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

[Trigger] (Need Help Fixing) Triggered Passive Mana Shield

Status
Not open for further replies.
Level 16
Joined
Mar 8, 2009
Messages
975
Edit: Updated.
alright, the problem with my passive mana Shield, is that the trigger happens before the damage is dealt, so when the target unit has full hp, bot life and mana gets damaged.
I'm trying to make it to heal after the damage is done only IF the target unit has full hp, but it doesnt works :/
here are my actual triggers:

  • Faith Protection 1
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
      • (GDD_DamagedUnit has buff Faith Protection ) Equal to (==) True
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of GDD_DamagedUnit) Equal to (==) (Max life of GDD_DamagedUnit)
        • Then - Actions
          • Trigger - Turn on Faith Protection 2 <gen>
        • Else - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • GDD_Damage Less than or equal to (<=) (Mana of GDD_DamagedUnit)
            • Then - Actions
              • Unit - Set life of GDD_DamagedUnit to ((Life of GDD_DamagedUnit) + GDD_Damage)
              • Unit - Set mana of GDD_DamagedUnit to ((Mana of GDD_DamagedUnit) - GDD_Damage)
              • Special Effect - Create a special effect attached to the origin of GDD_DamagedUnit using Abilities\Spells\Human\Defend\DefendCaster.mdl
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
              • Unit - Set life of GDD_DamagedUnit to ((Life of GDD_DamagedUnit) + (GDD_Damage - (Mana of GDD_DamagedUnit)))
              • Unit - Set mana of GDD_DamagedUnit to 0.00
  • Faith Protection 2
    • Events
      • Time - (Create a periodic One-shot timer lasting 0.00) expires
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GDD_Damage Less than or equal to (<=) (Mana of GDD_DamagedUnit)
        • Then - Actions
          • Unit - Set life of GDD_DamagedUnit to ((Life of GDD_DamagedUnit) + GDD_Damage)
          • Unit - Set mana of GDD_DamagedUnit to ((Mana of GDD_DamagedUnit) - GDD_Damage)
          • Special Effect - Create a special effect attached to the origin of GDD_DamagedUnit using Abilities\Spells\Human\Defend\DefendCaster.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
          • Unit - Set life of GDD_DamagedUnit to ((Life of GDD_DamagedUnit) + (GDD_Damage - (Mana of GDD_DamagedUnit)))
          • Unit - Set mana of GDD_DamagedUnit to 0.00
      • Trigger - Turn off (This trigger)
well, i made this simple trigger to make a Passive Mana Shield.
I think the triggers are right, but it doesnt work >_<
if its helps, the conditions works because the Special Effect is played, but none mana is removed never, nor the damage gets reduced :/
i hope you can help me fixing it, thanks in advance :D

  • Faith Protection 1
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacked unit) has buff Faith Protection ) Equal to (==) True
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Damage taken) Less than or equal to (<=) (Mana of (Attacked unit))
        • Then - Actions
          • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + (Damage taken))
          • Unit - Set mana of (Attacked unit) to ((Mana of (Attacked unit)) - (Damage taken))
          • Special Effect - Create a special effect attached to the origin of (Attacked unit) using Abilities\Spells\Human\Defend\DefendCaster.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
          • Unit - Set life of (Attacked unit) to ((Life of (Attacked unit)) + ((Damage taken) - (Mana of (Attacked unit))))
          • Unit - Set mana of (Attacked unit) to 0.00
 
Last edited:

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
I recommend using this GUI friendly damage detection system since I see you're using GUI script.

