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

Damage "Block"

Status
Not open for further replies.
Level 13
Joined
Mar 24, 2013
Messages
1,105
Hello, I'm trying to make a damage "block" ability that upon activation it will "prevent" damage to the unit, by prevent I mean give it back the hp it would lose from damage. It technically WORKS as of now (except when the caster is full hp (but I'm not worried about that), but for some reason the caster still seems to take ~ about 2 damage or so but I'm not sure why. Thanks!

  • Protection
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Protection
    • Actions
      • Set Protection_Caster = (Casting unit)
      • Set Protection_CasterHP = (Life of Protection_Caster)
      • Trigger - Add to Protection 2 <gen> the event (Unit - Protection_Caster Takes damage)
      • Trigger - Turn on Protection 2 <gen>
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Real((Level of Protection for Protection_Caster))) Equal to 1.00
        • Then - Actions
          • Wait 5.00 seconds
        • Else - Actions
      • Trigger - Turn off Protection 2 <gen>
  • Protection 2
    • Events
    • Conditions
    • Actions
      • Unit - Set life of Protection_Caster to (Protection_CasterHP + ((Damage taken))
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
You want to completely null damage received? If yes, you could just use a conjunction of spell book and modified Hardened skin. That way when unit casts this ability you would only add that spell book, disable it and after X seconds (once the spell ends) enable it and remove it
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
But it's the ability can be used only on the caster, he can't cast it on other unit, is that correct? Basically a Divine shield spell, but the caster can be attacked (he will null all damage)

Edit:
Anyway, looking at your triggers, there are a few problems:
1) it's not mui, so if more than 1 units cast this at a time, it will bug
2) you don't have any condition for 2nd trigger. So if 2 different units cast this ability, 2 different units will fire 2nd trigger, thus the currect caster will be healed even when previous caster takes damage
3) There is no need to do this: Unit - Set life of Protection_Caster to (Protection_CasterHP + ((Damage taken)); when you are supposed to null all damage. Leave out the (damage taken) part and just set the life to Protection_CasterHp.

In praxis, what happens now is you store life amount upon spell cast
So for example Start_HP = 100
Then caster takes 30 damage.
His hp is now 70, but you set his health as 100 (Start_Hp) +30 (Damage Taken) => 130. This results in the unit healing from receiving damage, instead of just nulling it.
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
No, not spell reduction as it reduces incoming spell damage (up to magic-immune, which makes the unti unable to be targeted by spells).

I was thinking more along the lines of having dummy ability that starts this spell, then dummy unit that casts a modified version of "Anti-magic Shell (Magic Resistance)" (this version is not used in melee maps and it absorbs magic damage, up to a certain amount, which can be changed in object editor) and adding spell book with Hardened Skin.

Then using the trigger in hidden tags
  • Triggers
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Protection
    • Actions
      • Set TempPoint = (Position of (Triggering unit))
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at TempPoint facing Default building facing degrees
      • Set TempUnit = (Last created unit)
      • Unit - Add Protection to TempUnit
      • Unit - Order TempUnit to Undead Banshee - Anti-magic Shell (Triggering unit)
      • Unit - Remove TempUnit from the game
      • Unit - Add SpellBook(Protection) to (Triggering unit)
      • Player - Disable SpellBook(Protection) for (Owner of (Triggering unit))
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Custom script: set udg_TempPoint = null
      • Wait X seconds /// spell duration
      • Player - Enable SpellBook(Protection) for (Owner of (Triggering unit))
      • Unit - Remove SpellBook(Proteciton) from (Triggering unit)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Unit - Set life of Protection_Caster to (Protection_CasterHP + ((Damage taken))
The HP fluctuation is due to you adding the damage to a constant. Hitting it with a powerful nuke ability like Death Bolt will heal the unit considerably but then a simple 1 damage attack will lower its health to that amount.

You are after using the unit's current health added to the damage taken, not a constant of the unit's current health when the ability was cast.
 
Status
Not open for further replies.
Top