Snippet Putting 3D Lightning in GUI

MoonSlinger

I Love using Cheap Tricks... only Results matters
Reaction score
74
[SIZE="+1"]What is this?[/SIZE]
This is a little snippet for letting GUI users make 3D lightning easily
It is made as easy as possible for those without Jass Knowledge. :D


[SIZE="+1"]Reason:[/SIZE]
I noticed that GUI only allows putting on lightnings on the floor.
Personally, I think it is a restriction on creativity for those who doesn't know Jass or vJass. :p


[SIZE="+1"]Global Variables you will need[/SIZE]
LightStartPoint - Point
LightEndtPoint - Point
LightStartZ - Real
LightEndZ - Real
LightType - String
LightCustom - Lightning


[SIZE="+1"]Other Things you need[/SIZE]
Put the following code into the header
JASS:
function Light3D takes nothing returns nothing
   local real X1 = GetLocationX(udg_LightStartPoint)
   local real X2 = GetLocationX(udg_LightEndPoint)
   local real Y1 = GetLocationY(udg_LightStartPoint)
   local real Y2 = GetLocationY(udg_LightEndPoint)
   local real Z1 = udg_LightStartZ
   local real Z2 = udg_LightEndZ
   set udg_LightCustom = AddLightningEx( udg_LightType, true, X1, Y1, Z1, X2, Y2, Z2)
endfunction

For those who do not know where the header is:
- Open Trigger Editor
- Click on the map name... <map name>.w3x
- Put the codes there.
header.jpg


If you still don't get it, open the test map and try to locate where I have placed the codes :D


[SIZE="+1"]How to use it[/SIZE]
The default GUI lightning trigger requires 2 points
A lightning will be drawn from the First Point to the 2nd Point

In imitation to the above:
LightStartPoint - Set your first point into this variable
LightEndtPoint - Set your second point into this variable

Following that:
LightStartZ determines the height of the First position
LightEndZ determines the height of the Second position
They are both "Real" values

Setting the Type
LightType, determines the type of lightning that will appear.
List of Lighning Types:

"CLPB" Chain Lightning - Primary
"CLSB" Chain Lightning - Secondary
"DRAB" Drain
"DRAL" Drain Life
"DRAM" Drain Mana
"AFOD" Finger of Death
"FORK" Fork Lightning
"HWPB" Healing Wave - Primary
"HWSB" Healing Wave - Secondary
"CHIM" Lightning Attack (Chimera)
"LEAS" Magic Leash
"MBUR" Mana Burn
"MFPB" Mana Flare
"SPLK" Spirit Link

Just set the 4 letter word as your LightType :D

Creating the Lightning
For now, with all the required variables set, we just have to call the function and watch it work:
It is very similar to scripts used for removing leaks
Custom script: call Light3D()

Cleaning Up
When the Lightning is create, now you need to clean-up
We need to give the lightning an identifier so we can remove it when it is no longer needed. ;)

Usually for a normal Lightning, we would use (Last Created Lightning Effect).
However, for this snippet, that function seems not to work, so I have placed the reference into a variable called "LightCustom"
Set <Your Lightning Variable> = LightCustom

To destroy the Lightning Effect, you can simply destroy it as per normal
Lightning - Destroy <Your Lightning Variable>
OR
Lightning - Destroy LightCustom​
Do Remember: LightCustom works like (Last Created Lightning Effect). If you make a new lightning, it will overwrite the previous one.


Also take care of the leaks which "points" might cause as well as:
Custom script: call RemoveLocation(udg_LightStartPoint)
Custom script: call RemoveLocation(udg_LightEndPoint)


[SIZE="+1"]Summary[/SIZE]
Creating and removing normal lightning:
Code:
[COLOR="Blue"]// Set Points[/COLOR]
    Set [COLOR="Red"]LightStartPoint[/COLOR] = (Position of Unit1)
    Set [COLOR="Red"]LightEndPoint[/COLOR] = (Position of Unit2)

[COLOR="Blue"]// Create and Storage[/COLOR]
    Lightning - Create a Chain Lightning - Primary lightning effect from source [COLOR="Red"]LightStartPoint[/COLOR] to target [COLOR="Red"]LightEndPoint[/COLOR]
    Set [COLOR="Red"]Electric[/COLOR] = [B](Last created lightning effect)[/B]

