- Joined
- Nov 18, 2013
- Messages
- 21
can someone explain me why is the dummy not beeing removed?
JASS:
function Turmoil_Condition takes nothing returns boolean
return GetSpellAbilityId() == 'A003'
endfunction
function Timer takes nothing returns nothing
local timer t = GetExpiredTimer()
call DestroyTimer(t)
set t = null
endfunction
function Turmoil_Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local location p = GetSpellTargetLoc()
local group target = CreateGroup()
local unit temp = null
local real dmg = 20 + 35*GetUnitAbilityLevel(caster, 'A003')
local effect sfx = AddSpecialEffectLoc("war3mapImported\\Swashbuckler_Turmoil_Effect.MDX", p)
local timer t = CreateTimer()
local real r
local unit dummy = null
call TimerStart(t, 2., false, function Timer)
call CreateUnitAtLoc(GetOwningPlayer(caster), 'h004', p, 0.)
set dummy = bj_lastCreatedUnit
call UnitApplyTimedLife(dummy, 'BTFL', 2.)
call ShowUnit(caster, false)
loop
call GroupEnumUnitsInRangeOfLoc(target, p, 500, null)
set temp = GroupPickRandomUnit(target)
set r = TimerGetRemaining(t)
exitwhen r == 0
if (IsUnitEnemy(temp, GetOwningPlayer(caster))) and (IsUnitAliveBJ(temp)) and (not IsUnitType(temp, UNIT_TYPE_STRUCTURE)) then
call UnitDamageTarget(caster, temp, dmg, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL, null)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Orc\\Devour\\DevourEffectArt.mdl", temp, "chest"))
call PolledWait(0.2)
else
call GroupRemoveUnit(target, temp)
endif
endloop
loop
set temp = FirstOfGroup(target)
exitwhen temp == null
call GroupRemoveUnit(target, temp)
endloop
call ShowUnit(caster, true)
call SetUnitPositionLoc(caster, p)
call SelectUnitForPlayerSingle(caster, GetOwningPlayer(caster))
call PanCameraToLocForPlayer(GetOwningPlayer(caster), GetUnitLoc(caster))
call DestroyTimer(t)
call DestroyGroup(target)
call DestroyEffect(sfx)
set t=null
set sfx = null
set target = null
set temp = null
set p = null
set caster = null
set dummy = null
endfunction
function InitTrig_Turmoil takes nothing returns nothing
set gg_trg_Turmoil = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Turmoil, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_Turmoil, Condition(function Turmoil_Condition))
call TriggerAddAction(gg_trg_Turmoil, function Turmoil_Actions)
endfunction
Last edited by a moderator: