NeuroToxin
New Member
- Reaction score
- 46
Okay, so heres my spell:
The Witch Doctor can channel for 120 seconds to gain +5 attributes to all stats; since the Witch Doctor can gather souls, each soul reduces the channel time by 10 seconds. My problem? It doesn't work. At all, and my channel ability only needs one level. Heres my code
The Witch Doctor can channel for 120 seconds to gain +5 attributes to all stats; since the Witch Doctor can gather souls, each soul reduces the channel time by 10 seconds. My problem? It doesn't work. At all, and my channel ability only needs one level. Heres my code
JASS:
scope Attributegain initializer Init
globals
private timer ChannelTime = CreateTimer()
private integer TimeLeft = 120
private boolean FinishedCast = false
private unit Caster = null
endglobals
private function ReduceTime takes nothing returns nothing
if TimeLeft <= 1 then
call SetHeroAgi( Caster, GetHeroAgi(Caster, false) + 5, true)
call SetHeroStr( Caster, GetHeroStr(Caster, false) + 5, true)
call SetHeroInt( Caster, GetHeroInt(Caster, false) + 5, true)
set FinishedCast = true
call PauseTimer(ChannelTime)
call IssueImmediateOrder( Caster, "Stop")
set TimeLeft = 120
else
set TimeLeft = TimeLeft - 1
endif
endfunction
private function StartSpell takes nothing returns boolean
if GetSpellAbilityId() == 039;A01L039; and FinishedCast == true then
set Caster = GetTriggerUnit()
if COUNT > 12 then
set COUNT = COUNT - 12
set TimeLeft = 1
elseif COUNT < 12 then
set TimeLeft = TimeLeft - (COUNT * 10)
set COUNT = 0
endif
call TimerStart( ChannelTime, 1, true, function ReduceTime)
elseif GetSpellAbilityId() == 039;A01L039; and FinishedCast == false then
call TimerStart( ChannelTime, 1, true, function ReduceTime)
endif
return false
endfunction
private function CancelSpell takes nothing returns boolean
if GetTriggerUnit() == Caster then
call PauseTimer(ChannelTime)
endif
return false
endfunction
//===========================================================================
function Init takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition( t, Condition(function StartSpell))
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ISSUED_ORDER)
call TriggerAddCondition( t, Condition(function CancelSpell))
endfunction
endscope