Merge pull request #29 from D1GQ/dev

v1.1.2
This commit is contained in:
D1GQ authored and GitHub committed 2024-08-31 20:47:59 -05:00
commit 13bb6eec1e
21 files changed
+315 -220

No files matched your search

+70 -53
View File
@@ -60,43 +60,43 @@ class AntiCheat
[HarmonyPostfix]
public static void Deserialize_Postfix(PlatformSpecificData __instance)
{
if (!Main.AntiCheat.Value) return;
if (!Main.AntiCheat.Value || !GameStates.IsVanillaServer) return;
if (GameStates.IsLobby)
{
_ = new LateTask(() =>
{
var player = Main.AllPlayerControls.FirstOrDefault(pc => pc.GetClient().PlatformData == __instance);
if (player != null)
{
var player = Main.AllPlayerControls.FirstOrDefault(pc => pc.GetClient().PlatformData == __instance);
if (player != null)
if (__instance.Platform is Platforms.StandaloneWin10 or Platforms.Xbox)
{
if (__instance.Platform is Platforms.StandaloneWin10 or Platforms.Xbox)
if (__instance.XboxPlatformId.ToString().Length is < 10 or > 16)
{
if (__instance.XboxPlatformId.ToString().Length is < 10 or > 16)
{
player.ReportPlayer(ReportReasons.Cheating_Hacking);
BetterNotificationManager.NotifyCheat(player, $"Platform Spoofer", newText: "Has been detected with a cheat");
Logger.LogCheat($"{player.BetterData().RealName} Platform Spoofer: {__instance.XboxPlatformId}");
}
}
if (__instance.Platform is Platforms.Playstation)
{
if (__instance.PsnPlatformId.ToString().Length is < 14 or > 20)
{
player.ReportPlayer(ReportReasons.Cheating_Hacking);
BetterNotificationManager.NotifyCheat(player, $"Platform Spoofer", newText: "Has been detected with a cheat");
Logger.LogCheat($"{player.BetterData().RealName} Platform Spoofer: {__instance.PsnPlatformId}");
}
player.ReportPlayer(ReportReasons.Cheating_Hacking);
BetterNotificationManager.NotifyCheat(player, $"Platform Spoofer", newText: "Has been detected with a cheat");
Logger.LogCheat($"{player.BetterData().RealName} Platform Spoofer: {__instance.XboxPlatformId}");
}
}
}, 3.5f, shoudLog: false);
if (__instance.Platform is Platforms.Playstation)
{
if (__instance.PsnPlatformId.ToString().Length is < 14 or > 20)
{
player.ReportPlayer(ReportReasons.Cheating_Hacking);
BetterNotificationManager.NotifyCheat(player, $"Platform Spoofer", newText: "Has been detected with a cheat");
Logger.LogCheat($"{player.BetterData().RealName} Platform Spoofer: {__instance.PsnPlatformId}");
}
}
}
}, 3.5f, shoudLog: false);
}
}
}
// Handle RPC before anti cheat detection
public static void HandleRPCBeforeCheck(PlayerControl player, byte callId, MessageReader Oldreader)
public static void HandleCheatRPCBeforeCheck(PlayerControl player, byte callId, MessageReader Oldreader)
{
MessageReader reader = MessageReader.Get(Oldreader);
@@ -276,21 +276,21 @@ class AntiCheat
var taskId = reader.ReadPackedUInt32();
if (player.IsImpostorTeam() || !player.Data.Tasks.ToArray().Any(task => task.Id == taskId)
|| player.BetterData().LastTaskId == taskId || player.BetterData().LastTaskId != taskId
&& player.BetterData().TimeSinceLastTask < 1.25f)
|| player.BetterData().AntiCheatInfo.LastTaskId == taskId || player.BetterData().AntiCheatInfo.LastTaskId != taskId
&& player.BetterData().AntiCheatInfo.TimeSinceLastTask < 1.25f)
{
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName((RpcCalls)callId)}: {player.IsImpostorTeam()} || {!player.Data.Tasks.ToArray().Any(task => task.Id == taskId)} ||" +
$" {player.BetterData().LastTaskId == taskId} || {player.BetterData().LastTaskId != taskId} && {player.BetterData().TimeSinceLastTask < 1.25f}");
$" {player.BetterData().AntiCheatInfo.LastTaskId == taskId} || {player.BetterData().AntiCheatInfo.LastTaskId != taskId} && {player.BetterData().AntiCheatInfo.TimeSinceLastTask < 1.25f}");
player.BetterData().TimeSinceLastTask = 0f;
player.BetterData().LastTaskId = taskId;
player.BetterData().AntiCheatInfo.TimeSinceLastTask = 0f;
player.BetterData().AntiCheatInfo.LastTaskId = taskId;
return;
}
player.BetterData().TimeSinceLastTask = 0f;
player.BetterData().LastTaskId = taskId;
player.BetterData().AntiCheatInfo.TimeSinceLastTask = 0f;
player.BetterData().AntiCheatInfo.LastTaskId = taskId;
}
if (callId is (byte)RpcCalls.CloseDoorsOfType)
@@ -333,29 +333,29 @@ class AntiCheat
// Set fixing status
if (Utils.SystemTypeIsSabotage(systemType))
{
if (amount == openPanelNum && !player.BetterData().IsFixingPanelSabotage)
if (amount == openPanelNum && !player.BetterData().AntiCheatInfo.IsFixingPanelSabotage)
{
player.BetterData().OpenSabotageNum = 1;
player.BetterData().AntiCheatInfo.OpenSabotageNum = 1;
}
else if (amount == openPanelNum + 1 && !player.BetterData().IsFixingPanelSabotage)
else if (amount == openPanelNum + 1 && !player.BetterData().AntiCheatInfo.IsFixingPanelSabotage)
{
player.BetterData().OpenSabotageNum = 2;
player.BetterData().AntiCheatInfo.OpenSabotageNum = 2;
}
if (amount == closePanelNum && player.BetterData().OpenSabotageNum == 1)
if (amount == closePanelNum && player.BetterData().AntiCheatInfo.OpenSabotageNum == 1)
{
player.BetterData().OpenSabotageNum = 0;
player.BetterData().AntiCheatInfo.OpenSabotageNum = 0;
}
else if (amount == closePanelNum + 1 && player.BetterData().OpenSabotageNum == 2)
else if (amount == closePanelNum + 1 && player.BetterData().AntiCheatInfo.OpenSabotageNum == 2)
{
player.BetterData().OpenSabotageNum = 0;
player.BetterData().AntiCheatInfo.OpenSabotageNum = 0;
}
}
if (!GameStates.IsHost || PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.BetterData().IsBetterHost || !IsEnabled || !Main.AntiCheat.Value
|| (GameStates.IsBetterHostLobby && !GameStates.IsHost) || !BetterGameSettings.DetectInvalidRPCs.GetBool()) return true;
if (!BetterGameSettings.ExperimentalDetectInvalidSabotage.GetBool())
if (!BetterGameSettings.CancelInvalidSabotage.GetBool())
return true;
// Single Fix: 0
@@ -371,11 +371,14 @@ class AntiCheat
{
SystemTypes SaboType = (SystemTypes)amount;
if (!player.IsImpostorTeam() || GameStates.IsAnySabotageActive() || !Utils.SystemTypeIsSabotage(SaboType))
if (!player.IsImpostorTeam() || GameStates.IsAnySabotageActive() || !Utils.SystemTypeIsSabotage(SaboType)
|| GameStates.SkeldIsActive && ShipStatus.Instance.AllDoors.Any(door => !door.IsOpen))
{
/*
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName(SaboType)}");
Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName(SaboType)}: {!player.IsImpostorTeam()} || {GameStates.IsAnySabotageActive()} " +
$"|| {!Utils.SystemTypeIsSabotage(SaboType)}");
*/
return false;
}
}
@@ -385,8 +388,10 @@ class AntiCheat
{
if (amount == hostNum && !player.IsHost())
{
/*
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName(systemType)}");
Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName(systemType)}: {amount == hostNum} && {!player.IsHost()}");
*/
return false;
}
@@ -394,35 +399,43 @@ class AntiCheat
{
if (systemType is SystemTypes.Electrical)
{
/*
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName(systemType)}");
Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName(systemType)}: {systemType is SystemTypes.Electrical}");
*/
}
return false;
}
if (player.BetterData().IsFixingPanelSabotage)
if (player.BetterData().AntiCheatInfo.IsFixingPanelSabotage)
{
if (player.BetterData().OpenSabotageNum == 0)
if (player.BetterData().AntiCheatInfo.OpenSabotageNum == 0)
{
/*
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName(systemType)}");
Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName(systemType)}: {player.BetterData().OpenSabotageNum == 0}");
Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName(systemType)}: {player.BetterData().AntiCheatInfo.OpenSabotageNum == 0}");
*/
return false;
}
if (amount == openPanelNum && amount == openPanelNum + 1)
{
/*
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName(systemType)}");
Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName(systemType)}: {amount == openPanelNum} && {amount == openPanelNum + 1}");
*/
return false;
}
if (player.BetterData().OpenSabotageNum == 1 && amount == openPanelNum + 1
|| player.BetterData().OpenSabotageNum == 2 && amount == openPanelNum)
if (player.BetterData().AntiCheatInfo.OpenSabotageNum == 1 && amount == openPanelNum + 1
|| player.BetterData().AntiCheatInfo.OpenSabotageNum == 2 && amount == openPanelNum)
{
/*
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName(systemType)}");
Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName(systemType)}: {player.BetterData().OpenSabotageNum == 1} && {amount == openPanelNum + 1} " +
$"|| {player.BetterData().OpenSabotageNum == 2} && {amount == openPanelNum}");
Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName(systemType)}: {player.BetterData().AntiCheatInfo.OpenSabotageNum == 1} && {amount == openPanelNum + 1} " +
$"|| {player.BetterData().AntiCheatInfo.OpenSabotageNum == 2} && {amount == openPanelNum}");
*/
return false;
}
}
@@ -432,10 +445,12 @@ class AntiCheat
&& amount != closePanelNum && amount != closePanelNum + 1
&& amount > MaxLightNum)
{
/*
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName(systemType)}");
Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName(systemType)}: {amount != fixNum} && {amount != fixNum + 1}" +
$" && {amount != closePanelNum} && {amount != closePanelNum + 1}" +
$" && {amount > MaxLightNum}");
*/
return false;
}
@@ -443,8 +458,10 @@ class AntiCheat
{
if (amount > MaxLightNum)
{
/*
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName(systemType)}");
Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName(systemType)}: {amount > MaxLightNum}");
*/
return false;
}
}
@@ -474,12 +491,12 @@ class AntiCheat
{
if (target == PlayerControl.LocalPlayer)
{
target.BetterData().TimesAttemptedKilled++;
target.BetterData().AntiCheatInfo.TimesAttemptedKilled++;
if (target.BetterData().TimesAttemptedKilled >= 5 && !target.IsAlive())
if (target.BetterData().AntiCheatInfo.TimesAttemptedKilled >= 5 && !target.IsAlive())
{
BetterNotificationManager.NotifyCheat(player, $"Invalid Action: Attempted To Ban Exploit");
Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName((RpcCalls)callId)} 2: {target.BetterData().TimesAttemptedKilled >= 5} && {!target.IsAlive()}");
Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName((RpcCalls)callId)} 2: {target.BetterData().AntiCheatInfo.TimesAttemptedKilled >= 5} && {!target.IsAlive()}");
return false;
}
@@ -545,11 +562,11 @@ class AntiCheat
}
else
{
if (player.BetterData().TimesCalledMeeting >= GameOptionsManager.Instance.currentNormalGameOptions.NumEmergencyMeetings)
if (player.BetterData().AntiCheatInfo.TimesCalledMeeting >= GameOptionsManager.Instance.currentNormalGameOptions.NumEmergencyMeetings)
{
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName((RpcCalls)callId)}: {player.BetterData().TimesCalledMeeting} -> {GameOptionsManager.Instance.currentNormalGameOptions.NumEmergencyMeetings}" +
$" - {player.BetterData().TimesCalledMeeting >= GameOptionsManager.Instance.currentNormalGameOptions.NumEmergencyMeetings}");
Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName((RpcCalls)callId)}: {player.BetterData().AntiCheatInfo.TimesCalledMeeting} -> {GameOptionsManager.Instance.currentNormalGameOptions.NumEmergencyMeetings}" +
$" - {player.BetterData().AntiCheatInfo.TimesCalledMeeting >= GameOptionsManager.Instance.currentNormalGameOptions.NumEmergencyMeetings}");
if (GameStates.IsHost)
{
return false;
+5
View File
@@ -104,6 +104,11 @@ public class ClientOptionItem
passiveButton.OnClick.AddListener(new Action(() =>
{
if (toggleCheck() == false)
{
return;
}
additionalOnClickAction?.Invoke();
}));
+2 -1
View File
@@ -7,7 +7,7 @@ namespace BetterAmongUs;
public class DebugMenu : MonoBehaviour
{
public static bool RevealRoles = false;
#if DEBUG
[HideFromIl2Cpp]
public DragWindow Window { get; }
@@ -237,4 +237,5 @@ public class DebugMenu : MonoBehaviour
WindowEnabled = !WindowEnabled;
}
#endif
}
+3
View File
@@ -14,6 +14,7 @@ class Logger
public static void LogHeader(string info, string tag = "LogHeader") => Log($" >-------------- {info} --------------<", tag);
public static void LogCheat(string info, string tag = "AntiCheat") => Log(info, tag);
public static void Error(string info, string tag = "Error") => Log(info, tag);
public static void Error(Exception ex, string tag = "Error") => Log(ex.ToString(), tag);
public static void Test()
{
Log("------------------> TEST <------------------", "TEST");
@@ -31,11 +32,13 @@ class Logger
public static void LogPrivate(string info, string tag = "Log")
{
#if DEBUG
if (GameStates.IsDev)
{
Log(info, tag);
return;
}
#endif
string mark = $"{DateTime.Now:HH:mm} [BetterLog][PrivateLog][{tag}]";
string logFilePath = Path.Combine(BetterDataManager.filePathFolder, "better-log.txt");
+41 -2
View File
@@ -125,7 +125,45 @@ static class ExtendedPlayerControl
AmongUsClient.Instance.KickPlayer(player.GetClientId(), ban);
player.BetterData().BannedByAntiCheat = AntiCheatBan;
player.BetterData().AntiCheatInfo.BannedByAntiCheat = AntiCheatBan;
}
public static void SetOutline(this PlayerControl player, bool active, Color? color = null)
{
player.cosmetics.currentBodySprite.BodySprite.material.SetFloat("_Outline", (float)(active ? 1 : 0));
SpriteRenderer[] longModeParts = player.cosmetics.currentBodySprite.LongModeParts;
for (int i = 0; i < longModeParts.Length; i++)
{
longModeParts[i].material.SetFloat("_Outline", (float)(active ? 1 : 0));
}
if (color != null)
{
player.cosmetics.currentBodySprite.BodySprite.material.SetColor("_OutlineColor", color.Value);
longModeParts = player.cosmetics.currentBodySprite.LongModeParts;
for (int i = 0; i < longModeParts.Length; i++)
{
longModeParts[i].material.SetColor("_OutlineColor", color.Value);
}
}
}
public static void SetOutlineByHex(this PlayerControl player, bool active, string hexColor = "")
{
Color color = Utils.HexToColor32(hexColor);
player.cosmetics.currentBodySprite.BodySprite.material.SetFloat("_Outline", (float)(active ? 1 : 0));
SpriteRenderer[] longModeParts = player.cosmetics.currentBodySprite.LongModeParts;
for (int i = 0; i < longModeParts.Length; i++)
{
longModeParts[i].material.SetFloat("_Outline", (float)(active ? 1 : 0));
}
if (color != null)
{
player.cosmetics.currentBodySprite.BodySprite.material.SetColor("_OutlineColor", color);
longModeParts = player.cosmetics.currentBodySprite.LongModeParts;
for (int i = 0; i < longModeParts.Length; i++)
{
longModeParts[i].material.SetColor("_OutlineColor", color);
}
}
}
// RPCs
@@ -134,6 +172,7 @@ static class ExtendedPlayerControl
if (player == null || target == null) return;
RPC.SetNamePrivate(player, name, target);
}
public static void RpcExile(this PlayerControl player)
{
if (player == null) return;
@@ -228,7 +267,7 @@ static class ExtendedPlayerControl
// Report player
public static void ReportPlayer(this PlayerControl player, ReportReasons reason = ReportReasons.None)
{
if (player != null)
if (player?.GetClient() != null)
{
if (!player.GetClient().HasBeenReported)
{
+31 -17
View File
@@ -6,6 +6,7 @@ namespace BetterAmongUs;
public static class PlayerControlDataExtension
{
// Base
public class ExtendedPlayerInfo
{
public NetworkedPlayerInfo? _Data { get; set; }
@@ -14,17 +15,22 @@ public static class PlayerControlDataExtension
public bool IsBetterUser { get; set; } = false;
public bool IsBetterHost { get; set; } = false;
public bool IsTOHEHost { get; set; } = false;
public bool BannedByAntiCheat { get; set; } = false;
public int TimesAttemptedKilled { get; set; } = 0;
// Track Game Info
public int OpenSabotageNum { get; set; } = 0;
public bool IsFixingPanelSabotage => OpenSabotageNum != 0;
public float TimeSinceLastTask { get; set; } = 5f;
public uint LastTaskId { get; set; } = 999;
public int TimesCalledMeeting { get; set; } = 0;
public DisconnectReasons DisconnectReason { get; set; } = DisconnectReasons.Unknown;
public ExtendedRoleInfo? RoleInfo { get; set; }
public ExtendedAntiCheatInfo? AntiCheatInfo { get; set; }
}
public class ExtendedAntiCheatInfo
{
public bool BannedByAntiCheat { get; set; } = false;
public int TimesAttemptedKilled { get; set; } = 0;
public int OpenSabotageNum { get; set; } = 0;
public bool IsFixingPanelSabotage => OpenSabotageNum != 0;
public int TimesCalledMeeting { get; set; } = 0;
public float TimeSinceLastTask { get; set; } = 5f;
public uint LastTaskId { get; set; } = 999;
}
public class ExtendedRoleInfo
@@ -36,24 +42,29 @@ public static class PlayerControlDataExtension
public static readonly Dictionary<string, ExtendedPlayerInfo> playerInfo = [];
public static void ClearData(this ExtendedPlayerInfo BetterData) => playerInfo[BetterData._Data.Puid] = new ExtendedPlayerInfo();
public static void ClearData(this ExtendedPlayerInfo BetterData) => playerInfo[BetterData._Data.Puid] = new ExtendedPlayerInfo
{
_Data = BetterData._Data,
RoleInfo = new ExtendedRoleInfo(),
AntiCheatInfo = new ExtendedAntiCheatInfo()
};
// Reset info when needed
public static void ResetPlayerData(PlayerControl player)
{
if (GameStates.IsLobby)
{
player.BetterData().TimesCalledMeeting = 0;
player.BetterData().AntiCheatInfo.TimesCalledMeeting = 0;
player.BetterData().RoleInfo.HasNoisemakerNotify = false;
player.BetterData().TimeSinceLastTask = 5f;
player.BetterData().LastTaskId = 999;
player.BetterData().AntiCheatInfo.TimeSinceLastTask = 5f;
player.BetterData().AntiCheatInfo.LastTaskId = 999;
player.BetterData().RoleInfo.Kills = 0;
player.BetterData().OpenSabotageNum = 0;
player.BetterData().TimesAttemptedKilled = 0;
player.BetterData().AntiCheatInfo.OpenSabotageNum = 0;
player.BetterData().AntiCheatInfo.TimesAttemptedKilled = 0;
}
else
{
player.BetterData().TimeSinceLastTask += Time.deltaTime;
player.BetterData().AntiCheatInfo.TimeSinceLastTask += Time.deltaTime;
if (player.IsAlive() || player.Data.RoleType == RoleTypes.GuardianAngel)
player.BetterData().RoleInfo.DeadDisplayRole = player.Data.RoleType;
@@ -75,7 +86,8 @@ public static class PlayerControlDataExtension
playerInfo[player.Data.Puid] = new ExtendedPlayerInfo
{
_Data = player.Data,
RoleInfo = new ExtendedRoleInfo()
RoleInfo = new ExtendedRoleInfo(),
AntiCheatInfo = new ExtendedAntiCheatInfo()
};
}
@@ -90,7 +102,8 @@ public static class PlayerControlDataExtension
playerInfo[info.Puid] = new ExtendedPlayerInfo
{
_Data = info,
RoleInfo = new ExtendedRoleInfo()
RoleInfo = new ExtendedRoleInfo(),
AntiCheatInfo = new ExtendedAntiCheatInfo()
};
}
@@ -110,7 +123,8 @@ public static class PlayerControlDataExtension
{
_Data = player.Data,
RealName = player.Data.PlayerName,
RoleInfo = new ExtendedRoleInfo()
RoleInfo = new ExtendedRoleInfo(),
AntiCheatInfo = new ExtendedAntiCheatInfo()
};
}
+4
View File
@@ -19,10 +19,12 @@ class FileChecker
// Set up if unauthorized files have been found.
public static void UpdateUnauthorizedFiles()
{
#if DEBUG
if (GameStates.IsDev)
{
HasTrySpoofFriendCode = false;
}
#endif
if (Enabled == false) return;
@@ -136,11 +138,13 @@ class FileChecker
}
}
#if DEBUG
if (GameStates.IsDev)
{
Enabled = false;
return false;
}
#endif
// Check for Banned BepInEx Mods
foreach (var bannedMod in BannedBepInExMods)
+1 -1
View File
@@ -25,7 +25,7 @@ internal class PlayerControlRPCHandlerPatch
{
public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] byte callId, [HarmonyArgument(1)] MessageReader reader)
{
AntiCheat.HandleRPCBeforeCheck(__instance, callId, reader);
AntiCheat.HandleCheatRPCBeforeCheck(__instance, callId, reader);
if (AntiCheat.CheckCancelRPC(__instance, callId, reader) != true)
{
+15
View File
@@ -147,6 +147,21 @@ public static class Utils
}
}
public static string Color32ToHex(Color32 color) => $"#{color.r:X2}{color.g:X2}{color.b:X2}{255:X2}";
public static Color HexToColor32(string hex)
{
if (hex.StartsWith("#"))
{
hex = hex.Substring(1);
}
byte r = byte.Parse(hex.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
byte g = byte.Parse(hex.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
byte b = byte.Parse(hex.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
return new Color32(r, g, b, 255);
}
// Disconnect client
public static void DisconnectSelf(string reason, bool showReason = true)
{
-23
View File
@@ -7,29 +7,6 @@ namespace BetterAmongUs.Patches;
[HarmonyPatch(typeof(ChatNotification))]
public class ChatNotificationPatch
{
[HarmonyPatch(nameof(ChatNotification.Awake))]
[HarmonyPostfix]
public static void Awake_Postfix(ChatNotification __instance)
{
if (__instance.gameObject.name == "ChatNotification" && BetterNotificationManager.BAUNotificationManagerObj == null)
{
GameObject ChatNotifications = __instance.gameObject;
if (ChatNotifications != null)
{
GameObject BAUNotification = UnityEngine.Object.Instantiate(ChatNotifications);
BAUNotification.name = "BAUNotification";
UnityEngine.Object.Destroy(BAUNotification.GetComponent<ChatNotification>());
UnityEngine.Object.Destroy(GameObject.Find($"{BAUNotification.name}/Sizer/PoolablePlayer"));
UnityEngine.Object.Destroy(GameObject.Find($"{BAUNotification.name}/Sizer/ColorText"));
BAUNotification.GetComponent<AspectPosition>().DistanceFromEdge = new Vector3(-1.57f, 5.3f, -15f);
GameObject.Find($"{BAUNotification.name}/Sizer/NameText").transform.localPosition = new Vector3(-3.3192f, -0.0105f);
GameObject.Find($"{BAUNotification.name}/Sizer/NameText").GetComponent<TextMeshPro>().text = "<color=#00ff44>System Notification</color>";
UnityEngine.Object.DontDestroyOnLoad(BAUNotification);
BetterNotificationManager.BAUNotificationManagerObj = BAUNotification;
BAUNotification.SetActive(false);
}
}
}
[HarmonyPatch(nameof(ChatNotification.Update))]
[HarmonyPostfix]
public static void Update_Postfix(ChatNotification __instance)
+5 -1
View File
@@ -1,4 +1,5 @@
using AmongUs.Data;
using AmongUs.GameOptions;
using Assets.CoreScripts;
using HarmonyLib;
using Hazel;
@@ -197,7 +198,10 @@ class ChatPatch
}
}
sbTag.Append(Role);
if (PlayerControl.LocalPlayer.Is(RoleTypes.GuardianAngel) && !sourcePlayer.IsAlive() || !PlayerControl.LocalPlayer.Is(RoleTypes.GuardianAngel))
{
sbTag.Append(Role);
}
sbInfo.Append("<size=75%>");
for (int i = 0; i < sbTag.ToString().Split("+++").Length; i++)
+23 -12
View File
@@ -8,15 +8,16 @@ namespace BetterAmongUs.Patches;
[HarmonyPatch(typeof(OptionsMenuBehaviour))]
public static class OptionsMenuBehaviourPatch
{
private static ClientOptionItem AntiCheat;
private static ClientOptionItem BetterHost;
private static ClientOptionItem BetterNotifications;
private static ClientOptionItem ChatInGameplay;
private static ClientOptionItem LobbyPlayerInfo;
private static ClientOptionItem DisableLobbyTheme;
private static ClientOptionItem UnlockFPS;
private static ClientOptionItem ShowFPS;
private static ClientOptionItem OpenSaveData;
private static ClientOptionItem? AntiCheat;
private static ClientOptionItem? BetterHost;
private static ClientOptionItem? BetterNotifications;
private static ClientOptionItem? ChatInGameplay;
private static ClientOptionItem? LobbyPlayerInfo;
private static ClientOptionItem? DisableLobbyTheme;
private static ClientOptionItem? UnlockFPS;
private static ClientOptionItem? ShowFPS;
private static ClientOptionItem? OpenSaveData;
private static ClientOptionItem? SwitchToVanilla;
[HarmonyPatch(nameof(OptionsMenuBehaviour.Start))]
[HarmonyPrefix]
@@ -26,7 +27,7 @@ public static class OptionsMenuBehaviourPatch
{
bool flag = GameStates.IsInGame && !GameStates.IsLobby || GameStates.IsFreePlay;
if (flag)
BetterNotificationManager.Notify($"Unable to toggle {buttonName} while in gameplay!", 2.5f);
BetterNotificationManager.Notify($"Unable to toggle '{buttonName}' while in gameplay!", 2.5f);
return flag;
}
@@ -34,7 +35,7 @@ public static class OptionsMenuBehaviourPatch
{
bool flag = GameStates.IsInGame;
if (flag)
BetterNotificationManager.Notify($"Unable to toggle {buttonName} while in game!", 2.5f);
BetterNotificationManager.Notify($"Unable to toggle '{buttonName}' while in game!", 2.5f);
return flag;
}
@@ -112,7 +113,7 @@ public static class OptionsMenuBehaviourPatch
if (OpenSaveData == null || OpenSaveData.ToggleButton == null)
{
DisableLobbyTheme = ClientOptionItem.Create("Open Save Data", null, __instance, OpenSaveDataButtonToggle, IsToggle: false);
OpenSaveData = ClientOptionItem.Create("Open Save Data", null, __instance, OpenSaveDataButtonToggle, IsToggle: false);
static void OpenSaveDataButtonToggle()
{
if (File.Exists(BetterDataManager.GetFilePath("BetterData")))
@@ -126,6 +127,16 @@ public static class OptionsMenuBehaviourPatch
}
}
}
if (SwitchToVanilla == null || SwitchToVanilla.ToggleButton == null)
{
SwitchToVanilla = ClientOptionItem.Create("Switch To Vanilla", null, __instance, SwitchToVanillaButtonToggle, IsToggle: false, toggleCheck: () => !toggleCheckInGame("Switch To Vanilla"));
static void SwitchToVanillaButtonToggle()
{
UnityEngine.Object.Destroy(BetterNotificationManager.BAUNotificationManagerObj);
Harmony.UnpatchAll();
}
}
}
[HarmonyPatch(nameof(OptionsMenuBehaviour.Close))]
+6 -9
View File
@@ -36,6 +36,7 @@ class CommandsPatch
};
public static string[] DebugCommandListHelper =
{
#if DEBUG
"getposition---Get current player position - <color=#ff00f7>DeBug</color>",
"role {role}---Set your role for the next game - <color=red>Host Only</color> - <color=#ff00f7>DeBug</color>",
"setrole {id} {role}---Set another players role for the next game - <color=red>Host Only</color> - <color=#ff00f7>DeBug</color>",
@@ -43,7 +44,8 @@ class CommandsPatch
"suicide---Kill self <color=#ff00f7>DeBug</color>",
"exile---Set self as dead <color=#ff00f7>DeBug</color>",
"revive---Set self as alive<color=#ff00f7>DeBug</color>",
};
#endif
};
// Run code for specific commands
@@ -244,14 +246,7 @@ class CommandsPatch
{
if (subArgs == "")
{
foreach (PlayerControl player in Main.AllPlayerControls)
{
player.RpcExile();
player.roleAssigned = false;
player.RpcSetRole(RoleTypes.CrewmateGhost, true);
}
GameManager.Instance.RpcEndGame(GameOverReason.ImpostorByKill, false);
return;
GameManager.Instance.RpcEndGame(GameOverReason.ImpostorDisconnect, false);
}
else if (subArgs is "impostor" or "1")
{
@@ -292,6 +287,7 @@ class CommandsPatch
break;
}
#if DEBUG
// DeBug Commands
if (checkDebugCommand)
{
@@ -430,6 +426,7 @@ class CommandsPatch
break;
}
}
#endif
cmdTarget = null;
}
+7 -15
View File
@@ -79,23 +79,9 @@ class GamePlayManager
{
try
{
static Color HexToColor(string hex)
{
if (hex.StartsWith("#"))
{
hex = hex.Substring(1);
}
byte r = byte.Parse(hex.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
byte g = byte.Parse(hex.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
byte b = byte.Parse(hex.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
return new Color32(r, g, b, 255);
}
_ = new LateTask(() =>
{
Color RoleColor = HexToColor(Utils.GetRoleColor(PlayerControl.LocalPlayer.Data.RoleType));
Color RoleColor = Utils.HexToColor32(Utils.GetRoleColor(PlayerControl.LocalPlayer.Data.RoleType));
__instance.ImpostorText.gameObject.SetActive(false);
__instance.TeamTitle.gameObject.SetActive(false);
@@ -361,6 +347,12 @@ class GamePlayManager
{
__instance.FrontMost.gameObject.SetActive(false);
__instance.Navigation.ShowDefaultNavigation();
if (!GameStates.IsLocalGame)
{
__instance.Navigation.ShowNavigationToProgressionScreen();
__instance.Navigation.ContinueButton.transform.Find("ContinueButton").position -= new Vector3(0.5f, 0.2f, 0f);
}
return false;
}
}
+5 -2
View File
@@ -19,7 +19,7 @@ class BetterGameSettings
public static BetterOptionItem? RoleRandomizer;
public static BetterOptionItem? DesyncRoles;
public static BetterOptionItem? ExperimentalDetectInvalidSabotage;
public static BetterOptionItem? CancelInvalidSabotage;
}
class BetterGameSettingsTemp
@@ -52,6 +52,7 @@ static class GameSettingMenuPatch
TitleList.Add(new BetterOptionTitleItem().Create(BetterSettingsTab, $"<color=#4f92ff>Host Only</color>"));
BetterGameSettings.WhenCheating = new BetterOptionStringItem().Create(100, BetterSettingsTab, "When a player is caught cheating", ["Notify", "Kick", "Ban"], 2);
BetterGameSettings.InvalidFriendCode = new BetterOptionCheckboxItem().Create(200, BetterSettingsTab, "Detected invalid FriendCodes", true);
BetterGameSettings.CancelInvalidSabotage = new BetterOptionCheckboxItem().Create(900, BetterSettingsTab, "Cancel Invalid Sabotages", true);
BetterGameSettings.UseBanPlayerList = new BetterOptionCheckboxItem().Create(300, BetterSettingsTab, "Use Ban Player List", true);
BetterGameSettings.UseBanNameList = new BetterOptionCheckboxItem().Create(400, BetterSettingsTab, "Use Ban Name List", true);
BetterGameSettings.UseBanWordList = new BetterOptionCheckboxItem().Create(500, BetterSettingsTab, "Use Ban Word List", true);
@@ -63,9 +64,11 @@ static class GameSettingMenuPatch
BetterGameSettings.DetectCheatClients = new BetterOptionCheckboxItem().Create(700, BetterSettingsTab, "Detect Cheat Clients", true);
BetterGameSettings.DetectInvalidRPCs = new BetterOptionCheckboxItem().Create(800, BetterSettingsTab, "Detect Invalid RPCs", true);
/*
TitleList.Add(new BetterOptionDividerItem().Create(BetterSettingsTab));
TitleList.Add(new BetterOptionTitleItem().Create(BetterSettingsTab, $"<color=#f20>Experimental</color>"));
BetterGameSettings.ExperimentalDetectInvalidSabotage = new BetterOptionCheckboxItem().Create(100000, BetterSettingsTab, "Detect Invalid Sabotages", false);
BetterGameSettings.CancelInvalidSabotage = new BetterOptionCheckboxItem().Create(100000, BetterSettingsTab, "Detect Invalid Sabotages", false);
*/
}
if (IsPreload || GameStates.IsHost)
+28 -19
View File
@@ -1,4 +1,5 @@
using HarmonyLib;
using TMPro;
using UnityEngine;
@@ -17,30 +18,38 @@ public class HudManagerPatch
[HarmonyPostfix]
public static void Start_Postfix(HudManager __instance)
{
if (BetterNotificationManager.BAUNotificationManagerObj == null)
{
var ChatNotifications = __instance.Chat.chatNotification;
if (ChatNotifications != null)
{
ChatNotifications.timeOnScreen = 1f;
ChatNotifications.gameObject.SetActive(true);
GameObject BAUNotification = UnityEngine.Object.Instantiate(ChatNotifications.gameObject);
BAUNotification.name = "BAUNotification";
UnityEngine.Object.Destroy(BAUNotification.GetComponent<ChatNotification>());
UnityEngine.Object.Destroy(GameObject.Find($"{BAUNotification.name}/Sizer/PoolablePlayer"));
UnityEngine.Object.Destroy(GameObject.Find($"{BAUNotification.name}/Sizer/ColorText"));
BAUNotification.GetComponent<AspectPosition>().DistanceFromEdge = new Vector3(-1.57f, 5.3f, -15f);
GameObject.Find($"{BAUNotification.name}/Sizer/NameText").transform.localPosition = new Vector3(-3.3192f, -0.0105f);
GameObject.Find($"{BAUNotification.name}/Sizer/NameText").GetComponent<TextMeshPro>().text = "<color=#00ff44>System Notification</color>";
UnityEngine.Object.DontDestroyOnLoad(BAUNotification);
BetterNotificationManager.BAUNotificationManagerObj = BAUNotification;
BAUNotification.SetActive(false);
ChatNotifications.timeOnScreen = 0f;
ChatNotifications.gameObject.SetActive(false);
}
}
_ = new LateTask(() =>
{
try
if (!HasBeenWelcomed && GameStates.IsInGame && GameStates.IsLobby && !GameStates.IsFreePlay)
{
if (BetterNotificationManager.BAUNotificationManagerObj == null)
{
bool ChatState = GameObject.Find("ChatUi");
__instance.Chat.gameObject.SetActive(true);
__instance.Chat.chatNotification.gameObject.SetActive(true);
__instance.Chat.chatNotification.SetUp(PlayerControl.LocalPlayer, "");
__instance.Chat.chatNotification.timeOnScreen = 0f;
__instance.Chat.chatNotification.gameObject.SetActive(false);
__instance.Chat.gameObject.SetActive(ChatState);
}
BetterNotificationManager.Notify("<b><color=#00751f>Welcome To Better Among Us!</color></b>", 8f);
if (!HasBeenWelcomed && GameStates.IsInGame && GameStates.IsLobby && !GameStates.IsFreePlay)
{
BetterNotificationManager.Notify("<b><color=#00751f>Welcome To Better Among Us!</color></b>", 8f);
Utils.AddChatPrivate(WelcomeMessage, overrideName: " ");
HasBeenWelcomed = true;
}
Utils.AddChatPrivate(WelcomeMessage, overrideName: " ");
HasBeenWelcomed = true;
}
catch { }
}, 1f, "HudManagerPatch Start");
}
[HarmonyPatch(nameof(HudManager.Update))]
+1 -1
View File
@@ -84,7 +84,7 @@ class MeetingHudUpdatePatch
DisconnectText = "Left The Game";
break;
case DisconnectReasons.Banned:
if (playerData.BetterData().BannedByAntiCheat)
if (playerData.BetterData().AntiCheatInfo.BannedByAntiCheat)
{
DisconnectText = "Banned By Anti-Cheat>";
}
+39 -12
View File
@@ -1,4 +1,5 @@
using AmongUs.Data;
using AmongUs.GameOptions;
using HarmonyLib;
using Il2CppSystem.Linq;
using LibCpp2IL;
@@ -93,9 +94,6 @@ class PlayerControlPatch
return;
}
if (Main.AllPlayerControls.Any(pc => player.Data.PlayerId == pc.shapeshiftTargetPlayerId))
return;
string NewName = player.Data.PlayerName;
string hashPuid = Utils.GetHashPuid(player);
@@ -132,14 +130,31 @@ class PlayerControlPatch
var sbTagBottom = new StringBuilder();
// Put +++ at the end of each tag
if (!player.isDummy)
if (!string.IsNullOrEmpty(hashPuid) && AntiCheat.SickoData.ContainsKey(hashPuid) || !string.IsNullOrEmpty(friendCode) && AntiCheat.SickoData.ContainsValue(friendCode))
{
if (!string.IsNullOrEmpty(hashPuid) && AntiCheat.SickoData.ContainsKey(hashPuid) || !string.IsNullOrEmpty(friendCode) && AntiCheat.SickoData.ContainsValue(friendCode))
sbTag.Append("<color=#00f583>Sicko User</color>+++");
else if (!string.IsNullOrEmpty(hashPuid) && AntiCheat.AUMData.ContainsKey(hashPuid) || !string.IsNullOrEmpty(friendCode) && AntiCheat.AUMData.ContainsValue(friendCode))
sbTag.Append("<color=#4f0000>AUM User</color>+++");
else if (!string.IsNullOrEmpty(hashPuid) && AntiCheat.PlayerData.ContainsKey(hashPuid) || !string.IsNullOrEmpty(friendCode) && AntiCheat.PlayerData.ContainsValue(friendCode))
sbTag.Append("<color=#fc0000>Known Cheater</color>+++");
sbTag.Append("<color=#00f583>Sicko User</color>+++");
player.SetOutlineByHex(true, "#00f583");
}
else if (!string.IsNullOrEmpty(hashPuid) && AntiCheat.AUMData.ContainsKey(hashPuid) || !string.IsNullOrEmpty(friendCode) && AntiCheat.AUMData.ContainsValue(friendCode))
{
sbTag.Append("<color=#4f0000>AUM User</color>+++");
player.SetOutlineByHex(true, "#4f0000");
}
else if (!string.IsNullOrEmpty(hashPuid) && AntiCheat.PlayerData.ContainsKey(hashPuid) || !string.IsNullOrEmpty(friendCode) && AntiCheat.PlayerData.ContainsValue(friendCode))
{
sbTag.Append("<color=#fc0000>Known Cheater</color>+++");
player.SetOutlineByHex(true, "#fc0000");
}
else
{
var color = player.cosmetics.currentBodySprite.BodySprite.material.GetColor("_OutlineColor");
if (color == Utils.HexToColor32("#00f583") || color == Utils.HexToColor32("#4f0000") || color == Utils.HexToColor32("#fc0000"))
{
player.SetOutline(false, null);
}
}
if (GameStates.IsInGame && GameStates.IsLobby && !GameStates.IsFreePlay)
@@ -163,7 +178,7 @@ class PlayerControlPatch
sbTagTop.Append($"<color=#9e9e9e>{platform}</color>+++");
sbTagTop.Append($"<color=#ffd829>Lv: {player.Data.PlayerLevel.ToString()}</color>+++");
sbTagTop.Append($"<color=#ffd829>Lv: {player.Data.PlayerLevel + 1}</color>+++");
sbTagBottom.Append($"<color={friendCodeColor}>{friendCode}</color>+++");
}
@@ -176,7 +191,11 @@ class PlayerControlPatch
{
Role += $" <color=#cbcbcb>({player.Data.Tasks.ToArray().Where(task => task.Complete).Count()}/{player.Data.Tasks.Count})</color>";
}
sbTagTop.Append($"{Role}+++");
if (PlayerControl.LocalPlayer.Is(RoleTypes.GuardianAngel) && !player.IsAlive() || !PlayerControl.LocalPlayer.Is(RoleTypes.GuardianAngel))
{
sbTagTop.Append($"{Role}+++");
}
}
}
else if (GameStates.IsInGame || GameStates.IsFreePlay)
@@ -203,6 +222,14 @@ class PlayerControlPatch
{
player.RawSetName(NewName);
}
else
{
var target = Utils.PlayerFromId(player.shapeshiftTargetPlayerId);
if (target != null)
{
player.RawSetName(target.Data.PlayerName);
}
}
// Put +++ at the end of each tag
static StringBuilder FormatInfo(StringBuilder source)
+1 -1
View File
@@ -136,7 +136,7 @@ class GameDataShowNotificationPatch
{
public static void BetterShowNotification(NetworkedPlayerInfo playerData, DisconnectReasons reason = DisconnectReasons.Unknown, string forceReasonText = "")
{
if (playerData.BetterData().BannedByAntiCheat) return;
if (playerData.BetterData().AntiCheatInfo.BannedByAntiCheat) return;
string playerName = playerData.BetterData().RealName;
+24 -49
View File
@@ -88,6 +88,7 @@ public class RoleManagerPatch
CrewmateRoles[role] = GameOptionsManager.Instance.CurrentGameOptions.RoleOptions.GetNumPerGame(role);
}
#if DEBUG
// Override player role assignment
if (SetPlayerRole.Keys.Any())
{
@@ -102,7 +103,6 @@ public class RoleManagerPatch
{
Impostors.Add(player);
player.RpcSetRole(RoleTypes.Impostor);
player.roleAssigned = true;
Logger.Log($"Override Assigned {Utils.GetRoleName(RoleTypes.Impostor)} role to {player.Data.PlayerName}", "RoleManager");
}
else continue;
@@ -111,7 +111,6 @@ public class RoleManagerPatch
{
Crewmates.Add(player);
player.RpcSetRole(RoleTypes.Crewmate);
player.roleAssigned = true;
Logger.Log($"Override Assigned {Utils.GetRoleName(RoleTypes.Crewmate)} role to {player.Data.PlayerName}", "RoleManager");
}
else
@@ -156,11 +155,11 @@ public class RoleManagerPatch
}
}
player.roleAssigned = true;
Logger.Log($"Override Assigned {Utils.GetRoleName(role)} role to {player.Data.PlayerName}", "RoleManager");
}
}
}
#endif
// Get players in random order
List<PlayerControl> players = Main.AllPlayerControls
@@ -206,7 +205,6 @@ public class RoleManagerPatch
}
}
pc.roleAssigned = true;
Logger.Log($"Assigned {Utils.GetRoleName(kvp.Key)} role to {pc.Data.PlayerName}", "RoleManager");
break;
}
@@ -217,7 +215,6 @@ public class RoleManagerPatch
ImpostorMultiplier[Utils.GetHashPuid(pc)] += 15;
Impostors.Add(pc);
pc.RpcSetRole(RoleTypes.Impostor);
pc.roleAssigned = true;
Logger.Log($"Assigned {Utils.GetRoleName(RoleTypes.Impostor)} role to {pc.Data.PlayerName}", "RoleManager");
}
}
@@ -245,7 +242,6 @@ public class RoleManagerPatch
}
}
pc.roleAssigned = true;
Logger.Log($"Assigned {Utils.GetRoleName(kvp.Key)} role to {pc.Data.PlayerName}", "RoleManager");
break;
}
@@ -256,7 +252,6 @@ public class RoleManagerPatch
ImpostorMultiplier[Utils.GetHashPuid(pc)] = 0;
Crewmates.Add(pc);
pc.RpcSetRole(RoleTypes.Crewmate);
pc.roleAssigned = true;
Logger.Log($"Assigned {Utils.GetRoleName(RoleTypes.Crewmate)} role to {pc.Data.PlayerName}", "RoleManager");
}
}
@@ -276,42 +271,25 @@ public class RoleManagerPatch
{
Logger.LogHeader($"Better Role Assignment Has Started", "RoleManager");
foreach (var addplayer in Main.AllPlayerControls.Where(pc => !ImpostorMultiplier.ContainsKey(Utils.GetHashPuid(pc))))
ImpostorMultiplier[Utils.GetHashPuid(addplayer)] = 0;
int NumImpostors = BetterGameSettings.HideAndSeekImpNum.GetInt();
int NumPlayers = Main.AllPlayerControls.Length;
if (NumImpostors > Main.AllPlayerControls.Length)
NumImpostors = Main.AllPlayerControls.Length;
List<PlayerControl> Impostors = [];
List<PlayerControl> Crewmates = [];
// Set imp from settings
int SetImpostor = GameOptionsManager.Instance.currentHideNSeekGameOptions.ImpostorPlayerID;
if (SetImpostor >= 0)
{
var player = Utils.PlayerFromId(SetImpostor);
if (player != null)
{
Impostors.Add(player);
player.RpcSetRole(RoleTypes.Impostor);
player.roleAssigned = true;
NumImpostors--;
Logger.Log($"Settings Assigned {Utils.GetRoleName(RoleTypes.Impostor)} role to {player.Data.PlayerName}", "RoleManager");
}
}
var betterImpostorSettings = new int[]
{
-1,
int[] betterImpostorSettings =
[
GameOptionsManager.Instance.currentHideNSeekGameOptions.ImpostorPlayerID,
BetterGameSettingsTemp.HideAndSeekImp2.GetValue(),
BetterGameSettingsTemp.HideAndSeekImp3.GetValue(),
BetterGameSettingsTemp.HideAndSeekImp4.GetValue(),
BetterGameSettingsTemp.HideAndSeekImp5.GetValue()
};
];
for (int i = 1; i < BetterGameSettings.HideAndSeekImpNum.GetInt(); i++)
for (int i = 0; i < NumImpostors; i++)
{
int tempSetImpostor = betterImpostorSettings[i];
@@ -320,18 +298,16 @@ public class RoleManagerPatch
var player = Utils.PlayerFromId(tempSetImpostor);
if (player != null)
{
if (NumImpostors > 0 && !Impostors.Contains(player))
if (Impostors.Count < NumImpostors)
{
Impostors.Add(player);
player.RpcSetRole(RoleTypes.Impostor);
player.roleAssigned = true;
NumImpostors--;
Logger.Log($"Settings Assigned {Utils.GetRoleName(RoleTypes.Impostor)} role to {player.Data.PlayerName}", "RoleManager");
}
}
}
}
#if DEBUG
// Override player role assignment
if (SetPlayerRole.Keys.Any())
{
@@ -345,8 +321,6 @@ public class RoleManagerPatch
if (Impostors.Count < NumImpostors)
{
Impostors.Add(player);
player.RpcSetRole(RoleTypes.Impostor);
player.roleAssigned = true;
Logger.Log($"Override Assigned {Utils.GetRoleName(RoleTypes.Impostor)} role to {player.Data.PlayerName}", "RoleManager");
}
else continue;
@@ -354,12 +328,11 @@ public class RoleManagerPatch
else if (role is RoleTypes.Engineer)
{
Crewmates.Add(player);
player.RpcSetRole(RoleTypes.Engineer);
player.roleAssigned = true;
Logger.Log($"Override Assigned {Utils.GetRoleName(RoleTypes.Engineer)} role to {player.Data.PlayerName}", "RoleManager");
}
}
}
#endif
// Get players in random order
List<PlayerControl> players = Main.AllPlayerControls
@@ -381,31 +354,33 @@ public class RoleManagerPatch
{
if (pc == null || pc.roleAssigned == true) continue;
if (Impostors.Count < NumImpostors && RNG() > ImpostorMultiplier[Utils.GetHashPuid(pc)])
if (Impostors.Count < NumImpostors)
{
if (!Impostors.Contains(pc))
if (!Crewmates.Contains(pc))
{
ImpostorMultiplier[Utils.GetHashPuid(pc)] += 15;
Impostors.Add(pc);
pc.RpcSetRole(RoleTypes.Impostor);
pc.roleAssigned = true;
Logger.Log($"Assigned {Utils.GetRoleName(RoleTypes.Impostor)} role to {pc.Data.PlayerName}", "RoleManager");
}
}
else
{
if (!Crewmates.Contains(pc))
if (!Impostors.Contains(pc))
{
ImpostorMultiplier[Utils.GetHashPuid(pc)] = 0;
Crewmates.Add(pc);
pc.RpcSetRole(RoleTypes.Engineer);
pc.roleAssigned = true;
Logger.Log($"Assigned {Utils.GetRoleName(RoleTypes.Engineer)} role to {pc.Data.PlayerName}", "RoleManager");
}
}
}
SetPlayerRole.Clear();
foreach (var player in Impostors)
{
player.RpcSetRole(RoleTypes.Impostor);
}
foreach (var player in Crewmates)
{
player.RpcSetRole(RoleTypes.Engineer);
}
_ = new LateTask(() =>
{
+4 -2
View File
@@ -27,8 +27,8 @@ public class Main : BasePlugin
public const string HotfixNum = "0";
public const bool IsHotFix = false;
public const string PluginGuid = "com.d1gq.betteramongus";
public const string PluginVersion = "1.1.1";
public const string ReleaseDate = "08.25.2024"; // mm/dd/yyyy
public const string PluginVersion = "1.1.2";
public const string ReleaseDate = "08.31.2024"; // mm/dd/yyyy
public const string Github = "https://github.com/D1GQ/BetterAmongUs-Public";
public const string Discord = "https://discord.gg/vjYrXpzNAn";
@@ -158,10 +158,12 @@ public class Main : BasePlugin
for (int i = 0; i < DevUser.Length; i++)
DevUser[i] = Encryptor.Decrypt(DevUser[i]);
#if DEBUG
ClassInjector.RegisterTypeInIl2Cpp<DebugMenu>();
ClassInjector.RegisterTypeInIl2Cpp<Resources.Coroutines.Component>();
debugmenu = AddComponent<DebugMenu>();
AddComponent<Resources.Coroutines.Component>();
#endif
string SupportedVersions = string.Empty;
foreach (string text in SupportedAmongUsVersions.ToArray())