- Joined
- Oct 11, 2012
- Messages
- 711
I am trying to make a spell, its like an AOE life drain, the spell has two triggers. The first trigger is used for selecting a group of enemy units and use dummies to cast magic leash on them. The second trigger is used for causing damage every 0.2 second to the group of units that are effected by the leash.
My problem is that my spell sometimes works and sometimes not.... I really cannot fix it. I just know that the first trigger sometimes fails to select the group (I used the IsUnitGroupEmptyBJ to detect it)..Please help, here are the triggersI know that my spell is inefficient and may have MUI issue, but please ignore that for the purpose of this thread, thank you)
The first trigger:
The second trigger:
My problem is that my spell sometimes works and sometimes not.... I really cannot fix it. I just know that the first trigger sometimes fails to select the group (I used the IsUnitGroupEmptyBJ to detect it)..Please help, here are the triggersI know that my spell is inefficient and may have MUI issue, but please ignore that for the purpose of this thread, thank you)
The first trigger:
JASS:
function Trig_ChainConditions takes nothing returns boolean
return ((GetSpellAbilityId() == 'A405'))
endfunction
function Trig_ChainFunc001005 takes nothing returns boolean
return IsUnitEnemy(GetEnumUnit(), GetOwningPlayer(GetTriggerUnit()))
endfunction
function Trig_Chain1 takes nothing returns nothing
local timer t = GetExpiredTimer()
call DisableTrigger(gg_trg_chaindamage)
call PauseTimer(t)
call DestroyTimer(t)
set t = null
endfunction
function Trig_ChainActions takes nothing returns nothing
local timer t = CreateTimer()
local integer p = GetPlayerId(GetTriggerPlayer())
local location stloc = GetSpellTargetLoc()
local real x = GetLocationX(stloc)
local real y = GetLocationY(stloc)
local unit dummy
local unit u
local group g = CreateGroup()
call GroupEnumUnitsInRange( g, GetLocationX(stloc), GetLocationY(stloc), 700.00, Condition(function Trig_ChainFunc001005) )
set u = FirstOfGroup(g)
loop
exitwhen u == null
set u = FirstOfGroup(g)
set dummy = CreateUnit(Player(p),'h02X',x,y,bj_UNIT_FACING)
call ShowUnit(dummy,false)
call UnitApplyTimedLife( dummy, 'BHwe', 3.20 )
call IssueTargetOrder( dummy, "magicleash", u )
call GroupAddUnit(udg_leashgroup,u)
call GroupRemoveUnit(g,u)
endloop
call EnableTrigger(gg_trg_chaindamage)
call TimerStart(t,3.00,false,function Trig_Chain1)
call RemoveLocation(stloc)
set stloc = null
set t = null
set dummy = null
set g = null
endfunction
//===========================================================================
function InitTrig_Chain takes nothing returns nothing
set gg_trg_Chain = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( gg_trg_Chain, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition(gg_trg_Chain, Condition(function Trig_ChainConditions))
call TriggerAddAction(gg_trg_Chain, function Trig_ChainActions)
endfunction
The second trigger:
JASS:
function Trig_chaindamageActions takes nothing returns nothing
local integer p = GetPlayerId(GetTriggerPlayer())
local unit u
set u = FirstOfGroup(udg_leashgroup)
loop
exitwhen u == null
if IsUnitEnemy(u,Player(p)) then
call UnitDamageTarget( gg_unit_Hblm_0002, u, 100.00, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_DEMOLITION, WEAPON_TYPE_WHOKNOWS )
call GroupRemoveUnit(udg_leashgroup,u)
endif
endloop
endfunction
//===========================================================================
function InitTrig_chaindamage takes nothing returns nothing
set gg_trg_chaindamage = CreateTrigger()
call DisableTrigger(gg_trg_chaindamage)
call TriggerRegisterTimerEventPeriodic( gg_trg_chaindamage, 0.20 )
call TriggerAddAction(gg_trg_chaindamage, function Trig_chaindamageActions)
endfunction