A little JASS help, please

trb92

Throwing science at the wall to see what sticks
Reaction score
142
This trigger is in my map, but it doesn't work properly.
JASS:
function NextLevel_Filter takes nothing returns boolean
    return ( GetOwningPlayer(GetFilterUnit()) == Player(11) and GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE) <= 0)
endfunction

function Trig_NextLevel_Conditions takes nothing returns boolean
    local group g = CreateGroup()
    local integer i = 0
    local unit u
    call BJDebugMsg("Next Level Condition Runs")
    call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea,Condition(function NextLevel_Filter))
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        set i = i + 1
        call GroupRemoveUnit(g,u)
    endloop
    call BJDebugMsg("There are " +I2S(i) + " units")
    call DestroyGroup(g)
    set g = null
    set u = null
    return ( i < 1)
endfunction

function Trig_NextLevel_Actions takes nothing returns nothing
    call BJDebugMsg("Next Level Runs")
    call TimerStart(SpawnTimer,30,false,null)
    call DestroyTimerDialog(TD)
    set TD = CreateTimerDialog(SpawnTimer)
    call TimerDialogSetTitle(TD,"Level " + I2S(Level) + " starts in: ")
    call TimerDialogDisplay(TD,true)
endfunction

//===========================================================================
function InitTrig_NextLevel takes nothing returns nothing
    set gg_trg_NextLevel = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEvent( gg_trg_NextLevel, Player(11), EVENT_PLAYER_UNIT_DEATH,null )
    call TriggerAddCondition( gg_trg_NextLevel, Condition( function Trig_NextLevel_Conditions ) )
    call TriggerAddAction( gg_trg_NextLevel, function Trig_NextLevel_Actions )
endfunction

What it should do is run the actions when there are no living units owned by Brown. However, what it does do is checks conditions, both BJDebugMsg's show, but the actions never run. I can't figure out why, when I test this the units are clearly dead and this looks like it should work.

Thanks for any help I might get.
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
Try out
JASS:
if i == 0 then
return true
endif
return false


instead of "return i < 1"
 

trb92

Throwing science at the wall to see what sticks
Reaction score
142
That won't fix the problem, I've already tried it. Though I forgot something in my first post, I'll explain now.
JASS:
call BJDebugMsg(&quot;There are &quot; +I2S(i) + &quot; units&quot;)

This line shows the number of units like it should, but it includes the dead ones. I think the Filter must be the problem, but it looks fine to me.
 

trb92

Throwing science at the wall to see what sticks
Reaction score
142
Well... Figures that it's something like that. That's what I get for trying to see if units are alive by copying the IsUnitDeadBJ's code... Yeah, works now, thanks.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top