Extending Round_Settings_Device - Verse code help

Hi fellow coders!

I’m learning Verse on the fly and drinking from a firehose. Only way to learn! I come from a strong background of Java and Python (and SAS) but am having some issues with syntax due to the functional nature of this. Yes, it’s familiar to Python but it’s not the same as far as thinking.

So, here’s what I’m trying to do. I have a round device I want to use to control the game specifics but trying to add some extra functionality to control Last Player Standing, End Round, Game, etc.

I’m essentially wanting to turn on the zone and then count players that leave (by elimination or game) by creating arrays of the teams and once they are filled I know that the team is eliminated and the inverse, I know who’s won the game. There might be a totally different or better way to go about this because my thinking is geared toward OOP. Is everything passed by value? Also, I realize many objects are immutable, so I saw a video on having to assign it to a new Array and then reassign it back.

Here is what I have so far:

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Fortnite.com/Teams }
using { /UnrealEngine.com/Temporary/Diagnostics }

# See https://dev.epicgames.com/documentation/en-us/uefn/create-your-own-device-in-verse for how to create a verse device.

# A Verse-authored creative device that can be placed in a level
round_player_counter_device := class(creative_device):
    @editable
    PlayerCountedDevice : player_counter_device = player_counter_device {}

    var Team1: []agent = array{}
    var Team2: []agent = array{}
    var Team3: []agent = array{}
    var Team4: []agent = array{}

    
    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
        # TODO: Replace this with your code
        PlayerCountedDevice.RemovedEvent.Subscribe(OnPlayerEliminated)
            
    OnPlayerEliminated(Agent:agent):void=

        if(Player := player[Agent]):
            TeamCollection := GetPlayspace().GetTeamCollection()
            if(
                PlayerTeam := TeamCollection.GetTeam[Player],
                PlayerAllies := TeamCollection.GetAgents[PlayerTeam],
                VerseTeamIndex := TeamCollection.GetTeams().Find[PlayerTeam],
                TrueTeamIndex := VerseTeamIndex + 1
            ):
                #for(Ally : PlayerAllies):
                    # DO STUFF
                if(TrueTeamIndex = 1):
                    AddPlayerToEliminatedTeam(Team1, Agent)

    #consider making a class out of eliminatedTeam with flag of eliminated
    AddPlayerToEliminatedTeam(TeamArray:[]agent, Agent:agent):void=
        TeamMemberCount := TeamArray.Length
        if( TeamMemberCount < 4 ):
           if( NewArray := TeamArray.Insert[TeamMemberCount-1, array{agent}] ):
                set TeamArray = NewArray
.
.
.
It doesn't like the set TeamArray -> The assignment's left hand expression type `[]agent` cannot be assigned to(3509)
TeamArray:[]agent

also when I hover over the Team1 being passed into my function it seems to think its not an array?

round_player_counter_device:)Team1:agent

I’m not entirely sure on what you want to do? Do you just want to count the amount of players that are on a team?

I apologize if I wasn’t clear above. There is a lot to explain. :slight_smile:

The way I’m working my map, the game rounds and winner are limited with the default Creative maps. I’m trying to extend the work with the player counter device in conjunction with the rounds settings. In the code example I’m trying to keep track of what players are left in the “zone” of the counter to find out who the winner will be. Trying to do this by creating Team arrays of the agents that get removed from the zone.

Can’t you just place a player counter with a selected team to see whether that team is still alive?

I can look into it a little bit more, but I’d like to go the code route. In this case it’s easier for what I need to do and gives me more flexibility.

This actually helps me a lot with syntax and thinking. I’m just continuing to search everywhere and hopefully find the needles in the haystack! :laughing:
Team Multiplayer Balancing | Epic Developer Community (epicgames.com)