• 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.

[Solved] Damage Detection

Status
Not open for further replies.
Level 8
Joined
Jul 3, 2011
Messages
251
Hey guys, im planning on making a shallow grave (from DotA) like item but im unsure of how to check the damage a unit takes before he takes it, ive heard that can be in done in JASS but not in GUI. Can someone tell me how please? I would be very greatfull, + rep for help. :ogre_love:
 
For sure it can be done in GUI too. Use GUI friendly damage detection system.

Its nothing but healing unit by the same amount of damage taken.
Uses Bride's Unit Indexer.

Set the instance:
  • cast
    • Events
      • Unit - Unit Starts effect of ability
    • Conditions
      • (Ability being cast) Equal to Shadow Grave
    • Actions
      • Set Key = (Custom value of (Target of ability being cast)
      • Set Duration[Key] = 5.00
      • Unit Group - Add (Traget of ability being cast) to ImmunityGroup
Loop the duration:
  • loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in ImmunityGroup and do Actions
        • Loop - Actions
          • Set Key = (Custom value of (Picked unit))
          • Set Duration[Key] = (Duration[Key] - 0.05)
          • If (All conditions are true) then do (Then Actions) else do (Else actions)
            • If - Conditions
              • Duration[Key] Less or equal to 0.00
            • Then - Actions
              • Unit Group - Remove (Picked unit) from ImmunityGroup
            • Else - Actions
      • If (All conditions are true) then do (Then Actions) else do (Else actions)
        • If - Conditions
          • (ImmunityGroup is Empty) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
Detecting the damage:
  • main
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Condiitons
      • (GDD_DamagedUnit is in ImmunityGroup) Equal to True
    • Actions
      • Timer - Start Timer as One shoot that will expire in 0.00 seconds
      • Unit Group - Add GDD_DamagedUnit to TempGroup
      • Set Key = (Custom value of (GDD_DamagedUnit))
      • Set Heal[Key] = GDD_Damage
Triggering the healing:
  • healing
    • Events
      • Time - Timer expires
    • Conditions
    • Actions
      • Unit Group - Pick every unit in TempGroup and do Actions
        • Loop - Actions
          • Set Key = (Custom value of (Picked unit)
          • Unit - Set life of (Picked unit) to (Life of (Picked unit) + Heal[Key])
          • Unit Group - Remove (Picked unit) from TempGroup
Note: I know that shadow grave doesn't absorb all the damage but let it pass unless you have 1 life, but I guess those condition stuff you can do on your own.

Note: Timer issue is ONLY for kind of shield ability that suck up all the damage. You should know that whenever your triggers are responding to 'damage taken' event like this GDD system does, actions are executed before the damage is dealt. So, when you want to 'heal' this way a unit (aka negate the damage) that had full hp before the event responded - healing won't be triggered because fullhp units can not be healed. To prevent that issue we have wait at least 0.00 seconds, and since Waits are anaccurete here, timers prove to be better option.

Note: You can use Has buff condition instead of group creating, although I don't trust that in case of dispells and other stuff.

Note: Since you grave spell do not require shield-like protecting you can cut timer part, and use:

  • main
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
      • (GDD_DamagedUnit is in ImmunityGroup) Equal to True
    • Actions
      • Unit - Set Life of GDD_DamagedUnit to (Life of GDD_DamagedUnit + GDD_Damage)
Note: If you want to follow buff conditions and you still stick to grave-like spell (not the shield one) you have to add conditions to make trigger react only when damage is greater than or equal to buffed unit's current life. If so, leave that unit with 1 hp. Also, this way enables you to run with just two triggers.
 
Last edited:
Status
Not open for further replies.
Top