I have a spell idea that I think would require an action that allows you to remove an event from a trigger.
IDEA: Stun-shield. Creates a buff on a target unit. Any unit that attacks the buffed unit will be stunned for 3 seconds. There is only one hero who can cast it in my campaign, so it doesn't have to be MUI or anything. There will only ever be 1 unit in the game (at a time) that has the shield on them.
To work, I plan on having two triggers:
Trigger #1: fires when the shield buff is applied to a unit. Adds the event "Unit X is attacked" to Trigger #2.
Trigger #2: Fires when that unit is attacked. Summons an invisible unit to thunderbolt the attacker.
My problem, is how to remove that event when the spell is cast on a second unit? For example, if the spell is cast on a footman, Trigger #2 will fire when that specific footman is attacked. But then the hero casts it on a rifleman. Now I want to the first buff to go away (that's easy to do), but I also want the Event in Trigger #2 to be removed. Is there any way using JASS or custom code to remove an event from a trigger that was put there before?
I could just store the shielded unit as a variable and put a condition in Trigger #2 (does unitX = attacked unit). But if the hero casts the shield on 20 or 40 or 60 units in a given game then Trigger #2 would have 60 events. That could get messy I'd think.
I hope this makes sense, please ask questions if I can clarify.
IDEA: Stun-shield. Creates a buff on a target unit. Any unit that attacks the buffed unit will be stunned for 3 seconds. There is only one hero who can cast it in my campaign, so it doesn't have to be MUI or anything. There will only ever be 1 unit in the game (at a time) that has the shield on them.
To work, I plan on having two triggers:
Trigger #1: fires when the shield buff is applied to a unit. Adds the event "Unit X is attacked" to Trigger #2.
Trigger #2: Fires when that unit is attacked. Summons an invisible unit to thunderbolt the attacker.
My problem, is how to remove that event when the spell is cast on a second unit? For example, if the spell is cast on a footman, Trigger #2 will fire when that specific footman is attacked. But then the hero casts it on a rifleman. Now I want to the first buff to go away (that's easy to do), but I also want the Event in Trigger #2 to be removed. Is there any way using JASS or custom code to remove an event from a trigger that was put there before?
I could just store the shielded unit as a variable and put a condition in Trigger #2 (does unitX = attacked unit). But if the hero casts the shield on 20 or 40 or 60 units in a given game then Trigger #2 would have 60 events. That could get messy I'd think.
I hope this makes sense, please ask questions if I can clarify.