From 321537b0bf04a437ded17be2373812ddc92229a8 Mon Sep 17 00:00:00 2001 From: Nova900 Date: Wed, 23 Feb 2022 04:33:31 +0100 Subject: [PATCH] Lawyer can have Jester as Client - Added option jesterCanBeLawyerClient. When active, Jester can be chosen as Client for the Lawyer. Lawyer steals victory from Jester when still alive and Jester voted out. Lawyer wins with Jester when dead and Jester voted out. Lawyer turns to Pursuer when Jester is normally killed. --- TheOtherRoles/CustomOptionHolder.cs | 2 ++ TheOtherRoles/Patches/EndGamePatch.cs | 33 +++++++++++--------- TheOtherRoles/Patches/RoleAssignmentPatch.cs | 5 +-- TheOtherRoles/RPC.cs | 10 ++++-- TheOtherRoles/TheOtherRoles.cs | 2 ++ 5 files changed, 32 insertions(+), 20 deletions(-) diff --git a/TheOtherRoles/CustomOptionHolder.cs b/TheOtherRoles/CustomOptionHolder.cs index 97ab897fa..42941aa94 100644 --- a/TheOtherRoles/CustomOptionHolder.cs +++ b/TheOtherRoles/CustomOptionHolder.cs @@ -68,6 +68,7 @@ public class CustomOptionHolder { public static CustomOption jesterSpawnRate; public static CustomOption jesterCanCallEmergency; public static CustomOption jesterHasImpostorVision; + public static CustomOption jesterCanBeLawyerClient; public static CustomOption arsonistSpawnRate; public static CustomOption arsonistCooldown; @@ -349,6 +350,7 @@ public static void Load() { jesterSpawnRate = CustomOption.Create(60, cs(Jester.color, "Jester"), rates, null, true); jesterCanCallEmergency = CustomOption.Create(61, "Jester Can Call Emergency Meeting", true, jesterSpawnRate); jesterHasImpostorVision = CustomOption.Create(62, "Jester Has Impostor Vision", false, jesterSpawnRate); + jesterCanBeLawyerClient = CustomOption.Create(8999, "Jester Can Be Client Of Lawyer", false, jesterSpawnRate); arsonistSpawnRate = CustomOption.Create(290, cs(Arsonist.color, "Arsonist"), rates, null, true); arsonistCooldown = CustomOption.Create(291, "Arsonist Cooldown", 12.5f, 2.5f, 60f, 2.5f, arsonistSpawnRate); diff --git a/TheOtherRoles/Patches/EndGamePatch.cs b/TheOtherRoles/Patches/EndGamePatch.cs index f59e5e322..a53e4cf47 100644 --- a/TheOtherRoles/Patches/EndGamePatch.cs +++ b/TheOtherRoles/Patches/EndGamePatch.cs @@ -189,22 +189,25 @@ public static void Postfix(AmongUsClient __instance, [HarmonyArgument(0)]ref End } // Possible Additional winner: Lawyer - if (!lawyerSoloWin && Lawyer.lawyer != null && Lawyer.target != null && !Lawyer.target.Data.IsDead) { - WinningPlayerData winningClient = null; - foreach (WinningPlayerData winner in TempData.winners) { - if (winner.PlayerName == Lawyer.target.Data.PlayerName) - winningClient = winner; - } - if (winningClient != null) { // The Lawyer wins if the client is winning (and alive, but if he wasn't the Lawyer shouldn't exist anymore) - if (!TempData.winners.ToArray().Any(x => x.PlayerName == Lawyer.lawyer.Data.PlayerName)) - TempData.winners.Add(new WinningPlayerData(Lawyer.lawyer.Data)); - if (!Lawyer.lawyer.Data.IsDead) { // The Lawyer steals the clients win - TempData.winners.Remove(winningClient); - AdditionalTempData.additionalWinConditions.Add(WinCondition.AdditionalLawyerStolenWin); - } else { // The Lawyer wins together with the client - AdditionalTempData.additionalWinConditions.Add(WinCondition.AdditionalLawyerBonusWin); + if (!lawyerSoloWin && Lawyer.lawyer != null && Lawyer.target != null) { + if (!Lawyer.target.Data.IsDead || (Jester.jester != null && Lawyer.target == Jester.jester)) { + WinningPlayerData winningClient = null; + foreach (WinningPlayerData winner in TempData.winners) { + if (winner.PlayerName == Lawyer.target.Data.PlayerName) + winningClient = winner; } - } + if (winningClient != null) { // The Lawyer wins if the client is winning (and alive, but if he wasn't the Lawyer shouldn't exist anymore) + if (!TempData.winners.ToArray().Any(x => x.PlayerName == Lawyer.lawyer.Data.PlayerName)) + TempData.winners.Add(new WinningPlayerData(Lawyer.lawyer.Data)); + if (!Lawyer.lawyer.Data.IsDead) { // The Lawyer steals the clients win + TempData.winners.Remove(winningClient); + AdditionalTempData.additionalWinConditions.Add(WinCondition.AdditionalLawyerStolenWin); + } + else { // The Lawyer wins together with the client + AdditionalTempData.additionalWinConditions.Add(WinCondition.AdditionalLawyerBonusWin); + } + } + } } // Possible Additional winner: Pursuer diff --git a/TheOtherRoles/Patches/RoleAssignmentPatch.cs b/TheOtherRoles/Patches/RoleAssignmentPatch.cs index f1f7ae6d5..3208ef4e9 100644 --- a/TheOtherRoles/Patches/RoleAssignmentPatch.cs +++ b/TheOtherRoles/Patches/RoleAssignmentPatch.cs @@ -367,8 +367,9 @@ private static void assignRoleTargets(RoleAssignmentData data) { if (Lawyer.lawyer != null) { var possibleTargets = new List(); foreach (PlayerControl p in PlayerControl.AllPlayerControls) { - if (!p.Data.IsDead && !p.Data.Disconnected && p != Lovers.lover1 && p != Lovers.lover2 && (p.Data.Role.IsImpostor || p == Jackal.jackal)) - possibleTargets.Add(p); + // Only allow Jester as client if setting is true + if (!p.Data.IsDead && !p.Data.Disconnected && p != Lovers.lover1 && p != Lovers.lover2 && (p.Data.Role.IsImpostor || p == Jackal.jackal || (p == Jester.jester && Jester.canBeLawyerClient))) + possibleTargets.Add(p); } if (possibleTargets.Count == 0) { MessageWriter w = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.LawyerPromotesToPursuer, Hazel.SendOption.Reliable, -1); diff --git a/TheOtherRoles/RPC.cs b/TheOtherRoles/RPC.cs index a03d71fe1..d37511649 100644 --- a/TheOtherRoles/RPC.cs +++ b/TheOtherRoles/RPC.cs @@ -761,13 +761,17 @@ public static void lawyerSetTarget(byte playerId) { public static void lawyerPromotesToPursuer() { PlayerControl player = Lawyer.lawyer; PlayerControl client = Lawyer.target; + + // Don't promote to pursuer if target is jester and jester was exiled + if (client != null && client == Jester.jester && ExileController.Instance.exiled != null && ExileController.Instance.exiled.PlayerId == Jester.jester.PlayerId) return; + Lawyer.clearAndReload(); Pursuer.pursuer = player; if (player.PlayerId == PlayerControl.LocalPlayer.PlayerId && client != null) { - Transform playerInfoTransform = client.nameText.transform.parent.FindChild("Info"); - TMPro.TextMeshPro playerInfo = playerInfoTransform != null ? playerInfoTransform.GetComponent() : null; - if (playerInfo != null) playerInfo.text = ""; + Transform playerInfoTransform = client.nameText.transform.parent.FindChild("Info"); + TMPro.TextMeshPro playerInfo = playerInfoTransform != null ? playerInfoTransform.GetComponent() : null; + if (playerInfo != null) playerInfo.text = ""; } } diff --git a/TheOtherRoles/TheOtherRoles.cs b/TheOtherRoles/TheOtherRoles.cs index c8519f4c5..f33ee025a 100644 --- a/TheOtherRoles/TheOtherRoles.cs +++ b/TheOtherRoles/TheOtherRoles.cs @@ -70,12 +70,14 @@ public static class Jester { public static bool triggerJesterWin = false; public static bool canCallEmergency = true; public static bool hasImpostorVision = false; + public static bool canBeLawyerClient = false; public static void clearAndReload() { jester = null; triggerJesterWin = false; canCallEmergency = CustomOptionHolder.jesterCanCallEmergency.getBool(); hasImpostorVision = CustomOptionHolder.jesterHasImpostorVision.getBool(); + canBeLawyerClient = CustomOptionHolder.jesterCanBeLawyerClient.getBool(); } }