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

invulnerability spell

Status
Not open for further replies.
Level 26
Joined
Dec 3, 2018
Messages
871
i want to make a spell whch makes a unit invulnerable.
It basically is holy light and i need a trigger which makes the unit invulnerable.
event: a unit finishes the effect of an ability
condition: the ability being cast equals to divine protection
action: make the unit the ability is being cast on invulnerable
wait 5 seconds
make the unit the ability is being cast on vulnerable.
 
Level 28
Joined
Feb 18, 2014
Messages
3,576
  • InvulnerabilitySpell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Divine Protection
    • Actions
      • Set TempInteger = (TempInteger + 1)
      • Set TempTarget[TempInteger] = (Target unit of ability being cast)
      • Unit - Make TempTarget[TempInteger] Invulnerable
      • Wait 5.00 seconds
      • Set TempRecycle = (TempRecycle + 1)
      • Unit - Make TempTarget[TempRecycle] Vulnerable
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempRecycle Equal to TempInteger
        • Then - Actions
          • Set TempInteger = 0
          • Set TempRecycle = 0
        • Else - Actions
 
Level 26
Joined
Dec 3, 2018
Messages
871
Events: Unit - A unit Finishes casting an ability
Conditions: (Ability being cast) Equal to Divine Protection
Actions: Set DivineProtection = (DivineProtection + 1)
Set DivineTarget = (Target unit of ability being cast)
Unit - Make DivineTarget Invulnerable
Wait 5.00 seconds
Set DivineRecycle = (DivineRecycle + 1)
Unit - Make DivineReUnit Vulnerable
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
DivineRecycle Equal to DivineProtection
Then - Actions
Set DivineProtection = 0
Set DivineRecycle = 0
Else - Actions
--------------------
DivioneProtection and DivineRecycle are integers
and DivineTarget and DivineReUnit are units.
Whats wrong here?
 

Wrda

Spell Reviewer
Level 25
Joined
Nov 18, 2012
Messages
1,870
  • InvulnerabilitySpell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Divine Protection
    • Actions
      • Set TempInteger = (TempInteger + 1)
      • Set TempTarget[TempInteger] = (Target unit of ability being cast)
      • Unit - Make TempTarget[TempInteger] Invulnerable
      • Wait 5.00 seconds
      • Set TempRecycle = (TempRecycle + 1)
      • Unit - Make TempTarget[TempRecycle] Vulnerable
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempRecycle Equal to TempInteger
        • Then - Actions
          • Set TempInteger = 0
          • Set TempRecycle = 0
        • Else - Actions
Man, you guys have to really make something simple into something unnecessarily complicated.
  • Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Divine Protection
    • Actions
      • Unit - Make (Triggering unit) Invulnerable
      • Wait 5.00 seconds
      • Unit - Make (Triggering unit) Vulnerable
(Triggering Unit) acts like a local variable, so no need to make any additional variables.
Just follow the KISS principle :p
 
Level 9
Joined
Jul 30, 2018
Messages
445
Man, you guys have to really make something simple into something unnecessarily complicated.
  • Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Divine Protection
    • Actions
      • Unit - Make (Triggering unit) Invulnerable
      • Wait 5.00 seconds
      • Unit - Make (Triggering unit) Vulnerable
(Triggering Unit) acts like a local variable, so no need to make any additional variables.
Just follow the KISS principle :p

But considering it's based on Holy Light, I guess OP wants to make a "targetable Divine Shield" (why not else just use Divine Shield?). To make that kind of spell MUI it has to be a bit more complicated.
 
Level 13
Joined
May 10, 2009
Messages
868
Create a unit variable named "Target". Then:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Spell
  • Actions
    • Custom script: local unit udg_Target = GetSpellTargetUnit()
    • Unit - Make Target Invulnerable
    • Wait 5.00 seconds
    • Unit - Make Target Vulnerable
There you go.


However, I personally dislike the trigger above because it can conflict with other triggers/spells which make units invulnerable.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,510
Create a unit variable named "Target". Then:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Spell
  • Actions
    • Custom script: local unit udg_Target = GetSpellTargetUnit()
    • Unit - Make Target Invulnerable
    • Wait 5.00 seconds
    • Unit - Make Target Vulnerable
There you go.


However, I personally dislike the trigger above because it can conflict with other triggers/spells which make units invulnerable.
A solution to that problem would be to use an invulnerability counter that is stored to the unit. So whenever you make a unit invulnerable you would increase it's invulnerability counter by 1 and whenever the invulnerability effect ends you would decrease it's invulnerability counter by 1. Then you check if the counter is equal to 0 and if it is then you can safely make the unit vulnerable again.
 
Level 28
Joined
Feb 18, 2014
Messages
3,576
Man, you guys have to really make something simple into something unnecessarily complicated.
  • Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Divine Protection
    • Actions
      • Unit - Make (Triggering unit) Invulnerable
      • Wait 5.00 seconds
      • Unit - Make (Triggering unit) Vulnerable
(Triggering Unit) acts like a local variable, so no need to make any additional variables.
Just follow the KISS principle :p
That trigger will work if the spell is presumably casted by one unit only. Although, it may still cause troubles if the cooldown of the spell is lower than the wait in the trigger. Also, if the spell is casted by multiple units at once, there is a high chance that one of the targets will remain invulnerable forever.
 

Wrda

Spell Reviewer
Level 25
Joined
Nov 18, 2012
Messages
1,870
No, Triggering unit doesn't get replaced if it is casted by multiple units, like I said in my post, it acts like a local variable. The other problems can simply be solved by adding the invulnerable ability instead of making the unit invulnerable with this function.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
No, Triggering unit doesn't get replaced if it is casted by multiple units, like I said in my post, it acts like a local variable. The other problems can simply be solved by adding the invulnerable ability instead of making the unit invulnerable with this function.
No they can not (maybe I am not sure what you mean by "other problems"). If unit was made invulnerable via this ability, and at the 4th second ability casted again you would expect unit to gain +5 seconds of invulnerability, but first cast will make the unit vulnerable in 5th second.
But I agree that its still better than Warseeker's first posted trigger, since it has the same problems but also unnecessary indexing stuff.
 
Last edited:
Level 28
Joined
Feb 18, 2014
Messages
3,576
No, Triggering unit doesn't get replaced if it is casted by multiple units, like I said in my post, it acts like a local variable. The other problems can simply be solved by adding the invulnerable ability instead of making the unit invulnerable with this function.
Hold on a second. I just realised that your trigger makes the caster invulnerable. The OP wants the target of the ability being cast to be invulnerable. :p
@BloodSoul's method seems to work without problems.
Anyway. The reason why I made the trigger complicated is because I've kinda had a similar issue a while back. I think it's about changing the ownership of the target then return it back to its original owner after a few seconds. The problem I've encountred is that if the spell is casted on another unit before the previous unit returns to its former owner, then this latter won't return back.
 
Last edited:
Status
Not open for further replies.
Top