HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Making an OnDamage Trigger that isn't dumb and laggy

06-24-2008, 11:15 PM#1
Burning Rose
So, as far as I know, due to Blizzard being dumb, the Only way to detect a trigger on damage is to loop through and add any units that are on the map or enter the map to a Trigger (Correct me if I'm wrong). This is Okay with a small map and one trigger. However, my map has a LOT of Units on it, taking frequent damage, and there are about 9 of these triggers in my map.

Of course, those of you who have played my map know that it is laggy. If you haven't, it is. Part of that is undoubtedly due to the amount of units, but I can't help but think that these triggers are also to blame. They have conditions, so the triggers don't run any actions most of the time, but I can't help but think that 9 triggers each checking their conditions whenever a unit takes damage would cause a large amount of lag.

I have a few Ideas, but I want to know if they would make a difference (Since I don't know how the Trigger-Engine works, I don't know if these would make a substantial change in lag.):
  • Disable unused Triggers. The triggers would start disabled, and when a Player selected the Hero that used it, they would be enabled. Two Problems: When all the right heroes are selected, there is no change. In addition, I don't know if a Disabled Trigger can still cause lag.
  • Combine the Triggers. I could combine them all into one trigger that runs when a unit takes damage, and then use conditions to do the right effects. This would be messy for me, however, and I could easily screw it up.
  • Make a 'Router' Trigger. Similar to the last Idea, it would be the only one that fired. It would only fire if one of the many spell conditions was met, and then check to see which it was, and run that trigger with all the right information. This would also be messy, however, because it would require me to turn many of the Triggers into just functions, and I may have compiling errors if I try to keep my in-editor Organization.

If you all have any better ideas, of course, I'm open to any. They can be really complex if necessary, as long as someone can walk me through it :o

The Triggers that enter the events, if it matters:

Hidden information:
Trigger:
Glacimancer 1st
Collapse Events
Time - Elapsed game time is 0.01 seconds
Conditions
Collapse Actions
Set TPUG = (Units in (Playable map area))
Collapse Unit Group - Pick every unit in TPUG and do (Actions)
Collapse Loop - Actions
Trigger - Add to Glacimancer 3rd <gen> the event (Unit - (Picked unit) Takes damage)
Trigger - Add to Glacimancer 3rd Copy <gen> the event (Unit - (Picked unit) Takes damage)
Trigger - Add to Chaos Strikes <gen> the event (Unit - (Picked unit) Takes damage)
Trigger - Add to Seal of Sacrifice <gen> the event (Unit - (Picked unit) Takes damage)
Trigger - Add to Focused Ambush <gen> the event (Unit - (Picked unit) Takes damage)
Trigger - Add to Mana Storm Drain Mana <gen> the event (Unit - (Picked unit) Takes damage)
Trigger:
Glacimancer 2nd
Collapse Events
Unit - A unit enters (Playable map area)
Collapse Conditions
(Unit-type of (Triggering unit)) Not equal to caster (Caster System)
(Unit-type of (Triggering unit)) Not equal to 30 Charges
(Unit-type of (Triggering unit)) Not equal to 5 Charges
(Unit-type of (Triggering unit)) Not equal to 7 Charges
(Unit-type of (Triggering unit)) Not equal to HERO (Battle Trainer 1)
(Unit-type of (Triggering unit)) Not equal to HERO (Cone of Cold)
(Unit-type of (Triggering unit)) Not equal to HERO (Fire-Eater)
(Unit-type of (Triggering unit)) Not equal to HERO (Ice Armor)
(Unit-type of (Triggering unit)) Not equal to HERO (Mayhem 1)
(Unit-type of (Triggering unit)) Not equal to HERO (Submerge)
(Unit-type of (Triggering unit)) Not equal to HERO (Test)
(Unit-type of (Triggering unit)) Not equal to HERO (Weatherking)
(Unit-type of (Triggering unit)) Not equal to Less than 30% Health
(Unit-type of (Triggering unit)) Not equal to THunderstorm (Weatherking)
(Unit-type of (Triggering unit)) Not equal to Mana Storm Bit
Collapse Actions
Unit Group - Add (Triggering unit) to TPUG
Trigger - Add to Glacimancer 3rd <gen> the event (Unit - (Triggering unit) Takes damage)
Trigger - Add to Glacimancer 3rd Copy <gen> the event (Unit - (Triggering unit) Takes damage)
Trigger - Add to Chaos Strikes <gen> the event (Unit - (Triggering unit) Takes damage)
Trigger - Add to Seal of Sacrifice <gen> the event (Unit - (Triggering unit) Takes damage)
Trigger - Add to Focused Ambush <gen> the event (Unit - (Triggering unit) Takes damage)
Trigger - Add to Mana Storm Drain Mana <gen> the event (Unit - (Triggering unit) Takes damage)


Thanks, this lag is the biggest problem in my map and I would be ecstatic if I could fix it :)
06-24-2008, 11:38 PM#2
Anitarf
To solve the lag issue, reduce the number of units on the map or learn to use Jass.
06-24-2008, 11:39 PM#3
Rising_Dusk
The obvious solution is to not add it to 9 triggers. The even better solution is to use this system and be able to run up to 8190 different triggers while only adding events to one.
06-25-2008, 12:37 AM#4
Burning Rose
Well, I know enough JASS to fix leaks...

