scope CExplosion initializer init
globals
private constant hashtable hash = InitHashtable()
private constant integer AB_ID = 'A000' // RAW ID of the Ability
private constant string FX = "Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl" // FX of the explosion
private constant boolean ALLOW_STRUCTURE = TRUE // Are structures allowed
private constant boolean ALLOW_FLYING = TRUE // Are flying units allowed
private constant real DAMAGE = 5 // Damage dealt
private constant real AOE = 150 // AoE of each explosion
private unit a = GetTriggerUnit()
endglobals
private function CE_Cond takes nothing returns boolean
return GetSpellAbilityId() == AB_ID
endfunction
private function CE_Filter takes nothing returns boolean
return TRUE
endfunction
private function CE_Damage takes nothing returns nothing
if IsUnitEnemy(GetEnumUnit(), GetOwningPlayer(a)) then
call UnitDamageTarget(a, GetEnumUnit(), DAMAGE, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
endif
endfunction
private function CE_Boom takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer i = LoadInteger(hash, GetHandleId(t), 1)
local unit u = LoadUnitHandle(hash, GetHandleId(t), 2)
local real ang = GetRandomReal(0, 360)
local real o = GetRandomReal(0, 380)
local real x = LoadReal(hash, GetHandleId(t), 3) + o * Cos(ang * bj_DEGTORAD)
local real y = LoadReal(hash, GetHandleId(t), 4) + o * Sin(ang * bj_DEGTORAD)
local unit fog = null
if i < 200 then
call DestroyEffect(AddSpecialEffect(FX, x, y))
call SaveInteger(hash, GetHandleId(t), 1, i + 1)
call ForGroup(LoadGroupHandle(hash, GetHandleId(t), 5), function CE_Damage)
call GroupEnumUnitsInRange(LoadGroupHandle(hash, GetHandleId(t), 5), LoadReal(hash, GetHandleId(t), 3), LoadReal(hash, GetHandleId(t), 4), 420, Filter(function CE_Filter))
elseif i == 200 then
call PauseTimer(t)
call DestroyGroup(LoadGroupHandle(hash, GetHandleId(t), 5))
call FlushChildHashtable(hash, GetHandleId(t))
call DestroyTimer(t)
endif
set t = null
set u = null
endfunction
private function CE_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local group g = CreateGroup()
local real x = GetSpellTargetX()
local real y = GetSpellTargetY()
local integer i = 0
local timer t = CreateTimer()
set a = GetTriggerUnit()
call GroupEnumUnitsInRange(g, x, y, 420, Filter(function CE_Filter))
call SaveGroupHandle(hash, GetHandleId(t), 5, g)
call SaveInteger(hash, GetHandleId(t), 1, i)
call SaveReal(hash, GetHandleId(t), 3, x)
call SaveReal(hash, GetHandleId(t), 4, y)
call SaveUnitHandle(hash, GetHandleId(t), 2, u)
call TimerStart(t, 0.02, true, function CE_Boom)
set t = 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 CE_Cond))
call TriggerAddAction(t, function CE_Actions)
set t = null
endfunction
endscope