Queue or Exclusive Triggers

From Staredit Network Wiki
Jump to: navigation, search

"Queue" or Exclusive Triggers is a good method to use if you want to:

  • Avoid conflicting triggers / conflicting conditions (for example: due to conflicting timing)
  • Place priority on a trigger to be activated before another trigger which meets the same conditions
  • To allow only the working of one trigger which meets the same conditions as any other trigger
  • To skip certain triggers (going down the list of triggers) which meet equal conditions
  • To enable or disable certain triggers or groups of triggers during the working of a particular trigger
  • "Wait" conditions (as opposed to wait actions)
  • "One Trigger at a Time Please"

This method is very effective when dealing with timing glitches of triggers which meet the same conditions or of a pair of triggers in which the later triggers' conditions depend on the previous triggers' actions. For example, when you don't want the later triggers to activate before the 1st trigger is finished.

How to:

One of the best things to use as a "queue" or exclusive trigger, is the death count. My favorite is the death count of the start location (you can use whatever unit you like).

Example:

Trigger("Player 1")
Conditions:
Deaths("Player 8", "Start Location", Exactly, 0);
Bring("Player 7", "Zerg Zergling", "Location A", Exactly, 1);
Switch("Switch0", set);
Actions:
Set Deaths("Player 8", "Start Location", Set To, 1);
Create Unit with Properties("Current Player", "Vulture Spider Mine", 1, "Location A", 1);
Set Switch("Switch0", randomize);
Set Deaths("Player 8", "Start Location", Set To, 2);
Preserve Trigger();
Trigger("Player 1")
Conditions:
Deaths("Player 8", "Start Location", Exactly, 0);
Bring("Player 7", "Zerg Zergling", "Location A", Exactly, 1);
Actions:
Set Deaths("Player 8", "Start Location", Set To, 1);
Give Units to Player("Player 7", "Player 8", "Zerg Zergling", 1, "Location A");
Set Switch("Switch0", randomize);
Set Deaths("Player 8", "Start Location", Set To, 2);
Preserve Trigger();
Trigger("Player 1")
Conditions:
Deaths("Player 8", "Start Location", Exactly, 2);
Actions:
Set Deaths("Player 8", "Start Location", Set To, 0);
Preserve Trigger();

In the example above, I have 3 triggers:

  • The 1st trigger and the 2nd trigger both have the exact same conditions, (except that the 1st trigger has one more additional condition: The Switch). If Switch 0 is set, then the 1st trigger will be activated.
  • The 2nd trigger will be activated regardless. This means that both triggers will be active at the same time (I don't want it to be). The death count of the Start Location for player 8 is used in both triggers (in the conditions, and at the beginning and end of the actions) to make it exclusive; that is: Only ONE trigger will be activated while the Other Skipped. Notice that when Switch 0 is set, the 1st trigger is activated; and the death count changes to exclude the very next trigger.
  • The 3rd trigger I used is only to "reset" the "queue".