Moderator
M
Moderator
15:36, 25th Oct 2012
Magtheridon96: Approved.
Magtheridon96: Approved.
Timed Lightning

Events


Map initialization

Conditions

Actions


Custom script: set udg_TL_Hash = InitHashtable()


-------- ----------------------------------- --------


-------- Lightning Codes --------


-------- ----------------------------------- --------


-------- Chain Lightning - Primary --------


Set TL_LightningType[1] = CLPB


-------- Chain Lightning - Secondary --------


Set TL_LightningType[2] = CLSB


-------- Healing Wave - Primary --------


Set TL_LightningType[3] = HWPB


-------- Healing Wave - Secondary --------


Set TL_LightningType[4] = HWSB


-------- Finger of Death --------


Set TL_LightningType[5] = AFOD


-------- Magic Leash/Aerial Shackles --------


Set TL_LightningType[6] = LEAS


-------- Drain Mana --------


Set TL_LightningType[7] = DRAM


-------- Drain Life --------


Set TL_LightningType[8] = DRAL


-------- Forked Lightning --------


Set TL_LightningType[9] = FORK


-------- Mana Burn --------


Set TL_LightningType[10] = MBUR


-------- Chimera Attack --------


Set TL_LightningType[11] = CHIM


-------- Mana Flare --------


Set TL_LightningType[12] = MFPB


-------- Spirit Link --------


Set TL_LightningType[13] = SPLK


Custom script: call ExecuteFunc("InitTimedLightning")


Custom script: endfunction


-------- ----------------------------------- --------


-------- This function destroys any kind of lightning,of course,depending on time or if a unit is dead --------


-------- call DestroyTimedLightning() as a key to destroy it. --------


-------- ----------------------------------- --------


Custom script: function DestroyTimedLightning takes nothing returns nothing


Lightning - Destroy TL_TempLightning


Hashtable - Clear all child hashtables of child TL_Key in TL_Hash


Unit Group - Remove TL_TempSource from TL_LoopGroup


Unit - Kill TL_TempSource


Custom script: endfunction


-------- ----------------------------------- --------


-------- This function creates the timed lightning --------


-------- Use call CreateTimedLightning --------


-------- ----------------------------------- --------


Custom script: function CreateTimedLightning takes nothing returns nothing


-------- ----------------------------------- --------


-------- Coordinates X,Y,Z --------


-------- ----------------------------------- --------


-------- ----------------------------------- --------


-------- Checks if a source unit is a location(via boolean) --------


-------- ----------------------------------- --------


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



If - Conditions




TL_IsSourceLocation Equal to True



Then - Actions




Custom script: set udg_TL_SourceZ = GetUnitFlyHeight(udg_TL_Source)



Else - Actions




Custom script: set udg_TL_SourceZ = GetUnitFlyHeight(udg_TL_Source) + 50


-------- ----------------------------------- --------


-------- Checks if a target unit is a location(via boolean) --------


-------- ----------------------------------- --------


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



If - Conditions




TL_IsTargetLocation Equal to True



Then - Actions




Custom script: set udg_TL_TargetZ = GetUnitFlyHeight(udg_TL_Target)



Else - Actions




Custom script: set udg_TL_TargetZ = GetUnitFlyHeight(udg_TL_Target) + 50


-------- ----------------------------------- --------


-------- X,Y of source and target --------


-------- ----------------------------------- --------


Custom script: set udg_TL_SourceX = GetUnitX(udg_TL_Source)


Custom script: set udg_TL_SourceY = GetUnitX(udg_TL_Source)


Custom script: set udg_TL_TargetX = GetUnitX(udg_TL_Target)


Custom script: set udg_TL_TargetY = GetUnitX(udg_TL_Target)


-------- ----------------------------------- --------


-------- Creating Lightning --------


-------- ----------------------------------- --------


Custom script: set udg_TL_Lightning = AddLightningEx(udg_TL_LCode,true,udg_TL_SourceX,udg_TL_SourceY,udg_TL_SourceZ,udg_TL_TargetX,udg_TL_TargetY,udg_TL_TargetZ)


-------- ----------------------------------- --------


-------- Colors --------


-------- ----------------------------------- --------


Lightning - Change color of TL_Lightning to (TL_Red TL_Green TL_Blue) with 1.00 alpha


-------- ----------------------------------- --------


-------- Save --------


-------- ----------------------------------- --------


Hashtable - Save Handle OfTL_Lightning as (Key Lightning) of TL_CastKey in TL_Hash


Hashtable - Save TL_MaxTime as (Key TempMaxTime) of TL_CastKey in TL_Hash


Hashtable - Save TL_StartTime as (Key Current) of TL_CastKey in TL_Hash


Hashtable - Save Handle OfTL_Target as (Key Target) of TL_CastKey in TL_Hash


Hashtable - Save Handle OfTL_FakeSource as (Key FakeSource) of TL_CastKey in TL_Hash


Hashtable - Save TL_SourceZ as (Key SourceHeight) of TL_CastKey in TL_Hash


