• 🏆 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!

Lightning Flashes - Environmental Effect

zZZZLightning FlashesZZZz

What this tutorial will teach you to do:

Create a flashing lightning effect to add to your dynamic environmental effects. You may know how to put nature sounds across a region, create ambient rain or fog in a region and create a periodic roll of thunder, but now add heat lightning to your environment. I looked everywhere for a tutorial on how to do this. I still really like the monsoon target buff .mdx but I couldn't make the blast and fumes at the end of the animation disappear. So unless some really nice model-maker comes along and creates one, this will have to do for now.

What you need to get started:
  1. View attachment Light.mdx
  2. World Editor

Let's get started:

Step 1:

Import Light.mdx into your map with Import Manager and
SAVE! .

Step 2:

Select a unit in Object Editor and make sure it is highlighted.
Press cntrl-C and then contrl-V (copy and paste).
Then click OK.
This will be our light dummy unit.

Lightning%20Flashes.jpg

Step 3:

Edit the unit's data fields in Object Editor as follows:
PHP:
Abilities - Normal: Locust
Movement - Height: 70 
Movement - Type: Fly
Pathing - Collision Size: 0.00
Art - Scaling Value: 5.00 
Combat - Attacks Enabled: None
Feel free to give it a lightning icon and anything else you want. Height is not so important but it will change the downward angle of the flash.
And then rename it something appropriate, like LightningDummy, or fxUnit (that's what I will call it).


Step 4:



You can do this part many ways, and I am sure this is not the best by any means. They way you do this next part might depend on how your map is intended to function.
Open Trigger Editor.

Now create the trigger. Here's what I did:


  • Lightning Flashing Effect
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
      • (Blood Moore <gen> contains unit) Equal to True
    • Actions
      • -----set to store location for removal later. we hate leaks------
      • Set temploc = (Position of (pWhatever_Unit))
      • Set temploc2 = (temploc offset by 200.00 towards 0.00 degrees)
      • -------The distance and angle will change the intensity and x,y direction of the flash----
      • ----------------------------------------------------------------------------------------
      • Unit - Create 1 Lightning for Neutral Passive at temploc2 facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_temploc)
      • Custom script: call RemoveLocation(udg_temploc2)
      • Set fxUnit = (Last created unit)
      • Wait 0.03 seconds
      • Unit - Remove fxUnit from the game
      • --------One flash is complete, but one is never enough for a spooky storm------
      • ----------so. . . . . . --------
      • Wait 0.04 seconds
      • Set temploc = (Position of unit)
      • Set temploc2 = (temploc offset by 200.00 towards 0.00 degrees)
      • Unit - Create 1 Lightning for Neutral Passive at temploc2 facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_temploc)
      • Custom script: call RemoveLocation(udg_temploc2)
      • Set fxUnit = (Last created unit)
      • Wait 0.04 seconds
      • Unit - Remove fxUnit from the game
      • ------And again-------------------------------------
      • Wait 0.04 seconds
      • Set temploc = (Position of unit)
      • Set temploc2 = (temploc offset by 200.00 towards 0.00 degrees)
      • Unit - Create 1 Lightning for Neutral Passive at temploc2 facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_temploc)
      • Custom script: call RemoveLocation(udg_temploc2)
      • Set fxUnit = (Last created unit)
      • Wait 0.05 seconds
      • Unit - Remove fxUnit from the game
      • -----Pause for effect and ... wait for it-----
      • Wait 1.00 seconds
      • Sound - Play RollingThunder1 <gen>
      • -----And how about a bit of thunder for a nice finish-------------

Blizzard did it this way in Chapter 4 of the Night Elf Campaign like this:
  • Occasional Lightning
    • Events
      • Time - LightningTimer expires
    • Conditions
    • Actions
      • Wait until (InCinematic Equal to False), checking every 1.00 seconds
      • Countdown Timer - Start LightningTimer as a One-shot timer that will expire in (Random real number between 25.00 and 60.00) seconds
      • Cinematic - Fade out and back in over 0.12 seconds using texture White Mask and color (100.00%, 100.00%, 100.00%) with 5.00% transparency
      • Wait 0.03 seconds
      • Cinematic - Fade out and back in over 0.12 seconds using texture White Mask and color (100.00%, 100.00%, 100.00%) with 5.00% transparency
      • Wait 0.20 seconds
      • Set RandomSound = (Random integer number between 1 and 2)
      • If (RandomSound Equal to 1) then do (Sound - Play LightningBolt1 <gen>) else do (Do nothing)
      • If (RandomSound Equal to 2) then do (Sound - Play RollingThunder1 <gen>) else do (Do nothing)
Or as suggested in a comment below, a better way would be to use an advanced filter. This protects tooltips:

  • Cinematic - Apply a filter over 0.12 seconds using Normal blending on texture White Mask, starting with color (100.00%, 100.00%, 100.00%) and 25.00% transparency and ending with color (0.00%, 0.00%, 0.00%) and 100.00% transparency


Put them both together to get this effect ---->

For more on lighting and environmental effects,
try reading the following:

Storm.jpg




 
Last edited:
Level 14
Joined
Nov 17, 2010
Messages
1,265
I've seen them done with a cinematic filter and it looks ok, but I like the way this looks way better personally. I guess it's up to you which method you prefer.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
That's a nice addition. So you mean that we should do this?

  • Set temploc2 = (temploc offset by 200.00 towards (Random number from 0 to 360) degrees)

Exactly, randoming offset is not bad either. Maybe between 175 and 225

My last suggestion is using a loop instead of repeating code.
  • Untitled Trigger 001
    • Events
      • Time - Elapsed game time is 3.00 seconds
    • Conditions
    • Actions
      • Custom script: local location udg_loc
      • Custom script: local location udg_loc2
      • Custom script: local unit udg_u
      • Unit - Order Ancient of Lore 0000 <gen> to Move To (Center of Region 001 <gen>)
      • Camera - Lock camera target for Player 1 (Red) to Ancient of Lore 0000 <gen>, offset by (0.00, 0.00) using Default rotation
      • Camera - Set Player 1 (Red)'s camera Rotation to 120.00 over 0.00 seconds
      • Camera - Set Player 1 (Red)'s camera Distance to target to 1050.00 over 0.00 seconds
      • Camera - Set Player 1 (Red)'s camera Angle of attack to 350.00 over 0.00 seconds
      • Wait 3.00 seconds
      • For each (Integer A) from 1 to 3, do (Actions)
        • Loop - Actions
          • Set loc = (Position of Ancient of Lore 0000 <gen>)
          • Set loc2 = (loc offset by 200.00 towards (Random angle) degrees)
          • Unit - Create 1 Lightning for Neutral Passive at loc2 facing Default building facing degrees
          • Set u = (Last created unit)
          • Custom script: call RemoveLocation(udg_loc)
          • Custom script: call RemoveLocation(udg_loc2)
          • Wait 0.03 seconds
          • Sound - Play RollingThunder1 <gen>
          • Unit - Remove u from the game
          • Wait 5.00 seconds
This creates lightning 3 times with a 5 second interval.
Obviously you can ignore the camera and order stuff, that's for my map alone.
 
Last edited:
Top