- Joined
- Jul 26, 2008
- Messages
- 1,009
It's odd, because the other spell resets it just fine that I have and runs similarly.
The spell is an activatable based on immolation.
The spell sets your Movespeed to 1 at the end of it's timer for some reason, but the amount to subtract is only 250.
The spell is an activatable based on immolation.
The spell sets your Movespeed to 1 at the end of it's timer for some reason, but the amount to subtract is only 250.
JASS:
scope Hunt initializer init
globals
private constant integer SPELLID = 'hunt'
private constant string TurnOn = "immolation"
private constant string TurnOff = "unimmolation"
private constant real tick = 0.1
private HandleTable info
endglobals
private struct Data
unit c
boolean deactivate = false
integer co
real bonus
timer tim
real mspd
real d
real i
static method onLoop takes nothing returns nothing
local Data D = Data(GetTimerData(GetExpiredTimer()))
local integer lvl = GetUnitAbilityLevel(D.c, SPELLID)
local real aspd = 2+1*lvl
local real mspd = 5*lvl
local real cap = 15+10*lvl
if not(IsUnitType(D.c,UNIT_TYPE_DEAD)) and not(D.deactivate) and GetUnitState(D.c, UNIT_STATE_MANA) >= 25 then
//Start timer
if D.d == 1 + D.i and D.i <= 3+3*lvl then
set D.i = D.i + 1
set D.co = D.co - 21
if D.bonus < cap then
call UnitModifyAttackSpeed(D.c, aspd)
if GetUnitMoveSpeed(D.c) < 500 then
call SetUnitMoveSpeed(D.c, GetUnitMoveSpeed(D.c) + mspd)
debug call BJDebugMsg(R2S(D.mspd))
set D.mspd = D.mspd + mspd
endif
set D.bonus = D.bonus + aspd
endif
call SetUnitVertexColor(D.c, 255, D.co, D.co, 255)
call SetUnitState(D.c, UNIT_STATE_MANA, GetUnitState(D.c, UNIT_STATE_MANA) - D.i*(0.6*lvl))
elseif D.i > 3+3*lvl then
if D.bonus < cap then
call UnitModifyAttackSpeed(D.c, aspd)
set D.bonus = D.bonus + aspd
endif
call SetUnitState(D.c, UNIT_STATE_MANA, GetUnitState(D.c, UNIT_STATE_MANA) - D.i*(lvl*0.05))
endif
set D.d = D.d + tick
else
//Cleanup
call BJDebugMsg(R2S(D.mspd)+" is the end result")
call SetUnitMoveSpeed(D.c, GetUnitMoveSpeed(D.c)-D.mspd)
call UnitModifyAttackSpeed(D.c, -D.bonus)
call SetUnitVertexColor(D.c, 255,255,255,255)
call IssueImmediateOrder(D.c, TurnOff)
call IssueSecondLastOrder(D.c)
call info.flush(D.c)
set D.c = null
call ReleaseTimer(D.tim)
call D.destroy()
endif
endmethod
static method create takes unit caster, real movespeed returns Data
local Data D = Data.allocate()
set D.c = caster
set D.co = 255
set D.d = 0
set D.i = 0
set D.bonus = 0
set D.mspd = 0
//Timer
set D.tim = NewTimer()
call SetTimerData(D.tim,D)
call TimerStart(D.tim, tick, true, function Data.onLoop)
set info[D.c] = D
return D
endmethod
endstruct
private function Deactivate takes nothing returns boolean
local Data D
if GetIssuedOrderId() == OrderId(TurnOff) and info.exists(GetTriggerUnit()) then
set D = info[GetTriggerUnit()]
set D.deactivate = true
endif
return false
endfunction
private function Activation takes nothing returns boolean
if GetIssuedOrderId() == OrderId(TurnOn) and GetUnitAbilityLevel(GetTriggerUnit(), SPELLID) > 0 then
call Data.create(GetTriggerUnit(), GetUnitMoveSpeed(GetTriggerUnit()))
endif
return false
endfunction
//===========================================================================
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerAddCondition(t, function Activation )
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerAddCondition( t, function Deactivate )
set info = HandleTable.create()
call XE_PreloadAbility(SPELLID)
endfunction
endscope