• 🏆 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 if a unit dies to an ability

Status
Not open for further replies.
Level 7
Joined
Feb 23, 2020
Messages
253
Hello, as the title reads, i wonder if there is a way to detect if a unit dies to a certain ability, if so. How do you do that?
 
Level 7
Joined
Feb 23, 2020
Messages
253
You can create a trigger that checks when the ability is cast and then run a near-instant timer that will check if the unit is dead or not.

If I have time, I'll make a test map to show you how.

I'd appreciate that a lot.

If the ability deals damage then you can detect this using a Damage Engine.

Yes, i use bribes damage engine but i still cant figure it out how to make it work
 
Last edited by a moderator:
Level 4
Joined
Jun 28, 2012
Messages
23
You can also do that :
Thus it haves it limitation since the damage will be pre mitigation from the game so if your spell deal 100dmg and the unit haves likes 200hp and 0 heavy armor it would still kill it.
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Life of (Target unit of ability being cast)) Less than (Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field Damage ('Hbz2'), of Level: (Level of (Ability being cast) for (Triggering unit)))
  • Actions
 
Level 7
Joined
Feb 23, 2020
Messages
253
You can also do that :
Thus it haves it limitation since the damage will be pre mitigation from the game so if your spell deal 100dmg and the unit haves likes 200hp and 0 heavy armor it would still kill it.
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Life of (Target unit of ability being cast)) Less than (Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field Damage ('Hbz2'), of Level: (Level of (Ability being cast) for (Triggering unit)))
  • Actions
Well this would not work for coded damage right?

  • Feast Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to X
    • Actions
      • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 50.00 damage of attack type Spells and damage type Normal
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of (Target unit of ability being cast)) Less than 1.00
        • Then - Actions
          • Do things
        • Else - Actions
Would this work properly?
 
Last edited by a moderator:
Level 4
Joined
Jun 28, 2012
Messages
23
Oh with coded damage it's a lot easier !
  • Feast Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to X
    • Actions
      • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 50.00 damage of attack type Spells and damage type Normal
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of (Target unit of ability being cast)) Less than 1.00
        • Then - Actions
          • Do things
        • Else - Actions
Would this work properly?
It should work, use 0.31 instead of 1.00 tho.
 
Level 4
Joined
Jun 28, 2012
Messages
23
Maybe there's some case where "target unit of ability being cast" point to a null since it's dead but from what I know i think unit are not removed instantly on death. Try and see but should work.
Edit maybe add
  • Conditions
  • (Target unit of ability being cast) Equal to No unit
Edit 2 : equal will mean that your unit has been removed from the game
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
So how do i make this even work with a certain ability?
Have a unique dummy unit cast the ability. Then check if the DamageEventSource (damaging unit) is equal to this unit.
So your hero will cast a fake version of the spell that has no effects and then you trigger a Dummy unit to cast the real spell in response to this.
If you need access to the Hero in the LethalDamageEvent trigger you can link the Dummy unit to your Hero using a Hashtable/Unit Indexer when you first create it.

Alternatively, if this is the only damaging spell that your hero has you can do something like this:
  • Conditions:
  • IsDamageSpell equal to True
  • Unit-type of DamageEventSource equal to Your Hero
 
Level 7
Joined
Feb 23, 2020
Messages
253
Have a unique dummy unit cast the ability. Then check if the DamageEventSource (damaging unit) is equal to this unit.
So your hero will cast a fake version of the spell that has no effects and then you trigger a Dummy unit to cast the real spell in response to this.
If you need access to the Hero in the LethalDamageEvent trigger you can link the Dummy unit to your Hero using a Hashtable/Unit Indexer when you first create it.

Alternatively, if this is the only damaging spell that your hero has you can do something like this:
  • Conditions:
  • IsDamageSpell equal to True
  • Unit-type of DamageEventSource equal to Your Hero
Alright, thanks a lot mate!
 
Level 24
Joined
Jun 26, 2020
Messages
1,852
In fact is not necessary have one specific dummy to each ability (if you wanna do this with various abilities) you can add the dummy to a unit group (obviously you need a group for each ability) and when the damage is deal check if the source is in that group and then remove it from that group.
 
Status
Not open for further replies.
Top