- Joined
- Jun 28, 2011
- Messages
- 540
Beginner's Guide to Lightning Effects
Table of Contents
1. Lightning Effects - What and Where
Lightning Effects - What and Where
What is a lightning effect?
For those that have just started babbling with the editor - lightning effects are what you'd expect. Electrifying lines that shoot across the screen. Now, mind you - we're not talking about the doodads. We're talking about those snazzy blue and green ones that are created when you cast certain spells, like Chain Lightning. The intention of this tutorial is to show you how to properly use lightning effects.
That sounds nice - now where are they?
Blatantly put - in the editor. However, there's quite a few ways for getting lightning effects to show up in-game. You can do so by clicking on the 'Art - Lightning Effects' field in the Ability editor, as displayed below.
This is the simplest way of adding lightning effects and the abilities that can have them are:
• Chain Lightning
• Healing Wave
• Spirit Link
• Aerial Shackles
• Lightning Attack
• Mana Flare
• Mana Burn
• Finger of Death
• Forked Lightning
• Drain
Not a whole lot, hmm? Notably, you don't have a circular area of effect spell.
So let's make one.
A Triggered Lightning Spell
For those speed racers that have browsed through the trigger editor, you might've noticed a few GUI lightning triggers. If not, open the trigger editor and do so. Add a new action and search "lightning" and you'll come across these:
Custom Script?!
Yes. It's a real scary thing at first, so we'll dissect this beast together.
set udg_YOURVARIABLE
You have to create a lightning variable to use this custom script. (Last created lightning effect) will NOT work. So hit that Ctrl+B, New Variable, and set the variable type to Lightning. Hit a-okay twice and put the name of your variable after the "udg_" part of the code.
AddLightningEx
This is the name of the lightning function in Jass. There are in fact two functions similar to this one - AddLightning() and AddLightningLoc(). Both do not use the height option (Z) and so they should never be used.
LIGHTNING TYPE
This is where you define what type of lightning you want. Note that this is a string, so you must put the type of lightning inside quotes. An example of this would be "FORK" - the lightning effect will show up in-game as the Forked Lightning's lightning. If you forget about the " " an error will show up.
CHECKVISIBILITY
This is where we decide if the lightning effects will show through the fog of war and black mask. Type in true and the lightning will not appear through the fog - type in false and it will.
X1, Y1, Z1
This is where we determine where the lightning will start at. X,Y,Z are real values. If you plan on using location variables to decide where the lightning effects will be you'll have to get the location's X,Y,Z values. This can be done by using the following:
You'll have to substitute the "YOURPOINT" with the location variable's name and then you'll be good to go.
X2, Y2, Z2
Like X1, Y1, and Z1 except this is where you want your lightning to end. Use the GetLocation trick with a second location variable.
What about moving the lightning?
The second code to never use is the following:
Action Shots!
Here's an example spell that uses the above techniques to create a MUI lightning spell:
Colorizing Lightning
Want to customize your lightning effects? You can by using this wonderful code:
Here's what happened to the 'Example Spell' after changing the colors around:
Tips, Reminders, and Helpful Things
Lightning Code List
For your convenience I've compiled a list of all the lightning names, what they look like, and their code. Here you go:
Or alternatively, here's a text list:
"Chain Lightning Primary" - "CLPB"
"Chain Lightning Secondary" - "CLSB"
"Drain" - "DRAB"
"Drain Life" - "DRAL"
"Drain Mana" - "DRAM"
"Finger of Death" - "AFOD"
"Forked Lightning" - "FORK"
"Healing Wave Primary" - "HWPB"
"Healing Wave Secondary" - "HWSB"
"Lightning Attack" - "CHIM"
"Magic Leash" - "LEAS"
"Mana Burn" - "MBUR"
"Mana Flare" - "MFPB"
"Spirit Link" - "SPLK"
Lightning Circles
Circles can be made out of lightning effects - yet it's difficult and can prove laggy. If you absolutely have to have one, the trick to making one is using a loop function that creates a lightning effect. The loop makes a lightning, then creates another slightly turned, and another, until you've got a circle.
A good example of this being done is Omega Wave made by Maker.
The extra effort
When using lightning effects, you may want to add dummy units at the ends of the lightning effects and have the unit use a missile/special effect model. Apparently, it makes them look pretty. Spell moderators *may* push you to do it, so it's good practice to go ahead and add that extra special effect.
A good example of this is Chaos Singularity by Tank-Commander.
A hearty reminder
Entire spells can be made out of lightning effects. They often become the basis for advanced spells, but if you do plan on making a lightning spell make sure that it's destroyed properly. No one likes seeing a random lightning effect on the map that doesn't do anything. Make sure you use the destroy function. It's there for a reason.
[rainbow]Special Thanks[/rainbow]
I'd like to give a shout out to Radamantus for requesting me to make this, Jazztastic for his hashtable guide layout, and PurgeandFire111 for seeing if there already is a guide on lightning effects.
Back to top
Table of Contents
1. Lightning Effects - What and Where
3. Where are they?
4. A Triggered Lightning Spell5. Custom Script
6. Moving Lightning
7. Example Trigger
9. Miscellaneous Tips and Reminders10. Lightning Code List
11. Lightning Circles
12. The extra effort
13. A hearty reminder
14. Special ThanksLightning Effects - What and Where
What is a lightning effect?
For those that have just started babbling with the editor - lightning effects are what you'd expect. Electrifying lines that shoot across the screen. Now, mind you - we're not talking about the doodads. We're talking about those snazzy blue and green ones that are created when you cast certain spells, like Chain Lightning. The intention of this tutorial is to show you how to properly use lightning effects.
That sounds nice - now where are they?
Blatantly put - in the editor. However, there's quite a few ways for getting lightning effects to show up in-game. You can do so by clicking on the 'Art - Lightning Effects' field in the Ability editor, as displayed below.
This is the simplest way of adding lightning effects and the abilities that can have them are:
• Chain Lightning
• Healing Wave
• Spirit Link
• Aerial Shackles
• Lightning Attack
• Mana Flare
• Mana Burn
• Finger of Death
• Forked Lightning
• Drain
Not a whole lot, hmm? Notably, you don't have a circular area of effect spell.
So let's make one.
A Triggered Lightning Spell
For those speed racers that have browsed through the trigger editor, you might've noticed a few GUI lightning triggers. If not, open the trigger editor and do so. Add a new action and search "lightning" and you'll come across these:
- Lightning - Create a Chain Lightning - Primary lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
- Lightning - Move (Last created lightning effect) to source (Position of (Triggering unit)) and target (Center of (Playable map area))
- Lightning - Change color of (Last created lightning effect) to (1.00 1.00 1.00) with 1.00 alpha
- Lightning - Destroy (Last created lightning effect)
- Hashtable - Save Handle Of(Last created lightning effect) as 0 of 0 in (Last created hashtable)
- Lightning - Create a Chain Lightning - Primary lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
- Custom script: set udg_YOURVARIABLE = AddLightningEx(LIGHTNING TYPE, CHECKVISIBILITY, X1, Y1, Z1, X2, Y2, Z2)
Custom Script?!
Yes. It's a real scary thing at first, so we'll dissect this beast together.
set udg_YOURVARIABLE
You have to create a lightning variable to use this custom script. (Last created lightning effect) will NOT work. So hit that Ctrl+B, New Variable, and set the variable type to Lightning. Hit a-okay twice and put the name of your variable after the "udg_" part of the code.
AddLightningEx
This is the name of the lightning function in Jass. There are in fact two functions similar to this one - AddLightning() and AddLightningLoc(). Both do not use the height option (Z) and so they should never be used.
LIGHTNING TYPE
This is where you define what type of lightning you want. Note that this is a string, so you must put the type of lightning inside quotes. An example of this would be "FORK" - the lightning effect will show up in-game as the Forked Lightning's lightning. If you forget about the " " an error will show up.
CHECKVISIBILITY
This is where we decide if the lightning effects will show through the fog of war and black mask. Type in true and the lightning will not appear through the fog - type in false and it will.
X1, Y1, Z1
This is where we determine where the lightning will start at. X,Y,Z are real values. If you plan on using location variables to decide where the lightning effects will be you'll have to get the location's X,Y,Z values. This can be done by using the following:
JASS:
GetLocationX(udg_YOURPOINT)
GetLocationY(udg_YOURPOINT)
GetLocationZ(udg_YOURPOINT)
You'll have to substitute the "YOURPOINT" with the location variable's name and then you'll be good to go.
X2, Y2, Z2
Like X1, Y1, and Z1 except this is where you want your lightning to end. Use the GetLocation trick with a second location variable.
What about moving the lightning?
The second code to never use is the following:
- Lightning - Move (Last created lightning effect) to source (Position of (Triggering unit)) and target (Center of (Playable map area))
- Custom script: call MoveLightningEx(udg_YOURLIGHTNING, CHECKVISIBILITY, X1, Y1, Z1, X2, Y2, Z2)
Action Shots!
Here's an example spell that uses the above techniques to create a MUI lightning spell:
-
Lightning AoE Spell
-
Events
- Unit - A unit Starts the effect of an ability
-
Conditions
- (Ability being cast) Equal to Test Lightning Target Spell
-
Actions
- -------- Remember that (Triggering Unit) = (Casting Unit) --------
- Set Unit = (Triggering unit)
- -------- Gets the unit's handle ID --------
- Set Handle_Lightning = (Key (Triggering unit))
- -------- Set up your location variables... --------
- Set Point = (Position of Unit)
- Set Point2 = (Target point of ability being cast)
- -------- == Create the lightning effect == --------
- -------- L2 is my lightning variable. --------
- Custom script: set udg_L2 = AddLightningEx("FORK", true , GetLocationX(udg_Point), GetLocationY(udg_Point), GetLocationZ(udg_Point) + 70, GetLocationX(udg_Point2), GetLocationY(udg_Point2), GetLocationZ(udg_Point2) + 70)
- -------- Save my lightning effect in a hashtable --------
- Hashtable - Save Handle OfL2 as 1 of Handle_Lightning in Hash_Lightning
- -------- Save the maximum duration of the lightning effect --------
- Hashtable - Save 40 as 2 of Handle_Lightning in Hash_Lightning
- -------- Save the location of the lightning effect --------
- Hashtable - Save Handle OfPoint2 as 3 of Handle_Lightning in Hash_Lightning
- -------- Adds the caster to a unit group. --------
- Unit Group - Add Unit to Spell_Group
- -------- Turns on the looping trigger --------
- Trigger - Turn on Lightning Spell Loop <gen>
- -------- Turns on the looping trigger --------
- Set LightningSpell_TurnOff = (LightningSpell_TurnOff + 1)
- -------- Deal damage and remove leaks --------
- Custom script: set bj_wantDestroyGroup = true
-
Unit Group - Pick every unit in (Units within 300.00 of Point2 matching ((Owner of (Matching unit)) Not equal to Player 1 (Red))) and do (Actions)
-
Loop - Actions
- Unit - Cause Unit to damage (Picked unit), dealing 25.00 damage of attack type Spells and damage type Normal
- Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Weapons\Bolt\BoltImpact.mdl
- Special Effect - Destroy (Last created special effect)
-
Loop - Actions
- Special Effect - Create a special effect at Point2 using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
- Special Effect - Destroy (Last created special effect)
- Custom script: call RemoveLocation(udg_Point)
-
Events
-
Lightning Spell Loop
-
Events
- Time - Every 0.03 seconds of game time
- Conditions
-
Actions
-
Unit Group - Pick every unit in Spell_Group and do (Actions)
-
Loop - Actions
- -------- Get the caster --------
- Set Unit = (Picked unit)
- -------- Set up the handle --------
- Set Handle_Lightning = (Key (Picked unit))
- -------- Get the position of the caster --------
- Set Point = (Position of Unit)
- -------- Load the target point --------
- Set Point2 = (Load 3 of Handle_Lightning in Hash_Lightning)
- -------- Load the lightning --------
- Set L2 = (Load 1 of Handle_Lightning in Hash_Lightning)
- -------- Move the lightning to where the caster is standing --------
- Custom script: call MoveLightningEx(udg_L2, true , GetLocationX(udg_Point), GetLocationY(udg_Point), GetLocationZ(udg_Point) + 70, GetLocationX(udg_Point2), GetLocationY(udg_Point2), GetLocationZ(udg_Point2) + 70)
- -------- Increase the timer, when the timer is greater than the maximum time the lightning is destroyed --------
- Set Integer = (Load 5 of Handle_Lightning from Hash_Lightning)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Integer Greater than (Load 2 of Handle_Lightning from Hash_Lightning)
-
Then - Actions
- -------- Destroy the lightning --------
- Lightning - Destroy L2
- -------- Turn off the spell, clear the hashtable --------
- Unit Group - Remove Unit from Spell_Group
- Set LightningSpell_TurnOff = (LightningSpell_TurnOff - 1)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- LightningSpell_TurnOff Equal to 0
-
Then - Actions
- Trigger - Turn off (This trigger)
- Else - Actions
-
If - Conditions
- Hashtable - Clear all child hashtables of child Handle_Lightning in Hash_Lightning
- -------- Remove the target point --------
- Custom script: call RemoveLocation(udg_Point2)
-
Else - Actions
- Hashtable - Save (Integer + 1) as 5 of Handle_Lightning in Hash_Lightning
-
If - Conditions
- -------- Remove the leaks --------
- Custom script: call RemoveLocation(udg_Point)
-
Loop - Actions
-
Unit Group - Pick every unit in Spell_Group and do (Actions)
-
Events
Colorizing Lightning
Want to customize your lightning effects? You can by using this wonderful code:
- Lightning - Change color of (Last created lightning effect) to (1.00 1.00 1.00) with 1.00 alpha
Here's what happened to the 'Example Spell' after changing the colors around:
Tips, Reminders, and Helpful Things
Lightning Code List
For your convenience I've compiled a list of all the lightning names, what they look like, and their code. Here you go:
Or alternatively, here's a text list:
"Chain Lightning Primary" - "CLPB"
"Chain Lightning Secondary" - "CLSB"
"Drain" - "DRAB"
"Drain Life" - "DRAL"
"Drain Mana" - "DRAM"
"Finger of Death" - "AFOD"
"Forked Lightning" - "FORK"
"Healing Wave Primary" - "HWPB"
"Healing Wave Secondary" - "HWSB"
"Lightning Attack" - "CHIM"
"Magic Leash" - "LEAS"
"Mana Burn" - "MBUR"
"Mana Flare" - "MFPB"
"Spirit Link" - "SPLK"
Lightning Circles
Circles can be made out of lightning effects - yet it's difficult and can prove laggy. If you absolutely have to have one, the trick to making one is using a loop function that creates a lightning effect. The loop makes a lightning, then creates another slightly turned, and another, until you've got a circle.
A good example of this being done is Omega Wave made by Maker.
The extra effort
When using lightning effects, you may want to add dummy units at the ends of the lightning effects and have the unit use a missile/special effect model. Apparently, it makes them look pretty. Spell moderators *may* push you to do it, so it's good practice to go ahead and add that extra special effect.
A good example of this is Chaos Singularity by Tank-Commander.
A hearty reminder
Entire spells can be made out of lightning effects. They often become the basis for advanced spells, but if you do plan on making a lightning spell make sure that it's destroyed properly. No one likes seeing a random lightning effect on the map that doesn't do anything. Make sure you use the destroy function. It's there for a reason.
- Lightning - Destroy (Last created lightning effect)
[rainbow]Special Thanks[/rainbow]
I'd like to give a shout out to Radamantus for requesting me to make this, Jazztastic for his hashtable guide layout, and PurgeandFire111 for seeing if there already is a guide on lightning effects.
Back to top
CHANGE LOG
v1.0 - Uploaded
v1.1 - Added Table of Contents
Last edited by a moderator: