• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[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,608
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