Fix role assign problems and some strings

This commit is contained in:
Ape committed 2026-02-21 16:42:22 +01:00
1 parent e53acde70a
commit c4b6e5709f
5 files changed
+71 -56

No files matched your search

+1 -1
View File
@@ -42,7 +42,7 @@ public partial class Main : BasePlugin
public static bool HasArgumentException;
public static string CredentialsText;
public const string ModVersion = "v1.5.3";
public const string ModVersion = "v1.6.0";
public static float GameTimer;
+1
View File
@@ -199,6 +199,7 @@ public static class Utils
NormalGameEndChecker.ImpCheckComplete = false;
CreateOptionsPickerPatch.SetDleks2 = false;
CanCallMeetings = true;
PlayerControlSetRolePatch.FirstAssign = true;
}
public static PlayerControl[] AllAlivePlayerControls
+1 -17
View File
@@ -11,7 +11,7 @@ internal static class CoShowIntroPatch
{
public static void Postfix(IntroCutscene __instance)
{
Logger.Info("Intro initiated", "CoShowIntro");
Logger.Info(" Intro initiated", "CoShowIntro");
if (!AmongUsClient.Instance.AmHost) return;
@@ -26,12 +26,6 @@ internal static class CoShowIntroPatch
{ "Mayor", Translator.Get("MayorPriv")}
});
if (Main.GM.Value)
{
PlayerControl.LocalPlayer.RpcSetRole(AmongUs.GameOptions.RoleTypes.CrewmateGhost, false);
PlayerControl.LocalPlayer.myTasks.Clear();
}
if (Options.DisableAnnoyingMeetingCalls.GetBool())
{
Utils.CanCallMeetings = false;
@@ -40,16 +34,6 @@ internal static class CoShowIntroPatch
Utils.CanCallMeetings = true;
}, 33f, "MeetingEnabled");
}
if (!Utils.isHideNSeek) return;
foreach (var p in PlayerControl.AllPlayerControls)
{
if (p.Data.Role.TeamType == RoleTeamTypes.Impostor)
{
p.RpcSetRole(AmongUs.GameOptions.RoleTypes.Impostor, false);
}
}
}
}
+66 -36
View File
@@ -1,4 +1,5 @@
using System;
using AmongUs.GameOptions;
using System;
using InnerNet;
using UnityEngine;
@@ -12,53 +13,82 @@ internal class CoStartGamePatch
if (!AmongUsClient.Instance.AmHost) return;
Logger.Info(" -------- GAME STARTED --------", "StartGame");
Logger.Info($" Gamemode: {Options.Gamemode.GetValue()}", "StartGame");
NormalGameEndChecker.imps.Clear();
NormalGameEndChecker.LastWinReason = "";
if (Options.Gamemode.GetValue() == 3 && !Utils.isHideNSeek)
}
}
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.RpcSetRole))]
class PlayerControlSetRolePatch
{
private static int i;
public static bool FirstAssign;
private static HashSet<byte> Seekers = new();
private static readonly System.Random rand = new System.Random();
public static bool Prefix(PlayerControl __instance, ref RoleTypes roleType, ref bool canOverrideRole)
{
if (!FirstAssign || !AmongUsClient.Instance.AmHost) return true;
canOverrideRole = false;
if (Main.GM.Value && __instance == PlayerControl.LocalPlayer)
{
roleType = RoleTypes.CrewmateGhost;
}
if (Utils.isHideNSeek && i == 0)
{
int seekersCount = Options.NumSeekers.GetInt();
var candidates = new List<PlayerControl>();
foreach (var p in PlayerControl.AllPlayerControls)
{
if (p != PlayerControl.LocalPlayer)
{
p.RpcSetRole(AmongUs.GameOptions.RoleTypes.Crewmate, false);
}
if (p == PlayerControl.LocalPlayer)
{
p.CoSetRole(AmongUs.GameOptions.RoleTypes.Crewmate, false);
}
if (Main.GM.Value && p != PlayerControl.LocalPlayer) candidates.Add(p);
}
seekersCount = Math.Min(seekersCount, candidates.Count);
for (int j = candidates.Count - 1; j > 0; j--)
{
int k = rand.Next(j + 1);
(candidates[j], candidates[k]) = (candidates[k], candidates[j]);
}
for (int j = 0; j < seekersCount; j++)
{
Seekers.Add(candidates[j].PlayerId);
}
}
if (Utils.isHideNSeek)
{
int seekersCount = Options.NumSeekers.GetInt();
int toAdd = Math.Max(0, seekersCount - 1);
var candidates = new List<PlayerControl>();
foreach (var p in PlayerControl.AllPlayerControls)
{
if (p.Data.Role.TeamType != RoleTeamTypes.Impostor && !p.Data.IsDead)
candidates.Add(p);
}
toAdd = Math.Min(toAdd, candidates.Count);
System.Random rand = new System.Random();
for (int i = candidates.Count - 1; i > 0; i--)
{
int j = rand.Next(i + 1);
(candidates[i], candidates[j]) = (candidates[j], candidates[i]);
}
for (int i = 0; i < toAdd; i++)
{
var player = candidates[i];
player.RpcSetRole(AmongUs.GameOptions.RoleTypes.Impostor, false);
}
if (Seekers.Contains(__instance.PlayerId)) roleType = RoleTypes.Impostor;
else roleType = RoleTypes.Crewmate;
}
if (Options.Gamemode.GetValue() == 3 && !Utils.isHideNSeek)
{
if (__instance == PlayerControl.LocalPlayer && Main.GM.Value)
{
PlayerControl.LocalPlayer.myTasks.Clear();
return true;
}
roleType = RoleTypes.Crewmate;
}
i++;
if (i >= PlayerControl.AllPlayerControls.Count)
{
Seekers.Clear();
FirstAssign = false;
i = 0;
Logger.Info("PCSRP successful", ".");
}
return true;
}
}
+2 -2
View File
@@ -68,7 +68,7 @@
"tabGroupGameplayGeneral": "General",
"disableAnnoyingMeetingCalls": "Disable Meeting Calls First 30s",
"disableReport": "Disable Body Reports",
"changeDecontaminationTime": "Override Decontamination Time",
"changeDecontaminationTime": "Override Decontamination Time (Standard Only)",
"decontaminationTimeOnMiraHQ": "Mira HQ Decon Duration",
"decontaminationDoorOpenTimeOnMiraHQ": "Mira HQ Door Open Duration",
"decontaminationTimeOnPolus": "Polus Decon Duration",
@@ -194,7 +194,7 @@
"allCommandsFull": "Commands:\n/r - Current mode description\n/0kc, /sns, /sp - Specific mode description\n/l - Shows last winner info\n/kick, /ban - Bans or kicks a player by name\n/ckick, /cban - Bans or kicks a player by color",
"allCommandsOne": "Commands:\n/r - Current mode description\n/0kc, /sns, /sp - Specific mode description\n/l - Shows last winner info",
"allCommandsTwo": "/kick, /ban - Bans or kicks a player by name\n/ckick, /cban - Bans or kicks a player by color",
"SocialsAll": "AUR socials:\n\ng i t h u b . c o m /\nApeMV/AmongUsRevamped\n\nd i s c o r d . g g /\n83Zhzhyhya",
"socialsAll": "AUR socials:\n\ng i t h u b . c o m /\nApeMV/AmongUsRevamped\n\nd i s c o r d . g g /\n83Zhzhyhya",
"Mayor": "Mayor",
"MayorPriv": "PRIVATE:\n\nYour role is Mayor!\n\nYou are a crewmate with i total votes. Use your voting power to eject Impostors.",