- Joined
- Jul 28, 2008
- Messages
- 211
I've just learned how to use hashtables and I made a simple spell. But, as always, it isn't working and I'm posting it here so someone can tell me what's wrong with it.
Thanks in advance.
JASS:
scope Mind initializer Init
globals
private constant integer SPELL_ID = 'A000'
private constant integer BUFF_ID = 'B000'
private constant integer SLOW_ID = 'A001'
private constant integer DUMMY_ID = 'h000'
private constant real TIME = 10.00
private hashtable h = InitHashtable()
endglobals
private function DMG takes integer lvl returns real
return I2R(lvl * 5 + 5)
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
private function Callback takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit c = LoadUnitHandle(h, 0, GetHandleId(t))
local unit u = LoadUnitHandle(h, 1, GetHandleId(t))
local integer i = LoadInteger(h, 2, GetHandleId(t))
if GetUnitAbilityLevel(u, BUFF_ID) > 0 then
call UnitDamageTarget(c, u, DMG(i), false, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
endif
set t = null
set c = null
set u = null
endfunction
private function Actions takes nothing returns nothing
local timer t = CreateTimer()
local unit c = GetTriggerUnit()
local unit u = GetSpellTargetUnit()
local unit d = CreateUnit(GetOwningPlayer(c), DUMMY_ID, GetUnitX(u), GetUnitY(u), 0.00)
call UnitApplyTimedLife(d, 'BTLF', 3.00)
call SaveUnitHandle(h, 0, GetHandleId(t), u)
call SaveUnitHandle(h, 1, GetHandleId(t), c)
call SaveInteger(h, 2, GetHandleId(t), GetUnitAbilityLevel(c, SPELL_ID))
call UnitAddAbility(d, SLOW_ID)
call IssueTargetOrder(d, "cripple", u)
call TimerStart(t, 1.00, true, function Callback)
call TriggerSleepAction(TIME)
call PauseTimer(t)
call DestroyTimer(t)
set t = null
set c = null
set u = null
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 Conditions))
call TriggerAddAction(t, function Actions)
endfunction
endscope
Thanks in advance.