# [Trigger] is there a way to remove an event?

Discussion in 'Triggers & Scripts' started by normalice, Aug 25, 2014.

1. ### normalice

Joined:
Mar 13, 2013
Messages:
267
Resources:
33
Packs:
1
Maps:
31
Tutorials:
1
Resources:
33
I'm trying to change incinerate to do aoe damage on hit rather on death. Here's what I have:

• Incinerate init
• Events
• Unit - A unit Is attacked
• Conditions
• And - All (Conditions) are true
• Conditions
• (Unit-type of (Attacking unit)) Equal to Firelord
• (Level of Incinerate (Arrow) for (Attacking unit)) Greater than 0
• Actions
• Trigger - Add to Incinerate <gen> the event (Unit - (Attacked unit) Takes damage)

and then:

• Incinerate
• Events
• Conditions
• Actions
• Unit Group - Pick every unit in (Units within 200.00 of (Position of (Attacked unit)) matching (((Matching unit) belongs to an enemy of (Owner of (Attacking unit))) Equal to True)) and do (Actions)
• Loop - Actions
• Unit Group - Add (Picked unit) to grp
• Set x = (Number of units in grp)
• Unit Group - Pick every unit in grp and do (Actions)
• Loop - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Level of Incinerate (Arrow) for (Attacking unit)) Equal to 1
• Then - Actions
• Set y = (Min(3.00, (45.00 / (Real(x)))))
• Else - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Level of Incinerate (Arrow) for (Attacking unit)) Equal to 2
• Then - Actions
• Set y = (Min(8.00, (45.00 / (Real(x)))))
• Else - Actions
• Set y = (Min(15.00, (45.00 / (Real(x)))))
• Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - y)
• Unit Group - Remove all units from grp

of course, this builds and builds so that successive attacks on a unit make the damage double/triple/quadruple and so on (since it keeps adding the same event). Is there a way to remove the event added in the first trigger? Obviously, simply using the orb of fire ability data wouldn't work since there is a damage cap (and I want it to do reduced damage to buildings, which I haven't really started working on yet..).

2. ### jonhysone

Joined:
Oct 29, 2012
Messages:
1,240
Resources:
1
Maps:
1
Resources:
1
You simply can't. Why not just use 'Trigger - Turn off trigger' and 'Trigger - Turn on trigger' whenever you want the trigger to run. There is no reliable way to remove events neither in GUI nor in any type of JASS.

So it's best to turn it on and off when you need to.

3. ### normalice

Joined:
Mar 13, 2013
Messages:
267
Resources:
33
Packs:
1
Maps:
31
Tutorials:
1
Resources:
33
i want the trigger to run when a unit takes damage. unfortunately, there is no way to do this unless you specify the unit. And there is no way to do that unless the unit is known beforehand (impossible for this purpose) or you add the unit dynamically to a trigger.

unless I'm missing something?

Joined:
Sep 26, 2009
Messages:
1,968
Resources:
0
Resources:
0

5. ### jonhysone

Joined:
Oct 29, 2012
Messages:
1,240
Resources:
1
Maps:
1
Resources:
1
I am sure there is another way to achieve the same goal. If you explain what the trigger properly does and its goal. We'll try to investigate it and attempt to create a better form for it.

6. ### Gismo359

Joined:
Jul 14, 2011
Messages:
771
Resources:
44
Packs:
4
Maps:
40
Resources:
44
Another solution is creating a trigger for every unit you want the event to affect, and then destroying it when you're done but that wouldn't be very practical.
I'd recommend a damage detection system, as Nichilus suggested. There was a few, last time I checked and they were really easy to use.

7. ### McQvaBlood

Joined:
Jul 3, 2010
Messages:
536
Resources:
44
Packs:
4
Maps:
40
Resources:
44
To actually answer the original question, you can't remove event. You can, however, be pro-active about not adding the event mulitple times, which achieves the same effect like this:
• Create a global variable unit group eg. Incinerate_Group.
• Change the Actions of the first trigger to this:
• Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• ((Attacked unit) is in Incinerate_Group) Equal to False
• Then - Actions
• Unit Group - Add (Attacked unit) to Incinerate_Group
• Trigger - Add to Incinerate <gen> the event (Unit - (Attacked unit) Takes damage)
• Else - Actions
Units should no longer get registered multiple times.

8. ### Nichilus

Joined:
Sep 26, 2009
Messages:
1,968
Resources:
0
Resources:
0
That will still register too many units throughout the game, since the event is not removed when unit dies but stays.
So over the course of the game, that trigger may crash.

That's why DDS has been created - to take care of all units taking damage in the map without having to register that event for each unit.
It will also help him with future spells when he needs to negate dmg, etc.

9. ### chobibo

Joined:
Sep 24, 2005
Messages:
2,697
Resources:
0
Resources:
0
Yeah, just use an existing DDS instead. It's too troublesome to make one anyway.

### Spell Reviewer

Joined:
Jan 18, 2005
Messages:
25,545
Resources:
3
Maps:
1
Spells:
2
Resources:
3
You need to destroy the trigger and then rebuild it to remove events. This works completely leak-lessly in JASS however it can introduce some instability if done incorrectly (do not ask me how to do it correctly as I do not know).

11. ### Mythic

Joined:
Apr 24, 2012
Messages:
7,728
Resources:
102
Models:
87
Icons:
4
Maps:
3
Spells:
6
Tutorials:
2
Resources:
102
Just use a DDS as mentioned, some offer more control over this.

12. ### normalice

Joined:
Mar 13, 2013
Messages:
267
Resources:
33
Packs:
1
Maps:
31
Tutorials:
1
Resources:
33
alright, I'll take a crack at this DDS thing. Where do i find it?

Joined:
Jul 14, 2011
Messages:
771
Resources:
44
Packs:
4
Maps:
40
Resources:
44

Joined:
Sep 24, 2005
Messages:
2,697
Resources:
0
Resources:
0
15. ### sethmachine

Joined:
Aug 7, 2013
Messages:
1,318
Resources:
0
Resources:
0
By instability you mean it can cause the game to crash if the trigger is destroyed at an inappropriate time?

### Spell Reviewer

Joined:
Jan 18, 2005
Messages:
25,545
Resources:
3
Maps:
1
Spells:
2
Resources:
3
Yes, something like it can still have executions queued up when you destroy it resulting in bad stuff happening. No one explain to me what exactly happened because they thought I was too stupid for some silly reason.

17. ### Gismo359

Joined:
Jul 14, 2011
Messages:
771
Resources:
44
Packs:
4
Maps:
40
Resources:
44
Do you mean this bug? As far as I know it was patched, but I dont remember where I read it. I was wrong.

Last edited: Aug 26, 2014

### Spell Reviewer

Joined:
Jan 18, 2005
Messages:
25,545
Resources:
3
Maps:
1
Spells:
2
Resources:
3
There were no official patch notes regarding it. However there were patches since that time so it is quite possible it was patched at some stage (hidden change).

Again its all so vague. There is no "chance" in computer science. Leaking is not a good alternative either.

Why is something so easy in SC2 so hard in WC3...

19. ### Gismo359

Joined:
Jul 14, 2011
Messages:
771
Resources:
44
Packs:
4
Maps:
40
Resources:
44
There were multiple conclusions by cohadar and masda in multiple threads, but I couldnt find them all and they werent nearly as consistent and 'logical' as Vex's, from what I remember. Anyways, if anyone has a more indepth and justified explanation to the actual cause of the problem he hasnt posted it anywhere from what I could find.

Joined:
Sep 24, 2005
Messages:
2,697
Resources:
0
Resources:
0