Name | Type | is_array | initial_value |
globals
hashtable STASSkills = InitHashtable()
hashtable STASIndexer = InitHashtable()
integer BASE_SPELL = 'A000'
integer UP_SPELL = 'A001'
integer UP_FOR_UP_SPELL = 'A002'
real UP_SPELL_ET = 3.00
real UP_FOR_UP_SPELL_ET = 1.00
endglobals
function STASConfigActions takes nothing returns nothing
// Configuring the spell, in this example you have BASE_SPELL (Q) -> UP_SPELL (Q) -> UP_FOR_UP_SPELL (Q)
// Save the spell ID in integer vars, better in order like base -> next -> next -> n..., base --> next --> next
// SAMPLE FOR base -> next -> next
// 1. Save the spell ID for BASE_SPELL -> NEXT_SPELL
call SaveInteger(STASSkills, BASE_SPELL, StringHash("NEXT_SPELL"), UP_SPELL)
// 2. Save the spell EXPIRATION TIME for BASE_SPELL -> NEXT_SPELL
call SaveReal(STASSkills, BASE_SPELL, StringHash("EXPIRATION_TIME"), UP_SPELL_ET)
// 3. Save the spell ID for UP_SPELL -> UP_FOR_UP_SPELL
call SaveInteger(STASSkills, UP_SPELL, StringHash("NEXT_SPELL"), UP_FOR_UP_SPELL)
// 4. Save the spell EXPIRATION TIME for TEMP_SPELL_ONE -> TEMP_SPELL_TWO
call SaveReal(STASSkills, UP_SPELL, StringHash("EXPIRATION_TIME"), UP_FOR_UP_SPELL_ET)
endfunction
//===========================================================================
function InitTrig_STAS_Config takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEventSingle(t, 0.00)
call TriggerAddAction(t, function STASConfigActions)
endfunction
function STASHandler takes nothing returns nothing
// USE: On timer expiration, remove the next_spell
// Get the expired timer
local timer t = GetExpiredTimer()
// Get the caster unit through timer ID
local unit caster = LoadUnitHandle(STASIndexer, GetHandleId(t), StringHash("CASTER"))
// Get the next_spell spell ID
local integer NEXT_SPELL = LoadInteger(STASIndexer, GetHandleId(t), StringHash("NEXT_SPELL"))
// Remove the spell
call UnitRemoveAbility(caster, NEXT_SPELL)
// For avoid bugs of timer, pause it
call PauseTimer(t)
// Destroy the timer
call DestroyTimer(t)
// Remove leak
set t = null
set caster = null
endfunction
function STASActions takes nothing returns nothing
// USE: create a timer to every unit that cast a spell that have next_spell
// Get the caster unit
local unit caster = GetSpellAbilityUnit()
// Get the casted spell
local integer CASTED_SPELL = GetSpellAbilityId()
// Later will save the expiration time of the combo / wombo spell
local real expirationTime
// Create a timer
local timer t
// Get the next_spell spell that correspond to the cast spell
local integer NEXT_SPELL = LoadInteger(STASSkills, CASTED_SPELL, StringHash("NEXT_SPELL"))
// Check if next_spell spell ID is greather than zero (have combo spell)
if (NEXT_SPELL != 0) then
// Initialize the timer
set t = CreateTimer()
// Save expiration time
set expirationTime = LoadReal(STASSkills, CASTED_SPELL, StringHash("EXPIRATION_TIME"))
// Save to hashtable the unit that cast the spell
call SaveUnitHandle(STASIndexer, GetHandleId(t), StringHash("CASTER"), caster)
// Save the next_spell spell ID
call SaveInteger(STASIndexer, GetHandleId(t), StringHash("NEXT_SPELL"), NEXT_SPELL)
// Add new spell to caster
call UnitAddAbility(caster, NEXT_SPELL)
// Start the timer
call TimerStart(t, expirationTime, false, function STASHandler)
else
return
endif
// Avoid leaks
set caster = null
set t = null
endfunction
function InitTrig_STAS_Cast takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
call TriggerAddAction(t, function STASActions)
// Set all players
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set i = i + 1
exitwhen i == bj_MAX_PLAYERS
endloop
endfunction