Warcraft III World Editor Tutorial – 11: Once-Only Triggers

As all of my other tutorials focus on a particular event to make them work, I thought I would dedicate one to making other events, picking up items etc. Mainly to illustrate once only triggers though!

Well, best go right into the deep end. If you’re looking at this, I’m assuming you’re not a complete trigger virgin, as it kind of starts quite deep anyway.

I will give you a few examples of using different events, and also making it a ‘once only trigger’

EXAMPLE 1

For the first example, I will show you how to run a quest by picking up an item; this trigger will only work once. For this trigger, you will need to make the following variable(s):

Variable Name – Variable Type – Initial Value
GotItem – Boolean – False

This variable will make the ‘once only trigger’ possible.

Before I continue, I would just like to point out that there is a way to simply turn off the trigger after use. I do not use this method, as it has not worked once in the past for me. Also the method I am about to go through is much safer. Now I will continue.

To start, you have to create a hero and an item in the World Editor to be selected for the use of the triggers. The item and hero do not matter, as long as the hero can actually pick up the item.

Now, open the trigger editor now (if you haven’t done so already), and create the following trigger:

Trigger Name:
– Item Picked Up

Events:
Unit – Paladin 0000 [gen] Acquires an item
– When the hero unit (in my case is a paladin) acquires an item…

Conditions:
((Item being manipulated) Equal to Ankh of Reincarnation 0001 [gen]) and (GotItem Equal to False)
– If the item being picked up is the selected item (in my case and Ankh of Reincarnation) is the one being acquired by the hero, AND the variable ‘GotItem’ is set to ‘False’…

Actions:
Set GotItem = True
– Sets the variable ‘GotItem’ to True, this is the key bit that makes the trigger non-repeatable, unless you reset the variable to false somewhere. This is the reason I use this method, so I can actually reset it easily.

Trigger – Run NewQuest (ignoring conditions)
– This simply runs the next trigger, which I just called ‘NewQuest’ for the sake of it! This is the safest way to continue with triggers after this trigger is no longer valid. The trigger ‘NewQuest’ could be your quest trigger that runs all of the quest actions etc.

Here is a picture of what my trigger looked like at the end (I know it says ‘Run (This trigger)’, it is because someone (Paul) was nagging me to get it finished quicker! – Sorry for the confusement):

11 - 01

And that’s really all there is to it! Extremely simple!

But, just incase you didn’t follow that any more than a blind man follows a finger, I will give you another example:

EXAMPLE 2

Hmm… For this next example, I think I will show you how to win by building a certain building. Just like building a wonder in Age Of Empires. For this trigger, you will need to make the following variable(s):

Variable Name – Variable Type – Initial Value
GotBarracks – Boolean – False

This variable will make the ‘once only trigger’ possible.

Now, open the trigger editor now (if you haven’t done so already), and create the following trigger:

Trigger Name:
– Barracks Built

Events:
Unit – A unit owned by Player 1 (Red) Finishes construction
– When a unit by player 1 has finished being built…

Conditions:
((Unit-type of (Triggering unit)) Equal to Barracks) and (GotBarracks Equal to False)
– If the unit built is a barracks (for me), and the variable ‘GotBarracks’ Is currently False…

Actions:
Set GotBarracks = True
– Sets the variable ‘GotBarracks’ to True, this is the key bit that makes the trigger non-repeatable, unless you reset the variable to false somewhere. This is the reason I use this method, so I can actually reset it easily.

Trigger – Run Victory for Player 1 (ignoring conditions)
– This simply runs the next trigger, which I just called ‘Victory for Player 1’ This is the safest way to continue with triggers after this trigger is no longer valid. The trigger ‘Victory for Player 1’ could be your victory trigger that runs all of the victory actions for player 1 etc.

Here is a picture of what my trigger looked like at the end (I know it says ‘Run (This trigger)’, it is because someone (Paul) was nagging me to get it finished quicker! – Sorry for the confusement):

11 - 02

Once again, that is all there is to it! Easier than taking candy from a baby! Although the second example will have to be repeated for each player that is in the game.

EXAMPLE 3

For this example, I will show you how to activate a trigger when a unit enters a region, and only activate once. For this trigger, you will need to make the following variable(s):

Variable Name – Variable Type – Initial Value
RegionDone – Boolean – False

Also, you will need a unit, I am using the same unit as in the first Example, my Paladin. The unit does not however need to be a hero unit, but can be any unit.

This variable will make the ‘once only trigger’ possible.

There are two ways to check the unit in this example, so only use one of the conditions. Not both. The first condition checks whether the unit that enters the region is owned by Player 1 (Red). The second condition checks to see whether the unit is a specific unit.

Now, open the trigger editor now (if you haven’t done so already), and create the following trigger:

Trigger Name:
– Enters Region

Events:
Unit – A unit enters Region 000 [gen]
– When a unit enters my selected region…

Conditions:
((Owner of (Triggering unit)) Equal to Player 1 (Red)) and (RegionDone Equal to False)
– If the unit is owned by player 1, and the variable ‘RegionDone’ Is currently False…
((Triggering unit) Equal to Paladin 0000 [gen]) and (RegionDone Equal to False)
– If the unit is my Paladin (that I also used in the first tutorial), and the variable ‘RegionDone’ Is currently False…

NOTE – Do not use both of the conditions in conjunction, they are not both needed (however they are together in the map I created, this is so I do not need to write two triggers).

Actions:
Set RegionDone = True
– Sets the variable ‘RegionDone’ to True, this is the key bit that makes the trigger non-repeatable, unless you reset the variable to false somewhere. This is the reason I use this method, so I can actually reset it easily.

Trigger – Run My Quest for Player 1 (ignoring conditions)
– This simply runs the next trigger, which I just called ‘My Quest’ This is the safest way to continue with triggers after this trigger is no longer valid. The trigger ‘My Quest’ could be your quest trigger, which runs the next part of the story in your map.

Here is a picture of what my trigger looked like at the end (I know it says ‘Run (This trigger)’, it is because someone (Paul) was nagging me to get it finished quicker! – Sorry for the confusement):

11 - 03

And there you go! Another example of a once only trigger, you must have got the hang of it by now.

There you go, three practically identical examples for the price of one!

Leave a Reply

Your email address will not be published. Required fields are marked *