- Joined
- Jul 28, 2008
- Messages
- 211
I'm making a stackable spell and I need a way to change the time remaining for a wait or a timer.
Here's my code so far:
I need a way to restart the timer when it triggers twice for the same unit? Any suggestions?
Here's my code so far:
JASS:
scope Endless initializer Init
globals
private constant integer SPELL_ID = 'A001'
private constant integer DAMAGE_ID = 'A002'
private constant integer SPEED_ID = 'A003'
private group g = CreateGroup()
endglobals
private function Conditions takes nothing returns boolean
return (GetUnitAbilityLevel(GetTriggerUnit(), SPELL_ID) > 0) and (GetRandomInt(0, 100) < (GetUnitAbilityLevel(GetTriggerUnit(), SPELL_ID) * 10 + 5))
endfunction
private function Actions takes nothing returns nothing
local unit attacker = GetTriggerUnit()
if IsUnitInGroup(attacker, g) then
call SetUnitAbilityLevel(attacker, DAMAGE_ID, GetUnitAbilityLevel(attacker, DAMAGE_ID) + 1)
call SetUnitAbilityLevel(attacker, SPEED_ID, GetUnitAbilityLevel(attacker, SPEED_ID) + 1)
else
call UnitAddAbility(attacker, DAMAGE_ID)
call UnitAddAbility(attacker, SPEED_ID)
call SetUnitAbilityLevel(attacker, DAMAGE_ID, 1)
call SetUnitAbilityLevel(attacker, SPEED_ID, 1)
endif
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer index
set index = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(index), EVENT_PLAYER_UNIT_ATTACKED, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(t, Condition(function Conditions))
call TriggerAddAction(t, function Actions)
endfunction
endscope
Gives the Berseker 25% to get bonus damage and attack speed for a short period of time. Stacks 5 times.
I need a way to restart the timer when it triggers twice for the same unit? Any suggestions?