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

Damage Reducing Shield

Status
Not open for further replies.
Level 6
Joined
May 11, 2010
Messages
236
Hey guys. So i've been trying to make this spell work, what i want for it is; The caster casts a shield on a friendly unit, when this unit takes damage the damage is halved. However i've only been able to get it to half the damage of the caster if it's casted on him, i've tried other ways but none seem to work. When changing "triggering unit" to "Target unit of ability being cast" it didnt halve the damage, instead healed the last unit that had the buff for the damage the unit that was that had the buff that taking the actual damage.

  • Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Gift of the Old Gods
    • Actions
      • Set Shieldgroup = (Units in (Playable map area))
      • Trigger - Add to Gift of the Dark Gods Shielding <gen> the event (Unit - (Picked unit) Takes damage)
  • Gift of the Dark Gods Shielding
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Picked unit) has buff Gift of the Old Gods ) Equal to True
        • Then - Actions
          • Special Effect - Create a special effect attached to the overhead of (Picked unit) using Abilities\Spells\NightElf\BattleRoar\RoarCaster.mdl
          • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + ((Damage taken) / 2.00))
        • Else - Actions
          • Do nothing
Right now I was messing around with picked unit and unit groups but it wasn't working. I'm running out of ideas for this : / would very much appreciate help if possible.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • Untitled Trigger 026
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Animate Dead
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target unit of ability being cast) is in Group) Equal to False
        • Then - Actions
          • Unit Group - Add (Target unit of ability being cast) to Group
          • Trigger - Add to Untitled Trigger 027 <gen> the event (Unit - (Target unit of ability being cast) Takes damage)
        • Else - Actions
  • Untitled Trigger 027
    • Events
    • Conditions
      • ((Triggering unit) has buff Acid Bomb) Equal to True
    • Actions
      • Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
      • Special Effect - Destroy (Last created special effect)
      • Unit - Set life of (Triggering unit) to...
The unit can die before getting life back. You need to revive it and calculate it's correct health.
 
Level 6
Joined
May 11, 2010
Messages
236
Thank you Maker, you rock. Though I had to change

"(Target unit of ability being cast) is in group) equal to false" to true, it wasnt working otherwise.
 
Level 6
Joined
May 11, 2010
Messages
236
Although, i've been realising something... It halves the damage but sometimes it doesnt for some reason... for example, if the unit is taking too much it doesn't seem to take it's health down, well it takes it down by 2-4 health but it just goes up? Yet it doesnt stop them from dying...

  • Gift of the Dark Gods Shielding
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Gift of the Old Gods
    • Actions
      • Set Shieldgroup = (Units in (Playable map area))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target unit of ability being cast) is in Shieldgroup) Equal to True
        • Then - Actions
          • Unit Group - Add (Target unit of ability being cast) to Shieldgroup
          • Trigger - Add to Cast <gen> the event (Unit - (Target unit of ability being cast) Takes damage)
        • Else - Actions
          • Do nothing
  • Cast
    • Events
    • Conditions
      • ((Triggering unit) has buff Gift of the Old Gods ) Equal to True
    • Actions
      • Special Effect - Create a special effect attached to the chest of (Triggering unit) using Abilities\Spells\Items\SpellShieldAmulet\SpellShieldCaster.mdl
      • Special Effect - Destroy (Last created special effect)
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + ((Damage taken) / 2.00))
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Shield group is a global group. Don't remove/create it with triggers.

  • Gift of the Dark Gods Shielding
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Gift of the Old Gods
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target unit of ability being cast) is in Shieldgroup) Equal to false
        • Then - Actions
          • Unit Group - Add (Target unit of ability being cast) to Shieldgroup
          • Trigger - Add to Cast <gen> the event (Unit - (Target unit of ability being cast) Takes damage)
        • Else - Actions
For the dying part, you need some math. Let's say the unit has 20 health and it take 30. It dies before the +health takes effect. Then you revive the unit and set it's health to 20 - 30 / 2 = 5.

You should check whether the unit should stay dead before reviving it.
 
Level 6
Joined
May 11, 2010
Messages
236
Okay so I just experimented - I had a unit with 30 chaos damage and a unit with 50 health and no health regen. I got the unit with 50 health down to 20 health using a unit that did 5 damage and then made the unit with 30 chaos damage attack him, he had the buff of course and survived with 4 health. Where the extra 1 damage came from beats me, but thats roughly 30 divided by 2. So I think we're good, I think the healing effect responds fast enough to stop the death

- Just tested 2 more times, and the last time with a unit without the shield on 20 health as well, he died instantly while the shield guy lived with 5 health

Nevertheless, thanks for the help again Maker, very much appreciated. Rep'd you :)
 
Okay so I just experimented - I had a unit with 30 chaos damage and a unit with 50 health and no health regen. I got the unit with 50 health down to 20 health using a unit that did 5 damage and then made the unit with 30 chaos damage attack him, he had the buff of course and survived with 4 health. Where the extra 1 damage came from beats me, but thats roughly 30 divided by 2. So I think we're good, I think the healing effect responds fast enough to stop the death

- Just tested 2 more times, and the last time with a unit without the shield on 20 health as well, he died instantly while the shield guy lived with 5 health

Nevertheless, thanks for the help again Maker, very much appreciated. Rep'd you :)

its because the event A unit takes damage actually fires before the unit gets damaged... so he is healed first before he gets damaged... which makes your shield a lifesaver... ^_^
 
Status
Not open for further replies.
Top