[Trigger] (GUI) Can't Remove Anti-Magic Shield Buff

Level 48
Joined
Jul 29, 2008
Messages
9,824
This seems like it should be so so so simple. Yet it doesn't work.

I'm using the OG Anti-Magic Shell (the one that imparts full magic immunity, not the one with 'shield life') as the base for a similar custom ability. Most of the important fields are the same, the ability functions properly with allies & deals damage to enemy summoned units.

However, targeting enemy units gives them the 'AMS' too, which I definitely do not want. I figured it would be as simple as removing the buff... But it simply does not work.

Code:
Poultice
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Poultice (OG Anti-magic Shell)
        ((Target unit of ability being cast) belongs to an enemy of (Owner of (Casting unit))) Equal to True
    Actions
        Unit - Remove Poultice buff from (Target unit of ability being cast)

(I have already been recommended to use a 0-sec timer and/or a set of dummy-casted abilities to accomplish this, which I will probably end up doing. But I wanted to see if there was any insight from the Hive about "unremovable buffs"?)
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,860
I doubt the buff is unremovable, it's just not on the unit yet hence the need for a delay. The "Starts the effect of an ability" Event isn't guaranteed to occur after the buff(s) have been applied. The timing could vary from ability to ability based on how they were coded. But most likely all abilities will apply their Buffs AFTER this Event fires.

Edit (deleted other comment after re-reading)

Here's some triggers that would ensure the buff gets removed properly:
  • AMS Add
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Anti-magic Shell
      • ((Target unit of ability being cast) has buff Anti-magic Shell (Unwanted)) Equal to False
      • ((Target unit of ability being cast) belongs to an enemy of (Triggering player)) Equal to True
    • Actions
      • Unit Group - Add (Target unit of ability being cast) to AMS_Remove_Group
      • Set VariableSet AMS_Remove_Count = (AMS_Remove_Count + 1)
      • Trigger - Turn on AMS Remove Loop <gen>
  • AMS Remove
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in AMS_Remove_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Anti-magic Shell) Equal to True
            • Then - Actions
              • Unit - Remove Anti-magic Shell (Unwanted) buff from (Picked unit)
              • Unit Group - Remove (Picked unit) from AMS_Remove_Group.
              • Set VariableSet AMS_Remove_Count = (AMS_Remove_Count - 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is alive) Equal to False
                • Then - Actions
                  • Unit Group - Remove (Picked unit) from AMS_Remove_Group.
                  • Set VariableSet AMS_Remove_Count = (AMS_Remove_Count - 1)
                • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AMS_Remove_Count Less than or equal to 0
        • Then - Actions
          • Set VariableSet AMS_Remove_Count = 0
          • Trigger - Turn off AMS Remove <gen>
        • Else - Actions
 

Attachments

  • AMS trigs.w3m
    17.4 KB · Views: 4
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,860
Oh nice, another solid solution. I already had two 😅 (see above), but I do greatly appreciate it (especially the full code)

Your comment makes me wonder... Could it also be as simple as not using "starts the effect of an ability", and instead using "finishes casting an ability" or something? 🤔
None of the other Events are safe to use. Begins Casting is obviously too early, Finishes Casting can be interrupted and skipped entirely, and Stops Casting has no reference to the (Target unit of ability being cast) - which may be true for Finishes as well.

Also, I recommend my approach since it guarantees that the buff gets removed regardless of how long the "buff application delay" is. Oh and I edited my previous post to fix a mistake I was making in the second trigger.
 
Level 48
Joined
Jul 29, 2008
Messages
9,824
None of the other Events are safe to use. Begins Casting is obviously too early, Finishes Casting can be interrupted and skipped entirely, and Stops Casting has no reference to the (Target unit of ability being cast) - which may be true for Finishes as well.
Dang!

Though you got me thinking... I might actually be fine with "finishes casting" if the only interruption possible is a player-driven one (i.e. the owner of the unit cancelling mid-cast), since that's only going to be bad for them (naturally disincentivized behavior)

But if you mean "interruption" to include the likes of Storm Bolt or other stuns (that an enemy could inflict on the caster)... Then yeah.

Also, I recommend my approach since it guarantees that the buff gets removed regardless of how long the "buff application delay" is. Oh and I edited my previous post to fix a mistake I was making in the second trigger.
Oh definitely, you're method is one of the ones I'd label "Correct"; I'm just tinkering with jank on the side. 😉

I see the addition of the "living" check. That makes sense, though it makes me wonder if there should be an overall group check, stripping out all the dead units?

==

On a related tangent, I wonder how best to use a set of triggers like this. This isn't actually the first time someone has suggested I use this sort of "periodically modulated group" thing; it's sort of a widely useful tool. Which leads me to wonder: is there any merit / is it common / would it work to simply run all such abilities through a singular set of such triggers?

Like, if I end up with a project where 10 custom abilities require this solution, I'm looking at 20 separate triggers (& variables and all that) to support it, which just seems excessive. What if I ran them all through one singular set of triggers?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,860
Dang!

Though you got me thinking... I might actually be fine with "finishes casting" if the only interruption possible is a player-driven one (i.e. the owner of the unit cancelling mid-cast), since that's only going to be bad for them (naturally disincentivized behavior)

But if you mean "interruption" to include the likes of Storm Bolt or other stuns (that an enemy could inflict on the caster)... Then yeah.


Oh definitely, you're method is one of the ones I'd label "Correct"; I'm just tinkering with jank on the side. 😉

I see the addition of the "living" check. That makes sense, though it makes me wonder if there should be an overall group check, stripping out all the dead units?

==

On a related tangent, I wonder how best to use a set of triggers like this. This isn't actually the first time someone has suggested I use this sort of "periodically modulated group" thing; it's sort of a widely useful tool. Which leads me to wonder: is there any merit / is it common / would it work to simply run all such abilities through a singular set of such triggers?

Like, if I end up with a project where 10 custom abilities require this solution, I'm looking at 20 separate triggers (& variables and all that) to support it, which just seems excessive. What if I ran them all through one singular set of triggers?
I would definitely just copy and paste what I made for you, I mean it'd probably take 30 seconds to transfer it between maps.

Edit:
The "living" check is just a fail-safe. It's probably unnecessary now that I think about it since a dead unit cannot have buffs... In fact you probably just want something like this:
  • AMS Remove
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in AMS_Remove_Group and do (Actions)
        • Loop - Actions
          • Unit - Remove Anti-magic Shell (Unwanted) buff from (Picked unit)
          • Unit Group - Remove (Picked unit) from AMS_Remove_Group.
          • Set VariableSet AMS_Remove_Count = (AMS_Remove_Count - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AMS_Remove_Count Less than or equal to 0
        • Then - Actions
          • Set VariableSet AMS_Remove_Count = 0
          • Trigger - Turn off AMS Remove <gen>
        • Else - Actions
This makes more sense to me, it'll always delay the buff check by at least 1 frame which is all you should need.

Also, 20 triggers is far from excessive, big custom maps can have 1000's of triggers, 1000's of variables, etc. You shouldn't notice any serious performance problems if that's your concern, although your trigger editor will bog down if you have too much stuff. But again, 20 triggers won't make it break a sweat.

There are solutions out there that let you sort of automate the process of these kinds of triggers, but you need to learn how to use them as well. Something like Bribe's spell system. Probably overkill for only 10 custom abilities.
 
Last edited:
Top