From af900e4f2a9faccd49f29b0bfbbc4d78ca55efd3 Mon Sep 17 00:00:00 2001 From: Ape <155788660+ApeMV@users.noreply.github.com> Date: Thu, 18 Dec 2025 19:44:34 +0100 Subject: [PATCH] Fix: Friend overlap, zoom, bad option looping, kicking --- Modules/FixedUpdate.cs | 12 ++++ Modules/Zoom.cs | 126 ++++++++++++++++++---------------- Patches/ChatControlPatch.cs | 18 ++++- Patches/CredentialsPatch.cs | 10 +-- Patches/NumberOptionsPatch.cs | 6 +- 5 files changed, 105 insertions(+), 67 deletions(-) diff --git a/Modules/FixedUpdate.cs b/Modules/FixedUpdate.cs index 2685744..a2d9583 100644 --- a/Modules/FixedUpdate.cs +++ b/Modules/FixedUpdate.cs @@ -11,6 +11,18 @@ public static class FixedUpdate { public static void Postfix() { + GameObject n = GameObject.Find("NewRequestInactive"); + if (n != null) + { + n.SetActive(false); + } + + GameObject nr = GameObject.Find("NewRequest"); + if (nr != null) + { + nr.SetActive(false); + } + if (!AmongUsClient.Instance.AmHost) return; if (Utils.InGame && !Utils.IsMeeting && !ExileController.Instance) diff --git a/Modules/Zoom.cs b/Modules/Zoom.cs index dee2919..b95f552 100644 --- a/Modules/Zoom.cs +++ b/Modules/Zoom.cs @@ -7,93 +7,97 @@ namespace AmongUsRevamped; [HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))] public static class Zoom { - private static bool ResetButtons = false; + private const float DefaultZoom = 3.0f; + private const float MaxZoom = 18.0f; + private const float ZoomFactor = 1.2f; + private const float Epsilon = 0.01f; + + private static float LastZoom = DefaultZoom; + public static void Postfix() { - if (Utils.IsShip && !Utils.IsMeeting && Utils.IsCanMove && PlayerControl.LocalPlayer.Data.IsDead || Utils.IsLobby && Utils.IsCanMove) - { - if (Camera.main.orthographicSize > 3.0f) - ResetButtons = true; + bool canZoom = + (Utils.IsShip && !Utils.IsMeeting && Utils.IsCanMove && PlayerControl.LocalPlayer.Data.IsDead) + || (Utils.IsLobby && Utils.IsCanMove); - if (Input.mouseScrollDelta.y > 0) - { - if (Camera.main.orthographicSize > 3.0f) - { - SetZoomSize(times: false); - } - - } - if (Input.mouseScrollDelta.y < 0) - { - if (Utils.IsDead || Utils.IsFreePlay || Utils.IsLobby) - { - if (Camera.main.orthographicSize < 18.0f) - { - SetZoomSize(times: true); - } - } - } - Flag.NewFlag("Zoom"); - } - else + if (!canZoom) { - Flag.Run(() => - { - SetZoomSize(reset: true); - }, "Zoom"); + ResetZoom(); + return; } + + if (Input.mouseScrollDelta.y > 0) + ChangeZoom(1f / ZoomFactor); + + if (Input.mouseScrollDelta.y < 0 && (Utils.IsDead || Utils.IsFreePlay || Utils.IsLobby)) + ChangeZoom(ZoomFactor); } - private static void SetZoomSize(bool times = false, bool reset = false) + private static void ChangeZoom(float multiplier) { - var size = 1.5f; - if (!times) size = 1 / size; - if (reset) - { - Camera.main.orthographicSize = 3.0f; - HudManager.Instance.UICamera.orthographicSize = 3.0f; - HudManager.Instance.Chat.transform.localScale = Vector3.one; - if (Utils.IsMeeting) MeetingHud.Instance.transform.localScale = Vector3.one; - } - else - { - Camera.main.orthographicSize *= size; - HudManager.Instance.UICamera.orthographicSize *= size; - } - DestroyableSingleton.Instance?.ShadowQuad?.gameObject?.SetActive((reset || Camera.main.orthographicSize == 3.0f) && !Utils.IsDead); + float target = Camera.main.orthographicSize * multiplier; + target = Mathf.Clamp(target, DefaultZoom, MaxZoom); - if (ResetButtons) - { - ResolutionManager.ResolutionChanged.Invoke((float)Screen.width / Screen.height, Screen.width, Screen.height, Screen.fullScreen); - ResetButtons = false; - } + if (Mathf.Abs(target - DefaultZoom) < Epsilon) + target = DefaultZoom; + + ApplyZoom(target); } - public static void OnFixedUpdate() - => DestroyableSingleton.Instance?.ShadowQuad?.gameObject?.SetActive((Camera.main.orthographicSize == 3.0f) && !Utils.IsDead); + private static void ResetZoom() + { + ApplyZoom(DefaultZoom); + } + + private static void ApplyZoom(float size) + { + if (Mathf.Abs(size - LastZoom) < Epsilon) + return; + + LastZoom = size; + + Camera.main.orthographicSize = size; + HudManager.Instance.UICamera.orthographicSize = size; + + bool isDefault = Mathf.Abs(size - DefaultZoom) < Epsilon; + + DestroyableSingleton.Instance?.ShadowQuad?.gameObject + ?.SetActive(isDefault && !Utils.IsDead); + + ResolutionManager.ResolutionChanged.Invoke( + (float)Screen.width / Screen.height, + Screen.width, + Screen.height, + Screen.fullScreen + ); + } } public static class Flag { - private static readonly List OneTimeList = []; - private static readonly List FirstRunList = []; - public static void Run(Action action, string type, bool firstrun = false) + private static readonly List OneTimeList = new(); + private static readonly List FirstRunList = new(); + + public static void Run(Action action, string type, bool firstRun = false) { - if (OneTimeList.Contains(type) || (firstrun && !FirstRunList.Contains(type))) + if (OneTimeList.Contains(type) || (firstRun && !FirstRunList.Contains(type))) { - if (!FirstRunList.Contains(type)) FirstRunList.Add(type); + if (!FirstRunList.Contains(type)) + FirstRunList.Add(type); + OneTimeList.Remove(type); action(); } - } + public static void NewFlag(string type) { - if (!OneTimeList.Contains(type)) OneTimeList.Add(type); + if (!OneTimeList.Contains(type)) + OneTimeList.Add(type); } public static void DeleteFlag(string type) { - if (OneTimeList.Contains(type)) OneTimeList.Remove(type); + OneTimeList.Remove(type); } } \ No newline at end of file diff --git a/Patches/ChatControlPatch.cs b/Patches/ChatControlPatch.cs index a16fcc1..794c2fd 100644 --- a/Patches/ChatControlPatch.cs +++ b/Patches/ChatControlPatch.cs @@ -37,7 +37,7 @@ internal static class AddVotePatch { AmongUsClient.Instance.KickPlayer(target.Data.ClientId, false); - Logger.Info($" Kicked {target.Data.PlayerName}, {target.Data.FriendCode}", "VoteKick"); + Logger.Info($" Kicked {target.Data.PlayerName}, {target.Data.FriendCode}", "KickPatch"); } return false; @@ -52,4 +52,20 @@ internal static class CmdAddVotePatch if (!AmongUsClient.Instance.AmHost) return true; else return false; } +} + +[HarmonyPatch(typeof(BanMenu), nameof(BanMenu.SetVisible))] +internal static class BanMenuSetVisiblePatch +{ + public static bool Prefix(BanMenu __instance, bool show) + { + if (!AmongUsClient.Instance.AmHost) return true; + + show &= PlayerControl.LocalPlayer && PlayerControl.LocalPlayer.Data != null; + __instance.BanButton.gameObject.SetActive(true); + __instance.KickButton.gameObject.SetActive(true); + __instance.MenuButton.gameObject.SetActive(show); + + return false; + } } \ No newline at end of file diff --git a/Patches/CredentialsPatch.cs b/Patches/CredentialsPatch.cs index a125072..4bd046f 100644 --- a/Patches/CredentialsPatch.cs +++ b/Patches/CredentialsPatch.cs @@ -114,7 +114,9 @@ namespace AmongUsRevamped if (instance.name != "HNSR_SettingsText") { - instance.aspectPosition.DistanceFromEdge = !AmongUsClient.Instance.IsGameStarted ? instance.lobbyPos : instance.gamePos; + Vector3 pos = !AmongUsClient.Instance.IsGameStarted ? instance.lobbyPos : instance.gamePos; + pos.y += 0.1f; + instance.aspectPosition.DistanceFromEdge = pos; instance.text.alignment = TextAlignmentOptions.Center; instance.text.text = Sb.ToString(); } @@ -125,7 +127,7 @@ namespace AmongUsRevamped Sb.Clear(); - Sb.Append(Utils.IsLobby ? "\r\n" : ""); + Sb.Append(Utils.IsLobby ? "\r\n" : ""); Sb.Append(Main.CredentialsText); int ping = AmongUsClient.Instance.Ping; @@ -138,7 +140,7 @@ namespace AmongUsRevamped _ => "#ff4500" }; - Sb.Append(Utils.InGame ? " - " : "\r\n"); + Sb.Append(Utils.InGame ? " - " : "\r\n"); Sb.Append($"Ping: {ping}"); AppendSeparator(); Sb.Append($"Server: {Utils.GetRegionName()}"); @@ -162,7 +164,7 @@ namespace AmongUsRevamped return false; - void AppendSeparator() => Sb.Append(Utils.InGame ? " - " : " - "); + void AppendSeparator() => Sb.Append(Utils.InGame ? " - " : " - "); } private static class FpsSampler diff --git a/Patches/NumberOptionsPatch.cs b/Patches/NumberOptionsPatch.cs index a7099da..b68fdf9 100644 --- a/Patches/NumberOptionsPatch.cs +++ b/Patches/NumberOptionsPatch.cs @@ -9,6 +9,8 @@ public static class NumberOption_Increase { public static bool Prefix(NumberOption __instance) { + if (ModGameOptionsMenu.TabIndex >= 3) return true; + if (Utils.isHideNSeek || !Utils.isHideNSeek && __instance.Title != StringNames.GameNumImpostors && __instance.Title != StringNames.GamePlayerSpeed) { __instance.Value += __instance.Increment; @@ -26,6 +28,8 @@ public static class NumberOption_Decrease { public static bool Prefix(NumberOption __instance) { + if (ModGameOptionsMenu.TabIndex >= 3) return true; + if (Utils.isHideNSeek || !Utils.isHideNSeek && __instance.Title != StringNames.GameNumImpostors && __instance.Title != StringNames.GamePlayerSpeed) { __instance.Value -= __instance.Increment; @@ -45,7 +49,7 @@ public static class NumberOption_Initialize { if (Utils.isHideNSeek || !Utils.isHideNSeek && __instance.Title != StringNames.GameNumImpostors && __instance.Title != StringNames.GamePlayerSpeed) { - __instance.ValidRange = new FloatRange(-999f, 999f); + __instance.ValidRange = new FloatRange(-900f, 900f); } } }