scope Web
globals
private constant integer Web_id = 'A001'
private constant integer Web_dummy = 'e000'
private constant integer Web_timerbuff = 'BTLF'
private constant integer Web_permhide = 'A003'
private constant integer Web_regen = 'A000'
private constant real Web_looprate = .1
endglobals
private constant function Web_lasttime takes real level returns real
return 30.*level
endfunction
private constant function Web_radius takes real level returns real
return 300.+(level-level)
endfunction
private struct Web
unit c = null
unit d = null
integer i = 0
real x = 0.00
real y = 0.00
endstruct
private function Web_Timed takes nothing returns nothing
local timer t = GetExpiredTimer()
local Web dat = GetHandleInt(t,"struct")
local group g = CreateGroup()
call GroupEnumUnitsInRange(g,dat.x,dat.y,Web_radius(I2R(dat.i)),null)
if IsUnitInGroup(dat.c,g) then
if GetUnitAbilityLevel(dat.c,Web_permhide) >= 1 then
call SetUnitAbilityLevel(dat.c,Web_permhide,dat.i)
call SetUnitAbilityLevel(dat.c,Web_regen,dat.i)
else
call UnitAddAbility(dat.c,Web_permhide)
call UnitAddAbility(dat.c,Web_regen)
call SetUnitAbilityLevel(dat.c,Web_permhide,dat.i)
call SetUnitAbilityLevel(dat.c,Web_regen,dat.i)
endif
else
call UnitRemoveAbility(dat.c,Web_permhide)
call UnitRemoveAbility(dat.c,Web_regen)
endif
call DestroyGroup(g)
if GetWidgetLife(dat.d) <= 0.405 then
call UnitRemoveAbility(dat.c,Web_permhide)
call UnitRemoveAbility(dat.c,Web_regen)
call FlushHandleLocals(t)
call dat.destroy()
call ReleaseTimer(t)
endif
set t = null
set g = null
endfunction
public function Web_Conditions takes nothing returns boolean
return GetSpellAbilityId() == Web_id
endfunction
public function Web_Actions takes nothing returns nothing
local Web dat = Web.create()
local location p = GetSpellTargetLoc()
local player o
local timer t = NewTimer()
set dat.c = GetTriggerUnit()
set dat.x = GetLocationX(p)
set dat.y = GetLocationY(p)
set dat.i = GetUnitAbilityLevel(dat.c,Web_id)
set o = GetOwningPlayer(dat.c)
set dat.d = CreateUnit(o,Web_dummy,dat.x,dat.y,bj_UNIT_FACING)
call UnitApplyTimedLife(dat.d,Web_timerbuff,Web_lasttime(I2R(dat.i)))
call RemoveLocation(p)
set p = null
set o = null
call SetHandleInt(t,"struct",dat)
call TimerStart(t,Web_looprate,true,function Web_Timed)
call UnitAddAbility(dat.c,Web_permhide)
call UnitAddAbility(dat.c,Web_regen)
endfunction
endscope
function InitTrig_Web takes nothing returns nothing
local trigger t
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition(t, Condition( function Web_Web_Conditions ) )
call TriggerAddAction(t, function Web_Web_Actions )
set t = null
endfunction