I've made an ability, which is a custom cleaving attack but works for ranged heroes too. I'm using DamageEvent for damage detection. When the effect is triggered, I get a debug message saying that there is a damage recursion and I should disable the trigger before dealing damage. However, I have done that. Here's my trigger:
Any idea why this happens?
JASS:
scope FlameBurst initializer init
globals
private constant integer ABIL_CODE = 'A03T'
private constant real AREA = 400
private trigger T
endglobals
private function True takes nothing returns boolean
return true
endfunction
private function Actions takes nothing returns boolean
local integer chance
local location targetloc
local group targetgroup
local unit u
if not ( GetUnitAbilityLevel(udg_DamageEventSource, ABIL_CODE) > 0 and udg_DamageEventPhysical) then
return false
endif
call DisableTrigger(T)
set chance = 20 + 10*GetUnitAbilityLevel(udg_DamageEventSource, ABIL_CODE)
if chance > GetRandomInt(0, 99) then
set targetloc = GetUnitLoc(udg_DamageEventTarget)
set targetgroup = GetUnitsInRangeOfLocMatching(AREA, targetloc, Filter(function True))
loop
set u = FirstOfGroup(targetgroup)
exitwhen u == null
if IsPlayerEnemy(GetOwningPlayer(u), GetOwningPlayer(udg_DamageEventSource)) and not IsUnitType(u, UNIT_TYPE_STRUCTURE) and GetUnitState(u, UNIT_STATE_LIFE) > 0 then
call UnitDamageTarget(udg_DamageEventSource, u, udg_DamageEventAmount,true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIfb\\AIfbSpecialArt.mdl", u, "origin"))
endif
call GroupRemoveUnit(targetgroup, u)
endloop
call DestroyGroup(targetgroup)
call RemoveLocation(targetloc)
set targetloc = null
set u = null
set targetgroup = null
endif
call EnableTrigger(T)
return false
endfunction
private function init takes nothing returns nothing
set T = CreateTrigger( )
call TriggerRegisterVariableEvent( T, "udg_DamageEvent", EQUAL, 1.00 )
call TriggerAddCondition( T, Condition( function Actions ) )
endfunction
endscope