I made this trigger to when i cast a spell, a dummy is spawned and some other dummies will cast Life Drain on units near.
But only one dummy cast Life Drain.
I can't see where is the error. x.x
Quick Question
1. What GroupClear do? Empty the group? The same as DestroyGroup?
Thanks in advance. =]
But only one dummy cast Life Drain.
JASS:
scope SuckingLight initializer Initial
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == 039;A002039;
endfunction
private function TargetConditions takes nothing returns boolean
return IsUnitEnemy( GetFilterUnit(), GetOwningPlayer( GetTriggerUnit() ) ) == true and GetUnitState( GetFilterUnit(), UNIT_STATE_LIFE ) > 0
endfunction
private function Light takes nothing returns nothing
local unit Caster = GetTriggerUnit()
local unit Dummy = CreateUnitAtLoc( GetOwningPlayer( Caster ), 039;u002039;, GetSpellTargetLoc(), 0.0 )
call UnitApplyTimedLife( Dummy, 039;BTLF039;, 20.0 )
call UnitAddAbility( Dummy, 039;A003039; )
call SetUnitAbilityLevel( Dummy, 039;A003039;, GetUnitAbilityLevel( Caster, 039;A002039; ) )
call IssueTargetOrder( Dummy, "drain", GetEnumUnit() )
set Caster = null
set Dummy = null
endfunction
private function Actions takes nothing returns nothing
local unit Caster = GetTriggerUnit()
local unit Dummy = CreateUnitAtLoc( GetOwningPlayer( Caster ), 039;u000039;, GetSpellTargetLoc(), 0.0 )
local group UnitsNear = GetUnitsInRangeOfLocMatching( 800, GetUnitLoc( Dummy ), Condition( function TargetConditions ) )
call SetUnitColor( Dummy, PLAYER_COLOR_YELLOW )
if CountUnitsInGroup( UnitsNear ) == 0 then
call KillUnit( Dummy )
else
call UnitApplyTimedLife( Dummy, 039;BFTL039;, 20.0 )
call ForGroup( UnitsNear, function Light )
endif
call DestroyGroup( UnitsNear )
set Caster = null
set Dummy = null
set UnitsNear = null
endfunction
private function Initial takes nothing returns nothing
local trigger trig = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( trig, Condition( function Conditions ) )
call TriggerAddAction( trig, function Actions )
set trig = null
endfunction
endscope
I can't see where is the error. x.x
Quick Question
1. What GroupClear do? Empty the group? The same as DestroyGroup?
Thanks in advance. =]