[COLOR="Blue"]// Destroy[/COLOR]
    Lightning - Destroy [COLOR="Red"]Electric[/COLOR]

[COLOR="Blue"]// Clean Point Leaks[/COLOR]
    Custom script:   call RemoveLocation(udg_LightStartPoint)
    Custom script:   call RemoveLocation(udg_LightEndPoint)

Creating and removing this 3D lightning:
Code:
[COLOR="Blue"]// Set Points[/COLOR]
    Set [COLOR="Red"]LightStartPoint[/COLOR] = (Position of Unit1)
    Set [COLOR="Red"]LightStartZ[/COLOR] = (Current flying height of Unit1)
    Set [COLOR="Red"]LightEndPoint[/COLOR] = (Position of Unit2)
    Set [COLOR="Red"]LightEndZ[/COLOR] = (Current flying height of Unit2)
    Set [COLOR="Red"]LightType[/COLOR] = CLPB

[COLOR="Blue"]// Create and Storage[/COLOR]
    Custom script:   call Light3D()
    Set [COLOR="Red"]Electric[/COLOR] = [COLOR="Red"]LightCustom[/COLOR]

[COLOR="Blue"]// Destroy[/COLOR]
    Lightning - Destroy [COLOR="Red"]Electric[/COLOR]

[COLOR="Blue"]// Clean Point Leaks[/COLOR]
    Custom script:   call RemoveLocation(udg_LightStartPoint)
    Custom script:   call RemoveLocation(udg_LightEndPoint)

Summary Notes:
Red colored words = variables
Blue colored words = comments (they just explain, no coding usage)

Look at the "// Create and Storage" portion

LightCustom works like (Last created lightning effect)
Electric is a lightning variable for you to store the lightning until you want to destroy it.



[SIZE="+1"]Last Words[/SIZE]

To Jass Users
Please go ahead and use the "AddLightningEx()" function, this snippet is for GUI users mainly

What is a Lightning?
Errmmm.... I don't know why are you still reading this when you don't know what a lightning is :D

For those who are wondering why I set a Local = Global:
It is there for a purpose.... still in the trying phase, so not going to reveal anything because I might fail :D

Updates
Update will usually happen when there are questions asked, do post if you have queries or don't understand anything here.
I will reply to questions as well as update the first post
- If they happen to be the same, I leave the reply for 1 week so you can check it instead of reading the whole lot again :D
- Don't complain if there are "Double" information :D

Why do you need 3D Lightning?
There are too many reason.... at least for me :D I attached some pictures to show what I did with 3D Lightnings
ElectricDoor.jpg

MultiNet.jpg


:D A map is attached for people who want to have fun. :D
 

Attachments

  • Lightning.w3x
    24.6 KB · Views: 280

PureOwnage

Minecraft Server OP, Inactive.
Reaction score
72
Good tutorial! Deserves a +Rep :thup:
Edit: I can't give rep to you (you must spread more rep around)
 

MoonSlinger

I Love using Cheap Tricks... only Results matters
Reaction score
74
@Flare
I tried to simply return a lightning but it somehow just up the required jass knowledge... My aim is to make it as simple as possible.

So I made it such that "LightCustom" would hold the lightning and it could be assigned to another variable, just like (Last created Lightning).



With regards to your timed lightning:
I usually don't read tutorial/systems coded in Jass or vJass (I am a GUI fanatic)

If I had known earlier :(
I should have simply stolen your Lightning ID instead of tying to make my own :p
 

NullCurrent

( ゚ε ゚)
Reaction score
110
Very useful. +Rep
Im trying to get mine to work, it works great except destroying the lightning.
Could you clearify how to destroy the lightning

Also, can you make the lightning move from the start to the end?
 

MoonSlinger

I Love using Cheap Tricks... only Results matters
Reaction score
74
Im trying to get mine to work, it works great except destroying the lightning.
Could you clearify how to destroy the lightning

Also, can you make the lightning move from the start to the end?

<< Updated in first Post >>
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top