From a172f97696a46d50c54be91f212624a74e698b29 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Tue, 24 Mar 2026 23:06:46 -0500 Subject: [PATCH] Disable sabotaging locally as host --- src/Managers/NetworkManager.cs | 21 ----------- .../Gameplay/Ship/DisableSabotagePatch.cs | 37 +++++++++++++++++++ 2 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 src/Patches/Gameplay/Ship/DisableSabotagePatch.cs diff --git a/src/Managers/NetworkManager.cs b/src/Managers/NetworkManager.cs index 590b9ac..a8e2b80 100644 --- a/src/Managers/NetworkManager.cs +++ b/src/Managers/NetworkManager.cs @@ -489,27 +489,6 @@ internal static class NetworkManager [HarmonyPatch] internal static class MessageReaderUpdateSystemPatch { - [HarmonyPatch(typeof(ShipStatus), nameof(ShipStatus.UpdateSystem), typeof(SystemTypes), typeof(PlayerControl), typeof(byte))] - [HarmonyPrefix] - internal static bool ShipStatus_UpdateSystemLocal_Prefix(SystemTypes systemType, PlayerControl player, byte amount) - { - if (!GameState.IsFreePlay) return true; - - MessageWriter messageWriter = MessageWriter.Get(0); - messageWriter.Write(amount); - MessageReader messageReader = MessageReader.Get(messageWriter.ToByteArray(false)); - messageWriter.Recycle(); - - if (BetterAntiCheat.RpcUpdateSystemCheck(player, systemType, messageReader) != true) - { - messageReader.Recycle(); - return false; - } - messageReader.Recycle(); - - return true; - } - [HarmonyPatch(typeof(ShipStatus), nameof(ShipStatus.UpdateSystem), typeof(SystemTypes), typeof(PlayerControl), typeof(MessageReader))] [HarmonyPrefix] internal static bool ShipStatus_UpdateSystem_Prefix(SystemTypes systemType, PlayerControl player, MessageReader msgReader) diff --git a/src/Patches/Gameplay/Ship/DisableSabotagePatch.cs b/src/Patches/Gameplay/Ship/DisableSabotagePatch.cs new file mode 100644 index 0000000..ce0d200 --- /dev/null +++ b/src/Patches/Gameplay/Ship/DisableSabotagePatch.cs @@ -0,0 +1,37 @@ +using BetterAmongUs.Helpers; +using BetterAmongUs.Modules; +using BetterAmongUs.Patches.Gameplay.UI.Settings; +using HarmonyLib; + +namespace BetterAmongUs.Patches.Gameplay.Ship; + +[HarmonyPatch] +internal static class DisableSabotagePatch +{ + [HarmonyPatch(typeof(MapRoom), nameof(MapRoom.SabotageReactor))] + [HarmonyPatch(typeof(MapRoom), nameof(MapRoom.SabotageHeli))] + [HarmonyPatch(typeof(MapRoom), nameof(MapRoom.SabotageComms))] + [HarmonyPatch(typeof(MapRoom), nameof(MapRoom.SabotageOxygen))] + [HarmonyPatch(typeof(MapRoom), nameof(MapRoom.SabotageLights))] + [HarmonyPatch(typeof(MapRoom), nameof(MapRoom.SabotageSeismic))] + [HarmonyPatch(typeof(MapRoom), nameof(MapRoom.SabotageMushroomMixup))] + [HarmonyPrefix] + internal static bool MapRoom_Sabotage_Prefix() + { + if (GameState.IsHost) + { + if (BetterGameSettings.DisableSabotages.GetBool()) + return false; + + if (BetterGameSettings.DisableSabotagesForDead.GetBool()) + { + if (!PlayerControl.LocalPlayer.IsAlive()) + { + return false; + } + } + } + + return true; + } +}