Triggers

By Cheetah

Image 1

Now that we've placed some units, groups and waypoints on the map, it is time to make the mission more dynamic. Waypoints will ensure that groups and units move around, triggers can delay the activation of waypoints for example. However, they can do a lot more than that, use them to tick off objectives or end the mission.

The trigger dialog (Image 1) is the most complex dialog of the editor, so pay attention. Once you are used to using triggers, you have a lot of additional power in your hands when it comes to developing missions.

Image 2
  • Axis- If ellipse: horizontal (axis a) and vertical (axis b) radius. If rectangle: half of the sides; horizontal (axis a) and vertical (axis b).
  • Angle- Angle at which the trigger will be placed. Useful if using a rectangle or ellipse shaped trigger.
  • Ellipse/Rectangle- Trigger shape.
  • Activation- Select the side or radio that can activate the trigger. Or none (put in a proper condition).
  • Once/Repeatly- Select how many times the trigger can be activated after it its deactivated. So a trigger will not activate if it is not previously deactivated.
  • Present/Not present/Detected by- Select if the trigger is activated upon a present or not present condition. Or select by who the activation unit should be detected.
  • Countdown/Timeout- With timeout you want the condition to be true for a number of seconds. Select countdown if you want effects to take place with a delay.
  • Min-Max-Mid- Minimal, Maximum and Middle waiting time. The engine will determine a (random) calculated average of the three values.
  • Type- Use Guarded by if you want groups with "GUARD" waypoints to visit the trigger radius, use switch to skip waypoints, including the endless ones - the swith will "jump" over the next waypoint to the waypoint where the trigger is synchronized. For example: if you have a hold WP followed by a move WP, a group will always stay at the hold WP. If you switch the hold WP with a switch trigger, the hold WP will be skipped as soon as the trigger's condition is met. Use the Ends to end the mission after the conditions have been met.
  • Name- Unique name for the trigger. You don't have to add one.
  • Text- Use this to remember what the trigger does, doesn't have to be unique (Image 2). And will be displayed when used for the radio.
  • Condition- When should the trigger be activated. Should be "this" if it is dialog determined, "true" if always activated and a special command if activated upon some other event (see Chapter 7). Use "this && CODE" or "this AND CODE" when both conditions have to be met. Use "this || CODE" or "this OR CODE" when only one of both conditions has to be true.
  • On Activation- Insert commands (see next Chapter) that should be executed once the trigger gets activated.
  • On Deactivation- Commands that should be executed as the trigger gets deactivated (from a true condition to a false one).
  • Effects- Same as with waypoints, contains a lot of options to make ingame cutscenes and play voices / music.
Image 3

Now that you have a basic sense for the trigger options, it is time to start adding triggers to the mission. We will need them for the objectives, for reinforcements and a savegame. What you have to keep in mind, is that triggers involve some commands available in the ArmA world. You can find them in the OFPEC COMREF.

Let's start with the objective triggers. The first objective involves blowing up the Shilka, we need to check when that is done. To do so, place a trigger somewhere on the map. Check Image 3 for its properties. Notice that I set Axis a and b to 0, I usually do so to make it easier for me to notice that the trigger doesn't require a radius to work. Don't forget to give it a proper "Text", it should help you remember what the trigger is for in the future. Finally, the most important lines of the trigger:
Condition: !(alive tank) - notice that we called the Shilka "tank" in the unit chapter. The unique name "tank" can be used for several commands (available in the COMREF). With "alive" we get a true or false depending on if the shilka is alive or destroyed. The exclamation mark (!) is used to specify "NOT". So in words the condition is the same as: check if the shilka is not alive. Once that line is true, the trigger will be executed.

Image 4

That brings us to the On Activation Field. Once the Shilka has been blown to dust, we want the objectives to be updated. These will later be added in the briefing (see Chapter 9). The command to use is "0" objStatus "DONE". With it, the 0th objective will get a status called "DONE". This will automatically display a hint on the screen "Objectives Updated". To keep track of which objective has been completed, we will include a variable. The line "obj0_done=true" will store "true" in a box called obj0_done. Later, we can ask obj0_done what its value is and depending on the output, we can end the mission or not.

Now, let's proceed with the second objective. As both are pretty similar, this trigger will be easier. The only lines that have to be changed are the Condition and On Activation fields. As you can see in the picture, for this objective, we want to know whether the officer has been killed or not. If he has been killed, we want the objective to switch to "completed" and the variable set to true.

Image 5

Let's hit preview and check what we have just done. Upon destroying the Shilka or eliminating the officer, you will see a hint appear in the top left corner of the screen, telling you that your objectives have been updated. Not much of a change so far, however, with the triggers you just made - the objective will tick off once we add the briefing.

