Verse Library verse

05 Setting Up Teams

Calculates hunter count, shuffles players into teams, initializes hunters, and starts the round timer.

extracted-snippets/documentation/en-us/fortnite/prop-hunt-05-game-loop-and-round-management-in-unreal-editor-for-fortnite/05-setting-up-teams.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/prop-hunt-05-game-loop-and-round-management-in-unreal-editor-for-fortnite
# Local doc:  epic-docs/documentation/en-us/fortnite/prop-hunt-05-game-loop-and-round-management-in-unreal-editor-for-fortnite.md
# Section:    Setting Up Teams
# Calculate the number of starting hunter agents for the game based on the player count and the number of hunter agents per number of players.
NumberOfPlayers:float = 1.0 * Players.Length # Converts Players.Length to a float so it can be used in the next Ceil function.
if (NumberOfStartingHunters:int = Ceil[NumberOfPlayers / Max(1.1, HunterTeam.HunterAgentPerNumberOfPlayers)]):
# Shuffle the players and then slice the array to get the starting hunter agents. The remaining players are the starting prop agents.
var RandomizedPlayers:[]agent = Shuffle(Players)
if (set StartingHunterAgents = RandomizedPlayers.Slice[0,NumberOfStartingHunters]) {}
if (set StartingPropAgents = RandomizedPlayers.Slice[NumberOfStartingHunters,RandomizedPlayers.Length]) {}
# Iterate through the starting hunter agents and assign them to the hunter team. Then start the hunter wait timer.
Logger.Print("Setting {StartingHunterAgents.Length} hunter agent(s).")
for (StartingHunterAgent : StartingHunterAgents): HunterTeam.InitializeAgent(StartingHunterAgent)
HunterTeam.WaitTimer.Start()
# Iterate through the starting prop agents and assign them to the prop team. Teleport them into the play area.
Logger.Print("Setting {StartingPropAgents.Length} prop agent(s).")

Comments

    Sign in to vote, comment, or suggest an edit. Sign in