Hashtable - Save TL_TargetZ as (Key TargetHeight) of TL_CastKey in TL_Hash


Hashtable - Save TL_Blue as (Key TempBlue) of TL_CastKey in TL_Hash


Hashtable - Save TL_Green as (Key TempRed) of TL_CastKey in TL_Hash


Hashtable - Save TL_Red as (Key TempRed) of TL_CastKey in TL_Hash


Unit Group - Add TL_Source to TL_LoopGroup


Custom script: endfunction


-------- ----------------------------------- --------


-------- This function moves lightning periodicallly --------


-------- ----------------------------------- --------


Custom script: function MoveTimedLightning takes nothing returns nothing


-------- ----------------------------------- --------


-------- Load --------


-------- ----------------------------------- --------


Set TL_TempTarget = (Load (Key Target) of TL_Key in TL_Hash)


Set TL_TempFakeSource = (Load (Key FakeSource) of TL_Key in TL_Hash)


Set TL_CurrentTime = (Load (Key Current) of TL_Key from TL_Hash)


Set TL_TempMaxTime = (Load (Key TempMaxTime) of TL_Key from TL_Hash)


Set TL_TempLightning = (Load (Key Lightning) of TL_Key in TL_Hash)


Set TL_TempSourceZ = (Load (Key SourceHeight) of TL_Key from TL_Hash)


Set TL_TempTargetZ = (Load (Key TargetHeight) of TL_Key from TL_Hash)


Set TL_TempBlue = (Load (Key TempBlue) of TL_Key from TL_Hash)


Set TL_TempGreen = (Load (Key TempGreen) of TL_Key from TL_Hash)


Set TL_TempRed = (Load (Key TempRed) of TL_Key from TL_Hash)


-------- ----------------------------------- --------


-------- Check if time is not ending --------


-------- ----------------------------------- --------


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



If - Conditions




TL_CurrentTime Greater than TL_TempMaxTime



Then - Actions




Custom script: call DestroyTimedLightning()



Else - Actions




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





If - Conditions






(TL_TempSource is alive) Equal to True





Then - Actions






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







If - Conditions








(TL_TempTarget is alive) Equal to True







Then - Actions








-------- ----------------------------------- --------








-------- Moving unit to the original caster(if not location) --------








-------- ----------------------------------- --------








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









If - Conditions










TL_TempFakeSource Not equal to No unit









Then - Actions










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











If - Conditions












(TL_TempFakeSource is dead) Equal to True











Then - Actions












Custom script: call DestroyTimedLightning()











Else - Actions












Custom script: call SetUnitX(udg_TL_TempSource,GetUnitX(udg_TL_TempFakeSource))












Custom script: call SetUnitY(udg_TL_TempSource,GetUnitY(udg_TL_TempFakeSource))









Else - Actions








-------- ----------------------------------- --------








-------- Coordinates --------








-------- ----------------------------------- --------








Custom script: set udg_TL_TempSourceX = GetUnitX(udg_TL_TempSource)








Custom script: set udg_TL_TempSourceY = GetUnitY(udg_TL_TempSource)








Custom script: set udg_TL_TempTargetX = GetUnitX(udg_TL_TempTarget)








Custom script: set udg_TL_TempTargetY = GetUnitY(udg_TL_TempTarget)








-------- ----------------------------------- --------








-------- Move Lightning --------








-------- ----------------------------------- --------








Custom script: call MoveLightningEx(udg_TL_TempLightning,true,udg_TL_TempSourceX,udg_TL_TempSourceY,udg_TL_TempSourceZ,udg_TL_TempTargetX,udg_TL_TempTargetY,udg_TL_TempTargetZ)








-------- ----------------------------------- --------








-------- Fade --------








-------- ----------------------------------- --------








Set TL_Fade = (TL_TempMaxTime - TL_CurrentTime)








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









If - Conditions










TL_Fade Less than 1.00









Then - Actions










Lightning - Change color of TL_TempLightning to (TL_TempRed TL_TempGreen TL_TempBlue) with TL_Fade alpha









Else - Actions








-------- ----------------------------------- --------








-------- Save --------








-------- ----------------------------------- --------








Hashtable - Save (TL_CurrentTime + 0.03) as (Key Current) of TL_Key in TL_Hash







Else - Actions








Custom script: call DestroyTimedLightning()





Else - Actions






Custom script: call DestroyTimedLightning()


Custom script: endfunction


Custom script: function TimedLightningLoop takes nothing returns nothing


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



Loop - Actions




Set TL_TempSource = (Picked unit)




Custom script: set udg_TL_Key = GetHandleId(udg_TL_TempSource)




Custom script: call ExecuteFunc("MoveTimedLightning")


Custom script: endfunction


Custom script: function InitTimedLightning takes nothing returns nothing


Custom script: local trigger t = GetTriggeringTrigger()


Custom script: call TriggerClearActions(t)


Custom script: call TriggerAddAction(t,function TimedLightningLoop)


Trigger - Add to (This trigger) the event (Time - Every 0.03 seconds of game time)