• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Events - Generic vs. Specific

Status
Not open for further replies.
Level 8
Joined
Oct 2, 2013
Messages
288
SO I understand that as far as Unit Death Event goes, it's best just to have 1 trigger for Generic Unit Death so I only have 1 event firing through-out my map when stuff dies.

But I was questioning this method since I end up filling a lot of conditions into one trigger to have certain things only happening for certain unit deaths.

So I had an idea with using this:
  • Trigger - Add to TriggerWithoutEvent <gen> the event (Unit - MyUnit Dies)
Basicly adding specific unit events through-out the gameplay to certain triggers. This way my triggers will know exactly when and what to do rather than checking through a line of conditions... I will end up with more triggers though but this seems convenient for managing purposes.
BUT from what I know these Events do actually leak unless the trigger is destroyed. It's not enough to remove the unit.

My question is: Is it heavier for the system to have a bunch of "invalid/dead" Specific Unit Events lying around compared to having a Generic Unit Death event that checks through many conditions to find out what to do.

Please let me know what you think. Thank you for looking into this!:)
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Go with the option which makes your life easier (until performance becomes an issue). It is true that taking care of all death stuff in one trigger would be more efficient in terms of used cpu clocks, but might hurt your brain.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,511
If you're worried about performance or just clutter, you can always store all of your triggers in Arrays and run them like functions:

Setup Trigger:
Map initialization

Set DeathTrigger[1] = Some trigger
Set DeathTrigger[2] = Some other trigger
Etc...

Death Trigger:
A unit dies

Run Trigger DeathTrigger[some unique value associated with the dying unit]
 
Level 8
Joined
Oct 2, 2013
Messages
288
I see. Thanks to the both of you! I'm glad to have a solution now at hand if it becomes a problem.
I am relieved to realize that it may not be the biggest of issues after all. It's really just a keep-in-mind thing if the map becomes really big and extensive. Still I like to keep things as quality as I can.

Thanks again. I consider my problem solved:)
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,191
My question is: Is it heavier for the system to have a bunch of "invalid/dead" Specific Unit Events lying around compared to having a Generic Unit Death event that checks through many conditions to find out what to do.
One could use Lua and construct a execution list per unit for a specific event. This way a single generic event can iterate the execution list and only execute sensible code. One can then remove functions from the execution list as desired.
 
Status
Not open for further replies.
Top