globals
// ========= GENERAL =========
private constant integer DUMMYID = 'n000'
private constant string MODELPATH = "war3mapImported\\VoidWalker.mdx" //"Abilities\\Spells\\Human\\Banish\\BanishTarget.mdl"
private constant real GROWTH_DURATION = 1.
private constant real MAX_SIZE = 2.
private constant real TICK = 1./32.
endglobals
private struct UnitImage
unit u
unit dummy
integer fade
real size
timer t
effect spx
static integer fadeStep
static real sizeStep
private static method onTick takes nothing returns nothing
local thistype data = thistype(GetTimerData(GetExpiredTimer()))
local real x
local real y
if not (data.fade <= 0) then
set data.fade = data.fade - fadeStep
set data.size = data.size + sizeStep
set x = GetUnitX(data.u)
set y = GetUnitY(data.u)
call SetUnitPosition(data.dummy, x, y)
call SetUnitFacing(data.dummy, GetUnitFacing(data.dummy))
call SetUnitVertexColor(data.dummy, 255,255,255,data.fade)
call SetUnitScale(data.dummy, data.size, data.size,data.size)
else
call data.destroy()
endif
endmethod
public static method create takes unit caster, unit target returns thistype
local thistype data = thistype.allocate()
local real x = GetUnitX(target)
local real y = GetUnitY(target)
set data.u = target
set data.dummy = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), DUMMYID, GetUnitX(data.u), GetUnitY(data.u), GetUnitFacing(data.u))
set data.spx = AddSpecialEffectTarget(MODELPATH, data.u,"origin")
call SetUnitPosition(data.dummy, x, y)
set data.fade = 255
set data.size = 1.
set data.t = NewTimer()
call SetTimerData(data.t, integer(data))
call TimerStart(data.t, TICK, true, function thistype.onTick)
return data
endmethod
private method onDestroy takes nothing returns nothing
set this.u = null
call RemoveUnit(this.dummy)
call DestroyEffect(this.spx)
call ReleaseTimer(this.t)
set this.spx = null
set this.dummy = null
endmethod
private static method onInit takes nothing returns nothing
set fadeStep = R2I((255. * TICK) / GROWTH_DURATION)
set sizeStep = (MAX_SIZE * TICK) / GROWTH_DURATION
endmethod
endstruct