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

Trigger issue

Status
Not open for further replies.
Level 5
Joined
Jul 5, 2014
Messages
155
I have some odd issue which I don't understand especially because earlier this trigger seemed to work. My goal would be to make certain Dragon unit vulnerable to magic attack, yet making it immune to buffs/debuffs. This is the trigger I'm trying to use, but it doesn't work for some reason.




  • Dragon magic immunity
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Unit-type of (Target unit of ability being cast)) Equal to Dragon
    • Actions
      • Wait 2.00 seconds
      • Unit - Remove All buffs from (Target unit of ability being cast)
 
Level 11
Joined
Nov 23, 2013
Messages
665
I think the problem comes from the Wait action. During these 2 seconds, many things can happen, including units casting spells: if several units cast spells to several targets, this is gonna mess things up and this is likely to change the Target unit of ability being cast. A solution would be to remove the Wait action, or to make your trigger MUI (see this tutorial)
Also, I'm not sure about this but you might want to use the event A unit Finishes casting an ability or A unit Starts the effect of an ability instead of Begins and see if it improves the trigger
 
Level 13
Joined
May 10, 2009
Messages
868
If I recall correctly, the function (Target unit of ability being cast) does not work after waits. You'd have to store the target in a variable, and then reference it after the wait. Though, by only using a global variable you'd also have the problem of overriding it with multiple units/casts within a short time. It's possible to work around that by using a local variable plus a global one. Like this:

upload_2018-10-15_23-35-44.png


  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Unit-type of (Target unit of ability being cast)) Equal to Footman
  • Actions
    • Custom script: local unit u = GetSpellTargetUnit()
    • Wait 2.00 seconds
    • Custom script: set udg_uVar = u
    • Unit - Remove All buffs from uVar
    • Custom script: set u = null
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
If I recall correctly, the function (Target unit of ability being cast) does not work after waits. You'd have to store the target in a variable, and then reference it after the wait. Though, by only using a global variable you'd also have the problem of overriding it with multiple units/casts within a short time. It's possible to work around that by using a local variable plus a global one. Like this:

View attachment 308095

  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Unit-type of (Target unit of ability being cast)) Equal to Footman
  • Actions
    • Custom script: local unit u = GetSpellTargetUnit()
    • Wait 2.00 seconds
    • Custom script: set udg_uVar = u
    • Unit - Remove All buffs from uVar
    • Custom script: set u = null

can be simplified to:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Unit-type of (Target unit of ability being cast)) Equal to Footman
  • Actions
    • Custom script: local unit udg_uVar = GetSpellTargetUnit()
    • Wait 2.00 seconds
    • Unit - Remove All buffs from uVar
I am actually unsure if you need to null when using the shadowing technique but I'll guess no.
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,892
can be simplified to:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Unit-type of (Target unit of ability being cast)) Equal to Footman
  • Actions
    • Custom script: local unit udg_uVar = GetSpellTargetUnit()
    • Wait 2.00 seconds
    • Unit - Remove All buffs from uVar
I am actually unsure if you need to null when using the shadowing technique but I'll guess no.
And that can be even simplified by not creating a global variable in first place, saves a useless variable for some space :D
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,892
But Wrda without a global you can't use the variable in GUI actions, which the OP clearly does need to do.
Oh that. Well, i thought he was going/could to use UnitRemoveBuffs function so that he didn't need global variable, but if he wants to keep the GUI actions because of not having such knowledge then fair enough.

It does not even save space? the global takes the same space as a local one
Unless we're talking memory, but in terms of lines there is no difference.
I was talking about how it saves space in the variable editor and other GUI actions that have that type, not memory. You see... I usually tend to avoid to create unnecessary variables so that they don't fill in the variable editor and GUI actions, specially on maps that already have a quite good amount of variables.
 
Level 5
Joined
Jul 5, 2014
Messages
155
can be simplified to:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Unit-type of (Target unit of ability being cast)) Equal to Footman
  • Actions
    • Custom script: local unit udg_uVar = GetSpellTargetUnit()
    • Wait 2.00 seconds
    • Unit - Remove All buffs from uVar
I am actually unsure if you need to null when using the shadowing technique but I'll guess no.


This trigger solves the targeted buffs, but things like scroll of protection doesn't come off.
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,892
This trigger solves the targeted buffs, but things like scroll of protection doesn't come off.
Of course not, scroll of protection neither a targetable nor stoppable order, you will need to check whether the unit you want to remove the buff it is in range of caster and then remove it.
Edit: Apparently the item has no string order so you need to make an if statement with custom script: if GetIssuedOrderId() == 852008 then
This is the order id of scroll of protection
 
Last edited:
Level 5
Joined
Jul 5, 2014
Messages
155
Of course not, scroll of protection neither a targetable nor stoppable order, you will need to check whether the unit you want to remove the buff it is in range of caster and then remove it.
Edit: Apparently the item has no string order so you need to make an if statement with custom script: if GetIssuedOrderId() == 852008 then
This is the order id of scroll of protection

Uhh, so in case of area buffs like SoP or Roar, I have to manually put every single one in triggers instead of having some global detection for ANY buff on the unit type?
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,892
Uhh, so in case of area buffs like SoP or Roar, I have to manually put every single one in triggers instead of having some global detection for ANY buff on the unit type?
Yes i think so, by the way, are auras also supposed to be removed from the immune unit? There is another way to do all of this but I wouldn't really recommend it.
 
Level 5
Joined
Jul 5, 2014
Messages
155
Yes i think so, by the way, are auras also supposed to be removed from the immune unit? There is another way to do all of this but I wouldn't really recommend it.

I think auras are okay. For buffs, I'd prefer a minimal time (hence why the 2 sec), but if its too painstaking, I'd be okay with instant removal.
 
Status
Not open for further replies.
Top