• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[GUI]Timed Lightning v1.3

Description


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
      • 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)
[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]
[tab=Description][/tab]
[tab=Description][/tab][/tabs][/center]
Contents

Timed Lightning v1.2 (Map)

Reviews
15:36, 25th Oct 2012 Magtheridon96: Approved.
and hmmm... destructables... pretty neat... though that can be achieved using points (since destructables cannot be moved), unless there are some things that can be done to destructables... but why no dest to point?

btw, can you add an example usage of doing the set-up part outside of the main trigger? it might be helpful... :)
 
I only looked at what you posted btw...

  • 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 Encapsulate()
the way I understand it, you set-up the lightning values tied to an integer or an abilityID into a hash so that the user can fetch it afterwards... and that part is set-up during the main trigger... and I think it's also clear that you can do it outside of the main trigger [by using those same actions in another trigger], but there is no example posted on how to do this "set-up"...

and oh, I think the user can also bypass the hash and just use their own values directly... am I right? maybe you can add an example for that too...

I don't really think those samples are actually needed but maybe some users might get confused... :)

btw, I'm really curious why there isn't a dest to point method... I mean you already made dest to dest and dest to unit, so why not complete the list by adding dest to point? I just based this on your features list...
 
well yeah, though it's a waste to add a dummy to the map just to create a "Dest to point" when you can just add the capability to make the system support a "Dest to point" by default... I guess... it's not really that important though... the whole dest functions actually since most destructables are static anyway so you can just always use P2P using the dest's locations... :)
 
Top