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

Detect damage coming from attack

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
Hi!

I know Wc3 allows detecting attack, but it can be abuseable. I also know there are Damage Detection Systems to detect when damage is dealt, but it may not come from an attack... So how can we detect when the damage came from an attack?

I've tough about keeping track of the order, but with right click order is not "attack" but "smart" and if the attacker is ranged, it could change the order before the missile strikes the target...
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
But how? I mean... If I add inmolation, it will damage everyone, but I don't want to do triggered bash to those units just because they received damage from inmolation or any otherskill.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
JASS:
library SpellDamage

    private function setSpellDamage takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype aType, damagetype dType, weapontype wType returns nothing
        // Save a boolean into hashtable for example
    endfunction
    
    hook UnitDamageTarget setSpellDamage

endlibrary

So you can use UnitDamageTarget for your spells. The hook thingy then automatically makes setSpellDamage to be called when UnitDamageTarget is called. You can set a boolean for example to tell to the damage detection system that the damage dealt came from a spell.
 
Status
Not open for further replies.
Top