From 73929cc189937d4576e83f4cf7b5a90cf8dbffe1 Mon Sep 17 00:00:00 2001 From: Ape <155788660+ApeMV@users.noreply.github.com> Date: Mon, 15 Dec 2025 18:53:23 +0100 Subject: [PATCH] Fixes & Settings in preparation for Shift And Seek --- HNSRevamped.cs | 2 -- Modules/CustomOptionsHolder.cs | 34 +++++++++++++++++++++-- Modules/Zoom.cs | 2 +- Patches/ClientOptionsPatch.cs | 4 --- Patches/NumberOptionsPatch.cs | 23 +++------------- Patches/PlayerControlPatches.cs | 32 ++++++++++++++++++++++ Patches/SabotagePatches.cs | 48 +++++++++++++++++++++++++++++++++ 7 files changed, 116 insertions(+), 29 deletions(-) create mode 100644 Patches/SabotagePatches.cs diff --git a/HNSRevamped.cs b/HNSRevamped.cs index 016271d..64812b4 100644 --- a/HNSRevamped.cs +++ b/HNSRevamped.cs @@ -25,7 +25,6 @@ public partial class Main : BasePlugin public static ConfigEntry AutoStart { get; private set; } public static ConfigEntry DarkTheme { get; private set; } public static ConfigEntry LobbyMusic { get; private set; } - public static ConfigEntry NoKcdMode { get; private set; } public static NormalGameOptionsV10 NormalOptions => GameOptionsManager.Instance != null ? GameOptionsManager.Instance.currentNormalGameOptions : null; public static bool HasArgumentException; @@ -68,7 +67,6 @@ public partial class Main : BasePlugin AutoStart = Config.Bind("Client Options", "Auto Start", false); DarkTheme = Config.Bind("Client Options", "Dark Theme", true); LobbyMusic = Config.Bind("Client Options", "Lobby Music", false); - NoKcdMode = Config.Bind("Client Options", "0 Kill Cooldown", false); BanManager.Init(); diff --git a/Modules/CustomOptionsHolder.cs b/Modules/CustomOptionsHolder.cs index 5b552cb..e52d6e2 100644 --- a/Modules/CustomOptionsHolder.cs +++ b/Modules/CustomOptionsHolder.cs @@ -21,7 +21,16 @@ namespace HNSRevamped taskOptionsLoad.Wait(); } + public static readonly string[] gameModes = + { + "None", "0 Kill Cooldown", "Shift And Seek" + }; + //System + public static OptionItem Gamemode; + + public static OptionItem TabGroupMain; + public static OptionItem KickLowLevelPlayer; public static OptionItem TempBanLowLevelPlayer; @@ -39,6 +48,11 @@ namespace HNSRevamped public static OptionItem NoGameEnd; //Mod + public static OptionItem DisableSabotage; + public static OptionItem DisableCloseDoor; + + public static OptionItem DisableReport; + public static OptionItem OverrideTaskSettings; public static OptionItem AllPlayersSameTasks; @@ -156,7 +170,13 @@ namespace HNSRevamped { if (IsLoaded) return; - //System Settings + Gamemode = StringOptionItem.Create(1, "Gamemode", gameModes, 0, TabGroup.SystemSettings, false) + .SetColor(Color.green) + .SetHeader(true); + + TabGroupMain = TextOptionItem.Create(2, "Main", TabGroup.SystemSettings) + .SetColor(Color.yellow); + KickLowLevelPlayer = IntegerOptionItem.Create(60050, "Kick Players Under Level", new(0, 100, 1), 0, TabGroup.SystemSettings, false) .SetValueFormat(OptionFormat.Level); TempBanLowLevelPlayer = BooleanOptionItem.Create(60051, "Ban Instead Of Kick", false, TabGroup.SystemSettings, false) @@ -174,7 +194,7 @@ namespace HNSRevamped .SetValueFormat(OptionFormat.Seconds); WaitAutoStart = IntegerOptionItem.Create(44421, "AutoStart After", new(10, 600, 10), 5, TabGroup.SystemSettings, false) .SetValueFormat(OptionFormat.Seconds); - PlayerAutoStart = IntegerOptionItem.Create(44422, "PlayerAutoStart", new(1, 15, 1), 5, TabGroup.SystemSettings, false); + PlayerAutoStart = IntegerOptionItem.Create(44422, "Players Needed To Start", new(1, 15, 1), 5, TabGroup.SystemSettings, false); NoGameEnd = BooleanOptionItem.Create(60380, "No Game End", false, TabGroup.SystemSettings, false) .SetColor(Color.red) @@ -187,6 +207,16 @@ namespace HNSRevamped .SetHeader(true); // Mod Settings + DisableSabotage = BooleanOptionItem.Create(60565, "Disable Critical Sabotages", false, TabGroup.ModSettings, false) + .SetColor(new Color32(255, 153, 153, byte.MaxValue)) + .SetHeader(true); + DisableCloseDoor = BooleanOptionItem.Create(60566, "Disable Door Sabotages", false, TabGroup.ModSettings, false) + .SetColor(new Color32(255, 153, 153, byte.MaxValue)); + DisableReport = BooleanOptionItem.Create(60520, "Disable Body Reports", false, TabGroup.ModSettings, false) + .SetColor(new Color32(255, 153, 153, byte.MaxValue)); + + + OverrideTaskSettings = BooleanOptionItem.Create(22998, "<#ffd>Ove<#ffb>rri<#ff9>de T<#ffb>ask <#ffd>Set<#ffb>tin<#ff9>gs", false, TabGroup.ModSettings, false) .SetColor(new Color32(239, 89, 175, byte.MaxValue)) .SetHeader(true); diff --git a/Modules/Zoom.cs b/Modules/Zoom.cs index 60775c4..66e016c 100644 --- a/Modules/Zoom.cs +++ b/Modules/Zoom.cs @@ -46,7 +46,7 @@ public static class Zoom private static void SetZoomSize(bool times = false, bool reset = false) { - var size = 1.2f; + var size = 1.5f; if (!times) size = 1 / size; if (reset) { diff --git a/Patches/ClientOptionsPatch.cs b/Patches/ClientOptionsPatch.cs index 0bc07a6..8f4a0f0 100644 --- a/Patches/ClientOptionsPatch.cs +++ b/Patches/ClientOptionsPatch.cs @@ -15,7 +15,6 @@ namespace HNSRevamped private static ClientOptionItem AutoStart; private static ClientOptionItem DarkTheme; private static ClientOptionItem LobbyMusic; - private static ClientOptionItem NoKcdMode; public static void Postfix(OptionsMenuBehaviour __instance) { @@ -66,9 +65,6 @@ namespace HNSRevamped if (LobbyMusic == null || LobbyMusic.ToggleButton == null) LobbyMusic = ClientOptionItem.Create("Lobby Music", Main.LobbyMusic, __instance); - - if (NoKcdMode == null || NoKcdMode.ToggleButton == null) - NoKcdMode = ClientOptionItem.Create("0 Kill Cooldown", Main.NoKcdMode, __instance); } } diff --git a/Patches/NumberOptionsPatch.cs b/Patches/NumberOptionsPatch.cs index 7efc2ad..d442ebf 100644 --- a/Patches/NumberOptionsPatch.cs +++ b/Patches/NumberOptionsPatch.cs @@ -9,7 +9,7 @@ public static class NumberOption_Increase { public static bool Prefix(NumberOption __instance) { - if (Utils.isHideNSeek || !Utils.isHideNSeek && __instance.TitleText.text != "# Impostors" && __instance.TitleText.text != "Player Speed") + if (Utils.isHideNSeek || !Utils.isHideNSeek && __instance.Title != StringNames.GameNumImpostors && __instance.Title != StringNames.GamePlayerSpeed) { __instance.Value += __instance.Increment; __instance.UpdateValue(); @@ -26,7 +26,7 @@ public static class NumberOption_Decrease { public static bool Prefix(NumberOption __instance) { - if (Utils.isHideNSeek || !Utils.isHideNSeek && __instance.TitleText.text != "# Impostors" && __instance.TitleText.text != "Player Speed") + if (Utils.isHideNSeek || !Utils.isHideNSeek && __instance.Title != StringNames.GameNumImpostors && __instance.Title != StringNames.GamePlayerSpeed) { __instance.Value -= __instance.Increment; __instance.UpdateValue(); @@ -43,26 +43,9 @@ public static class NumberOption_Initialize { public static void Postfix(NumberOption __instance) { - if (Utils.isHideNSeek || !Utils.isHideNSeek && __instance.TitleText.text != "# Impostors" && __instance.TitleText.text != "Player Speed") + if (Utils.isHideNSeek || !Utils.isHideNSeek && __instance.Title != StringNames.GameNumImpostors && __instance.Title != StringNames.GamePlayerSpeed) { __instance.ValidRange = new FloatRange(-999f, 999f); } - - if (Main.NoKcdMode.Value && !Utils.isHideNSeek) - { - Main.NormalOptions.KillCooldown = 0.01f; - - Main.NormalOptions.EmergencyCooldown = 0; - Main.NormalOptions.DiscussionTime = 0; - - Main.NormalOptions.NumCommonTasks = 0; - Main.NormalOptions.NumShortTasks = 1; - Main.NormalOptions.NumLongTasks = 0; - } - - if (!Main.NoKcdMode.Value && Main.NormalOptions.KillCooldown <= 0.01f) - { - Main.NormalOptions.KillCooldown = 25f; - } } } diff --git a/Patches/PlayerControlPatches.cs b/Patches/PlayerControlPatches.cs index 4c53067..2997c01 100644 --- a/Patches/PlayerControlPatches.cs +++ b/Patches/PlayerControlPatches.cs @@ -10,6 +10,23 @@ class FixedUpdateInGamePatch { if (__instance == null || __instance.PlayerId == 255) return; + 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; + + Main.NormalOptions.NumCommonTasks = 0; + Main.NormalOptions.NumShortTasks = 1; + Main.NormalOptions.NumLongTasks = 0; + } + + if (Options.Gamemode.GetValue() < 1 && Main.NormalOptions.KillCooldown <= 0.01f) + { + Main.NormalOptions.KillCooldown = 25f; + } + if (AmongUsClient.Instance.AmHost) { if (__instance.Data.PlayerLevel != 0 && __instance.Data.PlayerLevel < Options.KickLowLevelPlayer.GetInt() && __instance.Data.ClientId != AmongUsClient.Instance.HostId) @@ -29,4 +46,19 @@ class FixedUpdateInGamePatch } } } +} + +[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.ReportDeadBody))] +class ReportDeadBodyPatch +{ + public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] NetworkedPlayerInfo target) + { + if (!AmongUsClient.Instance.AmHost) return true; + + if (target != null && Options.DisableReport.GetBool()) + { + return false; + } + else return true; + } } \ No newline at end of file diff --git a/Patches/SabotagePatches.cs b/Patches/SabotagePatches.cs new file mode 100644 index 0000000..87e33ee --- /dev/null +++ b/Patches/SabotagePatches.cs @@ -0,0 +1,48 @@ +using Hazel; +using InnerNet; +using UnityEngine; + +namespace HNSRevamped; + +[HarmonyPatch(typeof(SabotageSystemType), nameof(SabotageSystemType.UpdateSystem))] // SetInitialSabotageCooldown - set sabotage cooldown in start game +public static class SabotageSystemTypeRepairDamagePatch +{ + private static bool Prefix([HarmonyArgument(0)] PlayerControl player, [HarmonyArgument(1)] MessageReader msgReader) + { + if (!AmongUsClient.Instance.AmHost) return true; + + byte amount; + { + var newReader = MessageReader.Get(msgReader); + amount = newReader.ReadByte(); + newReader.Recycle(); + } + var Sabo = (SystemTypes)amount; + + Logger.Info($" {player.Data.PlayerName} is trying to sabotage: {Sabo}", "SabotageCheck"); + if (Options.DisableSabotage.GetBool()) + { + Logger.Info($" Sabotage {Sabo} by: {player.Data.PlayerName} was blocked", "SabotageCheck"); + return false; + } + else return true; + } +} + +[HarmonyPatch(typeof(ShipStatus), nameof(ShipStatus.CloseDoorsOfType))] +class ShipStatusCloseDoorsPatch +{ + public static bool Prefix(SystemTypes room) + { + if (!AmongUsClient.Instance.AmHost) return true; + + Logger.Info($" Trying to close the door in: {room}", "DoorCheck"); + + if (Options.DisableCloseDoor.GetBool()) + { + Logger.Info($" Door sabotage in: {room} was blocked", "DoorCheck"); + return false; + } + else return true; + } +} \ No newline at end of file