Skip to content

Commit 24e5dc8

Browse files
BlaubeereeNotMyWing
authored andcommitted
Add ability to manipulate player roles
1 parent 49a3d33 commit 24e5dc8

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

src/gamemodes/amongus/gamemode/sv_game.moon

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,27 @@ GM.Game_Start = =>
170170
-- memo[a] = 1
171171
-- if not b.entity\IsBot!
172172
-- memo[b] = 1
173-
174-
memo[a] = memo[a] or math.random!
175-
memo[b] = memo[b] or math.random!
173+
if not memo[a]
174+
if @PlayersMarkedForImposter[a.entity]
175+
memo[a] = math.random! + 1
176+
elseif @PlayersMarkedForCrew[a.entity]
177+
memo[a] = math.random! - 1
178+
else
179+
memo[a] = math.random!
180+
181+
if not memo[b]
182+
if @PlayersMarkedForImposter[b.entity]
183+
memo[b] = math.random! + 1
184+
elseif @PlayersMarkedForCrew[b.entity]
185+
memo[b] = math.random! - 1
186+
else
187+
memo[b] = math.random!
188+
176189
memo[a] > memo[b]
177190

191+
@PlayersMarkedForCrew = {}
192+
@PlayersMarkedForImposter = {}
193+
178194
imposterCount = math.min GAMEMODE.ConVarSnapshots.ImposterCount\GetInt!, @GetImposterCount #initializedPlayers
179195
for index, ply in ipairs @GameData.PlayerTables
180196
-- Make the first N players imposters.

src/gamemodes/amongus/gamemode/sv_player.moon

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,28 @@ GM.GetFullyInitializedPlayers = => return for ply in *player.GetAll!
384384
else
385385
continue
386386

387+
GM.PlayersMarkedForCrew or= {}
388+
GM.PlayersMarkedForImposter or= {}
389+
--- Marks a player to become crewmate next round.
390+
-- This function doesn't overwrite the imposter count and therefor will be ignored if too many players are marked.
391+
-- @param ply Player entity.
392+
GM.Player_MarkCrew = (ply) =>
393+
@PlayersMarkedForCrew[ply] = true
394+
@PlayersMarkedForImposter[ply] = false
395+
396+
--- Marks a player to become crewmate next round.
397+
-- This function doesn't overwrite the imposter count and therefor will be ignored if too many players are marked.
398+
-- @param ply Player entity.
399+
GM.Player_MarkImposter = (ply) =>
400+
@PlayersMarkedForCrew[ply] = false
401+
@PlayersMarkedForImposter[ply] = true
402+
403+
--- Unmarks a player
404+
-- @param ply Player entity.
405+
GM.Player_UnMark = (ply) =>
406+
@PlayersMarkedForCrew[ply] = false
407+
@PlayersMarkedForImposter[ply] = false
408+
387409
hook.Add "PlayerInitialSpawn", "NMW AU AutoPilot", (ply) -> with GAMEMODE
388410
oldAutoPilot = \IsOnAutoPilot!
389411

0 commit comments

Comments
 (0)