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.
[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.
[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
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.
If you still don't get it, open the test map and try to locate where I have placed the codes
[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.
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
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"
To destroy the Lightning Effect, you can simply destroy it as per normal
Also take care of the leaks which "points" might cause as well as:
[SIZE="+1"]Summary[/SIZE]
Creating and removing normal lightning:
Creating and removing this 3D lightning:
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
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
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
- Don't complain if there are "Double" information
Why do you need 3D Lightning?
There are too many reason.... at least for me I attached some pictures to show what I did with 3D Lightnings
A map is attached for people who want to have fun.
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.
[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.
[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.
If you still don't get it, open the test map and try to locate where I have placed the codes
[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
"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
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.OR
Lightning - Destroy LightCustom
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)
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
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
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
- Don't complain if there are "Double" information
Why do you need 3D Lightning?
There are too many reason.... at least for me I attached some pictures to show what I did with 3D Lightnings
A map is attached for people who want to have fun.