This is the timed lightning,this supports any lightning.
Features:
unit to unit
unit to point
point to point
destructable to unit
destructable to destructable.
To use:
Create timed lightning by calling call ExecuteFunc("CreateTimedLightning")
The Loop will move all the timed lightning
The temp fake source is used so that it will have different indexes instead of replacing any lightning and variables.
If you want the lightning to be created in a point by source or target,just make the boolean
SourceUnitIsALocation or TargetUnitIsALocation to true.
The configuration can be found inside the setup.
Dont touch the functions.
If you want a JASS version,here:
Timed Light by Maker
[tab=Triggers]
System
Example Usage
Remove Dummies
-
Timed Lightning
-
Events
-
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
-
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)
[trigger=]TL Cast
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Storm Bolt
Actions
Set TL_Caster = (Triggering unit)
Set TL_Point = (Position of TL_Caster)
Set TL_Owner = (Triggering player)
Set TL_Target = (Target unit of ability being cast)
-------- ------------------------------------ --------
-------- Creating Source --------
-------- ------------------------------------ --------
Unit - Create 1 Dummy for TL_Owner at TL_Point facing Default building facing degrees
Set TL_Source = (Last created unit)
Custom script: set udg_TL_CastKey = GetHandleId(udg_TL_Source)
Set TL_FakeSource = TL_Caster
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
TL_FakeSource Not equal to No unit
Then - Actions
Set TL_IsSourceLocation = False
Else - Actions
Set TL_IsSourceLocation = True
Unit - Add a TL_MaxTime second Generic expiration timer to TL_Caster
Set TL_StartTime = 0.00
-------- ------------------------------------ --------
-------- Used to create location target --------
-------- ------------------------------------ --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of TL_Target) Equal to Dummy
Then - Actions
Set TL_IsTargetLocation = True
Unit - Add a TL_MaxTime second Generic expiration timer to TL_Target
Else - Actions
Set TL_IsTargetLocation = False
Set TL_LCode = TL_LightningType[9]
Set TL_MaxTime = 5.00
-------- ----------------------------------- --------
-------- Color from 0.00 to 1.00 only --------
-------- ----------------------------------- --------
Set TL_Red = 1.00
Set TL_Green = 0.00
Set TL_Blue = 1.00
Custom script: call ExecuteFunc("CreateTimedLightning")
Custom script: call RemoveLocation(udg_TL_Point)
[/trigger]
[trigger=]TL Remove Dummies
Events
Unit - A unit Dies
Conditions
(Unit-type of (Triggering unit)) Equal to Dummy
Actions
Unit - Remove (Triggering unit) from the game
[/trigger]
[/tab][tab=Credits]
Bribe for the idea of functions based on his Knockback 2D
Magtheridon96 for explaining me how functions work.[/tab][tab=Changelogs]v1.0
-Released
v1.1
-Fixed Fading
v1.2
-Fixed some codes
-Now uses only one trigger for the setup and loop instead of three
v1.3
-Removed Configuration
-Removed Encapsulation(of course)
[/tab]