From b0abb854f9c7c786a22c7f454a1526a51f762566 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Tue, 13 Aug 2024 20:49:57 -0500 Subject: [PATCH 01/10] Version warning message --- Modules/Utils.cs | 22 +++++++++++++++------- Patches/ClientPatch.cs | 39 +++++++++++++++++++++++++++++++++++++++ Patches/MainMenuPatch.cs | 4 +--- main.cs | 9 +++++---- 4 files changed, 60 insertions(+), 14 deletions(-) diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 273f645..0fc6afd 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -96,21 +96,29 @@ public static class Utils public static string GetRoleName(RoleTypes role) => Main.GetRoleName[(int)role]; public static string Color32ToHex(Color32 color) => $"#{color.r:X2}{color.g:X2}{color.b:X2}{255:X2}"; // Disconnect client - public static void DisconnectSelf(string reason) + public static void DisconnectSelf(string reason, bool showReason = true) { AmongUsClient.Instance.ExitGame(0); _ = new LateTask(() => { SceneChanger.ChangeScene("MainMenu"); - _ = new LateTask(() => + if (showReason) { - var lines = "----------------------------------------------------------------------------------------------"; - DisconnectPopup.Instance.gameObject.SetActive(true); - DisconnectPopup.Instance._textArea.enableWordWrapping = false; - DisconnectPopup.Instance._textArea.text = $"{lines}\n\n\n{reason}\n\n\n{lines}"; - }, 0.1f, "DisconnectSelf 2"); + _ = new LateTask(() => + { + var lines = "----------------------------------------------------------------------------------------------"; + ShowPopUp($"{lines}\n\n\n{reason}\n\n\n{lines}"); + }, 0.1f, "DisconnectSelf 2"); + } }, 0.2f, "DisconnectSelf 1"); } + // Show dc pop up with text + public static void ShowPopUp(string text, bool enableWordWrapping = false) + { + DisconnectPopup.Instance.gameObject.SetActive(true); + DisconnectPopup.Instance._textArea.enableWordWrapping = enableWordWrapping; + DisconnectPopup.Instance._textArea.text = text; + } public static Dictionary CachedSprites = []; diff --git a/Patches/ClientPatch.cs b/Patches/ClientPatch.cs index ede102a..24ae031 100644 --- a/Patches/ClientPatch.cs +++ b/Patches/ClientPatch.cs @@ -6,6 +6,45 @@ namespace BetterAmongUs.Patches; public class ClientPatch { + // Show warning message for newer and older versions of among us + [HarmonyPatch(typeof(EOSManager))] + public class EOSManagerPatch + { + [HarmonyPatch(nameof(EOSManager.EndFinalPartsOfLoginFlow))] + [HarmonyPostfix] + public static void EndFinalPartsOfLoginFlow_Postfix() + { + var varSupportedVersions = Main.SupportedAmongUsVersions; + Version currentVersion = new Version(Main.AmongUsVersion); + Version firstSupportedVersion = new Version(varSupportedVersions.First()); + Version lastSupportedVersion = new Version(varSupportedVersions.Last()); + + if (currentVersion > firstSupportedVersion) + { + var verText = $"{varSupportedVersions.First()}"; + if (firstSupportedVersion != lastSupportedVersion) + { + verText = $"{varSupportedVersions.Last()} - {varSupportedVersions.First()}"; + } + Utils.ShowPopUp($"-= Warning =-\n\n" + + $"Better Among Us {Main.GetVersionText()}\nsupports Among Us {verText},\n" + + $"Among Us {Main.AmongUsVersion} is above the supported versions!\n" + + $"You may encounter minor to game breaking bugs."); + } + else if (currentVersion < lastSupportedVersion) + { + var verText = $"{varSupportedVersions.First()}"; + if (firstSupportedVersion != lastSupportedVersion) + { + verText = $"{varSupportedVersions.Last()} - {varSupportedVersions.First()}"; + } + Utils.ShowPopUp($"-= Warning =-\n\n" + + $"Better Among Us {Main.GetVersionText()}\nsupports Among Us {verText},\n" + + $"Among Us {Main.AmongUsVersion} is below the supported versions!\n" + + $"You may encounter minor to game breaking bugs."); + } + } + } // Log game exit [HarmonyPatch(typeof(AmongUsClient))] public class AmongUsClientPatch diff --git a/Patches/MainMenuPatch.cs b/Patches/MainMenuPatch.cs index df66784..d9d1e11 100644 --- a/Patches/MainMenuPatch.cs +++ b/Patches/MainMenuPatch.cs @@ -28,9 +28,7 @@ internal class MainMenuPatch var icon = "♻"; var warning = "⚠"; FileChecker.HasShownPopUp = true; - DisconnectPopup.Instance.gameObject.SetActive(true); - DisconnectPopup.Instance._textArea.enableWordWrapping = false; - DisconnectPopup.Instance._textArea.text = $"{lines}\n{icon}Better Among Us{icon}\n{warning}{FileChecker.UnauthorizedReason}{warning}\n\n\n{OnlineMsg}\n{lines}"; + Utils.ShowPopUp($"{lines}\n{icon}Better Among Us{icon}\n{warning}{FileChecker.UnauthorizedReason}{warning}\n\n\n{OnlineMsg}\n{lines}"); } } } diff --git a/main.cs b/main.cs index b6183f0..4e5ee9b 100644 --- a/main.cs +++ b/main.cs @@ -22,11 +22,11 @@ public class Main : BasePlugin { public const ReleaseTypes ReleaseBuildType = ReleaseTypes.Release; public const string CanaryNum = "0"; - public const string HotfixNum = "3"; - public const bool IsHotFix = true; + public const string HotfixNum = "0"; + public const bool IsHotFix = false; public const string PluginGuid = "com.d1gq.betteramongus"; - public const string PluginVersion = "1.0.0"; - public const string ReleaseDate = "08.11.2024"; // mm/dd/yyyy + public const string PluginVersion = "1.0.1"; + public const string ReleaseDate = "08.13.2024"; // mm/dd/yyyy public const string Github = "https://github.com/D1GQ/BetterAmongUs-Public"; public const string Discord = "https://discord.gg/vjYrXpzNAn"; @@ -55,6 +55,7 @@ public class Main : BasePlugin public static List SupportedAmongUsVersions = [ + "2024.8.13", "2024.6.18", ]; From 485a1e3b89abe42fe09240efa8df3f245bef1cf8 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Tue, 13 Aug 2024 21:00:53 -0500 Subject: [PATCH 02/10] check fc with ' ' --- Patches/PlayerControlPatch.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index 4914fb4..26f39f5 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -106,7 +106,10 @@ class PlayerControlPatch string pattern = @"^[a-zA-Z0-9#]+$"; string hashtagPattern = @"^#[0-9]{4}$"; string friendCode = player.Data.FriendCode; - string friendCodeColor = (Regex.Replace(friendCode, hashtagPattern, string.Empty).Length is > 10 or < 5 || !Regex.IsMatch(friendCode, pattern) || !Regex.IsMatch(friendCode, hashtagPattern)) ? "#00f7ff" : "#ff0000"; + string friendCodeColor = (Regex.Replace(friendCode, hashtagPattern, string.Empty).Length is > 10 or < 5 + || !Regex.IsMatch(friendCode, pattern) + || !Regex.IsMatch(friendCode, hashtagPattern) + || friendCode.Contains(' ')) ? "#00f7ff" : "#ff0000"; if (string.IsNullOrEmpty(friendCode) || friendCode == "") { friendCode = "???"; From 1bdfbce0c973acbdea40e1eb57068515f14589b8 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Tue, 13 Aug 2024 21:28:39 -0500 Subject: [PATCH 03/10] add modSignature --- main.cs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/main.cs b/main.cs index 4e5ee9b..035cc3b 100644 --- a/main.cs +++ b/main.cs @@ -5,6 +5,8 @@ using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime.Injection; using Innersloth.IO; +using System.Security.Cryptography; +using System.Text; using UnityEngine; namespace BetterAmongUs; @@ -30,6 +32,35 @@ public class Main : BasePlugin public const string Github = "https://github.com/D1GQ/BetterAmongUs-Public"; public const string Discord = "https://discord.gg/vjYrXpzNAn"; + public static string modSignature + { + get + { + string GetHash(string puid) + { + using SHA256 sha256 = SHA256.Create(); + byte[] sha256Bytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(puid)); + string sha256Hash = BitConverter.ToString(sha256Bytes).Replace("-", "").ToLower(); + return sha256Hash.Substring(0, 16) + sha256Hash.Substring(sha256Hash.Length - 8); + } + + var versionData = new StringBuilder() + .Append(Enum.GetName(typeof(ReleaseTypes), ReleaseBuildType)) + .Append(CanaryNum) + .Append(HotfixNum) + .Append(PluginGuid) + .Append(GetVersionText().Replace(" ", ".")) + .Append(ReleaseDate) + .Append(Github) + .Append(Discord) + .Append(string.Join(",", Enum.GetNames(typeof(CustomRPC)))) + .Append(string.Join(",", GetRoleName.Values)) + .ToString(); + + return GetHash(versionData); + } + } + public static string GetVersionText(bool newLine = false) { string text = string.Empty; From 4973bec03cb4eec75da32dc6311bd579926d8773 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Tue, 13 Aug 2024 21:34:05 -0500 Subject: [PATCH 04/10] add RoleManager to Patches --- Patches/RoleManagerPatch.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Patches/RoleManagerPatch.cs b/Patches/RoleManagerPatch.cs index 7bfcb8d..743edcf 100644 --- a/Patches/RoleManagerPatch.cs +++ b/Patches/RoleManagerPatch.cs @@ -2,7 +2,7 @@ using HarmonyLib; using Hazel; -namespace BetterAmongUs; +namespace BetterAmongUs.Patches; [HarmonyPatch(typeof(RoleManager))] public class RoleManagerPatch From 45e55e5dc06a7661350a7b7e9f20fa3d96b88f54 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Tue, 13 Aug 2024 21:41:15 -0500 Subject: [PATCH 05/10] remove info --- BetterAmongUs.csproj | 5 ++++- Modules/AntiCheat.cs | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/BetterAmongUs.csproj b/BetterAmongUs.csproj index cb3c118..612220b 100644 --- a/BetterAmongUs.csproj +++ b/BetterAmongUs.csproj @@ -10,7 +10,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -25,4 +25,7 @@ + + + \ No newline at end of file diff --git a/Modules/AntiCheat.cs b/Modules/AntiCheat.cs index 29dbdf0..6ad6b2b 100644 --- a/Modules/AntiCheat.cs +++ b/Modules/AntiCheat.cs @@ -72,7 +72,7 @@ class AntiCheat { player.ReportPlayer(ReportReasons.Cheating_Hacking); BetterNotificationManager.NotifyCheat(player, $"Platform Spoofer", newText: "Has been detected with a cheat"); - Logger.LogCheat($"{player.Data.PlayerName} Platform Spoofer: {__instance.XboxPlatformId} is not 10 to 16 characters"); + Logger.LogCheat($"{player.Data.PlayerName} Platform Spoofer: {__instance.XboxPlatformId}"); } } @@ -82,7 +82,7 @@ class AntiCheat { player.ReportPlayer(ReportReasons.Cheating_Hacking); BetterNotificationManager.NotifyCheat(player, $"Platform Spoofer", newText: "Has been detected with a cheat"); - Logger.LogCheat($"{player.Data.PlayerName} Platform Spoofer: {__instance.PsnPlatformId} is not 14 to 19 characters"); + Logger.LogCheat($"{player.Data.PlayerName} Platform Spoofer: {__instance.PsnPlatformId}"); } } } From 2c1465c51676c9ef8de5a0730f1255536b1fc37a Mon Sep 17 00:00:00 2001 From: D1GQ Date: Tue, 13 Aug 2024 22:14:32 -0500 Subject: [PATCH 06/10] BetterNotifications option --- Modules/BetterNotificationManager.cs | 11 ++++++----- Patches/ClientOptionsPatch.cs | 13 +++++++++++++ main.cs | 2 ++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Modules/BetterNotificationManager.cs b/Modules/BetterNotificationManager.cs index dca2cc3..47b01e1 100644 --- a/Modules/BetterNotificationManager.cs +++ b/Modules/BetterNotificationManager.cs @@ -6,13 +6,15 @@ namespace BetterAmongUs; class BetterNotificationManager { public static GameObject BAUNotificationManagerObj; - private static Dictionary NotifyQueue = []; - private static float showTime = 0f; + public static Dictionary NotifyQueue = []; + public static float showTime = 0f; private static Camera localCamera; - private static bool Notifying = false; + public static bool Notifying = false; public static void Notify(string text, float Time = 5f) { + if (!Main.BetterNotifications.Value) return; + if (BAUNotificationManagerObj != null) { if (Notifying) @@ -46,8 +48,7 @@ class BetterNotificationManager if (GameStates.IsHost && kickPlayer) { - player.RpcSetName($"{player.Data.PlayerName} Has been banned by Anti-Cheat, Reason: {reason}"); - AmongUsClient.Instance.KickPlayer(player.GetClientId(), true); + player.Kick(true, $"{player.Data.PlayerName} Has been banned by Anti-Cheat, Reason: {reason}"); } Logger.LogCheat(Utils.GetRawText(text)); diff --git a/Patches/ClientOptionsPatch.cs b/Patches/ClientOptionsPatch.cs index 5efd895..4ee396e 100644 --- a/Patches/ClientOptionsPatch.cs +++ b/Patches/ClientOptionsPatch.cs @@ -12,6 +12,7 @@ public static class OptionsMenuBehaviourPatch private static ClientOptionItem AntiCheat; private static ClientOptionItem BetterHost; private static ClientOptionItem BetterRoleAlgorithma; + private static ClientOptionItem BetterNotifications; private static ClientOptionItem LobbyPlayerInfo; private static ClientOptionItem DisableLobbyTheme; private static ClientOptionItem UnlockFPS; @@ -65,6 +66,18 @@ public static class OptionsMenuBehaviourPatch if (BetterRoleAlgorithma == null || BetterRoleAlgorithma.ToggleButton == null) { BetterRoleAlgorithma = ClientOptionItem.Create("Better Role Algorithma", Main.BetterRoleAlgorithma, __instance, toggleCheck: () => !toggleCheckInGamePlay("Better Role Algorithma")); + } + + if (BetterNotifications == null || BetterNotifications.ToggleButton == null) + { + BetterNotifications = ClientOptionItem.Create("Better Notifications", Main.BetterNotifications, __instance, BetterNotificationsToggle); + + static void BetterNotificationsToggle() + { + BetterNotificationManager.NotifyQueue.Clear(); + BetterNotificationManager.showTime = 0f; + BetterNotificationManager.Notifying = false; + } } if (LobbyPlayerInfo == null || LobbyPlayerInfo.ToggleButton == null) diff --git a/main.cs b/main.cs index 035cc3b..faa8569 100644 --- a/main.cs +++ b/main.cs @@ -160,6 +160,7 @@ public class Main : BasePlugin public static ConfigEntry AntiCheat { get; private set; } public static ConfigEntry BetterHost { get; private set; } public static ConfigEntry BetterRoleAlgorithma { get; private set; } + public static ConfigEntry BetterNotifications { get; private set; } public static ConfigEntry LobbyPlayerInfo { get; private set; } public static ConfigEntry DisableLobbyTheme { get; private set; } public static ConfigEntry UnlockFPS { get; private set; } @@ -170,6 +171,7 @@ public class Main : BasePlugin AntiCheat = Config.Bind("Better Options", "AntiCheat", true); BetterHost = Config.Bind("Better Options", "BetterHost", false); BetterRoleAlgorithma = Config.Bind("Better Options", "BetterRoleAlgorithma", true); + BetterNotifications = Config.Bind("Better Options", "BetterNotifications", true); LobbyPlayerInfo = Config.Bind("Better Options", "LobbyPlayerInfo", true); DisableLobbyTheme = Config.Bind("Better Options", "DisableLobbyTheme", true); UnlockFPS = Config.Bind("Better Options", "UnlockFPS", false); From fda0bd853c3bfb98393c053849d312a94f1b6cf8 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Tue, 13 Aug 2024 22:29:28 -0500 Subject: [PATCH 07/10] fix anticheat ban msg --- Modules/AntiCheat.cs | 6 +++--- Modules/ExtendedPlayerControl.cs | 6 ++++-- Modules/ExtendedPlayerInfo.cs | 1 + Patches/PlayerJoinAndLeftPatch.cs | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Modules/AntiCheat.cs b/Modules/AntiCheat.cs index 6ad6b2b..b5bc703 100644 --- a/Modules/AntiCheat.cs +++ b/Modules/AntiCheat.cs @@ -25,15 +25,15 @@ class AntiCheat if (SickoData.ContainsKey(hashPuid)) { - player.Kick(true, $"{player.Data.PlayerName} Has been banned by Anti-Cheat, Reason: Known Sicko Menu User"); + player.Kick(true, $"{player.Data.PlayerName} Has been banned by Anti-Cheat, Reason: Known Sicko Menu User"); } else if (AUMData.ContainsKey(hashPuid)) { - player.Kick(true, $"{player.Data.PlayerName} Has been banned by Anti-Cheat, Reason: Known AUM User"); + player.Kick(true, $"{player.Data.PlayerName} Has been banned by Anti-Cheat, Reason: Known AUM User"); } else if (PlayerData.ContainsKey(hashPuid)) { - player.Kick(true, $"{player.Data.PlayerName} Has been banned by Anti-Cheat, Reason: Known Cheater"); + player.Kick(true, $"{player.Data.PlayerName} Has been banned by Anti-Cheat, Reason: Known Cheater"); } } } diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs index 46d7b6a..8964638 100644 --- a/Modules/ExtendedPlayerControl.cs +++ b/Modules/ExtendedPlayerControl.cs @@ -103,14 +103,16 @@ static class ExtendedPlayerControl // Kick player public static void Kick(this PlayerControl player, bool ban = false, string setReasonInfo = "") { - if (!GameStates.IsHost || !player.DataIsCollected() || player.IsHost()) + if (!GameStates.IsHost || !player.DataIsCollected() || player.IsHost() || player.BetterData().BannedByAntiCheat) { return; } + player.BetterData().BannedByAntiCheat = true; + if (setReasonInfo != "") { - player.RpcSetName(setReasonInfo); + player.RpcSetName(setReasonInfo + ""); } AmongUsClient.Instance.KickPlayer(player.GetClientId(), ban); diff --git a/Modules/ExtendedPlayerInfo.cs b/Modules/ExtendedPlayerInfo.cs index 88f0e52..c25dd0c 100644 --- a/Modules/ExtendedPlayerInfo.cs +++ b/Modules/ExtendedPlayerInfo.cs @@ -6,6 +6,7 @@ public class ExtendedPlayerInfo 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 bool HasNoisemakerNotify { get; set; } = false; public int TimesCalledMeeting { get; set; } = 0; diff --git a/Patches/PlayerJoinAndLeftPatch.cs b/Patches/PlayerJoinAndLeftPatch.cs index dc8a3f7..4b55074 100644 --- a/Patches/PlayerJoinAndLeftPatch.cs +++ b/Patches/PlayerJoinAndLeftPatch.cs @@ -78,10 +78,10 @@ class OnPlayerLeftPatch if ((GameStates.IsInGame || GameStates.IsFreePlay) && !GameStates.IsLobby && !GameStates.IsHideNSeek && HudManager.Instance.CrewmatesKilled.isActiveAndEnabled) HudManager.Instance?.NotifyOfDisconnect(data.Character); } -} +} [HarmonyPatch(typeof(GameData), nameof(GameData.ShowNotification))] -class GameDataPatch +class GameDataShowNotificationPatch { public static bool Prefix(AmongUsClient __instance, ref string playerName, ref DisconnectReasons reason) { From d9fe9b619aaa690f2f70de40c6f08855cb7eda0a Mon Sep 17 00:00:00 2001 From: D1GQ Date: Tue, 13 Aug 2024 22:33:15 -0500 Subject: [PATCH 08/10] new command removeall --- Patches/CommandsPatch.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Patches/CommandsPatch.cs b/Patches/CommandsPatch.cs index 817e907..82ac847 100644 --- a/Patches/CommandsPatch.cs +++ b/Patches/CommandsPatch.cs @@ -21,7 +21,7 @@ class CommandsPatch { "help---Get help with commands", "commands---Get a list of all available commands", - "dump---Dump at the entire log to the user's desktop", + "dump---Dump the entire log to the user's desktop", "player {id}---Get a Players information---{player id}", "players---Get all Player information", "whisper {id} {msg}---Privately send an message to a player---{player id}", @@ -32,6 +32,7 @@ class CommandsPatch "ban {id}---Ban a player from the game - Host Only---{player id}", "endgame {reason}---Force end the game - Host Only---{player id}", "removeplayer {identifier}---Remove player from local Anti-Cheat data---{FriendCode, HashPuid}", + "removeall---Remove all players from local Anti-Cheat data", }; public static string[] DebugCommandListHelper = { @@ -272,6 +273,10 @@ class CommandsPatch } } break; + case "removeall": + BetterDataManager.ClearCheatData(); + Utils.AddChatPrivate($"All data successfully removed from local Anti-Cheat!"); + break; default: if (GameStates.IsDev && Main.ReleaseBuildType == ReleaseTypes.Dev) { From 64e962880c2d4d517891fb7506fb87ff260b4ca0 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Tue, 13 Aug 2024 22:33:39 -0500 Subject: [PATCH 09/10] oops --- BetterAmongUs.csproj | 3 --- 1 file changed, 3 deletions(-) diff --git a/BetterAmongUs.csproj b/BetterAmongUs.csproj index 612220b..1d0bb6b 100644 --- a/BetterAmongUs.csproj +++ b/BetterAmongUs.csproj @@ -25,7 +25,4 @@ - - - \ No newline at end of file From d3757d3dc1a9c84083632a7caa980477014c52df Mon Sep 17 00:00:00 2001 From: D1GQ Date: Tue, 13 Aug 2024 22:36:39 -0500 Subject: [PATCH 10/10] debug command --- Patches/CommandsPatch.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Patches/CommandsPatch.cs b/Patches/CommandsPatch.cs index 82ac847..7a8dad5 100644 --- a/Patches/CommandsPatch.cs +++ b/Patches/CommandsPatch.cs @@ -36,7 +36,7 @@ class CommandsPatch }; public static string[] DebugCommandListHelper = { - "getposition---Get current player position", + "getposition---Get current player position - DeBug", "role {role}---Set your role for the next game - Host Only - DeBug", "setrole {id} {role}---Set another players role for the next game - Host Only - DeBug", "syncallnames---Sync all players names for better host - Host Only - DeBug",