• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Lightning Z Location

Status
Not open for further replies.
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • Custom script: call AddLightningEx takes string codeName, boolean checkVisibility, real x1, real y1, real z1, real x2, real y2, real z2 returns lightning

  • LIGHTNING EFFECTS
    • Events
    • Conditions
    • Actions
      • Lightning - Create a Chain Lightning - Primary lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
      • Lightning - Create a Chain Lightning - Secondary lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
      • Lightning - Create a Drain lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
      • Lightning - Create a Drain Life lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
      • Lightning - Create a Drain Mana lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
      • Lightning - Create a Finger of Death lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
      • Lightning - Create a Forked Lightning lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
      • Lightning - Create a Healing Wave - Primary lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
      • Lightning - Create a Healing Wave - Secondary lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
      • Lightning - Create a Lightning Attack lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
      • Lightning - Create a Magic Leash lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
      • Lightning - Create a Mana Burn lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
      • Lightning - Create a Mana Flare lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
      • Lightning - Create a Spirit Link lightning effect from source (Position of (Triggering unit)) to target (Center of (Playable map area))
      • -------- -------------------- --------
      • Custom script: set udg_Death_Gaze_Lightning = AddLightningEx( "CLPB" , true, GetLocationX(udg_Temp_Loc_1), GetLocationY(udg_Temp_Loc_1), udg_Z_location_1, GetLocationX(udg_Temp_Loc_2), GetLocationY(udg_Temp_Loc_2), udg_Z_location_2)
      • Custom script: set udg_Death_Gaze_Lightning = AddLightningEx( "CLSB" , true, GetLocationX(udg_Temp_Loc_1), GetLocationY(udg_Temp_Loc_1), udg_Z_location_1, GetLocationX(udg_Temp_Loc_2), GetLocationY(udg_Temp_Loc_2), udg_Z_location_2)
      • Custom script: set udg_Death_Gaze_Lightning = AddLightningEx( "DRAB" , true, GetLocationX(udg_Temp_Loc_1), GetLocationY(udg_Temp_Loc_1), udg_Z_location_1, GetLocationX(udg_Temp_Loc_2), GetLocationY(udg_Temp_Loc_2), udg_Z_location_2)
      • Custom script: set udg_Death_Gaze_Lightning = AddLightningEx( "DRAL" , true, GetLocationX(udg_Temp_Loc_1), GetLocationY(udg_Temp_Loc_1), udg_Z_location_1, GetLocationX(udg_Temp_Loc_2), GetLocationY(udg_Temp_Loc_2), udg_Z_location_2)
      • Custom script: set udg_Death_Gaze_Lightning = AddLightningEx( "DRAM" , true, GetLocationX(udg_Temp_Loc_1), GetLocationY(udg_Temp_Loc_1), udg_Z_location_1, GetLocationX(udg_Temp_Loc_2), GetLocationY(udg_Temp_Loc_2), udg_Z_location_2)
      • Custom script: set udg_Death_Gaze_Lightning = AddLightningEx( "AFOD" , true, GetLocationX(udg_Temp_Loc_1), GetLocationY(udg_Temp_Loc_1), udg_Z_location_1, GetLocationX(udg_Temp_Loc_2), GetLocationY(udg_Temp_Loc_2), udg_Z_location_2)
      • Custom script: set udg_Death_Gaze_Lightning = AddLightningEx( "FORK" , true, GetLocationX(udg_Temp_Loc_1), GetLocationY(udg_Temp_Loc_1), udg_Z_location_1, GetLocationX(udg_Temp_Loc_2), GetLocationY(udg_Temp_Loc_2), udg_Z_location_2)
      • Custom script: set udg_Death_Gaze_Lightning = AddLightningEx( "HWPB" , true, GetLocationX(udg_Temp_Loc_1), GetLocationY(udg_Temp_Loc_1), udg_Z_location_1, GetLocationX(udg_Temp_Loc_2), GetLocationY(udg_Temp_Loc_2), udg_Z_location_2)
      • Custom script: set udg_Death_Gaze_Lightning = AddLightningEx( "HWSB" , true, GetLocationX(udg_Temp_Loc_1), GetLocationY(udg_Temp_Loc_1), udg_Z_location_1, GetLocationX(udg_Temp_Loc_2), GetLocationY(udg_Temp_Loc_2), udg_Z_location_2)
      • Custom script: set udg_Death_Gaze_Lightning = AddLightningEx( "CHIM" , true, GetLocationX(udg_Temp_Loc_1), GetLocationY(udg_Temp_Loc_1), udg_Z_location_1, GetLocationX(udg_Temp_Loc_2), GetLocationY(udg_Temp_Loc_2), udg_Z_location_2)
      • Custom script: set udg_Death_Gaze_Lightning = AddLightningEx( "LEAS" , true, GetLocationX(udg_Temp_Loc_1), GetLocationY(udg_Temp_Loc_1), udg_Z_location_1, GetLocationX(udg_Temp_Loc_2), GetLocationY(udg_Temp_Loc_2), udg_Z_location_2)
      • Custom script: set udg_Death_Gaze_Lightning = AddLightningEx( "MBUR" , true, GetLocationX(udg_Temp_Loc_1), GetLocationY(udg_Temp_Loc_1), udg_Z_location_1, GetLocationX(udg_Temp_Loc_2), GetLocationY(udg_Temp_Loc_2), udg_Z_location_2)
      • Custom script: set udg_Death_Gaze_Lightning = AddLightningEx( "MFPB" , true, GetLocationX(udg_Temp_Loc_1), GetLocationY(udg_Temp_Loc_1), udg_Z_location_1, GetLocationX(udg_Temp_Loc_2), GetLocationY(udg_Temp_Loc_2), udg_Z_location_2)
      • Custom script: set udg_Death_Gaze_Lightning = AddLightningEx( "SPLK" , true, GetLocationX(udg_Temp_Loc_1), GetLocationY(udg_Temp_Loc_1), udg_Z_location_1, GetLocationX(udg_Temp_Loc_2), GetLocationY(udg_Temp_Loc_2), udg_Z_location_2)


