HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How are triggers handled by the WC3 engine?

09-07-2002, 10:21 PM#1
Guest
I couldn't find any information in the forums about how the triggers are actually handled by the WC3 engine. Is each trigger called each and every time an event like "Unit Aqquires an Item" occurs? Example:

"Event: Paladin Aqquires an item"

or

"Event: Paladin 001 <gen> Aqquires an item"

If a Mountain King aqquired an item, would both triggers be checked to see if the unit that aqquired an item was a Paladin? If a Paladin aqquired an item, would there be a boolean comparison in the second trigger to see if it is Paladin 001 <gen>?

IE, are the triggers checked by switches or boolean comparisons, or is some more efficient method used?

I am really looking to see if these types of triggers:

-----------------------------------------------------------------
Trigger 1 - Event: Paladin 001 <gen> Aqquires an item
Condition: Item-Type is "Pizza"
Action: Game Text - "Paladins don't like Pizza"
Trigger 2 - Event: Jaina 002 <gen> Aqquires an item
Condition: Item-Type is "Pizza"
Action: Game Text - "Sorcoresses love Pizza"
Trigger 3 - Event: Storm King 003 <gen> Aqquires an item
Condition: Item-Type is "Pizza"
Action: Game Text - "Mountain Kings order out"
Trigger 4 - Event: Far Seer 004 <gen> Aqquires an item
Condition: Item-Type is "Pizza"
Action: Game Text - "Farseers are allergic to Pizza"
Trigger 5 - Event: Blademaster 005 <gen> Aqquires an item
Condition: Item-Type is "Pizza"
Action: Game Text - "Blademasters slice their own Pizza"

------------------------------------------------------------------

is better then just this modular one:

------------------------------------------------------------------
Trigger 1
Event: A unit owned by Player 1 Aqquires an item
Event: A unit owned by Player 2 Aqquires an item
Event: A unit owned by Player 3 Aqquires an item
Event: A unit owned by Player 4 Aqquires an item

Condition
Item-Type is "Pizza"

Action
Game Text - PizzaStrings[Player Number(Triggering Player)]
----------------------------------------------------------------------


Where "PizzaStrings" is defined somewhere else. I like to make my maps as modular as possible (since its easier for me to make larger changes), but I do not want to decrease the preformance during multiplayer.
09-08-2002, 02:38 AM#2
Newhydra
That won't make a difference in speed. It really won't. However, the second one has the slight problem of if you give the farseer to player one it prints the wrong message...
09-08-2002, 06:20 AM#3
Guest
The idea was for the second trigger, "PizzaStrings" was already defined for what unit type is owned by the player. I am looking at this from the standpoint of an RPG, so the player wouldn't have more then one hero unit.

Hmm, I guess I'll experiment more thoroughly during the map's beta testing period.

Oh, and "PizzaStrings" won't be in the RPG ;)
09-08-2002, 08:14 AM#4
Guest
I really have no idea how the game handles registered triggers, but I would assume that with each "cycle" is checks each registered trigger to see if it has occured. If it has, then it will check the conditions to see if they are true.

In your example, I can't see it making 1 bit of difference in terms of speed.

BTW, you wouldn't use Triggering Player there, it would be Owner of Triggering Unit.
09-08-2002, 03:58 PM#5
Guest
Yes I know, I was just making some hastily-put together psuedo-code. Thanks, though...like I said, I'll have to see during beta.