• 🏆 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!

[JASS] Registering unit damage event but executing functions before damage is dealt

Status
Not open for further replies.
Level 17
Joined
Apr 13, 2008
Messages
1,597
Hi, I want to register Unit Damage Events and I want to execute functions BEFORE the damage would be dealt.

Why I want to do this?

I'm making a map where I handle the units on the map as unit stacks.
Have you ever played any Heroes of Might and Magic games? Well if yes, then just like that, if not then look at this:
http://linuxgazette.net/issue60/misc/andreiana/homm_combat1.jpg
So my units should only die in the Warcraftly means if their "stack" (integer value attached to them) becomes less than 1.

Spirit linking every unit with a dummy unit seemed a brilliant idea but then I had to realize that I can't make the attacked spirit linked unit suffer no damage. Even though you can set the "main target damage factor" field to 0 in the Ability Editor.

Is there a solution to my case?

(Remember, when the unit dies its buffs will be gone when I resurrect it with resurrect or reincarnation.
And I don't want my unit to have Stack*UnitDefaultMaxLife HP.)
 
Last edited:
Level 11
Joined
Feb 18, 2004
Messages
394
native TriggerRegisterUnitEvent takes trigger whichTrigger, unit whichUnit, unitevent whichEvent returns event with EVENT_UNIT_DAMAGED Actually occurs before damage is dealt. You can increase health past damage on that event, start a 0 second timer, and when it expires, reset health to where it was, less the damage you actually want to occur the unit. This is the same concept used in passive mana shield spells. (For increasing maximum health, check out SetUnitMaxState, in the JASS functions forum of this site.)
 
Status
Not open for further replies.
Top