• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Function Wanted: GetTotalStartLocations

Status
Not open for further replies.
Level 11
Joined
Mar 31, 2009
Messages
732
Looking for a function that will return the total number of starting locations that are placed on the map, used and unused.
Is there such a thing? Do unused player slots still keep their starting location after the map goes past the lobby?
 
Level 11
Joined
Mar 31, 2009
Messages
732
Uhh. Can you explain what mapcontrol variables are?

If a map has 8 starting locations, 5 players, and 3 obs, what would each of their mapcontrol variables be?
And what about if only 3 players were in the game? Or if the map only had 3 starting locations and observers disabled?
What would the results of GetPlayers() and the mapcontrol's be?
 
Level 13
Joined
May 11, 2008
Messages
1,198
well, when we look at the map script we get some clues. you can try eliminating start locations and place them yourself using your own code i guess...
Code:
    call DefineStartLocation( 0, 3200.0, -8064.0 )
    call DefineStartLocation( 1, 3456.0, -8064.0 )
    call DefineStartLocation( 2, -960.0, -1472.0 )
    call DefineStartLocation( 3, -1024.0, -832.0 )
    call DefineStartLocation( 4, -896.0, -320.0 )
    call DefineStartLocation( 5, -896.0, 256.0 )
    call DefineStartLocation( 6, -128.0, 192.0 )
    call DefineStartLocation( 7, 640.0, 192.0 )
    call DefineStartLocation( 8, 896.0, -192.0 )
    call DefineStartLocation( 9, 1024.0, -960.0 )
    call DefineStartLocation( 10, 3712.0, -8128.0 )
    call DefineStartLocation( 11, -256.0, -1728.0 )
this is just a sample of what's going on in a map script in my map.
there's also this stuff before that:
Code:
function InitCustomPlayerSlots takes nothing returns nothing

    // Player 0
    call SetPlayerStartLocation( Player(0), 0 )
    call ForcePlayerStartLocation( Player(0), 0 )
    call SetPlayerColor( Player(0), ConvertPlayerColor(0) )
    call SetPlayerRacePreference( Player(0), RACE_PREF_NIGHTELF )
    call SetPlayerRaceSelectable( Player(0), false )
    call SetPlayerController( Player(0), MAP_CONTROL_USER )

    // Player 1
    call SetPlayerStartLocation( Player(1), 1 )
    call ForcePlayerStartLocation( Player(1), 1 )
    call SetPlayerColor( Player(1), ConvertPlayerColor(1) )
    call SetPlayerRacePreference( Player(1), RACE_PREF_NIGHTELF )
    call SetPlayerRaceSelectable( Player(1), false )
    call SetPlayerController( Player(1), MAP_CONTROL_USER )

    // Player 2
    call SetPlayerStartLocation( Player(2), 2 )
    call ForcePlayerStartLocation( Player(2), 2 )
    call SetPlayerColor( Player(2), ConvertPlayerColor(2) )
    call SetPlayerRacePreference( Player(2), RACE_PREF_UNDEAD )
    call SetPlayerRaceSelectable( Player(2), false )
    call SetPlayerController( Player(2), MAP_CONTROL_USER )

    // Player 3
    call SetPlayerStartLocation( Player(3), 3 )
    call ForcePlayerStartLocation( Player(3), 3 )
    call SetPlayerColor( Player(3), ConvertPlayerColor(3) )
    call SetPlayerRacePreference( Player(3), RACE_PREF_UNDEAD )
    call SetPlayerRaceSelectable( Player(3), false )
    call SetPlayerController( Player(3), MAP_CONTROL_USER )
you might want to export your map script and examine it.
if you use an integer of 0 and set that integer = that integer +1 after each time you pass through the players and give them their start location then you can count thestart locations. all this is like at the bottom of the map script.
 
Uhh. Can you explain what mapcontrol variables are?

mapcontrol variables are just the controllers of players. They are defined via Scenario -> Player Properties. Any slots that are filled, whether they are a computer, user, neutral, or rescuable, must have a start location. (Or else WE will auto-generate them)

These are the mapcontrol types:
JASS:
MAP_CONTROL_COMPUTER
MAP_CONTROL_CREEP
MAP_CONTROL_NEUTRAL
MAP_CONTROL_NONE
MAP_CONTROL_RESCUABLE
MAP_CONTROL_USER

Whatever is defined in the player options will be what map control it will return via:
native GetPlayerController takes player whichPlayer returns mapcontrol

If a map has 8 starting locations, 5 players, and 3 obs, what would each of their mapcontrol variables be?
And what about if only 3 players were in the game? Or if the map only had 3 starting locations and observers disabled?
What would the results of GetPlayers() and the mapcontrol's be?

They would all return as users. However, if a player is defined as a User in the player options, it will return Computer if it is played by a computer player. Otherwise, it will return the one defined in the player options whether or not someone is playing.

For the second part, same thing. All of them will be considered users if they are defined as users in the player options and aren't being played by a computer player. :ogre_haosis:

====================

Basically, the number of player start locations will be defined with:
JASS:
function CountStartLocations takes nothing returns integer
    local integer i = 0
    local integer count = 0
    loop
        exitwhen i == 12 
        if GetPlayerController(Player(i)) != MAP_CONTROL_NONE then
            set count = count + 1
        endif
        set i = i + 1
    endloop
    return count
endfunction

Because each player defined must have a start location. With this, you are basically counting which players are either a computer, neutral, rescuable, or a user. :)
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Does it allow you to differentiate between Observers and actual players? If so then you could also include how you went about determining this for purpose of reference; it seems to me as useful knowledge regardless of whether he chooses to use your system.

Because each player defined must have a start location. With this, you are basically counting which players are either a computer, neutral, rescuable, or a user. :)

Are you certain you are able to determine which player start-locations are being occupied by Observer players, though? From the sound of it the author of this thread needs to know this, and it doesn't seem necessarily true that MAP_CONTROL_NONE would infer the player is an Observer.
 
Are you certain you are able to determine which player start-locations are being occupied by Observer players, though? From the sound of it the author of this thread needs to know this, and it doesn't seem necessarily true that MAP_CONTROL_NONE would infer the player is an Observer.

Yeah sorry, observers don't have start locs. However, you can probably just check IsPlayerObserver to suit your needs. I'm still not sure what the intent of his question is though. :p
 
Status
Not open for further replies.
Top