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

[Solved] Spell Trigger

Status
Not open for further replies.
Level 4
Joined
Feb 24, 2018
Messages
71
I would like my spell to instantly kill a target if he's lower than 5% health and give the caster strength and intelligence but this trigger gives stats to the hero regardless of the target's health if the spell one shots the target. Any idea ?
  • Unholy Exsecution
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Festering Strike
    • Actions
      • Unit - Set life of (Triggering unit) to ((Max life of (Triggering unit)) - (0.05 x (Max life of (Triggering unit))))
      • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing (((100.00 x (Real((Level of Festering Strike for (Triggering unit))))) + ((2.00 x (Real((Strength of (Triggering unit) (Include bonuses))))) + (3.00 x (Real((Intelligence of (Triggering unit) (Include bonuses))))))) x (Real((Level of Festering Strike for (T damage of attack type Spells and damage type Normal
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer((Percentage life of (Target unit of ability being cast)))) Less than or equal to 5
        • Then - Actions
          • Set TempLoc5 = (Position of (Target unit of ability being cast))
          • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 1000000000.00 damage of attack type Spells and damage type Normal
          • Hero - Modify Strength of (Triggering unit): Add (1 x (Level of Festering Strike for (Triggering unit)))
          • Hero - Modify Intelligence of (Triggering unit): Add (1 x (Level of Festering Strike for (Triggering unit)))
          • Special Effect - Create a special effect at TempLoc5 using units\undead\Banshee\Banshee.mdl
          • Special Effect - Destroy (Last created special effect)
          • Special Effect - Create a special effect at TempLoc5 using Objects\Spawnmodels\Undead\UndeadDissipate\UndeadDissipate.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation (udg_TempLoc5)
        • Else - Actions
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
The life comparison happens after you deal damage. This means if the damage killed the target, the target always has less than 5% hp after that (it has 0% hp).

You have to first check the hp. If it has more than 5%, deal normal damage, else kill it and give the killer the stats you want.
 
Level 4
Joined
Feb 24, 2018
Messages
71
Like this ?
  • Unholy Exsecution
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Festering Strike
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer((Percentage life of (Target unit of ability being cast)))) Greater than 5
        • Then - Actions
          • Unit - Set life of (Triggering unit) to ((Max life of (Triggering unit)) - (0.05 x (Max life of (Triggering unit))))
          • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing (((100.00 x (Real((Level of Festering Strike for (Triggering unit))))) + ((2.00 x (Real((Strength of (Triggering unit) (Include bonuses))))) + (3.00 x (Real((Intelligence of (Triggering unit) (Include bonuses))))))) x (Real((Level of Festering Strike for (T damage of attack type Spells and damage type Normal
        • Else - Actions
          • Set TempLoc5 = (Position of (Target unit of ability being cast))
          • Unit - Set life of (Triggering unit) to ((Max life of (Triggering unit)) - (0.05 x (Max life of (Triggering unit))))
          • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 1000000000.00 damage of attack type Spells and damage type Normal
          • Hero - Modify Strength of (Triggering unit): Add (1 x (Level of Festering Strike for (Triggering unit)))
          • Hero - Modify Intelligence of (Triggering unit): Add (1 x (Level of Festering Strike for (Triggering unit)))
          • Special Effect - Create a special effect at TempLoc5 using units\undead\Banshee\Banshee.mdl
          • Special Effect - Destroy (Last created special effect)
          • Special Effect - Create a special effect at TempLoc5 using Objects\Spawnmodels\Undead\UndeadDissipate\UndeadDissipate.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation (udg_TempLoc5)
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
  • Unit - Set life of (Triggering unit) to ((Max life of (Triggering unit)) - (0.05 x (Max life of (Triggering unit))))
Shouldn't, this all the way up here ^^ be current? ?

Currently you are instantly setting the unit's life to 95% every time it casts the ability.
Also. you could put this part outside the if statement as it happens in both cases.
 
Level 4
Joined
Feb 24, 2018
Messages
71
Yes , I changed it
  • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (0.05 x (Max life of (Triggering unit))))
Thanks
 
Status
Not open for further replies.
Top