Trigger will look like this:
  • Faith Protection 1
    • Events
      • Game - GDD_Event becomes equal to 0.00
    • Conditions
      • ((GDD_DamagedUnit) has buff Faith Protection ) Equal to (==) True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (GDD_Damage) Less than or equal to (<=) (Mana of (GDD_DamagedUnit))
        • Then - Actions
          • Unit - Set life of (GDD_DamagedUnit) to ((Life of (GDD_DamagedUnit)) + (GDD_Damage))
          • Unit - Set mana of (GDD_DamagedUnit) to ((Mana of (GDD_DamagedUnit)) - (GDD_Damage))
          • Special Effect - Create a special effect attached to the origin of (GDD_DamagedUnit) using Abilities\Spells\Human\Defend\DefendCaster.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
          • Unit - Set life of (GDD_DamagedUnit) to ((Life of (GDD_DamagedUnit)) + ((GDD_Damage) - (Mana of (GDD_DamagedUnit))))
          • Unit - Set mana of (GDD_DamagedUnit) to 0.00
 
Level 16
Joined
Mar 8, 2009
Messages
975
lol, i didnt knew i would need a damage detection system x_x
will see if i can use that one, Spinnaker. Im really new in triggering but i dont understand why the world editor would has a 'damage taken' event response if it hasnt any damage detection system in-built lol :D
thank you both for helping, im gonna check if it works and Ill be back with rep for you two :)
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
It's well know bug, untill unit has less than max life there are problems to detect exact damage. However, systems from vjass deal with it.
In GUI its hard, but not imposible, go to this link select from Demo maps Energy shield. Guy shows an option how to eliminate that bug in GUI. Now just combine a little bit my trigger with that one, and your are done.

@Justify Single units? that trigger is MUI since it is instand action. Don't know what are you talking about. If you thought that its because of set unit into variable, you were wrong, since GUI friendly damage detection system works fine and such situations does not occur.
 
Level 16
Joined
Mar 8, 2009
Messages
975
thanks, I'll take a look at that, hopefully i'll be able to fix it :)

edit: well, i will need some help understanding how those triggers works lol
at least gimme a clue where to start >_<

i think something like:
if damaged unit's life == damaged unit's max life then
set value of Variable to unit's life
set unit's max life to unit's max life + damage taken
set unit's life to unit's max life

and then, somehow, after the damage is dealt, return the unit's max life to where it sould be using the value of that variable.
The problem is i have no idea how to do this last thing and how to wait until the damage is actually dealt >_<
that was my idea of fixing it, but perhaps what this guy did is just more simple. The thing is, i cant get to figure out how he did it :/
 
Last edited:
Level 13
Joined
Mar 16, 2008
Messages
941
Ok, where to start:
It's well know bug, untill unit has less than max life there are problems to detect exact damage. However, systems from vjass deal with it.
No. The damage is always exact. The problem is that the event fires BEFOR the damage is done. Healing the unit will result in healing befor the damage is done. Since healing at 100% HP doesn't work, it "bugs" in vJass too. To avoid this you need to wait some time. Not with a wait but a VERY short time like a 0.00 second timer.

@Justify Single units? that trigger is MUI since it is instand action. Don't know what are you talking about. If you thought that its because of set unit into variable, you were wrong, since GUI friendly damage detection system works fine and such situations does not occur.
Read... I answered to his question about damage events, not this system.

EDIT: @Xezko. There is an event for damage detection that only works for single units. You have to add an event for each unit to the detection trigger.
Now, when the trigger fires, the damage is not done. The rest is written above.
 
Level 16
Joined
Mar 8, 2009
Messages
975
oh i see, what happens is what i thought :D
so, adding a timer will fix it?
how can I add it?
and if I add a timer, what will happen is the damage will kill the unit, but the unit has enough mana in order to not die. I mean, waiting until the damage is done would be too late xD

i tried adding this condition:
  • If ((Life of GDD_DamagedUnit) Equal to (==) (Max life of GDD_DamagedUnit)) then do (Wait 0.00 seconds) else do (Do nothing)
