Moderator
M
Moderator
11:34, 28th Jul 2010
TriggerHappy:
Thanks for updating your spell.
TriggerHappy:
Thanks for updating your spell.
Setup

Events


Map initialization

Conditions

Actions


-------- Creates the hashtable for effects --------


Hashtable - Create a hashtable


Set ColSpray_Hash = (Last created hashtable)


-------- The number of levels the spell has --------


Set ColSpray_Data_Levels = 3


-------- The size of the effect's arc, in degrees --------


Set ColSpray_Levels_ArcAngle[1] = 90.00


Set ColSpray_Levels_ArcAngle[2] = 100.00


Set ColSpray_Levels_ArcAngle[3] = 110.00


-------- The length the cone extends --------


Set ColSpray_Levels_MaxDistance[1] = 250.00


Set ColSpray_Levels_MaxDistance[2] = 350.00


Set ColSpray_Levels_MaxDistance[3] = 450.00


-------- The longest a unit can be stunned for --------


Set ColSpray_Levels_MaxDuration[1] = 6.00


Set ColSpray_Levels_MaxDuration[2] = 8.00


Set ColSpray_Levels_MaxDuration[3] = 10.00


-------- The number of lights to be sprayed fo the effect (multiples of LightsPerTick (below) are best) --------


Set ColSpray_Data_Lights = 162


-------- The number of lights to be sprayed every 0.05 seconds (multiples of the number of spell levels are best) --------


Set ColSpray_Data_LightsPerTick = 9


-------- The possible colours of each light --------


Set ColSpray_Data_Colors[0] = (Color of Player 1 (Red))


Set ColSpray_Data_Colors[1] = (Color of Player 2 (Blue))


Set ColSpray_Data_Colors[2] = (Color of Player 3 (Teal))


Set ColSpray_Data_Colors[3] = (Color of Player 4 (Purple))


Set ColSpray_Data_Colors[4] = (Color of Player 5 (Yellow))


Set ColSpray_Data_Colors[5] = (Color of Player 6 (Orange))


Set ColSpray_Data_Colors[6] = (Color of Player 7 (Green))


Set ColSpray_Data_Colors[7] = (Color of Player 8 (Pink))


Set ColSpray_Data_Colors[8] = (Color of Player 9 (Gray))


Set ColSpray_Data_Colors[9] = (Color of Player 10 (Light Blue))
On Cast

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Colour Spray

Actions


-------- Retrieve level-specific data --------


Set ColSpray_Data_MaxDistance = ColSpray_Levels_MaxDistance[(Level of (Ability being cast) for (Triggering unit))]


Set ColSpray_Data_MaxDuration = ColSpray_Levels_MaxDuration[(Level of (Ability being cast) for (Triggering unit))]


Set ColSpray_Data_ArcAngle = ColSpray_Levels_ArcAngle[(Level of (Ability being cast) for (Triggering unit))]


-------- Determine the points of the caster and target, and the angle between them. --------


Set ColSpray_Vars_CastPoint = (Target point of ability being cast)


Set ColSpray_Vars_CasterPoint = (Position of (Triggering unit))


Set ColSpray_Vars_CastDir = (Angle from ColSpray_Vars_CasterPoint to ColSpray_Vars_CastPoint)


-------- Blizzard does angle-betweens odd... converts negatives to over 180's. --------


If (ColSpray_Vars_CastDir Less than 0.00) then do (Set ColSpray_Vars_CastDir = (ColSpray_Vars_CastDir + 360.00)) else do (Do nothing)


-------- Find units in range. --------


Set ColSpray_Groups_AffectedUnits = (Units within ColSpray_Data_MaxDistance of ColSpray_Vars_CasterPoint matching (((Owner of (Matching unit)) is an ally of (Owner of (Triggering unit))) Equal to False))


Unit Group - Pick every unit in ColSpray_Groups_AffectedUnits and do (Actions)



Loop - Actions




-------- Find position of a unit, and the angle to it from the casting point. --------




Set ColSpray_Vars_UnitPoint = (Position of (Picked unit))




Set ColSpray_Vars_UnitDir = (Angle from ColSpray_Vars_CasterPoint to ColSpray_Vars_UnitPoint)




-------- Blizzard does angle-betweens odd... converts negatives to over 180's. --------




If (ColSpray_Vars_UnitDir Less than 0.00) then do (Set ColSpray_Vars_UnitDir = (ColSpray_Vars_UnitDir + 360.00)) else do (Do nothing)




-------- Find the difference between the casting angle, and the angle to that unit. --------




Set ColSpray_Vars_AngleDif = (Abs((ColSpray_Vars_CastDir - ColSpray_Vars_UnitDir)))




-------- If the unit is alive, in the arc, a ground unit, and not immune to magic, stun it. --------




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






((Picked unit) is alive) Equal to True






((Picked unit) is A ground unit) Equal to True






((Picked unit) is Magic Immune) Equal to False






ColSpray_Vars_AngleDif Less than or equal to (ColSpray_Data_ArcAngle / 2.00)





Then - Actions






-------- Determine distance from caster. --------






Set ColSpray_Vars_Distance = (Distance between ColSpray_Vars_CasterPoint and ColSpray_Vars_UnitPoint)






-------- Determine duration (based on distance, and max duration) --------






-------- If you are one quarter of the max distance away, you'll get three quarters of the duration. --------






Set ColSpray_Vars_Duration = (ColSpray_Vars_Distance / ColSpray_Data_MaxDistance)






Set ColSpray_Vars_Duration = (1.00 - ColSpray_Vars_Duration)






Set ColSpray_Vars_Duration = (ColSpray_Vars_Duration x ColSpray_Data_MaxDuration)






