Moderator
M
Moderator
15:59, 11th Sep 2010
TriggerHappy:
Looked fine and was leakless.
TriggerHappy:
Looked fine and was leakless.
Morphing Ray Cast

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Morphing Ray

Actions


-------- Stores caster and target into variables --------


-------- NOTE 1: Caster is stored only because it's easier to write the script, not searching for Triggering Unit --------


Set Caster = (Triggering unit)


Set Target = (Target unit of ability being cast)


-------- Finds the Caster's location --------


-------- NOTE 2: Will be used later for start-end points of the lightning we will create --------


Set Points[1] = (Position of Caster)


-------- Counts the damage dealt to target --------


-------- NOTE 3: Make your countings here --------


Set Real[1] = (0.01 x (Real((Level of Morphing Ray for Caster))))


Set Real[1] = ((Max life of Target) x Real[1])


-------- NOTE 4: All the counted damage MUST be multiplied by 0.03 (or divided into 33.3) --------


-------- It is a MUST, because all ticks of damage will be dealt at interval of 0.03 --------


-------- We don't want to deal 800*.05=40 damage per 0.03 or 40/0.03=1333.(3) per second, do we? --------


Set Real[1] = (Real[1] x 0.03)


-------- Counts the duration of the Spell --------


-------- NOTE 5: Count your duration here --------


-------- NOTE 6: This must be equal to follow through time for each level --------


Set Real[2] = (1.00 + (Real((Level of Morphing Ray for Caster))))


-------- Stores all information to the Hashtable --------


-------- NOTE 7: It is made to be easier to interupt the channeled effect through effect --------


-------- NOTE 8: Never, EVER, make spells w/ hashtables which is casted by CASTER and all information is attached to TARGET, cause it will get bugged! A LOT! --------


Hashtable - Save Handle OfTarget as 0 of (Key (Triggering unit)) in Hashtable


Hashtable - Save Real[1] as 1 of (Key (Triggering unit)) in Hashtable


Hashtable - Save Real[2] as 2 of (Key (Triggering unit)) in Hashtable


-------- NOTE 9: Lightning is created here, as I didn't want to waste an action for storing da lightning to da variable --------


-------- NOTE 10: Change your lighting type here --------


Lightning - Create a Drain Mana lightning effect from source Points[1] to target Points[1]


Hashtable - Save Handle Of(Last created lightning effect) as 3 of (Key (Triggering unit)) in Hashtable


-------- Checks if there is any instance of spell already in on --------


-------- If not, turns the Channeled effect trigger on --------


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



If - Conditions




(RayCasters is empty) Equal to True



Then - Actions




Trigger - Turn on Morphing Ray Channel <gen>



Else - Actions


-------- Adds the Caster/Target SFX abilities to the Caster/Target. Obvious, isn't it? --------


Unit - Add SFX Caster to Caster


Unit - Add SFX Target to Target


-------- 'Sheeps' target --------


Unit - Create 1 Dummy Caster for (Owner of Caster) at Points[1] facing Default building facing degrees


Unit - Add Polymorph to (Last created unit)


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


Unit - Order (Last created unit) to Human Sorceress - Polymorph Target


-------- Adds caster to the Channelers' group --------


Unit Group - Add Caster to RayCasters


-------- Fixes the Leak --------


Custom script: call RemoveLocation(udg_Points[1])
Morphing Ray Channel

Events


Time - Every 0.03 seconds of game time

Conditions

Actions


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



Loop - Actions




-------- Stores Caster/Target into variables --------




Set Caster = (Picked unit)




Set Target = (Load 0 of (Key (Picked unit)) in Hashtable)




-------- Finds locations of Caster/Target --------




-------- These locations will be used to check the distance between the Duo and move lighting if possible --------




Set Points[1] = (Position of Caster)




Set Points[2] = (Position of Target)




-------- Loads the Tick's damage --------




Set Real[1] = (Load 1 of (Key (Picked unit)) from Hashtable)




-------- Loads the duration left and reduces it by Tick interval --------




-------- NOTE 1: It MUST be equal to the interval of this Trigger, as stated above --------




Set Real[2] = (Load 2 of (Key (Picked unit)) from Hashtable)




Set Real[2] = (Real[2] - 0.03)




-------- Loads the Lighting effect --------




Set Lightning = (Load 3 of (Key (Picked unit)) in Hashtable)




-------- Finds the Heights into which our lightning's start-end will be rised --------




Custom script: set udg_Real[3] = GetLocationZ(udg_Points[1])




Custom script: set udg_Real[4] = GetLocationZ(udg_Points[2])




Set Real[3] = (Real[3] + ((Current flying height of Caster) + 55.00))




Set Real[4] = (Real[4] + ((Current flying height of Target) + 20.00))




-------- If everyone in the Duo is alive, timer hasn't expired and range between the Duo isn't too big... --------




-------- NOTE 2: Change your max channel range in the conditions --------




-------- NOTE 3: if you want it be infinite, write a huge number --------




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





If - Conditions






(Distance between Points[1] and Points[2]) Less than or equal to 800.00






Real[2] Greater than 0.00






(Caster is alive) Equal to True






(Target is alive) Equal to True





Then - Actions






-------- Then... --------






-------- Moves lightning --------






Custom script: call MoveLightningEx(udg_Lightning, true, GetLocationX(udg_Points[2]), GetLocationY(udg_Points[2]), udg_Real[4], GetLocationX(udg_Points[1]), GetLocationY(udg_Points[1]), udg_Real[3])






-------- Causes caster to damage target --------






Unit - Cause Caster to damage Target, dealing Real[1] damage of attack type Spells and damage type Normal






-------- Updates the time left in the timer --------






Hashtable - Save Real[2] as 2 of (Key (Picked unit)) in Hashtable





Else - Actions






-------- Else... --------






-------- Removes SFX abilities from the Duo --------






Unit - Remove SFX Caster from Caster






Unit - Remove SFX Target from Target






-------- Removes the Transformation buff from Target. Well, if it is not dead yet --------






Unit - Remove Morphing Ray buff from Target






-------- Destroys the lightning --------






Lightning - Destroy Lightning






-------- Clears the Hashtable --------






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






-------- Removes Caster from the Channelers' group --------






Unit Group - Remove Caster from RayCasters






-------- Orders the Caster to hold position. Well, if it is not dead yet --------






Unit - Order Caster to Hold Position




-------- Clears the leaks --------




Custom script: call RemoveLocation(udg_Points[1])




Custom script: call RemoveLocation(udg_Points[2])


-------- Checks if there is any instance of spell left after loop --------


-------- If not, turns this trigger off --------


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



If - Conditions




(RayCasters is empty) Equal to True



Then - Actions




Trigger - Turn off (This trigger)



Else - Actions
Morphing Ray Interupt

Events


Unit - A unit Stops casting an ability

Conditions


(Ability being cast) Equal to Morphing Ray

Actions


-------- Stores our Duo into variables --------


Set Caster = (Triggering unit)


Set Target = (Load 0 of (Key (Triggering unit)) in Hashtable)


-------- Stores the Lightning into variable --------


Set Lightning = (Load 3 of (Key (Triggering unit)) in Hashtable)


-------- Clears the Hashtable, as we won't need anything anymore --------


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


-------- Removes caster from channelers' group --------


Unit Group - Remove (Triggering unit) from RayCasters


-------- Removes SFX abilities from the Duo --------


Unit - Remove SFX Caster from Caster


Unit - Remove SFX Target from Target


-------- Removes the Transformation buff from the Target --------


Unit - Remove Morphing Ray buff from Target


-------- Destroys the Lightning --------


Lightning - Destroy Lightning