Instead of GetLocationX, you can use GetUnitX. But you might need to use locations for the last parameters, z1 and z2.
 
Level 21
Joined
Mar 19, 2009
Messages
444
JASS:
 library Lightnings initializer init needs AbilityPreload,TimerUtils//AbilityPreload and TimerUtils are both available at wc3.net
globals
    private constant real LIGHTNING_Z = 0. //A small offset if you want to link 2 units. 0. = lightning will be created on the feet
    private constant real TIMEOUT = 0.03 //Period of the timer. The fastest it is, the most fluant it is but the most power_devourer it is.
    private constant integer DUMMY_ID = 'u000' //id of a dummy unit without any model -  stats - sight etc...
    private constant integer RAVEN_ID = 'Amrf" //Given to a unit, this ability allows to change the flying height.
endglobals 
    
    private struct str  //a struct is something like a meta-variable
        unit origin  //origin of the lightning
        unit destination   //...
        lightning fx //your lightning
        integer duration
        integer i
    endstruct


    private function Update takes nothing returns nothing //this function updates the position of the lightning in the case you want it to move
        local timer t = GetExpiredTimer() //through Timerutils
        local str dat = GetTimerData(t)  //you are able to retreive the data stored into the struct
        local real x1 = GetUnitX(dat.origin)
        local real y1 = GetUnitY(dat.origin)
        local real z1 = GetUnitFlyHeight(dat.origin)
        local real x2 = GetUnitX(dat.destination)
        local real y2 = GetUnitY(dat.destination)
        local real z2 = GetUnitFlyHeight(dat.destination)
            if dat.i < dat.duration and not (IsUnitType(dat.origin,UNIT_TYPE_DEAD)) and not (IsUnitType(dat.destination,UNIT_TYPE_DEAD)) then
                set dat.i = dat.i + 1    //if the origin and the destination are alive, still update the lightning position
                call MoveLightningEx(dat.fx,true,x1,y1,z1+LIGHTNING_Z,x2,y2,z2+LIGHTNING_Z)
            else
                call DestroyLightning(dat.fx) //if timer has reached the duration (counted with the integer i) or one of the unit is dead, remove the lightning
                call ReleaseTimer(t)  //release the timer through timerutils to avoid leaks
                call dat.destroy() //destroy the struct
            endif
    endfunction

    //This function allows to link 2 units with a lightning
    //origin = first unit
    //destination = second unit
    //duration = the maximal duration you want the lightning to get
    //lightningArt = the string of the lightning (like a model for a special effect, example "DRAL", "DRAM" etc..)
    function AddLightningToUnits takes unit origin, unit destination, real duration, string lightningArt returns nothing
        local timer t = NewTimer() // create a timer through TimerUtils
        local str  dat = str.create() //Create a struct (metavariable)
        local real x1 = GetUnitX(origin)
        local real y1 = GetUnitY(origin)
        local real z1 = GetUnitFlyHeight(origin)
        local real x2 = GetUnitX(destination)
        local real y2 = GetUnitY(destination)
        local real z2 = GetUnitFlyHeight(destination)
            set dat.origin = origin
            set dat.destination = destination
            set dat.duration = R2I(duration/TIMEOUT)
            set dat.fx = AddLightningEx(lightningArt_ART, true,x1,y1,z1+LIGHTNING_Z,x2,y2,z2+LIGHTNING_Z)
            set dat.i = 0
            call SetTimerData(t, dat) 
            call TimerStart (t, TIMEOUT, true, function Update )
    endfunction  

    //This function allows you to create a lightning effect from a point (x1,y1,z1) to an other point (x2,y2,z2) during (duration) seconds with the (lightningArt) effect
    function AddLightningOnLocation takes real x1, real y1, real z1, real x2, real y2, real z2, real duration, string lightningArt returns nothing
             local unit origin = CreateUnit(Player(15),DUMMY_ID,x1,y1,0.)
             local unit destination = CreateUnit(Player(15),DUMMY_ID,x2,y2,0.)
                 call UnitAddAbility(origin,RAVEN_ID)
                 call UnitAddAbility(destination,RAVEN_ID)
                 call SetUnitFlyHeight(origin,z1,0.)
                 call SetUnitFlyHeight(destination,z2,0.)
                 call UnitApplyTimedLife(origin,'BTLF',duration)
                 call UnitApplyTimedLife(destination,'BTLF',duration)
                 call AddLightningToUnits(origin,destination,duration,lightningArt)
                 set origin = null
                 set destination = null
    endfunction

    private function init takes nothing returns nothing
            call AbilityPreload(RAVEN_ID)//To prevent lag on first use
    endfunction
    
endlibrary
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Yes, x1 , x2 , y1 , y2 are coordinates.

Point(x1 , y1) = The starting point
Point(x2, y2) = The ending point
z1 = Lightning height offset at the starting point
z2 = Lightning height offset at the starting point

You can do it like this:

Set Location1 = Position of Unit(u)
Set z1 = GetLocationZ(udg_Location1)

Now the starting point will be at grond level. If you do this:
Set z1 = GetLocationZ(udg_Location1) + 100
The starting point will be slightly above ground.
 
Status
Not open for further replies.
Top