To make the mission a bit easier for the player, we are going to include a savegame. To do so, let's place a trigger, somewhere on the map. In Image 5 you will see what line you should add in the condition field. We are going to check if one of the two variables - determining if an objective has been completed - switches to true. The word OR, between the two variables allows the trigger to get activated even if only one of the two objectives has been completed. In English, the condition states: if obj0 or obj1 is done, active. Upon activation, "saveGame" will get activated. This is a command found in the COMREF, used to save the game. Finally, switch the trigger to "countdown" and add min-3, max-3 and mid-3 to have 3 seconds of delay before the game will be saved.

NOTE: obj0_done and obj1_done are chosen so that we know what they represent. We could have used any name, as the name doesn't have any special value or function.

Image 6

If you preview the mission again, you will notice that upon eliminating either the officer or the Shilka, nothing happens. That is because variables have to be initialized, to do so. Open up the player's unit and add the following to his init line: obj0_done=false; obj1_done=false; (Image 6). That should trigger the savegame after completing one of the objectives. Notice that we could have added the "saveGame" command to any or both of the triggers that activate upon the objective getting completed. I chose not to, because I want the game to be saved once any objectives gets ticked.

Image 7

Let's continue with all this objective stuff, we still need a trigger that ends the mission. To end the mission, the player has to be at sea (near the extraction marker) and the two objectives have to be completed.

Create a trigger in the center of the evacuation marker, with the properties as shown in Image 7. Note that the trigger will cover as much ground as the marker does, also note that we set a coutdown to prevent the mission from ending straight away. Notice the condition, "this" refers to the player being present, we have come across the other two before. This line checks if the player is present and the two objectives have been completed.

