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.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top