mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
fix viper
This commit is contained in:
1 parent
9f11874189
commit
790d868759
2 files changed
+49
-1
No files matched your search
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in new issue
Block a user