mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-11-19 13:17:17 +00:00
19 files changed
+377
-175
No files matched your search
+143
-17
@@ -4,6 +4,7 @@ using Hazel;
|
||||
using InnerNet;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Purchasing;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace BetterAmongUs;
|
||||
|
||||
@@ -26,15 +27,15 @@ class AntiCheat
|
||||
|
||||
if (SickoData.ContainsKey(hashPuid))
|
||||
{
|
||||
player.Kick(true, $"<color=#ffea00>{player.Data.PlayerName}</color> banned by <color=#4f92ff>Anti-Cheat</color>!\n Reason: <color=#00f583>Known Sicko Menu User</color>");
|
||||
player.Kick(true, $"banned by <color=#4f92ff>Anti-Cheat</color>!\n Reason: <color=#00f583>Known Sicko Menu User</color>", true);
|
||||
}
|
||||
else if (AUMData.ContainsKey(hashPuid))
|
||||
{
|
||||
player.Kick(true, $"<color=#ffea00>{player.Data.PlayerName}</color> banned by <color=#4f92ff>Anti-Cheat</color>!\n Reason: <color=#4f0000>Known AUM User</color>");
|
||||
player.Kick(true, $"banned by <color=#4f92ff>Anti-Cheat</color>!\n Reason: <color=#4f0000>Known AUM User</color>", true);
|
||||
}
|
||||
else if (PlayerData.ContainsKey(hashPuid))
|
||||
{
|
||||
player.Kick(true, $"<color=#ffea00>{player.Data.PlayerName}</color> banned by <color=#4f92ff>Anti-Cheat</color>!\n Reason: <color=#fc0000>Known Cheater</color>");
|
||||
player.Kick(true, $"banned by <color=#4f92ff>Anti-Cheat</color>!\n Reason: <color=#fc0000>Known Cheater</color>", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,22 +324,130 @@ class AntiCheat
|
||||
// Check game states when sabotaging
|
||||
public static bool RpcUpdateSystemCheck(PlayerControl player, SystemTypes systemType, byte amount)
|
||||
{
|
||||
if (!player.IsImpostorTeam() || !GameStates.IsSystemActive(systemType) && GameStates.IsAnySabotageActive() || Utils.SystemTypeIsSabotage(systemType)
|
||||
|| ShipStatus.Instance.AllDoors.ToArray().Any(door => !door.IsOpen))
|
||||
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))
|
||||
{
|
||||
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()} || {Utils.SystemTypeIsSabotage(systemType)} || {ShipStatus.Instance.AllDoors.ToArray().Any(door => !door.IsOpen)}");
|
||||
return false;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// Fix Sabo
|
||||
if (amount == 16)
|
||||
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)
|
||||
{
|
||||
if (!GameStates.IsSystemActive(systemType))
|
||||
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)} Fix Sabotage: {!GameStates.IsSystemActive(systemType)}");
|
||||
Logger.LogCheat($"{player.Data.PlayerName} {Enum.GetName(systemType)}: {amount == hostNum} && {!player.IsHost()}");
|
||||
return false;
|
||||
}
|
||||
|
||||
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)}: {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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,11 +472,18 @@ class AntiCheat
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
if (!target.IsAlive() && target == PlayerControl.LocalPlayer)
|
||||
if (target == PlayerControl.LocalPlayer)
|
||||
{
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
Logger.LogCheat($"{player.Data.PlayerName} {Enum.GetName((RpcCalls)callId)} 2: {!target.IsAlive()}");
|
||||
return false;
|
||||
if (target.BetterData().CheckBanExploit && !target.IsAlive())
|
||||
{
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action: Attempted To Ban Exploit");
|
||||
Logger.LogCheat($"{player.Data.PlayerName} {Enum.GetName((RpcCalls)callId)} 2: {target.BetterData().CheckBanExploit} && {!target.IsAlive()}");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
target.BetterData().CheckBanExploit = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -495,6 +620,7 @@ class AntiCheat
|
||||
if (callId is (byte)RpcCalls.CheckName)
|
||||
{
|
||||
var name = reader.ReadString();
|
||||
Utils.AddChatPrivate($"{player.GetPlayerNameAndColor()} Has tried to change their name to '{name}' but has been undone!");
|
||||
Logger.LogCheat($"{player.Data.PlayerName} Has tried to change their name to '{name}' but has been undone!");
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -9,6 +9,7 @@ class BetterDataManager
|
||||
public static string filePathFolderSaveInfo = Path.Combine(filePathFolder, $"SaveInfo");
|
||||
public static string banPlayerListFile = Path.Combine(filePathFolderSaveInfo, "BanPlayerList.txt");
|
||||
public static string banNameListFile = Path.Combine(filePathFolderSaveInfo, "BanNameList.txt");
|
||||
public static string banWordListFile = Path.Combine(filePathFolderSaveInfo, "BanWordList.txt");
|
||||
|
||||
public static string GetFilePath(string name)
|
||||
{
|
||||
@@ -37,6 +38,11 @@ class BetterDataManager
|
||||
File.WriteAllText(banNameListFile, "// Example\nBanName1\nBanName2");
|
||||
}
|
||||
|
||||
if (!File.Exists(banWordListFile))
|
||||
{
|
||||
File.WriteAllText(banWordListFile, "// Example\nStart");
|
||||
}
|
||||
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
// Initialize with predefined categories
|
||||
|
||||
@@ -228,7 +228,7 @@ class BetterHostManager
|
||||
else if (player.BetterData().IsBetterUser)
|
||||
sbTopTag.Append("<color=#0dff00>Better User</color>+++");
|
||||
}
|
||||
else if (GameStates.IsInGamePlay)
|
||||
else if (GameStates.IsInGamePlay && !GameStates.IsHideNSeek)
|
||||
{
|
||||
string Role = $"<color={player.GetTeamHexColor()}>{player.GetRoleName()}</color>";
|
||||
if (!player.IsImpostorTeam() && player.myTasks.Count > 0)
|
||||
@@ -267,9 +267,9 @@ class BetterHostManager
|
||||
NewName = $"{NewName}";
|
||||
|
||||
// Don't send rpc if name is the same!
|
||||
if (player.BetterData().LastNameSetFor.TryGetValue(target.PlayerId, out var lastName) && lastName == NewName)
|
||||
if (player.BetterData().LastNameSetFor.TryGetValue(target.PlayerId, out var lastName))
|
||||
{
|
||||
if (!force)
|
||||
if (lastName == NewName || !force)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -48,10 +48,10 @@ class BetterNotificationManager
|
||||
|
||||
if (GameStates.IsHost && kickPlayer)
|
||||
{
|
||||
player.Kick(true, $"<color=#ffea00>{player.Data.PlayerName}</color> banned by <color=#4f92ff>Anti-Cheat</color>!\n Reason: <color=#fc0000>{reason}</color>");
|
||||
player.Kick(true, $"banned by <color=#4f92ff>Anti-Cheat</color>!\n Reason: <color=#fc0000>{reason}</color>", true);
|
||||
}
|
||||
|
||||
Logger.LogCheat(Utils.GetRawText(text));
|
||||
Logger.LogCheat(Utils.RemoveHtmlText(text));
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
|
||||
+6
-2
@@ -7,14 +7,18 @@ class Logger
|
||||
{
|
||||
string mark = $"{DateTime.Now:HH:mm} [BetterLog][{tag}]";
|
||||
string logFilePath = Path.Combine(BetterDataManager.filePathFolder, "better-log.txt");
|
||||
string newLine = $"{mark}: {info}";
|
||||
string newLine = $"{mark}: {Utils.RemoveHtmlText(info)}";
|
||||
File.AppendAllText(logFilePath, newLine + Environment.NewLine);
|
||||
Main.Logger.LogInfo($"[{tag}] {info}");
|
||||
}
|
||||
public static void LogHeader(string info, string tag = "Log") => Log($" <-------------- {info} -------------->", tag);
|
||||
public static void LogCheat(string info, string tag = "AntiCheat") => Log(info, tag);
|
||||
public static void Error(string info, string tag = "Error") => Log(info, tag);
|
||||
public static void Test() => Log("------------------> TEST <------------------", "TEST");
|
||||
public static void Test()
|
||||
{
|
||||
Log("------------------> TEST <------------------", "TEST");
|
||||
InGame("TEST");
|
||||
}
|
||||
// Log in game join msg
|
||||
public static void InGame(string info)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using AmongUs.GameOptions;
|
||||
using BetterAmongUs.Patches;
|
||||
using InnerNet;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@@ -53,7 +54,7 @@ static class ExtendedPlayerControl
|
||||
infoType = "InfoText_Info_TMP";
|
||||
var topText = player.gameObject.transform.Find("Names/NameText_TMP/InfoText_T_TMP")?.GetComponent<TextMeshPro>();
|
||||
|
||||
if (topText != null && string.IsNullOrEmpty(Utils.GetRawText(topText.text)))
|
||||
if (topText != null && string.IsNullOrEmpty(Utils.RemoveHtmlText(topText.text)))
|
||||
{
|
||||
text = "<voffset=-2.25em>" + text + "</voffset>";
|
||||
}
|
||||
@@ -100,21 +101,30 @@ static class ExtendedPlayerControl
|
||||
}
|
||||
|
||||
// Kick player
|
||||
public static void Kick(this PlayerControl player, bool ban = false, string setReasonInfo = "")
|
||||
public static void Kick(this PlayerControl player, bool ban = false, string setReasonInfo = "", bool AntiCheatBan = false)
|
||||
{
|
||||
if (!GameStates.IsHost || PlayerControl.LocalPlayer == player || !player.DataIsCollected() || player.IsHost() || player.BetterData().BannedByAntiCheat || player.isDummy)
|
||||
if (!GameStates.IsHost || PlayerControl.LocalPlayer == player || !player.DataIsCollected() || player.IsHost() || player.isDummy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.BetterData().BannedByAntiCheat = true;
|
||||
player.BetterData().BannedByAntiCheat = AntiCheatBan && ban;
|
||||
|
||||
NetworkedPlayerInfo playerInfo = player.Data;
|
||||
string saveName = player.Data.PlayerName;
|
||||
|
||||
if (setReasonInfo != "")
|
||||
{
|
||||
player.RpcSetName(setReasonInfo + "<size=0%>");
|
||||
playerInfo.PlayerName = $"<color=#ffea00>{saveName}</color> {setReasonInfo}<size=0%>";
|
||||
player.SetName($"<color=#ffea00>{saveName}</color> {setReasonInfo}<size=0%>");
|
||||
}
|
||||
|
||||
AmongUsClient.Instance.KickPlayer(player.GetClientId(), ban);
|
||||
|
||||
_ = new LateTask(() =>
|
||||
{
|
||||
playerInfo.PlayerName = saveName;
|
||||
}, 0.15f, shoudLog: false);
|
||||
}
|
||||
|
||||
// RPCs
|
||||
|
||||
@@ -1,35 +1,62 @@
|
||||
using AmongUs.GameOptions;
|
||||
using InnerNet;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BetterAmongUs;
|
||||
|
||||
public class ExtendedPlayerInfo
|
||||
public static class PlayerControlDataExtension
|
||||
{
|
||||
public Dictionary<byte, string> LastNameSetFor { get; set; } = [];
|
||||
public bool IsBetterUser { get; set; } = false;
|
||||
public bool IsBetterHost { get; set; } = false;
|
||||
public bool IsTOHEHost { get; set; } = false;
|
||||
public bool BannedByAntiCheat { get; set; } = false;
|
||||
public class ExtendedPlayerInfo
|
||||
{
|
||||
public NetworkedPlayerInfo? ThisPlayerData { get; set; }
|
||||
public Dictionary<byte, string> LastNameSetFor { get; set; } = [];
|
||||
public bool IsBetterUser { get; set; } = false;
|
||||
public bool IsBetterHost { get; set; } = false;
|
||||
public bool IsTOHEHost { get; set; } = false;
|
||||
public bool BannedByAntiCheat { get; set; } = false;
|
||||
public bool CheckBanExploit { get; set; } = false;
|
||||
|
||||
// Track Game Info
|
||||
public float TimeSinceLastTask { get; set; } = 5f;
|
||||
public uint LastTaskId { get; set; } = 0;
|
||||
public int TimesCalledMeeting { get; set; } = 0;
|
||||
public DisconnectReasons DisconnectReason { get; set; } = DisconnectReasons.Unknown;
|
||||
public ExtendedRoleInfo? RoleInfo { get; set; }
|
||||
}
|
||||
// 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;
|
||||
public DisconnectReasons DisconnectReason { get; set; } = DisconnectReasons.Unknown;
|
||||
public ExtendedRoleInfo? RoleInfo { get; set; }
|
||||
}
|
||||
|
||||
public class ExtendedRoleInfo
|
||||
{
|
||||
public int Kills { get; set; } = 0;
|
||||
public bool HasNoisemakerNotify { get; set; } = false;
|
||||
public RoleTypes DeadDisplayRole { get; set; }
|
||||
}
|
||||
public class ExtendedRoleInfo
|
||||
{
|
||||
public int Kills { get; set; } = 0;
|
||||
public bool HasNoisemakerNotify { get; set; } = false;
|
||||
public RoleTypes DeadDisplayRole { get; set; }
|
||||
}
|
||||
|
||||
public static class PlayerControlExtensions
|
||||
{
|
||||
public static readonly Dictionary<string, ExtendedPlayerInfo> playerInfo = [];
|
||||
|
||||
// Reset info when needed
|
||||
public static void ResetPlayerData(PlayerControl player)
|
||||
{
|
||||
if (GameStates.IsLobby)
|
||||
{
|
||||
player.BetterData().TimesCalledMeeting = 0;
|
||||
player.BetterData().RoleInfo.HasNoisemakerNotify = false;
|
||||
player.BetterData().TimeSinceLastTask = 5f;
|
||||
player.BetterData().LastTaskId = 999;
|
||||
player.BetterData().RoleInfo.Kills = 0;
|
||||
player.BetterData().OpenSabotageNum = 0;
|
||||
player.BetterData().CheckBanExploit = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.BetterData().TimeSinceLastTask += Time.deltaTime;
|
||||
|
||||
if (player.IsAlive() || player.Data.RoleType == RoleTypes.GuardianAngel)
|
||||
player.BetterData().RoleInfo.DeadDisplayRole = player.Data.RoleType;
|
||||
}
|
||||
}
|
||||
|
||||
// Get BetterData from PlayerControl
|
||||
public static ExtendedPlayerInfo? BetterData(this PlayerControl player)
|
||||
{
|
||||
@@ -39,6 +66,7 @@ public static class PlayerControlExtensions
|
||||
{
|
||||
playerInfo[player.Data.Puid] = new ExtendedPlayerInfo
|
||||
{
|
||||
ThisPlayerData = player.Data,
|
||||
RoleInfo = new ExtendedRoleInfo()
|
||||
};
|
||||
}
|
||||
@@ -53,6 +81,7 @@ public static class PlayerControlExtensions
|
||||
{
|
||||
playerInfo[info.Puid] = new ExtendedPlayerInfo
|
||||
{
|
||||
ThisPlayerData = info,
|
||||
RoleInfo = new ExtendedRoleInfo()
|
||||
};
|
||||
}
|
||||
@@ -71,6 +100,7 @@ public static class PlayerControlExtensions
|
||||
{
|
||||
playerInfo[player.Data.Puid] = new ExtendedPlayerInfo
|
||||
{
|
||||
ThisPlayerData = player.Data,
|
||||
RoleInfo = new ExtendedRoleInfo()
|
||||
};
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public static class GameStates
|
||||
|
||||
return type switch
|
||||
{
|
||||
SystemTypes.Electrical when mapId != 5 => system.Cast<SwitchSystem>()?.IsActive ?? false,
|
||||
SystemTypes.Electrical when mapId != 5 => !system.Cast<SwitchSystem>()?.IsActive == false,
|
||||
SystemTypes.Reactor when mapId != 2 => system.Cast<ReactorSystemType>()?.IsActive ?? false,
|
||||
SystemTypes.Laboratory when mapId == 2 => system.Cast<ReactorSystemType>()?.IsActive ?? false,
|
||||
SystemTypes.LifeSupp when mapId is 0 or 3 => system.Cast<LifeSuppSystemType>()?.IsActive ?? false,
|
||||
|
||||
+42
-2
@@ -89,7 +89,12 @@ internal static class RPC
|
||||
}
|
||||
|
||||
public static void SetNamePrivate(PlayerControl player, string name, PlayerControl target)
|
||||
{
|
||||
{
|
||||
if (!GameStates.IsHost || !GameStates.IsVanillaServer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SetName, SendOption.Reliable, target.GetClientId());
|
||||
writer.Write(player.Data.NetId);
|
||||
writer.Write(name);
|
||||
@@ -98,7 +103,10 @@ internal static class RPC
|
||||
|
||||
public static void SyncAllNames(bool isForMeeting = false, bool force = false, bool isBetterHost = true)
|
||||
{
|
||||
if (!GameStates.IsHost) return;
|
||||
if (!GameStates.IsHost || !GameStates.IsVanillaServer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (PlayerControl player in Main.AllPlayerControls)
|
||||
BetterHostManager.SetPlayersInfoAsHost(player, isForMeeting, force, isBetterHost);
|
||||
@@ -214,6 +222,38 @@ internal static class RPC
|
||||
BetterNotificationManager.Notify($"{player.GetPlayerNameAndColor()} has granted permission!");
|
||||
}
|
||||
}
|
||||
|
||||
// Check banned words
|
||||
if (Main.UseBannedList.Value)
|
||||
{
|
||||
try
|
||||
{
|
||||
Func<string, string> normalizeText = text => new string(text.Where(c => char.IsLetterOrDigit(c)).ToArray()).ToLower();
|
||||
|
||||
HashSet<string> bannedWords = new HashSet<string>(
|
||||
File.ReadLines(BetterDataManager.banWordListFile)
|
||||
.Select(normalizeText)
|
||||
.Where(text => !string.IsNullOrWhiteSpace(text))
|
||||
);
|
||||
|
||||
string normalizedMessage = normalizeText(text);
|
||||
|
||||
bool isWordBanned = bannedWords.Any(bannedWord =>
|
||||
normalizedMessage.Contains(bannedWord)
|
||||
);
|
||||
|
||||
if (!string.IsNullOrEmpty(normalizedMessage) && isWordBanned)
|
||||
{
|
||||
_ = new LateTask(() =>
|
||||
{
|
||||
player.Kick(false, $"has been kicked due to\nchat message containing a banned word!");
|
||||
}, 1f, shoudLog: false);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+29
-3
@@ -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)
|
||||
{
|
||||
@@ -98,12 +100,36 @@ public static class Utils
|
||||
// Remove Html Tags Template
|
||||
public static string RemoveHtmlTagsTemplate(string str) => Regex.Replace(str, "", "");
|
||||
// Get raw text
|
||||
public static string GetRawText(string text)
|
||||
public static string RemoveHtmlText(string text)
|
||||
{
|
||||
text = Regex.Replace(text, "<[^>]*>", "");
|
||||
text = Regex.Replace(text, "{[^}]*}", "");
|
||||
text = text.Replace("\n", " ").Replace("\r", " ");
|
||||
text = text.Trim();
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
public static bool IsHtmlText(string text)
|
||||
{
|
||||
if (Regex.IsMatch(text, "<[^>]*>"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (Regex.IsMatch(text, "{[^}]*}"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (text.Contains("\n") || text.Contains("\r"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Get name for role
|
||||
public static string GetRoleName(RoleTypes role) => Main.GetRoleName[(int)role];
|
||||
// Get hex color for team
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using static Rewired.Data.UserDataStore_PlayerPrefs.ControllerAssignmentSaveInfo;
|
||||
|
||||
namespace BetterAmongUs.Patches;
|
||||
|
||||
@@ -12,6 +13,7 @@ public static class OptionsMenuBehaviourPatch
|
||||
private static ClientOptionItem BetterHost;
|
||||
private static ClientOptionItem BetterRoleAlgorithma;
|
||||
private static ClientOptionItem BetterNotifications;
|
||||
private static ClientOptionItem UseBannedList;
|
||||
private static ClientOptionItem LobbyPlayerInfo;
|
||||
private static ClientOptionItem DisableLobbyTheme;
|
||||
private static ClientOptionItem UnlockFPS;
|
||||
@@ -53,6 +55,11 @@ public static class OptionsMenuBehaviourPatch
|
||||
{
|
||||
RPC.SendBetterCheck();
|
||||
|
||||
foreach (var kvp in PlayerControlDataExtension.playerInfo)
|
||||
{
|
||||
PlayerControlDataExtension.playerInfo[kvp.Key].LastNameSetFor.Clear();
|
||||
}
|
||||
|
||||
RPC.SyncAllNames(force: true);
|
||||
}
|
||||
}
|
||||
@@ -73,6 +80,11 @@ public static class OptionsMenuBehaviourPatch
|
||||
BetterNotificationManager.Notifying = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (UseBannedList == null || UseBannedList.ToggleButton == null)
|
||||
{
|
||||
UseBannedList = ClientOptionItem.Create("Use Ban Lists", Main.UseBannedList, __instance);
|
||||
}
|
||||
|
||||
if (LobbyPlayerInfo == null || LobbyPlayerInfo.ToggleButton == null)
|
||||
{
|
||||
|
||||
@@ -151,7 +151,7 @@ public class ClientPatch
|
||||
[HarmonyPrefix]
|
||||
public static void Show_Prefix(ref string playerName)
|
||||
{
|
||||
if (playerName.Contains("Anti-Cheat"))
|
||||
if (Utils.IsHtmlText(playerName))
|
||||
{
|
||||
string extractedText = playerName.Split(new[] { "<color=#ffea00>", "</color>" }, StringSplitOptions.None)[1];
|
||||
playerName = extractedText;
|
||||
|
||||
@@ -23,7 +23,7 @@ class GamePlayManager
|
||||
// Clear unused Better Data
|
||||
var keysToRemove = new List<string>();
|
||||
|
||||
foreach (var betterInfo in PlayerControlExtensions.playerInfo)
|
||||
foreach (var betterInfo in PlayerControlDataExtension.playerInfo)
|
||||
{
|
||||
if (!Main.AllPlayerControls.Any(pc => pc.Data.Puid == betterInfo.Key))
|
||||
{
|
||||
@@ -33,7 +33,7 @@ class GamePlayManager
|
||||
|
||||
foreach (var key in keysToRemove)
|
||||
{
|
||||
PlayerControlExtensions.playerInfo.Remove(key);
|
||||
PlayerControlDataExtension.playerInfo.Remove(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -55,25 +55,6 @@ public class HudManagerPatch
|
||||
|
||||
if (GameStates.InGame && __instance?.Chat?.gameObject.active != true)
|
||||
__instance.Chat.gameObject.SetActive(true);
|
||||
|
||||
GameObject TaskDisplay = GameObject.Find("TaskDisplay");
|
||||
GameObject ProgressTracker = GameObject.Find("ProgressTracker");
|
||||
if (TaskDisplay != null && ProgressTracker != null)
|
||||
{
|
||||
if (PlayerControl.LocalPlayer.IsImpostorTeam())
|
||||
{
|
||||
__instance.CrewmatesKilled.gameObject.SetActive(true);
|
||||
__instance.CrewmatesKilled.gameObject.transform.SetLocalZ(-25);
|
||||
TaskDisplay.transform.localPosition = new Vector3(0f, -0.4f, -5f);
|
||||
ProgressTracker.transform.localPosition = new Vector3(-2.8733f, 3.1f);
|
||||
}
|
||||
else if (__instance.CrewmatesKilled.isActiveAndEnabled)
|
||||
{
|
||||
__instance.CrewmatesKilled.gameObject.SetActive(GameManager.Instance.ShowCrewmatesKilled());
|
||||
TaskDisplay.transform.localPosition = new Vector3(0f, 0f);
|
||||
ProgressTracker.transform.localPosition = new Vector3(-2.8733f, 2.7f, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using AmongUs.Data;
|
||||
using AmongUs.GameOptions;
|
||||
using HarmonyLib;
|
||||
using Il2CppSystem.Linq;
|
||||
using LibCpp2IL;
|
||||
@@ -68,18 +69,7 @@ class PlayerControlPatch
|
||||
}
|
||||
|
||||
// Reset player data in lobby
|
||||
if (!GameStates.IsInGamePlay)
|
||||
{
|
||||
__instance.BetterData().TimesCalledMeeting = 0;
|
||||
__instance.BetterData().RoleInfo.HasNoisemakerNotify = false;
|
||||
__instance.BetterData().TimeSinceLastTask = 5f;
|
||||
__instance.BetterData().LastTaskId = 999;
|
||||
__instance.BetterData().RoleInfo.Kills = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.BetterData().TimeSinceLastTask += Time.deltaTime;
|
||||
}
|
||||
PlayerControlDataExtension.ResetPlayerData(__instance);
|
||||
}
|
||||
|
||||
public static void SetPlayerInfo(PlayerControl player)
|
||||
@@ -173,7 +163,7 @@ class PlayerControlPatch
|
||||
|
||||
sbTagBottom.Append($"<color={friendCodeColor}>{friendCode}</color>+++");
|
||||
}
|
||||
else if (GameStates.IsInGame || GameStates.IsFreePlay)
|
||||
else if ((GameStates.IsInGame || GameStates.IsFreePlay) && !GameStates.IsHideNSeek)
|
||||
{
|
||||
if (player.IsImpostorTeammate() || player == PlayerControl.LocalPlayer || !PlayerControl.LocalPlayer.IsAlive() || DebugMenu.RevealRoles)
|
||||
{
|
||||
@@ -205,7 +195,7 @@ class PlayerControlPatch
|
||||
string[] parts = text.Split("+++");
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Utils.GetRawText(parts[i])))
|
||||
if (!string.IsNullOrEmpty(Utils.RemoveHtmlText(parts[i])))
|
||||
{
|
||||
destination.Append(parts[i]);
|
||||
if (i != parts.Length - 2)
|
||||
@@ -231,6 +221,17 @@ class PlayerControlPatch
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(PlayerControl.RpcSetName))]
|
||||
[HarmonyPrefix]
|
||||
public static bool RpcSetName_Prefix([HarmonyArgument(0)] string name)
|
||||
{
|
||||
if (!GameStates.IsVanillaServer && Utils.IsHtmlText(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(PlayerControl.SetColor))]
|
||||
[HarmonyPostfix]
|
||||
@@ -251,9 +252,6 @@ class PlayerControlPatch
|
||||
{
|
||||
if (target == null) return;
|
||||
|
||||
if (PlayerControl.LocalPlayer.IsImpostorTeam() && GameStates.IsInGamePlay && !GameStates.IsHideNSeek && HudManager.Instance.CrewmatesKilled.isActiveAndEnabled)
|
||||
HudManager.Instance?.NotifyOfDeath();
|
||||
|
||||
Logger.LogPrivate($"{__instance.Data.PlayerName} Has killed {target.Data.PlayerName} as {Utils.GetRoleName(__instance.Data.RoleType)}", "EventLog");
|
||||
|
||||
__instance.BetterData().RoleInfo.Kills += 1;
|
||||
|
||||
@@ -11,7 +11,7 @@ class OnGameJoinedPatch
|
||||
{
|
||||
try
|
||||
{
|
||||
PlayerControlExtensions.playerInfo.Clear();
|
||||
PlayerControlDataExtension.playerInfo.Clear();
|
||||
|
||||
PlayerControlPatch.infotime = 0f;
|
||||
|
||||
@@ -50,45 +50,55 @@ public static class OnPlayerJoinedPatch
|
||||
client.Character.RpcSendHostChat(HudManagerPatch.WelcomeMessage, sendToBetterUser: false);
|
||||
|
||||
// Auto ban player on ban list
|
||||
var player = Utils.PlayerFromClientId(client.Id);
|
||||
if (player != null)
|
||||
if (Main.UseBannedList.Value)
|
||||
{
|
||||
string banPlayerListContent = File.ReadAllText(BetterDataManager.banPlayerListFile);
|
||||
|
||||
string[] listPlayerArray = banPlayerListContent.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
|
||||
|
||||
foreach (string text in listPlayerArray)
|
||||
var player = Utils.PlayerFromClientId(client.Id);
|
||||
if (player != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(player.Data.FriendCode) && text.Contains(player.Data.FriendCode)
|
||||
|| !string.IsNullOrEmpty(Utils.GetHashPuid(player)) && text.Contains(Utils.GetHashPuid(player)))
|
||||
try
|
||||
{
|
||||
player.Kick(true, $"{player.Data.PlayerName} has been banned due to being on the ban player list!");
|
||||
break;
|
||||
string banPlayerListContent = File.ReadAllText(BetterDataManager.banPlayerListFile);
|
||||
|
||||
string[] listPlayerArray = banPlayerListContent.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
|
||||
|
||||
foreach (string text in listPlayerArray)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(player.Data.FriendCode) && text.Contains(player.Data.FriendCode)
|
||||
|| !string.IsNullOrEmpty(Utils.GetHashPuid(player)) && text.Contains(Utils.GetHashPuid(player)))
|
||||
{
|
||||
player.Kick(true, $"has been banned due to being on the ban player list!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
try
|
||||
{
|
||||
// Normalize and remove spaces and special characters from names
|
||||
Func<string, string> normalizeName = name => new string(name.Where(c => char.IsLetterOrDigit(c)).ToArray()).ToLower();
|
||||
|
||||
// Read all banned names into a HashSet with normalized names
|
||||
HashSet<string> bannedNames = new HashSet<string>(
|
||||
File.ReadLines(BetterDataManager.banNameListFile)
|
||||
.Select(normalizeName)
|
||||
.Where(name => !string.IsNullOrWhiteSpace(name))
|
||||
);
|
||||
|
||||
string normalizedPlayerName = normalizeName(player.Data.PlayerName);
|
||||
|
||||
// Check if any banned name is a prefix of the player's normalized name
|
||||
bool isNameBanned = bannedNames.Any(bannedName =>
|
||||
normalizedPlayerName.StartsWith(bannedName)
|
||||
);
|
||||
|
||||
if (!string.IsNullOrEmpty(normalizedPlayerName) && isNameBanned)
|
||||
{
|
||||
player.Kick(false, $"has been kicked due to their name being on the ban name list!");
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
// Normalize and remove spaces and special characters from names
|
||||
Func<string, string> normalizeName = name => new string(name.Where(c => char.IsLetterOrDigit(c)).ToArray()).ToLower();
|
||||
|
||||
// Read all banned names into a HashSet with normalized names
|
||||
HashSet<string> bannedNames = new HashSet<string>(
|
||||
File.ReadLines(BetterDataManager.banNameListFile)
|
||||
.Select(normalizeName)
|
||||
.Where(name => !string.IsNullOrWhiteSpace(name))
|
||||
);
|
||||
|
||||
string normalizedPlayerName = normalizeName(player.Data.PlayerName);
|
||||
|
||||
// Check if any banned name is a prefix of the player's normalized name
|
||||
bool isNameBanned = bannedNames.Any(bannedName =>
|
||||
normalizedPlayerName.StartsWith(bannedName)
|
||||
);
|
||||
|
||||
if (!string.IsNullOrEmpty(normalizedPlayerName) && isNameBanned)
|
||||
{
|
||||
player.Kick(false, $"{player.Data.PlayerName} has been kicked due to their name being on the ban name list!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}, 2.5f, "OnPlayerJoinedPatch", false);
|
||||
@@ -99,8 +109,6 @@ class OnPlayerLeftPatch
|
||||
{
|
||||
public static void Postfix(/*AmongUsClient __instance,*/ [HarmonyArgument(0)] ClientData data, [HarmonyArgument(1)] DisconnectReasons reason)
|
||||
{
|
||||
if ((GameStates.IsInGame || GameStates.IsFreePlay) && !GameStates.IsLobby && !GameStates.IsHideNSeek && HudManager.Instance.CrewmatesKilled.isActiveAndEnabled)
|
||||
HudManager.Instance?.NotifyOfDisconnect(data.Character);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -377,9 +377,6 @@ public class RoleManagerPatch
|
||||
[HarmonyPrefix]
|
||||
public static bool AssignRoleOnDeath_Prefix(/*RoleManager __instance*/ [HarmonyArgument(0)] PlayerControl player)
|
||||
{
|
||||
if (player.Data.RoleType != RoleTypes.CrewmateGhost && player.Data.RoleType != RoleTypes.ImpostorGhost)
|
||||
player.BetterData().RoleInfo.DeadDisplayRole = player.Data.RoleType;
|
||||
|
||||
if (!Main.BetterRoleAlgorithma.Value) return true;
|
||||
|
||||
Dictionary<RoleTypes, int> GhostRoles = new() // Role, Amount
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
using HarmonyLib;
|
||||
|
||||
namespace BetterAmongUs.Patches;
|
||||
|
||||
[HarmonyPatch(typeof(Constants), nameof(Constants.GetBroadcastVersion))]
|
||||
class ServerUpdatePatch
|
||||
{
|
||||
static void Postfix(ref int __result)
|
||||
{
|
||||
var region = ServerManager.Instance.CurrentRegion.Name;
|
||||
|
||||
if (GameStates.IsLocalGame)
|
||||
{
|
||||
}
|
||||
if (GameStates.IsOnlineGame)
|
||||
{
|
||||
if (region.Contains("MNA") || region.Contains("MEU") || region.Contains("MAS"))
|
||||
{
|
||||
__result += 25;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
[HarmonyPatch(typeof(Constants), nameof(Constants.IsVersionModded))]
|
||||
public static class IsVersionModdedPatch
|
||||
{
|
||||
public static bool Prefix(ref bool __result)
|
||||
{
|
||||
var region = ServerManager.Instance.CurrentRegion.Name;
|
||||
|
||||
if (region.Contains("MNA") || region.Contains("MEU") || region.Contains("MAS"))
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -27,8 +27,8 @@ public class Main : BasePlugin
|
||||
public const string HotfixNum = "0";
|
||||
public const bool IsHotFix = false;
|
||||
public const string PluginGuid = "com.d1gq.betteramongus";
|
||||
public const string PluginVersion = "1.0.2";
|
||||
public const string ReleaseDate = "08.16.2024"; // mm/dd/yyyy
|
||||
public const string PluginVersion = "1.0.4";
|
||||
public const string ReleaseDate = "08.19.2024"; // mm/dd/yyyy
|
||||
public const string Github = "https://github.com/D1GQ/BetterAmongUs-Public";
|
||||
public const string Discord = "https://discord.gg/vjYrXpzNAn";
|
||||
|
||||
@@ -161,6 +161,7 @@ public class Main : BasePlugin
|
||||
public static ConfigEntry<bool> BetterHost { get; private set; }
|
||||
public static ConfigEntry<bool> BetterRoleAlgorithma { get; private set; }
|
||||
public static ConfigEntry<bool> BetterNotifications { get; private set; }
|
||||
public static ConfigEntry<bool> UseBannedList { get; private set; }
|
||||
public static ConfigEntry<bool> LobbyPlayerInfo { get; private set; }
|
||||
public static ConfigEntry<bool> DisableLobbyTheme { get; private set; }
|
||||
public static ConfigEntry<bool> UnlockFPS { get; private set; }
|
||||
@@ -172,6 +173,7 @@ public class Main : BasePlugin
|
||||
BetterHost = Config.Bind("Better Options", "BetterHost", false);
|
||||
BetterRoleAlgorithma = Config.Bind("Better Options", "BetterRoleAlgorithma", true);
|
||||
BetterNotifications = Config.Bind("Better Options", "BetterNotifications", true);
|
||||
UseBannedList = Config.Bind("Better Options", "UseBannedList", true);
|
||||
LobbyPlayerInfo = Config.Bind("Better Options", "LobbyPlayerInfo", true);
|
||||
DisableLobbyTheme = Config.Bind("Better Options", "DisableLobbyTheme", true);
|
||||
UnlockFPS = Config.Bind("Better Options", "UnlockFPS", false);
|
||||
|
||||
Reference in new issue
Block a user