I'll look at that system, Hope it isn't too big, map size is pretty hefty already :(.
...
Okay... yeah... that would require a lot of work... I may do it, but I was really more looking to see if what I suggested would do anything?

PS: I do appreciate the response, but most of the map is already set up without Triggered Damage, and it would be one hell of a pain to change it all. However, if I make another map (Which I probably will), you can bet that will be used. In addition to ABuff, when I figure out enough JASS to not be intimidated by it (or, say, to know what a "scope" or "library" is >_>)
06-25-2008, 06:42 AM#5
cohadar
Quote:
Originally Posted by Rising_Dusk
The obvious solution is to not add it to 9 triggers. The even better solution is to use this system and be able to run up to 8190 different triggers while only adding events to one.

That system is no better than any other damage detection sys out there.

The lag in the map is produced by number of units because of game pathing AI.
I learned from experience that damage detection engine is really a minor issue when it comes to lag.

ENFO's team survival is a great example of this, it has no DD engine (it barely has any custom spells) and it still lags like shit when number of creeps too big.

Now you CAN make a map with lot of creeps and with no lug BUT:
there must be no choke points.
If for example creeps are ordered to go from point A to point B but something gets in their way (for example heroes defending a narrow path) the other creeps will start a "maze search" to get to point B with alternative route.
If no such route exists game starts to lag because it tries to calculate the path over and over again.

This calculation needs not only to involve the pathing of the terrain but also the pathing of all units on the map (that move around constantly) so it creates huge lag when there are too many units.

There is one simple solution, if you know that on route from A to B creeps can get stuck at point C recode your rally engine to order the creeps in sequences, A to C, C to B.

In fact it is best that distances between rally points be short as possible and preferably strait lines.
06-25-2008, 08:23 PM#6
Burning Rose
Hmmm.... Alright then... I'll try that. thanks, That's what I wanted to know :)
06-25-2008, 09:09 PM#7
Vexorian
Quote:
So, as far as I know, due to Blizzard being dumb, the Only way to detect a trigger on damage is to loop through and add any units that are on the map or enter the map to a Trigger (Correct me if I'm wrong). This is Okay with a small map and one trigger. However, my map has a LOT of Units on it, taking frequent damage, and there are about 9 of these triggers in my map.
Though Cohadar ellaborated on the reason. After reading this paragraph I needed to say there is no reason the event registration would cause this lag, first of all the "loop through any units that are in the map" often happens only on map initialization. After that it is just region enters events, the registration of the event is likely not to be much heavier than the whole unit creation, so there really was no relation. The only other way a damage detect engine would affect you would be if you had 100s of units being attacked simultaneously and the trigger you are firing is VERY heavy. But otherwise...
06-26-2008, 02:31 AM#8
Strilanc
Quote:
Originally Posted by cohadar
The lag in the map is produced by number of units because of game pathing AI.
I learned from experience that damage detection engine is really a minor issue when it comes to lag.

This is wrong. Pathing does play a huge role, but damage events are not negligible.

Point in case: power towers. In version 1.24 I put damage events on all runners. In version 1.25 I only put damage events on runners that had damage-triggered abilities (feedback, shield). The difference in cpu lag on non-ability rounds is _incredible_. 20 fps instead of 1 fps (note: old computer, late in the game with 8 players).
06-26-2008, 08:25 AM#9
cohadar
Quote:
Originally Posted by Strilanc
This is wrong. Pathing does play a huge role, but damage events are not negligible.

Point in case: power towers. In version 1.24 I put damage events on all runners. In version 1.25 I only put damage events on runners that had damage-triggered abilities (feedback, shield). The difference in cpu lag on non-ability rounds is _incredible_. 20 fps instead of 1 fps (note: old computer, late in the game with 8 players).

You know using DD only on units that need it is kind of common sense so all you are saying is that DD can lag if you use it in not-so-bright way....
06-26-2008, 06:03 PM#10
Strilanc
Quote:
Originally Posted by cohadar
You know using DD only on units that need it is kind of common sense so all you are saying is that DD can lag if you use it in not-so-bright way....

No, I'm saying that damage events are not negligible, even if you use them "brightly". My frame rate still tanks on rounds with abilities.
06-27-2008, 06:35 AM#11
cohadar
Quote:
Originally Posted by Strilanc
No, I'm saying that damage events are not negligible, even if you use them "brightly". My frame rate still tanks on rounds with abilities.

Elemental TD does not have that problem....
06-27-2008, 08:25 AM#12
Strilanc
Quote:
Originally Posted by cohadar
Elemental TD does not have that problem....

My frame rate tanks in elemental td later on, too.

(Having an older computer makes these things a lot more obvious.)
06-27-2008, 10:15 AM#13
TheDamien
I agree with Strilanc. Element TD seems (note italics) to be poorly made. The framerate frequently dips - especially later - and the reviving creeps cause massive lag (I am not even sure why this is). It isn't uncommon to see about half the players drop after the first undead round.
06-27-2008, 03:32 PM#14
Joker
Elemental TD is made in GUI though, right?
06-27-2008, 04:49 PM#15
TheDamien
4.0 is in vJass, AFAIK.