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

[General] Spell Shield using GDD

Status
Not open for further replies.
Level 5
Joined
Dec 25, 2018
Messages
110
It works properly but if Hero is at 100% hp, he will still take damage.
How can I fix it?
  • Events
    • Game - GDD_Event becomes Equal to 1.00
    • Conditions
      • (GDD_DamagedUnit has buff Shield ) Equal to True
      • GDD_DamageSource Equal to DamageTypeMagic[(Player number of (Owner of GDD_DamageSource))]
    • Actions
      • Set Caster = GDD_DamagedUnit
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AbilityValue1_Real[(Player number of (Owner of Caster))] Greater than or equal to GDD_Damage
        • Then - Actions
          • Set AbilityValue1_Real[(Player number of (Owner of Caster))] = (AbilityValue1_Real[(Player number of (Owner of Caster))] - GDD_Damage)
          • Unit - Set life of Caster to ((Life of Caster) + (GDD_Damage - 0.00))
          • Set GDD_Damage = 0.00
        • Else - Actions
          • Set AbilityValue1_Real[(Player number of (Owner of Caster))] = (AbilityValue1_Real[(Player number of (Owner of Caster))] - GDD_Damage)
          • Unit - Set life of Caster to ((Life of Caster) + (GDD_Damage - AbilityValue1_Real[(Player number of (Owner of Caster))]))
          • Set GDD_Damage = 0.00
          • Custom script: call UnitRemoveAbility(udg_Caster ,'B008')
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
If I understand your problem correctly, the problem occurs when ((life of unit before damage) + (damage taken)) > (max healt of unit). You need to use a trick with damage bonus ability, not sure if there is another way.

  • Damage Block Tricky Event
    • Events
      • Game - Your damage event
    • Conditions
    • Actions
      • Unit - Add BLOCK LIFE BONUS (Greater) to (Triggering unit)
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (Damage taken))
      • Unit Group - Add (Triggering unit) to DamageBlockGroup
      • Countdown Timer - Start DamageBlockTimer as a One-shot timer that will expire in 0.00 seconds

  • Damage Block Tricky Callback
    • Events
      • Time - DamageBlockTimer expires
    • Conditions
    • Actions
      • Unit Group - Pick every unit in DamageBlockGroup and do (Actions)
        • Loop - Actions
          • Unit - Remove BLOCK LIFE BONUS (Greater) from (Picked unit)
      • Unit Group - Remove all units from DamageBlockGroup
Edit: A better thing to do is, in damage event trigger, first you should check if (life of unit) + (damage taken) <= max health. If yes simply increase life of the unit, if no use this trick.
 

Attachments

  • Damage Block Trick.w3x
    17.2 KB · Views: 22
Last edited:
Level 12
Joined
Feb 22, 2010
Messages
1,115
Is it dumb to use local caster with low value wait instead?
If you mean wait before remove life bonus ability instead of timer, a problem will occur if unit takes another damage during wait. Or if you mean wait a low amount of time before increase unit's health, there is a chance your unit may die if you do not block damage immediately.
 
Level 5
Joined
Dec 25, 2018
Messages
110
I'm using the latest patch and latest DDS. Works fine.

Every map with this DDS gives me the same error so the problem is on my side

upload_2019-7-29_14-35-50.png

This is ver of my wc3, pretty sure its updated
 

Attachments

  • upload_2019-7-29_14-35-30.png
    upload_2019-7-29_14-35-30.png
    17 KB · Views: 24
Status
Not open for further replies.
Top