leaving the ability triggers as this:
  • Faith Protection 1
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
      • (GDD_DamagedUnit has buff Faith Protection ) Equal to (==) True
    • Actions
      • If ((Life of GDD_DamagedUnit) Equal to (==) (Max life of GDD_DamagedUnit)) then do (Wait 0.01 seconds) else do (Do nothing)
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • GDD_Damage Less than or equal to (<=) (Mana of GDD_DamagedUnit)
          • Then - Actions
            • Unit - Set life of GDD_DamagedUnit to ((Life of GDD_DamagedUnit) + GDD_Damage)
            • Unit - Set mana of GDD_DamagedUnit to ((Mana of GDD_DamagedUnit) - GDD_Damage)
            • Special Effect - Create a special effect attached to the origin of GDD_DamagedUnit using Abilities\Spells\Human\Defend\DefendCaster.mdl
            • Special Effect - Destroy (Last created special effect)
          • Else - Actions
            • Unit - Set life of GDD_DamagedUnit to ((Life of GDD_DamagedUnit) + (GDD_Damage - (Mana of GDD_DamagedUnit)))
            • Unit - Set mana of GDD_DamagedUnit to 0.00
but it doesnt works, neither making it 0.01 seconds and i think making it a higher value will not help at all... :/

I still dont get how the guy on the Energy Shield Test Map that Spinnaker gave me did it, so any help fixing this, please? :D
 
Last edited:
Level 13
Joined
Mar 16, 2008
Messages
941
If possible, heal BEFOR the damage comes.
There are 3 cases:
The heal can be fully applied befor the damage comes, best case.
The heal can be partially applied. For example, you have 900/1000 HP and take 200 damage. Now you would heal 100 befor, and 100 after the damage comes.
Last situation is at full HP so the entire heal comes after the damage.
To do this, create a timer. When you need to heal afterwards save the remaining heal in a variable, start the timer with a timeout of 0.00 and heal the unit in the trigger called by the timer.

A hint: This shows that real one-hits can't be absorbed.
 
Level 16
Joined
Mar 8, 2009
Messages
975
well, i did this, but its not working. I'm sure there is a better way of doing it because i know that CnPing code isnt any good, but this is what i can do for now u.u

I suspect this timer isnt working :/

  • Faith Protection 1
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
      • (GDD_DamagedUnit has buff Faith Protection ) Equal to (==) True
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of GDD_DamagedUnit) Equal to (==) (Max life of GDD_DamagedUnit)
        • Then - Actions
          • Trigger - Turn on Faith Protection 2 <gen>
        • Else - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • GDD_Damage Less than or equal to (<=) (Mana of GDD_DamagedUnit)
            • Then - Actions
              • Unit - Set life of GDD_DamagedUnit to ((Life of GDD_DamagedUnit) + GDD_Damage)
              • Unit - Set mana of GDD_DamagedUnit to ((Mana of GDD_DamagedUnit) - GDD_Damage)
              • Special Effect - Create a special effect attached to the origin of GDD_DamagedUnit using Abilities\Spells\Human\Defend\DefendCaster.mdl
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
              • Unit - Set life of GDD_DamagedUnit to ((Life of GDD_DamagedUnit) + (GDD_Damage - (Mana of GDD_DamagedUnit)))
              • Unit - Set mana of GDD_DamagedUnit to 0.00
  • Faith Protection 2
    • Events
      • Time - (Create a periodic One-shot timer lasting 0.00) expires
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GDD_Damage Less than or equal to (<=) (Mana of GDD_DamagedUnit)
        • Then - Actions
          • Unit - Set life of GDD_DamagedUnit to ((Life of GDD_DamagedUnit) + GDD_Damage)
          • Unit - Set mana of GDD_DamagedUnit to ((Mana of GDD_DamagedUnit) - GDD_Damage)
          • Special Effect - Create a special effect attached to the origin of GDD_DamagedUnit using Abilities\Spells\Human\Defend\DefendCaster.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
          • Unit - Set life of GDD_DamagedUnit to ((Life of GDD_DamagedUnit) + (GDD_Damage - (Mana of GDD_DamagedUnit)))
          • Unit - Set mana of GDD_DamagedUnit to 0.00
      • Trigger - Turn off (This trigger)
 
Status
Not open for further replies.
Top