From 9f11874189d57a2fcbcc641876644479c6806015 Mon Sep 17 00:00:00 2001
From: XtraCube <72575280+XtraCube@users.noreply.github.com>
Date: Sun, 14 Sep 2025 15:15:06 -0400
Subject: [PATCH 1/3] fix role settings
---
MiraAPI/Patches/Roles/RoleOptionsCollectionPatch.cs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/MiraAPI/Patches/Roles/RoleOptionsCollectionPatch.cs b/MiraAPI/Patches/Roles/RoleOptionsCollectionPatch.cs
index d867139c..7f53b0ab 100644
--- a/MiraAPI/Patches/Roles/RoleOptionsCollectionPatch.cs
+++ b/MiraAPI/Patches/Roles/RoleOptionsCollectionPatch.cs
@@ -9,17 +9,17 @@ namespace MiraAPI.Patches.Roles;
///
/// Patches to return the correct role counts.
///
-[HarmonyPatch(typeof(RoleOptionsCollectionV09))]
+[HarmonyPatch(typeof(RoleOptionsCollectionV10))]
public static class RoleOptionsCollectionPatch
{
///
/// This patch fixes GetNumPerGame being inlined (2025.5.20) in the original code.
///
[HarmonyPrefix]
- [HarmonyPatch(nameof(RoleOptionsCollectionV09.AnyRolesEnabled))]
- public static bool AnyRolesEnabledPrefix(RoleOptionsCollectionV09 __instance, ref bool __result)
+ [HarmonyPatch(nameof(RoleOptionsCollectionV10.AnyRolesEnabled))]
+ public static bool AnyRolesEnabledPrefix(RoleOptionsCollectionV10 __instance, ref bool __result)
{
- foreach (KeyValuePair keyValuePair in __instance.roles)
+ foreach (KeyValuePair keyValuePair in __instance.roles)
{
if (__instance.GetNumPerGame(keyValuePair.Key) > 0)
{
@@ -34,7 +34,7 @@ public static class RoleOptionsCollectionPatch
///
/// Return false to skip original method, true to not.
[HarmonyPrefix]
- [HarmonyPatch(nameof(RoleOptionsCollectionV09.GetChancePerGame))]
+ [HarmonyPatch(nameof(RoleOptionsCollectionV10.GetChancePerGame))]
public static bool GetChancePrefix(RoleTypes role, ref int __result)
{
if (!CustomRoleManager.GetCustomRoleBehaviour(role, out var customRole) || customRole == null)
@@ -64,7 +64,7 @@ public static class RoleOptionsCollectionPatch
///
/// Return false to skip original method, true to not.
[HarmonyPrefix]
- [HarmonyPatch(nameof(RoleOptionsCollectionV09.GetNumPerGame))]
+ [HarmonyPatch(nameof(RoleOptionsCollectionV10.GetNumPerGame))]
public static bool GetNumPrefix(RoleTypes role, ref int __result)
{
if (!CustomRoleManager.GetCustomRoleBehaviour(role, out var customRole) || customRole == null)
From 790d868759a15da66c38d45dce142ea69aadff5f Mon Sep 17 00:00:00 2001
From: XtraCube <72575280+XtraCube@users.noreply.github.com>
Date: Sun, 14 Sep 2025 15:26:58 -0400
Subject: [PATCH 2/3] fix viper
---
MiraAPI/Patches/PlayerControlPatches.cs | 45 +++++++++++++++++++++-
MiraAPI/Patches/Roles/KillButtonPatches.cs | 5 +++
2 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/MiraAPI/Patches/PlayerControlPatches.cs b/MiraAPI/Patches/PlayerControlPatches.cs
index a0b88cdc..ac88d942 100644
--- a/MiraAPI/Patches/PlayerControlPatches.cs
+++ b/MiraAPI/Patches/PlayerControlPatches.cs
@@ -1,4 +1,5 @@
-using System.Linq;
+using System.Globalization;
+using System.Linq;
using HarmonyLib;
using MiraAPI.Events;
using MiraAPI.Events.Vanilla.Gameplay;
@@ -66,6 +67,48 @@ internal static class PlayerControlPatches
}
}
+ [HarmonyPrefix]
+ [HarmonyPatch(nameof(PlayerControl.CheckMurder))]
+ public static void PlayerControlCheckMurderPrefix(PlayerControl __instance, PlayerControl target, ref bool __runOriginal)
+ {
+ __runOriginal = false;
+
+ __instance.logger.Debug($"Checking if {__instance.PlayerId} murdered {(target == null ? "null player" : target.PlayerId.ToString(NumberFormatInfo.InvariantInfo))}");
+
+ __instance.isKilling = false;
+ if (AmongUsClient.Instance.IsGameOver || !AmongUsClient.Instance.AmHost)
+ {
+ return;
+ }
+
+ if (!target || __instance.Data.IsDead || !__instance.Data.Role.IsImpostor || __instance.Data.Disconnected)
+ {
+ int num = target ? target!.PlayerId : -1;
+ __instance.logger.Warning($"Bad kill from {__instance.PlayerId} to {num}");
+ __instance.RpcMurderPlayer(target, false);
+ return;
+ }
+
+ NetworkedPlayerInfo data = target!.Data;
+ if (data == null || data.IsDead || target.inVent || target.MyPhysics.Animations.IsPlayingEnterVentAnimation() ||
+ target.MyPhysics.Animations.IsPlayingAnyLadderAnimation() || target.inMovingPlat)
+ {
+ __instance.logger.Warning("Invalid target data for kill");
+ __instance.RpcMurderPlayer(target, false);
+ return;
+ }
+
+ if (MeetingHud.Instance)
+ {
+ __instance.logger.Warning("Tried to kill while a meeting was starting");
+ __instance.RpcMurderPlayer(target, false);
+ return;
+ }
+
+ __instance.isKilling = true;
+ __instance.RpcMurderPlayer(target, true);
+ }
+
[HarmonyPrefix]
[HarmonyPatch(nameof(PlayerControl.RpcMurderPlayer))]
// ReSharper disable once InconsistentNaming
diff --git a/MiraAPI/Patches/Roles/KillButtonPatches.cs b/MiraAPI/Patches/Roles/KillButtonPatches.cs
index 2a04e9d0..902a9e67 100644
--- a/MiraAPI/Patches/Roles/KillButtonPatches.cs
+++ b/MiraAPI/Patches/Roles/KillButtonPatches.cs
@@ -58,6 +58,11 @@ public static class KillButtonPatches
return false;
}
+ if (PlayerControl.LocalPlayer.Data.Role is not ICustomRole)
+ {
+ return true;
+ }
+
PlayerControl.LocalPlayer.RpcCustomMurder(__instance.currentTarget);
__instance.SetTarget(null);
From f3175990d3431c40d2fc97bd3ea9c8e0ab3a0788 Mon Sep 17 00:00:00 2001
From: Pietro420 <77608535+Pietrodjaowjao@users.noreply.github.com>
Date: Sun, 14 Sep 2025 20:07:17 -0300
Subject: [PATCH 3/3] ACTUALLY fix Viper
---
MiraAPI/Patches/PlayerControlPatches.cs | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/MiraAPI/Patches/PlayerControlPatches.cs b/MiraAPI/Patches/PlayerControlPatches.cs
index ac88d942..df737746 100644
--- a/MiraAPI/Patches/PlayerControlPatches.cs
+++ b/MiraAPI/Patches/PlayerControlPatches.cs
@@ -105,20 +105,16 @@ internal static class PlayerControlPatches
return;
}
- __instance.isKilling = true;
- __instance.RpcMurderPlayer(target, true);
- }
-
- [HarmonyPrefix]
- [HarmonyPatch(nameof(PlayerControl.RpcMurderPlayer))]
- // ReSharper disable once InconsistentNaming
- // Note: This method is partially inlined in 2025.5.20 but we already use custom murder RPCs.
- public static void PlayerControlMurderPrefix(PlayerControl __instance, PlayerControl target, ref bool didSucceed)
- {
var beforeMurderEvent = new BeforeMurderEvent(__instance, target);
MiraEventManager.InvokeEvent(beforeMurderEvent);
- didSucceed = beforeMurderEvent.IsCancelled;
+ if (beforeMurderEvent.IsCancelled)
+ {
+ return;
+ }
+
+ __instance.isKilling = true;
+ __instance.RpcMurderPlayer(target, true);
}
[HarmonyPostfix]