Set ColSpray_Vars_Duration = (ColSpray_Vars_Duration + (1.00 - (ColSpray_Vars_Duration mod 1.00)))






-------- Stun the unit --------






Unit - Create 1 Colour Spray Stunner for (Owner of (Triggering unit)) at ColSpray_Vars_CastPoint facing ColSpray_Vars_UnitPoint






Unit - Set level of Stun for (Last created unit) to (Integer(ColSpray_Vars_Duration))






Unit - Order (Last created unit) to Human Mountain King - Storm Bolt (Picked unit)






Unit - Add a 2.00 second Generic expiration timer to (Last created unit)





Else - Actions


-------- Create an effect, which sprays a certain amount of lights into the area of effect. --------


Unit Group - Add (Triggering unit) to ColSpray_Groups_Casters


Hashtable - Save ColSpray_Vars_CastDir as 0 of (Key (Triggering unit)) in ColSpray_Hash


Hashtable - Save ColSpray_Data_Lights as 1 of (Key (Triggering unit)) in ColSpray_Hash


Hashtable - Save ColSpray_Data_ArcAngle as 2 of (Key (Triggering unit)) in ColSpray_Hash


Hashtable - Save (Level of (Ability being cast) for (Triggering unit)) as 3 of (Key (Triggering unit)) in ColSpray_Hash


-------- Cleanup --------


Custom script: call DestroyGroup( udg_ColSpray_Groups_AffectedUnits )


Custom script: call RemoveLocation( udg_ColSpray_Vars_CastPoint )


Custom script: call RemoveLocation( udg_ColSpray_Vars_CasterPoint )


Custom script: call RemoveLocation( udg_ColSpray_Vars_UnitPoint )
Lights Spawn

Events


Time - Every 0.05 seconds of game time

Conditions


(ColSpray_Groups_Casters is empty) Equal to False

Actions


Unit Group - Pick every unit in ColSpray_Groups_Casters and do (Actions)



Loop - Actions




Set ColSpray_Vars_CastDir = (Load 0 of (Key (Picked unit)) from ColSpray_Hash)




Set ColSpray_Vars_LightsLeft = (Load 1 of (Key (Picked unit)) from ColSpray_Hash)




Set ColSpray_Data_ArcAngle = (Load 2 of (Key (Picked unit)) from ColSpray_Hash)




Set ColSpray_Vars_SpellLevel = (Load 3 of (Key (Picked unit)) from ColSpray_Hash)




Set ColSpray_Vars_UnitPoint = (Position of (Picked unit))




Set Temp_Real = ((Real(ColSpray_Data_LightsPerTick)) x ((Real(ColSpray_Vars_SpellLevel)) / (Real(ColSpray_Data_Levels))))




For each (Integer Temp_Int) from 1 to (Integer(Temp_Real)), do (Actions)





Loop - Actions






Set ColSpray_Vars_UnitDir = ColSpray_Vars_CastDir






Unit - Create 1 Colour Spray Light for Neutral Passive at ColSpray_Vars_UnitPoint facing (ColSpray_Vars_CastDir + (Random real number between ((ColSpray_Data_ArcAngle / 2.00) x -1.00) and (ColSpray_Data_ArcAngle / 2.00))) degrees






Unit Group - Add (Last created unit) to ColSpray_Groups_Lights






Unit - Change color of (Last created unit) to ColSpray_Data_Colors[(Random integer number between 0 and 9)]






Unit - Add a ((Random real number between 0.30 and 0.70) x ((Real(ColSpray_Vars_SpellLevel)) / (Real(ColSpray_Data_Levels)))) second Generic expiration timer to (Last created unit)






Unit - Turn collision for (Last created unit) Off




Set ColSpray_Vars_LightsLeft = (ColSpray_Vars_LightsLeft - ColSpray_Data_LightsPerTick)




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






ColSpray_Vars_LightsLeft Less than or equal to 0





Then - Actions






Hashtable - Clear all child hashtables of child (Key (Picked unit)) in ColSpray_Hash






Unit Group - Remove (Picked unit) from ColSpray_Groups_Casters





Else - Actions






Hashtable - Save ColSpray_Vars_LightsLeft as 1 of (Key (Picked unit)) in ColSpray_Hash


Custom script: call RemoveLocation( udg_ColSpray_Vars_MovePoint )


Custom script: call RemoveLocation( udg_ColSpray_Vars_UnitPoint )
Move Lights

Events


Time - Every 0.03 seconds of game time

Conditions


(ColSpray_Groups_Lights is empty) Equal to False

Actions


Unit Group - Pick every unit in ColSpray_Groups_Lights and do (Actions)



Loop - Actions




Set ColSpray_Vars_UnitPoint = (Position of (Picked unit))




Set ColSpray_Vars_MovePoint = (ColSpray_Vars_UnitPoint offset by 18.00 towards (Facing of (Picked unit)) degrees)




Unit - Move (Picked unit) instantly to ColSpray_Vars_MovePoint
Related Death

Events


Unit - A unit Dies

Conditions

Actions


If (All Conditions are True) then do (Then Actions) else do (Else Actions)



If - Conditions




(Unit-type of (Dying unit)) Equal to Colour Spray Light



Then - Actions




Unit Group - Remove (Dying unit) from ColSpray_Groups_Lights



Else - Actions




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






((Dying unit) is in ColSpray_Groups_Casters) Equal to True





Then - Actions






Hashtable - Clear all child hashtables of child (Key (Dying unit)) in ColSpray_Hash






Unit Group - Remove (Dying unit) from ColSpray_Groups_Casters





Else - Actions