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

make target of spell invulnerable?

Status
Not open for further replies.
Level 22
Joined
Sep 24, 2005
Messages
4,821
You could add the Invulnerable ability to the unit, there's also a GUI action that makes a unit invulnerable.
 
[trigger=]Spell
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Channel
Actions
Unit - Add Divine Shield (Neutral Hostile) to (Target unit of ability being cast)
Unit - Add Item Mana Bonus (Greater) to (Target unit of ability being cast)
Unit - Set mana of (Triggering unit) to 100.00%
Unit - Order (Target unit of ability being cast) to Human Paladin - Activate Divine Shield
[/trigger]
[trigger=]Spell Part 2
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Divine Shield (Neutral Hostile)
Actions
Unit - Remove Divine Shield (Neutral Hostile) from (Triggering unit)
Unit - Remove Item Mana Bonus (Greater) from (Triggering unit)

[/trigger]
Then just edit the dummy ability of divine shield to the time you want, this would be the simple way out. I will add a more complex/proper method later if nobody else does before me.

EDIT: You can easily remove the mana stuff, it was just there because I didn't edit the spell in object editor.
 
Last edited:
Level 13
Joined
Mar 24, 2013
Messages
1,105
Dat-C3 has a cute way of doing it, although I think you should make mana cost 0, because full mana is probably not intended...

Just write a trigger that takes units, gives them the invulnerability, then after whatever duration you want, make them vulnerable. Just Index it, should be quite simple to do.
 
I think a trigger for mana is not necessary, because the spell comes from the caster and takes the maan of the caster. Actually what I want to do is the spell Divine protection which is a divinse shield which can be cast on alllies, except the Paladin. But the Divine shield do function only for itself, so I look forward to customize it. Right now checking if the trigger will work.
 
Ok,
  • Untitled Trigger 001
    • Events
      • Unit - Paladin 0000 <gen> Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Divine Protection
    • Actions
      • Unit - Make (Target unit of ability being cast) Invulnerable
How Do I detect the rank of the Divine protection, 1,2,3, because they have different duration
OR
how do I detect when the effect of the Divine shield is expired and set the unit back to vulnerable?
 
Last edited:
If you want it to use like you've posted than you can do like this


  • Events
    • Einheit - A unit starts the effect of an ability
  • Conditions
    • (Ability being cast) == YourAbility
  • Actions
    • Custom script: local unit u
    • Custom script: set u = GetSpellTargetUnit()
    • Set Duration = ((Real((Level of (Ability being cast) for (Triggering unit)))) x 5.00)
    • Custom script: call SetUnitInvulnerable( u, true )
    • Wait Duration seconds
    • Custom script: call SetUnitInvulnerable( u, false )
Local unit, because after waits global variable could get overwritten.
Duration is a variable of type 'real'. It's set by a constant value (5) x LevelOfAbility for Unit (converted Integer into real)

If you want very accurate methode maybe you could use a periodc event or timers instead of the wait :thumbs_up:

btw, for buffs there is a simple boolean comparrison, if unit has buff = true
 
  • Cast
    • Events
      • Unit - Paladin 0000 <gen> Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Divine Protection
    • Actions
      • Unit - Make (Target unit of ability being cast) Invulnerable
  • paladins
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Paladin 0000 <gen> has buff Divine Protection) Equal to False
        • Then - Actions
          • Unit - Make Paladin 0000 <gen> Vulnerable
        • Else - Actions
Causing Problem?
  • archmages
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
      • (Archmage 0001 <gen> has buff Divine Protection) Equal to False
    • Actions
      • Unit - Make Archmage 0001 <gen> Vulnerable
Something is wrong here... The Invulnerable appear only for 0.10 secs? :D why, when the condition is not met?
Also I made like these for the rest 5 ally units so they can be bubbled too.

Can the rest allies' triggers be the problem? Thsi worked when there was a trigger only for the Paladin :O Why the triggers for other heroes cause the invulnerability to disappear????

- Yeah I figured the problem myself :D I had to change every periodic event different - thank you forum ;)
 
Last edited:
Looks like someone already posted the complex method and you didn't want it stan so I will post exactly what you seem to want. The way your doing it now is bad and uses up un-required RAM. Try to use a way that you don't need so many triggers like the way that is shown in the attachment below. Fyi my other method did work unless you wanted to use purge in your map. Then I am not sure still it was a good method too.
 

Attachments

  • ezinvulforstan.w3x
    16.4 KB · Views: 48
Looks like someone already posted the complex method and you didn't want it stan so I will post exactly what you seem to want. The way your doing it now is bad and uses up un-required RAM. Try to use a way that you don't need so many triggers like the way that is shown in the attachment below. Fyi my other method did work unless you wanted to use purge in your map. Then I am not sure still it was a good method too.

  • gruopstanivul
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • (Number of units in invulgroup) Greater than 0
    • Actions
      • Unit Group - Pick every unit in invulgroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering unit) has buff Divine Shield) Equal to True
            • Then - Actions
            • Else - Actions
              • Unit - Make (Picked unit) Vulnerable
              • Unit Group - Remove (Picked unit) from invulgroup
After many tries - i did exactly your trigger :D - the unit becomes invul but stays this way. I like to do things simpel so I\ll get back to mine D:
 
Last edited:
Yes, i saw my mistake already.. Still dont work :/ I dont think im doing anything wrong am I? the unit stays unvil even after expire of effect
  • remove invul
    • Events
      • Time - Every 0.12 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in DIVINE_PROT and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering unit) has buff Divine Protection) Equal to True
            • Then - Actions
              • Unit - Make (Picked unit) Vulnerable
              • Unit Group - Remove (Picked unit) from DIVINE_PROT
            • Else - Actions
So I think mine works even if takes RAM(for timers)
 
  • remove invul
    • Events
      • Time - Every 0.12 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in DIVINE_PROT and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Divine Protection) Equal to True
            • Then - Actions
              • Unit - Make (Picked unit) Vulnerable
              • Unit Group - Remove (Picked unit) from DIVINE_PROT
            • Else - Actions
Now Everything is Ok, right? :thumbs_up: still the unit stays with invulnerability after the effcet expires :thumbs_up:
 
I don't see your issue here stan0033, the trigger I gave you works perfectly. Do you apply the buff and make sure it has a set duration?

Also for a trigger/spell like this you shouldn't need 0.12 seconds and you should add a condition so the trigger isn't running all the time.

Example -
(Number of units in DIVINE_PROT) Greater than 0
 
Status
Not open for further replies.
Top