EDIT: NEVERMIND. GOT IT TO WORK. (I'm really stupid rofl)
I Changed this:
to this:
I Changed this:
JASS:
library TimeLapse initializer Init requires TimerUtils, PUI
globals
private constant integer AbilId = 039;A01X039;
private boolean array Cast
private constant real TimerFrequency = 0.03125
private constant integer MaxValue = 160
private constant string StartSFX = "Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl"
private constant string EndSFX = "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl"
endglobals
private struct Lapse
unit u
integer CurrentValue
real array x[MaxValue]
real array y[MaxValue]
endstruct
private function Periodic takes nothing returns nothing
local timer tim = GetExpiredTimer()
local Lapse d = GetTimerData(tim)
local real val = 0
local real ox = GetUnitX(d.u)
local real oy = GetUnitY(d.u)
if Cast[GetUnitIndex(d.u)] == true then
call DestroyEffect(AddSpecialEffect(StartSFX, ox, oy))
set val = d.CurrentValue - MaxValue
loop
exitwhen val >= 0
set val = MaxValue+val
endloop
call DestroyEffect(AddSpecialEffect(EndSFX, d.x[R2I(val)], d.y[R2I(val)]))
call SetUnitX(d.u, d.x[R2I(val)])
call SetUnitY(d.u, d.y[R2I(val)])
set Cast[GetUnitIndex(d.u)] = false
endif
set d.CurrentValue = d.CurrentValue + 1
if d.CurrentValue > MaxValue then
set d.CurrentValue = 0
endif
call BJDebugMsg(I2S(d.CurrentValue))
set d.x[d.CurrentValue] = ox
set d.y[d.CurrentValue] = oy
endfunction
public function Add takes unit u returns nothing
local Lapse d = Lapse.create()
local timer tim = NewTimer()
set d.u = u
set d.CurrentValue = 0
set d.x[d.CurrentValue] = GetUnitX(d.u)
set d.y[d.CurrentValue] = GetUnitY(d.u)
set Cast[GetUnitIndex(d.u)] = false
call SetTimerData(tim, d)
call TimerStart(tim, TimerFrequency, true, function Periodic)
endfunction
private function Action takes nothing returns nothing
local unit c = GetTriggerUnit()
local integer PUI = GetUnitIndex(c)
set Cast[PUI] = true
set c = null
endfunction
private function Cond takes nothing returns boolean
return GetSpellAbilityId() == AbilId
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function Cond))
call TriggerAddAction(t, function Action)
endfunction
endlibrary
to this:
JASS:
library TimeLapse initializer Init requires TimerUtils, PUI
globals
private constant integer AbilId = 039;A01X039;
private boolean array Cast
private constant real TimerFrequency = 0.03125
private constant integer MaxValue = 160
private constant string StartSFX = "Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl"
private constant string EndSFX = "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl"
endglobals
private struct Lapse
unit u
integer CurrentValue
real array x[MaxValue]
real array y[MaxValue]
endstruct
private function Periodic takes nothing returns nothing
local timer tim = GetExpiredTimer()
local Lapse d = GetTimerData(tim)
local integer val = 0
local real ox = GetUnitX(d.u)
local real oy = GetUnitY(d.u)
if Cast[GetUnitIndex(d.u)] == true then
call DestroyEffect(AddSpecialEffect(StartSFX, ox, oy))
set val = d.CurrentValue + 1
if val > MaxValue then
set val = 0
endif
call DestroyEffect(AddSpecialEffect(EndSFX, d.x[val], d.y[val]))
call SetUnitX(d.u, d.x[R2I(val)])
call SetUnitY(d.u, d.y[R2I(val)])
set Cast[GetUnitIndex(d.u)] = false
endif
set d.CurrentValue = d.CurrentValue + 1
if d.CurrentValue > MaxValue then
set d.CurrentValue = 0
endif
set d.x[d.CurrentValue] = ox
set d.y[d.CurrentValue] = oy
endfunction
public function Add takes unit u returns nothing
local Lapse d = Lapse.create()
local timer tim = NewTimer()
set d.u = u
set d.CurrentValue = 0
set d.x[d.CurrentValue] = GetUnitX(d.u)
set d.y[d.CurrentValue] = GetUnitY(d.u)
set Cast[GetUnitIndex(d.u)] = false
call SetTimerData(tim, d)
call TimerStart(tim, TimerFrequency, true, function Periodic)
endfunction
private function Action takes nothing returns nothing
local unit c = GetTriggerUnit()
local integer PUI = GetUnitIndex(c)
set Cast[PUI] = true
set c = null
endfunction
private function Cond takes nothing returns boolean
return GetSpellAbilityId() == AbilId
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function Cond))
call TriggerAddAction(t, function Action)
endfunction
endlibrary