waaaks!
Zinctified
- Reaction score
- 255
Hello.
I have this fade lightning library I made that lets you create lightning (duh!) from a unit to a unit, both requires a Z offset. The library works fine in means of creating the lightning and fading it, but the Z offset thing is pissing me off.
When I used 600.0 for the sourceZ offset and 0.0 for the targetZ offset (to make it touch the ground) created in a level 3 or any level cliffs, the lightning tends to use the lowest level of the cliff as the z offset, which means 0 offset is the lowest level of terrain, creating the lightning under the cliff like this illustration:
looks like GetLocationZ is what I need to fix this, but I heard that GetLocationZ can cause desync, is there any solution?
in this code, I used to add the input Z offset to the fly height of the unit, but still it doesn't work, because the unit's fly height is 0 which adds nothing.
I have this fade lightning library I made that lets you create lightning (duh!) from a unit to a unit, both requires a Z offset. The library works fine in means of creating the lightning and fading it, but the Z offset thing is pissing me off.
When I used 600.0 for the sourceZ offset and 0.0 for the targetZ offset (to make it touch the ground) created in a level 3 or any level cliffs, the lightning tends to use the lowest level of the cliff as the z offset, which means 0 offset is the lowest level of terrain, creating the lightning under the cliff like this illustration:
looks like GetLocationZ is what I need to fix this, but I heard that GetLocationZ can cause desync, is there any solution?
in this code, I used to add the input Z offset to the fly height of the unit, but still it doesn't work, because the unit's fly height is 0 which adds nothing.
JASS:
library FadeLightning
private struct vdata
lightning l
real dur
real ctr
unit t
real tz
real x
real y
real z
real R
real G
real B
endstruct
private function callBacks takes nothing returns boolean
local timer t = GetExpiredTimer()
local vdata d = GetTimerData(t)
local real A
set A = d.ctr / d.dur
call MoveLightningEx(d.l,true,GetUnitX(d.t),GetUnitY(d.t),d.tz,d.x,d.y,d.z)
call SetLightningColor(d.l,d.R,d.G,d.B,d.ctr)
set d.ctr = d.ctr - 0.035
if d.ctr <= 0 then
set A = 0
call DestroyLightning(d.l)
call ReleaseTimer(t)
call d.destroy()
endif
set t = null
return true
endfunction
function LightningSourceTarget takes unit source, real sourcez, real targetx, real targety, real targetz, string light, real dur, real R, real G, real B returns nothing
local timer t = NewTimer()
local vdata d = vdata.create()
set d.l = AddLightningEx(light, true, GetUnitX(source), GetUnitY(source), sourcez + GetLocationZ(Location(GetUnitX(source),GetUnitY(source))), targetx, targety, targetz + GetLocationZ(Location(targetx,targety)))
set d.dur = dur
set d.ctr = dur
set d.t = source
set d.tz = sourcez + GetLocationZ(Location(GetUnitX(source),GetUnitY(source)))
set d.x = targetx
set d.y = targety
set d.z = targetz + GetLocationZ(Location(targetx,targety))
set d.R = R
set d.G = G
set d.B = B
call SetLightningColor(d.l,R,G,B,1.0)
call TimerStart(t,0.035,true, function callBacks)
call SetTimerData(t,d)
set t = null
endfunction
endlibrary