• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[JASS] code after endloop not functioning

Status
Not open for further replies.
Level 2
Joined
Jun 14, 2018
Messages
9
The following code is not working for some reason after endloop, what's is wrong here?

set udg_counterab = 0
call BJDebugMsg("test")
call DestroyGroup(ug)



JASS:
function aa takes nothing returns boolean
    if (IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == TRUE) then
    return TRUE
    else
    return FALSE
    endif
endfunction
function abr takes nothing returns boolean
    if (GetSpellAbilityId() == 'A015') then
    return TRUE
    else
    return FALSE
    endif
endfunction
function Trig_Arcane_Barrage_Actions takes nothing returns nothing
local integer t = R2I(udg_counterab)
local group ug = CreateGroup()
local unit caster = GetTriggerUnit()
local location loc = GetSpellTargetLoc()
local real range = 350.00
local unit temp
call SetTextTagText(udg_tt, "", 20 * 0.023 / 10)
call PolledWait(0.5)
set ug = GetUnitsInRangeOfLocMatching(range, loc, Condition(function aa))
loop
exitwhen ug == null
set temp = FirstOfGroup(ug)
if t == 1 then
    call UnitDamageTargetBJ(caster, temp, 50, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL)
elseif t == 2 then
    call UnitDamageTargetBJ(caster, temp, 100, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL)
elseif t == 3 then
    call UnitDamageTargetBJ(caster, temp, 150, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL)
elseif t == 4 then
    call UnitDamageTargetBJ(caster, temp, 200, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL)
endif
call GroupRemoveUnit(ug, temp)
endloop
set udg_counterab = 0
call BJDebugMsg("test")
call DestroyGroup(ug)
endfunction
//===========================================================================
function InitTrig_Arcane_Barrage takes nothing returns nothing
    set gg_trg_Arcane_Barrage = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Arcane_Barrage, EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddCondition( gg_trg_Arcane_Barrage, Condition(function abr))
    call TriggerAddAction( gg_trg_Arcane_Barrage, function Trig_Arcane_Barrage_Actions )
endfunction
 
Level 2
Joined
Jun 14, 2018
Messages
9
It never exits the loop (and instead threadcrashes after looping to the op limit) because you're checking if ug==null instead of it temp==null. Also the check needs to come right after assigning temp, not right before assigning it.
Thank you +rep.
 
Status
Not open for further replies.
Top