From 1595904d29145d6d388827499b02c98ed2e6da46 Mon Sep 17 00:00:00 2001 From: twix <91138333+whichtwix@users.noreply.github.com> Date: Wed, 24 Apr 2024 11:01:55 +0600 Subject: [PATCH 1/3] fungle changes --- source/Patches/MushroomMixup.cs | 67 +++++++++++++++++++++++ source/Patches/Roles/Cultist/Chameleon.cs | 1 + source/Patches/Roles/Glitch.cs | 3 +- source/Patches/Roles/Morphling.cs | 1 + source/Patches/Roles/Swooper.cs | 1 + source/Patches/Roles/Venerer.cs | 1 + source/Patches/RpcHandling.cs | 2 +- source/Patches/SizePatch.cs | 2 +- source/Patches/Utils.cs | 5 ++ 9 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 source/Patches/MushroomMixup.cs diff --git a/source/Patches/MushroomMixup.cs b/source/Patches/MushroomMixup.cs new file mode 100644 index 000000000..4c7ee13c5 --- /dev/null +++ b/source/Patches/MushroomMixup.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using HarmonyLib; +using Reactor.Utilities.Extensions; +using TownOfUs.Roles; +using TownOfUs.Roles.Cultist; + +namespace TownOfUs.Patches +{ + [HarmonyPatch] + + public class MushroomMixupPatch + { + [HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.AddSystemTask))] + [HarmonyPostfix] + + public static void Postfix(ref SystemTypes system) + { + if (system == SystemTypes.MushroomMixupSabotage) + { + foreach (Glitch glitch in Role.GetRoles(RoleEnum.Glitch).Cast()) + { + glitch.LastMimic = DateTime.UtcNow; + glitch.IsUsingMimic = false; + glitch.MimicTarget = null; + Utils.Unmorph(glitch.Player); + } + ResetAbilities(); + } + } + + [HarmonyPatch(typeof(MushroomMixupSabotageSystem), nameof(MushroomMixupSabotageSystem.GenerateRandomOutfit))] + [HarmonyPostfix] + + public static void Postfix(MushroomMixupSabotageSystem __instance, ref MushroomMixupSabotageSystem.CondensedOutfit __result) + { + List list = [.. __instance.cachedOutfitsByPlayerId.keys]; + list.Remove(PlayerControl.LocalPlayer.PlayerId); + + while (__result.ColorPlayerId == 34) + { + __result.ColorPlayerId = list.Random(); + } + } + + public static void ResetAbilities() + { + foreach (Morphling Morphling in Role.GetRoles(RoleEnum.Morphling).Cast()) + { + Morphling.Unmorph(); + } + foreach (Swooper Swooper in Role.GetRoles(RoleEnum.Swooper).Cast()) + { + Swooper.UnSwoop(); + } + foreach (Venerer Venerer in Role.GetRoles(RoleEnum.Venerer).Cast()) + { + Venerer.StopAbility(); + } + foreach (Chameleon Chameleon in Role.GetRoles(RoleEnum.Chameleon).Cast()) + { + Chameleon.UnSwoop(); + } + } + } +} \ No newline at end of file diff --git a/source/Patches/Roles/Cultist/Chameleon.cs b/source/Patches/Roles/Cultist/Chameleon.cs index ce2f90bb5..8e1aa6076 100644 --- a/source/Patches/Roles/Cultist/Chameleon.cs +++ b/source/Patches/Roles/Cultist/Chameleon.cs @@ -65,6 +65,7 @@ public void Swoop() public void UnSwoop() { Enabled = false; + TimeRemaining = 0f; LastSwooped = DateTime.UtcNow; Utils.Unmorph(Player); Player.myRend().color = Color.white; diff --git a/source/Patches/Roles/Glitch.cs b/source/Patches/Roles/Glitch.cs index 108ed1617..eac06c666 100644 --- a/source/Patches/Roles/Glitch.cs +++ b/source/Patches/Roles/Glitch.cs @@ -454,7 +454,8 @@ public static IEnumerator Mimic(Glitch __instance, PlayerControl mimicPlayer) $"{__instance.ColorString}Mimicking {mimicPlayer.Data.PlayerName} ({CustomGameOptions.MimicDuration - Math.Round(totalMimickTime)}s)"; if (totalMimickTime > CustomGameOptions.MimicDuration || PlayerControl.LocalPlayer.Data.IsDead || - AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Ended) + AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Ended + || Utils.HasTask(TaskTypes.MushroomMixupSabotage)) { PlayerControl.LocalPlayer.myTasks.Remove(mimicText); //System.Console.WriteLine("Unsetting mimic"); diff --git a/source/Patches/Roles/Morphling.cs b/source/Patches/Roles/Morphling.cs index 8938482b9..400c406ed 100644 --- a/source/Patches/Roles/Morphling.cs +++ b/source/Patches/Roles/Morphling.cs @@ -55,6 +55,7 @@ public void Unmorph() { MorphedPlayer = null; Utils.Unmorph(Player); + TimeRemaining = 0f; LastMorphed = DateTime.UtcNow; } diff --git a/source/Patches/Roles/Swooper.cs b/source/Patches/Roles/Swooper.cs index dbf19555c..ee5aa1a6e 100644 --- a/source/Patches/Roles/Swooper.cs +++ b/source/Patches/Roles/Swooper.cs @@ -79,6 +79,7 @@ public void Swoop() public void UnSwoop() { Enabled = false; + TimeRemaining = 0f; LastSwooped = DateTime.UtcNow; if (PlayerControl.LocalPlayer.Is(RoleEnum.Aurial) && !Role.GetRole(PlayerControl.LocalPlayer).NormalVision) return; Utils.Unmorph(Player); diff --git a/source/Patches/Roles/Venerer.cs b/source/Patches/Roles/Venerer.cs index 2e6aa5277..e7b320c32 100644 --- a/source/Patches/Roles/Venerer.cs +++ b/source/Patches/Roles/Venerer.cs @@ -78,6 +78,7 @@ public void Ability() public void StopAbility() { Enabled = false; + TimeRemaining = 0f; LastCamouflaged = DateTime.UtcNow; if (!CamouflageUnCamouflage.IsCamoed) Utils.Unmorph(Player); } diff --git a/source/Patches/RpcHandling.cs b/source/Patches/RpcHandling.cs index c74a2c663..e02c41aca 100644 --- a/source/Patches/RpcHandling.cs +++ b/source/Patches/RpcHandling.cs @@ -1316,7 +1316,7 @@ public static void Postfix() if (CustomGameOptions.SeerOn > 0) CrewmateRoles.Add((typeof(Seer), CustomGameOptions.SeerOn, false)); - if (CustomGameOptions.SpyOn > 0) + if (CustomGameOptions.SpyOn > 0 && GameOptionsManager.Instance.currentNormalGameOptions.MapId != 5) CrewmateRoles.Add((typeof(Spy), CustomGameOptions.SpyOn, false)); if (CustomGameOptions.SnitchOn > 0) diff --git a/source/Patches/SizePatch.cs b/source/Patches/SizePatch.cs index 2bd35e04f..adffa9e67 100644 --- a/source/Patches/SizePatch.cs +++ b/source/Patches/SizePatch.cs @@ -14,7 +14,7 @@ public static void Postfix(HudManager __instance) { foreach (var player in PlayerControl.AllPlayerControls.ToArray()) { - if (!(player.Data.IsDead || player.Data.Disconnected)) + if (!(player.Data.IsDead || player.Data.Disconnected || Utils.HasTask(TaskTypes.MushroomMixupSabotage, TaskTypes.FixComms))) player.transform.localScale = player.GetAppearance().SizeFactor; else player.transform.localScale = new Vector3(0.7f, 0.7f, 1.0f); diff --git a/source/Patches/Utils.cs b/source/Patches/Utils.cs index 35da78fe0..dbb48c529 100644 --- a/source/Patches/Utils.cs +++ b/source/Patches/Utils.cs @@ -1095,6 +1095,11 @@ public static void Rpc(params object[] data) AmongUsClient.Instance.FinishRpcImmediately(writer); } + public static bool HasTask(params TaskTypes[] types) + { + return PlayerControl.LocalPlayer.myTasks.ToArray().Any(x => types.ToList().Contains(x.TaskType)); + } + [HarmonyPatch(typeof(MedScanMinigame), nameof(MedScanMinigame.FixedUpdate))] class MedScanMinigameFixedUpdatePatch { From 58282ef99f190b7aaa6fa8c222f0b74917a179f6 Mon Sep 17 00:00:00 2001 From: twix <91138333+whichtwix@users.noreply.github.com> Date: Wed, 24 Apr 2024 11:13:19 +0600 Subject: [PATCH 2/3] revert size in camo comms only --- source/Patches/SizePatch.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Patches/SizePatch.cs b/source/Patches/SizePatch.cs index adffa9e67..9cf412360 100644 --- a/source/Patches/SizePatch.cs +++ b/source/Patches/SizePatch.cs @@ -14,7 +14,7 @@ public static void Postfix(HudManager __instance) { foreach (var player in PlayerControl.AllPlayerControls.ToArray()) { - if (!(player.Data.IsDead || player.Data.Disconnected || Utils.HasTask(TaskTypes.MushroomMixupSabotage, TaskTypes.FixComms))) + if (!player.Data.IsDead && !player.Data.Disconnected && !Utils.HasTask(TaskTypes.MushroomMixupSabotage) && !CamouflageUnCamouflage.IsCamoed) player.transform.localScale = player.GetAppearance().SizeFactor; else player.transform.localScale = new Vector3(0.7f, 0.7f, 1.0f); From 6c513b6fb95e671db9d549858d0756ebb52c4412 Mon Sep 17 00:00:00 2001 From: twix <91138333+whichtwix@users.noreply.github.com> Date: Sat, 27 Apr 2024 14:04:09 +0600 Subject: [PATCH 3/3] also disable the buttons --- source/Patches/CultistRoles/ChameleonMod/HudManagerUpdate.cs | 3 ++- source/Patches/ImpostorRoles/MorphlingMod/HudManagerUpdate.cs | 3 ++- source/Patches/ImpostorRoles/SwooperMod/HudManagerUpdate.cs | 3 ++- source/Patches/ImpostorRoles/VenererMod/HudManagerUpdate.cs | 3 ++- source/Patches/Roles/Glitch.cs | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/source/Patches/CultistRoles/ChameleonMod/HudManagerUpdate.cs b/source/Patches/CultistRoles/ChameleonMod/HudManagerUpdate.cs index c46737f5b..5232b27fd 100644 --- a/source/Patches/CultistRoles/ChameleonMod/HudManagerUpdate.cs +++ b/source/Patches/CultistRoles/ChameleonMod/HudManagerUpdate.cs @@ -24,7 +24,8 @@ public static void UpdateSwoopButton(HudManager __instance) swoopButton.gameObject.SetActive((__instance.UseButton.isActiveAndEnabled || __instance.PetButton.isActiveAndEnabled) && !MeetingHud.Instance && !PlayerControl.LocalPlayer.Data.IsDead - && AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Started); + && AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Started + && !Utils.HasTask(TaskTypes.MushroomMixupSabotage)); if (role.IsSwooped) swoopButton.SetCoolDown(role.TimeRemaining, CustomGameOptions.SwoopDuration); else swoopButton.SetCoolDown(role.SwoopTimer(), CustomGameOptions.SwoopCd); diff --git a/source/Patches/ImpostorRoles/MorphlingMod/HudManagerUpdate.cs b/source/Patches/ImpostorRoles/MorphlingMod/HudManagerUpdate.cs index c71486147..6d07449ae 100644 --- a/source/Patches/ImpostorRoles/MorphlingMod/HudManagerUpdate.cs +++ b/source/Patches/ImpostorRoles/MorphlingMod/HudManagerUpdate.cs @@ -32,7 +32,8 @@ public static void Postfix(HudManager __instance) role.MorphButton.gameObject.SetActive((__instance.UseButton.isActiveAndEnabled || __instance.PetButton.isActiveAndEnabled) && !MeetingHud.Instance && !PlayerControl.LocalPlayer.Data.IsDead - && AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Started); + && AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Started + && !Utils.HasTask(TaskTypes.MushroomMixupSabotage)); if (role.MorphButton.graphic.sprite == SampleSprite) { role.MorphButton.SetCoolDown(0f, 1f); diff --git a/source/Patches/ImpostorRoles/SwooperMod/HudManagerUpdate.cs b/source/Patches/ImpostorRoles/SwooperMod/HudManagerUpdate.cs index fbbfbabee..72c3a7289 100644 --- a/source/Patches/ImpostorRoles/SwooperMod/HudManagerUpdate.cs +++ b/source/Patches/ImpostorRoles/SwooperMod/HudManagerUpdate.cs @@ -25,7 +25,8 @@ public static void Postfix(HudManager __instance) role.SwoopButton.graphic.sprite = SwoopSprite; role.SwoopButton.gameObject.SetActive((__instance.UseButton.isActiveAndEnabled || __instance.PetButton.isActiveAndEnabled) && !MeetingHud.Instance && !PlayerControl.LocalPlayer.Data.IsDead - && AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Started); + && AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Started + && !Utils.HasTask(TaskTypes.MushroomMixupSabotage)); if (role.IsSwooped) { diff --git a/source/Patches/ImpostorRoles/VenererMod/HudManagerUpdate.cs b/source/Patches/ImpostorRoles/VenererMod/HudManagerUpdate.cs index 5930e4064..ab2f809cc 100644 --- a/source/Patches/ImpostorRoles/VenererMod/HudManagerUpdate.cs +++ b/source/Patches/ImpostorRoles/VenererMod/HudManagerUpdate.cs @@ -31,7 +31,8 @@ public static void Postfix(HudManager __instance) else role.AbilityButton.graphic.sprite = CamoSprintFreezeSprite; role.AbilityButton.gameObject.SetActive((__instance.UseButton.isActiveAndEnabled || __instance.PetButton.isActiveAndEnabled) && !MeetingHud.Instance && !PlayerControl.LocalPlayer.Data.IsDead - && AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Started); + && AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Started + && !Utils.HasTask(TaskTypes.MushroomMixupSabotage)); if (role.IsCamouflaged) { diff --git a/source/Patches/Roles/Glitch.cs b/source/Patches/Roles/Glitch.cs index eac06c666..93ed700af 100644 --- a/source/Patches/Roles/Glitch.cs +++ b/source/Patches/Roles/Glitch.cs @@ -629,7 +629,8 @@ public static void MimicButtonUpdate(Glitch __gInstance, HudManager __instance) __gInstance.MimicButton.gameObject.SetActive((__instance.UseButton.isActiveAndEnabled || __instance.PetButton.isActiveAndEnabled) && !MeetingHud.Instance && !__gInstance.Player.Data.IsDead - && AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started); + && AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started + && !Utils.HasTask(TaskTypes.MushroomMixupSabotage)); if (__instance.UseButton != null) { __gInstance.MimicButton.transform.position = new Vector3(