- Joined
- Oct 11, 2012
- Messages
- 711
The following trigger works most of the time, but sometimes it does not fire. I can't figure out why... please help
I have tried to replace GroupClear with DestroyGroup, the result is the same. The spell is based on channel and it is an AOE spell, if that matters. "lichking1" and "lichking2" are global variables.
JASS:
function lichking1_actions takes nothing returns nothing
local group g=CreateGroup()
local real x=GetSpellTargetX()
local real y=GetSpellTargetY()
local unit u
local integer level=GetUnitAbilityLevel(gg_unit_U00X_0001,'A421')*5
local real level1=I2R(level)*0.01
local real life
if GetSpellAbilityId() == 'A421' then
call BJDebugMsg("start")
//call GroupEnumUnitsInRange(g,x,y,800.,null)
call GroupEnumUnitsInRange(g,x,y,800.,Condition(function Group_TrgU_Filter))
//set lichking1=CreateGroup()
call GroupAddGroup(g,lichking1)
loop
set u=FirstOfGroup(g)
exitwhen u==null
call GroupRemoveUnit(g,u)
call SetUnitInvulnerable(u,false)
set life=GetUnitState(u,UNIT_STATE_LIFE)
call SetUnitState(u, UNIT_STATE_LIFE, life-life*level1)
//set lichking2=CreateGroup()
call GroupAddGroup(lichking1,lichking2)
call GroupRemoveUnit(lichking2,u)
call BJDebugMsg("add group")
if GetRandomInt(1,100)<=level then
call IssueTargetOrder(u,"attack",GroupPickRandomUnit(lichking2))
call BJDebugMsg("attack")
endif
call GroupClear(lichking2)
endloop
call GroupClear(lichking1)
call DestroyGroup(g)
endif
set g=null
//return false
endfunction
function InitTrig_lichking1 takes nothing returns nothing
set gg_trg_lichking1=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( gg_trg_lichking1, EVENT_PLAYER_UNIT_SPELL_EFFECT )
//call TriggerAddCondition(gg_trg_lichking1, Condition(function lichking1_actions))
call TriggerAddAction(gg_trg_lichking1,function lichking1_actions)
endfunction
I have tried to replace GroupClear with DestroyGroup, the result is the same. The spell is based on channel and it is an AOE spell, if that matters. "lichking1" and "lichking2" are global variables.