• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

a basic question I wanted to ask for a long time now

Status
Not open for further replies.
Level 4
Joined
Feb 4, 2014
Messages
50
Hello,

for a long time now there was a question on which I wish to know the answer.

How does a generic unit event work?
Let's say I have a condition for a generic unit event - unit type comparison:

- is the game first checking every unit on the map and then checking if all conditions were met?
- is it first checking conditions and than somehow miraculously applying operations pinned to it?
- are these mechanics working on a completely different principle?

I search for the answer for a reason.
I wish to know if it's fine to have a dozen triggers with generic unit events doing condition checking for every unit on the map simultaneously.

I appreciate your effort in advance. Explaining things isn't exactly something most people enjoy.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Whenever the event is satisfied (say, a unit is issued a point order), the game runs the conditions, and if they're satisfied it runs the actions. Any checking to see if the event itself is satisfied is done much more efficiently than the rest of the process since it isn't running in JASS.

Either way, you can pile up silly amounts of generic unit events without noticeably affecting performance, so don't worry too much about it.
 
If you choose generic unit event "A Unit Dies" then your trigger gets triggered when ever a unit dies. There is no check here.

Now you have the "Triggering Unit". So again no check.

If you add a boolean comparisson for example "Triggering Unit Is a Hero == true" you only check the single unit: "Triggering Unit".

Usually its recommended to use as less same events as possible, but yes you can use it more often without any problems in more triggers. <-- was said already
 
Level 30
Joined
Nov 29, 2012
Messages
6,637
is the game first checking every unit on the map and then checking if all conditions were met?

As far as I know, they do. Generic Unit events refers to all units.

is it first checking conditions and than somehow miraculously applying operations pinned to it?

Yes, it does check the conditions. Most does that before applying the Action, the Event and Conditions were being checked first unless there is a trigger before that which made this trigger run IGNORING CONDITIONS though.

Overall, generic units works like its partner specific unit namely but for obvious reasons, they differ on how it is being checked. Generic Units checks all units in map that are dying, starts an effect of an ability and etc. while specific unit does that as well but focuses more on a specific target or unit.
 
Level 10
Joined
Apr 18, 2009
Messages
601
If you choose generic unit event "A Unit Dies" then your trigger gets triggered when ever a unit dies. There is no check here.

Now you have the "Triggering Unit". So again no check.

If you add a boolean comparisson for example "Triggering Unit Is a Hero == true" you only check the single unit: "Triggering Unit".

This. This is how you should think about it.

A trigger with the event "A unit dies" will get triggered, will run, every time a unit dies, right? You should think about it like this and not how many units are checked or whatever. By using the event "A unit dies" you bind the occurrence that a unit dies within your map to this trigger. When a unit dies in your map then immediately your trigger will know which exact unit it was that died, because it was that unit that gave rise to running the trigger in the first place. This is why you can use "Triggering Unit" directly in the trigger conditions for example.

So if you wonder if a trigger will take much performance think about it this way: "how many times will this trigger run?". If the trigger runs very often (like those "every x second" thingies for example), then think about how efficient the code within the Actions-body of that trigger is. Really you shouldn't need to worry too much about any of this though. Like people already said you can use large amounts of generic unit triggers for example.
 
Level 4
Joined
Feb 4, 2014
Messages
50
Thank you all, when I read all of your posts, it got to me pretty fast and then I read Licheus's post and I connected everything the rest of you stated.

I used to think about it the way a generic unit event checks all units on the map and then figures out which one died. Well now when you showed me I can't believe I didn't figure it myself :)

The question is answered and understood. Thanks again.
 
Status
Not open for further replies.
Top