From 9d20bdfb95d44a8b9b239ad27f2a5bffb1377b10 Mon Sep 17 00:00:00 2001 From: Ape <155788660+ApeMV@users.noreply.github.com> Date: Wed, 17 Dec 2025 16:08:45 +0100 Subject: [PATCH] Transfer HNSR -> AUR Time to pray to God this all goes well! --- .gitignore | 2 +- HNSRevamped.cs => AmongUsRevamped.cs | 18 +-- HNSRevamped.csproj => AmongUsRevamped.csproj | 4 +- Modules/AURoleOptions.cs | 139 +++++++++++++++++++ Modules/BanManager.cs | 10 +- Modules/ClientOptionItem.cs | 6 +- Modules/CustomOptionsHolder.cs | 51 +++++-- Modules/FixedUpdate.cs | 35 +++++ Modules/LateTask.cs | 2 +- Modules/LogHandler.cs | 2 +- Modules/OptionBackup/OptionBackupData.cs | 2 +- Modules/OptionBackup/OptionBackupValue.cs | 2 +- Modules/OptionItem/BooleanOptionItem.cs | 2 +- Modules/OptionItem/FloatOptionItem.cs | 2 +- Modules/OptionItem/IntegerOptionItem.cs | 2 +- Modules/OptionItem/OptionItem.cs | 4 +- Modules/OptionItem/StringOptionItem.cs | 2 +- Modules/OptionItem/TextOptionItem.cs | 2 +- Modules/OptionItem/ValueRule.cs | 2 +- Modules/RPC.cs | 2 +- Modules/Utils.cs | 10 +- Modules/Zoom.cs | 2 +- Patches/ChatControlPatch.cs | 2 +- Patches/ClientOptionsPatch.cs | 12 +- Patches/CredentialsPatch.cs | 11 +- Patches/EndGamePatches.cs | 5 +- Patches/GameOptionsMenuPatch.cs | 2 +- Patches/GameSettingMenuPatch.cs | 10 +- Patches/GameStartManagerPatch.cs | 2 +- Patches/JoinAndLeavePatches.cs | 2 +- Patches/KickPlayerPatch.cs | 2 +- Patches/LobbyPatch.cs | 2 +- Patches/LobbyViewSettingsPatch.cs | 2 +- Patches/NumberOptionsPatch.cs | 2 +- Patches/OnGameStartedPatch.cs | 62 +++++---- Patches/PlayerControlPatches.cs | 114 +++++++++++++-- Patches/SabotagePatches.cs | 2 +- Patches/TaskAssignPatch.cs | 2 +- 38 files changed, 422 insertions(+), 115 deletions(-) rename HNSRevamped.cs => AmongUsRevamped.cs (86%) rename HNSRevamped.csproj => AmongUsRevamped.csproj (89%) create mode 100644 Modules/AURoleOptions.cs create mode 100644 Modules/FixedUpdate.cs diff --git a/.gitignore b/.gitignore index 09a8f54..4e2d9d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ bin/ obj/ -HNSRevamped.sln +AmongUsRevamped.sln diff --git a/HNSRevamped.cs b/AmongUsRevamped.cs similarity index 86% rename from HNSRevamped.cs rename to AmongUsRevamped.cs index 64812b4..d2c19d1 100644 --- a/HNSRevamped.cs +++ b/AmongUsRevamped.cs @@ -9,7 +9,7 @@ using BepInEx.Unity.IL2CPP; using System; using UnityEngine; -namespace HNSRevamped; +namespace AmongUsRevamped; [BepInAutoPlugin] [BepInProcess("Among Us.exe")] @@ -29,7 +29,9 @@ public partial class Main : BasePlugin public static NormalGameOptionsV10 NormalOptions => GameOptionsManager.Instance != null ? GameOptionsManager.Instance.currentNormalGameOptions : null; public static bool HasArgumentException; public static string CredentialsText; - public const string ModVersion = "v0.4.0"; + public const string ModVersion = "v1.0.0"; + + public static float GameTimer; public static PlayerControl[] AllPlayerControls { @@ -55,17 +57,17 @@ public partial class Main : BasePlugin public override void Load() { - var handler = HNSRevamped.Logger.Handler("GitVersion"); - Logger = BepInEx.Logging.Logger.CreateLogSource("HNSRevamped"); - HNSRevamped.Logger.Enable(); + var handler = AmongUsRevamped.Logger.Handler("GitVersion"); + Logger = BepInEx.Logging.Logger.CreateLogSource("AmongUsRevamped"); + AmongUsRevamped.Logger.Enable(); Instance = this; AutoStart = Config.Bind("Client Options", "Auto Start", false); - GM = Config.Bind("Client Options", "GM", false); + GM = Config.Bind("Client Options", "Game Master", false); UnlockFps = Config.Bind("Client Options", "Unlock FPS", false); ShowFps = Config.Bind("Client Options", "Show FPS", false); AutoStart = Config.Bind("Client Options", "Auto Start", false); - DarkTheme = Config.Bind("Client Options", "Dark Theme", true); + DarkTheme = Config.Bind("Client Options", "Dark Theme", false); LobbyMusic = Config.Bind("Client Options", "Lobby Music", false); BanManager.Init(); @@ -82,4 +84,4 @@ public partial class Main : BasePlugin LateTask.Update(Time.deltaTime); } } -} +} \ No newline at end of file diff --git a/HNSRevamped.csproj b/AmongUsRevamped.csproj similarity index 89% rename from HNSRevamped.csproj rename to AmongUsRevamped.csproj index 6a21794..09fccd7 100644 --- a/HNSRevamped.csproj +++ b/AmongUsRevamped.csproj @@ -6,8 +6,8 @@ 1.0.0 dev - Mod generated using Reactor Template - + The ultimate Host-Only mod without Modded Protocol + Most Various diff --git a/Modules/AURoleOptions.cs b/Modules/AURoleOptions.cs new file mode 100644 index 0000000..9dd7120 --- /dev/null +++ b/Modules/AURoleOptions.cs @@ -0,0 +1,139 @@ +using AmongUs.GameOptions; + +namespace AmongUsRevamped; + +public static class AURoleOptions +{ + private static IGameOptions Opt; + + public static float KillCooldown + { + get => Opt.GetFloat(FloatOptionNames.KillCooldown); + set => Opt.SetFloat(FloatOptionNames.KillCooldown, value); + } + + public static float PlayerSpeedMod + { + get => Opt.GetFloat(FloatOptionNames.PlayerSpeedMod); + set => Opt.SetFloat(FloatOptionNames.PlayerSpeedMod, value); + } + + public static float ScientistCooldown + { + get => Opt.GetFloat(FloatOptionNames.ScientistCooldown); + set => Opt.SetFloat(FloatOptionNames.ScientistCooldown, value); + } + + public static float ScientistBatteryCharge + { + get => Opt.GetFloat(FloatOptionNames.ScientistBatteryCharge); + set => Opt.SetFloat(FloatOptionNames.ScientistBatteryCharge, value); + } + + public static float EngineerCooldown + { + get => Opt.GetFloat(FloatOptionNames.EngineerCooldown); + set => Opt.SetFloat(FloatOptionNames.EngineerCooldown, value); + } + + public static float EngineerInVentMaxTime + { + get => Opt.GetFloat(FloatOptionNames.EngineerInVentMaxTime); + set => Opt.SetFloat(FloatOptionNames.EngineerInVentMaxTime, value); + } + + public static float GuardianAngelCooldown + { + get => Opt.GetFloat(FloatOptionNames.GuardianAngelCooldown); + set => Opt.SetFloat(FloatOptionNames.GuardianAngelCooldown, value); + } + + public static float ProtectionDurationSeconds + { + get => Opt.GetFloat(FloatOptionNames.ProtectionDurationSeconds); + set => Opt.SetFloat(FloatOptionNames.ProtectionDurationSeconds, value); + } + + public static bool ImpostorsCanSeeProtect + { + get => Opt.GetBool(BoolOptionNames.ImpostorsCanSeeProtect); + set => Opt.SetBool(BoolOptionNames.ImpostorsCanSeeProtect, value); + } + + public static float ShapeshifterDuration + { + get => Opt.GetFloat(FloatOptionNames.ShapeshifterDuration); + set => Opt.SetFloat(FloatOptionNames.ShapeshifterDuration, value); + } + + public static float ShapeshifterCooldown + { + get => Opt.GetFloat(FloatOptionNames.ShapeshifterCooldown); + set => Opt.SetFloat(FloatOptionNames.ShapeshifterCooldown, value); + } + + public static bool ShapeshifterLeaveSkin + { + get => Opt.GetBool(BoolOptionNames.ShapeshifterLeaveSkin); + set => Opt.SetBool(BoolOptionNames.ShapeshifterLeaveSkin, value); + } + + public static bool NoisemakerImpostorAlert + { + get => Opt.GetBool(BoolOptionNames.NoisemakerImpostorAlert); + set => Opt.SetBool(BoolOptionNames.NoisemakerImpostorAlert, value); + } + + public static float NoisemakerAlertDuration + { + get => Opt.GetFloat(FloatOptionNames.NoisemakerAlertDuration); + set => Opt.SetFloat(FloatOptionNames.NoisemakerAlertDuration, value); + } + + public static float PhantomCooldown + { + get => Opt.GetFloat(FloatOptionNames.PhantomCooldown); + set => Opt.SetFloat(FloatOptionNames.PhantomCooldown, value); + } + + public static float PhantomDuration + { + get => Opt.GetFloat(FloatOptionNames.PhantomDuration); + set => Opt.SetFloat(FloatOptionNames.PhantomDuration, value); + } + + public static float TrackerCooldown + { + get => Opt.GetFloat(FloatOptionNames.TrackerCooldown); + set => Opt.SetFloat(FloatOptionNames.TrackerCooldown, value); + } + + public static float TrackerDuration + { + get => Opt.GetFloat(FloatOptionNames.TrackerDuration); + set => Opt.SetFloat(FloatOptionNames.TrackerDuration, value); + } + + public static float TrackerDelay + { + get => Opt.GetFloat(FloatOptionNames.TrackerDelay); + set => Opt.SetFloat(FloatOptionNames.TrackerDelay, value); + } + + public static float ViperDissolveTime + { + get => Opt.GetFloat(FloatOptionNames.ViperDissolveTime); + set => Opt.SetFloat(FloatOptionNames.ViperDissolveTime, value); + } + + public static float DetectiveSuspectLimit + { + get => Opt.GetFloat(FloatOptionNames.DetectiveSuspectLimit); + set => Opt.SetFloat(FloatOptionNames.DetectiveSuspectLimit, value); + } + + public static void SetOpt(IGameOptions opt) + { + Opt = opt; + } +} \ No newline at end of file diff --git a/Modules/BanManager.cs b/Modules/BanManager.cs index f18ab68..1f69990 100644 --- a/Modules/BanManager.cs +++ b/Modules/BanManager.cs @@ -7,19 +7,19 @@ using System.Text.RegularExpressions; using System.Reflection; // https://github.com/EnhancedNetwork/TownofHost-Enhanced/blob/main/Modules/BanManager.cs -namespace HNSRevamped; +namespace AmongUsRevamped; public static class BanManager { public static string RemoveHtmlTags(this string str) => Regex.Replace(str, "<[^>]*?>", ""); - private static string BanListPath = "./HNSR-DATA/BanList.txt"; - private static string ModeratorListPath = "./HNSR-DATA/ModeratorList.txt"; + private static string BanListPath = "./AUR-DATA/BanList.txt"; + private static string ModeratorListPath = "./AUR-DATA/ModeratorList.txt"; public static List TempBanWhiteList = []; public static void Init() { try { - Directory.CreateDirectory("HNSR-DATA"); + Directory.CreateDirectory("AUR-DATA"); if (!File.Exists(BanListPath)) { @@ -114,7 +114,7 @@ public static class BanManager try { - Directory.CreateDirectory("HNSR-DATA"); + Directory.CreateDirectory("AUR-DATA"); if (!File.Exists(BanListPath)) File.Create(BanListPath).Close(); using StreamReader sr = new(BanListPath); string line; diff --git a/Modules/ClientOptionItem.cs b/Modules/ClientOptionItem.cs index 2db9de2..dd6bdf0 100644 --- a/Modules/ClientOptionItem.cs +++ b/Modules/ClientOptionItem.cs @@ -2,7 +2,7 @@ using System; using BepInEx.Configuration; using UnityEngine; -namespace HNSRevamped; +namespace AmongUsRevamped; // Credit: https://github.com/tukasa0001/TownOfHost public class ClientOptionItem @@ -65,8 +65,8 @@ public class ClientOptionItem ToggleButtonBehaviour modOptionsButton = UnityEngine.Object.Instantiate(mouseMoveToggle, generalTab); modOptionsButton.transform.localPosition = leaveButton?.transform.localPosition ?? new(0f, -2.4f, 1f); - modOptionsButton.name = "HNSR Options"; - modOptionsButton.Text.text = "HNSR Options"; + modOptionsButton.name = "AUR Options"; + modOptionsButton.Text.text = "AUR Options"; modOptionsButton.Background.color = new Color32(0, 165, 255, byte.MaxValue); var modOptionsPassiveButton = modOptionsButton.GetComponent(); modOptionsPassiveButton.OnClick = new(); diff --git a/Modules/CustomOptionsHolder.cs b/Modules/CustomOptionsHolder.cs index e52d6e2..15aa589 100644 --- a/Modules/CustomOptionsHolder.cs +++ b/Modules/CustomOptionsHolder.cs @@ -2,7 +2,7 @@ using UnityEngine; // https://github.com/tukasa0001/TownOfHost/blob/main/Modules/OptionHolder.cs -namespace HNSRevamped +namespace AmongUsRevamped { [HarmonyPatch] public static class Options @@ -161,9 +161,20 @@ namespace HNSRevamped public static OptionItem DisableSubmitScan; public static OptionItem DisableUploadData; - // HNS + // Gamemode + public static OptionItem TabGroupHNS; public static OptionItem NumSeekers; + public static OptionItem TabGroup0Kcd; + public static OptionItem NoKcdSettingsOverride; + + public static OptionItem TabGroupSNS; + public static OptionItem SNSSettingsOverride; + public static OptionItem CrewAutoWinsGameAfter; + public static OptionItem CantKillTime; + public static OptionItem MisfiresToSuicide; + + public static bool IsLoaded = false; public static void Load() @@ -174,7 +185,7 @@ namespace HNSRevamped .SetColor(Color.green) .SetHeader(true); - TabGroupMain = TextOptionItem.Create(2, "Main", TabGroup.SystemSettings) + TabGroupMain = TextOptionItem.Create(60000, "Main", TabGroup.SystemSettings) .SetColor(Color.yellow); KickLowLevelPlayer = IntegerOptionItem.Create(60050, "Kick Players Under Level", new(0, 100, 1), 0, TabGroup.SystemSettings, false) @@ -187,26 +198,42 @@ namespace HNSRevamped .SetParent(KickInvalidFriendCodes); ApplyBanList = BooleanOptionItem.Create(60110, "Apply BanList", true, TabGroup.SystemSettings, true); - ApplyModeratorList = BooleanOptionItem.Create(60120, "Apply ModeratorList", false, TabGroup.SystemSettings, false); + ApplyModeratorList = BooleanOptionItem.Create(60120, "Apply ModeratorList", true, TabGroup.SystemSettings, false); AutoRejoinLobby = BooleanOptionItem.Create(60210, "Auto Rejoin Lobby", false, TabGroup.SystemSettings, false); - AutoStartTimer = IntegerOptionItem.Create(44420, "Countdown For AutoStart", new(1, 600, 1), 5, TabGroup.SystemSettings, false) + AutoStartTimer = IntegerOptionItem.Create(44420, "Countdown For Auto Start", new(1, 600, 1), 5, TabGroup.SystemSettings, false) .SetValueFormat(OptionFormat.Seconds); - WaitAutoStart = IntegerOptionItem.Create(44421, "AutoStart After", new(10, 600, 10), 5, TabGroup.SystemSettings, false) + WaitAutoStart = IntegerOptionItem.Create(44421, "Auto Start After", new(10, 600, 10), 300, TabGroup.SystemSettings, false) .SetValueFormat(OptionFormat.Seconds); - PlayerAutoStart = IntegerOptionItem.Create(44422, "Players Needed To Start", new(1, 15, 1), 5, TabGroup.SystemSettings, false); + PlayerAutoStart = IntegerOptionItem.Create(44422, "Players Needed To Auto Start", new(1, 15, 1), 1, TabGroup.SystemSettings, false); NoGameEnd = BooleanOptionItem.Create(60380, "No Game End", false, TabGroup.SystemSettings, false) .SetColor(Color.red) .SetHeader(true); - // HNS Settings - NumSeekers = IntegerOptionItem.Create(70000, "# Seekers", new(0, 15, 1), 1, TabGroup.HNSSettings, false) - .SetValueFormat(OptionFormat.Level) - .SetHeader(true); + // Gamemode Settings + TabGroupHNS = TextOptionItem.Create(70000, "Hide and Seek", TabGroup.GamemodeSettings) + .SetColor(Color.green); + NumSeekers = IntegerOptionItem.Create(70001, "# Seekers", new(0, 15, 1), 1, TabGroup.GamemodeSettings, false) + .SetValueFormat(OptionFormat.Level); - // Mod Settings + + TabGroup0Kcd = TextOptionItem.Create(70025, "0 Kill Cooldown", TabGroup.GamemodeSettings) + .SetColor(Color.red); + NoKcdSettingsOverride = BooleanOptionItem.Create(70026, "Auto Update Settings", true, TabGroup.GamemodeSettings, false); + + TabGroupSNS = TextOptionItem.Create(70050, "Shift and Seek", TabGroup.GamemodeSettings) + .SetColor(Color.yellow); + SNSSettingsOverride = BooleanOptionItem.Create(70051, "Auto Update Settings", true, TabGroup.GamemodeSettings, false); + CantKillTime = IntegerOptionItem.Create(70053, "After Misfiring, Can't kill for", new(0, 60, 5), 20, TabGroup.GamemodeSettings, false) + .SetValueFormat(OptionFormat.Seconds); + MisfiresToSuicide = IntegerOptionItem.Create(70052, "Suicide After Amount Of Misfires", new(1, 15, 1), 2, TabGroup.GamemodeSettings, false); + CrewAutoWinsGameAfter = IntegerOptionItem.Create(70054, "Crewmates Automatically Win After", new(0, 600, 10), 300, TabGroup.GamemodeSettings, false) + .SetValueFormat(OptionFormat.Seconds); + + + // Gameplay Settings DisableSabotage = BooleanOptionItem.Create(60565, "Disable Critical Sabotages", false, TabGroup.ModSettings, false) .SetColor(new Color32(255, 153, 153, byte.MaxValue)) .SetHeader(true); diff --git a/Modules/FixedUpdate.cs b/Modules/FixedUpdate.cs new file mode 100644 index 0000000..2685744 --- /dev/null +++ b/Modules/FixedUpdate.cs @@ -0,0 +1,35 @@ +using Hazel; +using System; +using System.Runtime.CompilerServices; +using InnerNet; +using UnityEngine; + +namespace AmongUsRevamped; + +[HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.FixedUpdate))] +public static class FixedUpdate +{ + public static void Postfix() + { + if (!AmongUsClient.Instance.AmHost) return; + + if (Utils.InGame && !Utils.IsMeeting && !ExileController.Instance) + { + // 2 = Shift and Seek + if (Options.Gamemode.GetValue() == 2 && !Utils.isHideNSeek && Options.CrewAutoWinsGameAfter.GetInt() != 0 && !Options.NoGameEnd.GetBool()) + { + Main.GameTimer += Time.fixedDeltaTime; + + if (Main.GameTimer > Options.CrewAutoWinsGameAfter.GetInt()) + { + Main.GameTimer = 0f; + + MessageWriter writer = AmongUsClient.Instance.StartEndGame(); + writer.Write((byte)GameOverReason.CrewmatesByVote); + AmongUsClient.Instance.FinishEndGame(writer); + Logger.Info($" Crewmates win because the game took longer than {Options.CrewAutoWinsGameAfter.GetInt()}s", "SNSManager"); + } + } + } + } +} \ No newline at end of file diff --git a/Modules/LateTask.cs b/Modules/LateTask.cs index e0f905b..3d6cea6 100644 --- a/Modules/LateTask.cs +++ b/Modules/LateTask.cs @@ -2,7 +2,7 @@ using System; using System.Runtime.CompilerServices; -namespace HNSRevamped; +namespace AmongUsRevamped; class LateTask { diff --git a/Modules/LogHandler.cs b/Modules/LogHandler.cs index 1246f40..df32e0f 100644 --- a/Modules/LogHandler.cs +++ b/Modules/LogHandler.cs @@ -5,7 +5,7 @@ using System.Net.Http; using System.Runtime.CompilerServices; using LogLevel = BepInEx.Logging.LogLevel; -namespace HNSRevamped; +namespace AmongUsRevamped; public interface ILogHandler { diff --git a/Modules/OptionBackup/OptionBackupData.cs b/Modules/OptionBackup/OptionBackupData.cs index d5f2a7b..b8873ee 100644 --- a/Modules/OptionBackup/OptionBackupData.cs +++ b/Modules/OptionBackup/OptionBackupData.cs @@ -2,7 +2,7 @@ using System; using AmongUs.GameOptions; // https://github.com/tukasa0001/TownOfHost/blob/main/Modules/OptionBackup/OptionBackupData.cs -namespace HNSRevamped +namespace AmongUsRevamped { public class OptionBackupData { diff --git a/Modules/OptionBackup/OptionBackupValue.cs b/Modules/OptionBackup/OptionBackupValue.cs index d7e0fee..31a0f19 100644 --- a/Modules/OptionBackup/OptionBackupValue.cs +++ b/Modules/OptionBackup/OptionBackupValue.cs @@ -2,7 +2,7 @@ using System; using AmongUs.GameOptions; // https://github.com/tukasa0001/TownOfHost/blob/main/Modules/OptionBackup/OptionBackupValue.cs -namespace HNSRevamped +namespace AmongUsRevamped { public abstract class OptionBackupValue { diff --git a/Modules/OptionItem/BooleanOptionItem.cs b/Modules/OptionItem/BooleanOptionItem.cs index 32f8036..29eb484 100644 --- a/Modules/OptionItem/BooleanOptionItem.cs +++ b/Modules/OptionItem/BooleanOptionItem.cs @@ -1,5 +1,5 @@ // https://github.com/tukasa0001/TownOfHost/blob/main/Modules/OptionItems/BooleanOptionItem.cs -namespace HNSRevamped +namespace AmongUsRevamped { public class BooleanOptionItem : OptionItem { diff --git a/Modules/OptionItem/FloatOptionItem.cs b/Modules/OptionItem/FloatOptionItem.cs index ae78b9b..0f9205b 100644 --- a/Modules/OptionItem/FloatOptionItem.cs +++ b/Modules/OptionItem/FloatOptionItem.cs @@ -1,5 +1,5 @@ // https://github.com/tukasa0001/TownOfHost/blob/main/Modules/OptionItems/FloatOptionItem.cs -namespace HNSRevamped +namespace AmongUsRevamped { public class FloatOptionItem : OptionItem { diff --git a/Modules/OptionItem/IntegerOptionItem.cs b/Modules/OptionItem/IntegerOptionItem.cs index 8cdfb08..a6610cd 100644 --- a/Modules/OptionItem/IntegerOptionItem.cs +++ b/Modules/OptionItem/IntegerOptionItem.cs @@ -1,5 +1,5 @@ // https://github.com/tukasa0001/TownOfHost/blob/main/Modules/OptionItems/IntegerOptionItem.cs -namespace HNSRevamped +namespace AmongUsRevamped { public class IntegerOptionItem : OptionItem { diff --git a/Modules/OptionItem/OptionItem.cs b/Modules/OptionItem/OptionItem.cs index 826ab56..98db188 100644 --- a/Modules/OptionItem/OptionItem.cs +++ b/Modules/OptionItem/OptionItem.cs @@ -4,7 +4,7 @@ using BepInEx.Configuration; using UnityEngine; // https://github.com/tukasa0001/TownOfHost/blob/main/Modules/OptionItems/OptionItem.cs -namespace HNSRevamped +namespace AmongUsRevamped { public abstract class OptionItem { @@ -215,7 +215,7 @@ namespace HNSRevamped { SystemSettings, ModSettings, - HNSSettings, + GamemodeSettings, } diff --git a/Modules/OptionItem/StringOptionItem.cs b/Modules/OptionItem/StringOptionItem.cs index 855174a..998573f 100644 --- a/Modules/OptionItem/StringOptionItem.cs +++ b/Modules/OptionItem/StringOptionItem.cs @@ -1,5 +1,5 @@ // https://github.com/tukasa0001/TownOfHost/blob/main/Modules/OptionItems/StringOptionItem.cs -namespace HNSRevamped +namespace AmongUsRevamped { public class StringOptionItem : OptionItem { diff --git a/Modules/OptionItem/TextOptionItem.cs b/Modules/OptionItem/TextOptionItem.cs index bd8b396..5a263c1 100644 --- a/Modules/OptionItem/TextOptionItem.cs +++ b/Modules/OptionItem/TextOptionItem.cs @@ -1,5 +1,5 @@ // https://github.com/Yumenopai/TownOfHost_Y/blob/main/Modules/OptionItem/TextOptionItem.cs -namespace HNSRevamped +namespace AmongUsRevamped { public class TextOptionItem : OptionItem { diff --git a/Modules/OptionItem/ValueRule.cs b/Modules/OptionItem/ValueRule.cs index 42a4432..fc4b02c 100644 --- a/Modules/OptionItem/ValueRule.cs +++ b/Modules/OptionItem/ValueRule.cs @@ -1,7 +1,7 @@ using System; // https://github.com/tukasa0001/TownOfHost/blob/main/Modules/OptionItems/ValueRule.cs -namespace HNSRevamped +namespace AmongUsRevamped { public abstract class ValueRule { diff --git a/Modules/RPC.cs b/Modules/RPC.cs index 8d3e287..2a292b4 100644 --- a/Modules/RPC.cs +++ b/Modules/RPC.cs @@ -6,7 +6,7 @@ using AmongUs.GameOptions; using Object = UnityEngine.Object; -namespace HNSRevamped +namespace AmongUsRevamped { public enum CustomRPC { diff --git a/Modules/Utils.cs b/Modules/Utils.cs index cbce96b..263d74d 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -14,7 +14,7 @@ using AmongUs.InnerNet.GameDataMessages; using Object = UnityEngine.Object; -namespace HNSRevamped; +namespace AmongUsRevamped; public static class Utils { @@ -43,7 +43,7 @@ public static class Utils { if (friendCode == "") return false; - var friendCodesFilePath = @"./HNSR-DATA/Moderators.txt"; + var friendCodesFilePath = @"./AUR-DATA/Moderators.txt"; var friendCodes = File.ReadAllLines(friendCodesFilePath); return friendCodes.Any(code => code.Contains(friendCode)); } @@ -55,9 +55,9 @@ public static class Utils case TabGroup.SystemSettings: return "System Settings"; case TabGroup.ModSettings: - return "Mod Settings"; - case TabGroup.HNSSettings: - return "HNS Settings"; + return "Gameplay Settings"; + case TabGroup.GamemodeSettings: + return "Gamemode Settings"; default: return ""; } diff --git a/Modules/Zoom.cs b/Modules/Zoom.cs index 66e016c..dee2919 100644 --- a/Modules/Zoom.cs +++ b/Modules/Zoom.cs @@ -1,7 +1,7 @@ using System; using UnityEngine; -namespace HNSRevamped; +namespace AmongUsRevamped; // https://github.com/Yumenopai/TownOfHost_Y [HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))] diff --git a/Patches/ChatControlPatch.cs b/Patches/ChatControlPatch.cs index 43ce45e..a16fcc1 100644 --- a/Patches/ChatControlPatch.cs +++ b/Patches/ChatControlPatch.cs @@ -4,7 +4,7 @@ using System; using UnityEngine; // https://github.com/SuperNewRoles/SuperNewRoles/blob/master/SuperNewRoles/Patches/LobbyBehaviourPatch.cs -namespace HNSRevamped; +namespace AmongUsRevamped; [HarmonyPatch(typeof(ChatController), nameof(ChatController.Update))] internal static class ChatControllerUpdatePatch diff --git a/Patches/ClientOptionsPatch.cs b/Patches/ClientOptionsPatch.cs index 8f4a0f0..9c94dfc 100644 --- a/Patches/ClientOptionsPatch.cs +++ b/Patches/ClientOptionsPatch.cs @@ -3,13 +3,13 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using UnityEngine; -namespace HNSRevamped +namespace AmongUsRevamped { // https://github.com/tukasa0001/TownOfHost [HarmonyPatch(typeof(OptionsMenuBehaviour), nameof(OptionsMenuBehaviour.Start))] public static class OptionsMenuBehaviourStartPatch { - private static ClientOptionItem GM; // Currently not used yet + private static ClientOptionItem GM; private static ClientOptionItem UnlockFPS; private static ClientOptionItem ShowFPS; private static ClientOptionItem AutoStart; @@ -22,7 +22,7 @@ namespace HNSRevamped if (GM == null || GM.ToggleButton == null) { - GM = ClientOptionItem.Create("GM", Main.GM, __instance, GMButtonToggle); + GM = ClientOptionItem.Create("Game Master", Main.GM, __instance, GMButtonToggle); static void GMButtonToggle() { @@ -33,7 +33,7 @@ namespace HNSRevamped if (UnlockFPS == null || UnlockFPS.ToggleButton == null) { - UnlockFPS = ClientOptionItem.Create("UnlockFPS", Main.UnlockFps, __instance, UnlockFPSButtonToggle); + UnlockFPS = ClientOptionItem.Create("Unlock FPS", Main.UnlockFps, __instance, UnlockFPSButtonToggle); static void UnlockFPSButtonToggle() { @@ -43,11 +43,11 @@ namespace HNSRevamped } if (ShowFPS == null || ShowFPS.ToggleButton == null) - ShowFPS = ClientOptionItem.Create("ShowFPS", Main.ShowFps, __instance); + ShowFPS = ClientOptionItem.Create("Show FPS", Main.ShowFps, __instance); if (AutoStart == null || AutoStart.ToggleButton == null) { - AutoStart = ClientOptionItem.Create("AutoStart", Main.AutoStart, __instance, AutoStartButtonToggle); + AutoStart = ClientOptionItem.Create("Auto Start", Main.AutoStart, __instance, AutoStartButtonToggle); static void AutoStartButtonToggle() { diff --git a/Patches/CredentialsPatch.cs b/Patches/CredentialsPatch.cs index c22f3c5..a125072 100644 --- a/Patches/CredentialsPatch.cs +++ b/Patches/CredentialsPatch.cs @@ -4,7 +4,7 @@ using TMPro; using UnityEngine; //https://github.com/Gurge44/EndlessHostRoles/blob/main/Patches/CredentialsPatch.cs -namespace HNSRevamped +namespace AmongUsRevamped { public enum ErrorCode { @@ -51,10 +51,13 @@ namespace HNSRevamped { private static void Postfix(VersionShower __instance) { - RpcSetTasksPatch.GlobalTaskIds = null; - OnGameJoinedPatch.AutoStartCheck = false; + RpcSetTasksPatch.GlobalTaskIds = null; + OnGameJoinedPatch.AutoStartCheck = false; + Main.GameTimer = 0f; + MurderPlayerPatch.misfireCount.Clear(); + LateTask.Tasks.Clear(); - Main.CredentialsText = $"Hide And Seek Revamped {Main.ModVersion}"; + Main.CredentialsText = $"Among Us Revamped {Main.ModVersion}"; var credentials = UnityEngine.Object.Instantiate(__instance.text); credentials.text = Main.CredentialsText; diff --git a/Patches/EndGamePatches.cs b/Patches/EndGamePatches.cs index c945ea3..5612139 100644 --- a/Patches/EndGamePatches.cs +++ b/Patches/EndGamePatches.cs @@ -3,7 +3,7 @@ using Hazel; using InnerNet; using UnityEngine; -namespace HNSRevamped; +namespace AmongUsRevamped; [HarmonyPatch(typeof(EndGameManager), nameof(EndGameManager.ShowButtons))] public static class EndGameManagerPatch @@ -12,6 +12,9 @@ public static class EndGameManagerPatch { RpcSetTasksPatch.GlobalTaskIds = null; OnGameJoinedPatch.AutoStartCheck = false; + Main.GameTimer = 0f; + MurderPlayerPatch.misfireCount.Clear(); + LateTask.Tasks.Clear(); EndGameNavigation navigation = __instance.Navigation; if (!AmongUsClient.Instance.AmHost || __instance == null || navigation == null || !Options.AutoRejoinLobby.GetBool()) return; diff --git a/Patches/GameOptionsMenuPatch.cs b/Patches/GameOptionsMenuPatch.cs index 9cd133a..7753d2c 100644 --- a/Patches/GameOptionsMenuPatch.cs +++ b/Patches/GameOptionsMenuPatch.cs @@ -5,7 +5,7 @@ using UnityEngine; using Object = UnityEngine.Object; // https://github.com/Yumenopai/TownOfHost_Y/blob/main/Patches/GameOptionsPatch.cs -namespace HNSRevamped +namespace AmongUsRevamped { public static class ModGameOptionsMenu { diff --git a/Patches/GameSettingMenuPatch.cs b/Patches/GameSettingMenuPatch.cs index 377b50a..d12337a 100644 --- a/Patches/GameSettingMenuPatch.cs +++ b/Patches/GameSettingMenuPatch.cs @@ -4,7 +4,7 @@ using UnityEngine; using Object = UnityEngine.Object; // https://github.com/Yumenopai/TownOfHost_Y/blob/main/Patches/GameSettingMenuPatch.cs -namespace HNSRevamped +namespace AmongUsRevamped { [HarmonyPatch(typeof(GameSettingMenu))] public class GameSettingMenuPatch @@ -114,13 +114,13 @@ namespace HNSRevamped switch ((TabGroup)(tabNum - 3)) { case TabGroup.SystemSettings: - __instance.MenuDescriptionText.text = "System Settings"; + __instance.MenuDescriptionText.text = "Quality settings to improve comfort and testing"; break; case TabGroup.ModSettings: - __instance.MenuDescriptionText.text = "Mod Settings"; + __instance.MenuDescriptionText.text = "Gameplay Settings to improve the in-game experience"; break; - case TabGroup.HNSSettings: - __instance.MenuDescriptionText.text = "HNS Settings"; + case TabGroup.GamemodeSettings: + __instance.MenuDescriptionText.text = "Situational settings to apply for specific gamemodes"; break; } } diff --git a/Patches/GameStartManagerPatch.cs b/Patches/GameStartManagerPatch.cs index 93d40a1..ec9aa12 100644 --- a/Patches/GameStartManagerPatch.cs +++ b/Patches/GameStartManagerPatch.cs @@ -1,6 +1,6 @@ using System; -namespace HNSRevamped; +namespace AmongUsRevamped; [HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.Update))] public static class GameStartManagerUpdatePatch diff --git a/Patches/JoinAndLeavePatches.cs b/Patches/JoinAndLeavePatches.cs index 3df4c39..b23bb58 100644 --- a/Patches/JoinAndLeavePatches.cs +++ b/Patches/JoinAndLeavePatches.cs @@ -5,7 +5,7 @@ using System.Text.RegularExpressions; using TMPro; using UnityEngine; -namespace HNSRevamped; +namespace AmongUsRevamped; [HarmonyPatch(typeof(AmongUsClient), nameof(AmongUsClient.OnGameJoined))] internal static class OnGameJoinedPatch diff --git a/Patches/KickPlayerPatch.cs b/Patches/KickPlayerPatch.cs index 428cea4..681f2a0 100644 --- a/Patches/KickPlayerPatch.cs +++ b/Patches/KickPlayerPatch.cs @@ -2,7 +2,7 @@ using UnityEngine; // https://github.com/tukasa0001/TownOfHost/blob/main/Patches/ClientPatch.cs -namespace HNSRevamped; +namespace AmongUsRevamped; [HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.KickPlayer))] internal class KickPlayerPatch diff --git a/Patches/LobbyPatch.cs b/Patches/LobbyPatch.cs index 4d786b1..63ea6b6 100644 --- a/Patches/LobbyPatch.cs +++ b/Patches/LobbyPatch.cs @@ -3,7 +3,7 @@ using System; using UnityEngine; // https://github.com/SuperNewRoles/SuperNewRoles/blob/master/SuperNewRoles/Patches/LobbyBehaviourPatch.cs -namespace HNSRevamped; +namespace AmongUsRevamped; [HarmonyPatch(typeof(LobbyBehaviour), nameof(LobbyBehaviour.Update))] internal static class LobbyBehaviourUpdatePatch diff --git a/Patches/LobbyViewSettingsPatch.cs b/Patches/LobbyViewSettingsPatch.cs index 89dfb6f..1557ef2 100644 --- a/Patches/LobbyViewSettingsPatch.cs +++ b/Patches/LobbyViewSettingsPatch.cs @@ -5,7 +5,7 @@ using UnityEngine; using Object = UnityEngine.Object; // https://github.com/Rabek009/MoreGamemodes/blob/master/Patches/LobbyViewSettingsPatch.cs -namespace HNSRevamped +namespace AmongUsRevamped { [HarmonyPatch(typeof(LobbyViewSettingsPane))] public class LobbyViewPatch diff --git a/Patches/NumberOptionsPatch.cs b/Patches/NumberOptionsPatch.cs index d442ebf..a7099da 100644 --- a/Patches/NumberOptionsPatch.cs +++ b/Patches/NumberOptionsPatch.cs @@ -1,6 +1,6 @@ using AmongUs.GameOptions; -namespace HNSRevamped; +namespace AmongUsRevamped; // https://github.com/astra1dev/AUnlocker/blob/main/src/OptionsPatches.cs diff --git a/Patches/OnGameStartedPatch.cs b/Patches/OnGameStartedPatch.cs index 2a4b2a8..0d49aa7 100644 --- a/Patches/OnGameStartedPatch.cs +++ b/Patches/OnGameStartedPatch.cs @@ -2,7 +2,7 @@ using InnerNet; using UnityEngine; -namespace HNSRevamped; +namespace AmongUsRevamped; [HarmonyPatch(typeof(AmongUsClient), nameof(AmongUsClient.CoStartGame))] internal class ApplyCustomImpostorCount @@ -24,43 +24,45 @@ internal class ApplyCustomImpostorCount } } - if (!Utils.isHideNSeek) return; - int seekersCount = Options.NumSeekers.GetInt(); - - int toAdd = Math.Max(0, seekersCount - 1); - - var candidates = new List(); - foreach (var p in PlayerControl.AllPlayerControls) + if (Utils.isHideNSeek) { - if (p.Data.Role.TeamType != RoleTeamTypes.Impostor && !p.Data.IsDead) - candidates.Add(p); - } + int seekersCount = Options.NumSeekers.GetInt(); - 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]); - } - - // 1st RpcSetRole forces the role on that user. 2nd is needed to allow them to kill. - for (int i = 0; i < toAdd; i++) - { - var player = candidates[i]; - - player.RpcSetRole(AmongUs.GameOptions.RoleTypes.Impostor, false); + int toAdd = Math.Max(0, seekersCount - 1); + var candidates = new List(); foreach (var p in PlayerControl.AllPlayerControls) { - if (p.Data.Role.TeamType == RoleTeamTypes.Impostor) + 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]); + } + + // 1st RpcSetRole forces the role on that user. 2nd is needed to allow them to kill. + for (int i = 0; i < toAdd; i++) + { + var player = candidates[i]; + + player.RpcSetRole(AmongUs.GameOptions.RoleTypes.Impostor, false); + + foreach (var p in PlayerControl.AllPlayerControls) { - new LateTask(() => + if (p.Data.Role.TeamType == RoleTeamTypes.Impostor) { - p.RpcSetRole(AmongUs.GameOptions.RoleTypes.Impostor, false); - }, 9f, "Secondary RPCSetRole"); + new LateTask(() => + { + p.RpcSetRole(AmongUs.GameOptions.RoleTypes.Impostor, false); + }, 9f, "Secondary RPCSetRole"); + } } } } diff --git a/Patches/PlayerControlPatches.cs b/Patches/PlayerControlPatches.cs index 2997c01..0a4393a 100644 --- a/Patches/PlayerControlPatches.cs +++ b/Patches/PlayerControlPatches.cs @@ -1,8 +1,10 @@ using AmongUs.Data; using AmongUs.GameOptions; +using Hazel; using InnerNet; +using System; -namespace HNSRevamped; +namespace AmongUsRevamped; [HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.FixedUpdate))] class FixedUpdateInGamePatch { @@ -10,19 +12,42 @@ class FixedUpdateInGamePatch { if (__instance == null || __instance.PlayerId == 255) return; + // 0Kc if (Options.Gamemode.GetValue() == 1 && !Utils.isHideNSeek && Main.NormalOptions.KillCooldown != 0.01f) { Main.NormalOptions.KillCooldown = 0.01f; - Main.NormalOptions.EmergencyCooldown = 0; - Main.NormalOptions.DiscussionTime = 0; + if (Options.NoKcdSettingsOverride.GetBool()) + { + Main.NormalOptions.EmergencyCooldown = 0; + Main.NormalOptions.DiscussionTime = 0; + Main.NormalOptions.VotingTime = 30; - Main.NormalOptions.NumCommonTasks = 0; - Main.NormalOptions.NumShortTasks = 1; - Main.NormalOptions.NumLongTasks = 0; + Main.NormalOptions.TaskBarMode = 0; + Main.NormalOptions.NumCommonTasks = 0; + Main.NormalOptions.NumShortTasks = 1; + Main.NormalOptions.NumLongTasks = 0; + } } - if (Options.Gamemode.GetValue() < 1 && Main.NormalOptions.KillCooldown <= 0.01f) + // SnS + if (Options.Gamemode.GetValue() == 2 && !Utils.isHideNSeek && Main.NormalOptions.KillCooldown != 2.5f) + { + Main.NormalOptions.KillCooldown = 2.5f; + + if (Options.SNSSettingsOverride.GetBool()) + { + Main.NormalOptions.NumEmergencyMeetings = 0; + + Main.NormalOptions.TaskBarMode = 0; + + Options.DisableSabotage.SetValue(1); + Options.DisableCloseDoor.SetValue(1); + Options.DisableReport.SetValue(1); + } + } + + if (Options.Gamemode.GetValue() == 0 && Main.NormalOptions.KillCooldown <= 0.01f) { Main.NormalOptions.KillCooldown = 25f; } @@ -55,10 +80,81 @@ class ReportDeadBodyPatch { if (!AmongUsClient.Instance.AmHost) return true; - if (target != null && Options.DisableReport.GetBool()) + if (Options.DisableReport.GetBool() && target != null) { + Logger.Info($" Stopped {__instance.Data.PlayerName} reporting the body of {target.PlayerName}", "ReportDeadBodyPatch"); return false; } else return true; } -} \ No newline at end of file +} + +[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.MurderPlayer))] +internal static class MurderPlayerPatch +{ + public static readonly Dictionary misfireCount = new(); + + public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)] PlayerControl target, [HarmonyArgument(1)] MurderResultFlags resultFlags, ref bool __state) + { + if (!AmongUsClient.Instance.AmHost) return; + + //2 = Shift and Seek + if (Options.Gamemode.GetValue() == 2 && !Utils.isHideNSeek) + { + if (!resultFlags.HasFlag(MurderResultFlags.Succeeded)) + return; + + byte playerId = __instance.Data.PlayerId; + + if (target.Data.PlayerId == __instance.shapeshiftTargetPlayerId) + { + Logger.Info($" {__instance.Data.PlayerName} correctly killed {target.Data.PlayerName} ", "SNSKillManager"); + } + else + { + if (!misfireCount.ContainsKey(playerId)) + misfireCount[playerId] = 0; + + misfireCount[playerId]++; + + __instance.RpcSetRole(RoleTypes.Crewmate); + __instance.isNew = true; + Logger.Info($" {__instance.Data.PlayerName} killed {target.Data.PlayerName} incorrectly and can't kill for {Options.CantKillTime.GetInt()}s", "SNSKillManager"); + Logger.SendInGame($" {__instance.Data.PlayerName} killed {target.Data.PlayerName}, incorrectly and can't kill for {Options.CantKillTime.GetInt()}s"); + + new LateTask(() => + { + __instance.isNew = false; + if (!__instance.Data.IsDead) {__instance.RpcSetRole(RoleTypes.Shapeshifter, false);} + }, Options.CantKillTime.GetInt(), "SNSResetRole"); + + if (misfireCount[__instance.Data.PlayerId] >= Options.MisfiresToSuicide.GetValue()) + { + __instance.RpcSetRole(RoleTypes.ImpostorGhost); + Logger.Info($" {__instance.Data.PlayerName} misfired {misfireCount[playerId]} times and suicided", "SNSKillManager"); + Logger.SendInGame($" {__instance.Data.PlayerName} misfired {misfireCount[playerId]} times and suicided"); + } + + } + } + } +} + +[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CheckShapeshift))] +internal static class CheckShapeshiftPatch +{ + + public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] PlayerControl target) + { + if (!AmongUsClient.Instance.AmHost) return true; + + // Canceling a Shapeshift freezes the player until they successfully Shapeshift again. Unavoidable game logic. + if (Options.Gamemode.GetValue() == 2 && !Utils.isHideNSeek && __instance.isNew) + { + Logger.Info($" {__instance.Data.PlayerName} shapeshifted during misfire cooldown, making the game temporarily freeze them.", "SNSShapeshiftManager"); + Logger.SendInGame($" {__instance.Data.PlayerName} shapeshifted during misfire cooldown, making the game temporarily freeze them."); + return false; + } + else return true; + } +} diff --git a/Patches/SabotagePatches.cs b/Patches/SabotagePatches.cs index 87e33ee..7556522 100644 --- a/Patches/SabotagePatches.cs +++ b/Patches/SabotagePatches.cs @@ -2,7 +2,7 @@ using InnerNet; using UnityEngine; -namespace HNSRevamped; +namespace AmongUsRevamped; [HarmonyPatch(typeof(SabotageSystemType), nameof(SabotageSystemType.UpdateSystem))] // SetInitialSabotageCooldown - set sabotage cooldown in start game public static class SabotageSystemTypeRepairDamagePatch diff --git a/Patches/TaskAssignPatch.cs b/Patches/TaskAssignPatch.cs index c811387..740ac95 100644 --- a/Patches/TaskAssignPatch.cs +++ b/Patches/TaskAssignPatch.cs @@ -2,7 +2,7 @@ using AmongUs.GameOptions; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Random = UnityEngine.Random; -namespace HNSRevamped; +namespace AmongUsRevamped; // https://github.com/Gurge44/EndlessHostRoles/blob/main/Patches/TaskAssignPatch.cs