HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Question regarding Removing Events

12-06-2006, 12:26 AM#1
Pyrogasm
Ok, there's a way to dynamically add an event to a trigger, but is there a way (with custom script(s), 'cause I don't really know JASS) to remove an event from a trigger or clear all events from a trigger? Also, if I use a trigger to add an event to a trigger every time some action happens, will the action be added multiple times on top of itself as a new event, or will the game realize that the event is already there and won't add it.

Question 2: For the event "Unit - A unit takes damage", is there a way to check for the type of damage (physical/spell) or check to see if the source was a spell?
12-06-2006, 12:46 AM#2
wyrmlord
Quote:
Originally Posted by Pyrogasm
Ok, there's a way to dynamically add an event to a trigger, but is there a way (with custom script(s), 'cause I don't really know JASS) to remove an event from a trigger or clear all events from a trigger? Also, if I use a trigger to add an event to a trigger every time some action happens, will the action be added multiple times on top of itself as a new event, or will the game realize that the event is already there and won't add it.

Question 2: For the event "Unit - A unit takes damage", is there a way to check for the type of damage (physical/spell) or check to see if the source was a spell?

1. I don't think there is a function to remove an event from a trigger. Also, I'm not entirely sure, but I think the same event might be able to be added twice. If you kept adding more and move events, it would use up more and more memory, but I heard somewhere that if you destroy a trigger, it frees up the memory used by the events, but I'm not entirely sure on that.

2. There is no 100% way to be sure of this. Most systems add an orb ability to each unit so when a unit is damaged, it checks the unit to see if it has the buff from that orb ability and if it does, assumes the unit took damage from an attack and otherwise assumes the damage source was a spell.
12-06-2006, 01:12 AM#3
shadow1500
Quote:
I heard somewhere that if you destroy a trigger, it frees up the memory used by the events, but I'm not entirely sure on that.
Destroying a trigger will free the memory used by events. You cannot remove individual events from a trigger, you must clone it but without the said event.

Quote:
2. There is no 100% way to be sure of this. Most systems add an orb ability to each unit so when a unit is damaged, it checks the unit to see if it has the buff from that orb ability and if it does, assumes the unit took damage from an attack and otherwise assumes the damage source was a spell.
It is 100% reliable. The idea is to give the frost orb ability to all units in the map, then the damage detection trigger must check if the damaged unit has the buff, if he does, remove it and execute the actions on attack, otherwise execute the actions on spell/trigger damage.
12-06-2006, 01:15 AM#4
wyrmlord
Quote:
Originally Posted by shadow1500
It is 100% reliable. The idea is to give the frost orb ability to all units in the map, then the damage detection trigger must check if the damaged unit has the buff, if he does, remove it and execute the actions on attack, otherwise execute the actions on spell/trigger damage.

