• 🏆 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] Simple Lightning Handling System v1.21 [GUI]

  • Like
Reactions: JesusHipster
- This system allows you to create Lightning in 4 ways (Unit2Unit | Unit2Point | Point2Unit | Point2Point)
- It is in GUI (you do not need JNGP to edit this system)


- Open World Editor - File - Preferences... - General Tab - Tick the Automatically create unknown variables while pasting trigger data
- Copy the Simple Lightning Handling System folder.
- Further instructions inside the LH Setup Trigger.
- You can also take a look at the examples (4) and see how do you want to manipulate this system.


  • LH Loop
    • Events
    • Conditions
    • Actions
      • Custom script: local real x1
      • Custom script: local real y1
      • Custom script: local real z1
      • Custom script: local real x2
      • Custom script: local real y2
      • Custom script: local real z2
      • For each (Integer LH_CurrentIndex) from 1 to LH_MaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LH_UnitSource[LH_CurrentIndex] Not equal to No unit
            • Then - Actions
              • Custom script: set x1 = GetUnitX(udg_LH_UnitSource[udg_LH_CurrentIndex])
              • Custom script: set y1 = GetUnitY(udg_LH_UnitSource[udg_LH_CurrentIndex])
              • Custom script: call MoveLocation(udg_LH_Location, x1, y1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (LH_UnitSource[LH_CurrentIndex] is A ground unit) Equal to True
                • Then - Actions
                  • Custom script: set z1 = GetLocationZ(udg_LH_Location) + udg_LH_UnitZ
                • Else - Actions
                  • Custom script: set z1 = GetLocationZ(udg_LH_Location) + GetUnitFlyHeight(udg_LH_UnitSource[udg_LH_CurrentIndex])
            • Else - Actions
              • Custom script: set x1 = GetLocationX(udg_LH_PointSource[udg_LH_CurrentIndex])
              • Custom script: set y1 = GetLocationY(udg_LH_PointSource[udg_LH_CurrentIndex])
              • Custom script: call MoveLocation(udg_LH_Location, x1, y1)
              • Custom script: set z1 = GetLocationZ(udg_LH_Location) + udg_LH_PointSourceZ[udg_LH_CurrentIndex]
              • -------- For UnitSource Location --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LH_UnitTarget[LH_CurrentIndex] Not equal to No unit
            • Then - Actions
              • Custom script: set x2 = GetUnitX(udg_LH_UnitTarget[udg_LH_CurrentIndex])
              • Custom script: set y2 = GetUnitY(udg_LH_UnitTarget[udg_LH_CurrentIndex])
              • Custom script: call MoveLocation(udg_LH_Location, x2, y2)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (LH_UnitTarget[LH_CurrentIndex] is A ground unit) Equal to True
                • Then - Actions
                  • Custom script: set z2 = GetLocationZ(udg_LH_Location) + udg_LH_UnitZ
                • Else - Actions
                  • Custom script: set z2 = GetLocationZ(udg_LH_Location) + GetUnitFlyHeight(udg_LH_UnitTarget[udg_LH_CurrentIndex])
            • Else - Actions
              • Custom script: set x2 = GetLocationX(udg_LH_PointTarget[udg_LH_CurrentIndex])
              • Custom script: set y2 = GetLocationY(udg_LH_PointTarget[udg_LH_CurrentIndex])
              • Custom script: call MoveLocation(udg_LH_Location, x2, y2)
              • Custom script: set z2 = GetLocationZ(udg_LH_Location) + udg_LH_PointTargetZ[udg_LH_CurrentIndex]
              • -------- For TargetSource Location --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LH_Duration[LH_CurrentIndex] Greater than 0.00
            • Then - Actions
              • Set LH_Duration[LH_CurrentIndex] = (LH_Duration[LH_CurrentIndex] - LH_Interval)
              • Set LH_LightningAlpha[LH_CurrentIndex] = (LH_LightningAlpha[LH_CurrentIndex] - LH_LightningFadeInterval[LH_CurrentIndex])
              • Custom script: if udg_LH_LightningAlpha[udg_LH_CurrentIndex] < 0.00 then
              • Custom script: set udg_LH_Duration[udg_LH_CurrentIndex] = -0.01
              • Custom script: else
              • Custom script: call MoveLightningEx(udg_LH_Lightning[udg_LH_CurrentIndex], true, x1, y1, z1, x2, y2, z2)
              • Custom script: call SetLightningColor(udg_LH_Lightning[udg_LH_CurrentIndex], 1.00, 1.00, 1.00, udg_LH_LightningAlpha[udg_LH_CurrentIndex])
              • Custom script: endif
            • Else - Actions
              • Lightning - Destroy LH_Lightning[LH_CurrentIndex]
              • Custom script: call RemoveLocation(udg_LH_PointSource[udg_LH_CurrentIndex])
              • Custom script: call RemoveLocation(udg_LH_PointTarget[udg_LH_CurrentIndex])
              • Set LH_PointSource[LH_CurrentIndex] = LH_PointSource[LH_MaxIndex]
              • Set LH_PointTarget[LH_CurrentIndex] = LH_PointTarget[LH_MaxIndex]
              • Set LH_Duration[LH_CurrentIndex] = LH_Duration[LH_MaxIndex]
              • Set LH_Lightning[LH_CurrentIndex] = LH_Lightning[LH_MaxIndex]
              • Set LH_UnitSource[LH_CurrentIndex] = LH_UnitSource[LH_MaxIndex]
              • Set LH_UnitTarget[LH_CurrentIndex] = LH_UnitTarget[LH_MaxIndex]
              • Set LH_PointSourceZ[LH_CurrentIndex] = LH_PointSourceZ[LH_MaxIndex]
              • Set LH_PointTargetZ[LH_CurrentIndex] = LH_PointTargetZ[LH_MaxIndex]
              • Set LH_LightningName[LH_CurrentIndex] = LH_LightningName[LH_MaxIndex]
              • Set LH_LightningAlpha[LH_CurrentIndex] = LH_LightningAlpha[LH_MaxIndex]
              • Set LH_LightningFadeInterval[LH_CurrentIndex] = LH_LightningFadeInterval[LH_MaxIndex]
              • Set LH_CurrentIndex = (LH_CurrentIndex - 1)
              • Set LH_MaxIndex = (LH_MaxIndex - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • LH_MaxIndex Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
  • LH Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- ---------- --------
      • -------- DATA CONFIGURABLE --------
      • -------- LH_UnitZ = The Z adjustment to unit that is classified as Ground Unit (so that the Lightning do not created at base of the unit) --------
      • Set LH_UnitZ = 50.00
      • -------- END OF CONFIGURABLE --------
      • -------- ---------- --------
      • -------- LIGHTNING NAME --------
      • -------- CLPB - CHAIN LIGHTNING PRIMARY --------
      • -------- CLSB - CHAIN LIGHTNING SECONDARY --------
      • -------- DRAB - DRAIN --------
      • -------- DRAL - DRAIN LIFE --------
      • -------- DRAM - DRAIN MANA --------
      • -------- AFOD - FINGER OF DEATH --------
      • -------- FORK - FORKED LIGHTNING --------
      • -------- HWPB - HEALING WAVE PRIMARY --------
      • -------- HWSB - HEALING WAVE SECONDARY --------
      • -------- CHIM - LIGHTNING ATTACK --------
      • -------- LEAS - MAGIC LEASH --------
      • -------- MBUR - MANA BURN --------
      • -------- MFPB - MANA FLARE --------
      • -------- SPLK - SPIRIT LINK --------
      • -------- ---------- --------
      • -------- AT ALL TIME, YOU MUST INCLUDE THESE 3 VARIABLES --------
      • -------- LH_MaxIndex = LH_MaxIndex + 1 --------
      • -------- LH_Duration[LH_MaxIndex] = Duration of the Lightning --------
      • -------- LH_LightningName[LH_MaxIndex] = The name of your Lightning (refer above list) --------
      • -------- ---------- --------
      • -------- DO NOT TOUCH THIS IF YOU DON'T KNOW WHAT YOU ARE DOING --------
      • Set LH_CurrentIndex = 0
      • Set LH_Location = (Center of (Playable map area))
      • Set LH_Interval = 0.03
      • Trigger - Add to LH Loop <gen> the event (Time - Every LH_Interval seconds of game time)
      • -------- INSTRUCTIONS --------
      • -------- ---------- --------
      • -------- Requirement for Unit2Unit function --------
      • -------- ---------- --------
      • -------- LH_DurationSet = The duration of the Lightning --------
      • -------- LH_LightningNameSet = The name of the Lighting --------
      • -------- LH_UnitSourceSet = The source of the Lightning starts from this unit --------
      • -------- LH_UnitTargetSet = The target of the Lightning from source to this unit --------
      • -------- ---------- --------
      • -------- Requirement for Unit2Point function --------
      • -------- LH_DurationSet = The duration of the Lightning --------
      • -------- LH_LightningNameSet = The name of the Lighting --------
      • -------- LH_PointTargetZSet = The Z height of your lightning at target point --------
      • -------- LH_UnitSourceSet = The Lightning (Source) is attached to this unit --------
      • -------- LH_PointTargetSet = The Lightning (Target) is attached to this point --------
      • -------- ---------- --------
      • -------- Requirement for Point2Unit function --------
      • -------- LH_DurationSet = The duration of the Lightning --------
      • -------- LH_LightningNameSet = The name of the Lighting --------
      • -------- LH_PointSourceZSet = The Z height of Lightning at Source --------
      • -------- LH_PointSourceSet = The Lightning (Source) is attached to this point --------
      • -------- LH_UnitTargetSet = The Lightning (Target) is attached to this unit --------
      • -------- ---------- --------
      • -------- Requirement for Point2Point function --------
      • -------- LH_DurationSet = The duration of the Lightning --------
      • -------- LH_LightningNameSet = The name of the Lighting --------
      • -------- LH_PointSourceZSet = The Z height of Lightning at Source --------
      • -------- LH_PointTargetZSet = The Z height of Lightning at Target --------
      • -------- LH_PointSourceSet = The Lightning (Source) is attached to this point --------
      • -------- LH_PointTargetSet = The Lightning (Target) is attached to this point --------
      • -------- ---------- --------
  • LH Unit2Unit
    • Events
    • Conditions
    • Actions
      • Custom script: local real x1
      • Custom script: local real y1
      • Custom script: local real z1
      • Custom script: local real x2
      • Custom script: local real y2
      • Custom script: local real z2
      • Set LH_MaxIndex = (LH_MaxIndex + 1)
      • Set LH_Duration[LH_MaxIndex] = LH_DurationSet
      • Set LH_LightningName[LH_MaxIndex] = LH_LightningNameSet
      • Set LH_UnitSource[LH_MaxIndex] = LH_UnitSourceSet
      • Set LH_UnitTarget[LH_MaxIndex] = LH_UnitTargetSet
      • Set LH_LightningFadeInterval[LH_MaxIndex] = ((1.00 / LH_DurationSet) x LH_Interval)
      • Set LH_LightningAlpha[LH_MaxIndex] = 1.00
      • Custom script: set x1 = GetUnitX(udg_LH_UnitSource[udg_LH_MaxIndex])
      • Custom script: set y1 = GetUnitY(udg_LH_UnitSource[udg_LH_MaxIndex])
      • Custom script: call MoveLocation(udg_LH_Location, x1, y1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (LH_UnitSource[LH_MaxIndex] is A ground unit) Equal to True
        • Then - Actions
          • Custom script: set z1 = GetLocationZ(udg_LH_Location) + udg_LH_UnitZ
        • Else - Actions
          • Custom script: set z1 = GetLocationZ(udg_LH_Location) + GetUnitFlyHeight(udg_LH_UnitSource[udg_LH_MaxIndex])
      • Custom script: set x2 = GetUnitX(udg_LH_UnitTarget[udg_LH_MaxIndex])
      • Custom script: set y2 = GetUnitY(udg_LH_UnitTarget[udg_LH_MaxIndex])
      • Custom script: call MoveLocation(udg_LH_Location, x2, y2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (LH_UnitTarget[LH_MaxIndex] is A ground unit) Equal to True
        • Then - Actions
          • Custom script: set z2 = GetLocationZ(udg_LH_Location) + udg_LH_UnitZ
        • Else - Actions
          • Custom script: set z2 = GetLocationZ(udg_LH_Location) + GetUnitFlyHeight(udg_LH_UnitTarget[udg_LH_MaxIndex])
      • Custom script: set udg_LH_Lightning[udg_LH_MaxIndex] = AddLightningEx(udg_LH_LightningName[udg_LH_MaxIndex], true, x1, y1, z1, x2, y2, z2)
      • Trigger - Turn on LH Loop <gen>
  • LH Unit2Point
    • Events
    • Conditions
    • Actions
      • Custom script: local real x1
      • Custom script: local real y1
      • Custom script: local real z1
      • Custom script: local real x2
      • Custom script: local real y2
      • Custom script: local real z2
      • Set LH_MaxIndex = (LH_MaxIndex + 1)
      • Set LH_Duration[LH_MaxIndex] = LH_DurationSet
      • Set LH_LightningName[LH_MaxIndex] = LH_LightningNameSet
      • Set LH_PointTargetZ[LH_MaxIndex] = LH_PointTargetZSet
      • Set LH_UnitSource[LH_MaxIndex] = LH_UnitSourceSet
      • Set LH_PointTarget[LH_MaxIndex] = LH_PointTargetSet
      • Set LH_LightningFadeInterval[LH_MaxIndex] = ((1.00 / LH_DurationSet) x LH_Interval)
      • Set LH_LightningAlpha[LH_MaxIndex] = 1.00
      • Custom script: set x1 = GetUnitX(udg_LH_UnitSource[udg_LH_MaxIndex])
      • Custom script: set y1 = GetUnitY(udg_LH_UnitSource[udg_LH_MaxIndex])
      • Custom script: call MoveLocation(udg_LH_Location, x1, y1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (LH_UnitSource[LH_MaxIndex] is A ground unit) Equal to True
        • Then - Actions
          • Custom script: set z1 = GetLocationZ(udg_LH_Location) + udg_LH_UnitZ
        • Else - Actions
          • Custom script: set z1 = GetLocationZ(udg_LH_Location) + GetUnitFlyHeight(udg_LH_UnitSource[udg_LH_MaxIndex])
      • Set LH_UnitTarget[LH_MaxIndex] = No unit
      • Custom script: set x2 = GetLocationX(udg_LH_PointTarget[udg_LH_MaxIndex])
      • Custom script: set y2 = GetLocationY(udg_LH_PointTarget[udg_LH_MaxIndex])
      • Custom script: call MoveLocation(udg_LH_Location, x2, y2)
      • Custom script: set z2 = GetLocationZ(udg_LH_Location) + udg_LH_PointTargetZ[udg_LH_MaxIndex]
      • Custom script: set udg_LH_Lightning[udg_LH_MaxIndex] = AddLightningEx(udg_LH_LightningName[udg_LH_MaxIndex], true, x1, y1, z1, x2, y2, z2)
      • Trigger - Turn on LH Loop <gen>
  • LH Point2Unit
    • Events
    • Conditions
    • Actions
      • Custom script: local real x1
      • Custom script: local real y1
      • Custom script: local real z1
      • Custom script: local real x2
      • Custom script: local real y2
      • Custom script: local real z2
      • Set LH_MaxIndex = (LH_MaxIndex + 1)
      • Set LH_Duration[LH_MaxIndex] = LH_DurationSet
      • Set LH_LightningName[LH_MaxIndex] = LH_LightningNameSet
      • Set LH_PointSourceZ[LH_MaxIndex] = LH_PointSourceZSet
      • Set LH_PointSource[LH_MaxIndex] = LH_PointSourceSet
      • Set LH_UnitTarget[LH_MaxIndex] = LH_UnitTargetSet
      • Set LH_LightningFadeInterval[LH_MaxIndex] = ((1.00 / LH_DurationSet) x LH_Interval)
      • Set LH_LightningAlpha[LH_MaxIndex] = 1.00
      • Set LH_UnitSource[LH_MaxIndex] = No unit
      • Custom script: set x1 = GetLocationX(udg_LH_PointSource[udg_LH_MaxIndex])
      • Custom script: set y1 = GetLocationY(udg_LH_PointSource[udg_LH_MaxIndex])
      • Custom script: call MoveLocation(udg_LH_Location, x1, y1)
      • Custom script: set z1 = GetLocationZ(udg_LH_Location) + udg_LH_PointSourceZ[udg_LH_MaxIndex]
      • Custom script: set x2 = GetUnitX(udg_LH_UnitTarget[udg_LH_MaxIndex])
      • Custom script: set y2 = GetUnitY(udg_LH_UnitTarget[udg_LH_MaxIndex])
      • Custom script: call MoveLocation(udg_LH_Location, x2, y2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (LH_UnitTarget[LH_MaxIndex] is A ground unit) Equal to True
        • Then - Actions
          • Custom script: set z2 = GetLocationZ(udg_LH_Location) + udg_LH_UnitZ
        • Else - Actions
          • Custom script: set z2 = GetLocationZ(udg_LH_Location) + GetUnitFlyHeight(udg_LH_UnitTarget[udg_LH_MaxIndex])
      • Custom script: set udg_LH_Lightning[udg_LH_MaxIndex] = AddLightningEx(udg_LH_LightningName[udg_LH_MaxIndex], true, x1, y1, z1, x2, y2, z2)
      • Trigger - Turn on LH Loop <gen>
  • LH Point2Point
    • Events
    • Conditions
    • Actions
      • Custom script: local real x1
      • Custom script: local real y1
      • Custom script: local real z1
      • Custom script: local real x2
      • Custom script: local real y2
      • Custom script: local real z2
      • Set LH_MaxIndex = (LH_MaxIndex + 1)
      • Set LH_Duration[LH_MaxIndex] = LH_DurationSet
      • Set LH_LightningName[LH_MaxIndex] = LH_LightningNameSet
      • Set LH_PointSourceZ[LH_MaxIndex] = LH_PointSourceZSet
      • Set LH_PointTargetZ[LH_MaxIndex] = LH_PointTargetZSet
      • Set LH_PointSource[LH_MaxIndex] = LH_PointSourceSet
      • Set LH_PointTarget[LH_MaxIndex] = LH_PointTargetSet
      • Set LH_LightningFadeInterval[LH_MaxIndex] = ((1.00 / LH_DurationSet) x LH_Interval)
      • Set LH_LightningAlpha[LH_MaxIndex] = 1.00
      • Set LH_UnitSource[LH_MaxIndex] = No unit
      • Custom script: set x1 = GetLocationX(udg_LH_PointSource[udg_LH_MaxIndex])
      • Custom script: set y1 = GetLocationY(udg_LH_PointSource[udg_LH_MaxIndex])
      • Custom script: call MoveLocation(udg_LH_Location, x1, y1)
      • Custom script: set z1 = GetLocationZ(udg_LH_Location) + udg_LH_PointSourceZ[udg_LH_MaxIndex]
      • Set LH_UnitTarget[LH_MaxIndex] = No unit
      • Custom script: set x2 = GetLocationX(udg_LH_PointTarget[udg_LH_MaxIndex])
      • Custom script: set y2 = GetLocationY(udg_LH_PointTarget[udg_LH_MaxIndex])
      • Custom script: call MoveLocation(udg_LH_Location, x2, y2)
      • Custom script: set z2 = GetLocationZ(udg_LH_Location) + udg_LH_PointTargetZ[udg_LH_MaxIndex]
      • Custom script: set udg_LH_Lightning[udg_LH_MaxIndex] = AddLightningEx(udg_LH_LightningName[udg_LH_MaxIndex], true, x1, y1, z1, x2, y2, z2)
      • Trigger - Turn on LH Loop <gen>
Maker - Inspired by his Lightning System
mckill2009 - Location manipulation of GetLocationZ
Magtheridon96 - Changed user setting style


v1.0
- Initial release

v1.1
- Changed the user setting by turning it to non-array variable
- Changed functions' name to improve readability

v1.2
- Lightning will now fade corresponding with the duration


Keywords:
simple, lightning, handle, handling, system, defskull, index, indexing, thunder, duration, fade.
Contents

Just another Warcraft III map (Map)

Reviews
17:28, 26th Sep 2012 Magtheridon96: Approved. This is quite a useful system. The instance stack is efficient and the loop code is short.

Moderator

M

Moderator

17:28, 26th Sep 2012
Magtheridon96:

Approved.
This is quite a useful system. The instance stack is efficient and the loop code is short.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
This is why it's better to let the user set some non-array variables which you will eventually store into your system arrays after increasing the index by 1.
My idea is that to create 2 types of same variable, 1 is non-array, and 1 is array, for example;

LH_LightningName0 - This is for user to set it up
LH_LightningName[array] - This is for the code-use

So, the code will LH_LightningName[LH_MaxIndex] = LH_LightningName0, BUT by doing this, I will increase the amount of variables, is that okay ?
Currently I have like 5 array variables for the user to set, so I have to create another 5 non-array variable for the user to set, is that okay ?

I'm just afraid creating much variable, that's all.
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
I FEEL PALADON WAY OF MAKING SYSTEMS MAG96!

I'm just afraid creating much variable, that's all.

You should be more afraid of creating arrays, non-arrays takes no space at all compared to an arrayed variable (which makes it so stupid to use arrays for simple things where you dont use the arrays to the fully like settings damage like Damage[1] = 3 Damage[2] = 4 etc.).
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
Actually this:
set udg_Unit1 = unitA
set udg_Unit2 = unitB
set udg_Unit3 = unitC

and this:
set udg_Unit[1] = unitA
set udg_Unit[2] = unitB
set udg_Unit[3] = unitC

is technically the same...arrays using [1] is hard to read in indexing...

EDIT:
May I suggest also to replace the names 'LH P2P' and alike to a readable one?...
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
You should be more afraid of creating arrays, non-arrays takes no space at all compared to an arrayed variable (which makes it so stupid to use arrays for simple things where you dont use the arrays to the fully like settings damage like Damage[1] = 3 Damage[2] = 4 etc.).
Okay, I'll make a copy of each array variable for the user to set, so that they won't mess the code up
Like LH_LightningName[LH_MaxIndex] = LH_LightningNameSet
Where 'Set' is to acknowledge the variable which should be set by users.

Actually this:
set udg_Unit1 = unitA
set udg_Unit2 = unitB
set udg_Unit3 = unitC

and this:
set udg_Unit[1] = unitA
set udg_Unit[2] = unitB
set udg_Unit[3] = unitC

is technically the same...arrays using [1] is hard to read in indexing...
So what is your point from that comment ?
I'm not using array[1], I used array[indexName] am I ?

May I suggest also to replace the names 'LH P2P' and alike to a readable one?...
Like LH Point2Point ?
 
Top