HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Recording Unit Damage

02-19-2004, 02:30 AM#1
RaeVanMorlock
Is there anyway to find the amount of damage an attack does to a unit? I can see there's an event response for it, given by the "Unit takes damage" event, but that event is only available under Specific unit events -- what about General unit events? I don't think it'd be good for my map to add an event for every specific unit created whose damage I need to record -- that could easily exceed 1500 units in any single sitting.
02-19-2004, 02:33 AM#2
Vilkacis
create a unit group for it and add em all to the group?
02-19-2004, 02:33 AM#3
linkmaster23
Yes, just set the units health to a variable, then when its attacked, set the new life to a new variable, and subtract the two. Then set the result to the DMG Variable. Answer your question?
02-19-2004, 02:38 AM#4
RaeVanMorlock
Quote:
Originally posted by linkmaster23
Yes, just set the units health to a variable, then when its attacked, set the new life to a new variable, and subtract the two. Then set the result to the DMG Variable. Answer your question?


Umm.. that'd require the foresight to know which unit was going to be attacked, and the ability to retain such information over a period of time.


I could have as many as 2412 units on the map at once whom could potentially all need to have their damages recorded.
02-19-2004, 02:39 AM#5
Vilkacis
WOw, over 2k triggers being fired at once with caz UBER AMOUNTS OF LAG!!!!...Why do u need to do this anyway?
02-19-2004, 02:46 AM#6
RaeVanMorlock
Quote:
Originally posted by Vilkacis
WOw, over 2k triggers being fired at once with caz UBER AMOUNTS OF LAG!!!!...Why do u need to do this anyway?



I think the applications are infinite -- restoring life based on a percentage of damage dealt, simulating a fully-customizable "splash" effect, simulating critical strike-type damage, storing the amount of damage a player deals in any game as a way of measuring his prowess...


Also, the trigger wouldn't fire 2000 times simultaneously unless all 2000 units on the map attacked at the same time. And even then, if the trigger is only a line or two long, it wouldn't be all that bad (we are talking worst-case scenario here -- it's not something that'd happen often).
02-19-2004, 02:48 AM#7
Vilkacis
Quote:
Originally posted by RaeVanMorlock
I think the applications are infinite -- restoring life based on a percentage of damage dealt, simulating a fully-customizable "splash" effect, simulating critical strike-type damage, storing the amount of damage a player deals in any game as a way of measuring his prowess...


I did not get one word of that, so u mean it wont caz lag? The splash thing is hardcodded, so naturally it dont caz lag...this is not.
02-19-2004, 02:55 AM#8
RaeVanMorlock
I'm not referring to my own map, but some examples of the above that would not be possible with the editor:



You could create a splash effect that hits up to 10 units within 200 range of the target, dealing 5% less damage each time.

Also, splash damage isn't upgradeable, as far as I've ever been able to tell. If you could create your own splash effect, you could upgrade the percentages done and increase the AoE with each level.



For crit strike, you could give it like 50% chance to deal 2 times damage, 10% chance to deal 3 times more damage, and 1% chance to deal 10 times damage. So then when the unit strikes, calculate a random number from 1-100. If it's 1-50, multiply damage by 2, 51-61, multiply damage by 3, and if 62, then multiply it by 10.... ya know?



If a unit is attacked and lives, you could restore say... 100% of the damage dealt. This way, only lethal damage could kill the unit. Granted, you could just fill his life -- but what if the effect only lasts for a short amount of time, then you'd be giving him full life instead of the amount of life he had when he turned on the ability. Or what if you only wanted to restore 50% of teh damage? Or only have it work when a certain type of unit attacked him?





As for lag, just let me worry about that.
02-19-2004, 02:59 AM#9
Vilkacis
errr....ok...i kinda get you...did you figure out how to solve ur problem yet?
02-19-2004, 03:06 AM#10
RaeVanMorlock
lol no, that's why I asked the question here.
02-19-2004, 07:35 PM#11
linkmaster23
It will still work... and it will only take 1 trigger... SIGH. I'm bored, I'll do it for you.

Well as always, I was right. Just kidding. I told you it would take 1 trigger, it did... I told you it would take 3 variables, I lied, it took 1 array. It will work for as many uints as you need. So, have fun and remember, always trust the Slayers.
02-19-2004, 07:35 PM#12
linkmaster23
Forgot to attach...
02-19-2004, 08:30 PM#13
Vilkacis
You coulda just edited it you know.
02-19-2004, 08:47 PM#14
RaeVanMorlock
Ummm... yeah, well I appreciate the effort, linkmaster23, but this isn't going to work. If the same unit is attacked more than once within the same second then things will get screwed up.

For instance, consider this rough timeline:

Code:
seconds | action
--------+------------------------------
0       | Knight attacks peasant for 5 damage
0.5     | Rifleman attacks peasant for 4 damage
1.0     | 9 damage is recorded
1.5     | 9 damage is recorded
2.0     | Knight attacks peasant for 3 damage

....

Now in this example, not only is the first recorded damage inaccurate, but the second is also inaccurate and the same amount. This would only get worse as more units are added to the mix. And if they both attack at the same time, it'd be the same effect, but I thought having them attack a half second apart would make things more clear -- this will only get worse as more units are added to the mix.



I think my best bet will be to just add on the event for each specific unit to be able to take damage as their created -- and then see if the likely lag will cause a huge problem or not.

Does anyone know if there's a way to remove an event from a trigger? Or if there's a limit to the number of events? Or if having 50000 events would even cause lag? There are so many different possibilities that could occur with this, depending on how well Blizzard thought out their event stuff.
02-19-2004, 09:35 PM#15
Shimrra
Quote:
Originally posted by RaeVanMorlock
Does anyone know if there's a way to remove an event from a trigger?
Use the Run Trigger trigger. It runs the trigger, without looking at the event. You can also use Run Trigger (Ignoring Condition) to skip both the condition and the event.