# Making a channeled spell

#### Karzama

Level 12
Hi,

So I've got an idea of a channeled spell but I have never created a custom channeled spell.

So the idea for the spell is that the user would cast it like shockwave and it'd channel for 4 or so seconds. Every 0.25 seconds the user would create orbs that fly out in the target direction, dealing damage when they hit a target.

I know how to index so I can easily do the second part (orbs moving and dealing damage). However I'm not sure on the best way to get the caster as such.

I had an idea to add them into a group when they begin casting (starts effect of ability) and removing them when they finish or stop casting the ability. This way I could pick the group every 0.25 seconds and make the orbs from that.

Is this a good way to do it or is there a better method?

#### BloodDrunk

Level 18
you can create new boolean array variable and new trigger where you check orders and loop through all instances and see if unit that issued order is equal to the unit in variable[] and set that bool to true.
That's how similarly I did.

#### Karzama

Level 12
Not sure I understand quite what you mean by that if i'm honest!!!

#### BloodDrunk

Level 18
Not sure I understand quite what you mean by that if i'm honest!!!

I'll give you an example of my channeled spell in a minute.

• Black Hole
• Events
• Unit - A unit Starts the effect of an ability
• Conditions
• (Ability being cast) Equal to Black Hole
• Actions
• -------- ------------------------------------------------------------------------------------- --------
• Set BH_MaxIndex = (BH_MaxIndex + 1)
• Set BH_TrigUnit[BH_MaxIndex] = (Triggering unit)
• Set BH_SpellLvl[BH_MaxIndex] = (Level of Black Hole for BH_TrigUnit[BH_MaxIndex])
• Set BH_DamageUnit[BH_MaxIndex] = BH_Damage[BH_SpellLvl[BH_MaxIndex]]
• Set BH_Channel[BH_MaxIndex] = True //There I've defined array boolean to true
• -------- ------------------------------------------------------------------------------------- --------
• -------- ------------------------------------------------------------------------------------- --------
• Set BH_Point = (Target point of ability being cast)
• Unit - Create 1 Dummy Black Hole for (Owner of BH_TrigUnit[BH_MaxIndex]) at BH_Point facing Default building facing degrees
• Set BH_Dummy[BH_MaxIndex] = (Last created unit)
• -------- ------------------------------------------------------------------------------------- --------
• -------- ------------------------------------------------------------------------------------- --------
• Unit - Add a BH_Duration[BH_SpellLvl[BH_MaxIndex]] second Generic expiration timer to BH_Dummy[BH_MaxIndex]
• -------- ------------------------------------------------------------------------------------- --------
• -------- ------------------------------------------------------------------------------------- --------
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• BH_MaxIndex Equal to 1
• Then - Actions
• Trigger - Turn on Black Hole Loop <gen>
• Trigger - Turn on Black Hole Channel <gen>
• Else - Actions
• -------- ------------------------------------------------------------------------------------- --------
• -------- ------------------------------------------------------------------------------------- --------
• Custom script: call RemoveLocation(udg_BH_Point)
• Custom script: set udg_BH_Point = null
• -------- ------------------------------------------------------------------------------------- --------
• Black Hole Loop
• Events
• Time - Every 0.03 seconds of game time
• Conditions
• Actions
• For each (Integer BH_Loop) from 1 to BH_MaxIndex, do (Actions)
• Loop - Actions
• -------- ------------------------------------------------------------------------------------- --------
• Set BH_Point = (Position of BH_Dummy[BH_Loop])
• -------- ------------------------------------------------------------------------------------- --------
• -------- ------------------------------------------------------------------------------------- --------
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• Or - Any (Conditions) are true
• Conditions
• (Life of BH_Dummy[BH_Loop]) Less than or equal to 0.41
• BH_Channel[BH_Loop] Equal to False //Here I check if that boolean of the unit that broke the channel is false, and if it is, I stop that spell instance and de-index.
• Then - Actions
• -------- ------------------------------------------------------------------------------------- --------
• Unit - Kill BH_Dummy[BH_Loop]
• -------- ------------------------------------------------------------------------------------- --------
• -------- ------------------------------------------------------------------------------------- --------
• Set BH_TrigUnit[BH_Loop] = BH_TrigUnit[BH_MaxIndex]
• Set BH_TrigUnit[BH_MaxIndex] = No unit
• Set BH_Dummy[BH_Loop] = BH_Dummy[BH_MaxIndex]
• Set BH_Dummy[BH_MaxIndex] = No unit
• Set BH_Channel[BH_Loop] = BH_Channel[BH_MaxIndex]
• Set BH_DamageUnit[BH_Loop] = BH_DamageUnit[BH_MaxIndex]
• Set BH_SpellLvl[BH_Loop] = BH_SpellLvl[BH_MaxIndex]
• Set BH_MaxIndex = (BH_MaxIndex - 1)
• Set BH_Loop = (BH_Loop - 1)
• -------- ------------------------------------------------------------------------------------- --------
• Else - Actions
• -------- ------------------------------------------------------------------------------------- --------
• Set BH_UnitGroup = (Units within 550.00 of BH_Point matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an enemy of (Owner of BH_TrigUnit[BH_Loop])) Equal to True) and (((Life of (Matching unit)) Greater than 0.41) and (((Matching unit)
• -------- ------------------------------------------------------------------------------------- --------
• -------- ------------------------------------------------------------------------------------- --------
• Unit Group - Pick every unit in BH_UnitGroup and do (Actions)
• Loop - Actions
• -------- ------------------------------------------------------------------------------------- --------
• Set BH_PickedUnit = (Picked unit)
• Set BH_Point2 = (Position of BH_PickedUnit)
• Set BH_Angle = ((Angle from BH_Point to BH_Point2) - 2.00)
• Set BH_Point3 = (BH_Point offset by ((Distance between BH_Point and BH_Point2) - 10.00) towards BH_Angle degrees)
• -------- ------------------------------------------------------------------------------------- --------
• Unit - Turn collision for BH_PickedUnit Off
• -------- ------------------------------------------------------------------------------------- --------
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Distance between BH_Point and BH_Point2) Less than or equal to 90.00
• Then - Actions
• -------- ------------------------------------------------------------------------------------- --------
• Unit - Cause BH_TrigUnit[BH_Loop] to damage BH_PickedUnit, dealing 1000000000.00 damage of attack type Chaos and damage type Normal
• -------- ------------------------------------------------------------------------------------- --------
• Else - Actions
• -------- ------------------------------------------------------------------------------------- --------
• Unit - Order BH_PickedUnit to Stop
• Unit - Make BH_PickedUnit face BH_Point over 0.00 seconds
• Custom script: call SetUnitX(udg_BH_PickedUnit, GetLocationX(udg_BH_Point3))
• Custom script: call SetUnitY(udg_BH_PickedUnit, GetLocationY(udg_BH_Point3))
• Unit - Cause BH_TrigUnit[BH_Loop] to damage BH_PickedUnit, dealing BH_DamageUnit[BH_Loop] damage of attack type Spells and damage type Normal
• -------- ------------------------------------------------------------------------------------- --------
• -------- ------------------------------------------------------------------------------------- --------
• -------- ------------------------------------------------------------------------------------- --------
• Custom script: call RemoveLocation(udg_BH_Point2)
• Custom script: call RemoveLocation(udg_BH_Point3)
• -------- ------------------------------------------------------------------------------------- --------
• -------- ------------------------------------------------------------------------------------- --------
• -------- ------------------------------------------------------------------------------------- --------
• Custom script: call DestroyGroup(udg_BH_UnitGroup)
• -------- ------------------------------------------------------------------------------------- --------
• -------- ------------------------------------------------------------------------------------- --------
• -------- ------------------------------------------------------------------------------------- --------
• Custom script: call RemoveLocation(udg_BH_Point)
• -------- ------------------------------------------------------------------------------------- --------
• -------- ------------------------------------------------------------------------------------- --------
• -------- ------------------------------------------------------------------------------------- --------
• Custom script: set udg_BH_Point = null
• Custom script: set udg_BH_Point2 = null
• Custom script: set udg_BH_Point3 = null
• Custom script: set udg_BH_UnitGroup = null
• -------- ------------------------------------------------------------------------------------- --------
• -------- ------------------------------------------------------------------------------------- --------
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• BH_MaxIndex Equal to 0
• Then - Actions
• Trigger - Turn off (This trigger)
• Trigger - Turn off Black Hole Channel <gen>
• Else - Actions
• -------- ------------------------------------------------------------------------------------- --------
• Black Hole Channel
• Events
• Unit - A unit Is issued an order targeting an object
• Unit - A unit Is issued an order targeting a point
• Unit - A unit Is issued an order with no target
• Conditions
• Actions
• For each (Integer BH_Loop) from 1 to BH_MaxIndex, do (Actions)
• Loop - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Ordered unit) Equal to BH_TrigUnit[BH_Loop]
• Then - Actions
• Set BH_Channel[BH_Loop] = False //Here I loop through all the instances and check if the unit did an order and then set that boolean to false, meaning the unit has broken the channel.
• Else - Actions
I hope you'll understand this.

#### deathismyfriend

Level 29
Using a Hashtable would be much faster for this.

#### BloodDrunk

Level 18
Using a Hashtable would be much faster for this.

Unfortunately, I'm not comfortable with hashes yet haha so I rely on indexing.
Its processing speed it fine.

#### Karzama

Level 12
Ahh I think I get it, I managed to get it working the way I had planned. Thanks anyway

Replies
2
Views
953
Replies
13
Views
820
Replies
7
Views
521
Replies
4
Views
3K
Replies
10
Views
751