diff --git a/MiraAPI/Patches/PlayerControlPatches.cs b/MiraAPI/Patches/PlayerControlPatches.cs
index a0b88cdc..df737746 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;
@@ -67,15 +68,53 @@ internal static class PlayerControlPatches
}
[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)
+ [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;
+ }
+
var beforeMurderEvent = new BeforeMurderEvent(__instance, target);
MiraEventManager.InvokeEvent(beforeMurderEvent);
- didSucceed = beforeMurderEvent.IsCancelled;
+ if (beforeMurderEvent.IsCancelled)
+ {
+ return;
+ }
+
+ __instance.isKilling = true;
+ __instance.RpcMurderPlayer(target, true);
}
[HarmonyPostfix]
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);
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)