If all conditions are met, the mission will end (type: End#1). You may have noticed that there are multiple ends, all end the mission, the difference lies in the text shown in the debriefing. In the briefing.html, you can set multiple endings (different texts) for the debriefing.

This trigger won't be able to detect if the player is inside, because no activation has been filled in. We have two options, the first is to set activation to BLUFOR. It will then activate upon the player entering the trigger as he is on the BLUFOR side. However, to make the trigger more unique, we will synchronize the trigger and the player's unit. By doing that, the activation will switch to "vehicle" resulting in the trigger only activating upon the player's presence.

Image 8

To do so, select F2 or groups and group the player and the trigger by drawing a line between them (Image 8). This should create a blue line between the trigger and the player's unit. If you open up the trigger's dialog, you will see that the activation has been switched to "vehicle". With this done, the mission should end upon completing both of the objectives and making it back to open sea - alive.

Do you remember the group of reinforcements we put southeast of the fishing village? At the moment, they will run towards the village immediatly, however, we want them to act as reinforcements. To achieve that, we need a trigger to put them on hold until a certain condition has been met. Important to start with is the think of the condition that has to be turned to true.

Image 9

Maybe when the player has been detected? Or after completing an objective? Possibly a timed trigger after a few minutes? There are numerous possibilites, here we will use a trigger that activates upon the player getting detected. To do so, place a trigger in the center of the fishing village. The properties are listed in the image to the right.

Image 10

We need the trigger to cover the fishing village and some of its surroundings, so make it a 150 x 150 ellipse. Activated by BLUFOR - "Detected by OPFOR" (Image 9). That is all we need for the trigger, its condition will switch to true (thus activating the trigger) once any OPFOR units see the player (BLUFOR unit) in the trigger's radius. In the chapter about synchronizing (Ch. 8) we will link waypoints and triggers.

You may have noticed that the mission is pretty easy in its current state. So let's add another group of SLA soldiers. To speed up their arrival on the scene, we will put them in a truck.

As you can see in the image above (Image 10), we place a custom SLA infantry group, a Ural (empty) and then use waypoints to direct the group's movement. First, we place a move waypoints close to the starting position of the group. We will later use this waypoint to synchronize it with the trigger that will be used as a countdown mechanism. The group will move towards the fishing village after 30 seconds of waiting outside the truck.

Image 11

First the waypoints, place one "MOVE" close to the group (as shown in the image above). Then place a "GET IN" waypoint directly on the empty Ural to make the group board the Ural. Place a "GET OUT" waypoint close to the fishing village to let all the men disembark before entering the village. Finally, place a "SEEK AND DESTROY" waypoint in the center of the village. Notice that we haven't set any of the special attributes available in the waypoint dialogs, we don't need any because player's only interaction with the group should be when they enter the village.

Now it is time to place a trigger that will act as a countdown mechanism. As you can see in Image 11, only a few fields have to be changed from default. Optionally, you can set axis a and b to 0 as we won't need a trigger radius (nothing to detect). Set the countdown to 30 seconds (all three fields), give it a proper "text" to know what the trigger is for and most important: set the condition to "true". This will activate the trigger immediatly, starting the countdown as soon as the mission starts. We will synchronize the trigger and waypoint in Chapter 8 (synchronize).

Image 12

Remember the spy we placed? It is time to add a dialog when the player approaches him. To do so, create a trigger with axis a and b se to 3 and put it over the spy. Then, group (draw a line with F2) this trigger with the player. This will switch the activation to "vehicle" (as explained in Ch. 4 Groups). Next, create a game logic (unit dialog) near the spy. A game logic can be considered an invisible unit. It can take up a position in a truck, can be given waypoints and is used a lot to get the position of a position.

Now, give the game logic a waypoint a few metres to the north (type: AND) and synchronize the trigger and the waypoint you just placed (Image 12). Because of the AND waypoint, both the waypoint and the trigger will have to be true in order for the waypoint to activate (On Activation gets active after the condition is true). So by synchronizing it with the trigger, which activates when the player is inside, the conversation only starts once the player is near the spy! However, we don't want the conversation to take place if the spy gets shot - for example by the player. Therefore, create another trigger (axis a+b can be set to 0); go the its condition field and type:
alive spy;. Next switch activation from 'Once' to 'Repeatly'. If you don't, the trigger will switch to true as the spy is alive at the start of the mission. With 'repeatly', the trigger will keep checking and returns false if the spy is dead.

Synchronize the trigger with the waypoint of the game logic and voila! You have just create a multi conditional waypoint, the conversation will only start if: the player is inside trigger A and if the spy is still alive (image).

Image 13

Right, the dialogue with the player - it will be short, but if completed hidden US reinforcements will move in to aid the player in his quest! Open up the first waypoint for the game logic and go the its On Act. field. Type:
titleText ["Spy: Hello, you must be the SF Commando!","PLAIN DOWN"];
This will display a text on the bottom of the screen as soon as the player is near the spy. Why not add a bit of music too? Go to the effects button of the waypoint and select track "Team Alpha" (Image 13). This will play the music as soon as the conversation starts, notice the tiny blue camera displayed as soon as the effects are used.

Image 14

Now, let's add another waypoint, type can be AND or OR. As it should activate only after the player had the time to read the text, go to the min-max-mid fields and set them to 6. This gives the player 6 seconds to read the text before triggering the next. In the On Act. field:
titleText ["And you are.. a deserter?","PLAIN DOWN"]; - min/max-mid: 6
Go to the effects button once more and switch on "trigger -> bird singing". This will make a bird singing sound to displayed as soon as the 2nd message is displayed.

Do the same (create waypoints with min-max-mid) for the following texts (Image 14):

  • titleText ["Spy: No, I'm a US spy. Actually, because of me you are here, HQ needed someone to eliminate the officer - information passed by me.","PLAIN DOWN"]; - min/max/mid: 4
  • titleText ["Spy: Don't waste more time, enemy reinforcements are moving in as they intercepted a radio message.","PLAIN DOWN"]; - min/max/mid: 12
  • titleText ["Alright, I will move.","PLAIN DOWN"]; - min/max/mid: 10
  • titleText ["Spy: Don't worry, there are more US SF operators on Rahmadi. I will direct them to the fishing village. Now move out.","PLAIN DOWN"]; - min/max/mid: 3
  • titleText ["Thanks!","PLAIN DOWN"]; - min/max/mid: 11
  • Finally, create a AND waypoint. No special settings.
Image 15

So what we want now is to have two friendly squads moving in, place two three man teams. Set their skill level to 75% and place a Sgt. SF Assault, one Cpl. and one Pvt. SF Saboteur. Now copy the group and paste one a few hundred metres to the north or south. Place a waypoint for each group, a few metres in front. Settings: "type: MOVE", "speed: Full","behaviour: Aware","combat mode: Open fire". Now, synchronize both waypoint with each other, and synchronize each of the waypoints with the last waypoint of the game logic. Effectively creating a triangle.

This is called "WP synchronization" causing waypoints only to be completed when all the others are ready too. Thus, resulting in the groups advancing at the same time after the conversation has finished. Add two more waypoints for each group, first create one half way (type: MOVE) with default settings and synchronize these waypoints (Image 15). Then create Search and Destroy markers in or around the fishing village. We have now created US reinforcements for the player upon having the conversation with the spy.

You now have a basic knowledge of triggers, this will help you with a lot of dynamic stuff in missions as well as getting a mission to end properly and objectives which should tick off. In the next chapter, we will be placing a few triggers and other objects before experimenting with some commands available in the Armed Assault engine and editor.

Should anything so far be left unclear, please take a look at the ExampleMission added in the package of this tutorial. Called: "ExampleMission.Intro", located in the folder "examples".