mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-20 01:46:19 +00:00
sabo fixes
This commit is contained in:
1 parent
bb320117e4
commit
293e1b0ac0
5 files changed
+132
-13
No files matched your search
+122
-10
@@ -4,6 +4,7 @@ using Hazel;
|
||||
using InnerNet;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Purchasing;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace BetterAmongUs;
|
||||
|
||||
@@ -294,6 +295,15 @@ class AntiCheat
|
||||
player.BetterData().LastTaskId = taskId;
|
||||
}
|
||||
|
||||
if (callId is (byte)RpcCalls.CloseDoorsOfType)
|
||||
{
|
||||
if (!player.IsImpostorTeam())
|
||||
{
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
Logger.LogCheat($"{player.Data.PlayerName} {Enum.GetName((RpcCalls)callId)}: {!player.IsImpostorTeam()}");
|
||||
}
|
||||
}
|
||||
|
||||
if (callId is (byte)RpcCalls.Pet or (byte)RpcCalls.CancelPet)
|
||||
{
|
||||
if (player?.CurrentOutfit?.PetId == "pet_EmptyPet")
|
||||
@@ -314,27 +324,129 @@ class AntiCheat
|
||||
// Check game states when sabotaging
|
||||
public static bool RpcUpdateSystemCheck(PlayerControl player, SystemTypes systemType, byte amount)
|
||||
{
|
||||
if (PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer || player.BetterData().IsBetterHost || !IsEnabled || !Main.AntiCheat.Value
|
||||
|| GameStates.IsBetterHostLobby && !GameStates.IsHost) return true;
|
||||
byte hostNum = 128; // Only host should ever send this number
|
||||
byte singleFixNum = 0;
|
||||
byte minLightNum = 0;
|
||||
byte MaxLightNum = 4;
|
||||
byte fixNum = 16; // 16 and 17
|
||||
byte openPanelNum = 64; // 64 and 65
|
||||
byte closePanelNum = 32; // 32 and 33
|
||||
|
||||
// Set fixing status
|
||||
if (Utils.SystemTypeIsSabotage(systemType))
|
||||
{
|
||||
if (!player.IsImpostorTeam() || !GameStates.IsSystemActive(systemType) && GameStates.IsAnySabotageActive()
|
||||
|| ShipStatus.Instance.AllDoors.ToArray().Any(door => !door.IsOpen))
|
||||
if (amount == openPanelNum && !player.BetterData().IsFixingPanelSabotage)
|
||||
{
|
||||
player.BetterData().OpenSabotageNum = 1;
|
||||
}
|
||||
else if (amount == openPanelNum + 1 && !player.BetterData().IsFixingPanelSabotage)
|
||||
{
|
||||
player.BetterData().OpenSabotageNum = 2;
|
||||
}
|
||||
|
||||
if (amount == closePanelNum && player.BetterData().OpenSabotageNum == 1)
|
||||
{
|
||||
player.BetterData().OpenSabotageNum = 0;
|
||||
}
|
||||
else if (amount == closePanelNum + 1 && player.BetterData().OpenSabotageNum == 2)
|
||||
{
|
||||
player.BetterData().OpenSabotageNum = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!GameStates.IsHost || PlayerControl.LocalPlayer == null || player == null || player == PlayerControl.LocalPlayer
|
||||
|| player.BetterData().IsBetterHost || !IsEnabled || !Main.AntiCheat.Value
|
||||
|| GameStates.IsBetterHostLobby && !GameStates.IsHost) return true;
|
||||
|
||||
// Single Fix: 0
|
||||
// Lights: 0-1-2-3-4
|
||||
// Fix 1: 16
|
||||
// Fix 2: 17
|
||||
// Panel 1: Open/Hold 64 - Close/Release 32
|
||||
// Panel 2: Open/Hold 65 - Close/Release 33
|
||||
// Cheat Sabo: 128
|
||||
|
||||
// Activate sabotage
|
||||
if (systemType == SystemTypes.Sabotage)
|
||||
{
|
||||
SystemTypes SaboType = (SystemTypes)amount;
|
||||
|
||||
if (!player.IsImpostorTeam() || GameStates.IsAnySabotageActive() || !Utils.SystemTypeIsSabotage(SaboType))
|
||||
{
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName(SaboType)}");
|
||||
Logger.LogCheat($"{player.Data.PlayerName} {Enum.GetName(SaboType)}: {!player.IsImpostorTeam()} || {GameStates.IsAnySabotageActive()} " +
|
||||
$"|| {!Utils.SystemTypeIsSabotage(SaboType)}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Fix sabotage
|
||||
else if (Utils.SystemTypeIsSabotage(systemType))
|
||||
{
|
||||
if (amount == hostNum && !player.IsHost())
|
||||
{
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName(systemType)}");
|
||||
Logger.LogCheat($"{player.Data.PlayerName} {Enum.GetName(systemType)} Start Sabotage: {!player.IsImpostorTeam()} || {!GameStates.IsSystemActive(systemType)} " +
|
||||
$"&& {GameStates.IsAnySabotageActive()} || {ShipStatus.Instance.AllDoors.ToArray().Any(door => !door.IsOpen)}");
|
||||
Logger.LogCheat($"{player.Data.PlayerName} {Enum.GetName(systemType)}: {amount == hostNum} && {!player.IsHost()}");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Fix Sabo
|
||||
if (amount == 16)
|
||||
if (!GameStates.IsSystemActive(systemType))
|
||||
{
|
||||
if (!GameStates.IsSystemActive(systemType))
|
||||
if (systemType is SystemTypes.Electrical)
|
||||
{
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName(systemType)}");
|
||||
Logger.LogCheat($"{player.Data.PlayerName} {Enum.GetName(systemType)} Fix Sabotage: {!GameStates.IsSystemActive(systemType)}");
|
||||
Logger.LogCheat($"{player.Data.PlayerName} {Enum.GetName(systemType)}: {systemType is SystemTypes.Electrical}");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.BetterData().IsFixingPanelSabotage)
|
||||
{
|
||||
if (player.BetterData().OpenSabotageNum == 0)
|
||||
{
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName(systemType)}");
|
||||
Logger.LogCheat($"{player.Data.PlayerName} {Enum.GetName(systemType)}: {player.BetterData().OpenSabotageNum == 0}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (amount == openPanelNum && amount == openPanelNum + 1)
|
||||
{
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName(systemType)}");
|
||||
Logger.LogCheat($"{player.Data.PlayerName} {Enum.GetName(systemType)}: {amount == openPanelNum} && {amount == openPanelNum + 1}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.BetterData().OpenSabotageNum == 1 && amount == openPanelNum + 1
|
||||
|| player.BetterData().OpenSabotageNum == 2 && amount == openPanelNum)
|
||||
{
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName(systemType)}");
|
||||
Logger.LogCheat($"{player.Data.PlayerName} {Enum.GetName(systemType)}: {player.BetterData().OpenSabotageNum == 1} && {amount == openPanelNum + 1} " +
|
||||
$"|| {player.BetterData().OpenSabotageNum == 2} && {amount == openPanelNum}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (amount != fixNum && amount != fixNum + 1
|
||||
&& amount != closePanelNum && amount != closePanelNum + 1
|
||||
&& amount > MaxLightNum)
|
||||
{
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName(systemType)}");
|
||||
Logger.LogCheat($"{player.Data.PlayerName} {Enum.GetName(systemType)}: {amount != fixNum} && {amount != fixNum + 1}" +
|
||||
$" && {amount != closePanelNum} && {amount != closePanelNum + 1}" +
|
||||
$" && {amount > MaxLightNum}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (systemType == SystemTypes.Electrical)
|
||||
{
|
||||
if (amount > MaxLightNum)
|
||||
{
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName(systemType)}");
|
||||
Logger.LogCheat($"{player.Data.PlayerName} {Enum.GetName(systemType)}: {amount > MaxLightNum}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,10 @@ static class ExtendedPlayerControl
|
||||
player.RpcSetName(setReasonInfo + "<size=0%>");
|
||||
}
|
||||
|
||||
byte savePlayerId = player.PlayerId;
|
||||
string saveName = player.Data.PlayerName;
|
||||
AmongUsClient.Instance.KickPlayer(player.GetClientId(), ban);
|
||||
GameData.Instance.GetPlayerById(savePlayerId).PlayerName = saveName;
|
||||
}
|
||||
|
||||
// RPCs
|
||||
|
||||
@@ -12,6 +12,8 @@ public class ExtendedPlayerInfo
|
||||
public bool BannedByAntiCheat { get; set; } = false;
|
||||
|
||||
// Track Game Info
|
||||
public int OpenSabotageNum { get; set; } = 0;
|
||||
public bool IsFixingPanelSabotage => OpenSabotageNum != 0;
|
||||
public float TimeSinceLastTask { get; set; } = 5f;
|
||||
public uint LastTaskId { get; set; } = 0;
|
||||
public int TimesCalledMeeting { get; set; } = 0;
|
||||
|
||||
+4
-2
@@ -68,13 +68,15 @@ public static class Utils
|
||||
or SystemTypes.Comms
|
||||
or SystemTypes.LifeSupp
|
||||
or SystemTypes.MushroomMixupSabotage
|
||||
or SystemTypes.HeliSabotage;
|
||||
or SystemTypes.HeliSabotage
|
||||
or SystemTypes.Electrical;
|
||||
public static bool SystemTypeIsSabotage(int typeNum) => (SystemTypes)typeNum is SystemTypes.Reactor
|
||||
or SystemTypes.Laboratory
|
||||
or SystemTypes.Comms
|
||||
or SystemTypes.LifeSupp
|
||||
or SystemTypes.MushroomMixupSabotage
|
||||
or SystemTypes.HeliSabotage;
|
||||
or SystemTypes.HeliSabotage
|
||||
or SystemTypes.Electrical;
|
||||
// Get players HashPuid
|
||||
public static string GetHashPuid(PlayerControl player)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Main : BasePlugin
|
||||
{
|
||||
public const ReleaseTypes ReleaseBuildType = ReleaseTypes.Release;
|
||||
public const string CanaryNum = "0";
|
||||
public const string HotfixNum = "1";
|
||||
public const string HotfixNum = "2";
|
||||
public const bool IsHotFix = true;
|
||||
public const string PluginGuid = "com.d1gq.betteramongus";
|
||||
public const string PluginVersion = "1.0.3";
|
||||
|
||||
Reference in new issue
Block a user