scope FanOfKnives initializer onInit
private function onFilter takes nothing returns boolean
return GetSpellAbilityId() == 'A000' //custom id of spell
endfunction
private function onCast takes nothing returns nothing
local group unitsInRangeGroup = CreateGroup()
local unit casterUnit = GetTriggerUnit()
local real x = GetUnitX(casterUnit)
local real y = GetUnitY(casterUnit)
local unit fog = null
local effect spellEffect = AddSpecialEffect("Abilities\\Spells\\NightElf\\FanOfKnives\\FanOfKnivesCaster.mdl", x, y)
// Select nearby units
call GroupEnumUnitsInRange(unitsInRangeGroup, x, y, 500, null)
// Deal damage to enemies
loop
set fog = FirstOfGroup(unitsInRangeGroup)
exitwhen fog == null
if(IsUnitEnemy(casterUnit, GetOwningPlayer(fog))) then
call UnitDamageTarget(casterUnit, fog, 300, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_ENHANCED, WEAPON_TYPE_WHOKNOWS)
endif
call GroupRemoveUnit(unitsInRangeGroup, fog)
endloop
// Cleanup
call DestroyEffect(spellEffect)
set spellEffect = null
call DestroyGroup(unitsInRangeGroup)
set unitsInRangeGroup = null
set casterUnit = null
endfunction
private function onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(t, function onCast)
call TriggerAddCondition(t, Condition(function onFilter))
set t = null
endfunction
endscope