HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Preventing Damage

08-11-2007, 05:18 AM#1
Dil999
Is there a way to, when a unit is attacked, prevent the unit from taking that damage but still registering the damage that would have been dealt? This meant if X unit has 100 hp and Y unit deals 120 damage, the unit would still be alive.
08-11-2007, 05:21 AM#2
Tide-Arc Ephemera
I don't think so....
08-11-2007, 05:47 AM#3
Earth-Fury
the "Unit takes damage" event happens before a unit actually takes damage. So use something like bonus mod to increase a units max HP above the damage, start a timer with a 0 timeout, and in the callback set the units HP to what it should be. Atleast thats how i understand it.
08-11-2007, 06:01 AM#4
Rising_Dusk
Quote:
the "Unit takes damage" event happens before a unit actually takes damage. So use something like bonus mod to increase a units max HP above the damage, start a timer with a 0 timeout, and in the callback set the units HP to what it should be. Atleast thats how i understand it.

Mostly.
You want to run the EVENT_UNIT_DAMAGED event on your unit. Then when your unit is damaged, store the damage dealt, unit's current life, and unit's maximum life to a timer, then set the unit's max life to some number that makes it unkillable and run the timer for 0.0 seconds. In the timer callback, restore the unit's max life and current life, but you still know the damage that would have been dealt (It was attached to the timer).

Notably, that damage isn't entirely accurate.
It factors passives such as bash or critical strike and also factors armor (If it was from an attack). This means if you want the true original damage you will need to do some back-calculating. Not too tough, as long as you monitor all sources of damage in the map and so forth. (This would mean triggering critical strike/bash/etc. would be desirable)