Tutorial GUI - Triggering for Dummies (custom actions and functions)

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
Prerequisits:

In this tutorial we will be going over 2 things, custom actions and functions. These are very usefull because you can make it much faster to do more routine actions or create functions that get complex values with mathematics or even run off variables.

Actions

We will begin with Custom Actions. When you first create one (via right clicking the left hand box for triggers, highlighting new, and selecting New Action Definition. You should get a picture that looks like this on the right:

02.png

*Traceline is only the name of the function being made, it has nothing to do with what is actually in the function.

Each of these does different things but i will explain the most important parts first.
Returns and parameters: In custom actions you will not use returns, they are only for functions, but parameters are important to make your custom actions as versatile and fluid as possible. A parameter is essentially one of the red or green options on actions and functions that you fill in. It is a field custom to that specific instance of this action. It is similar to a local variable because it is attached only to a specific action. There are many types ranging from variable data types to presets (operators like !=, <=, ==, or true/false).

the parameter field should look like the local variable field in a trigger after you define some locals, like this:
Trigger:
  • Parameters
    • I = 0 &lt;integer&gt;
    • P = == &lt;Any Option Parameter&gt;


The next field we will look at is the Grammar Text. This is the field at the bottom of the trigger editor when you create a new action. As an example this should look like this:

Key_Stroke.jpg


where (All Players) and Debug are the default parameters, the green field is what they have already set, and any red paramaters are ones that must be set before the trigger containing the action can be activated, you can create these with paramaters that have the option no default value checked just above the default value when they are selected.
You set this by setting the Grammar Text field to whatever text you want without the parameters put in, include a space for each parameter, then go back and select it with the drop down menu on the bottom. This will input the parameter then walah, you action will look nice and pretty when you select it in the trigger editor.

The name of the Action is what will be displayed in the Editor when selecting an action, and if the function name is based off the action name, it will be the same as the name without any spaces. This is for use in custom text, you call that exact text to do this action.

Next is the Hint Text, that is simply the grayed out text along the bottom, telling what each action/function does.

Custom Text is a place where you can write out your actions rather than selecting them, but until the custom coding program for the galaxy editor is finished this wont be something to really get into.

Finally the local variables and custom actions. This part is essentially a trigger. The only difference is you can use the parameters as well, then when set by the user they will fill in the options set to those parameters.

Functions

In order for me to properly explain functions you must understand variables. Essentially a function is like a variable in that, they take something and return something. like this:

set variable X[index] = data type of the variable

function FunctionName takes Parameters returns data type of the return

so basically, a function with a return type of a unit, can replace a field in an action that requires a unit, like damage unit: the victim can be set to a custom function with a return type unit.

so now we will create an ability with a custom action and a custom function to fit our needs.
this ability will be based off the snipe ability (off the ghosts), the ability will do 2 things: Blink behind the target unit and then deal damage in an aoe. Think of how you could do that with 1 action and 1 function and try it out, then check this:

action:

Trigger:
  • Blink Area Damage
    • Return Type: (None)
    • Parameters
      • Blinker = No Unit &lt;Unit&gt;
      • Facing Point = No Location &lt;Location&gt;
      • Blink Point= No Location &lt;Location&gt;
      • Real = 50.0 &lt;Real&gt;
      • Integer = 2 &lt;Integer&gt;
    • Grammar Text: Moves Blinker to Blink Point facing Facing Point and deals Real damage in a Integer Radius.
    • Hint: Moves a unit to a point and deals damage in a radius around that point.
    • Local Variables
    • Actions
      • Unit - Move Blinker to Blink Point facing Facing Point
      • Unit Group - Pick Every unit within Real(Integer) of Blink Point matching conditions (Owner of Matching unit (==) enemy of Owner of Triggering Unit) and do actions
        • Loop Actions
          • Unit - Cause Blinker to damage Picked Unit dealing Real damage with the effect Psionic Storm (Damage)

function:

Trigger:
  • Point Behind Unit
    • Return: (Location)
    • Parameters
      • Unit = No Unit &lt;Unit&gt;
    • Grammar Text: Behind Unit
    • Hint: Gets the point behind the selected unit.
    • Local Variables
    • Actions
      • General - Return (Position of Unit offset by 1.0 in the direction of ((Facing Angle of Unit) + 180))

and here we wrap it all up nicely in a 3 element trigger:

Trigger:
  • Full Trigger
    • Events
      • A unit finishes casting an ability targeting a unit
    • Conditions
      • Ability being cast = Snipe (i forget the real name)
    • Actions
      • Unit - Move Triggering Unit to (Behind Target Unit of ability cast) facing (Position of Target unit of ability cast) and deal 50.0 damage in a 2 Radius

if you can get that without checking the spoilers first you are golden, now go out an use this to your advantage and create functions and actions that make your life easier :)

Here are some ideas you can try:

Easy:
A Damage action that avoids loops in triggers fired by damage by turning off the trigger it is in, dealing the damage, then turning the trigger back on.
A Deal aoe damage action targeting a point a radius and a source as the parameters
A function returning a point in relation to a unit specific to what direction it is facing, example above

Advanced:
A dialog box with all labels/buttons included with spacing based on the ammount of dialog items
A chain lightning action dealing damage to a target then bouncing to a max number of additional targets 1 at a time but never hitting the same target twice.
A function returning the damage reduction factor of a unit by dealing 1 damage to it then checking how much was actually dealt due to reduction, then setting the units health back to what it was

This goes on to:
  • WIP
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top