[vJASS] Force

Status
Not open for further replies.
Level 10
Joined
May 28, 2011
Messages
455
How can i get a force set in player properties?

I use GetEnumAllies but there is a logic error which is player(0) is inside his force and another force. The player(0) should be only inside his force not inside the other one.

here is the code.

JASS:
globals
    force Players = CreateForce()
    integer Players_Count = 0
        
    force Players_Light = CreateForce()
    integer Players_Light_Count = 0
    force Players_Light_Playing = CreateForce()
        
    force Players_Dark = CreateForce()
    integer Players_Dark_Count = 0
    force Players_Dark_Playing = CreateForce()
endglobals

scope SetupPlayers initializer Init
//----------------------------------------------------------------
    private function Pick takes nothing returns boolean
        return GetPlayerController(GetFilterPlayer()) == MAP_CONTROL_USER 
    endfunction
    
//----------------------------------------------------------------
    private function Pick1 takes nothing returns boolean
        return GetPlayerSlotState(GetFilterPlayer()) == PLAYER_SLOT_STATE_PLAYING
    endfunction
   
//----------------------------------------------------------------
    private function SetupPlayers takes nothing returns nothing
        call SetPlayerState( GetEnumPlayer(), PLAYER_STATE_RESOURCE_GOLD, 700 )
        set Players_Count = Players_Count + 1
    endfunction
    
//----------------------------------------------------------------
    private function CountLightPlayers takes nothing returns nothing
        set Players_Light_Count = Players_Light_Count + 1
    endfunction
    
//----------------------------------------------------------------
    private function CountDarkPlayers takes nothing returns nothing
        set Players_Dark_Count = Players_Dark_Count + 1
    endfunction
    
//---------------------------------------------------------------- 
    private function Init takes nothing returns nothing
        local boolexpr b = Condition(function Pick)
        local boolexpr b1 = Condition(function Pick1)
        
        call ForceEnumPlayers(Players, b)
        call ForForce(Players, function SetupPlayers)
        
        //Light
        call ForceEnumAllies(Players_Light, Player(0), null)
        call ForForce(Players_Light, function CountLightPlayers)
        call ForceEnumPlayers(Players_Light, b1)
        
        //Dark
        call ForceEnumAllies(Players_Dark, Player(5), null)
        call ForForce(Players_Dark, function CountDarkPlayers)
        call ForceEnumPlayers(Players_Dark, b1)
        
        call DestroyBoolExpr(b)
        call DestroyBoolExpr(b1)
    endfunction
endscope

Btw, if there is a leak. Please advice me. Thank you so much ^^
 
It seems to me that all user controlled players will be in all forces.

If Players meant to gather players for separating them in the two other forces
then u should remove player from Player force and than add it to Dark or Light force one by one and then destroy force

JASS:
call ForceEnumPlayers(Players_Light, b1)
call ForceEnumPlayers(Players_Dark, b1)

Won't these will reset the forces and add all players in those again?
 
Last edited:
Status
Not open for further replies.
Back
Top