Argh ! Different integer value returned by CountPlayersInForceBJ()?

Vassilev

New Member
Reaction score
39
After countless frustrating retries i've given up on finding why my trigger returns a different integer value


JASS:

function TotalPlayers takes nothing returns boolean
return GetPlayerSlotState(GetFilterPlayer()) == PLAYER_SLOT_STATE_PLAYING and  GetPlayerController(GetFilterPlayer()) == MAP_CONTROL_USER
endfunction

function Trig_First_Wave_Actions takes nothing returns nothing
local boolexpr b = Condition ( function TotalPlayers )
local integer randomatkloc
local integer noofunits
local integer noofwaves
local integer noofplayers
local real waittime
local unit u
local real x
local real y
local force f = CreateForce()
set noofwaves = 3
loop
    exitwhen noofwaves < 1
    call ForceEnumPlayers( f, b)
    set noofplayers = CountPlayersInForceBJ(f)
    call BJDebugMsg("Number of players detected: " + I2S(noofplayers))
    set randomatkloc = GetRandomInt( 1, 5)
    set noofunits = ( GetRandomInt(8, 11) * noofplayers ) + 7
    set waittime = I2R(noofunits)
if randomatkloc == 1 then
    call DisplayTimedTextToForce( f, 15, "|cffff0000Warning|r ! The Enemy is approaching from the |cffffcc00West|r !")
elseif randomatkloc == 2 then
    call DisplayTimedTextToForce( f, 15, "|cffff0000Warning|r ! The Enemy is approaching from the |cffffcc00South West|r !")
elseif randomatkloc == 3 then
    call DisplayTimedTextToForce( f, 15, "|cffff0000Warning|r ! The Enemy is approaching from the |cffffcc00South|r !")
elseif randomatkloc == 4 then
    call DisplayTimedTextToForce( f, 15, "|cffff0000Warning|r ! The Enemy is approaching from the |cffffcc00South East|r !")
elseif randomatkloc == 5 then
    call DisplayTimedTextToForce( f, 15, "|cffff0000Warning|r ! The Enemy is approaching from the |cffffcc00East|r !")
endif
loop
    exitwhen noofunits < 1
        set x = GetRandomReal( GetRectMinX( udg_SpawnLocation1[randomatkloc]), GetRectMaxX(  udg_SpawnLocation1[randomatkloc]) )
        set y = GetRandomReal( GetRectMinY( udg_SpawnLocation1[randomatkloc]), GetRectMaxY(  udg_SpawnLocation1[randomatkloc]) )
        set u = CreateUnit( Player(11), udg_Crabby[GetRandomInt(1, 20)], x , y , bj_UNIT_FACING) 
        call IssuePointOrder( u, "attack", GetRectCenterX(gg_rct_Orc_Gate), GetRectCenterY(gg_rct_Orc_Gate))
        set noofunits = noofunits - 1
        call TriggerSleepAction( GetRandomReal( 0.50 , 1))
endloop
    call TriggerSleepAction(1 * waittime)
    set noofwaves = noofwaves - 1
endloop
call DestroyBoolExpr(b)
set b = null
set randomatkloc = 0
set noofunits = 0
set noofwaves = 0
set noofplayers = 0
set u = null
call DestroyForce(f)
set f = null
call TriggerSleepAction( GetRandomReal( 30, 60) )
set udg_LevelCounter = udg_LevelCounter + 1
endfunction

//===========================================================================
function InitTrig_First_Wave takes nothing returns nothing
    set gg_trg_First_Wave = CreateTrigger(  )
    call TriggerRegisterVariableEvent( gg_trg_First_Wave, "udg_LevelCounter", EQUAL, 1.00 )
    call TriggerAddAction( gg_trg_First_Wave, function Trig_First_Wave_Actions )
endfunction



the first noofwaves loop, the debug message correctly returns 1 player playing i.e, me.
the second loop, the debug message returns 5 players?! (me and 4 other computers ?)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top