Skip to content

Commit

Permalink
Add ability to manipulate player roles
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaubeeree authored and NotMyWing committed Apr 1, 2021
1 parent 49a3d33 commit 24e5dc8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/gamemodes/amongus/gamemode/sv_game.moon
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 22 additions & 0 deletions src/gamemodes/amongus/gamemode/sv_player.moon
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down

0 comments on commit 24e5dc8

Please sign in to comment.