From c5ed4698f08a3dece69d098c0b080e27299bb2b1 Mon Sep 17 00:00:00 2001 From: whichtwix Date: Sat, 6 Aug 2022 18:57:58 +0600 Subject: [PATCH 1/5] qol feature for reporting bodies --- source/Patches/CustomGameOptions.cs | 1 + source/Patches/CustomOption/Generate.cs | 2 ++ source/Patches/CustomRPC.cs | 4 ++- source/Patches/RpcHandling.cs | 7 ++++ source/Patches/reportmsg.cs | 46 +++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 source/Patches/reportmsg.cs diff --git a/source/Patches/CustomGameOptions.cs b/source/Patches/CustomGameOptions.cs index e0043485f..6ed02220d 100644 --- a/source/Patches/CustomGameOptions.cs +++ b/source/Patches/CustomGameOptions.cs @@ -133,6 +133,7 @@ public static class CustomGameOptions public static bool DeadSeeRoles => Generate.DeadSeeRoles.Get(); public static bool DisableLevels => Generate.DisableLevels.Get(); public static bool WhiteNameplates => Generate.WhiteNameplates.Get(); + public static bool Locationreports => Generate.Locationreports.Get(); public static bool SeeTasksDuringRound => Generate.SeeTasksDuringRound.Get(); public static bool SeeTasksDuringMeeting => Generate.SeeTasksDuringMeeting.Get(); public static bool SeeTasksWhenDead => Generate.SeeTasksWhenDead.Get(); diff --git a/source/Patches/CustomOption/Generate.cs b/source/Patches/CustomOption/Generate.cs index 31fcde3b1..8a5e6f934 100644 --- a/source/Patches/CustomOption/Generate.cs +++ b/source/Patches/CustomOption/Generate.cs @@ -84,6 +84,7 @@ public class Generate public static CustomToggleOption DeadSeeRoles; public static CustomToggleOption DisableLevels; public static CustomToggleOption WhiteNameplates; + public static CustomToggleOption Locationreports; public static CustomNumberOption VanillaGame; public static CustomNumberOption InitialCooldowns; public static CustomToggleOption ParallelMedScans; @@ -500,6 +501,7 @@ public static void GenerateAll() SkipButtonDisable = new CustomStringOption(num++, "Disable Meeting Skip Button", new[] { "No", "Emergency", "Always" }); DisableLevels = new CustomToggleOption(num++, "Disable Level Icons", false); WhiteNameplates = new CustomToggleOption(num++, "Disable Player Nameplates", false); + Locationreports = new CustomToggleOption(num++, "locations of body reports are displayed at the start of a meeting", false); RoleCountSettings = new CustomHeaderOption(num++, "Role Count Settings"); diff --git a/source/Patches/CustomRPC.cs b/source/Patches/CustomRPC.cs index bfd6ba968..813daac5f 100644 --- a/source/Patches/CustomRPC.cs +++ b/source/Patches/CustomRPC.cs @@ -150,6 +150,8 @@ public enum CustomRPC RemoveAllBodies, CheckMurder, - SubmergedFixOxygen + SubmergedFixOxygen, + + Sendchat } } diff --git a/source/Patches/RpcHandling.cs b/source/Patches/RpcHandling.cs index faab7bd42..90ab65dfd 100644 --- a/source/Patches/RpcHandling.cs +++ b/source/Patches/RpcHandling.cs @@ -1051,6 +1051,13 @@ public static void Postfix([HarmonyArgument(0)] byte callId, [HarmonyArgument(1) var setplayer = Utils.PlayerById(reader.ReadByte()); setplayer.transform.position = new Vector3(reader.ReadSingle(), reader.ReadSingle(), setplayer.transform.position.z); break; + case CustomRPC.Sendchat: + string report = reader.ReadString(); + if (PlayerControl.LocalPlayer.Data.IsDead == false) + { + DestroyableSingleton.Instance.Chat.AddChat(PlayerControl.LocalPlayer, report); + } + break; } } } diff --git a/source/Patches/reportmsg.cs b/source/Patches/reportmsg.cs new file mode 100644 index 000000000..ac8c51572 --- /dev/null +++ b/source/Patches/reportmsg.cs @@ -0,0 +1,46 @@ +using HarmonyLib; +using Hazel; + +namespace TownOfUs +{ + public class Reportmessage + { + public static string location; + + [HarmonyPatch(typeof(RoomTracker), nameof(RoomTracker.FixedUpdate))] + public class Recordlocation + { + [HarmonyPostfix] + public static void postfix(RoomTracker __instance) + { + if (__instance.text.transform.localPosition.y != -3.25f) + { + location = __instance.text.text; + } + else + { + string name = PlayerControl.LocalPlayer.name; + location = $"a hallway/outside, {name} where is the body?"; + } + } + } + [HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.CmdReportDeadBody))] + public class Sendchat + { + [HarmonyPostfix] + public static void postfix([HarmonyArgument(0)] GameData.PlayerInfo target) + { + string report = $"Body reported in: {location}"; + if (target != null && CustomGameOptions.Locationreports) + { + DestroyableSingleton.Instance.Chat.AddChat(PlayerControl.LocalPlayer, report); + var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, + (byte)CustomRPC.Sendchat, SendOption.Reliable, -1); + writer.Write(report); + AmongUsClient.Instance.FinishRpcImmediately(writer); + } + + } + } + } +} \ No newline at end of file From 7b0abfca4904190858ad58fd75445ecf11e79c88 Mon Sep 17 00:00:00 2001 From: whichtwix Date: Sat, 27 Aug 2022 10:42:22 +0600 Subject: [PATCH 2/5] merge x3 as i made some mistakes.. --- source/Patches/CustomOption/Generate.cs | 25 +++---------------------- source/Patches/RpcHandling.cs | 2 ++ 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/source/Patches/CustomOption/Generate.cs b/source/Patches/CustomOption/Generate.cs index d7452d123..13090c3c2 100644 --- a/source/Patches/CustomOption/Generate.cs +++ b/source/Patches/CustomOption/Generate.cs @@ -100,11 +100,11 @@ public class Generate public static CustomToggleOption DeadSeeRoles; public static CustomToggleOption DisableLevels; public static CustomToggleOption WhiteNameplates; - public static CustomToggleOption Locationreports; public static CustomNumberOption VanillaGame; public static CustomNumberOption InitialCooldowns; public static CustomToggleOption ParallelMedScans; public static CustomStringOption SkipButtonDisable; + public static CustomToggleOption Locationreports; public static CustomHeaderOption BetterPolusSettings; public static CustomToggleOption VentImprovements; @@ -522,33 +522,12 @@ public static void GenerateAll() TiebreakerOn = new CustomNumberOption(true, num++, MultiMenu.modifiers, "Tiebreaker", 0f, 0f, 100f, 10f, PercentFormat); - - CustomGameSettings = - new CustomHeaderOption(num++, "Custom Game Settings"); - ColourblindComms = new CustomToggleOption(num++, "Camouflaged Comms", false); - ImpostorSeeRoles = new CustomToggleOption(num++, "Impostors Can See The Roles Of Their Team", false); - DeadSeeRoles = - new CustomToggleOption(num++, "Dead Can See Everyone's Roles/Votes", false); - VanillaGame = new CustomNumberOption(num++, "Probability Of A Completely Vanilla Game", 0f, 0f, 100f, 5f, - PercentFormat); - InitialCooldowns = - new CustomNumberOption(num++, "Game Start Cooldowns", 10, 10, 30, 2.5f, CooldownFormat); - ParallelMedScans = new CustomToggleOption(num++, "Parallel Medbay Scans", false); - SkipButtonDisable = new CustomStringOption(num++, "Disable Meeting Skip Button", new[] { "No", "Emergency", "Always" }); - DisableLevels = new CustomToggleOption(num++, "Disable Level Icons", false); - WhiteNameplates = new CustomToggleOption(num++, "Disable Player Nameplates", false) - Locationreports = new CustomToggleOption(num++, "locations of body reports are displayed at the start of a meeting", false); - - RoleCountSettings = - new CustomHeaderOption(num++, "Role Count Settings"); - GameModeSettings = new CustomHeaderOption(num++, MultiMenu.main, "Game Mode Settings"); GameMode = new CustomStringOption(num++, MultiMenu.main, "Game Mode", new[] {"Classic", "All Any", "Killing Only"}); ClassicSettings = new CustomHeaderOption(num++, MultiMenu.main, "Classic Game Mode Settings"); - MinNeutralNonKillingRoles = new CustomNumberOption(num++, MultiMenu.main, "Min Neutral Non-Killing Roles", 1f, 0f, 5f, 1f); MaxNeutralNonKillingRoles = @@ -617,6 +596,8 @@ public static void GenerateAll() SkipButtonDisable = new CustomStringOption(num++, MultiMenu.main, "Disable Meeting Skip Button", new[] { "No", "Emergency", "Always" }); DisableLevels = new CustomToggleOption(num++, MultiMenu.main, "Disable Level Icons", false); WhiteNameplates = new CustomToggleOption(num++, MultiMenu.main, "Disable Player Nameplates", false); + Locationreports = new CustomToggleOption(num++, MultiMenu.main, "Locations of body reports are displayed in chat", false); + TaskTrackingSettings = new CustomHeaderOption(num++, MultiMenu.main, "Task Tracking Settings"); diff --git a/source/Patches/RpcHandling.cs b/source/Patches/RpcHandling.cs index 2dad060ed..9f78c5b48 100644 --- a/source/Patches/RpcHandling.cs +++ b/source/Patches/RpcHandling.cs @@ -1158,6 +1158,7 @@ public static void Postfix([HarmonyArgument(0)] byte callId, [HarmonyArgument(1) case CustomRPC.SetPos: var setplayer = Utils.PlayerById(reader.ReadByte()); setplayer.transform.position = new Vector3(reader.ReadSingle(), reader.ReadSingle(), setplayer.transform.position.z); + break; case CustomRPC.SetSettings: readByte = reader.ReadByte(); PlayerControl.GameOptions.MapId = readByte == byte.MaxValue ? (byte)0 : readByte; @@ -1173,6 +1174,7 @@ public static void Postfix([HarmonyArgument(0)] byte callId, [HarmonyArgument(1) { DestroyableSingleton.Instance.Chat.AddChat(PlayerControl.LocalPlayer, report); } + break; } } } From d1768f56e616ae6c86556e0e26038f705ec94f96 Mon Sep 17 00:00:00 2001 From: twix <91138333+whichtwix@users.noreply.github.com> Date: Fri, 6 Oct 2023 14:19:28 +0600 Subject: [PATCH 3/5] theese were removed --- source/Patches/CustomGameOptions.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/Patches/CustomGameOptions.cs b/source/Patches/CustomGameOptions.cs index e1c629cee..e4cc5b0b4 100644 --- a/source/Patches/CustomGameOptions.cs +++ b/source/Patches/CustomGameOptions.cs @@ -161,8 +161,6 @@ public static class CustomGameOptions public static bool ImpostorSeeRoles => Generate.ImpostorSeeRoles.Get(); public static bool DeadSeeRoles => Generate.DeadSeeRoles.Get(); - public static bool DisableLevels => Generate.DisableLevels.Get(); - public static bool WhiteNameplates => Generate.WhiteNameplates.Get(); public static bool Locationreports => Generate.Locationreports.Get(); public static bool HiddenRoles => Generate.HiddenRoles.Get(); @@ -378,4 +376,4 @@ public static class CustomGameOptions public static float IncreasedCooldownPerRevive => Generate.IncreasedCooldownPerRevive.Get(); public static int MaxReveals => (int)Generate.MaxReveals.Get(); } -} \ No newline at end of file +} From e14147dda0cf0053d31f864366dfc481169c44c5 Mon Sep 17 00:00:00 2001 From: twix <91138333+whichtwix@users.noreply.github.com> Date: Fri, 6 Oct 2023 14:22:20 +0600 Subject: [PATCH 4/5] finish removing --- source/Patches/CustomOption/Generate.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/Patches/CustomOption/Generate.cs b/source/Patches/CustomOption/Generate.cs index 4bc021234..f585236d9 100644 --- a/source/Patches/CustomOption/Generate.cs +++ b/source/Patches/CustomOption/Generate.cs @@ -781,8 +781,6 @@ public static void GenerateAll() ParallelMedScans = new CustomToggleOption(num++, MultiMenu.main, "Parallel Medbay Scans", false); SkipButtonDisable = new CustomStringOption(num++, MultiMenu.main, "Disable Meeting Skip Button", new[] { "No", "Emergency", "Always" }); - DisableLevels = new CustomToggleOption(num++, MultiMenu.main, "Disable Level Icons", false); - WhiteNameplates = new CustomToggleOption(num++, MultiMenu.main, "Disable Player Nameplates", false); Locationreports = new CustomToggleOption(num++, MultiMenu.main, "Locations of body reports are displayed in chat", false); HiddenRoles = new CustomToggleOption(num++, MultiMenu.main, "Enable Hidden Roles", true); @@ -1291,4 +1289,4 @@ public static void GenerateAll() UnderdogIncreasedKC = new CustomToggleOption(num++, MultiMenu.modifiers, "Increased Kill Cooldown When 2+ Imps", true); } } -} \ No newline at end of file +} From 63227fb058cbf39da331bb9a63f47edb2fa74f46 Mon Sep 17 00:00:00 2001 From: twix <91138333+whichtwix@users.noreply.github.com> Date: Fri, 6 Oct 2023 14:34:42 +0600 Subject: [PATCH 5/5] undate to utils method --- source/Patches/{reportmsg.cs => Reportmsg.cs} | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) rename source/Patches/{reportmsg.cs => Reportmsg.cs} (81%) diff --git a/source/Patches/reportmsg.cs b/source/Patches/Reportmsg.cs similarity index 81% rename from source/Patches/reportmsg.cs rename to source/Patches/Reportmsg.cs index ac8c51572..dac6d89bb 100644 --- a/source/Patches/reportmsg.cs +++ b/source/Patches/Reportmsg.cs @@ -34,13 +34,10 @@ public static void postfix([HarmonyArgument(0)] GameData.PlayerInfo target) if (target != null && CustomGameOptions.Locationreports) { DestroyableSingleton.Instance.Chat.AddChat(PlayerControl.LocalPlayer, report); - var writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, - (byte)CustomRPC.Sendchat, SendOption.Reliable, -1); - writer.Write(report); - AmongUsClient.Instance.FinishRpcImmediately(writer); + Utils.Rpc(CustomRPC.SendChat, report); } } } } -} \ No newline at end of file +}