From 24e5dc88e08ad7e1971c8978421dd80c94e641b0 Mon Sep 17 00:00:00 2001 From: Blaubeeree Date: Wed, 31 Mar 2021 20:36:58 +0200 Subject: [PATCH] Add ability to manipulate player roles --- src/gamemodes/amongus/gamemode/sv_game.moon | 22 ++++++++++++++++--- src/gamemodes/amongus/gamemode/sv_player.moon | 22 +++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/gamemodes/amongus/gamemode/sv_game.moon b/src/gamemodes/amongus/gamemode/sv_game.moon index a709102..def2390 100644 --- a/src/gamemodes/amongus/gamemode/sv_game.moon +++ b/src/gamemodes/amongus/gamemode/sv_game.moon @@ -170,11 +170,27 @@ GM.Game_Start = => -- memo[a] = 1 -- if not b.entity\IsBot! -- memo[b] = 1 - - memo[a] = memo[a] or math.random! - memo[b] = memo[b] or math.random! + if not memo[a] + if @PlayersMarkedForImposter[a.entity] + memo[a] = math.random! + 1 + elseif @PlayersMarkedForCrew[a.entity] + memo[a] = math.random! - 1 + else + memo[a] = math.random! + + if not memo[b] + if @PlayersMarkedForImposter[b.entity] + memo[b] = math.random! + 1 + elseif @PlayersMarkedForCrew[b.entity] + memo[b] = math.random! - 1 + else + memo[b] = math.random! + memo[a] > memo[b] + @PlayersMarkedForCrew = {} + @PlayersMarkedForImposter = {} + imposterCount = math.min GAMEMODE.ConVarSnapshots.ImposterCount\GetInt!, @GetImposterCount #initializedPlayers for index, ply in ipairs @GameData.PlayerTables -- Make the first N players imposters. diff --git a/src/gamemodes/amongus/gamemode/sv_player.moon b/src/gamemodes/amongus/gamemode/sv_player.moon index 2caf67f..5fcad05 100644 --- a/src/gamemodes/amongus/gamemode/sv_player.moon +++ b/src/gamemodes/amongus/gamemode/sv_player.moon @@ -384,6 +384,28 @@ GM.GetFullyInitializedPlayers = => return for ply in *player.GetAll! else continue +GM.PlayersMarkedForCrew or= {} +GM.PlayersMarkedForImposter or= {} +--- Marks a player to become crewmate next round. +-- This function doesn't overwrite the imposter count and therefor will be ignored if too many players are marked. +-- @param ply Player entity. +GM.Player_MarkCrew = (ply) => + @PlayersMarkedForCrew[ply] = true + @PlayersMarkedForImposter[ply] = false + +--- Marks a player to become crewmate next round. +-- This function doesn't overwrite the imposter count and therefor will be ignored if too many players are marked. +-- @param ply Player entity. +GM.Player_MarkImposter = (ply) => + @PlayersMarkedForCrew[ply] = false + @PlayersMarkedForImposter[ply] = true + +--- Unmarks a player +-- @param ply Player entity. +GM.Player_UnMark = (ply) => + @PlayersMarkedForCrew[ply] = false + @PlayersMarkedForImposter[ply] = false + hook.Add "PlayerInitialSpawn", "NMW AU AutoPilot", (ply) -> with GAMEMODE oldAutoPilot = \IsOnAutoPilot!