Name | Type | is_array | initial_value |
globals
hashtable comboSystemSkills = InitHashtable()
hashtable comboSystemIndexer = InitHashtable()
endglobals
function ComboSystemConfigActions takes nothing returns nothing
// Configuring the spell, in this example you have baseSpell (Q) -> comboSpell (Q) -> womboSpell (Q)
// Save the spell ID in integer vars, better in order like base -> next -> next -> n..., base --> next --> next
local integer baseSpell = 'A000'
local integer comboSpell = 'A001'
local integer womboSpell = 'A002'
// DO THIS FOR EVERY THREE SPELL COMBO //
// 1. Save the spell ID for baseSpell -> comboSpell
call SaveInteger(comboSystemSkills, baseSpell, StringHash("comboSpell"), comboSpell)
// 2. Save the spell EXPIRATION TIME for baseSpell -> comboSpell
call SaveReal(comboSystemSkills, baseSpell, StringHash("expirationTime"), 3.00)
// 3. Save the spell ID for comboSpell -> womboSpell
call SaveInteger(comboSystemSkills, comboSpell, StringHash("comboSpell"), womboSpell)
// 4. Save the spell EXPIRATION TIME for comboSpell -> womboSpell
call SaveReal(comboSystemSkills, comboSpell, StringHash("expirationTime"), 1.00)
endfunction
//===========================================================================
function InitTrig_ComboSystem_Config takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEventSingle(t, 0.00)
call TriggerAddAction(t, function ComboSystemConfigActions)
endfunction
function ComboSystemHandler takes nothing returns nothing
// USE: On timer expiration, remove the combo/wombo spell
// Get the expired timer
local timer t = GetExpiredTimer()
// Get the caster unit through timer ID
local unit caster = LoadUnitHandle(comboSystemIndexer, GetHandleId(t), StringHash("caster"))
// Get the combo/wombo spell ID
local integer comboSpell = LoadInteger(comboSystemIndexer, GetHandleId(t), StringHash("comboSpell"))
// Remove the spell
call UnitRemoveAbility(caster, comboSpell)
// 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 ComboSystemActions takes nothing returns nothing
// USE: create a timer to every unit that cast a spell that have combo/wombo
// Get the caster unit
local unit caster = GetSpellAbilityUnit()
// Get the casted spell
local integer baseSpell = GetSpellAbilityId()
// Later will save the expiration time of the combo / wombo spell
local real expirationTime
// Create a timer
local timer t
// Get the combo/wombo spell that correspond to the cast spell
local integer comboSpell = LoadInteger(comboSystemSkills, baseSpell, StringHash("comboSpell"))
// Check if combo/wombo spell ID is greather than zero (have combo spell)
if (comboSpell != 0) then
// Initialize the timer
set t = CreateTimer()
// Save expiration time
set expirationTime = LoadReal(comboSystemSkills, baseSpell, StringHash("expirationTime"))
// Save to hashtable the unit that cast the spell
call SaveUnitHandle(comboSystemIndexer, GetHandleId(t), StringHash("caster"), caster)
// Save the combo/wombo spell ID
call SaveInteger(comboSystemIndexer, GetHandleId(t), StringHash("comboSpell"), comboSpell)
// Add new spell to caster
call UnitAddAbility(caster, comboSpell)
// Start the timer
call TimerStart(t, expirationTime, false, function ComboSystemHandler)
else
return
endif
// Avoid leaks
set caster = null
set t = null
endfunction
function InitTrig_ComboSystem_Cast takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
call TriggerAddAction(t, function ComboSystemActions)
// 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