I made a spell based on the Fireball Barrage spell in Warhammer Online. It is a channeled spell that launches three fireballs at the target - one when cast and one per second for two seconds.
So I made the spell with 4 triggers and it works just fine, except it continues to launch the last two fireballs even when I give the caster a new order.
Don't go telling me it's my use of "current_hashtable" and "current_group," because all my triggered spells use it and they work fine (even the channeled ones). This is just a trick I made so I don't have to go in and change every line when I make spells that are similar.
So here is the code and a short explanation:
Trigger 1 - When the spell is cast, this saves all the needed information and initializes the channel trigger. Turns on periodic trigger 2.
Trigger 2 - The spell is made of 20 ticks, saved as an integer. Each 0.10 seconds of channel adds 1 tick. This trigger shuts off itself and trigger 4 if the number of ticks exceeds 20, and creates a fireball missle at ticks 0, 10, and 20. Turns on triggers 3 and 4.
Trigger 3 - Selects all existing fireballs and guides them to their targets, causes the damage if the missle is close enough to the target. Turns off itself when no fireballs exist.
Trigger 4 - Turns off trigger 2 (by setting ticks to 21) if the caster stops channeling - this one is not working.
For reference, here is a similar spell based on the same class from Warhammer; Withering Heat. This spell works a lot like Mindflay in World of Warcraft. This spell works and exits properly when the caster is ordered to do something else. The same idea here, except it only needs 3 triggers since no missles are created.
So I made the spell with 4 triggers and it works just fine, except it continues to launch the last two fireballs even when I give the caster a new order.
Don't go telling me it's my use of "current_hashtable" and "current_group," because all my triggered spells use it and they work fine (even the channeled ones). This is just a trick I made so I don't have to go in and change every line when I make spells that are similar.
So here is the code and a short explanation:
Trigger 1 - When the spell is cast, this saves all the needed information and initializes the channel trigger. Turns on periodic trigger 2.
-
Fireball Barrage 1
-
Events
- Unit - A unit Starts the effect of an ability
-
Conditions
- (Ability being cast) Equal to BWZ.U - Fireball Barrage [R]
-
Actions
- Set current_hashtable = H_FireballBarrage
- Set current_group = FireballBarrageCasters
- Set SpellDamage_Base = 100.00
- Set SpellDamage_Level = 50.00
- Set Spellpower_Coefficient = 0.50
- Hashtable - Save ((SpellDamage_Base + (SpellDamage_Level x (Real((Level of (Ability being cast) for (Triggering unit)))))) + (Spellpower_Coefficient x (Load 100 of (Key (Triggering unit)) from H_Spellpower))) as (Key damage) of (Key (Triggering unit)) in current_hashtable
- Hashtable - Save 2.00 as (Key duration) of (Key (Triggering unit)) in current_hashtable
- Hashtable - Save 30.00 as (Key mana/sec) of (Key (Triggering unit)) in current_hashtable
- Hashtable - Save Handle Of(Target unit of ability being cast) as (Key target) of (Key (Triggering unit)) in current_hashtable
- Special Effect - Create a special effect attached to the hand, left of (Triggering unit) using Abilities\Spells\Other\BreathOfFire\BreathOfFireDamage.mdl
- Hashtable - Save Handle Of(Last created special effect) as (Key left hand) of (Key (Triggering unit)) in current_hashtable
- Special Effect - Create a special effect attached to the hand, right of (Triggering unit) using Abilities\Spells\Other\BreathOfFire\BreathOfFireDamage.mdl
- Hashtable - Save Handle Of(Last created special effect) as (Key right hand) of (Key (Triggering unit)) in current_hashtable
- Hashtable - Save 0 as (Key ticks) of (Key (Triggering unit)) in current_hashtable
- Unit Group - Add (Triggering unit) to current_group
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Fireball Barrage 2 <gen> is on) Equal to False
-
Then - Actions
- Trigger - Turn on Fireball Barrage 2 <gen>
- Trigger - Turn on Fireball Barrage 4 <gen>
- Else - Actions
-
If - Conditions
- Custom script: set udg_current_hashtable = null
- Custom script: set udg_current_group = null
-
Events
Trigger 2 - The spell is made of 20 ticks, saved as an integer. Each 0.10 seconds of channel adds 1 tick. This trigger shuts off itself and trigger 4 if the number of ticks exceeds 20, and creates a fireball missle at ticks 0, 10, and 20. Turns on triggers 3 and 4.
-
Fireball Barrage 2
-
Events
- Time - Every 0.10 seconds of game time
- Conditions
-
Actions
- Set current_hashtable = H_FireballBarrage
- Set current_group = FireballBarrageCasters
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Number of units in current_group) Greater than 0
-
Then - Actions
-
Unit Group - Pick every unit in current_group and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Load (Key ticks) of (Key (Picked unit)) from current_hashtable) Greater than 20
-
Then - Actions
- Special Effect - Destroy (Load (Key left hand) of (Key (Picked unit)) in current_hashtable)
- Special Effect - Destroy (Load (Key right hand) of (Key (Picked unit)) in current_hashtable)
- Unit Group - Remove (Picked unit) from current_group
- Hashtable - Clear all child hashtables of child (Key (Picked unit)) in current_hashtable
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Load (Key ticks) of (Key (Picked unit)) from current_hashtable) mod 10) Equal to 0
-
Then - Actions
- Set temp_point[0] = (Position of (Picked unit))
- Set temp_point[1] = (temp_point[0] offset by 50.00 towards (Facing of (Picked unit)) degrees)
- Custom script: call RemoveLocation( udg_temp_point[0] )
- Unit - Create 1 fireball for (Owner of (Picked unit)) at temp_point[1] facing (Facing of (Picked unit)) degrees
- Custom script: call RemoveLocation( udg_temp_point[1] )
- Hashtable - Save (Load (Key damage) of (Key (Picked unit)) from current_hashtable) as (Key damage) of (Key (Last created unit)) in current_hashtable
- Hashtable - Save Handle Of(Picked unit) as (Key caster) of (Key (Last created unit)) in current_hashtable
- Hashtable - Save Handle Of(Load (Key target) of (Key (Picked unit)) in current_hashtable) as (Key target) of (Key (Last created unit)) in current_hashtable
- Hashtable - Save 200.00 as (Key radius) of (Key (Last created unit)) in current_hashtable
- Hashtable - Save 600.00 as (Key speed) of (Key (Last created unit)) in current_hashtable
- Hashtable - Save 30.00 as (Key speedmod) of (Key (Last created unit)) in current_hashtable
- Unit Group - Add (Last created unit) to FireballBarrageMissles
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Fireball Barrage 3 <gen> is on) Equal to False
-
Then - Actions
- Trigger - Turn on Fireball Barrage 3 <gen>
- Else - Actions
-
If - Conditions
- Else - Actions
-
If - Conditions
- Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - (FPS_DOTSpells x (Load (Key mana/sec) of (Key (Picked unit)) from current_hashtable)))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
- ((Load (Key target) of (Key (Picked unit)) in current_hashtable) is dead) Equal to True
- (Mana of (Picked unit)) Less than (FPS_DOTSpells x (Load (Key mana/sec) of (Key (Picked unit)) from current_hashtable))
-
Conditions
-
Or - Any (Conditions) are true
-
Then - Actions
- Unit - Order (Picked unit) to Stop
- Hashtable - Save 21 as (Key ticks) of (Key (Picked unit)) in current_hashtable
- Else - Actions
-
If - Conditions
- Hashtable - Save ((Load (Key duration) of (Key (Picked unit)) from current_hashtable) - FPS_DOTSpells) as (Key duration) of (Key (Picked unit)) in current_hashtable
- Hashtable - Save ((Load (Key ticks) of (Key (Picked unit)) from current_hashtable) + 1) as (Key ticks) of (Key (Picked unit)) in current_hashtable
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
Unit Group - Pick every unit in current_group and do (Actions)
-
Else - Actions
- Trigger - Turn off Fireball Barrage 4 <gen>
- Trigger - Turn off (This trigger)
-
If - Conditions
- Custom script: set udg_current_hashtable = null
- Custom script: set udg_current_group = null
-
Events
Trigger 3 - Selects all existing fireballs and guides them to their targets, causes the damage if the missle is close enough to the target. Turns off itself when no fireballs exist.
-
Fireball Barrage 3
-
Events
- Time - Every 0.03 seconds of game time
- Conditions
-
Actions
- Set current_hashtable = H_FireballBarrage
- Set current_group = FireballBarrageMissles
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Number of units in current_group) Greater than 0
-
Then - Actions
-
Unit Group - Pick every unit in current_group and do (Actions)
-
Loop - Actions
- Set temp_point[0] = (Position of (Picked unit))
- Set temp_point[1] = (Position of (Load (Key target) of (Key (Picked unit)) in current_hashtable))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Distance between temp_point[0] and temp_point[1]) Less than or equal to (FPS_ProjectileSpells x ((Load (Key speed) of (Key (Picked unit)) from current_hashtable) / 2.00))
-
Then - Actions
- Custom script: call RemoveLocation( udg_temp_point[0] )
- Unit - Kill (Picked unit)
- Special Effect - Create a special effect at temp_point[1] using Abilities\Spells\Other\Incinerate\FireLordDeathExplode.mdl
- Special Effect - Destroy (Last created special effect)
- Set temp_unit[0] = (Load (Key caster) of (Key (Picked unit)) in current_hashtable)
- Set temp_real[0] = (Load (Key damage) of (Key (Picked unit)) from current_hashtable)
- Set temp_group = (Units within (Load (Key radius) of (Key (Picked unit)) from current_hashtable) of temp_point[1] matching ((((Matching unit) belongs to an ally of (Owner of (Picked unit))) Equal to False) and ((((Matching unit) is Mechanical) Equal to False) and (((Matching
- Custom script: call RemoveLocation( udg_temp_point[1] )
-
Unit Group - Pick every unit in temp_group and do (Actions)
-
Loop - Actions
- Unit - Cause temp_unit[0] to damage (Picked unit), dealing temp_real[0] damage of attack type Spells and damage type Fire
- Unit Group - Remove (Picked unit) from temp_group
-
Loop - Actions
- Custom script: call DestroyGroup( udg_temp_group )
- Custom script: set udg_temp_unit[0] = null
- Unit Group - Remove (Picked unit) from current_group
- Hashtable - Clear all child hashtables of child (Key (Picked unit)) in current_hashtable
-
Else - Actions
- Set temp_point[2] = (temp_point[0] offset by (FPS_ProjectileSpells x (Load (Key speed) of (Key (Picked unit)) from current_hashtable)) towards (Angle from temp_point[0] to temp_point[1]) degrees)
- Custom script: call RemoveLocation( udg_temp_point[0] )
- Unit - Move (Picked unit) instantly to temp_point[2], facing temp_point[1]
- Custom script: call RemoveLocation( udg_temp_point[1] )
- Custom script: call RemoveLocation( udg_temp_point[2] )
- Hashtable - Save ((Load (Key speed) of (Key (Picked unit)) from current_hashtable) + (Load (Key speedmod) of (Key (Picked unit)) from current_hashtable)) as (Key speed) of (Key (Picked unit)) in current_hashtable
-
If - Conditions
-
Loop - Actions
-
Unit Group - Pick every unit in current_group and do (Actions)
-
Else - Actions
- Trigger - Turn off (This trigger)
-
If - Conditions
- Custom script: set udg_current_hashtable = null
- Custom script: set udg_current_group = null
-
Events
Trigger 4 - Turns off trigger 2 (by setting ticks to 21) if the caster stops channeling - this one is not working.
-
Fireball Barrage 4
-
Events
- Unit - A unit Is issued an order with no target
- Unit - A unit Is issued an order targeting a point
- Unit - A unit Is issued an order targeting an object
-
Conditions
- ((Triggering unit) is in FireballBarrageCasters) Equal to True
-
Actions
- Hashtable - Save 21 as (Key ticks) of (Key (Triggering unit)) in H_FireballBarrage
-
Events
For reference, here is a similar spell based on the same class from Warhammer; Withering Heat. This spell works a lot like Mindflay in World of Warcraft. This spell works and exits properly when the caster is ordered to do something else. The same idea here, except it only needs 3 triggers since no missles are created.
-
Withering Heat 1
-
Events
- Unit - A unit Starts the effect of an ability
-
Conditions
- (Ability being cast) Equal to BWZ.A1 - Withering Heat [W]
-
Actions
- Set current_hashtable = H_WitheringHeat
- Set current_group = WitheringHeatCasters
- Set SpellDamage_Base = 60.00
- Set SpellDamage_Level = 60.00
- Set Spellpower_Coefficient = 1.00
- Hashtable - Save ((SpellDamage_Base + (SpellDamage_Level x (Real((Level of (Ability being cast) for (Triggering unit)))))) + (Spellpower_Coefficient x (Load 100 of (Key (Triggering unit)) from H_Spellpower))) as (Key damage) of (Key (Triggering unit)) in current_hashtable
- Hashtable - Save 6.00 as (Key duration) of (Key (Triggering unit)) in current_hashtable
- Hashtable - Save 13.00 as (Key mana/sec) of (Key (Triggering unit)) in current_hashtable
- Hashtable - Save Handle Of(Target unit of ability being cast) as (Key target) of (Key (Triggering unit)) in current_hashtable
- Hashtable - Save overhead as 1 of (Key (Triggering unit)) in current_hashtable
- Hashtable - Save hand, left as 2 of (Key (Triggering unit)) in current_hashtable
- Hashtable - Save hand, right as 3 of (Key (Triggering unit)) in current_hashtable
- Hashtable - Save chest as 4 of (Key (Triggering unit)) in current_hashtable
- Set temp_point[0] = (Position of (Triggering unit))
- Set temp_point[1] = (temp_point[0] offset by 50.00 towards (Facing of (Triggering unit)) degrees)
- Custom script: call RemoveLocation( udg_temp_point[0] )
- Set temp_point[2] = (Position of (Target unit of ability being cast))
- Lightning - Create a Spirit Link lightning effect from source temp_point[1] to target temp_point[2]
- Custom script: call RemoveLocation( udg_temp_point[1] )
- Custom script: call RemoveLocation( udg_temp_point[2] )
- Hashtable - Save Handle Of(Last created lightning effect) as (Key light) of (Key (Triggering unit)) in current_hashtable
- Lightning - Change color of (Last created lightning effect) to (1.00 0.50 0.00) with 0.25 alpha
- Special Effect - Create a special effect attached to the hand, left of (Triggering unit) using Abilities\Spells\Other\BreathOfFire\BreathOfFireDamage.mdl
- Hashtable - Save Handle Of(Last created special effect) as (Key left hand) of (Key (Triggering unit)) in current_hashtable
- Special Effect - Create a special effect attached to the hand, right of (Triggering unit) using Abilities\Spells\Other\BreathOfFire\BreathOfFireDamage.mdl
- Hashtable - Save Handle Of(Last created special effect) as (Key right hand) of (Key (Triggering unit)) in current_hashtable
- Unit Group - Add (Triggering unit) to current_group
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Withering Heat 2 <gen> is on) Equal to False
-
Then - Actions
- Trigger - Turn on Withering Heat 2 <gen>
- Trigger - Turn on Withering Heat 3 <gen>
- Else - Actions
-
If - Conditions
- Custom script: set udg_current_hashtable = null
- Custom script: set udg_current_group = null
-
Events
-
Withering Heat 2
-
Events
- Time - Every 0.10 seconds of game time
- Conditions
-
Actions
- Set current_hashtable = H_WitheringHeat
- Set current_group = WitheringHeatCasters
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Number of units in current_group) Greater than 0
-
Then - Actions
-
Unit Group - Pick every unit in current_group and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Load (Key duration) of (Key (Picked unit)) from current_hashtable) Less than or equal to 0.00
-
Then - Actions
- Unit - Remove 0~Withering Heat Slow (Bright Wizard) buff from (Load (Key target) of (Key (Picked unit)) in current_hashtable)
- Special Effect - Destroy (Load (Key left hand) of (Key (Picked unit)) in current_hashtable)
- Special Effect - Destroy (Load (Key right hand) of (Key (Picked unit)) in current_hashtable)
- Lightning - Destroy (Load (Key light) of (Key (Picked unit)) in current_hashtable)
- Unit Group - Remove (Picked unit) from current_group
- Hashtable - Clear all child hashtables of child (Key (Picked unit)) in current_hashtable
-
Else - Actions
- Unit - Cause (Picked unit) to damage (Load (Key target) of (Key (Picked unit)) in current_hashtable), dealing (((Load (Key damage) of (Key (Picked unit)) from current_hashtable) / 6.00) x FPS_DOTSpells) damage of attack type Spells and damage type Fire
- Set temp_point[0] = (Position of (Load (Key target) of (Key (Picked unit)) in current_hashtable))
- Unit - Create 1 dummy (Bright Wizard) for (Owner of (Picked unit)) at temp_point[0] facing Default building facing degrees
- Custom script: call RemoveLocation( udg_temp_point[0] )
- Unit - Add a 0.10 second Generic expiration timer to (Last created unit)
- Unit - Order (Last created unit) to Human Sorceress - Slow (Load (Key target) of (Key (Picked unit)) in current_hashtable)
- Set temp_point[0] = (Position of (Picked unit))
- Set temp_point[1] = (temp_point[0] offset by 50.00 towards (Facing of (Picked unit)) degrees)
- Custom script: call RemoveLocation( udg_temp_point[0] )
- Set temp_point[2] = (Position of (Load (Key target) of (Key (Picked unit)) in current_hashtable))
- Lightning - Move (Load (Key light) of (Key (Picked unit)) in current_hashtable) to source temp_point[1] and target temp_point[2]
- Custom script: call RemoveLocation( udg_temp_point[1] )
- Custom script: call RemoveLocation( udg_temp_point[2] )
- Special Effect - Create a special effect attached to the (Load (Random integer number between 1 and 4) of (Key (Picked unit)) from current_hashtable) of (Load (Key target) of (Key (Picked unit)) in current_hashtable) using Abilities\Spells\Items\AIfb\AIfbSpecialArt.mdl
- Special Effect - Destroy (Last created special effect)
- Hashtable - Save ((Load (Key duration) of (Key (Picked unit)) from current_hashtable) - FPS_DOTSpells) as (Key duration) of (Key (Picked unit)) in current_hashtable
- Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - (FPS_DOTSpells x (Load (Key mana/sec) of (Key (Picked unit)) from current_hashtable)))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
- ((Load (Key target) of (Key (Picked unit)) in current_hashtable) is dead) Equal to True
- (Mana of (Picked unit)) Less than (FPS_DOTSpells x (Load (Key mana/sec) of (Key (Picked unit)) from current_hashtable))
-
Conditions
-
Or - Any (Conditions) are true
-
Then - Actions
- Unit - Order (Picked unit) to Stop
- Hashtable - Save 0.00 as (Key duration) of (Key (Picked unit)) in current_hashtable
- Else - Actions
-
If - Conditions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
Unit Group - Pick every unit in current_group and do (Actions)
-
Else - Actions
- Trigger - Turn off Withering Heat 3 <gen>
- Trigger - Turn off (This trigger)
-
If - Conditions
- Custom script: set udg_current_hashtable = null
- Custom script: set udg_current_group = null
-
Events
-
Withering Heat 3
-
Events
- Unit - A unit Is issued an order with no target
- Unit - A unit Is issued an order targeting a point
- Unit - A unit Is issued an order targeting an object
-
Conditions
- ((Triggering unit) is in WitheringHeatCasters) Equal to True
-
Actions
- Hashtable - Save 0.00 as (Key duration) of (Key (Triggering unit)) in H_WitheringHeat
-
Events