Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion source/Patches/CultistRoles/ChameleonMod/HudManagerUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion source/Patches/ImpostorRoles/SwooperMod/HudManagerUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 2 additions & 1 deletion source/Patches/ImpostorRoles/VenererMod/HudManagerUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
67 changes: 67 additions & 0 deletions source/Patches/MushroomMixup.cs
Original file line number Diff line number Diff line change
@@ -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>())
{
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<byte> 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>())
{
Morphling.Unmorph();
}
foreach (Swooper Swooper in Role.GetRoles(RoleEnum.Swooper).Cast<Swooper>())
{
Swooper.UnSwoop();
}
foreach (Venerer Venerer in Role.GetRoles(RoleEnum.Venerer).Cast<Venerer>())
{
Venerer.StopAbility();
}
foreach (Chameleon Chameleon in Role.GetRoles(RoleEnum.Chameleon).Cast<Chameleon>())
{
Chameleon.UnSwoop();
}
}
}
}
1 change: 1 addition & 0 deletions source/Patches/Roles/Cultist/Chameleon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions source/Patches/Roles/Glitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@ public static IEnumerator Mimic(Glitch __instance, PlayerControl mimicPlayer)
$"{__instance.ColorString}Mimicking {mimicPlayer.Data.PlayerName} ({CustomGameOptions.MimicDuration - Math.Round(totalMimickTime)}s)</color>";
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");
Expand Down Expand Up @@ -628,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(
Expand Down
1 change: 1 addition & 0 deletions source/Patches/Roles/Morphling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public void Unmorph()
{
MorphedPlayer = null;
Utils.Unmorph(Player);
TimeRemaining = 0f;
LastMorphed = DateTime.UtcNow;
}

Expand Down
1 change: 1 addition & 0 deletions source/Patches/Roles/Swooper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Aurial>(PlayerControl.LocalPlayer).NormalVision) return;
Utils.Unmorph(Player);
Expand Down
1 change: 1 addition & 0 deletions source/Patches/Roles/Venerer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public void Ability()
public void StopAbility()
{
Enabled = false;
TimeRemaining = 0f;
LastCamouflaged = DateTime.UtcNow;
if (!CamouflageUnCamouflage.IsCamoed) Utils.Unmorph(Player);
}
Expand Down
2 changes: 1 addition & 1 deletion source/Patches/RpcHandling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion source/Patches/SizePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) && !CamouflageUnCamouflage.IsCamoed)
player.transform.localScale = player.GetAppearance().SizeFactor;
else
player.transform.localScale = new Vector3(0.7f, 0.7f, 1.0f);
Expand Down
5 changes: 5 additions & 0 deletions source/Patches/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down