What is the relationship between teams & devices?

I have a custom class with 2 [team_settings_and_inventory_device] editables & then in the main device code I call GetPlayspace().GetTeamCollection() … How do I determine which item in the collection relates to my device?

Sample Code ( assign 1 player to first team & then ALL other players to second team)


    AssignTeams():void={
        #randomly select 1 player at the beginning 
        AllPlayers := GetPlayspace().GetPlayers()
        PlayerIndex := GetRandomInt(0,AllPlayers.Length-1)
        if(SelectedPlayer := AllPlayers[PlayerIndex]){
            #(move player to first team & apply the class)
            
        }

        var curIndex : int = 0
        Teams := GetPlayspace().GetTeamCollection()
        for(CustomPlayer : AllPlayers){
            if(curIndex <> PlayerIndex){
                #Move ALL other player to other Team
                
            }
            set curIndex += 1
        }
    }

So the GetTeamCollection() does not return a team_settings_and_inventory_device device, it’s a pure Verse class that allows you to access team related functions.

If you want a specific team (let’s say team 1), you’ll do :

if(TeamOne := GetPlayspace().GetTeamCollection().GetTeams()[0]):
    # TeamOne is a instance of the class 'team'

TeamOne can then be used in other functions that require any team type variable. I’m not sure what you’re trying to do exactly so I might need more intel on the best solution to provide here :person_shrugging:

1 Like

As denoted in my sample code, I want to assign 1 random player to a specific team on game start… as said player eliminates others, they are then also moved to that team (an infection style game).

If the team_settings_and_inventory_device is not the route I should take then I am lost. I need to be able to know the team a player is on and then move said player to another team. I don’t think assuming team 1 (team index 0) is a good idea, but maybe that is how I should approach this.

Thoughts?

Additionally, I need to add custom code to events from team_settings_and_inventory_device

Sorry for not reading your comments properly, if you want to do an infection game, you could just use the following Island Settings ?
image

“Teams” / “Spawn Limit” / “After Last Spawn Go To”

Then in you Team settings and inventory for team 2, override the spawn limit and set it to 0? or 999?

1 Like

Well, I really do need to read up on existing device functionality :sweat_smile:

Even so, if those weren’t settings I had available, within Verse, how would I associate a Team object to a device? … or maybe that isn’t even a reasonable idea… I really don’t know yet. Regardless, thanks for the continued support. I’ll keep digging & learning.

So, I think I’d do :

@editable
TeamOneSettingsDevice : team_settings_and_inventory_device  = team_settings_and_inventory_device {}

@editable
TeamTwoSettingsDevice : team_settings_and_inventory_device  = team_settings_and_inventory_device {}

or maybe :

@editable
TeamsSettingsDevice : []team_settings_and_inventory_device  = array{}

And then use the array index to compare to the player’s team index, but I’m not sure you’re looking for this answer either ?

Ok, I figured out how to force a team to use the indexes… but in verse, when a player respawns, I need to check their team and call specific code…

                #Check Team... use Infected Or Human 
                AllTeams := GetPlayspace().GetTeamCollection()
                if(AssignedTeam := AllTeams.GetTeam[Agent]){
                    #Infected Team is index 2 (or 1 if it is zero based ???)
                    *if player is on Infected team then custom code here.*
                }

I think I got it…

AllTeams := GetPlayspace().GetTeamCollection()
                if(AssignedTeam := AllTeams.GetTeam[Agent], 
                    TargetTeam := AllTeams.GetTeams()[1],
                    AssignedTeam = TargetTeam
                ){ custom code here }

Does that look legit?

1 Like

This is exactly what you should do :+1:

Ok, I am certainly progressing and I am trying to move forward… I have my code in a fresh project ( I was in a test project where I have a bunch of other test code ).

When my map starts, it is only finding 1 team when I call GetPlayspace().GetTeamCollection().GetTeams().Length even though I have 2 team designers created.

So, my previous code is no longer working as index 1 does not exist…

AllTeams := GetPlayspace().GetTeamCollection()
                if(AssignedTeam := AllTeams.GetTeam[Agent], 
                    TargetTeam := AllTeams.GetTeams()[1] <-- Fails

Team 1 is default & Team 2 (red) is the team I am targeting in the above code.

What am I missing?

Even though you can define any team settings with the team settings and inventory device, the count of existing team is defined by your IslandSettings, by both those parameters :
image

In my exemple it’s FFA so I guess there’s like 100 available teams, but if you choose Team Index, you can choose the number of teams with the number on the right.

  1. Get the team of the player who eliminating.
  2. Transfer the player who eliminated
    image
    to the player’s team

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.