mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-20 01:46:19 +00:00
anti-cheat improvements
This commit is contained in:
1 parent
f5aef60689
commit
6ed3320f37
7 files changed
+38
-5
No files matched your search
+23
-1
@@ -2,6 +2,7 @@
|
||||
using HarmonyLib;
|
||||
using Hazel;
|
||||
using InnerNet;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BetterAmongUs;
|
||||
|
||||
@@ -12,6 +13,24 @@ class AntiCheat
|
||||
public static Dictionary<string, string> AUMData = []; // HashPuid, FriendCode
|
||||
private static bool IsEnabled = true;
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
if (GameStates.IsInGame)
|
||||
{
|
||||
foreach (var kvp in ExtendedPlayerControl.TimeSinceKill)
|
||||
{
|
||||
ExtendedPlayerControl.TimeSinceKill[kvp.Key] += Time.deltaTime;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ExtendedPlayerControl.TimeSinceKill.Any())
|
||||
{
|
||||
ExtendedPlayerControl.TimeSinceKill.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void PauseAntiCheat()
|
||||
{
|
||||
float time = 2f;
|
||||
@@ -193,8 +212,11 @@ class AntiCheat
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
if (IsCrewmate || !player.IsAlive() || player.IsInVanish() || !target.IsAlive() || target.IsImpostorTeam())
|
||||
if (IsCrewmate || !player.IsAlive() || player.IsInVanish() || !target.IsAlive() || target.IsImpostorTeam()
|
||||
|| ExtendedPlayerControl.TimeSinceKill.TryGetValue(player, out var value) && value < (float)GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown)
|
||||
{
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ class BetterHostManager
|
||||
&& !player.shapeshifting
|
||||
&& !player.onLadder
|
||||
&& !player.MyPhysics.Animations.IsPlayingAnyLadderAnimation()
|
||||
&& ExtendedPlayerControl.TimeSinceKill.TryGetValue(player, out var value) && value >= (float)GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown
|
||||
&& CheckRange(player.GetCustomPosition(), target.GetCustomPosition(), 3f))
|
||||
{
|
||||
if (target.IsAlive()
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace BetterAmongUs;
|
||||
|
||||
static class ExtendedPlayerControl
|
||||
{
|
||||
public static Dictionary<PlayerControl, float> TimeSinceKill = [];
|
||||
// Get players client
|
||||
public static ClientData? GetClient(this PlayerControl player)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ static class ExtendedPlayerInfo
|
||||
|
||||
public static bool GetIsBetterHost(this PlayerControl player)
|
||||
{
|
||||
if (IsBetterHost.ContainsKey(player))
|
||||
if (player.IsHost() && IsBetterHost.ContainsKey(player))
|
||||
return IsBetterHost[player];
|
||||
else
|
||||
return false;
|
||||
|
||||
+10
-3
@@ -94,8 +94,7 @@ internal static class RPC
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
/*
|
||||
PlayerControl asPlayer = Main.AllPlayerControls.Where(pc => pc.IsAlive()).OrderBy(pc => pc == PlayerControl.LocalPlayer ? 0 : 1).First();
|
||||
|
||||
var oldName = asPlayer.CurrentOutfit.PlayerName;
|
||||
@@ -120,6 +119,7 @@ internal static class RPC
|
||||
|
||||
SyncAllNames(force: true);
|
||||
}, 0.08f, shoudLog: false);
|
||||
*/
|
||||
}
|
||||
|
||||
public static void HandleRPC(PlayerControl player, byte callId, MessageReader reader)
|
||||
@@ -131,8 +131,15 @@ internal static class RPC
|
||||
case (byte)CustomRPC.BetterCheck:
|
||||
if (reader.ReadByte() == player.Data.NetId)
|
||||
{
|
||||
var IsBetterHost = reader.ReadBoolean();
|
||||
|
||||
if (!player.IsHost() && IsBetterHost)
|
||||
{
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)} called as BetterHost");
|
||||
}
|
||||
|
||||
player.SetIsBetterUser(true);
|
||||
player.SetIsBetterHost(reader.ReadBoolean());
|
||||
player.SetIsBetterHost(IsBetterHost);
|
||||
}
|
||||
break;
|
||||
case (byte)CustomRPC.AddChat:
|
||||
|
||||
@@ -15,6 +15,7 @@ public class ModManagerPatch
|
||||
if (__instance.ModStamp.gameObject.active == true)
|
||||
__instance.ModStamp.GetComponent<SpriteRenderer>().sprite = Utils.LoadSprite("BetterAmongUs.Resources.Images.BetterAmongUs-Mod.png", 250f);
|
||||
|
||||
AntiCheat.Update();
|
||||
FileChecker.UpdateUnauthorizedFiles();
|
||||
LateTask.Update(Time.deltaTime);
|
||||
BetterNotificationManager.Update();
|
||||
|
||||
@@ -229,6 +229,7 @@ class PlayerControlPatch
|
||||
if (PlayerControl.LocalPlayer.IsImpostorTeam() && GameStates.IsInGamePlay && !GameStates.IsHideNSeek && HudManager.Instance.CrewmatesKilled.isActiveAndEnabled)
|
||||
HudManager.Instance?.NotifyOfDeath();
|
||||
|
||||
ExtendedPlayerControl.TimeSinceKill[__instance] = 0f;
|
||||
|
||||
Logger.LogPrivate($"{__instance.Data.PlayerName} Has killed {target.Data.PlayerName} as {Utils.GetRoleName(__instance.Data.RoleType)}", "EventLog");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user