HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to avoid using dynamic triggers?

01-11-2009, 07:56 AM#1
Vestras
Yeah, I'd like to know...
01-11-2009, 07:58 AM#2
Rising_Dusk
Name me one instance where you think you need them and I'll tell you why you don't.
01-11-2009, 08:01 AM#3
Vestras
I know I can use timers instead of death and range events and such, but yeah...
Dialog button events?

[offtopic]Why is there a new AotZ logo? :o[/offtopic]
01-11-2009, 08:01 AM#4
Rising_Dusk
No, I'm serious. It depends on what you're using them for.
Quote:
Originally Posted by Rising_Dusk
Name me one instance where you think you need them and I'll tell you why you don't.
01-11-2009, 08:04 AM#5
chobibo
How about damage detection? I'm just curious, no offense intended Dusk. Thanks!
01-11-2009, 08:10 AM#6
Rising_Dusk
There are multiple options for DDS':
  • Registering a single trigger to the system with numerous events attached to that trigger. This classically 'leaks' the events of units who die and are removed from the map. This can be fixed with a unit recycling system, as seen by moyack in the resource submission forum. I prefer this form, since leaking events for hundreds upon hundreds of units results in maybe 4kb of memory used at the end of a 45 minute game. Big deal.
  • Using a single trigger per system, such as with Anitarf's ADamage. This tacks a bunch of events to a single trigger for a single type of event, but that trigger is later on destroyed. This is not as evil as the third option, though, since it uses less than a dozen of them throughout the map. This doesn't leak events, so if you must use dynamic triggers do it this way.
  • A single trigger per unit in the map. This is awful because you're actually gouging the handle index count far more this way and doing more damage to your map than not. This prevents events from leaking, but results in your code doing a lot of trigger manipulation work that reduces efficiency. You also cannot safely destroy triggers without some overwrought multi-minute delay between their last use and destruction. It is a very inelegant solution.
I recommend the first option and use it myself.
01-11-2009, 08:33 AM#7
akolyt0r
Quote:
Originally Posted by Rising_Dusk
There are multiple options for DDS':
  • Registering a single trigger to the system with numerous events attached to that trigger. This classically 'leaks' the events of units who die and are removed from the map. This can be fixed with a unit recycling system, as seen by moyack in the resource submission forum. I prefer this form, since leaking events for hundreds upon hundreds of units results in maybe 4kb of memory used at the end of a 45 minute game. Big deal.
  • Using a single trigger per system, such as with Anitarf's ADamage. This tacks a bunch of events to a single trigger for a single type of event, but that trigger is later on destroyed. This is not as evil as the third option, though, since it uses less than a dozen of them throughout the map. This doesn't leak events, so if you must use dynamic triggers do it this way.
  • A single trigger per unit in the map. This is awful because you're actually gouging the handle index count far more this way and doing more damage to your map than not. This prevents events from leaking, but results in your code doing a lot of trigger manipulation work that reduces efficiency. You also cannot safely destroy triggers without some overwrought multi-minute delay between their last use and destruction. It is a very inelegant solution.
I recommend the first option and use it myself.

and what to do when you only need DamageDetection for ..lets say one spell, to know when some spell-missile hits the target ..?
01-11-2009, 08:41 AM#8
Fledermaus
Depending on the spell, you could just use a timer checking for a buff it leaves?
01-11-2009, 08:47 AM#9
Rising_Dusk
Quote:
Originally Posted by akolyt0r
and what to do when you only need DamageDetection for ..lets say one spell, to know when some spell-missile hits the target ..?
In general, with projectile spells, you don't need a DDS at all! I code all of mine in my maps without one being used. You can just do all of the happy IsUnitInRange() stuff on a timer callback.

If you need to detect when your hero attacks and deals damage to a unit for a custom on-attack passive, you will need a DDS. It is not a problem to use one, not at all. Some DDS' can be installed as necessary, and others are designed to be integrated into the map (but with the reward of being incredibly easy to use and control your map with). Is it a problem to use a system for one spell? No way! That the system exists means that if you do want to use it again, it's very easy to do so and you don't have to waste or copy/paste code! That's a good thing!

And seriously, the 4kb overhead (Let's point out that leaking a rect is already worse than that) is nothing. People overreact with the events, they're by far the lesser of the evils, if you can call them an evil at all in the first place.
01-11-2009, 08:53 AM#10
Vestras
I was serious about dialog buttons :s
01-11-2009, 01:27 PM#11
Vexorian
Doing any sort of silly thing for dialogs is... silly.

Notice this:

You can only show one dialog per player
01-11-2009, 01:35 PM#12
akolyt0r
Quote:
Originally Posted by Rising_Dusk
In general, with projectile spells, you don't need a DDS at all! I code all of mine in my maps without one being used. You can just do all of the happy IsUnitInRange() stuff on a timer callback.

IsUnitInRange on "real" projectiles ..doesnt work ..
01-11-2009, 01:37 PM#13
Vexorian
Not like dynamic triggers would be any help in that case.
01-11-2009, 02:43 PM#14
Flame_Phoenix
You can avoid dynamic triggers in all cases (or in most cases) except when making damage detection, in which case

Quote:
you have to pick your own poison
.

Rising_Dusk advices the use of DD systems for such a case, whereas I don't see any real advantage for doing so:
http://www.wc3campaigns.net/showthread.php?t=104036

For more information please see thread:
http://www.wc3campaigns.net/showthre...+triggers+evil

There is no specific scheme for avoiding dynamic triggers, it all depends on the case. See some of my spell, The "Stupid Penguin" was my first spell where I avoided the use of dynamic triggers using Table and TimerUtils.
01-11-2009, 04:27 PM#15
Rising_Dusk
Quote:
Originally Posted by akolyt0r
IsUnitInRange on "real" projectiles ..doesnt work ..
Quote:
Originally Posted by Vexorian
Not like dynamic triggers would be any help in that case.
______________________________________________
Quote:
Originally Posted by Flame_Phoenix
You can avoid dynamic triggers in all cases (or in most cases) except when making damage detection, in which case
Damage Detection is the only instance where a dynamic trigger even has reason to be used, but can and still should be avoided. Vexorian and I have long said that leaking the events is a nonissue.
Quote:
Originally Posted by Flame_Phoenix
you have to pick your own poison
I hope you realize you've been taking this quote out of context forever. Vexorian said that with regard to WHICH DDS you use, NOT with regard to dynamic triggers next to leaking events. The DDS' in the database are all designed in such a way to not use a trigger per unit, and God knows if any are I will unapprove them right now. (Note: ADamage does not)