If you do it this way, you'll need to make sure units don't have some other abilities with orb effects which could possibly (I haven't tested this) mess the system up and cause the Frost Orb buff not to appear. That's why I said the system wasn't 100% reliable.
12-06-2006, 01:22 AM#5
shadow1500
It is 100% reliable in detection, which is what I thought you meant by your response:
Quote:
is there a way to check for the type of damage (physical/spell) or check to see if the source was a spell?
Quote:
There is no 100% way to be sure of this.
12-06-2006, 03:44 AM#6
Pyrogasm
So if I were making a spell using the "A unit takes damage" event that would be for a hero to be used in melee maps... that would complicate things a lot, wouldn't it? In order to accomplish this I would have to add an orb effect to each unit in the entire game, right? Would a workaround like this be possible? (The spell idea is that it creates a pool of sludge at target location, which slows affected units' movespeed and damages them as they attack)
Initilization Add:
Initilization Add
Collapse Events
Map initialization
Conditions
Collapse Actions
Unit Group - Pick every unit in (Units in (Playable map area)) and do (Trigger - Add to Damage for Attack <gen> the event (Unit - (Triggering unit) Takes damage))
Enter Add:
Enter
Collapse Events
Unit - A unit enters (Playable map area)
Conditions
Collapse Actions
Trigger - Add to Damage for Attack <gen> the event (Unit - (Attacked unit) Takes damage)
Physical Attack Detect:
Physical Attack Detect
Collapse Events
Unit - A unit Is attacked
Collapse Conditions
Collapse Or - Any (Conditions) are true
Collapse Conditions
((Attacking unit) has buff Toxic Splatter (Level 1)) Equal to True
((Attacking unit) has buff Toxic Splatter (Level 2)) Equal to True
((Attacking unit) has buff Toxic Splatter (Level 3)) Equal to True
Collapse Actions
Unit - Create 1 Dummy for (Owner of (Attacked unit)) at (Position of (Attacked unit)) facing Default building facing degrees
Unit - Add Toxic Splatter (Dummy) to (Last created unit)
Unit - Order (Last created unit) to Undead Necromancer - Unholy Frenzy (Attacked unit)
Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
The "Toxic Splatter (Dummy)" ability would have a ~.02 duration.
Damage for Attack:
Damage for Attack
Events
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Attacked unit) has buff Toxic Splatter (Attack Detect Buff)) Equal to True
Collapse Then - Actions
If (((Damage source) has buff Toxic Splatter (Level 1)) Equal to True) then do (Unit - Cause (Damage source) to damage (Damage source), dealing ((Damage taken) x 0.66) damage of attack type Spells and damage type Disease) else do (Do nothing)
If (((Damage source) has buff Toxic Splatter (Level 2)) Equal to True) then do (Unit - Cause (Damage source) to damage (Damage source), dealing ((Damage taken) x 1.33) damage of attack type Spells and damage type Disease) else do (Do nothing)
If (((Damage source) has buff Toxic Splatter (Level 3)) Equal to True) then do (Unit - Cause (Damage source) to damage (Damage source), dealing ((Damage taken) x 2.00) damage of attack type Spells and damage type Disease) else do (Do nothing)
Collapse Else - Actions
Do nothing
The Spell Cast Part:
Pretty Stuff
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Toxic
Collapse Actions
Set TempPoint[1] = (Target point of ability being cast)
Unit - Create 1 Dummy for (Owner of (Triggering unit)) at TempPoint[1] facing Default building facing degrees
Unit - Add Splatter Slow to (Last created unit)
Unit - Set level of Splatter Slow for (Last created unit) to (Level of Toxic for (Triggering unit))
Unit - Add a 22.00 second Generic expiration timer to (Last created unit)
Collapse For each (Integer A) from 1 to (2 + (5 x (Level of Toxic for (Triggering unit)))), do (Actions)
Collapse Loop - Actions
Unit - Create 1 Dummy for (Owner of (Triggering unit)) at TempPoint[1] facing Default building facing degrees
Unit - Add Toxic Splatter (Dummy) to (Last created unit)
Unit - Set level of Toxic Splatter (Dummy) for (Last created unit) to (Level of Toxic for (Triggering unit))
Unit - Order (Last created unit) to Human Blood Mage - Flame Strike TempPoint[1]
Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
Unit - Create 1 Dummy for (Owner of (Triggering unit)) at TempPoint[1] facing Default building facing degrees
Collapse For each (Integer B) from 1 to (Level of Toxic for (Triggering unit)), do (Actions)
Collapse Loop - Actions
Unit - Add Toxic Splatter (Other Dummy) to (Last created unit)
Unit - Set level of Toxic Splatter (Other Dummy) for (Last created unit) to (Level of Toxic for (Triggering unit))
Unit - Order (Last created unit) to Human Blood Mage - Flame Strike TempPoint[1]
Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
Custom script: call RemoveLocation( udg_TempPoint[1] )

Might that work, or would it get screwed up by units that have long delays between when it "attack" to when it "deals damage", eg. Meat Wagons/Catapults?