diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index c887cb8..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Build AntiCheat (.NET Framework 4.7.2) - -on: - push: - branches: - - main - pull_request: - branches: - - main - workflow_dispatch: - -jobs: - build: - runs-on: windows-2019 - - steps: - - name: 检出代码 - uses: actions/checkout@v3 - - - name: 设置 NuGet - uses: NuGet/setup-nuget@v1.0.5 - - - name: 恢复 NuGet 包 - run: nuget restore AntiCheat.sln - - - name: 设置 MSBuild - uses: microsoft/setup-msbuild@v1.1 - - - name: 编译解决方案 - run: msbuild AntiCheat.sln /p:Configuration=Release /p:Platform="Any CPU" diff --git a/.gitignore b/.gitignore index f4224b5..9491a2f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,363 @@ -################################################################################ -# 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。 -################################################################################ - -/AntiCheat/obj/Debug -/.vs -/AntiCheat/bin/Debug -/AntiCheat.zip +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd \ No newline at end of file diff --git a/AntiCheat.slnx b/AntiCheat.slnx new file mode 100644 index 0000000..d1da2d4 --- /dev/null +++ b/AntiCheat.slnx @@ -0,0 +1,3 @@ + + + diff --git a/AntiCheat/.vs/AntiCheat.csproj.dtbcache.json b/AntiCheat/.vs/AntiCheat.csproj.dtbcache.json deleted file mode 100644 index 3e11cd3..0000000 --- a/AntiCheat/.vs/AntiCheat.csproj.dtbcache.json +++ /dev/null @@ -1 +0,0 @@ -{"RootPath":"C:\\Users\\91021\\source\\repos\\AntiCheat\\AntiCheat","ProjectFileName":"AntiCheat.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[],"References":[],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"C:\\Users\\91021\\source\\repos\\AntiCheat\\AntiCheat\\bin\\Debug\\AntiCheat.dll","OutputItemRelativePath":"AntiCheat.dll"},{"OutputItemFullPath":"","OutputItemRelativePath":""}],"CopyToOutputEntries":[]} \ No newline at end of file diff --git a/AntiCheat/AntiCheat.csproj b/AntiCheat/AntiCheat.csproj new file mode 100644 index 0000000..4a00d6b --- /dev/null +++ b/AntiCheat/AntiCheat.csproj @@ -0,0 +1,55 @@ + + + + netstandard2.1 + AntiCheat + chuxiaaaa + AntiCheat + AntiCheat + 1.0.0 + $(Product).deps.json + $(Product) + $(Product) + + + true + embedded + $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)'))=./ + + + + + $(AssemblyName) + $(Product) + $(Version) + + + + $(IntermediateOutputPath)LCMPluginInfo.cs + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + diff --git a/AntiCheat/AntiCheatPlugin.cs b/AntiCheat/AntiCheatPlugin.cs new file mode 100644 index 0000000..f2b5f9f --- /dev/null +++ b/AntiCheat/AntiCheatPlugin.cs @@ -0,0 +1,99 @@ +using AntiCheat; +using AntiCheat.Locale; + +using BepInEx; +using BepInEx.Logging; + +using GameNetcodeStuff; + +using HarmonyLib; + +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; + +[BepInPlugin(LCMPluginInfo.PLUGIN_GUID, LCMPluginInfo.PLUGIN_NAME, LCMPluginInfo.PLUGIN_VERSION)] +public class AntiCheatPlugin : BaseUnityPlugin +{ + internal static ManualLogSource Log = null!; + + private void Awake() + { + Log = Logger; + PluginConfig.Init(this); + } + + public static void LogInfo(string info) + { + if (StartOfRound.Instance == null || StartOfRound.Instance.IsHost) + { + if (PluginConfig.Log == null || PluginConfig.Log.Value) + { + Log.LogInfo($"{info}"); + File.AppendAllLines("AntiCheat.log", new string[] { $"[{DateTime.Now.ToString("MM-dd HH:mm:ss:ff")}] {info}" }); + } + } + } + + public static void LogInfo(PlayerControllerB p, string rpc, params object[] param) + { + LogInfo($"{p.playerUsername}({p.playerClientId}) -> {rpc};{string.Join("|", param)}"); + } + + private static string lastMessage = string.Empty; + + private static readonly MethodInfo AddChatMessageMethod = + AccessTools.DeclaredMethod(typeof(HUDManager), "AddChatMessage"); + + private static readonly MethodInfo AddTextMessageClientRpcMethod = + AccessTools.DeclaredMethod(typeof(HUDManager), "AddTextMessageClientRpc"); + + /// + /// 在游戏中输出信息 + /// + public static void ShowMessage(string msg, string dedupeKey = null) + { + var template = locale.MessageFormat(); + var showmsg = template + .Replace("{Prefix}", locale.Prefix()) + .Replace("{msg}", msg); + + var compareKey = dedupeKey ?? showmsg; + + if (lastMessage == compareKey) + return; + + lastMessage = compareKey; + + if (HUDManager.Instance == null) + return; + + switch (PluginConfig.DetectedMessageType.Value) + { + case PluginConfig.MessageType.PublicChat: + AddTextMessageClientRpc(showmsg); + break; + + case PluginConfig.MessageType.HostChat: + ShowMessageHostOnly(showmsg); + break; + default: + LogInfo($"ShowGUI|{showmsg}"); + break; + } + + + } + + public static void ShowMessageHostOnly(string msg) + { + LogInfo($"ShowMessageHostOnly -> {msg}"); + AddChatMessageMethod.Invoke(HUDManager.Instance,new object[] { msg, "", -1, false }); + } + + public static void AddTextMessageClientRpc(string showmsg) + { + AddTextMessageClientRpcMethod.Invoke(HUDManager.Instance,new object[] { showmsg }); + } +} diff --git a/AntiCheat/Build/Build.bat b/AntiCheat/Build/Build.bat deleted file mode 100644 index 0874d9f..0000000 --- a/AntiCheat/Build/Build.bat +++ /dev/null @@ -1,56 +0,0 @@ -@echo off -setlocal enabledelayedexpansion - -:: ��ȡ���� -set projectDir=%~1 -set targetDir=%~2 -set solutionDir=%~3 -set projectName=%~4 - -:: ������ʱĿ¼ -set tempDir=%TEMP%\%projectName% -if exist "%tempDir%" ( - rmdir /s /q "%tempDir%" -) -mkdir "%tempDir%" - -:: �����ĵ��ļ� -copy "%solutionDir%CHANGELOG.md" "%tempDir%\" >nul 2>&1 -copy "%solutionDir%README.md" "%tempDir%\" >nul 2>&1 - -:: �������Ŀ¼�ṹ -mkdir "%tempDir%\BepInEx\plugins" -copy "%targetDir%%projectName%.dll" "%tempDir%\BepInEx\plugins\" >nul 2>&1 - -:: �Զ��������������ļ� -set langSourceDir=%projectDir%Lang -set localesDir=%tempDir%\BepInEx\plugins\locales - -if exist "%langSourceDir%" ( - mkdir "%localesDir%" - echo ���ڸ��������ļ�: - for %%f in ("%langSourceDir%\*") do ( - copy "%%f" "%localesDir%\" >nul 2>&1 - echo - %%~nxf - ) -) - -:: ����������Դ�ļ� -copy "%solutionDir%icon.png" "%tempDir%\" >nul 2>&1 -copy "%solutionDir%manifest.json" "%tempDir%\" >nul 2>&1 - -:: ����ZIP�ļ� -set zipPath=%solutionDir%%projectName%.zip -if exist "%zipPath%" ( - del /f "%zipPath%" -) - -:: ʹ������ѹ������ (Windows 10+) -powershell -Command "Compress-Archive -Path '%tempDir%\*' -DestinationPath '%zipPath%' -Force" - -:: ������ʱĿ¼ -rmdir /s /q "%tempDir%" - -:: ������ -echo. -echo ZIP������: %zipPath% \ No newline at end of file diff --git a/AntiCheat/Core/AntiCheat.cs b/AntiCheat/Core/AntiCheat.cs deleted file mode 100644 index e2e4b5b..0000000 --- a/AntiCheat/Core/AntiCheat.cs +++ /dev/null @@ -1,446 +0,0 @@ -using AntiCheat.Locale; -using AntiCheat.Patch; - -using BepInEx; -using BepInEx.Configuration; -using BepInEx.Logging; - -using GameNetcodeStuff; - -using HarmonyLib; - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.IO; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; - -using UnityEngine; -using UnityEngine.Diagnostics; -using UnityEngine.Rendering; -using UnityEngine.SceneManagement; - -namespace AntiCheat.Core -{ - [BepInPlugin("AntiCheat", "AntiCheat", Version)] - public class AntiCheat : BaseUnityPlugin - { - public const string Version = "0.8.7"; - public static ManualLogSource ManualLog = null; - - public enum MessageType - { - GUI, - HostChat, - PublicChat - } - - public static Locale.LocalizationManager localizationManager = null; - - - public static ConfigEntry Log; - public static ConfigEntry OperationLog; - - public static ConfigEntry IgnoreClientConfig; - - public static GameObject ui; - - public static ConfigEntry Shovel; - public static ConfigEntry Shovel2; - public static ConfigEntry Shovel3; - - public static ConfigEntry Prefix; - public static ConfigEntry PlayerJoin; - - public static ConfigEntry ShipConfig; - public static ConfigEntry ShipConfig2; - public static ConfigEntry ShipConfig3; - public static ConfigEntry ShipConfig4; - public static ConfigEntry Ship_Kick; - public static ConfigEntry ShipSetting_OnlyOneVote; - public static ConfigEntry ShipSetting_ChangToFreeMoon; - - public static ConfigEntry ShipBuild; - public static ConfigEntry ShipBuild2; - - public static ConfigEntry ShipLight; - public static ConfigEntry ShipLight_Cooldown; - - public static ConfigEntry TerminalNoise; - public static ConfigEntry TerminalNoise_Cooldown; - - public static ConfigEntry DespawnItem; - public static ConfigEntry DespawnItem2; - - public static ConfigEntry ChatReal; - public static ConfigEntry ChatReal_Cooldown; - public static ConfigEntry ChatReal2; - - public static ConfigEntry Mask; - public static ConfigEntry Mask2; - - public static ConfigEntry Gift; - public static ConfigEntry Gift2; - - public static ConfigEntry Invisibility; - public static ConfigEntry Invisibility2; - - public static ConfigEntry GrabObject; - public static ConfigEntry GrabObject_MoreSlot; - public static ConfigEntry GrabObject_TwoHand; - public static ConfigEntry GrabObject_BeltBag; - public static ConfigEntry GrabObject_Kick; - - public static ConfigEntry Boss; - public static ConfigEntry Boss2; - - public static ConfigEntry Landmine; - public static ConfigEntry Landmine2; - - public static ConfigEntry PlayerCarryWeight; - public static ConfigEntry PlayerCarryWeight2; - public static ConfigEntry PlayerCarryWeight3; - - - public static ConfigEntry Turret; - public static ConfigEntry Turret2; - - public static ConfigEntry Enemy; - - public static ConfigEntry KillEnemy; - public static ConfigEntry KillEnemy2; - - public static ConfigEntry SpawnWebTrap; - public static ConfigEntry SpawnWebTrap2; - - public static ConfigEntry Map; - public static ConfigEntry Map2; - - public static ConfigEntry Jetpack; - public static ConfigEntry Jetpack2; - - public static ConfigEntry ItemCooldown; - public static ConfigEntry ItemCooldown2; - - public static ConfigEntry InfiniteAmmo; - public static ConfigEntry InfiniteAmmo2; - - public static ConfigEntry FreeBuy; - public static ConfigEntry FreeBuy2; - - public static ConfigEntry RemoteTerminal; - public static ConfigEntry RemoteTerminal2; - - public static ConfigEntry Nameless; - public static ConfigEntry Nameless2; - - public static ConfigEntry RPCReport_Delay; - public static ConfigEntry RPCReport_Hit; - public static ConfigEntry RPCReport_KillPlayer; - public static ConfigEntry RPCReport_Kick; - - public static ConfigEntry Health_Recover; - public static ConfigEntry Health_Kick; - - - public static ConfigEntry DetectedMessageType; - - public static bool Gui; - - - //public static void String(string text, GUIStyle style, float yPos) - //{ - // float screenWidth = Screen.width; - // Vector2 textSize = style.CalcSize(new GUIContent(text)); - // float xPos = (screenWidth - textSize.x) / 2; - // GUI.Label(new Rect(xPos, yPos, textSize.x, textSize.y), text, style); - //} - - //public void Update() - //{ - // if (StartOfRound.Instance != null && !StartOfRound.Instance.IsHost) - // { - // return; - // } - // if (UnityInput.Current.GetKeyDown(KeyCode.F10)) - // { - // Gui = !Gui; - // } - //} - - //public void OnGUI() - //{ - // if (StartOfRound.Instance != null && !StartOfRound.Instance.IsHost) - // { - // return; - // } - // Scene activeScene = SceneManager.GetActiveScene(); - // Color darkBackground = new Color(23f / 255f, 23f / 255f, 23f / 255f, 1f); - - // GUI.backgroundColor = darkBackground; - // GUI.contentColor = Color.white; - - // var Style = new GUIStyle(GUI.skin.label); - // Style.normal.textColor = Color.white; - // Style.fontStyle = FontStyle.Bold; - // if (activeScene.name == "SampleSceneRelay") - // { - // if (!Gui) - // { - // String($"AntiCheat(Beta{AntiCheatPlugin.Version}) Press F10", Style, 10); - // Cursor.visible = false; - // Cursor.lockState = CursorLockMode.Locked; - // } - // else - // { - // Cursor.visible = true; - // Cursor.lockState = CursorLockMode.None; - // ShowMenu(); - // } - // } - //} - - public Dictionary Tabs { get; set; } - - //public void ShowMenu() - //{ - // var e = Event.current.type; - // if (e == EventType.Layout || e == EventType.Repaint) - // { - // float screenWidth = (Screen.width - 600) / 2; - // GUILayout.Window(0, new Rect(screenWidth, 10, 600, 300), (x) => - // { - // foreach (var item in Tabs) - // { - // if (GUILayout.Button(item.Key) || item.Value) - // { - // if (!item.Value) - // { - // Tabs[item.Key] = true; - // } - // GUILayout.BeginScrollView(Vector2.zero); - // foreach (var item2 in Config.Keys.GroupBy(p => p.Section)) - // { - // GUILayout.Label(item2.Key); - // foreach (var item3 in item2) - // { - // if (GUILayout.Button(item3.Key)) - // { - - // } - // } - // } - // GUILayout.EndScrollView(); - // } - // } - - // GUILayout.BeginHorizontal(); - // foreach (var item in StartOfRound.Instance.allPlayerScripts) - // { - // //if (item.isPlayerControlled) - // //{ - // // GUILayout.Label($"{item.playerUsername}:{item.gameObject.}"); - // //} - // } - // if (GUILayout.Button("检测记录")) - // { - - // } - // else if (GUILayout.Button("玩家管理")) - // { - - // } - // else if (GUILayout.Button("黑名单管理")) - // { - - // } - // else if (GUILayout.Button("语言设置")) - // { - - // } - // GUILayout.EndHorizontal(); - // }, $"AntiCheat(Beta{AntiCheatPlugin.Version})"); - // } - //} - - void Awake() - { - ManualLog = Logger; - //Tabs = new Dictionary(); - //Tabs.Add("模组配置", false); - FileSystemWatcher watcher = new FileSystemWatcher(); - var fi = new FileInfo(Config.ConfigFilePath); - watcher.Path = fi.DirectoryName; - watcher.Filter = fi.Name; - watcher.Changed += Watcher_Changed; - LoadConfig(); - watcher.EnableRaisingEvents = true; - - Harmony.CreateAndPatchAll(typeof(Patches)); - Harmony.CreateAndPatchAll(typeof(ShipTeleporterPatch)); - Harmony.CreateAndPatchAll(typeof(TurretPatch)); - Harmony.CreateAndPatchAll(typeof(HUDManagerPatch)); - Harmony.CreateAndPatchAll(typeof(StartOfRoundPatch)); - Harmony.CreateAndPatchAll(typeof(GrabbableObjectPatch)); - Harmony.CreateAndPatchAll(typeof(TerminalPatch)); - Harmony.CreateAndPatchAll(typeof(PlayerControllerBPatch)); - Harmony.CreateAndPatchAll(typeof(DoorLockPatch)); - Harmony.CreateAndPatchAll(typeof(LandminePatch)); - Harmony.CreateAndPatchAll(typeof(RoundManagerPatch)); - Harmony.CreateAndPatchAll(typeof(TerminalAccessibleObjectPatch)); - } - - private void Watcher_Changed(object sender, FileSystemEventArgs e) - { - LogInfo($"Reload Config"); - LoadConfig(); - } - - public static void LogInfo(string info) - { - if (StartOfRound.Instance == null || StartOfRound.Instance.IsHost) - { - if (Log == null || Log.Value) - { - ManualLog.LogInfo($"{info}"); - File.AppendAllLines("AntiCheat.log", new string[] { $"[{DateTime.Now.ToString("MM-dd HH:mm:ss:ff")}] {info}" }); - } - } - } - - public static void LogInfo(PlayerControllerB p,string rpc, params object[] param) - { - LogInfo($"{p.playerUsername}({p.playerClientId}) -> {rpc};{string.Join("|", param)}"); - } - - private void LoadConfig() - { - localizationManager = new LocalizationManager(); - IgnoreClientConfig = Config.Bind("VersionSetting", "NetworkSetting", false, localizationManager.Cfg_GetString("NetworkSetting")); - Prefix = Config.Bind("ServerNameSetting", "Prefix", "AC", localizationManager.Cfg_GetString("Prefix")); - ShipConfig = Config.Bind("ShipSetting", "StartGameOnlyHost", true, localizationManager.Cfg_GetString("ShipSetting")); - Log = Config.Bind("LogSetting", "Log", true, localizationManager.Cfg_GetString("Log")); - OperationLog = Config.Bind("LogSetting", "OperationLog", true, localizationManager.Cfg_GetString("OperationLog")); - - Ship_Kick = Config.Bind("ShipSetting", "Kick", false, localizationManager.Cfg_GetString("ShipConfig5")); - ShipConfig2 = Config.Bind("ShipSetting", "StartGamePlayerCount", 8, localizationManager.Cfg_GetString("ShipConfig2")); - ShipConfig3 = Config.Bind("ShipSetting", "EndGamePlayerTime", "14:00", localizationManager.Cfg_GetString("ShipConfig3")); - ShipConfig4 = Config.Bind("ShipSetting", "EndGamePlayerCount", 50, localizationManager.Cfg_GetString("ShipConfig4")); - ShipSetting_OnlyOneVote = Config.Bind("ShipSetting", "OnlyOneVote", true, localizationManager.Cfg_GetString("ShipConfig6")); - ShipSetting_ChangToFreeMoon = Config.Bind("ShipSetting", "ChangToFreeMoon", false, localizationManager.Cfg_GetString("ChangToFreeMoon")); - - - RPCReport_Delay = Config.Bind("RPCReportSetting", "Delay", 1000, localizationManager.Cfg_GetString("RPCReport_Delay")); - RPCReport_Hit = Config.Bind("RPCReportSetting", "Hit", true, localizationManager.Cfg_GetString("RPCReport_Hit")); - RPCReport_KillPlayer = Config.Bind("RPCReportSetting", "KillPlayer", true, localizationManager.Cfg_GetString("RPCReport_KillPlayer")); - RPCReport_Kick = Config.Bind("RPCReportSetting", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - Health_Recover = Config.Bind("HealthSetting", "Recover", true, localizationManager.Cfg_GetString("Health_Recover")); - Health_Kick = Config.Bind("HealthSetting", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - ShipBuild = Config.Bind("ShipBuildSetting", "Enable", true, localizationManager.Cfg_GetString("ShipBuild")); - ShipBuild2 = Config.Bind("ShipBuildSetting", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - ItemCooldown = Config.Bind("ItemCooldownSetting", "Enable", true, localizationManager.Cfg_GetString("ItemCooldown")); - ItemCooldown2 = Config.Bind("ItemCooldownSetting", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - ShipLight = Config.Bind("ShipLightSettings", "Enable", true, localizationManager.Cfg_GetString("ShipLight")); - ShipLight_Cooldown = Config.Bind("ShipLightSettings", "Cooldown", 2000, localizationManager.Cfg_GetString("Cooldown")); - - TerminalNoise = Config.Bind("TerminalNoiseSettings", "Enable", true, localizationManager.Cfg_GetString("ShipTerminal")); - TerminalNoise_Cooldown = Config.Bind("TerminalNoiseSettings", "Cooldown", 1000, localizationManager.Cfg_GetString("Cooldown")); - - DetectedMessageType = Config.Bind("DetectedMessageType", "Type", MessageType.PublicChat, localizationManager.Cfg_GetString("DetectedMessageType")); - - DespawnItem = Config.Bind("DespawnItemSettings", "Enable", true, localizationManager.Cfg_GetString("DespawnItem")); - DespawnItem2 = Config.Bind("DespawnItemSettings", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - ChatReal = Config.Bind("ChatRealSettings", "Enable", true, localizationManager.Cfg_GetString("ChatReal")); - ChatReal_Cooldown = Config.Bind("ChatRealSettings", "Cooldown", 100, localizationManager.Cfg_GetString("Cooldown")); - ChatReal2 = Config.Bind("ChatRealSettings", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - Mask = Config.Bind("MaskSettings", "Enable", true, localizationManager.Cfg_GetString("Mask")); - Mask2 = Config.Bind("MaskSettings", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - Gift = Config.Bind("GiftSettings", "Enable", true, localizationManager.Cfg_GetString("Gift")); - Gift2 = Config.Bind("GiftSettings", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - Turret = Config.Bind("TurretSettings", "Enable", true, localizationManager.Cfg_GetString("Turret")); - Turret2 = Config.Bind("TurretSettings", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - InfiniteAmmo = Config.Bind("InfiniteAmmoSettings", "Enable", true, localizationManager.Cfg_GetString("InfiniteAmmo")); - InfiniteAmmo2 = Config.Bind("InfiniteAmmoSettings", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - Invisibility = Config.Bind("InvisibilitySettings", "Enable", true, localizationManager.Cfg_GetString("Invisibility")); - Invisibility2 = Config.Bind("InvisibilitySettings", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - - Boss = Config.Bind("BossSetting", "Enable", true, localizationManager.Cfg_GetString("Boss")); - Boss2 = Config.Bind("BossSetting", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - Jetpack = Config.Bind("JetpackSetting", "Enable", true, localizationManager.Cfg_GetString("Jetpack")); - Jetpack2 = Config.Bind("JetpackSetting", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - //PlayerCarryWeight = Config.Bind("PlayerCarryWeightSetting", "Enable", true, localizationManager.Cfg_GetString("PlayerCarryWeight")); - //PlayerCarryWeight2 = Config.Bind("PlayerCarryWeightSetting", "Recovery", false, localizationManager.Cfg_GetString("PlayerCarryWeight2")); - //PlayerCarryWeight3 = Config.Bind("PlayerCarryWeightSetting", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - Landmine = Config.Bind("LandmineSetting", "Enable", true, localizationManager.Cfg_GetString("Landmine")); - Landmine2 = Config.Bind("LandmineSetting", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - SpawnWebTrap = Config.Bind("SpawnWebTrapSetting", "Enable", true, localizationManager.Cfg_GetString("SpawnWebTrap")); - SpawnWebTrap2 = Config.Bind("SpawnWebTrapSetting", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - Enemy = Config.Bind("EnemySetting", "Enable", true, localizationManager.Cfg_GetString("Enemy")); - - KillEnemy = Config.Bind("KillEnemySetting", "Enable", true, localizationManager.Cfg_GetString("KillEnemy")); - KillEnemy2 = Config.Bind("KillEnemySetting", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - Map = Config.Bind("MapSetting", "Enable", true, localizationManager.Cfg_GetString("Map")); - Map2 = Config.Bind("MapSetting", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - GrabObject = Config.Bind("GrabObjectSetting", "Enable", true, localizationManager.Cfg_GetString("GrabObject")); - GrabObject_MoreSlot = Config.Bind("GrabObjectSetting", "MoreSlot", true, localizationManager.Cfg_GetString("GrabObject_MoreSlot")); - GrabObject_TwoHand = Config.Bind("GrabObjectSetting", "TwoHand", true, localizationManager.Cfg_GetString("GrabObject_TwoHand")); - GrabObject_BeltBag = Config.Bind("GrabObjectSetting", "BeltBag", true, localizationManager.Cfg_GetString("GrabObject_BeltBag")); - GrabObject_Kick = Config.Bind("GrabObjectSetting", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - Shovel = Config.Bind("ShovelSettings", "Enable", true, localizationManager.Cfg_GetString("Shovel")); - Shovel3 = Config.Bind("ShovelSettings", "EmptyHand", false, localizationManager.Cfg_GetString("Shovel2")); - Shovel2 = Config.Bind("ShovelSettings", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - Nameless = Config.Bind("NamelessSettings", "Enable", true, localizationManager.Cfg_GetString("Nameless")); - Nameless2 = Config.Bind("NamelessSettings", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - FreeBuy = Config.Bind("FreeBuySettings", "Enable", true, localizationManager.Cfg_GetString("FreeBuy")); - FreeBuy2 = Config.Bind("FreeBuySettings", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - RemoteTerminal = Config.Bind("RemoteTerminalSettings", "Enable", true, localizationManager.Cfg_GetString("RemoteTerminal")); - RemoteTerminal2 = Config.Bind("RemoteTerminalSettings", "Kick", false, localizationManager.Cfg_GetString("Kick")); - - PlayerJoin = Config.Bind("MsgSettings", "PlayerJoinShip", localizationManager.Msg_GetString("wlc_player"), localizationManager.Msg_GetString("wlc_player")); - CooldownManager.Reset(); - CooldownManager.RegisterCooldownGroup( - "TerminalNoise", - () => AntiCheat.TerminalNoise.Value, - () => AntiCheat.TerminalNoise_Cooldown.Value / 1000f - ); - CooldownManager.RegisterCooldownGroup( - "ShipLight", - () => AntiCheat.ShipLight.Value, - () => AntiCheat.ShipLight_Cooldown.Value / 1000f - ); - CooldownManager.RegisterCooldownGroup( - "Chat", - () => AntiCheat.ChatReal.Value, - () => AntiCheat.ChatReal_Cooldown.Value / 1000f - ); - LogInfo($"{localizationManager.Log_GetString("load")}"); - } - - } -} diff --git a/AntiCheat/FeatureConfig.cs b/AntiCheat/FeatureConfig.cs new file mode 100644 index 0000000..e1c603b --- /dev/null +++ b/AntiCheat/FeatureConfig.cs @@ -0,0 +1,39 @@ +using BepInEx.Configuration; + +using System; +using System.Collections.Generic; +using System.Text; + +namespace AntiCheat +{ + internal class FeatureConfig + { + private ConfigEntry _Enable { get; } + private ConfigEntry? _Kick { get; } + + public bool Enable => _Enable.Value; + + public bool Kick => _Kick?.Value ?? false; + + public FeatureConfig( + ConfigFile config, + string section, + string enableDesc, + bool defaultEnable = true, + bool hasKick = true) + { + _Enable = config.Bind(section, + "Enable", + defaultEnable, + enableDesc); + + if (hasKick) + { + _Kick = config.Bind(section, + "Kick", + false, + localizationManager.Cfg_GetString("Kick")); + } + } + } +} diff --git a/AntiCheat/Lang/en_US.json b/AntiCheat/Lang/en_US.json deleted file mode 100644 index 7ee4c66..0000000 --- a/AntiCheat/Lang/en_US.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "Config": { - "Boss": "Detects when a player attempts to force the company monster to attack.", - "ChangToFreeMoon": "Detects when a player routing moon from priced to free", - "ChatReal": "Detects when a player attempts to spoof their name as another player's.", - "Cooldown": "Cooldown time. (in ms)", - "DespawnItem": "Detects when items are unusually destroyed or deleted.", - "DetectedMessageType": "Decide detection message display type, PublicChat = Shown for everyone, HostChat = Will only display in chat for the host, GUI = Display in GUI.", - "Enemy": "Detects when a monster behaves abnormally.", - "FreeBuy": "Detects when a player ordering items without spending credits.", - "Gift": "Detects when a player having abnormal gift box interactions.", - "GrabObject": "Detects picking up items outside of default grab range.", - "GrabObject_BeltBag": "Disables players from picking up scrap with belt bags", - "GrabObject_MoreSlot": "Prevents players from picking up more than 4 items", - "GrabObject_TwoHand": "Prevents players from picking up multiple two-handed items at once", - "Health_Recover": "Detects when a player using negative damage to regen health", - "InfiniteAmmo": "Detects when a player has infinite ammo. Note that if a shotgun has already been given infinite ammo, a normal player using it may cause them to be detected as using infinite ammo as well.", - "Invisibility": "Detects invisible players.", - "ItemCooldown": "Detects when a player uses an item faster than they should.", - "Jetpack": "Detects when a player forces a jetpack explosion.", - "Kick": "Kick player when this behavior is detected.", - "KillEnemy": "Detects when an enemy is instantly killed.", - "Landmine": "Detects when a player abnormally detonates a landmine.", - "Log": "Show logs.", - "Map": "Detects the use of mini-map mods.", - "Mask": "Detects when masked enemies are spawned abnormally.", - "Nameless": "Detects invalid or anomalous player names such as Nameless or Unknown.", - "NetworkSetting": "Ignore network configuration differences and try to avoid 'an error occurred' dialog.", - "OperationLog": "Logging action made by the client.", - "PlayerCarryWeight": "Detecting abnormal player carry weight.", - "PlayerCarryWeight2": "Restore player carry weight.", - "Prefix": "Puts text in square brackets before the lobby name, leave empty to disable.", - "RemoteTerminal": "Detects when a player uses the terminal remotely.", - "RPCReport_Delay": "RPC report grace period, decide how many time passed everytime the clients have to report the RPC. (in ms)", - "RPCReport_Hit": "Enable Hit RPC report, when someone takes damage without reporting health lose, they will be detected. (invincibility detection)", - "RPCReport_KillPlayer": "Enable KillPlayer RPC report, when someone dead but not reporting by themself after that, they will be detected. (invincibility detection)", - "ShipBuild": "Detects the abnormal placement of furniture.", - "ShipConfig2": "Clients can only pull the lever when this player count is reached. (StartGameOnlyHost must be set to false)", - "ShipConfig3": "Clients can take off after this in-game time.", - "ShipConfig4": "Clients can take off when the number of living players in the ship is equal or greater than the specified percentage. (0-100%)", - "ShipConfig5": "Detects when a player attempts to force the ship lever. Kicks the player if detected.", - "ShipConfig6": "Allow your single vote to instantly force the autopilot when as host.", - "ShipLight": "Enable ship light switch cooldown.", - "ShipSetting": "Only the host may land the ship.", - "ShipTerminal": "Enable terminal noise sound cooldown.", - "Shovel": "Detects unusual shovel damage.", - "Shovel2": "Allow players to deal damage without a weapon. Note that some mods that can reverses hotbar scrolling can also cause items to be out of sync.", - "SpawnWebTrap": "Detects when a player tries to spawn spiderwebs.", - "Turret": "Detects when a player forces a turret to go berserk." - }, - "Item": { - "Knife": "Kitchen Knife", - "Shotgun": "Shotgun", - "Shovel": "Shovel", - "Cruiser": "Cruiser" - }, - "log": { - "load": "AntiCheat mod is loaded!", - "refuse_connect": "{steamId} attempted to connect to the game but was refused! (Already kicked)" - }, - "Message": { - "behind_player": "[{player}] was left behind.", - "Boss": "{player} detected attempting to force the company monster to attack!", - "ChangeLevel": "{player} was detected routing moon from priced to free! (Insufficient permissions)", - "ChangeToFreeLevel": "{player} was detected routing moon from priced to free!", - "ChatReal": "{player} tried to spoof {player2}'s name in chat!", - "DespawnItem": "{player} was detected destroying items!", - "Enemy_ChangeOwnershipOfEnemy": "{player} was detected trying to alter a monster's behavior!", - "Enemy_SwitchToBehaviour": "{player} was detected trying to alter a monster's state!", - "FreeBuy_Item": "{player} was detected buying an item for free!", - "FreeBuy_Level": "{player} was detected routing to a priced moon for free!", - "FreeBuy_SetMoney": "{player} was detected modifying crew credits! ({Money})!", - "FreeBuy_unlockable": "{player} was detected buying a ship unlockable for free!", - "game_start": "Anti-Cheat (v{ver}) is enabled in this lobby", - "Gift": "{player} was detected causing a gift box to behave abnormally!", - "GrabObject": "{player} was detected grabbing objects from too far away! (Player coordinates: {player_position}|Item coordinates: {object_position})", - "Health_Recover": "{player} was detected regenerating health ({hp})!", - "InfiniteAmmo": "{player} was detected using infinite ammo weapon!", - "Invisibility": "{player} was detected to be invisible! (Player coordinates: {player_position})", - "ItemCooldown": "{player} was detected using an item faster than its cooldown would allow!", - "Jetpack": "{player} was detected forcing a jetpack explosion!", - "Kick": "{player} was kicked!", - "KickPlayer": "A cheat was detected", - "KillEnemy": "{player} was detected killing a monster instantly! ({enemyName}, monster HP before: {HP})", - "Landmine": "{player} was detected forcing a landmine explosion!", - "Map": "{player} was detected to have a mini-map mod!", - "Mask": "{player} was detected to have spawned Masked enemies abnormally!", - "Nameless": "{player} was detected to have an anomalous or invalid name!", - "KickReasonNameLess": "The host is unable to load your in-game name.\r\nPlease ensure your in-game name is not pure numbers/characters.", - "PlayerCarryWeight": "{player} was detected abnormal carry weight!", - "PlayerCarryWeight_Recovery": "Carry weights have been forcibly restored!", - "RemoteTerminal": "{player} was detected using the terminal remotely!", - "RPCReport": "{player} was detected not reporting {RPC} RPC!", - "ShipBuild": "{player} was detected placing furniture in an abnormal position! ({position})", - "ShipConfig2": "{player}, please wait until the number of people in the ship has reached {cfg} or more before pulling the lever, thanks!", - "ShipConfig4": "{player}, please wait until the number of people in the ship has reached {player_count}({cfg4}%) and the time has reached {cfg3} to depart. (current time: {game_time})", - "ShipConfig5": "{player} was detected attempting to force the ship lever!", - "ShipTerminal": "{player} was detected making too much terminal noise!", - "Shovel": "{player} was detected dealing abnormal damage to {player2} with a {item}! ({damageAmount})", - "Shovel2": "{player} was detected with abnormal shovel range, and damaged {player2}! ({damageAmount})", - "Shovel3": "{player} was detected damaging {player2} with no weapon! ({damageAmount})", - "Shovel4": "{player} was detected dealing abnormal damage to {enemyName} with a {item}! ({damageAmount})", - "Shovel5": "{player} was detected with abnormal shovel range, and damaged {enemyName}! ({damageAmount})", - "Shovel6": "{player} was detected damaging [enemyName} with no weapon! ({damageAmount})", - "snc_player": "[{player}] New creature data sent to terminal! ({enemy})", - "Turret": "{player} was detected causing a turret to go berserk! (distance: {Distance})", - "Turret2": "{player} was detected causing a turret to go berserk without a weapon!", - "Kick_Nameless": "Your Steam name did not load correctly.", - "vote": "You are the host, your vote can force the autopilot.", - "vote_player": "{player} voted for the ship to leave early. ({now}/{max})", - "wlc_player": "[{player}] joined the ship." - }, - "OperationLog": { - "BuyItem": "[ActionLog] {player} purchased {items}", - "BuyShipUnlockable": "[ActionLog] {player} purchased {unlockable}", - "ChangeLevel": "[ActionLog] {player} routed to moon {planet}", - "GrabLungProp": "[ActionLog] {player} pull the apparatus", - "JoinLobby": "{player} is joining..." - }, - "MessageFormat": "{Prefix} {msg}", - "Prefix": "[AC]" -} diff --git a/AntiCheat/Lang/ko_KR.json b/AntiCheat/Lang/ko_KR.json deleted file mode 100644 index 57c658a..0000000 --- a/AntiCheat/Lang/ko_KR.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "Config": { - "Boss": "플레이어가 회사 몬스터를 강제로 공격하게 하려고 시도할 때 이를 감지합니다.", - "ChangToFreeMoon": "플레이어가 유료 달을 무료 달로 변경하는 것을 감지합니다", - "ChatReal": "플레이어가 다른 플레이어의 이름으로 속이려고 할 때 이를 감지합니다.", - "Cooldown": "쿨타임(밀리초 단위)", - "DespawnItem": "아이템이 비정상적으로 파괴되거나 삭제될 때 이를 감지합니다.", - "DetectedMessageType": "메시지 표시 유형을 감지합니다. PublicChat = 방 공개 채팅에 표시, HostChat = 호스트만 채팅에 표시, GUI = GUI 인터페이스에 표시", - "Enemy": "몬스터가 비정상적으로 행동할 때 이를 감지합니다.", - "FreeBuy": "플레이어가 무료로 아이템을 주문하는것을 감지합니다.", - "Gift": "플레이어가 선물 상자를 여러번 사용하는걸 감지합니다.", - "GrabObject": "기본 잡기 범위 밖에서 아이템을 집을 때 이를 감지합니다.", - "GrabObject_BeltBag": "플레이어가 벨트 가방으로 스크랩을 집는 것을 비활성화합니다. (가방모드 비활성화)", - "GrabObject_MoreSlot": "플레이어가 4개 이상의 아이템을 집는 것을 방지합니다.", - "GrabObject_TwoHand": "플레이어가 동시에 여러 개의 양손 아이템을 집는 것을 방지합니다. (양손모드 비활성화)", - "Health_Recover": "플레이어가 음수 피해를 사용하여 체력을 회복할 때 이를 감지합니다. (healthstation같은거 비활성화)", - "NetworkSetting": "핑 차이를 무시하고 \"an error occurred\"메세지가 안나오게 합니다.", - "InfiniteAmmo": "플레이어가 무한 탄약을 사용할 때 이를 감지합니다. 참고: 이미 무한 탄약이 주어진 샷건을 사용하는 정상적인 플레이어도 무한 탄약을 사용하는 것으로 감지될 수 있습니다.", - "Invisibility": "보이지 않는 플레이어를 감지합니다.", - "ItemCooldown": "플레이어가 아이템을 너무 빨리 사용할 때 이를 감지합니다.", - "Jetpack": "플레이어가 제트팩 폭발을 강제할 때 이를 감지합니다.", - "Kick": "이 행동이 감지되면 플레이어를 킥합니다.", - "KillEnemy": "적이 즉시 죽을 때 이를 감지합니다. 삽의 공격력을 100이 아닙니다!!!", - "Landmine": "플레이어가 비정상적으로 지뢰를 폭발시킬 때 이를 감지합니다.", - "Log": "로그를 표시합니다.", - "Map": "미니맵 모드를 사용할 때 이를 감지합니다.", - "Mask": "가면을 쓴 적이 비정상적으로 생성될 때 이를 감지합니다.", - "Nameless": "이름이 없거나 알 수 없는 플레이어 이름을 감지합니다.", - "OperationLog": "클라이언트 측 플레이어 행동 로그", - "PlayerCarryWeight": "플레이어의 비정상적인 운반 무게를 감지합니다.", - "PlayerCarryWeight2": "플레이어의 운반 무게를 복원합니다.", - "Prefix": "로비 이름 앞에 괄호로 텍스트를 넣습니다. 비활성화하려면 비워 두세요.", - "RemoteTerminal": "플레이어가 원격으로 터미널을 사용할 때 이를 감지합니다.", - "RPCReport_Delay": "RPC 보고 감지 지연, 플레이어가 이 시간 후에 RPC를 보고하는지 감지합니다 (밀리초 단위)", - "RPCReport_Hit": "hit RPC 보고 감지, 플레이어가 공격을 받고 피를 흘리지 않는 경우 감지됩니다 (무적 감지)", - "RPCReport_KillPlayer": "KillPlayer RPC 보고 감지, 플레이어가 죽었지만 죽음을 보고하지 않는 경우 감지됩니다 (무적 감지)", - "ShipBuild": "비정상적으로 배치되는걸 감지합니다.", - "ShipConfig2": "이 플레이어 수에 도달하면 클라이언트가 레버를 당길 수 있습니다. (StartGameOnlyHost가 false로 설정되어야 합니다.)", - "ShipConfig3": "이 게임 시간이 지나면 클라이언트가 이륙할 수 있습니다.", - "ShipConfig4": "함선에 있는 생존 플레이어 수가 지정된 비율 이상일 때 클라이언트가 이륙할 수 있습니다. (0-100%)", - "ShipConfig5": "플레이어가 함선 레버를 강제로 작동시키려고 할 때 이를 감지합니다. 감지되면 플레이어를 킥합니다.", - "ShipConfig6": "호스트로서 단일 투표로 자동 조종을 즉시 강제할 수 있습니다.", - "ShipLight": "함선 조명 냉각시간", - "ShipSetting": "호스트만이 함선을 착륙시킬 수 있습니다.", - "ShipTerminal": "터미널 소음사용하여 시끄럽게 할 때 이를 감지합니다.", - "Shovel": "비정상적인 삽 피해를 감지합니다.", - "Shovel2": "플레이어가 무기 없이 피해를 입힐 수 있도록 허용합니다. 네트워크 비동기화로 인해 다른 플레이어의 활성 인벤토리 슬롯이 비동기화될 수 있습니다.", - "SpawnWebTrap": "플레이어가 거미줄을 생성하려고 할 때 이를 감지합니다.", - "Turret": "플레이어가 터렛을 폭주시키려고 할 때 이를 감지합니다." - }, - "Item": { - "Knife": "칼", - "Shotgun": "샷건", - "Shovel": "삽", - "Cruiser": "크루저" - }, - "Log": { - "load": "AntiCheat 모드 로드 성공!", - "refuse_connect": "{steamId}가 게임에 접속을 시도했으나 거부되었습니다! (이미 킥됨)" - }, - "Message": { - "behind_player": "[{player}] 가 버려졌습니다.", - "Boss": "{player} 님이 회사 몬스터를 강제로 공격하게 하려고 시도하는 것이 감지되었습니다!", - "ChangeLevel": "{player} 님이 유료 달을 무료 달로 변경하려고 시도하는 것이 감지되었습니다! (이 행동은 호스트에게만 허용됩니다!)", - "ChangeToFreeLevel": "{player} 님이 유료 달을 무료 달로 바꾸는 것이 감지되었습니다!", - "ChatReal": "{player} 님이 {player2}의 이름으로 채팅을 속이려고 시도했습니다!", - "DespawnItem": "{player} 님이 아이템을 파괴하는 것이 감지되었습니다!", - "Enemy_ChangeOwnershipOfEnemy": "{player} 님이 몬스터의 행동을 변경하려고 시도하는 것이 감지되었습니다!", - "Enemy_SwitchToBehaviour": "{player} 님이 몬스터의 상태를 변경하려고 시도하는 것이 감지되었습니다!", - "FreeBuy_Item": "{player} 님이 무료로 아이템을 구매하는 것이 감지되었습니다!", - "FreeBuy_Level": "{player} 님이 유료 달로 무료로 이동하려고 시도하는 것이 감지되었습니다!", - "FreeBuy_SetMoney": "{player} 님이 함선의 돈을 수정하는 것이 감지되었습니다! ({Money})!", - "FreeBuy_unlockable": "{player} 님이 부적절한 물건을 구매하는것이 감지되었습니다", - "game_start": "이 로비에서 Anti-Cheat (v{ver})가 활성화되었습니다", - "Gift": "{player} 님이 선물 상자를 비정상적으로 작동시키는 것이 감지되었습니다!", - "GrabObject": "{player} 님이 너무 멀리서 아이템을 집는 것이 감지되었습니다! (플레이어 좌표: {player_position}|아이템 좌표: {object_position})", - "Health_Recover": "{player} 님이 체력을 회복하는 것이 감지되었습니다 ({hp})!", - "InfiniteAmmo": "{player} 님이 무한 탄약을 사용하는 것이 감지되었습니다!", - "Invisibility": "{player} 님이 보이지 않는 상태인 것이 감지되었습니다! (플레이어 좌표: {player_position})", - "ItemCooldown": "{player} 님이 아이템을 너무 빨리 사용하는 것이 감지되었습니다!", - "Jetpack": "{player} 님이 제트팩 폭발을 강제하는 것이 감지되었습니다!", - "Kick": "{player} 님이 킥되었습니다!", - "KickPlayer": "치트가 감지되었습니다", - "KillEnemy": "{player} 님이 몬스터를 즉시 죽이는 것이 감지되었습니다! ({enemyName}, 몬스터 HP 이전: {HP})", - "Landmine": "{player} 님이 지뢰를 강제로 폭발시키는 것이 감지되었습니다!", - "Map": "{player} 님이 미니맵 모드를 사용하는 것이 감지되었습니다!", - "Mask": "{player} 님이 가면을 쓴 적을 비정상적으로 생성하는 것이 감지되었습니다!", - "Nameless": "{player} 님이 이름이 없거나 알 수 없는 이름을 사용하는 것이 감지되었습니다!", - "KickReasonNameLess": "호스트가 당신의 게임 이름을 로드할 수 없습니다. 다시 방에 참가해 보세요\r\n이름이 순수 숫자/순수 문자가 아닌지 확인하세요", - "PlayerCarryWeight": "{player} 님이 비정상적인 운반 무게를 사용하는 것이 감지되었습니다!", - "PlayerCarryWeight_Recovery": "운반 무게가 강제로 복원되었습니다!", - "RemoteTerminal": "{player} 님이 원격으로 터미널을 사용하는 것이 감지되었습니다!", - "RPCReport": "{player} 님이 {RPC} RPC를 보고하지 않는 것이 감지되었습니다!", - "ShipBuild": "{player} 님이 가구를 비정상적인 위치에 배치하는 것이 감지되었습니다! ({position})", - "ShipConfig2": "{player}, 레버를 당기기 전에 함선에 있는 사람 수가 {cfg} 이상이 될 때까지 기다려 주세요, 감사합니다!", - "ShipConfig4": "{player}, 함선에 있는 사람 수가 {player_count}({cfg4}%) 이상이고 시간이 {cfg3}에 도달할 때까지 기다려 주세요. (현재 시간: {game_time})", - "ShipConfig5": "{player} 님이 함선 레버를 강제로 작동시키려고 시도하는 것이 감지되었습니다!", - "ShipTerminal": "{player} 님이 터미널 소음을 너무 많이 내는 것이 감지되었습니다!", - "Shovel": "{player} 님이 {player2}에게 {item}으로 비정상적인 피해를 입히는 것이 감지되었습니다! ({damageAmount})", - "Shovel2": "{player} 님이 비정상적인 삽 범위로 {player2}에게 피해를 입히는 것이 감지되었습니다! ({damageAmount})", - "Shovel3": "{player} 님이 무기 없이 {player2}에게 피해를 입히는 것이 감지되었습니다! ({damageAmount})", - "Shovel4": "{player} 님이 {enemyName}에게 {item}으로 비정상적인 피해를 입히는 것이 감지되었습니다! ({damageAmount})", - "Shovel5": "{player} 님이 비정상적인 삽 범위로 {enemyName}에게 피해를 입히는 것이 감지되었습니다! ({damageAmount})", - "Shovel6": "{player} 님이 무기 없이 {enemyName}에게 피해를 입히는 것이 감지되었습니다! ({damageAmount})", - "snc_player": "[{player}] 터미널에 새로운 생물 데이터를 보냈습니다! ", - "Turret": "{player} 님이 터렛을 폭주시키는 것이 감지되었습니다! (거리: {Distance})", - "Turret2": "{player} 님이 무기 없이 터렛을 폭주시키는 것이 감지되었습니다!", - "vote": "당신은 호스트입니다, 다른사람의 투표를 강제할수 있습니다.", - "vote_player": "{player} 님이 함선의 조기 출발을 위해 투표했습니다. ({now}/{max})", - "wlc_player": "{player}이/가 입장했습니다" - }, - "OperationLog": { - "BuyItem": "[행동 로그] {player} 님이 {items}를 구매했습니다", - "BuyShipUnlockable": "[행동 로그] {player} 님이 {unlockable}를 구매했습니다", - "ChangeLevel": "[행동 로그] {player} 님이 달 {planet}로 라우팅했습니다", - "GrabLungProp": "[행동 로그] {player} 님이 코어를 제거했습니다", - "JoinLobby": "{player} 님이 참가 중..." - }, - "MessageFormat": "{Prefix} {msg}", - "Prefix": "[AC]" -} diff --git a/AntiCheat/Lang/localization_cfg.json b/AntiCheat/Lang/localization_cfg.json deleted file mode 100644 index 924f32d..0000000 --- a/AntiCheat/Lang/localization_cfg.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "current_language": "", - "support_language": { - "zh_CN": "中文(简体)", - "ko_KR": "한국어", - "en_US": "English" - } -} \ No newline at end of file diff --git a/AntiCheat/Lang/zh_CN.json b/AntiCheat/Lang/zh_CN.json deleted file mode 100644 index ff47430..0000000 --- a/AntiCheat/Lang/zh_CN.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "Config": { - "Boss": "召唤老板检测", - "ChangToFreeMoon": "检测玩家将 付费星球 切换至 免费星球", - "ChatReal": "发言伪造检测", - "Cooldown": "冷却时间(以毫秒为单位)", - "DespawnItem": "销毁物品检测", - "DetectedMessageType": "决定检测消息显示类型,PublicChat = 对所有人显示,HostChat = 仅在主机的聊天中显示,GUI = 在 GUI 界面中显示", - "Enemy": "怪物异常检测", - "FreeBuy": "零元购检测", - "Gift": "刷礼物盒检测", - "GrabObject": "隔空取物检测", - "GrabObject_BeltBag": "禁止玩家用腰包拾取废料", - "GrabObject_MoreSlot": "禁止玩家拾取超出四个物品", - "GrabObject_TwoHand": "禁止玩家同时拾取多个双手物品", - "Health_Recover": "玩家回血检测(使用负伤害回血)", - "NetworkSetting": "忽略网络配置差异,并尝试避免出现 发生错误 对话框", - "InfiniteAmmo": "无限子弹检测", - "Invisibility": "隐身检测", - "ItemCooldown": "物品使用冷却异常检测", - "Jetpack": "喷气背包爆炸检测", - "Kick": "检测到该行为时踢出玩家", - "KillEnemy": "秒杀敌人检测", - "Landmine": "引爆地雷检测", - "Log": "显示控制台日志", - "Map": "小地图检测", - "Mask": "刷假人检测", - "Nameless": "玩家名字检测(Nameless或Unknown)", - "OperationLog": "客户端玩家操作记录", - "PlayerCarryWeight": "玩家异常负重检测", - "PlayerCarryWeight2": "强制恢复玩家负重", - "Prefix": "设置房间名前缀,使用空值代表不启用前缀", - "RemoteTerminal": "远程终端检测", - "RPCReport_Delay": "RPC 报告宽限期,决定客户端每次必须报告 RPC 时经过的时间。(以毫秒为单位)", - "RPCReport_Hit": "启用Hit RPC报告,当有人受到伤害但未报告生命值损失时,则会被检测(无敌检测)", - "RPCReport_KillPlayer": "启用KillPlayer RPC报告,当有人死亡但之后没有自己报告时,则会被检测(无敌检测)", - "ShipBuild": "飞船物品位置异常检测", - "ShipConfig2": "非房主只有在超过指定人数才能进行着陆(需要关闭房主权限)", - "ShipConfig3": "非房主只有在该时间点以后才能起飞", - "ShipConfig4": "非房主只有在当飞船存活人数超过总存活人数时才能起飞(0-100%)", - "ShipConfig5": "检测强制拉杆行为(检测到该行为时踢出玩家)", - "ShipConfig6": "作为房主,你可以一票起飞", - "ShipLight": "飞船灯关冷却", - "ShipSetting": "只有房主才有着陆权限", - "ShipTerminal": "终端噪音冷却", - "Shovel": "铲子伤害检测", - "Shovel2": "允许玩家空手时能造成正常伤害(网络延迟可能会导致玩家空手)", - "SpawnWebTrap": "刷蜘蛛网检测", - "Turret": "激怒机枪检测" - }, - "Item": { - "Knife": "小刀", - "Shotgun": "霰弹枪", - "Shovel": "铲子", - "Cruiser": "卡车" - }, - "Log": { - "load": "反作弊模组已加载完毕!", - "refuse_connect": "{steamId} 尝试重连游戏被拒绝(已被踢出)!" - }, - "Message": { - "behind_player": "[{player}] 被抛弃了", - "Boss": "检测到玩家 {player} 召唤老板!", - "ChangeLevel": "检测 {player} 将付费星球改为免费星球!(这个行为只有房主才被允许!)", - "ChangeToFreeLevel": "检测到玩家 {player} 将 付费星球 切换至 免费星球", - "ChatReal": "检测到玩家 {player} 尝试伪装成 {player2} 发言!", - "DespawnItem": "检测到玩家 {player} 销毁物品 ({item})!", - "Enemy_ChangeOwnershipOfEnemy": "检测到玩家 {player} 强制改变怪物仇恨!", - "Enemy_SwitchToBehaviour": "检测到玩家 {player} 强制改变怪物状态!", - "FreeBuy_Item": "检测到玩家 {player} 强制购买 {items} 物品!", - "FreeBuy_Level": "检测到玩家 {player} 强制切换付费星球!", - "FreeBuy_SetMoney": "检测到玩家 {player} 修改金钱({Money})!", - "FreeBuy_unlockable": "检测到玩家 {player} 强制解锁飞船装饰!", - "game_start": "本房间启用反作弊(v{ver})", - "Gift": "检测到玩家 {player} 刷礼物盒!", - "GrabObject": "检测到玩家 {player} 隔空取物!(玩家坐标:{player_position}|物品坐标:{object_position})", - "Health_Recover": "检测到玩家 {player} 回复生命值({hp})!", - "InfiniteAmmo": "检测到玩家 {player} 正使用无限子弹!", - "Invisibility": "检测到玩家 {player} 坐标异常!(玩家坐标:{player_position})", - "ItemCooldown": "检测到玩家 {player} 使用 {item} 频率异常!", - "Jetpack": "检测到玩家 {player} 引爆喷气背包!", - "Kick": "{player} 已被踢出", - "KickPlayer": "检测到作弊行为", - "KillEnemy": "检测到玩家 {player} 秒杀怪物!( {enemyName} ,剩余血量:{HP})", - "Landmine": "检测到玩家 {player} 强制引爆地雷!", - "Map": "检测到玩家 {player} 使用小地图!", - "Mask": "检测到玩家 {player} 刷假人!", - "Nameless": "检测到玩家名称异常!", - "KickReasonNameLess": "房主无法加载你的游戏名称,你可以尝试重新加入房间\r\n请确保你的名称不是纯数字/纯字符", - "PlayerCarryWeight": "检测到玩家 {player} 负重异常!", - "PlayerCarryWeight_Recovery": "异常负重已被恢复!", - "RemoteTerminal": "检测到玩家 {player} 使用远程终端!", - "RPCReport": "检测到玩家 {player} 未上报 {RPC} RPC!", - "ShipBuild": "检测到玩家 {player} 将飞船物品({object})摆放到异常位置({position})!", - "ShipConfig2": "{player} 请等待飞船人数达到 {cfg} 以上再拉杆,谢谢!", - "ShipConfig4": "{player} 请等待飞船人数达到 {player_count}({cfg4}%) 并且 游戏时间在 {cfg3} 之后起飞(当前时间:{game_time})", - "ShipConfig5": "检测到玩家 {player} 强制拉杆!", - "ShipTerminal": "检测到玩家 {player} 频繁制造噪音!", - "Shovel": "检测到玩家 {player} 使用{item}对玩家 {player2} 造成异常伤害!({damageAmount})", - "Shovel2": "检测到玩家 {player} {item}范围异常,对玩家 {player2} 造成伤害!({distance},{damageAmount})", - "Shovel3": "检测到玩家 {player} 空手对玩家 {player2} 造成伤害!({damageAmount})", - "Shovel4": "检测到玩家 {player} 使用{item}对敌人 {enemyName} 造成异常伤害!({damageAmount})", - "Shovel5": "检测到玩家 {player} {item}范围异常,对敌人 {enemyName} 造成伤害!({damageAmount})", - "Shovel6": "检测到玩家 {player} 空手对敌人 {enemyName} 造成伤害!({damageAmount})", - "snc_player": "[{player}] 新的生物数据已发送至终端!({enemy})", - "Turret": "检测玩家 {player} 强制激怒机枪!(距离:{Distance})", - "Turret2": "检测玩家 {player} 强制激怒机枪(空手)!", - "Kick_Nameless": "你的Steam名称未正确加载(如果你是纯数字名称,请更改名称)", - "vote": "你是房主,投票直接起飞!", - "vote_player": "{player} 投票让飞船提前离开({now}/{max})", - "wlc_player": "欢迎 {player} 加入飞船" - }, - "OperationLog": { - "BuyItem": "[操作记录] {player} 购买 {items} 物品", - "BuyShipUnlockable": "[操作记录] {player} 解锁 {unlockable} 物品", - "ChangeLevel": "[操作记录] {player} 切换星球 {planet}", - "GrabLungProp": "[操作记录] {player} 取下了设施电源", - "JoinLobby": "{player} 加入房间中..." - }, - "MessageFormat": "{Prefix} {msg}", - "Prefix": "[反作弊]" -} \ No newline at end of file diff --git a/AntiCheat/Locale/Locale.cs b/AntiCheat/Locale/Locale.cs index aae9a24..396d2f8 100644 --- a/AntiCheat/Locale/Locale.cs +++ b/AntiCheat/Locale/Locale.cs @@ -1,18 +1,16 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; -using System.Threading.Tasks; namespace AntiCheat.Locale { public class Locale { - public Dictionary Config { get; set; } + public Dictionary Config { get; set; } public Dictionary Item { get; set; } public Dictionary Log { get; set; } - public Dictionary Message { get; set; } - public Dictionary OperationLog { get; set; } + public Dictionary Message { get; set; } + public Dictionary OperationLog { get; set; } public string Prefix { get; set; } public string MessageFormat { get; set; } } @@ -21,6 +19,6 @@ public class LocaleCfg { public string current_language { get; set; } - public Dictionary support_language { get; set; } + public Dictionary support_language { get; set; } } } diff --git a/AntiCheat/Locale/LocalizationManager.cs b/AntiCheat/Locale/LocalizationManager.cs index 3383948..fb7f2de 100644 --- a/AntiCheat/Locale/LocalizationManager.cs +++ b/AntiCheat/Locale/LocalizationManager.cs @@ -1,16 +1,10 @@ - -using Newtonsoft.Json; +using Newtonsoft.Json; using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; -using System.Resources; using System.Text; -using System.Threading.Tasks; - -using static AntiCheat.Core.AntiCheat; namespace AntiCheat.Locale { @@ -38,8 +32,8 @@ public LocalizationManager() { cfg.current_language = "en_US"; } - Core.AntiCheat.LogInfo($"no current language set, automatic language selection based on current region"); - Core.AntiCheat.LogInfo($"CurrentCulture:{lang},use language -> {cfg.current_language}"); + AntiCheatPlugin.LogInfo($"no current language set, automatic language selection based on current region"); + AntiCheatPlugin.LogInfo($"CurrentCulture:{lang},use language -> {cfg.current_language}"); } current_language = cfg.current_language; json = File.ReadAllText($"{Path.Combine(langPath, cfg.current_language)}.json"); @@ -83,7 +77,12 @@ private string ReplacePlaceholders(string input, Dictionary pair { if (pairs == null || string.IsNullOrEmpty(input)) return input; - return pairs.Aggregate(input, (current, item) => current.Replace(item.Key, item.Value)); + var result = new StringBuilder(input); + foreach (var pair in pairs) + { + result.Replace(pair.Key, pair.Value); + } + return result.ToString(); } } } diff --git a/AntiCheat/Patch/DoorLockPatch.cs b/AntiCheat/Patch/DoorLockPatch.cs deleted file mode 100644 index 3a23037..0000000 --- a/AntiCheat/Patch/DoorLockPatch.cs +++ /dev/null @@ -1,49 +0,0 @@ -using AntiCheat.Core; - -using HarmonyLib; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using Unity.Netcode; - -namespace AntiCheat.Patch -{ - [HarmonyPatch(typeof(DoorLock))] - [HarmonyWrapSafe] - public static class DoorLockPatch - { - [HarmonyPatch("__rpc_handler_184554516")] - [HarmonyPrefix] - public static bool UnlockDoorServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Patches.Check(rpcParams, out var p)) - { - AntiCheat.Core.AntiCheat.LogInfo(p, "DoorLock.UnlockDoorServerRpc"); - } - else if (p == null) - { - return false; - } - return true; - } - - [HarmonyPatch("__rpc_handler_2046162111")] - [HarmonyPrefix] - public static bool OpenDoorAsEnemyServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Patches.Check(rpcParams, out var p)) - { - AntiCheat.Core.AntiCheat.LogInfo(p, "DoorLock.OpenDoorAsEnemyServerRpc"); - } - else if (p == null) - { - return false; - } - return true; - } - } -} diff --git a/AntiCheat/Patch/GrabbableObjectPatch.cs b/AntiCheat/Patch/GrabbableObjectPatch.cs deleted file mode 100644 index c029797..0000000 --- a/AntiCheat/Patch/GrabbableObjectPatch.cs +++ /dev/null @@ -1,109 +0,0 @@ -using AntiCheat.Core; - -using HarmonyLib; - -using Steamworks.Ugc; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using Unity.Netcode; - -namespace AntiCheat -{ - [HarmonyPatch(typeof(GrabbableObject))] - [HarmonyWrapSafe] - public static class GrabbableObjectPatch - { - /// - /// ActivateItemServerRpc - /// - [HarmonyPrefix] - [HarmonyPatch("__rpc_handler_4280509730")] - public static bool ActivateItemServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Patches.Check(rpcParams, out var p)) - { - if (target != null) - { - var grab = (GrabbableObject)target; - if (grab != null) - { - if (grab is RemoteProp) - { - AntiCheat.Core.AntiCheat.LogInfo(p, $"({grab.itemProperties.itemName})GrabbableObject.ActivateItemServerRpc"); - bool canUse = CooldownManager.CheckCooldown("ShipLight", p); - if (!canUse) - { - UnityEngine.Object.FindFirstObjectByType().SetShipLightsClientRpc(true); - } - return canUse; - } - } - } - else - { - return false; - } - } - else if (p == null) - { - return false; - } - return true; - } - - [HarmonyPostfix] - [HarmonyPatch(typeof(GiftBoxItem), "ItemActivate")] - public static void ItemActivate(GiftBoxItem __instance) - { - if (StartOfRound.Instance.IsHost) - { - UnityEngine.Object.Destroy(__instance.gameObject); - } - } - - [HarmonyPrefix] - [HarmonyPatch("__rpc_handler_3484508350")] - public static bool SyncBatteryServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (!Patches.Check(rpcParams, out var p) && false) - return p != null; - ByteUnpacker.ReadValueBitPacked(reader, out int num); - reader.Seek(0); - GrabbableObject target1 = ((GrabbableObject)target); - if (target1.itemProperties.requiresBattery) - { - AntiCheat.Core.AntiCheat.LogInfo(p, $"({target1.itemProperties.itemName})GrabbableObject.SyncBatteryServerRpc", $"num:{num}"); - if (num > 100) - { - return false; - } - } - return true; - } - - /// - /// EquipItemServerRpc - /// - [HarmonyPrefix] - [HarmonyPatch(typeof(LungProp), "EquipItem")] - public static bool EquipItem(LungProp __instance) - { - if (AntiCheat.Core.AntiCheat.OperationLog.Value) - { - if (__instance.isLungDocked && StartOfRound.Instance.shipHasLanded) - { - Patches.ShowMessageHostOnly(Patches.locale.OperationLog_GetString("GrabLungProp", new Dictionary() { - { "{player}", $"{StartOfRound.Instance.allPlayerScripts.First(x => x.OwnerClientId == __instance.OwnerClientId).playerUsername}" } - })); - } - } - return true; - - } - } -} diff --git a/AntiCheat/Patch/HUDManagerPatch.cs b/AntiCheat/Patch/HUDManagerPatch.cs deleted file mode 100644 index d057b21..0000000 --- a/AntiCheat/Patch/HUDManagerPatch.cs +++ /dev/null @@ -1,124 +0,0 @@ -using HarmonyLib; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using Unity.Netcode; - -namespace AntiCheat -{ - [HarmonyPatch(typeof(HUDManager))] - [HarmonyWrapSafe] - public static class HUDManagerPatch - { - - public static List SyncAllPlayerLevelsServerRpcCalls { get; set; } = new List(); - - /// - /// GetNewStoryLogServerRpc - /// - [HarmonyPrefix] - [HarmonyPatch("__rpc_handler_3153465849")] - public static bool GetNewStoryLogServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (!Patches.Check(rpcParams, out var p)) - return p != null; - ByteUnpacker.ReadValueBitPacked(reader, out int logID); - reader.Seek(0); - var terminal = UnityEngine.Object.FindObjectOfType(); - if (logID < terminal.logEntryFiles.Count && logID > 0) - { - return true; - } - return false; - } - - /// - /// SendErrorMessageServerRpc - /// - [HarmonyPrefix] - [HarmonyPatch("__rpc_handler_1043384750")] - public static bool SendErrorMessageServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - return !Patches.Check(rpcParams, out _); - } - - - /// - /// SyncAllPlayerLevelsServerRpc - /// - [HarmonyPrefix] - [HarmonyPatch("__rpc_handler_4217433937")] - public static bool SyncAllPlayerLevelsServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (!Patches.Check(rpcParams, out var p)) - return p != null; - if (SyncAllPlayerLevelsServerRpcCalls.Contains(p.playerSteamId)) - { - return false; - } - ByteUnpacker.ReadValueBitPacked(reader, out int _); - ByteUnpacker.ReadValueBitPacked(reader, out int playerClientId); - reader.Seek(0); - if (playerClientId != (int)p.playerClientId) - { - return false; - } - SyncAllPlayerLevelsServerRpcCalls.Add(p.playerSteamId); - return true; - } - - /// - /// ScanNewCreatureServerRpc - /// - [HarmonyPatch("__rpc_handler_1944155956")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool ScanNewCreatureServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (!Patches.Check(rpcParams, out var p)) - return p != null; - ByteUnpacker.ReadValueBitPacked(reader, out int enemyID); - reader.Seek(0); - var terminal = UnityEngine.Object.FindObjectOfType(); - if (enemyID < terminal.enemyFiles.Count && enemyID > 0) - { - if (terminal.scannedEnemyIDs.Contains(enemyID) && terminal.newlyScannedEnemyIDs.Contains(enemyID)) - { - return false; - } - string msg = Core.AntiCheat.localizationManager.Msg_GetString("snc_player", new Dictionary() { - { "{player}",p.playerUsername }, - { "{enemy}",terminal.enemyFiles[enemyID].creatureName } - }); - Patches.LogInfo(msg); - return true; - } - return false; - } - - /// - /// 玩家使用信号发射器发送消息 - /// Prefix UseSignalTranslatorServerRpc - /// - /// - [HarmonyPatch("__rpc_handler_2436660286")] - [HarmonyPrefix] - public static bool UseSignalTranslatorServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (!Patches.Check(rpcParams, out var p)) - return p != null; - if (Core.AntiCheat.RemoteTerminal.Value) - { - if (!Patches.CheckRemoteTerminal(p, "HUDManager.UseSignalTranslatorServerRpc")) - { - return false; - } - } - return true; - } - } -} diff --git a/AntiCheat/Patch/LandminePatch.cs b/AntiCheat/Patch/LandminePatch.cs deleted file mode 100644 index e879135..0000000 --- a/AntiCheat/Patch/LandminePatch.cs +++ /dev/null @@ -1,31 +0,0 @@ -using HarmonyLib; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using UnityEngine; - -namespace AntiCheat.Patch -{ - [HarmonyPatch(typeof(Landmine))] - [HarmonyWrapSafe] - public static class LandminePatch - { - [HarmonyPrefix] - [HarmonyPatch("SpawnExplosion")] - public static void SpawnExplosion(Vector3 explosionPosition) - { - Patches.LogInfo($"Landmine.SpawnExplosion -> {explosionPosition}"); - Patches.explosions = Patches.explosions.Where(x => x.CreateDateTime.AddSeconds(10) > DateTime.Now).ToList(); - Patches.explosions.Add(new Patches.ExplosionData() - { - ExplosionPostion = explosionPosition, - CalledClient = new List(), - CreateDateTime = DateTime.Now - }); - } - } -} diff --git a/AntiCheat/Patch/Patches.cs b/AntiCheat/Patch/Patches.cs deleted file mode 100644 index a85f0a5..0000000 --- a/AntiCheat/Patch/Patches.cs +++ /dev/null @@ -1,3099 +0,0 @@ -using AntiCheat.Core; -using AntiCheat.Patch; - -using BepInEx; -using BepInEx.Configuration; - -using GameNetcodeStuff; - -using HarmonyLib; - -using Netcode.Transports.Facepunch; - -using Steamworks; -using Steamworks.Data; -using Steamworks.ServerList; - -using System; -using System.CodeDom; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Configuration; -using System.Diagnostics.Eventing.Reader; -using System.IO; -using System.Linq; -using System.Net.Http.Headers; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.InteropServices.WindowsRuntime; -using System.Runtime.Remoting.Messaging; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; - -using TMPro; - -using Unity.Collections.LowLevel.Unsafe; -using Unity.Netcode; - -using UnityEngine; -using UnityEngine.Events; - -using static UnityEngine.GraphicsBuffer; - -namespace AntiCheat -{ - public static class Patches - { - public static Locale.LocalizationManager locale { get => Core.AntiCheat.localizationManager; } - - public static List jcs = new List(); - - public static Dictionary> czcd = new Dictionary>(); - public static Dictionary> sdqcd = new Dictionary>(); - - public static Dictionary ConnectionIdtoSteamIdMap { get; set; } = new Dictionary(); - - //public static Dictionary>> chcs = new Dictionary>>(); - - public static List mjs { get; set; } = new List(); - - public static List landMines { get; set; } - - public static Dictionary> rpcs { get; set; } = new Dictionary>(); - - private static Dictionary> recentPlayerPositions = new Dictionary>(); - - public static void LogInfo(string info) => Core.AntiCheat.LogInfo(info); - - public static void LogInfo(PlayerControllerB p, string rpc, params object[] param) => Core.AntiCheat.LogInfo(p, rpc, param); - - public static void LogError(string info) - { - if (Core.AntiCheat.Log.Value) - { - Core.AntiCheat.ManualLog.LogError($"{info}"); - } - } - - /// - /// PlayerControllerB.KillPlayerServerRpc - /// - /// - /// - /// - /// - [HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_4121569671")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_4121569671(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - if (rpcs.ContainsKey("KillPlayer")) - { - rpcs["KillPlayer"].Remove(p.playerClientId); - } - ByteUnpacker.ReadValueBitPacked(reader, out int playerId); - reader.ReadValueSafe(out bool spawnBody, default); - reader.ReadValueSafe(out Vector3 bodyVelocity); - ByteUnpacker.ReadValueBitPacked(reader, out int num); - reader.Seek(0); - LogInfo(p, "PlayerControllerB.KillPlayerServerRpc", $"playerId:{PlayerClientIdConvertName(playerId)}({playerId})", $"spawnBody:{spawnBody}", $"bodyVelocity:{bodyVelocity}", $"num:{(CauseOfDeath)num}({num})"); - if (playerId < 0) - { - LogInfo($"KillPlayerServerRpc:Invalid PlayerId({playerId})"); - return false; - } - if (StartOfRound.Instance.allPlayerScripts[playerId] != p) - { - LogInfo("KillPlayerServerRpc:Can't kill other player!"); - return false; - } - if (p.isPlayerDead) - { - LogInfo("KillPlayerServerRpc:Player death can't kill!"); - return false; - } - if ((CauseOfDeath)num == CauseOfDeath.Abandoned) - { - string msg = locale.Msg_GetString("behind_player", new Dictionary() { - { "{player}",p.playerUsername } - }); - LogInfo(msg); - AddTextMessageClientRpc(msg); - } - } - else if (p == null) - { - return false; - } - return true; - } - - - /// - /// Prefix PlayerControllerB.DamagePlayerFromOtherClientServerRpc - /// - [HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_638895557")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_638895557(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - ByteUnpacker.ReadValueBitPacked(reader, out int damageAmount); - reader.ReadValueSafe(out Vector3 hitDirection); - ByteUnpacker.ReadValueBitPacked(reader, out int playerWhoHit); - reader.Seek(0); - LogInfo(p, "PlayerControllerB.DamagePlayerFromOtherClientServerRpc", $"damageAmount:{damageAmount}", $"hitDirection:{hitDirection}", $"playerWhoHit:{PlayerClientIdConvertName(playerWhoHit)}({playerWhoHit})"); - var p2 = (PlayerControllerB)target; - return CheckDamage(p2, p, ref damageAmount); - } - else if (p == null) - { - return false; - } - return true; - } - - /// - /// Prefix PlayerControllerB.HealServerRpc - /// - [HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_2585603452")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_2585603452(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - LogInfo(p, "PlayerControllerB.HealServerRpc", $"health:{p.health}", $"newHealth:20"); - p.health = 20; - } - else if (p == null) - { - return false; - } - return true; - } - - private static bool CheckDamage(PlayerControllerB p2, PlayerControllerB p, ref int damageAmount) - { - if (damageAmount == 0) - { - return true; - } - LogInfo($"{p.playerUsername} hit {p2.playerUsername} damageAmount:{damageAmount}|p2:{p2.playerUsername}"); - try - { - if (Core.AntiCheat.Shovel.Value) - { - var distance = Vector3.Distance(p.transform.position, p2.transform.position); - var obj = p.ItemSlots[p.currentItemSlot]; - string playerUsername = p.playerUsername; - if (jcs.Contains(p.playerSteamId)) - { - damageAmount = 0; - } - else if (damageAmount != 20 && obj != null && (isShovel(obj) || isKnife(obj))) - { - if (!jcs.Contains(p.playerSteamId)) - { - ShowMessage(locale.Msg_GetString("Shovel", new Dictionary() { - { "{player}",p.playerUsername }, - { "{player2}",p2.playerUsername }, - { "{damageAmount}",damageAmount.ToString() }, - { "{item}", isShovel(obj) ? locale.Item_GetString("Shovel") : locale.Item_GetString("Knife") } - })); - jcs.Add(p.playerSteamId); - if (Core.AntiCheat.Shovel2.Value) - { - KickPlayer(p); - } - } - damageAmount = 0; - } - else if (distance > 11 && obj != null && (isShovel(obj) || isKnife(obj))) - { - if (p2.isPlayerDead) - { - return true; - } - if (!jcs.Contains(p.playerSteamId)) - { - ShowMessage(locale.Msg_GetString("Shovel2", new Dictionary() { - { "{player}",p.playerUsername }, - { "{player2}",p2.playerUsername }, - { "{distance}",distance.ToString() }, - { "{damageAmount}",damageAmount.ToString() }, - { "{item}", isShovel(obj) ? locale.Item_GetString("Shovel") : locale.Item_GetString("Knife") } - })); - jcs.Add(p.playerSteamId); - if (Core.AntiCheat.Shovel2.Value) - { - KickPlayer(p); - } - } - damageAmount = 0; - } - else - { - if (ClingTime.ContainsKey(p.playerSteamId) && ClingTime[p.playerSteamId].AddSeconds(5) > DateTime.Now) - { - return true; - } - if (p.ItemSlots.Any(x => isShovel(x)) && damageAmount == 10) - { - return true; - } - //for (int i = 0; i <.Length; i++) - //{ - // LogInfo($"p:{p.playerUsername}|i:{i}|itemName:{p.ItemSlots[i]?.itemProperties?.itemName}"); - //} - //LogInfo($"currentItemSlot:{p.currentItemSlot}"); - //LogInfo($"currentlyHeldObjectServer:{p.currentlyHeldObjectServer?.itemProperties?.itemName}"); - //LogInfo($"obj:{obj}"); - //if (!jcs.Contains(p.playerSteamId)) - //{ - // if (Core.AntiCheat.Shovel3.Value && (damageAmount == 10 || damageAmount == 20 || damageAmount == 30 || damageAmount == 100)) - // { - // ShowMessage(locale.Msg_GetString("Shovel3", new Dictionary() { - // { "{player}",p.playerUsername }, - // { "{player2}",p2.playerUsername }, - // { "{damageAmount}",damageAmount.ToString() } - // })); - // return true; - // } - // else - // { - // ShowMessage(locale.Msg_GetString("Shovel3", new Dictionary() { - // { "{player}",p.playerUsername }, - // { "{player2}",p2.playerUsername }, - // { "{damageAmount}",damageAmount.ToString() } - // })); - // jcs.Add(p.playerSteamId); - // if (Core.AntiCheat.Shovel2.Value) - // { - // KickPlayer(p); - // } - // damageAmount = 0; - // } - //} - } - if (damageAmount == 0) - { - return false; - } - else - { - return true; - } - } - } - catch (Exception ex) - { - LogInfo($"{ex.ToString()}"); - } - return true; - } - - - //[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayerFromOtherClientServerRpc")] - //[HarmonyPrefix] - //public static bool DamagePlayerFromOtherClientServerRpc(PlayerControllerB __instance, ref int damageAmount, Vector3 hitDirection, int playerWhoHit) - //{ - // return DamagePlayerFromOtherClientServerRpc(ref damageAmount, playerWhoHit); - //} - public static bool isGun(GrabbableObject item) - { - return item is ShotgunItem; - } - - public static bool isShovel(GrabbableObject item) - { - return item is Shovel; - } - - public static bool isKnife(GrabbableObject item) - { - return item is KnifeItem; - } - - public static bool isJetpack(GrabbableObject item) - { - return item is JetpackItem; - } - - public static ulong lastClientId { get; set; } - - - //[HarmonyPatch(typeof(StartOfRound), "StartTrackingAllPlayerVoices")] - //[HarmonyPostfix] - //[HarmonyWrapSafe] - //public static void StartTrackingAllPlayerVoices() - //{ - // if (!StartOfRound.Instance.localPlayerController.IsHost) - // { - // return; - // } - // foreach (var item in StartOfRound.Instance.allPlayerScripts) - // { - // if (!item.isPlayerControlled) - // { - // continue; - // } - // var playerName = item.playerUsername; - // if (playerName == "Player #0") - // { - // continue; - // } - // if (StartOfRound.Instance.KickedClientIds.Contains(item.playerSteamId)) - // { - // KickPlayer(item); - // return; - // } - // LogInfo(playerName); - // if (Regex.IsMatch(playerName, "Nameless\\d*") || Regex.IsMatch(playerName, "Unknown\\d*") || Regex.IsMatch(playerName, "Player #\\d*")) - // { - // if (Core.AntiCheat.Nameless.Value) - // { - // ShowMessage(locale.Msg_GetString("Nameless")); - // if (Core.AntiCheat.Nameless2.Value) - // { - // KickPlayer(item, true, locale.Msg_GetString("Kick_Nameless")); - // } - // } - // } - // } - // var p2 = StartOfRound.Instance.allPlayerScripts.OrderByDescending(x => x.playerClientId).FirstOrDefault(); - // if (p2.playerClientId != lastClientId) - // { - // if (p2.isPlayerControlled && p2.playerSteamId == 0) - // { - // KickPlayer(p2); - // return; - // } - // else if (!p2.isPlayerControlled) - // { - // return; - // } - // bypass = true; - // string msg = Core.AntiCheat.PlayerJoin.Value.Replace("{player}", p2.playerUsername); - // LogInfo(msg); - // HUDManager.Instance.AddTextToChatOnServer(msg, -1); - // lastClientId = p2.playerClientId; - // bypass = false; - // } - //} - - - - [HarmonyPatch(typeof(GameNetworkManager), "SteamMatchmaking_OnLobbyMemberJoined")] - [HarmonyPostfix] - [HarmonyWrapSafe] - public static void SteamMatchmaking_OnLobbyMemberJoined() - { - if (StartOfRound.Instance == null || StartOfRound.Instance.localPlayerController == null || !StartOfRound.Instance.localPlayerController.IsHost) - { - return; - } - LogInfo($"SetMoney:{Money}"); - Money = terminal.groupCredits; - } - public static Terminal terminal - { - get - { - if (_terminal == null) - { - _terminal = UnityEngine.Object.FindObjectOfType(); - } - return _terminal; - } - } - - private static Terminal _terminal { get; set; } - - /// - /// 游戏结束时重置所有变量 - /// StartOfRound.EndOfGame - /// - [HarmonyPatch(typeof(StartOfRound), "EndOfGame")] - [HarmonyPostfix] - [HarmonyWrapSafe] - public static void EndOfGame() - { - jcs = new List(); - //chcs = new Dictionary>>(); - if (rpcs.ContainsKey("Hit")) - { - rpcs["Hit"] = new List(); - } - if (rpcs.ContainsKey("KillPlayer")) - { - rpcs["KillPlayer"] = new List(); - } - } - - public static int Money = -1; - - /// - /// Prefix StartOfRound.ChangeLevelServerRpc - /// - [HarmonyPatch(typeof(StartOfRound), "__rpc_handler_1134466287")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_1134466287(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - //LogInfo($"{p.playerUsername}|StartOfRound.ChangeLevelServerRpc"); - if (Core.AntiCheat.RemoteTerminal.Value) - { - if (!CheckRemoteTerminal(p, "StartOfRound.ChangeLevelServerRpc")) - { - return false; - } - } - ByteUnpacker.ReadValueBitPacked(reader, out int levelID); - ByteUnpacker.ReadValueBitPacked(reader, out int newGroupCreditsAmount); - reader.Seek(0); - if (Core.AntiCheat.FreeBuy.Value) - { - if (newGroupCreditsAmount > Money || Money < 0) - { - ShowMessage(locale.Msg_GetString("FreeBuy_SetMoney", new Dictionary() { - { "{player}",p.playerUsername }, - { "{Money}",(newGroupCreditsAmount - Money).ToString() } - })); - if (Core.AntiCheat.FreeBuy2.Value) - { - KickPlayer(p); - } - return false; - } - if (levelID > StartOfRound.Instance.levels.Length) - { - LogInfo(p, "StartOfRound.ChangeLevelServerRpc", "levelID > StartOfRound.Instance.levels.Length"); - return false; - } - var Route = terminal.terminalNodes.allKeywords.FirstOrDefault(x => x.word.ToLower() == "route");//Route - var level = StartOfRound.Instance.levels[levelID].PlanetName.Split(' ')[0]; - var compatibleNoun = Route.compatibleNouns.Where(x => x.result.name == level + "route"); - if (compatibleNoun.Any()) - { - int itemCost = compatibleNoun.First().result.itemCost; - level = StartOfRound.Instance.currentLevel.PlanetName.Split(' ')[0]; - var nowCompatibleNoun = Route.compatibleNouns.Where(x => x.result.name == level + "route"); - if (itemCost == 0 && nowCompatibleNoun.Any() && nowCompatibleNoun.First().result.itemCost != 0) - { - ShowMessage(locale.Msg_GetString("ChangeToFreeLevel", new Dictionary() { - { "{player}",p.playerUsername } - })); - return false; - } - LogInfo(p, "StartOfRound.ChangeLevelServerRpc", $"levelID:{levelID}", $"itemCost:{itemCost}"); - if (itemCost != 0) - { - int newValue = Money - itemCost; - if (newValue != newGroupCreditsAmount || Money == 0) - { - ShowMessage(locale.Msg_GetString("FreeBuy_Level", new Dictionary() { - { "{player}",p.playerUsername } - })); - if (Core.AntiCheat.FreeBuy2.Value) - { - KickPlayer(p); - } - return false; - } - } - } - } - if (Core.AntiCheat.OperationLog.Value) - { - if (levelID < StartOfRound.Instance.levels.Length) - { - ShowMessageHostOnly(locale.OperationLog_GetString("ChangeLevel", new Dictionary() { - { "{player}",p.playerUsername }, - { "{planet}",StartOfRound.Instance.levels[levelID].PlanetName } - })); - } - } - } - else if (p == null) - { - return false; - } - return true; - } - - - /// - /// StartOfRound.BuyShipUnlockableServerRpc - /// - /// - [HarmonyPatch(typeof(StartOfRound), "__rpc_handler_3953483456")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_3953483456(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - if (Core.AntiCheat.RemoteTerminal.Value) - { - if (!CheckRemoteTerminal(p, "StartOfRound.BuyShipUnlockableServerRpc")) - { - return false; - } - } - ByteUnpacker.ReadValueBitPacked(reader, out int unlockableID); - ByteUnpacker.ReadValueBitPacked(reader, out int newGroupCreditsAmount); - reader.Seek(0); - if (Core.AntiCheat.FreeBuy.Value) - { - //LogInfo($"__rpc_handler_3953483456|newGroupCreditsAmount:{newGroupCreditsAmount}"); - if (Money == newGroupCreditsAmount || Money == 0) - { - //LogInfo($"Money:{Money}|newGroupCreditsAmount:{newGroupCreditsAmount}"); - ShowMessage(locale.Msg_GetString("FreeBuy_unlockable", new Dictionary() { - { "{player}",p.playerUsername } - })); - if (Core.AntiCheat.FreeBuy2.Value) - { - KickPlayer(p); - } - return false; - } - else if (newGroupCreditsAmount > Money || Money < 0) - { - ShowMessage(locale.Msg_GetString("FreeBuy_SetMoney", new Dictionary() { - { "{player}",p.playerUsername }, - { "{Money}",(newGroupCreditsAmount - Money).ToString() } - })); - if (Core.AntiCheat.FreeBuy2.Value) - { - KickPlayer(p); - } - return false; - } - } - if (Core.AntiCheat.OperationLog.Value) - { - if (unlockableID < StartOfRound.Instance.unlockablesList.unlockables.Count) - { - ShowMessageHostOnly(locale.OperationLog_GetString("BuyShipUnlockable", new Dictionary() { - { "{player}",p.playerUsername }, - { "{unlockable}",StartOfRound.Instance.unlockablesList.unlockables[unlockableID].unlockableName } - })); - } - } - } - else if (p == null) - { - return false; - } - return true; - } - - - - - - [HarmonyPatch(typeof(StartOfRound), "BuyShipUnlockableClientRpc")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool BuyShipUnlockableClientRpc(int newGroupCreditsAmount, int unlockableID = -1) - { - if (!StartOfRound.Instance.localPlayerController.IsHost) - { - return true; - } - Money = newGroupCreditsAmount; - return true; - } - - - - [HarmonyPatch(typeof(TimeOfDay), "SyncNewProfitQuotaClientRpc")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool SyncNewProfitQuotaClientRpc(int newProfitQuota, int overtimeBonus, int fulfilledQuota) - { - if (!StartOfRound.Instance.localPlayerController.IsHost) - { - return true; - } - Money = Mathf.Clamp(terminal.groupCredits + overtimeBonus, terminal.groupCredits, 100000000); - return true; - } - - [HarmonyPatch(typeof(Terminal), "SyncGroupCreditsClientRpc")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool SyncGroupCreditsClientRpc(int newGroupCredits, int numItemsInShip) - { - if (!StartOfRound.Instance.localPlayerController.IsHost) - { - return true; - } - Money = newGroupCredits; - return true; - } - - [HarmonyPatch(typeof(StartOfRound), "ChangeLevelClientRpc")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool ChangeLevelClientRpc(int levelID, int newGroupCreditsAmount) - { - if (!StartOfRound.Instance.localPlayerController.IsHost) - { - return true; - } - Money = newGroupCreditsAmount; - return true; - } - - - [HarmonyWrapSafe] - [HarmonyPatch(typeof(Terminal), "BeginUsingTerminal")] - [HarmonyPrefix] - public static bool BeginUsingTerminal(Terminal __instance) - { - if (!StartOfRound.Instance.IsHost) - { - return true; - } - Money = __instance.groupCredits; - LogInfo($"SetMoney:{Money}"); - return true; - } - - /// - /// Prefix PlayerControllerB.DamagePlayer - /// - /// - [HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool DamagePlayer(PlayerControllerB __instance, int damageNumber, bool hasDamageSFX = true, bool callRPC = true, CauseOfDeath causeOfDeath = CauseOfDeath.Unknown, int deathAnimation = 0, bool fallDamage = false, Vector3 force = default(Vector3)) - { - //LogInfo($"PlayerControllerB.DamagePlayer|{__instance.playerUsername}|damageNumber:{damageNumber}|hasDamageSFX:{hasDamageSFX}|callRPC:{callRPC}"); - return true; - } - - //[HarmonyPatch(typeof(PlayerControllerB), "IHittable.Hit")] - //[HarmonyPrefix] - //[HarmonyWrapSafe] - //public static bool Hit(PlayerControllerB __instance, int force, Vector3 hitDirection, PlayerControllerB playerWhoHit, bool playHitSFX = false, int hitID = -1) - //{ - // if (!rpcs.ContainsKey("Hit")) - // { - // rpcs.Add("Hit", new List()); - // } - // if (__instance.AllowPlayerDeath()) - // { - // rpcs["Hit"].Add(__instance.playerClientId); - // LogInfo($"PlayerControllerB.Hit|{__instance.playerUsername}|force:{force}|playerWhoHit:{playerWhoHit.playerUsername}|playHitSFX:{playHitSFX}|hitID:{hitID}"); - // __instance.StartCoroutine(CheckRpc(__instance, "Hit")); - // } - // return true; - //} - - - - public static IEnumerator CheckRpc(PlayerControllerB __instance, string RPC) - { - if (RPC == "Hit" && !Core.AntiCheat.RPCReport_Hit.Value) - { - yield break; - } - if (RPC == "KillPlayer" && !Core.AntiCheat.RPCReport_KillPlayer.Value) - { - yield break; - } - LogInfo("700"); - yield return new WaitForSeconds(Core.AntiCheat.RPCReport_Delay.Value / 1000); - LogInfo("702"); - if (__instance.isPlayerDead) - { - LogInfo("705"); - yield break; - } - LogInfo("708"); - if (rpcs[RPC].Contains(__instance.playerClientId)) - { - LogInfo("711"); - rpcs[RPC].Remove(__instance.playerClientId); - LogInfo($"{__instance.playerUsername}:{__instance.isPlayerDead}"); - ShowMessage(locale.Msg_GetString("RPCReport", new Dictionary() { - { "{player}", __instance.playerUsername }, - { "{RPC}", RPC }, - - })); - if (Core.AntiCheat.RPCReport_Kick.Value) - { - KickPlayer(__instance); - } - } - yield break; - } - - - /// - /// Prefix PlayerControllerB.DamagePlayerServerRpc - /// - /// - [HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_1084949295")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_1084949295(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p) || StartOfRound.Instance.IsHost) - { - if (rpcs.ContainsKey("Hit")) - { - rpcs["Hit"].Remove(p.playerClientId); - } - ByteUnpacker.ReadValueBitPacked(reader, out int damageNumber); - ByteUnpacker.ReadValueBitPacked(reader, out int newHealthAmount); - reader.Seek(0); - LogInfo(p, "PlayerControllerB.DamagePlayerServerRpc", $"damageNumber:{damageNumber}", $"newHealthAmount:{newHealthAmount}"); - var p2 = (PlayerControllerB)target; - if (p2 == p) - { - if (Core.AntiCheat.Health_Recover.Value) - { - if (damageNumber < 0) - { - string msg = locale.Msg_GetString("Health_Recover", new Dictionary() { - { "{player}", p.playerUsername }, - { "{hp}", (damageNumber * -1).ToString() } - }); - ShowMessage(msg); - if (Core.AntiCheat.Health_Kick.Value) - { - KickPlayer(p); - } - return false; - } - } - return true; - } - return CheckDamage(p2, p, ref damageNumber); - } - else if (p == null) - { - return false; - } - return true; - } - - /// - /// Prefix EnemyAI.SwitchToBehaviourServerRpc - /// - [HarmonyPatch(typeof(EnemyAI), "__rpc_handler_2081148948")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_2081148948(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - ByteUnpacker.ReadValueBitPacked(reader, out int stateIndex); - reader.Seek(0); - var e = (EnemyAI)target; - LogInfo(p, $"({e.enemyType.enemyName})EnemyAI.SwitchToBehaviourServerRpc", $"stateIndex:{stateIndex}"); - if (Core.AntiCheat.Enemy.Value) - { - if (e is JesterAI j) - { - if (j.currentBehaviourStateIndex == 0 && stateIndex == 1) - { - if (j.targetPlayer != null) - { - return true; - } - } - else if (j.currentBehaviourStateIndex == 1 && stateIndex == 2 && j.popUpTimer <= 0) - { - return true; - } - else if (j.currentBehaviourStateIndex == 2 && stateIndex == 0) - { - return true; - } - else - { - LogInfo(p, $"({e.enemyType.enemyName})EnemyAI.SwitchToBehaviourServerRpc", $"stateIndex:{stateIndex}", $"popUpTimer:{j.popUpTimer}"); - //ShowMessage(locale.Msg_GetString("Enemy_SwitchToBehaviour", new Dictionary() { - // { "{player}", p.playerUsername } - //})); - //return false; - return true; - } - } - } - } - else if (p == null) - { - return false; - } - return true; - } - - #region Enemy Kill Player(Only Player Self) - - /// - /// Prefix JesterAI.KillPlayerServerRpc - /// - [HarmonyPatch(typeof(JesterAI), "__rpc_handler_3446243450")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_3446243450(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - return KillPlayerServerRpc(target, reader, rpcParams, "JesterAI.KillPlayerServerRpc"); - } - - ///// - ///// Prefix MouthDogAI.KillPlayerServerRpc - ///// - //[HarmonyPatch(typeof(MouthDogAI), "__rpc_handler_998670557")] - //[HarmonyPrefix] - //[HarmonyWrapSafe] - //public static bool __rpc_handler_998670557(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - //{ - // return KillPlayerServerRpc(target, reader, rpcParams, "MouthDogAI.KillPlayerServerRpc"); - //} - - ///// - ///// Prefix ForestGiantAI.GrabPlayerServerRpc - ///// - //[HarmonyPatch(typeof(ForestGiantAI), "__rpc_handler_2965927486")] - //[HarmonyPrefix] - //[HarmonyWrapSafe] - //public static bool __rpc_handler_2965927486(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - //{ - // return KillPlayerServerRpc(target, reader, rpcParams, "ForestGiantAI.GrabPlayerServerRpc"); - //} - - /// - /// Prefix RedLocustBees.BeeKillPlayerServerRpc - /// - [HarmonyPatch(typeof(RedLocustBees), "__rpc_handler_3246315153")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_3246315153(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - return KillPlayerServerRpc(target, reader, rpcParams, "RedLocustBees.BeeKillPlayerServerRpc"); - } - - ///// - ///// Prefix MaskedPlayerEnemy.KillPlayerAnimationServerRpc - ///// - //[HarmonyPatch(typeof(MaskedPlayerEnemy), "__rpc_handler_3192502457")] - //[HarmonyPrefix] - //[HarmonyWrapSafe] - //public static bool __rpc_handler_3192502457(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - //{ - // return KillPlayerServerRpc(target, reader, rpcParams, "MaskedPlayerEnemy.KillPlayerAnimationServerRpc"); - //} - - /// - /// Prefix NutcrackerEnemyAI.LegKickPlayerServerRpc - /// - [HarmonyPatch(typeof(NutcrackerEnemyAI), "__rpc_handler_3881699224")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_3881699224(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - return KillPlayerServerRpc(target, reader, rpcParams, "NutcrackerEnemyAI.LegKickPlayerServerRpc"); - } - - ///// - ///// Prefix BlobAI.SlimeKillPlayerEffectServerRpc - ///// - //[HarmonyPatch(typeof(BlobAI), "__rpc_handler_3848306567")] - //[HarmonyPrefix] - //[HarmonyWrapSafe] - //public static bool __rpc_handler_3848306567(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - //{ - // return KillPlayerServerRpc(target, reader, rpcParams, "BlobAI.SlimeKillPlayerEffectServerRpc"); - //} - - public static Dictionary ClingTime { get; set; } = new Dictionary(); - - /// - /// Prefix CentipedeAI.ClingToPlayerServerRpc - /// - [HarmonyPatch(typeof(CentipedeAI), "__rpc_handler_2791977891")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_2791977891(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (!Patches.Check(rpcParams, out var p)) - return p != null; - ByteUnpacker.ReadValueBitPacked(reader, out int num); - reader.Seek(0); - LogInfo(p, "CentipedeAI.ClingToPlayerServerRpc", $"num:{num}"); - if ((int)p.playerClientId == num) - { - if (ClingTime.ContainsKey(p.playerSteamId)) - { - ClingTime[p.playerSteamId] = DateTime.Now; - } - else - { - ClingTime.Add(p.playerSteamId, DateTime.Now); - } - } - return true; - //return KillPlayerServerRpc(target, reader, rpcParams, "CentipedeAI.ClingToPlayerServerRpc"); - } - - ///// - ///// Prefix RadMechAI.GrabPlayerServerRpc - ///// - //[HarmonyPatch(typeof(RadMechAI), "__rpc_handler_3707286996")] - //[HarmonyPrefix] - //[HarmonyWrapSafe] - //public static bool __rpc_handler_3707286996(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - //{ - // return KillPlayerServerRpc(target, reader, rpcParams, "RadMechAI.GrabPlayerServerRpc"); - //} - - ///// - ///// Prefix CaveDwellerAI.GrabPlayerServerRpc - ///// - ///// - //[HarmonyPatch(typeof(CaveDwellerAI), "__rpc_handler_3591556954")] - //[HarmonyPrefix] - //[HarmonyWrapSafe] - //public static bool __rpc_handler_3591556954(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - //{ - // return KillPlayerServerRpc(target, reader, rpcParams, "CaveDwellerAI.GrabPlayerServerRpc"); - //} - - - - private static bool KillPlayerServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams, string call) - { - if (Check(rpcParams, out var p)) - { - var e = (EnemyAI)target; - ByteUnpacker.ReadValueBitPacked(reader, out int playerId); - reader.Seek(0); - LogInfo(p, $"{e.GetType()}.KillPlayerServerRpc", $"playerId:{playerId}"); - if (playerId <= StartOfRound.Instance.allPlayerScripts.Length && StartOfRound.Instance.allPlayerScripts[playerId] != p) - { - LogInfo(p, $"{e.GetType()}.KillPlayerServerRpc", $"playerUsername:{StartOfRound.Instance.allPlayerScripts[playerId].playerUsername}"); - return false; - } - if (!rpcs.ContainsKey("KillPlayer")) - { - rpcs.Add("KillPlayer", new List()); - } - if (p.AllowPlayerDeath()) - { - LogInfo(p, "StartCoroutine:CheckRpc(KillPlayer)", $"call:{call}"); - rpcs["KillPlayer"].Add(p.playerClientId); - p.StartCoroutine(CheckRpc(p, "KillPlayer")); - } - } - else if (p == null) - { - return false; - } - return true; - } - - #endregion - - /// - /// Prefix EnemyAI.UpdateEnemyPositionServerRpc - /// - [HarmonyPatch(typeof(EnemyAI), "__rpc_handler_255411420")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_255411420(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - //reader.ReadValueSafe(out Vector3 newPos); - //reader.Seek(0); - //LogInfo($"{p.playerUsername} call EnemyAI.UpdateEnemyPositionServerRpc|newPos:{newPos}"); - } - else if (p == null) - { - return false; - } - return true; - } - - - [HarmonyPatch(typeof(EnemyAI), "__rpc_handler_1810146992")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_1810146992(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - var e = (EnemyAI)target; - LogInfo(p, $"({e.enemyType.enemyName})EnemyAI.KillEnemyServerRpc", $"EnemyId:{e.GetInstanceID()}", $"HP:{e.enemyHP}"); - if (Core.AntiCheat.KillEnemy.Value) - { - foreach (var item in bypassKill) - { - if (item.EnemyInstanceId == e.GetInstanceID() && !item.CalledClient.Contains(p.playerClientId)) - { - LogInfo($"{e.GetInstanceID()} bypass|playerClientId:{p.playerClientId}"); - item.CalledClient.Add(p.playerClientId); - return true; - } - } - if (e.enemyHP <= 0) - { - return true; - } - - if (Vector3.Distance(p.transform.position, e.transform.position) > 50f) - { - ShowMessage(locale.Msg_GetString("KillEnemy", new Dictionary() { - { "{player}",p.playerUsername }, - { "{enemyName}",e.enemyType.enemyName }, - { "{HP}",e.enemyHP.ToString() } - })); - if (Core.AntiCheat.KillEnemy2.Value) - { - KickPlayer(p); - return false; - } - } - } - } - return true; - } - - [HarmonyPatch(typeof(EnemyAI), "__rpc_handler_3079913705")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_3079913705(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - if (Core.AntiCheat.Enemy.Value) - { - //LogInfo($"{p.playerUsername} call EnemyAI.UpdateEnemyRotationServerRpc"); - return true; - } - } - return true; - } - - //[HarmonyPatch(typeof(EnemyAI), "__rpc_handler_255411420")] - //[HarmonyPrefix] - //public static bool __rpc_handler_255411420(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - //{ - // if (Check(rpcParams, out var p)) - // { - // if (Core.AntiCheatPlugin.Enemy.Value) - // { - // LogInfo($"{p.playerUsername} call EnemyAI.UpdateEnemyPositionServerRpc"); - // return true; - // } - // } - // else if (p == null) - // { - // return false; - // } - // return true; - //} - - [HarmonyPatch(typeof(EnemyAI), "__rpc_handler_3587030867")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_3587030867(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - if (Core.AntiCheat.Enemy.Value) - { - ByteUnpacker.ReadValueBitPacked(reader, out int clientId); - reader.Seek(0); - var enemy = target.GetComponent(); - if (enemy is MouthDogAI || enemy is DressGirlAI) - { - return true; - } - float v = Vector3.Distance(p.transform.position, enemy.transform.position); - LogInfo(p, $"({enemy.enemyType.enemyName})EnemyAI.ChangeEnemyOwnerServerRpc", $"Distance:{v}", $"CallClientId:{p.playerClientId}", $"OwnerClientId:{enemy.OwnerClientId}", $"NewClientId:{clientId}"); - return true; - } - } - else if (p == null) - { - return false; - } - return true; - } - - [HarmonyPatch(typeof(JetpackItem), "__rpc_handler_3663112878")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_3663112878(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - if (Core.AntiCheat.Jetpack.Value) - { - var jp = (JetpackItem)target; - if (jp.playerHeldBy != null && jp.playerHeldBy.playerClientId != p.playerClientId) - { - ShowMessage(locale.Msg_GetString("Jetpack", new Dictionary() { - { "{player}",p.playerUsername } - })); - if (Core.AntiCheat.Jetpack2.Value) - { - KickPlayer(p); - } - return false; - } - else if (jp.playerHeldBy == null) - { - ShowMessage(locale.Msg_GetString("Jetpack", new Dictionary() { - { "{player}",p.playerUsername } - })); - if (Core.AntiCheat.Jetpack2.Value) - { - KickPlayer(p); - } - return false; - } - return true; - } - } - else if (p == null) - { - return false; - } - return true; - } - - public static List bypassHit = new List(); - public static List bypassKill = new List(); - - [HarmonyPatch(typeof(EnemyAI), "KillEnemyOnOwnerClient")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static void KillEnemyOnOwnerClient(EnemyAI __instance) - { - if (StartOfRound.Instance.localPlayerController.IsHost) - { - if (bypassKill.Any(x => x.EnemyInstanceId == __instance.GetInstanceID())) - { - return; - } - LogInfo($"bypassKill -> {__instance.enemyType.enemyName}({__instance.GetInstanceID()})"); - bypassKill.Add(new HitData() - { - EnemyInstanceId = __instance.GetInstanceID(), - force = 0, - CalledClient = new List() - }); - } - } - - - [HarmonyPatch(typeof(EnemyAI), "HitEnemyOnLocalClient")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static void HitEnemyOnLocalClient(EnemyAI __instance, int force, Vector3 hitDirection, PlayerControllerB playerWhoHit, bool playHitSFX, int hitID) - { - if (StartOfRound.Instance.localPlayerController.IsHost) - { - //if (bypassHit.Any(x => x.EnemyInstanceId == __instance.GetInstanceID())) - //{ - // return; - //} - //if (playerWhoHit == null) - //{ - bypassHit.Add(new HitData() - { - EnemyInstanceId = __instance.GetInstanceID(), - force = force, - CalledClient = new List() - }); - //} - } - } - - public static List explosions { get; set; } = new List(); - - public class ExplosionData - { - public List CalledClient { get; set; } - - public Vector3 ExplosionPostion { get; set; } - - public DateTime CreateDateTime { get; set; } - } - - public class HitData - { - public int EnemyInstanceId { get; set; } - - public int force { get; set; } - - - public List CalledClient { get; set; } - } - - public static PlayerControllerB lastDriver { get; set; } - - - [HarmonyPatch(typeof(EnemyAI), "KillEnemy")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static void ButlerEnemyAI_KillEnemy(EnemyAI __instance) - { - if (StartOfRound.Instance.localPlayerController.IsHost) - { - if (__instance is ButlerEnemyAI) - { - LandminePatch.SpawnExplosion(__instance.transform.position + Vector3.up * 0.15f); - } - } - } - - - //public static void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1) - //{ - // LogInfo($"force:{force}|playerWhoHit:{playerWhoHit?.playerUsername}|playHitSFX:{playHitSFX}|hitID:{hitID}"); - //} - - public static string PlayerClientIdConvertName(int index) - { - if (index < 0 || index >= StartOfRound.Instance.allPlayerScripts.Length) - { - return "Unknown"; - } - return StartOfRound.Instance.allPlayerScripts[index].playerUsername; - } - - //[HarmonyPatch(typeof(EnemyAI), "HitEnemy")] - //[HarmonyPrefix] - //[HarmonyWrapSafe] - //public static void HitEnemy(EnemyAI __instance, int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1) - //{ - // AntiCheat.Core.AntiCheat.LogInfo($"({__instance.enemyType.enemyName})EnemyAI.HitEnemy;EnemyId:{__instance.GetInstanceID()}|HP:{__instance.enemyHP}|force:{force}|playerWhoHit:{playerWhoHit?.playerUsername}|playHitSFX:{playHitSFX}|hitID:{hitID}"); - //} - - [HarmonyPatch(typeof(EnemyAI), "__rpc_handler_3538577804")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool HitEnemyServerRpcPatch(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p) || StartOfRound.Instance.localPlayerController.IsHost) - { - if (p == null) - { - return false; - } - int force; - ByteUnpacker.ReadValueBitPacked(reader, out force); - ByteUnpacker.ReadValueBitPacked(reader, out int playerWhoHit); - reader.ReadValueSafe(out bool playHitSFX, default); - reader.Seek(0); - var e = (EnemyAI)target; - LogInfo(p, $"({e.enemyType.enemyName})EnemyAI.HitEnemyServerRpc", $"EnemyId:{e.GetInstanceID()}", $"HP:{e.enemyHP}", $"force:{force}", $"playerWhoHit:{PlayerClientIdConvertName(playerWhoHit)}({playerWhoHit})"); - if (p.isHostPlayerObject) - { - return true; - } - if (playerWhoHit != -1 && StartOfRound.Instance.allPlayerScripts[playerWhoHit] != p) - { - LogInfo("return false;"); - return false; - } - VehicleController vehicleController = UnityEngine.Object.FindFirstObjectByType(); - if (vehicleController != null) - { - PlayerControllerB currentDriver = vehicleController.currentDriver; - if (force == 2 && currentDriver != null && currentDriver.playerClientId == p.playerClientId) - { - lastDriver = currentDriver; - return true; - } - if (force == 2 && currentDriver == null && lastDriver.playerClientId == p.playerClientId) - { - return true; - } - } - //if (e.isEnemyDead) - //{ - // return true; - //} - foreach (var item in bypassHit) - { - if (item.EnemyInstanceId == e.GetInstanceID() && item.force == force && !item.CalledClient.Contains(p.playerClientId)) - { - LogInfo($"{e.GetInstanceID()} bypass|playerClientId:{p.playerClientId}"); - item.CalledClient.Add(p.playerClientId); - return true; - } - } - if (Core.AntiCheat.Shovel.Value) - { - //if (playerWhoHit == -1 && Vector3.Distance(p.transform.position, e.transform.position) < 30) - //{ - // return true; - //} - var obj = p.ItemSlots[p.currentItemSlot]; - string playerUsername = p.playerUsername; - if (force == 6 && playerWhoHit == -1) - { - LogInfo($"force = 6||enemyPostion:{e.transform.position}"); - explosions = explosions.Where(x => x.CreateDateTime.AddSeconds(10) > DateTime.Now).ToList(); - for (int i = explosions.Count - 1; i > 0; i--) - { - var item = explosions[i]; - if (item.CalledClient.Contains(p.playerSteamId)) - { - continue; - } - float ExplosionDistance = Vector3.Distance(item.ExplosionPostion, e.transform.position); - LogInfo($"ExplosionPostion:{item.ExplosionPostion}||Distance:{ExplosionDistance}"); - if (ExplosionDistance < 5f) - { - item.CalledClient.Add(p.playerSteamId); - return true; - } - } - } - else if (force != 1 && obj != null && (isShovel(obj) || isKnife(obj))) - { - if (!jcs.Contains(p.playerSteamId)) - { - ShowMessage(locale.Msg_GetString("Shovel4", new Dictionary() { - { "{player}",p.playerUsername }, - { "{enemyName}",e.enemyType.enemyName }, - { "{damageAmount}",force.ToString() }, - { "{item}", isShovel(obj) ? locale.Item_GetString("Shovel") : locale.Item_GetString("Knife") } - })); - jcs.Add(p.playerSteamId); - if (Core.AntiCheat.Shovel2.Value) - { - KickPlayer(p); - } - return false; - } - } - else if (!p.isPlayerDead && obj == null) - { - if (ClingTime.ContainsKey(p.playerSteamId) && ClingTime[p.playerSteamId].AddSeconds(5) > DateTime.Now) - { - return true; - } - if (p.ItemSlots.Any(x => isShovel(x)) && force == 1) - { - return true; - } - if (!jcs.Contains(p.playerSteamId)) - { - for (int i = 0; i < p.ItemSlots.Length; i++) - { - LogInfo($"p:{p.playerUsername}|i:{i}|itemName:{p.ItemSlots[i]?.itemProperties?.itemName}"); - } - LogInfo($"currentItemSlot:{p.currentItemSlot}"); - LogInfo($"currentlyHeldObjectServer:{p.currentlyHeldObjectServer?.itemProperties?.itemName}"); - LogInfo($"obj:{obj}"); - if (!Core.AntiCheat.Shovel3.Value && (force == 1 || force == 2 || force == 3 || force == 5)) - { - ShowMessage(locale.Msg_GetString("Shovel6", new Dictionary() { - { "{player}",p.playerUsername }, - { "{enemyName}",e.enemyType.enemyName }, - { "{damageAmount}",force.ToString() } - })); - jcs.Add(p.playerSteamId); - if (Core.AntiCheat.Shovel2.Value) - { - KickPlayer(p); - } - } - else - { - ShowMessage(locale.Msg_GetString("Shovel6", new Dictionary() { - { "{player}",p.playerUsername }, - { "{enemyName}",e.enemyType.enemyName }, - { "{damageAmount}",force.ToString() } - })); - } - return false; - } - } - else if (jcs.Contains(p.playerSteamId)) - { - return false; - } - } - } - - return true; - } - - private static string lastMessage = string.Empty; - - /// - /// 在游戏中输出信息 - /// - public static void ShowMessage(string msg, string lastmsg = null) - { - string showmsg = string.Empty; - var type = Core.AntiCheat.DetectedMessageType.Value; - showmsg = locale.MessageFormat(new Dictionary() { - { "{Prefix}",locale.Prefix() }, - { "{msg}",msg } - }); - if (lastMessage == msg || (lastmsg == lastMessage && lastmsg != null)) - { - //LogInfo($"RepeatMessage|{showmsg}"); - return; - } - if (lastmsg != null) - { - lastMessage = lastmsg; - } - else - { - lastMessage = msg; - } - if (type == Core.AntiCheat.MessageType.PublicChat) - { - LogInfo($"AddTextMessageClientRpc|{showmsg}"); - AddTextMessageClientRpc(showmsg); - } - else if (type == Core.AntiCheat.MessageType.HostChat) - { - ShowMessageHostOnly(showmsg); - } - else - { - LogInfo($"ShowGUI|{showmsg}"); - } - } - - public static void AddTextMessageClientRpc(string showmsg) - { - AccessTools.DeclaredMethod(typeof(HUDManager), "AddTextMessageClientRpc").Invoke(HUDManager.Instance, new object[] { - showmsg - }); - } - - public static bool bypass { get; set; } - - /// - /// 开礼物盒事件(一个礼物盒只能开一次) - /// Prefix GiftBoxItem.OpenGiftBoxServerRpc - /// - [HarmonyPatch(typeof(GiftBoxItem), "__rpc_handler_2878544999")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_2878544999(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - if (Core.AntiCheat.Gift.Value) - { - var item = (GiftBoxItem)target; - if ((bool)AccessTools.DeclaredField(typeof(GiftBoxItem), "hasUsedGift").GetValue(item)) - { - ShowMessage(locale.Msg_GetString("Gift", new Dictionary() { - { "{player}",p.playerUsername } - })); - if (Core.AntiCheat.Gift2.Value) - { - KickPlayer(p); - } - return false; - } - else - { - StartOfRound.Instance.localPlayerController.StartCoroutine(DestroySelf(item.gameObject)); - } - } - } - else if (p == null) - { - return false; - } - return true; - } - - public static IEnumerator DestroySelf(GameObject self) - { - yield return new WaitForSeconds(5f); - UnityEngine.Object.Destroy(self); - } - - /// - /// 使用面具生成假人事件(一个面具只能生成一个假人) - /// Prefix HauntedMaskItem.CreateMimicServerRpc - /// - [HarmonyPatch(typeof(HauntedMaskItem), "__rpc_handler_1065539967")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_1065539967(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - if (Core.AntiCheat.Mask.Value) - { - if (mjs.Contains(target.GetInstanceID())) - { - ShowMessage(locale.Msg_GetString("Mask", new Dictionary() { - { "{player}",p.playerUsername } - })); - if (Core.AntiCheat.Mask2.Value) - { - KickPlayer(p); - } - return false; - } - else - { - mjs.Add(target.GetInstanceID()); - } - } - } - else if (p == null) - { - return false; - } - return true; - } - - /// - /// 检测是否需要处理事件(顺带处理掉SteamID为0的玩家) - /// - public static bool Check(__RpcParams rpcParams, out PlayerControllerB p) - { - if (StartOfRound.Instance.localPlayerController == null) - { - p = default; - return false; - } - else if (!StartOfRound.Instance.localPlayerController.IsHost)//非主机 - { - p = StartOfRound.Instance.localPlayerController; - return false; - } - var tmp = GetPlayer(rpcParams); - p = tmp; - if (p == null)//没玩家 - { - NetworkManager.Singleton.DisconnectClient(rpcParams.Server.Receive.SenderClientId); - return false; - } - else if (rpcParams.Server.Receive.SenderClientId == GameNetworkManager.Instance.localPlayerController.actualClientId)//非本地 - { - p = StartOfRound.Instance.localPlayerController; - return false; - } - else if (StartOfRound.Instance.KickedClientIds.Contains(p.playerSteamId))//如果被踢 - { - Task.Delay(-100); - NetworkManager.Singleton.DisconnectClient(rpcParams.Server.Receive.SenderClientId); - return false; - } - else if (p.playerSteamId == 0) - { - uint clientId = ClientIdToTransportId(rpcParams.Server.Receive.SenderClientId); - if (clientId == 0) - { - return false; - } - ulong steamId = ConnectionIdtoSteamIdMap[clientId]; - Friend f = new Steamworks.Friend(steamId); - NetworkManager.Singleton.DisconnectClient(rpcParams.Server.Receive.SenderClientId); - StartOfRound.Instance.KickedClientIds.Add(steamId); - LogInfo($"检测玩家 {f.Name}({steamId}) 使用AntiKick功能,已自动踢出!"); - return false; - } - return true; - } - - public static uint ClientIdToTransportId(ulong SenderClientId) - { - if (SenderClientId == 0) - { - return 0; - } - NetworkConnectionManager networkConnectionManager = Traverse.Create(NetworkManager.Singleton).Field("ConnectionManager").GetValue(); - ulong transportId = Traverse.Create(networkConnectionManager).Method("ClientIdToTransportId", new object[] { SenderClientId }).GetValue(); - return (uint)transportId; - } - - /// - /// 降落时加载地图事件(显示反作弊信息) - /// Prefix RoundManager.LoadNewLevel - /// - [HarmonyPatch(typeof(RoundManager), "LoadNewLevel")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool LoadNewLevel(SelectableLevel newLevel) - { - if (!StartOfRound.Instance.localPlayerController.IsHost)//非主机 - { - return true; - } - landMines = new List(); - bypassHit = new List(); - bypassKill = new List(); - HUDManager.Instance.AddTextToChatOnServer(locale.Msg_GetString("game_start", new Dictionary() { - { "{ver}",Core.AntiCheat.Version } - }), -1); - return true; - } - - /// - /// 玩家切换格子事件(拿了双手物品无法切换格子,他们本地客户端依旧可以) - /// Prefix PlayerControllerB.SwitchItemSlotsServerRpc - /// - [HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_412259855")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_412259855(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - - if (p.currentlyHeldObjectServer != null && p.currentlyHeldObjectServer.itemProperties.twoHanded) - { - return false; - } - - return true; - } - else if (p == null) - { - return false; - } - return true; - } - - - /// - /// 添加物品到腰包事件 - /// Prefix BeltBagItem.TryAddObjectToBagServerRpc - /// - [HarmonyPatch(typeof(BeltBagItem), "__rpc_handler_2988305002")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_2988305002(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - if (Core.AntiCheat.GrabObject.Value && Core.AntiCheat.GrabObject_BeltBag.Value) - { - reader.ReadValueSafe(out NetworkObjectReference netObjectRef, default); - ByteUnpacker.ReadValueBitPacked(reader, out int playerWhoAdded); - reader.Seek(0); - if (netObjectRef.TryGet(out NetworkObject networkObject, null)) - { - GrabbableObject component = networkObject.GetComponent(); - if (!component.itemProperties.isScrap && !component.isHeld && !component.isHeldByEnemy && component.itemProperties.itemId != 123984 && component.itemProperties.itemId != 819501) - { - return true; - } - ((BeltBagItem)target).CancelAddObjectToBagClientRpc(playerWhoAdded); - return false; - } - } - } - else if (p == null) - { - return false; - } - return true; - } - - /// - /// 玩家捡起物品事件(用于检测多格子,单手拿双手物品,隔空取物) - /// Prefix PlayerControllerB.GrabObjectServerRpc - /// - [HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_1554282707")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_1554282707(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - if (Core.AntiCheat.GrabObject.Value) - { - reader.ReadValueSafe(out NetworkObjectReference grabbedObject, default); - reader.Seek(0); - var jetpack = false; - if (grabbedObject.TryGet(out var networkObject, null)) - { - var all = true; - bool hastwohand = false; - foreach (var item in p.ItemSlots) - { - if (item == null) - { - all = false; - } - else if (item.itemProperties.twoHanded) - { - hastwohand = true; - } - else if (item is JetpackItem) - { - jetpack = true; - } - } - var g = networkObject.GetComponentInChildren(); - if (g != null) - { - LogInfo(p, "PlayerControllerB.GrabObjectServerRpc", $"itemName:{g.itemProperties.itemName}", $"heldByPlayerOnServer:{(g.heldByPlayerOnServer ? g.playerHeldBy?.playerUsername : "false")}", $"Distance:{Vector3.Distance(p.transform.position, g.transform.position)}"); - bool ban = false; - if (Core.AntiCheat.GrabObject_TwoHand.Value) - { - if (g.itemProperties.twoHanded && hastwohand) - { - ban = true; - } - else if (g.itemProperties.twoHanded && jetpack) - { - ban = true; - } - else if (hastwohand && jetpack) - { - ban = true; - } - } - if (Core.AntiCheat.GrabObject_MoreSlot.Value && !ban) - { - ban = all; - } - if (ban) - { - var __rpc_exec_stage = typeof(NetworkBehaviour).GetField("__rpc_exec_stage", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); - __rpc_exec_stage.SetValue(target, 1); - typeof(PlayerControllerB).GetMethod("GrabObjectServerRpc", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke((PlayerControllerB)target, new object[] { - default - }); - __rpc_exec_stage.SetValue(target, 0); - return false; - } - if (Vector3.Distance(g.transform.position, p.serverPlayerPosition) > 100 && !StartOfRound.Instance.shipIsLeaving && StartOfRound.Instance.shipHasLanded) - { - if (p.teleportedLastFrame) - { - return true; - } - ShowMessage(locale.Msg_GetString("GrabObject", new Dictionary() { - { "{player}",p.playerUsername }, - { "{object_position}",g.transform.position.ToString() }, - { "{player_position}",p.serverPlayerPosition.ToString() } - })); - g = default; - grabbedObject = default; - if (Core.AntiCheat.GrabObject_MoreSlot.Value) - { - KickPlayer(p); - } - var __rpc_exec_stage = typeof(NetworkBehaviour).GetField("__rpc_exec_stage", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); - __rpc_exec_stage.SetValue(target, 1); - typeof(PlayerControllerB).GetMethod("GrabObjectServerRpc", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke((PlayerControllerB)target, new object[] { - default - }); - __rpc_exec_stage.SetValue(target, 0); - return false; - } - } - } - } - } - else if (p == null) - { - return false; - } - return true; - } - - - ///// - ///// 玩家跳跃 - ///// Prefix PlayerControllerB.PlayerJumpedServerRpc - ///// - //[HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_2013428264")] - //[HarmonyPrefix] - //[HarmonyWrapSafe] - //public static bool __rpc_handler_420292904(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - //{ - // if (Check(rpcParams, out var p)) - // { - // if (!PlayerJumping.ContainsKey(p)) - // { - // PlayerJumping.Add(p, false); - // } - // if (!PlayerJumping[p]) - // { - // p.StartCoroutine(PlayerJump(p)); - // } - // } - // else if (p == null) - // { - // return false; - // } - // return true; - //} - - //public static Dictionary PlayerJumping { get; set; } = new Dictionary(); - - //public static IEnumerator PlayerJump(PlayerControllerB p) - //{ - - // LogInfo($"{p.playerUsername} is Jumping"); - // PlayerJumping[p] = true; - // yield return new WaitForSeconds(0.25f); - // LogInfo($"{p.playerUsername} wait isGrounded"); - // yield return new WaitUntil(() => Physics.Raycast(p.transform.position, Vector3.down, out var raycastHit, 80f, 268437760, QueryTriggerInteraction.Ignore) && raycastHit.distance < 0.1); - // LogInfo($"{p.playerUsername} is Grounded"); - // PlayerJumping[p] = false; - //} - - - - /// - /// 玩家坐标变动事件(玩家如果隐身会将本体传送到一个很远的位置,例如当前坐标-100) - /// Prefix PlayerControllerB.UpdatePlayerPositionServerRpc - /// - [HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_2013428264")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_2013428264(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - reader.ReadValueSafe(out Vector3 newPos); - reader.Seek(0); - if (Check(rpcParams, out var p)) - { - if (Core.AntiCheat.Invisibility.Value) - { - if (StartOfRound.Instance.currentLevel != null && StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap) - { - if (!recentPlayerPositions.ContainsKey(p.playerSteamId)) - recentPlayerPositions[p.playerSteamId] = new List<(Vector3, float)>(); - float now = Time.time; - recentPlayerPositions[p.playerSteamId] = recentPlayerPositions[p.playerSteamId] - .Where(entry => now - entry.time <= 5f) - .ToList(); - recentPlayerPositions[p.playerSteamId].Add((newPos, now)); - } - var oldpos = p.serverPlayerPosition; - if (p.teleportedLastFrame) - { - return true; - } - if (Vector3.Distance(oldpos, newPos) > 100 && Vector3.Distance(newPos, new Vector3(0, 0, 0)) > 10) - { - ShowMessage(locale.Msg_GetString("Invisibility", new Dictionary() { - { "{player}",p.playerUsername }, - { "{player_position}",newPos.ToString() } - })); - if (Core.AntiCheat.Invisibility2.Value) - { - KickPlayer(p); - } - return false; - } - } - } - else if (p == null) - { - return false; - } - return true; - } - - /// - /// 记录本机SteamID - /// Prefix NetworkManager.Awake - /// - [HarmonyPatch(typeof(NetworkManager), "Awake")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static void NetworkManagerAwake() - { - if (!GameNetworkManager.Instance.disableSteam) - { - ConnectionIdtoSteamIdMap[0] = SteamClient.SteamId; - } - } - - /// - /// 代码来源 @Charlese2 HostFixes - /// 客户端连接事件,获取真实的SteamID - /// - [HarmonyPatch(typeof(FacepunchTransport), "Steamworks.ISocketManager.OnConnecting")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool FacepunchTransportOnConnecting(ref Connection connection, ref ConnectionInfo info) - { - NetIdentity identity = Traverse.Create(info).Field("identity").Value; - //if (StartOfRound.Instance.KickedClientIds.Contains(identity.SteamId.Value)) - //{ - // LogInfo(locale.Log_GetString("refuse_connect", new Dictionary() { - // {"{steamId}",identity.SteamId.Value.ToString() } - // })); - // return false; - //} - if (StartOfRound.Instance.allPlayerScripts.Any(x => x.isPlayerControlled && x.playerSteamId == identity.SteamId.Value)) - { - LogInfo("{steamId} repeatedly joins the game."); - return false; - } - if (ConnectionIdtoSteamIdMap.ContainsKey(connection.Id)) - { - ConnectionIdtoSteamIdMap[connection.Id] = identity.SteamId.Value; - } - else - { - ConnectionIdtoSteamIdMap.Add(connection.Id, identity.SteamId.Value); - } - if (Core.AntiCheat.OperationLog.Value) - { - ShowMessageHostOnly(locale.OperationLog_GetString("JoinLobby", new Dictionary() { - { "{player}",new Friend(ConnectionIdtoSteamIdMap[connection.Id]).Name } - })); - } - return true; - } - - - /// - /// - /// - /// - /// - [HarmonyPatch(typeof(NetworkConfig), "CompareConfig")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool NetworkConnectionManagerInitialize(ref bool __result) - { - if (StartOfRound.Instance != null && StartOfRound.Instance.IsHost) - { - if (Core.AntiCheat.IgnoreClientConfig.Value) - { - __result = true; - return false; - } - } - return true; - } - - /// - /// 代码来源 @Charlese2 HostFixes - /// 客户端断开连接事件 - /// Prefix FacepunchTransport.OnDisconnected - /// - [HarmonyPatch(typeof(FacepunchTransport), "Steamworks.ISocketManager.OnDisconnected")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static void FacepunchTransportOnDisconnected(ref Connection connection, ref ConnectionInfo info) - { - if (NetworkManager.Singleton?.IsListening == true) - { - NetIdentity identity = Traverse.Create(info).Field("identity").Value; - HUDManagerPatch.SyncAllPlayerLevelsServerRpcCalls.Remove(ConnectionIdtoSteamIdMap[connection.Id]); - StartOfRoundPatch.SyncShipUnlockablesServerRpcCalls.Remove(ConnectionIdtoSteamIdMap[connection.Id]); - StartOfRoundPatch.SyncAlreadyHeldObjectsServerRpcCalls.Remove(ConnectionIdtoSteamIdMap[connection.Id]); - ConnectionIdtoSteamIdMap.Remove(connection.Id); - } - } - - - - - - /// - /// Prefix HUDManager.AddTextMessageServerRpc - /// - [HarmonyPatch(typeof(HUDManager), "__rpc_handler_2787681914")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_2787681914(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - reader.ReadValueSafe(out bool flag, default); - string chatMessage = null; - if (flag) - { - reader.ReadValueSafe(out chatMessage, false); - } - reader.Seek(0); - LogInfo(p, "HUDManager.AddTextMessageServerRpc", $"chatMessage:{chatMessage}"); - if (chatMessage.Contains("Tyzeron.Minimap")) - { - ShowMessage(locale.Msg_GetString("Map", new Dictionary() { - { "{player}",p.playerUsername } - })); - if (Core.AntiCheat.Map2.Value) - { - KickPlayer(p); - } - return false; - } - } - return false; - } - else if (chatMessage.StartsWith("[morecompanycosmetics]"))//bypass MoreCompany - { - return true; - } - else - { - return false; - } - } - else if (p == null) - { - return false; - } - return true; - } - - ///// - ///// HUDManager.AddPlayerChatMessageClientRpc - ///// - //[HarmonyPatch(typeof(HUDManager), "__rpc_handler_168728662")] - //[HarmonyPrefix] - //[HarmonyWrapSafe] - //public static bool __rpc_handler_168728662(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - //{ - // return __rpc_handler_2930587515(target, reader, rpcParams); - //} - - /// - /// HUDManager.AddPlayerChatMessageServerRpc - /// - [HarmonyPatch(typeof(HUDManager), "__rpc_handler_2930587515")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_2930587515(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - if (Core.AntiCheat.ChatReal.Value) - { - try - { - reader.ReadValueSafe(out bool flag, default); - string chatMessage = null; - if (flag) - { - reader.ReadValueSafe(out chatMessage, false); - } - ByteUnpacker.ReadValueBitPacked(reader, out int playerId); - reader.Seek(0); - LogInfo(p, $"HUDManager.AddPlayerChatMessageServerRpc", $"chatMessage:{chatMessage}"); - if (playerId == -1) - { - return false; - } - if (playerId <= StartOfRound.Instance.allPlayerScripts.Length) - { - if (StartOfRound.Instance.allPlayerScripts[(int)playerId].playerSteamId != p.playerSteamId) - { - ShowMessage(locale.Msg_GetString("ChatReal", new Dictionary() { - { "{player}",p.playerUsername }, - { "{player2}",StartOfRound.Instance.allPlayerScripts[playerId].playerUsername }, - })); - if (Core.AntiCheat.ChatReal2.Value) - { - KickPlayer(p); - } - return false; - } - else - { - bool ret = CooldownManager.CheckCooldown("Chat", p); - if (ret && locale.current_language == "zh_CN") - { - - AccessTools.DeclaredMethod(typeof(HUDManager), "AddPlayerChatMessageClientRpc").Invoke(HUDManager.Instance, new object[] { - chatMessage, - playerId - }); - return false; - - } - return ret; - } - } - else - { - return false; - } - } - catch (Exception ex) - { - LogInfo(ex.ToString()); - return false; - } - } - } - else if (p == null) - { - return false; - } - return true; - } - - - public static bool CheckRemoteTerminal(PlayerControllerB p, string call) - { - LogInfo(p, "CheckRemoteTerminal", $"Call:{call}"); - if (whoUseTerminal == null && lastWhoUseTerminal.Value == p.playerSteamId) - { - LogInfo($"whoUseTerminal == null && lastWhoUseTerminal == {p.playerSteamId}||Time:{Math.Round((DateTime.Now - lastWhoUseTerminal.Key).TotalSeconds, 2)}s"); - if (lastWhoUseTerminal.Key.AddSeconds(10) > DateTime.Now) - { - return true; - } - } - if (whoUseTerminal != p) - { - if (whoUseTerminal == null) - { - LogInfo($"no player use terminal|request player:{p.playerUsername}|call:{call}"); - } - else - { - LogInfo($"whoUseTerminal:{whoUseTerminal.playerUsername}|p:{p.playerUsername}|call:{call}"); - } - ShowMessage(locale.Msg_GetString("RemoteTerminal", new Dictionary() { - { "{player}",p.playerUsername } - })); - if (Core.AntiCheat.RemoteTerminal2.Value) - { - KickPlayer(p); - } - return false; - } - return true; - } - - [HarmonyPatch(typeof(InteractTrigger), "__rpc_handler_1430497838")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_1430497838(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p) || StartOfRound.Instance.IsHost) - { - ByteUnpacker.ReadValueBitPacked(reader, out int playerNum); - reader.Seek(0); - if (playerNum == (int)p.playerClientId) - { - - var terminalTrigger = (InteractTrigger)AccessTools.DeclaredField(typeof(Terminal), "terminalTrigger").GetValue(terminal); - if (terminalTrigger.GetInstanceID() == ((InteractTrigger)target).GetInstanceID()) - { - whoUseTerminal = p; - LogInfo($"player {p.playerUsername} use Terminal"); - } - } - } - else if (p == null) - { - return false; - } - return true; - } - - [HarmonyPatch(typeof(InteractTrigger), "__rpc_handler_880620475")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_880620475(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p) || StartOfRound.Instance.IsHost) - { - ByteUnpacker.ReadValueBitPacked(reader, out int playerNum); - reader.Seek(0); - if (playerNum == (int)p.playerClientId) - { - if (p.isPlayerDead) - { - LogInfo($"player {p.playerUsername} death can't use terminal"); - return false; - } - var terminalTrigger = (InteractTrigger)AccessTools.DeclaredField(typeof(Terminal), "terminalTrigger").GetValue(terminal); - if (terminalTrigger.GetInstanceID() == ((InteractTrigger)target).GetInstanceID()) - { - lastWhoUseTerminal = new KeyValuePair(DateTime.Now, p.playerSteamId); - whoUseTerminal = null; - LogInfo($"player {p.playerUsername} stop use Terminal"); - } - } - } - else if (p == null) - { - return false; - } - return true; - } - - /// - /// 终端噪音限制 - /// Prefix Terminal.PlayTerminalAudioServerRpc - /// - [HarmonyPatch(typeof(Terminal), "__rpc_handler_1713627637")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_1713627637(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - if (Core.AntiCheat.RemoteTerminal.Value) - { - if (!CheckRemoteTerminal(p, "Terminal.PlayTerminalAudioServerRpc")) - { - return false; - } - } - return CooldownManager.CheckCooldown("TerminalNoise", p); - } - else if (p == null) - { - return false; - } - return true; - } - - /// - /// 飞船灯开关速度限制 - /// Prefix ShipLights.SetShipLightsServerRpc - /// - [HarmonyPatch(typeof(ShipLights), "__rpc_handler_1625678258")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_1625678258(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - bool canUse = CooldownManager.CheckCooldown("ShipLight", p); - if (!canUse) - { - ((ShipLights)target).SetShipLightsClientRpc(true); - } - return canUse; - } - else if (p == null) - { - return false; - } - return true; - } - - /// - /// 通过ClientId找到调用RPC的玩家 - /// - /// - /// - private static PlayerControllerB GetPlayer(__RpcParams rpcParams) - { - foreach (var item in StartOfRound.Instance.allPlayerScripts) - { - if (item.actualClientId == rpcParams.Server.Receive.SenderClientId) - { - return item; - } - } - return null;//?? - } - - public static Dictionary ReloadGun = new Dictionary(); - - /// - /// 上弹事件 - /// Prefix ShotgunItem.ReloadGunEffectsServerRpc - /// - [HarmonyPatch(typeof(ShotgunItem), "__rpc_handler_3349119596")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_3349119596(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - if (Core.AntiCheat.InfiniteAmmo.Value) - { - reader.ReadValueSafe(out bool start, default); - reader.Seek(0); - var shot = (ShotgunItem)target; - LogInfo(p, $"ShotgunItem.ReloadGunEffectsServerRpc", $"start:{start}", $"shellsLoaded:{shot.shellsLoaded}"); - if (!ReloadGun.ContainsKey(p.playerSteamId)) - { - ReloadGun.Add(p.playerSteamId, start); - } - else - { - ReloadGun[p.playerSteamId] = start; - } - if (start) - { - var ammo = shot.playerHeldBy.ItemSlots.FirstOrDefault(x => x is GunAmmo ga && ga.ammoType == shot.gunCompatibleAmmoID); - if (ammo != default) - { - shot.StartCoroutine(CheckAmmo(p, shot, ammo)); - return true; - } - else - { - ShowMessage(locale.Msg_GetString("InfiniteAmmo", new Dictionary() { - { "{player}",p.playerUsername } - })); - if (Core.AntiCheat.InfiniteAmmo2.Value) - { - KickPlayer(p); - } - } - return false; - } - } - } - else if (p == null) - { - return false; - } - return true; - } - - public static IEnumerator CheckAmmo(PlayerControllerB p, ShotgunItem shot, GrabbableObject ammo) - { - yield return new WaitForSeconds(0.95f + 0.3f); - yield return new WaitForSeconds(3f);//delay - if (ReloadGun.ContainsKey(p.playerSteamId) && !ReloadGun[p.playerSteamId]) - { - if (ammo != null && ammo.NetworkObject != null && ammo.NetworkObject.IsSpawned) - { - ShowMessage(locale.Msg_GetString("InfiniteAmmo", new Dictionary() { - { "{player}",p.playerUsername } - })); - if (Core.AntiCheat.InfiniteAmmo2.Value) - { - KickPlayer(p); - } - } - } - } - - - - /// - /// 开枪事件 - /// Prefix ShotgunItem.ShootGunServerRpc - /// - [HarmonyPatch(typeof(ShotgunItem), "__rpc_handler_1329927282")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_1329927282(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p) || StartOfRound.Instance.localPlayerController.IsHost) - { - if (Core.AntiCheat.InfiniteAmmo.Value) - { - var s = (ShotgunItem)target; - var localClientSendingShootGunRPC = (bool)typeof(ShotgunItem).GetField("localClientSendingShootGunRPC", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(s); - if (localClientSendingShootGunRPC) - { - return true; - } - else - { - LogInfo(p, "ShotgunItem.ShootGunServerRpc", $"shellsLoaded:{s.shellsLoaded}"); - if (s.shellsLoaded == 0) - { - ShowMessage(locale.Msg_GetString("InfiniteAmmo", new Dictionary() { - { "{player}",p.playerUsername } - })); - if (Core.AntiCheat.InfiniteAmmo2.Value) - { - KickPlayer(p); - } - return false; - } - } - } - if (Core.AntiCheat.ItemCooldown.Value) - { - var id = p.playerSteamId; - var m = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - if (!sdqcd.ContainsKey(id)) - { - sdqcd.Add(id, new List()); - } - if (sdqcd[id].Count > 200) - { - sdqcd[id].RemoveRange(0, sdqcd[id].Count - 1); - } - if (sdqcd[id].Count(x => x == m) >= 2) - { - ShowMessage(locale.Msg_GetString("ItemCooldown", new Dictionary() { - { "{player}",p.playerUsername }, - { "{item}",locale.Item_GetString("Shotgun") } - })); - if (Core.AntiCheat.ItemCooldown2.Value) - { - KickPlayer(p); - } - return false; - } - else - { - sdqcd[id].Add(m); - } - } - } - else if (p == null) - { - return false; - } - return true; - } - - /// - /// 挥刀事件 - /// Prefix KnifeItem.HitShovelServerRpc - /// - [HarmonyPatch(typeof(KnifeItem), "__rpc_handler_2696735117")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_2696735117(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - return CheckCoolDownMethod(rpcParams, 10); - } - - /// - /// 挥铲事件 - /// Prefix Shovel.HitShovelServerRpc - /// - [HarmonyPatch(typeof(Shovel), "__rpc_handler_2096026133")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_2096026133(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - return CheckCoolDownMethod(rpcParams, 3); - } - - private static bool CheckCoolDownMethod(__RpcParams rpcParams, int cd) - { - if (Check(rpcParams, out var p)) - { - if (Core.AntiCheat.ItemCooldown.Value) - { - var id = p.playerSteamId; - var m = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - if (!czcd.ContainsKey(id)) - { - czcd.Add(id, new List()); - } - if (czcd[id].Count > 200) - { - czcd[id].RemoveRange(0, czcd[id].Count - 1); - } - if (czcd[id].Count(x => x == m) >= cd) - { - ShowMessage(locale.Msg_GetString("ItemCooldown", new Dictionary() { - { "{player}",p.playerUsername }, - { "{item}",locale.Item_GetString("Shovel") } - })); - if (Core.AntiCheat.ItemCooldown2.Value) - { - KickPlayer(p); - } - return false; - } - else - { - czcd[id].Add(m); - } - } - } - else if (p == null) - { - return false; - } - return true; - } - - - /// - /// 玩家拉杆事件 - /// Prefix StartOfRound.__rpc_handler_1089447320 - /// - [HarmonyPatch(typeof(StartOfRound), "__rpc_handler_1089447320")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool StartGameServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - StartMatchLever startMatchLever = UnityEngine.Object.FindObjectOfType(); - if (Check(rpcParams, out var p)) - { - if (Core.AntiCheat.ShipConfig.Value && !GameNetworkManager.Instance.gameHasStarted) - { - ShowMessage(locale.Msg_GetString("ShipConfig5", new Dictionary() { - { "{player}",p.playerUsername } - })); - startMatchLever.triggerScript.interactable = true; - if (Core.AntiCheat.Ship_Kick.Value) - { - KickPlayer(p); - return false; - } - return false; - } - else if (StartOfRound.Instance.allPlayerScripts.Count(x => x.isPlayerControlled) >= Core.AntiCheat.ShipConfig2.Value) - { - return true; - } - else - { - startMatchLever.triggerScript.interactable = true; - ShowMessage(locale.Msg_GetString("ShipConfig2", new Dictionary() { - { "{player}",p.playerUsername }, - { "{cfg}",Core.AntiCheat.ShipConfig2.Value.ToString() } - })); - return false; - } - } - else if (p == null) - { - startMatchLever.triggerScript.interactable = true; - return false; - } - return true; - } - - /// - /// 玩家断开连接时清空SteamId(防止游戏缓存) - /// Postfix StartOfRound.OnPlayerDC - /// - [HarmonyPatch(typeof(StartOfRound), "OnPlayerDC")] - [HarmonyPostfix] - [HarmonyWrapSafe] - public static void OnPlayerDC(int playerObjectNumber, ulong clientId) - { - PlayerControllerB component = StartOfRound.Instance.allPlayerObjects[playerObjectNumber].GetComponent(); - component.playerSteamId = 0; - return; - } - - public static KeyValuePair lastWhoUseTerminal { get; set; } - public static PlayerControllerB whoUseTerminal { get; set; } - - /// - /// 踢出玩家 - /// - /// 玩家 - /// 重新加入 - public static void KickPlayer(PlayerControllerB kick, bool canJoin = false, string Reason = null) - { - if (kick.playerClientId == 0) - { - return; - } - NetworkManager.Singleton.DisconnectClient(kick.playerClientId, $"[{locale.Prefix()}] {locale.Msg_GetString("KickPlayer")}!"); - if (kick.playerSteamId == 0) - { - return; - } - var s = StartOfRound.Instance; - ulong playerSteamId = kick.playerSteamId; - if (!s.KickedClientIds.Contains(playerSteamId) && !canJoin) - { - s.KickedClientIds.Add(playerSteamId); - } - var terminal = UnityEngine.Object.FindAnyObjectByType(); - LogInfo("terminalInUse" + terminal.placeableObject.inUse); - LogInfo("whoUseTerminal:" + whoUseTerminal?.playerUsername); - LogInfo("playerUsername:" + kick?.playerUsername); - if (whoUseTerminal == kick && terminal.placeableObject.inUse) - { - LogInfo("SetTerminalInUseServerRpc"); - terminal.SetTerminalInUseClientRpc(false); - terminal.terminalInUse = false; - } - ShowMessage(locale.Msg_GetString("Kick", new Dictionary() { - { "{player}",kick.playerUsername } - })); - } - - - - /// - /// 拉杆事件(正常拉杆都要经过这一层) - /// Prefix StartMatchLever.PlayLeverPullEffectsServerRpc - /// - [HarmonyPatch(typeof(StartMatchLever), "__rpc_handler_2406447821")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_2406447821(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - - if (Check(rpcParams, out var p)) - { - if (UnityEngine.Object.FindAnyObjectByType().leverHasBeenPulled && !StartOfRound.Instance.shipHasLanded) - { - return StartGameServerRpc(target, reader, rpcParams); - } - else - { - return EndGameServerRpc(target, reader, rpcParams); - } - } - else if (p == null) - { - UnityEngine.Object.FindObjectOfType().triggerScript.interactable = true; - return false; - } - return true; - } - - - /// - /// 出售完货物事件(用于更新反作弊的记录金钱) - /// Postfix DepositItemsDesk.SellAndDisplayItemProfits - /// - [HarmonyPatch(typeof(DepositItemsDesk), "SellAndDisplayItemProfits")] - [HarmonyPostfix] - [HarmonyWrapSafe] - public static void SellAndDisplayItemProfits(int profit, int newGroupCredits) - { - if (!StartOfRound.Instance.localPlayerController.IsHost) - { - return; - } - Money = newGroupCredits; - LogInfo($"SetMoney:{Money}"); - } - - /// - /// 玩家销毁物品事件(允许销毁礼物盒和钥匙) - /// Prefix PlayerControllerB.DespawnHeldObjectServerRpc - /// - [HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_1786952262")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_1786952262(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - if (Core.AntiCheat.DespawnItem.Value) - { - LogInfo(p, "PlayerControllerB.DespawnHeldObjectServerRpc", $"itemName:{p.currentlyHeldObjectServer.itemProperties.itemName}"); - if (p.currentlyHeldObjectServer != null && !(p.currentlyHeldObjectServer is GiftBoxItem) && !(p.currentlyHeldObjectServer is KeyItem)) - { - ShowMessage(locale.Msg_GetString("DespawnItem", new Dictionary() { - { "{player}",p.playerUsername }, - { "{item}",p.currentlyHeldObjectServer.itemProperties.itemName } - })); - if (Core.AntiCheat.DespawnItem2.Value) - { - KickPlayer(p); - } - return false; - } - } - } - else if (p == null) - { - return false; - } - return true; - } - - - - - /// - /// UI更新事件(房主死亡时加上一票起飞提示) - /// Postfix HUDManager.Update - /// - [HarmonyPatch(typeof(HUDManager), "Update")] - [HarmonyPostfix] - [HarmonyWrapSafe] - public static void Update() - { - if (!StartOfRound.Instance.IsHost) - { - return; - } - if (GameNetworkManager.Instance == null || GameNetworkManager.Instance.localPlayerController == null) - { - return; - } - if (StartOfRound.Instance.shipIsLeaving || !StartOfRound.Instance.currentLevel.planetHasTime) - { - return; - } - if (Core.AntiCheat.ShipSetting_OnlyOneVote.Value) - { - if (!TimeOfDay.Instance.shipLeavingAlertCalled) - { - if (GameNetworkManager.Instance.localPlayerController.isPlayerDead && !string.IsNullOrEmpty(HUDManager.Instance.holdButtonToEndGameEarlyVotesText.text)) - { - HUDManager.Instance.holdButtonToEndGameEarlyVotesText.text += Environment.NewLine + locale.Msg_GetString("vote"); - } - } - } - } - - - /// - /// 死亡玩家投票事件(这里处理房主一票起飞) - /// Postfix TimeOfDay.SetShipLeaveEarlyServerRpc - /// - [HarmonyPatch(typeof(TimeOfDay), "__rpc_handler_543987598")] - [HarmonyPostfix] - [HarmonyWrapSafe] - public static void Postfix__rpc_handler_543987598(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (StartOfRound.Instance.localPlayerController.IsHost) - { - if (Core.AntiCheat.ShipSetting_OnlyOneVote.Value) - { - if (rpcParams.Server.Receive.SenderClientId == 0) - { - TimeOfDay.Instance.SetShipLeaveEarlyClientRpc(TimeOfDay.Instance.normalizedTimeOfDay + 0.1f, StartOfRound.Instance.allPlayerScripts.Length); - } - } - } - - } - - /// - /// 死亡玩家投票事件(将事件转发到起飞拉杆事件) - /// Prefix TimeOfDay.SetShipLeaveEarlyServerRpc - /// - [HarmonyPatch(typeof(TimeOfDay), "__rpc_handler_543987598")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_543987598(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - int num = StartOfRound.Instance.connectedPlayersAmount + 1 - StartOfRound.Instance.livingPlayers; - string msg = locale.Msg_GetString("vote_player", new Dictionary() { - { "{player}",p.playerUsername }, - { "{now}",(TimeOfDay.Instance.votesForShipToLeaveEarly + 1).ToString() }, - { "{max}",num.ToString() } - }); - ShowMessageHostOnly(msg); - if (TimeOfDay.Instance.votesForShipToLeaveEarly + 1 >= num) - { - LogInfo("Vote EndGame"); - return EndGameServerRpc(target, reader, rpcParams); - } - } - else if (p == null) - { - return false; - } - return true; - } - - - public static void ShowMessageHostOnly(string msg) - { - LogInfo($"ShowMessageHostOnly -> {msg}"); - AccessTools.DeclaredMethod(typeof(HUDManager), "AddChatMessage").Invoke(HUDManager.Instance, new object[] { msg, "", -1, false }); - } - - /// - /// 起飞拉杆事件 - /// Prefix StartOfRound.EndGameServerRpc - /// - [HarmonyPatch(typeof(StartOfRound), "__rpc_handler_2028434619")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool EndGameServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - ByteUnpacker.ReadValueBitPacked(reader, out int num); - reader.Seek(0); - LogInfo(p, "StartOfRound.EndGameServerRpc", $"num:{num}", $"shipHasLanded:{StartOfRound.Instance.shipHasLanded}"); - if (num == 0 && p.playerClientId != 0) - { - UnityEngine.Object.FindObjectOfType().triggerScript.interactable = true; - return false; - } - if (!StartOfRound.Instance.shipHasLanded) - { - UnityEngine.Object.FindObjectOfType().triggerScript.interactable = true; - return false; - } - if (TimeOfDay.Instance.shipLeavingAlertCalled) - { - return true; - } - var hour = int.Parse(Core.AntiCheat.ShipConfig3.Value.Split(':')[0]); - var min = int.Parse(Core.AntiCheat.ShipConfig3.Value.Split(':')[1]); - var time = (int)(TimeOfDay.Instance.normalizedTimeOfDay * (60f * TimeOfDay.Instance.numberOfHours)) + 360; - int time2 = (int)Mathf.Floor((float)(time / 60)); - bool pm = false; - if (time2 > 12) - { - pm = true; - time2 %= 12; - } - time = time % 60; - if (pm) - { - time2 += 12; - } - var live = StartOfRound.Instance.allPlayerScripts.Where(x => x.isPlayerControlled && !x.isPlayerDead); - - if (live.Count() == 1 && live.FirstOrDefault().isInHangarShipRoom) - { - return true; - } - decimal p1 = Math.Round((decimal)live.Count() * (decimal)(Core.AntiCheat.ShipConfig4.Value / 100m), 2); - decimal p2 = StartOfRound.Instance.allPlayerScripts.Count(x => x.isPlayerControlled && x.isInHangarShipRoom); // - if (StartOfRound.Instance.currentLevel.PlanetName.Contains("Gordion")) - { - time2 = hour; - time = min; - } - if (hour <= time2 && min <= time && p2 >= p1) - { - return true; - } - else - { - ShowMessage(locale.Msg_GetString("ShipConfig4", new Dictionary() { - { "{player}",p.playerUsername }, - { "{player_count}",p1.ToString() }, - { "{cfg4}",Core.AntiCheat.ShipConfig4.Value.ToString() }, - { "{cfg3}",$"{hour.ToString("00")}:{min.ToString("00")}" }, - { "{game_time}",$"{time2.ToString("00")}:{time.ToString("00")}" } - })); - UnityEngine.Object.FindObjectOfType().triggerScript.interactable = true; - return false; - } - } - else if (p == null) - { - UnityEngine.Object.FindObjectOfType().triggerScript.interactable = true; - return false; - } - return true; - } - - /// - /// 放置飞船装饰事件(检测) - /// Prefix ShipBuildModeManager.PlaceShipObjectServerRpc - /// - [HarmonyPatch(typeof(ShipBuildModeManager), "__rpc_handler_861494715")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_861494715(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p) || StartOfRound.Instance.IsHost) - { - if (Core.AntiCheat.ShipBuild.Value) - { - Vector3 newPosition; - reader.ReadValueSafe(out newPosition); - Vector3 newRotation; - reader.ReadValueSafe(out newRotation); - reader.ReadValueSafe(out NetworkObjectReference objectRef, default); - reader.Seek(0); - if (objectRef.TryGet(out var networkObject, null)) - { - PlaceableShipObject placingObject = networkObject.gameObject.GetComponentInChildren(); - LogInfo(p, "ShipBuildModeManager.PlaceShipObjectServerRpc", $"object:{placingObject.parentObject.name}", $"newPosition:{newPosition.ToString()}", $"newRotation:{newRotation}"); - //LogInfo($"newRotation:{newRotation}|mainMesh:{placingObject.mainMesh.transform.eulerAngles.ToString()}"); - if (Math.Floor(newRotation.x) != Math.Floor(placingObject.mainMesh.transform.eulerAngles.x) || Math.Floor(newRotation.z) != Math.Floor(placingObject.mainMesh.transform.eulerAngles.z)) - { - ShowMessage(locale.Msg_GetString("ShipBuild", new Dictionary() { - { "{player}",p.playerUsername }, - { "{position}",newRotation.ToString() }, - { "{object}",placingObject.parentObject.name } - }), locale.Msg_GetString("ShipBuild")); - if (Core.AntiCheat.ShipBuild2.Value) - { - KickPlayer(p); - } - return false; - } - var ShipBuildModeManager = (ShipBuildModeManager)target; - //LogInfo($"{p.playerUsername}|ShipBuildModeManager.PlaceShipObjectServerRpc|placingObject:{placingObject.parentObject.name},{placingObject.unlockableID}|newPosition:{newPosition}|newRotation:{newRotation}"); - if (!StartOfRound.Instance.shipInnerRoomBounds.bounds.Contains(newPosition)) - { - ShowMessage(locale.Msg_GetString("ShipBuild", new Dictionary() { - { "{player}",p.playerUsername }, - { "{position}",newPosition.ToString() } - }), locale.Msg_GetString("ShipBuild")); - if (Core.AntiCheat.ShipBuild2.Value) - { - KickPlayer(p); - } - return false; - } - } - } - return true; - } - else if (p == null) - { - return false; - } - return true; - } - - - /// - /// 离开地雷事件(记录是否触发过) - /// Prefix Landmine.OnTriggerExit - /// - [HarmonyPatch(typeof(Landmine), "OnTriggerExit")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool TriggerMineOnLocalClientByExiting(Landmine __instance, Collider other) - { - if (!StartOfRound.Instance.IsHost) - { - return true; - } - if (__instance.hasExploded) - { - return true; - } - if (!__instance.gameObject.activeSelf) - { - return true; - } - bool mineActivated = (bool)AccessTools.DeclaredField(typeof(Landmine), "mineActivated").GetValue(__instance); - if (!mineActivated) - { - return true; - } - int id = __instance.GetInstanceID(); - if (!landMines.Contains(id)) - { - landMines.Add(id); - } - //LogInfo($"Landmine.OnTriggerExit({id})"); - return true; - } - - /// - /// 地雷引爆事件(检测) - /// Prefix Landmine.ExplodeMineServerRpc - /// - [HarmonyPatch(typeof(Landmine), "__rpc_handler_3032666565")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_3032666565(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - if (Core.AntiCheat.Landmine.Value) - { - var lm = (Landmine)target; - int id = lm.GetInstanceID(); - //LogInfo(p, "Landmine.ExplodeMineServerRpc", $"LandMineId:{id}"); - if (!landMines.Contains(id) && !lm.hasExploded) - { - if(recentPlayerPositions.TryGetValue(p.playerSteamId,out var postions)) { - if (!postions.Any(x => Vector3.Distance(x.pos, lm.transform.position) < 5)) - { - ShowMessage(locale.Msg_GetString("Landmine", new Dictionary() { - { "{player}",p.playerUsername } - })); - if (Core.AntiCheat.Landmine2.Value) - { - KickPlayer(p); - } - } - } - - } - } - } - else if (p == null) - { - return false; - } - return true; - } - - /// - /// 老板激怒事件(正常被激怒只有主机才会调用SeverRpc,客户端调用就是有问题) - /// Prefix DepositItemsDesk.AttackPlayersServerRpc - /// - [HarmonyPatch(typeof(DepositItemsDesk), "__rpc_handler_3230280218")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static bool __rpc_handler_3230280218(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Check(rpcParams, out var p)) - { - if (Core.AntiCheat.Boss.Value) - { - ShowMessage(locale.Msg_GetString("Boss", new Dictionary() { - { "{player}",p.playerUsername } - })); - if (Core.AntiCheat.Boss2.Value) - { - KickPlayer(p); - } - } - return false; - } - else if (p == null) - { - return false; - } - return true; - } - - /// - /// 自动添加AC标识 - /// Prefix GameNetworkManager.StartHost - /// - [HarmonyPatch(typeof(GameNetworkManager), "StartHost")] - [HarmonyPrefix] - [HarmonyWrapSafe] - public static void StartHost() - { - if (Core.AntiCheat.Prefix.Value.IsNullOrWhiteSpace()) - { - return; - } - var setting = GameNetworkManager.Instance.lobbyHostSettings; - string rawText = setting.lobbyName; - rawText = rawText.Replace("【", "[").Replace("】", "]"); - List labels = new List(); - var match = Regex.Match(rawText, "^\\[(.*?)\\]"); - if (match.Success) - { - var txt = match.Groups[1].Value; - labels.AddRange(txt.Split('/')); - rawText = rawText.Remove(0, match.Groups[0].Value.Length).TrimStart(); - } - if (!labels.Any(x => x == Core.AntiCheat.Prefix.Value)) - { - labels.Add(Core.AntiCheat.Prefix.Value); - } - setting.lobbyName = "[" + string.Join("/", labels) + "]" + " " + rawText; - } - } -} diff --git a/AntiCheat/Patch/PlayerControllerBPatch.cs b/AntiCheat/Patch/PlayerControllerBPatch.cs deleted file mode 100644 index dcabee3..0000000 --- a/AntiCheat/Patch/PlayerControllerBPatch.cs +++ /dev/null @@ -1,97 +0,0 @@ -using AntiCheat.Core; - -using GameNetcodeStuff; - -using HarmonyLib; - -using Steamworks; -using Steamworks.Data; - -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net.Http.Headers; -using System.Runtime.Remoting.Messaging; -using System.Security.Permissions; -using System.Text; -using System.Threading.Tasks; - -using Unity.Netcode; - -using UnityEngine; - -namespace AntiCheat.Patch -{ - [HarmonyPatch(typeof(PlayerControllerB))] - [HarmonyWrapSafe] - public static class PlayerControllerBPatch - { - [HarmonyPostfix] - [HarmonyPatch("ConnectClientToPlayerObject")] - public static void ConnectClientToPlayerObject(PlayerControllerB __instance) - { - if (__instance.isHostPlayerObject && StartOfRound.Instance.IsHost) - { - if (File.Exists("AntiCheat.log")) - { - File.Delete("AntiCheat.log"); - } - Patches.explosions = new List(); - Patches.ConnectionIdtoSteamIdMap = new Dictionary(); - HUDManagerPatch.SyncAllPlayerLevelsServerRpcCalls = new List(); - StartOfRoundPatch.SyncShipUnlockablesServerRpcCalls = new List(); - StartOfRoundPatch.SyncAlreadyHeldObjectsServerRpcCalls = new List(); - } - } - - /// - /// DropAllHeldItemsServerRpc - /// - /// - [HarmonyPatch("__rpc_handler_760742013")] - [HarmonyPrefix] - public static bool DropAllHeldItemsServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (!Patches.Check(rpcParams, out var p)) - return p != null; - AntiCheat.Core.AntiCheat.LogInfo(p, $"PlayerControllerB.DropAllHeldItemsServerRpc"); - return true; - } - - /// - /// 玩家发送SteamID事件(目前还没遇到过伪造) - /// Prefix PlayerControllerB.SendNewPlayerValuesServerRpc - /// - [HarmonyPatch("__rpc_handler_2504133785")] - [HarmonyPrefix] - public static bool SendNewPlayerValuesServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (!StartOfRound.Instance.localPlayerController.IsHost)//非主机 - { - return true; - } - if (rpcParams.Server.Receive.SenderClientId == 0) - { - return true; - } - ByteUnpacker.ReadValueBitPacked(reader, out ulong newPlayerSteamId); - reader.Seek(0); - ulong steamId = Patches.ConnectionIdtoSteamIdMap[Patches.ClientIdToTransportId(rpcParams.Server.Receive.SenderClientId)]; - Friend friend = new Friend(steamId); - if (newPlayerSteamId != steamId) - { - NetworkManager.Singleton.DisconnectClient(rpcParams.Server.Receive.SenderClientId); - AntiCheat.Core.AntiCheat.LogInfo($"玩家 {friend.Name}({steamId}) 伪造SteamID({newPlayerSteamId})加入游戏"); - return false; - } - else - { - string msg = Core.AntiCheat.PlayerJoin.Value.Replace("{player}", friend.Name); - Patches.AddTextMessageClientRpc(msg); - } - return true; - } - } -} diff --git a/AntiCheat/Patch/TerminalAccessibleObjectPatch.cs b/AntiCheat/Patch/TerminalAccessibleObjectPatch.cs deleted file mode 100644 index 7f60b33..0000000 --- a/AntiCheat/Patch/TerminalAccessibleObjectPatch.cs +++ /dev/null @@ -1,32 +0,0 @@ -using HarmonyLib; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using Unity.Netcode; - -namespace AntiCheat.Patch -{ - [HarmonyPatch(typeof(TerminalAccessibleObject))] - [HarmonyWrapSafe] - public static class TerminalAccessibleObjectPatch - { - [HarmonyPatch("__rpc_handler_1181174413")] - [HarmonyPrefix] - public static bool Prefix(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) - { - if (Patches.Check(rpcParams, out var p)) - { - AntiCheat.Core.AntiCheat.LogInfo(p, "TerminalAccessibleObject.SetDoorOpenServerRpc"); - } - else if (p == null) - { - return false; - } - return true; - } - } -} diff --git a/AntiCheat/Patches/LandminePatch.cs b/AntiCheat/Patches/LandminePatch.cs new file mode 100644 index 0000000..901a935 --- /dev/null +++ b/AntiCheat/Patches/LandminePatch.cs @@ -0,0 +1,117 @@ +using AntiCheat; + +using HarmonyLib; + +using System; +using System.Collections.Generic; + +using Unity.Netcode; + +using UnityEngine; + +[HarmonyPatch(typeof(Landmine))] +[HarmonyWrapSafe] +public static class LandminePatch +{ + private static readonly HashSet _landMines = new HashSet(); + private static readonly List _explosions = new List(); + private static readonly object _explosionsLock = new object(); + + private static readonly AccessTools.FieldRef _mineActivatedField = + AccessTools.FieldRefAccess("mineActivated"); + + private const int EXPLOSION_EXPIRE_SECONDS = 10; + private const float MINE_TRIGGER_DISTANCE = 5f; + + [HarmonyPrefix] + [HarmonyPatch("SpawnExplosion")] + public static void SpawnExplosion(Vector3 explosionPosition) + { + AntiCheatPlugin.LogInfo($"Landmine.SpawnExplosion -> {explosionPosition}"); + + lock (_explosionsLock) + { + _explosions.RemoveAll(x => x.CreateDateTime.AddSeconds(EXPLOSION_EXPIRE_SECONDS) < DateTime.UtcNow); + + _explosions.Add(new ExplosionData(explosionPosition)); + } + } + + [HarmonyPrefix] + [HarmonyPatch("OnTriggerExit")] + public static bool TriggerMineOnLocalClientByExiting(Landmine __instance, Collider other) + { + if (!StartOfRound.Instance.IsHost || + __instance.hasExploded || + !__instance.gameObject.activeSelf) + { + return true; + } + + if (!_mineActivatedField(__instance)) + { + return true; + } + + lock (_landMines) + { + _landMines.Add(__instance.GetInstanceID()); + } + + return true; + } + + [HarmonyPatch("__rpc_handler_3032666565")] + [HarmonyPrefix] + [HarmonyWrapSafe] + public static bool __rpc_handler_3032666565(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) + { + if (!PluginConfig.Landmine.Enable || !Check(rpcParams, out var p) || p == null) + { + return p != null; // 如果 p 为 null 返回 false + } + + var lm = (Landmine)target; + int id = lm.GetInstanceID(); + + lock (_landMines) + { + if (_landMines.Contains(id) || lm.hasExploded) + { + return true; + } + } + + // 使用距离平方比较,避免开方 + const float triggerDistanceSq = MINE_TRIGGER_DISTANCE * MINE_TRIGGER_DISTANCE; + + if (recentPlayerPositions.TryGetValue(p.playerSteamId, out var positions) && + !positions.Any(x => (x.pos - lm.transform.position).sqrMagnitude < triggerDistanceSq)) + { + AntiCheatPlugin.ShowMessage(locale.Msg_GetString("Landmine", new Dictionary + { + ["{player}"] = p.playerUsername + })); + + if (PluginConfig.Landmine.Kick) + { + KickPlayer(p); + } + } + + return true; + } +} + +public class ExplosionData +{ + public List CalledClient { get; } = new List(); + public Vector3 ExplosionPostion { get; set; } + public DateTime CreateDateTime { get; set; } + + public ExplosionData(Vector3 position) + { + ExplosionPostion = position; + CreateDateTime = DateTime.UtcNow; + } +} \ No newline at end of file diff --git a/AntiCheat/Patch/RoundManagerPatch.cs b/AntiCheat/Patches/RoundManagerPatch.cs similarity index 78% rename from AntiCheat/Patch/RoundManagerPatch.cs rename to AntiCheat/Patches/RoundManagerPatch.cs index 9d82f71..fc0a655 100644 --- a/AntiCheat/Patch/RoundManagerPatch.cs +++ b/AntiCheat/Patches/RoundManagerPatch.cs @@ -2,13 +2,11 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; -using System.Threading.Tasks; using Unity.Netcode; -namespace AntiCheat.Patch +namespace AntiCheat.Patches { [HarmonyPatch(typeof(RoundManager))] [HarmonyWrapSafe] @@ -24,7 +22,7 @@ public static bool FinishedGeneratingLevelServerRpc(NetworkBehaviour target, Fas { int playersFinishedGeneratingFloorCount = (RoundManager.Instance.playersFinishedGeneratingFloor.Count + 1); - AntiCheat.Core.AntiCheat.LogInfo(p, $"RoundManager.FinishedGeneratingLevelServerRpc", $"playersFinishedGeneratingFloor:{playersFinishedGeneratingFloorCount}", $"connectedPlayers:{GameNetworkManager.Instance.connectedPlayers}"); + AntiCheatPlugin.LogInfo(p, $"RoundManager.FinishedGeneratingLevelServerRpc", $"playersFinishedGeneratingFloor:{playersFinishedGeneratingFloorCount}", $"connectedPlayers:{GameNetworkManager.Instance.connectedPlayers}"); CallFinishedGeneratingLevelServerRpc.Add(p.playerSteamId); if (playersFinishedGeneratingFloorCount < GameNetworkManager.Instance.connectedPlayers && playersFinishedGeneratingFloorCount + 5 > GameNetworkManager.Instance.connectedPlayers) { @@ -42,12 +40,12 @@ public static bool FinishedGeneratingLevelServerRpc(NetworkBehaviour target, Fas } if (!string.IsNullOrWhiteSpace(sb.ToString())) { - AntiCheat.Core.AntiCheat.LogInfo($"FinishedGeneratingLevelServerRpc Wait For:{sb.ToString()}"); + AntiCheatPlugin.LogInfo($"FinishedGeneratingLevelServerRpc Wait For:{sb.ToString()}"); } } if (playersFinishedGeneratingFloorCount == GameNetworkManager.Instance.connectedPlayers) { - AntiCheat.Core.AntiCheat.LogInfo($"FinishedGeneratingLevelServerRpc All Players Loaded"); + AntiCheatPlugin.LogInfo($"FinishedGeneratingLevelServerRpc All Players Loaded"); CallFinishedGeneratingLevelServerRpc = new List(); } } diff --git a/AntiCheat/Patch/ShipTeleporterPatch.cs b/AntiCheat/Patches/ShipTeleporterPatch.cs similarity index 73% rename from AntiCheat/Patch/ShipTeleporterPatch.cs rename to AntiCheat/Patches/ShipTeleporterPatch.cs index 881379f..6ac435b 100644 --- a/AntiCheat/Patch/ShipTeleporterPatch.cs +++ b/AntiCheat/Patches/ShipTeleporterPatch.cs @@ -2,13 +2,11 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; -using System.Threading.Tasks; using Unity.Netcode; -namespace AntiCheat.Patch +namespace AntiCheat.Patches { [HarmonyPatch(typeof(ShipTeleporter))] [HarmonyWrapSafe] @@ -21,18 +19,18 @@ public static class ShipTeleporterPatch [HarmonyPatch("__rpc_handler_389447712")] public static bool PressTeleportButtonServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { - if (Patches.Check(rpcParams, out var p)) + if (AntiCheatPlugin.Check(rpcParams, out var p)) { var shiptp = (ShipTeleporter)target; - Core.AntiCheat.LogInfo(p, "ShipTeleporter.PressTeleportButtonServerRpc", $"isInverseTeleporter:{shiptp.isInverseTeleporter}"); - if (shiptp.isInverseTeleporter && !(bool)AccessTools.DeclaredMethod(typeof(ShipTeleporter), "CanUseInverseTeleporter").Invoke(shiptp,null)) + AntiCheatPlugin.LogInfo(p, "ShipTeleporter.PressTeleportButtonServerRpc", $"isInverseTeleporter:{shiptp.isInverseTeleporter}"); + if (shiptp.isInverseTeleporter && !(bool)AccessTools.DeclaredMethod(typeof(ShipTeleporter), "CanUseInverseTeleporter").Invoke(shiptp, null)) { return false; } var cooldownTime = (float)AccessTools.DeclaredField(typeof(ShipTeleporter), "cooldownTime").GetValue(shiptp); if (cooldownTime > 0) { - Core.AntiCheat.LogInfo(p, "ShipTeleporter.PressTeleportButtonServerRpc", $"cooldownAmount:{cooldownTime}"); + AntiCheatPlugin.LogInfo(p, "ShipTeleporter.PressTeleportButtonServerRpc", $"cooldownAmount:{cooldownTime}"); return false; } return true; diff --git a/AntiCheat/Patch/StartOfRoundPatch.cs b/AntiCheat/Patches/StartOfRoundPatch.cs similarity index 76% rename from AntiCheat/Patch/StartOfRoundPatch.cs rename to AntiCheat/Patches/StartOfRoundPatch.cs index 01bfdd7..b8a1f95 100644 --- a/AntiCheat/Patch/StartOfRoundPatch.cs +++ b/AntiCheat/Patches/StartOfRoundPatch.cs @@ -1,19 +1,13 @@ -using AntiCheat.Core; - -using HarmonyLib; +using HarmonyLib; using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; -using System.Threading.Tasks; using Unity.Netcode; -using UnityEngine; - -namespace AntiCheat +namespace AntiCheat.Patches { [HarmonyPatch(typeof(StartOfRound))] [HarmonyWrapSafe] @@ -30,13 +24,13 @@ public static class StartOfRoundPatch public static bool SyncAlreadyHeldObjectsServerRpc(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { var steamId = Patches.ConnectionIdtoSteamIdMap[Patches.ClientIdToTransportId(rpcParams.Server.Receive.SenderClientId)]; - AntiCheat.Core.AntiCheat.LogInfo($"StartOfRound.SyncShipUnlockablesServerRpc:{steamId}|32"); + AntiCheatPlugin.LogInfo($"StartOfRound.SyncShipUnlockablesServerRpc:{steamId}|32"); if (SyncAlreadyHeldObjectsServerRpcCalls.Contains(steamId)) { - AntiCheat.Core.AntiCheat.LogInfo($"StartOfRound.SyncShipUnlockablesServerRpc:{steamId}|36"); + AntiCheatPlugin.LogInfo($"StartOfRound.SyncShipUnlockablesServerRpc:{steamId}|36"); return false; } - AntiCheat.Core.AntiCheat.LogInfo($"StartOfRound.SyncShipUnlockablesServerRpc:{steamId}|39"); + AntiCheatPlugin.LogInfo($"StartOfRound.SyncShipUnlockablesServerRpc:{steamId}|39"); SyncAlreadyHeldObjectsServerRpcCalls.Add(steamId); return true; } @@ -52,7 +46,7 @@ public static bool PlayerHasRevivedServerRpc(NetworkBehaviour target, FastBuffer if (Patches.Check(rpcParams, out var p)) { int playersRevived = (int)AccessTools.DeclaredField(typeof(StartOfRound), "playersRevived").GetValue(StartOfRound.Instance); - AntiCheat.Core.AntiCheat.LogInfo(p, $"StartOfRound.PlayerHasRevivedServerRpc", $"playersRevived:{(playersRevived + 1)}", $"connectedPlayers:{GameNetworkManager.Instance.connectedPlayers}"); + AntiCheatPlugin.LogInfo(p, $"StartOfRound.PlayerHasRevivedServerRpc", $"playersRevived:{(playersRevived + 1)}", $"connectedPlayers:{GameNetworkManager.Instance.connectedPlayers}"); CallPlayerHasRevivedServerRpc.Add(p.playerSteamId); if (playersRevived < GameNetworkManager.Instance.connectedPlayers && playersRevived + 5 > GameNetworkManager.Instance.connectedPlayers) { @@ -70,13 +64,13 @@ public static bool PlayerHasRevivedServerRpc(NetworkBehaviour target, FastBuffer } if (!string.IsNullOrWhiteSpace(sb.ToString())) { - AntiCheat.Core.AntiCheat.LogInfo($"PlayerHasRevivedServerRpc Wait For:{sb.ToString()}"); + AntiCheatPlugin.LogInfo($"PlayerHasRevivedServerRpc Wait For:{sb.ToString()}"); } - + } if ((playersRevived + 1) == GameNetworkManager.Instance.connectedPlayers) { - AntiCheat.Core.AntiCheat.LogInfo($"PlayerHasRevivedServerRpc All Players Loaded"); + AntiCheatPlugin.LogInfo($"PlayerHasRevivedServerRpc All Players Loaded"); CallPlayerHasRevivedServerRpc = new List(); } } @@ -101,7 +95,7 @@ public static bool PlayerLoadedServerRpc(NetworkBehaviour target, FastBufferRead if (Patches.Check(rpcParams, out var p)) { int fullyLoadedPlayers = StartOfRound.Instance.fullyLoadedPlayers.Count; - AntiCheat.Core.AntiCheat.LogInfo(p, $"StartOfRound.PlayerLoadedServerRpc", $"fullyLoadedPlayers:{(fullyLoadedPlayers + 1)}", $"connectedPlayers:{GameNetworkManager.Instance.connectedPlayers}"); + AntiCheatPlugin.LogInfo(p, $"StartOfRound.PlayerLoadedServerRpc", $"fullyLoadedPlayers:{(fullyLoadedPlayers + 1)}", $"connectedPlayers:{GameNetworkManager.Instance.connectedPlayers}"); CallPlayerLoadedServerRpc.Add(p.playerSteamId); if (fullyLoadedPlayers < GameNetworkManager.Instance.connectedPlayers && fullyLoadedPlayers + 5 > GameNetworkManager.Instance.connectedPlayers) { @@ -119,13 +113,13 @@ public static bool PlayerLoadedServerRpc(NetworkBehaviour target, FastBufferRead } if (!string.IsNullOrWhiteSpace(sb.ToString())) { - AntiCheat.Core.AntiCheat.LogInfo($"PlayerLoadedServerRpc Wait For:{sb.ToString()}"); + AntiCheatPlugin.LogInfo($"PlayerLoadedServerRpc Wait For:{sb.ToString()}"); } } if ((fullyLoadedPlayers + 1) == GameNetworkManager.Instance.connectedPlayers) { CallPlayerLoadedServerRpc = new List(); - AntiCheat.Core.AntiCheat.LogInfo($"PlayerLoadedServerRpc All Players Loaded"); + AntiCheatPlugin.LogInfo($"PlayerLoadedServerRpc All Players Loaded"); } } return true; @@ -140,13 +134,13 @@ public static bool __rpc_handler_744998938(NetworkBehaviour target, FastBufferRe { if (Patches.Check(rpcParams, out var p)) { - AntiCheat.Core.AntiCheat.LogInfo(p, $"StartOfRound.SyncShipUnlockablesServerRpc", "140"); + AntiCheatPlugin.LogInfo(p, $"StartOfRound.SyncShipUnlockablesServerRpc", "140"); if (SyncShipUnlockablesServerRpcCalls.Contains(p.playerSteamId)) { - AntiCheat.Core.AntiCheat.LogInfo(p, $"StartOfRound.SyncShipUnlockablesServerRpc", "144"); + AntiCheatPlugin.LogInfo(p, $"StartOfRound.SyncShipUnlockablesServerRpc", "144"); return false; } - AntiCheat.Core.AntiCheat.LogInfo(p, $"StartOfRound.SyncShipUnlockablesServerRpc", "146"); + AntiCheatPlugin.LogInfo(p, $"StartOfRound.SyncShipUnlockablesServerRpc", "146"); SyncShipUnlockablesServerRpcCalls.Add(p.playerSteamId); return true; } diff --git a/AntiCheat/Patch/TerminalPatch.cs b/AntiCheat/Patches/TerminalPatch.cs similarity index 87% rename from AntiCheat/Patch/TerminalPatch.cs rename to AntiCheat/Patches/TerminalPatch.cs index 3d5998d..4cb160d 100644 --- a/AntiCheat/Patch/TerminalPatch.cs +++ b/AntiCheat/Patches/TerminalPatch.cs @@ -1,18 +1,13 @@ -using AntiCheat.Locale; - -using HarmonyLib; +using HarmonyLib; using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Threading.Tasks; using Unity.Netcode; -using static Unity.IO.LowLevel.Unsafe.AsyncReadManagerMetrics; - -namespace AntiCheat.Patch +namespace AntiCheat.Patches { [HarmonyPatch(typeof(Terminal))] [HarmonyWrapSafe] @@ -29,7 +24,7 @@ public static bool BuyItemsServerRpc(NetworkBehaviour target, FastBufferReader r { if (Patches.Check(rpcParams, out var p)) { - if (Core.AntiCheat.RemoteTerminal.Value) + if (PluginConfig.RemoteTerminal.Value) { if (!Patches.CheckRemoteTerminal(p, "Terminal.BuyItemsServerRpc")) { @@ -44,7 +39,7 @@ public static bool BuyItemsServerRpc(NetworkBehaviour target, FastBufferReader r } ByteUnpacker.ReadValueBitPacked(reader, out int newGroupCredits); reader.Seek(0); - if (Core.AntiCheat.FreeBuy.Value) + if (PluginConfig.FreeBuy.Value) { //LogInfo("__rpc_handler_4003509079|boughtItems:" + string.Join(",", boughtItems) + "|newGroupCredits:" + newGroupCredits + "|Money:" + Money); if (Patches.Money == newGroupCredits || Patches.Money == 0) @@ -54,7 +49,7 @@ public static bool BuyItemsServerRpc(NetworkBehaviour target, FastBufferReader r { "{player}",p.playerUsername }, { "{items}", string.Join(",", boughtItems.GroupBy(x => terminal.buyableItemsList[x].itemName).Select(g => g.Count() == 1 ? g.Key : $"{g.Key}*{g.Count()}")) } })); - if (Core.AntiCheat.FreeBuy2.Value) + if (PluginConfig.FreeBuy_Kick.Value) { Patches.KickPlayer(p); } @@ -66,14 +61,14 @@ public static bool BuyItemsServerRpc(NetworkBehaviour target, FastBufferReader r { "{player}",p.playerUsername }, { "{Money}",(newGroupCredits - Patches.Money).ToString() } })); - if (Core.AntiCheat.FreeBuy2.Value) + if (PluginConfig.FreeBuy_Kick.Value) { Patches.KickPlayer(p); } return false; } } - if (Core.AntiCheat.OperationLog.Value) + if (PluginConfig.OperationLog.Value) { var terminal = (Terminal)target; if (boughtItems.Count(x => x < terminal.buyableItemsList.Length) == boughtItems.Count()) @@ -98,7 +93,7 @@ public static bool BuyVehicleServerRpc(NetworkBehaviour target, FastBufferReader { if (Patches.Check(rpcParams, out var p) || true) { - if (Core.AntiCheat.RemoteTerminal.Value) + if (PluginConfig.RemoteTerminal.Value) { if (!Patches.CheckRemoteTerminal(p, "Terminal.BuyVehicleServerRpc")) { @@ -109,9 +104,9 @@ public static bool BuyVehicleServerRpc(NetworkBehaviour target, FastBufferReader ByteUnpacker.ReadValueBitPacked(reader, out int newGroupCredits); reader.ReadValueSafe(out bool useWarranty, default); reader.Seek(0); - if (Core.AntiCheat.FreeBuy.Value) + if (PluginConfig.FreeBuy.Value) { - if(useWarranty && (bool)AccessTools.DeclaredField(typeof(Terminal), "hasWarrantyTicket").GetValue(target)) + if (useWarranty && (bool)AccessTools.DeclaredField(typeof(Terminal), "hasWarrantyTicket").GetValue(target)) { //可以免费购买 } @@ -121,7 +116,7 @@ public static bool BuyVehicleServerRpc(NetworkBehaviour target, FastBufferReader { "{player}",p.playerUsername }, { "{items}", Patches.locale.Item_GetString("Cruiser") } })); - if (Core.AntiCheat.FreeBuy2.Value) + if (PluginConfig.FreeBuy_Kick.Value) { Patches.KickPlayer(p); } @@ -133,14 +128,14 @@ public static bool BuyVehicleServerRpc(NetworkBehaviour target, FastBufferReader { "{player}",p.playerUsername }, { "{Money}",(newGroupCredits - Patches.Money).ToString() } })); - if (Core.AntiCheat.FreeBuy2.Value) + if (PluginConfig.FreeBuy_Kick.Value) { Patches.KickPlayer(p); } return false; } } - if (Core.AntiCheat.OperationLog.Value) + if (PluginConfig.OperationLog.Value) { var terminal = (Terminal)target; Patches.ShowMessageHostOnly(Patches.locale.OperationLog_GetString("BuyItem", new Dictionary() { diff --git a/AntiCheat/Patch/TurretPatch.cs b/AntiCheat/Patches/TurretPatch.cs similarity index 85% rename from AntiCheat/Patch/TurretPatch.cs rename to AntiCheat/Patches/TurretPatch.cs index b6326b4..355c218 100644 --- a/AntiCheat/Patch/TurretPatch.cs +++ b/AntiCheat/Patches/TurretPatch.cs @@ -1,20 +1,14 @@ -using AntiCheat.Core; -using AntiCheat.Locale; - -using HarmonyLib; +using HarmonyLib; using System; using System.Collections.Generic; -using System.Linq; -using System.Security.Policy; using System.Text; -using System.Threading.Tasks; using Unity.Netcode; using UnityEngine; -namespace AntiCheat.Patch +namespace AntiCheat.Patches { [HarmonyPatch(typeof(Turret))] [HarmonyWrapSafe] @@ -32,7 +26,7 @@ public static bool EnterBerserkModeServerRpc(NetworkBehaviour target, FastBuffer { if (Patches.Check(rpcParams, out var p)) { - if (Core.AntiCheat.Turret.Value) + if (PluginConfig.Turret.Enable) { var obj = p.ItemSlots[p.currentItemSlot]; if (obj != null && (Patches.isShovel(obj) || Patches.isKnife(obj))) @@ -45,7 +39,7 @@ public static bool EnterBerserkModeServerRpc(NetworkBehaviour target, FastBuffer { "{player}",p.playerUsername }, { "{Distance}",v.ToString() } })); - if (Core.AntiCheat.Turret2.Value) + if (PluginConfig.Turret.Kick) { Patches.KickPlayer(p); } @@ -57,7 +51,7 @@ public static bool EnterBerserkModeServerRpc(NetworkBehaviour target, FastBuffer Patches.ShowMessage(Patches.locale.Msg_GetString("Turret2", new Dictionary() { { "{player}",p.playerUsername } })); - if (Core.AntiCheat.Turret2.Value) + if (PluginConfig.Turret.Kick) { Patches.KickPlayer(p); } @@ -79,7 +73,7 @@ public static bool ToggleTurretServerRpc(NetworkBehaviour target, FastBufferRead { if (Patches.Check(rpcParams, out var p)) { - if (AntiCheat.Core.AntiCheat.RemoteTerminal.Value) + if (PluginConfig.RemoteTerminal.Enable) { bool remote = Patches.CheckRemoteTerminal(p, "Turret.ToggleTurretServerRpc"); if (!remote) @@ -87,8 +81,8 @@ public static bool ToggleTurretServerRpc(NetworkBehaviour target, FastBufferRead return false; } } - } - else if (p == null) + } + else if (p == null) { return false; } diff --git a/AntiCheat/PluginConfig.cs b/AntiCheat/PluginConfig.cs new file mode 100644 index 0000000..0c792e3 --- /dev/null +++ b/AntiCheat/PluginConfig.cs @@ -0,0 +1,284 @@ +using AntiCheat.Utils; + +using BepInEx; +using BepInEx.Configuration; + +using System; +using System.Collections.Generic; +using System.Text; + +using static UnityEngine.InputSystem.InputRemoting; + +namespace AntiCheat +{ + internal class PluginConfig + { + public static FeatureConfig Jetpack = null!; + public static FeatureConfig ShipBuild = null!; + public static FeatureConfig Landmine = null!; + public static FeatureConfig InfiniteAmmo = null!; + public static FeatureConfig Mask = null!; + public static FeatureConfig Gift = null!; + public static FeatureConfig Turret = null!; + public static FeatureConfig Invisibility = null!; + public static FeatureConfig KillEnemy = null!; + public static FeatureConfig SpawnWebTrap = null!; + public static FeatureConfig Map = null!; + public static FeatureConfig FreeBuy = null!; + public static FeatureConfig RemoteTerminal = null!; + public static FeatureConfig Nameless = null!; + public static FeatureConfig DespawnItem = null!; + public static FeatureConfig ChatReal = null!; + public static FeatureConfig ShipLight = null!; + public static FeatureConfig TerminalNoise = null!; + public static FeatureConfig ItemCooldown = null!; + public static FeatureConfig Health = null!; + public static FeatureConfig RPCReport = null!; + public static FeatureConfig Boss = null!; + public static FeatureConfig Shovel = null!; + public static FeatureConfig GrabObject = null!; + + public static ConfigEntry Prefix = null!; + public static ConfigEntry PlayerJoin = null!; + public static ConfigEntry Log = null!; + public static ConfigEntry OperationLog = null!; + public static ConfigEntry ShipSetting_OnlyOneVote = null!; + public static ConfigEntry ShipSetting_ChangToFreeMoon = null!; + public static ConfigEntry ShipLight_Cooldown = null!; + public static ConfigEntry TerminalNoise_Cooldown = null!; + public static ConfigEntry ChatReal_Cooldown = null!; + public static ConfigEntry DetectedMessageType = null!; + public enum MessageType + { + GUI, + HostChat, + PublicChat + } + + + + //public static ConfigEntry Shovel = null!; + //public static ConfigEntry Shovel_Kick = null!; + //public static ConfigEntry Shovel3 = null!; + + + + //public static ConfigEntry ShipConfig = null!; + //public static ConfigEntry ShipConfig2 = null!; + //public static ConfigEntry ShipConfig3 = null!; + //public static ConfigEntry ShipConfig4 = null!; + //public static ConfigEntry Ship_Kick = null!; + + //public static ConfigEntry ShipBuild = null!; + //public static ConfigEntry ShipBuild_Kick = null!; + + //public static ConfigEntry ShipLight = null!; + + //public static ConfigEntry TerminalNoise = null!; + + //public static ConfigEntry DespawnItem = null!; + //public static ConfigEntry DespawnItem_Kick = null!; + + //public static ConfigEntry ChatReal = null!; + //public static ConfigEntry ChatReal_Kick = null!; + + //public static ConfigEntry Mask = null!; + //public static ConfigEntry Mask_Kick = null!; + + //public static ConfigEntry Gift = null!; + //public static ConfigEntry Gift_Kick = null!; + + //public static ConfigEntry Invisibility = null!; + //public static ConfigEntry Invisibility_Kick = null!; + + //public static ConfigEntry GrabObject = null!; + //public static ConfigEntry GrabObject_MoreSlot = null!; + //public static ConfigEntry GrabObject_TwoHand = null!; + //public static ConfigEntry GrabObject_BeltBag = null!; + //public static ConfigEntry GrabObject_Kick = null!; + + //public static ConfigEntry Boss = null!; + //public static ConfigEntry Boss2 = null!; + + //public static ConfigEntry Landmine = null!; + //public static ConfigEntry Landmine_Kick = null!; + + //public static ConfigEntry PlayerCarryWeight = null!; + //public static ConfigEntry PlayerCarryWeight2 = null!; + //public static ConfigEntry PlayerCarryWeight3 = null!; + + + //public static ConfigEntry Turret = null!; + //public static ConfigEntry Turret_Kick = null!; + + //public static ConfigEntry Enemy = null!; + + //public static ConfigEntry KillEnemy = null!; + //public static ConfigEntry KillEnemy_Kick = null!; + + //public static ConfigEntry SpawnWebTrap = null!; + //public static ConfigEntry SpawnWebTrap_Kick = null!; + + //public static ConfigEntry Map = null!; + //public static ConfigEntry Map_Kick = null!; + + //public static ConfigEntry Jetpack = null!; + //public static ConfigEntry Jetpack_Kick = null!; + + //public static ConfigEntry ItemCooldown = null!; + //public static ConfigEntry ItemCooldown_Kick = null!; + + //public static ConfigEntry InfiniteAmmo = null!; + //public static ConfigEntry InfiniteAmmo_Kick = null!; + + //public static ConfigEntry FreeBuy = null!; + //public static ConfigEntry FreeBuy_Kick = null!; + + //public static ConfigEntry RemoteTerminal = null!; + //public static ConfigEntry RemoteTerminal_Kick = null!; + + //public static ConfigEntry Nameless = null!; + //public static ConfigEntry Nameless_Kick = null!; + + //public static ConfigEntry RPCReport_Delay = null!; + //public static ConfigEntry RPCReport_Hit = null!; + //public static ConfigEntry RPCReport_KillPlayer = null!; + //public static ConfigEntry RPCReport_Kick = null!; + + //public static ConfigEntry Health_Recover = null!; + //public static ConfigEntry Health_Kick = null!; + + + + internal static void Init(BaseUnityPlugin plugin) + { + var config = plugin.Config; + + + Prefix = config.Bind("ServerNameSetting", + "Prefix", + "AC", + localizationManager.Cfg_GetString("Prefix")); + + Log = config.Bind("LogSetting", + "Log", + true, + localizationManager.Cfg_GetString("Log")); + + OperationLog = config.Bind("LogSetting", + "OperationLog", + true, + localizationManager.Cfg_GetString("OperationLog")); + + + ShipConfig = config.Bind("ShipSetting", + "StartGameOnlyHost", + true, + localizationManager.Cfg_GetString("ShipSetting")); + + Ship_Kick = config.Bind("ShipSetting", + "Kick", + false, + localizationManager.Cfg_GetString("ShipConfig5")); + + ShipConfig2 = config.Bind("ShipSetting", + "StartGamePlayerCount", + 8, + localizationManager.Cfg_GetString("ShipConfig2")); + + ShipConfig3 = config.Bind("ShipSetting", + "EndGamePlayerTime", + "14:00", + localizationManager.Cfg_GetString("ShipConfig3")); + + ShipConfig4 = config.Bind("ShipSetting", + "EndGamePlayerCount", + 50, + localizationManager.Cfg_GetString("ShipConfig4")); + + ShipSetting_OnlyOneVote = config.Bind("ShipSetting", + "OnlyOneVote", + true, + localizationManager.Cfg_GetString("ShipConfig6")); + + ShipSetting_ChangToFreeMoon = config.Bind("ShipSetting", + "ChangToFreeMoon", + false, + localizationManager.Cfg_GetString("ChangToFreeMoon")); + + // ===== FeatureConfig 功能类 ===== + + ShipBuild = new FeatureConfig(config, "ShipBuildSetting", localizationManager.Cfg_GetString("ShipBuild")); + ItemCooldown = new FeatureConfig(config, "ItemCooldownSetting", localizationManager.Cfg_GetString("ItemCooldown")); + ShipLight = new FeatureConfig(config, "ShipLightSettings", localizationManager.Cfg_GetString("ShipLight")); + TerminalNoise = new FeatureConfig(config, "TerminalNoiseSettings", localizationManager.Cfg_GetString("ShipTerminal")); + DespawnItem = new FeatureConfig(config, "DespawnItemSettings", localizationManager.Cfg_GetString("DespawnItem")); + ChatReal = new FeatureConfig(config, "ChatRealSettings", localizationManager.Cfg_GetString("ChatReal")); + Mask = new FeatureConfig(config, "MaskSettings", localizationManager.Cfg_GetString("Mask")); + Gift = new FeatureConfig(config, "GiftSettings", localizationManager.Cfg_GetString("Gift")); + Turret = new FeatureConfig(config, "TurretSettings", localizationManager.Cfg_GetString("Turret")); + InfiniteAmmo = new FeatureConfig(config, "InfiniteAmmoSettings", localizationManager.Cfg_GetString("InfiniteAmmo")); + Invisibility = new FeatureConfig(config, "InvisibilitySettings", localizationManager.Cfg_GetString("Invisibility")); + Boss = new FeatureConfig(config, "BossSetting", localizationManager.Cfg_GetString("Boss")); + Jetpack = new FeatureConfig(config, "JetpackSetting", localizationManager.Cfg_GetString("Jetpack")); + Landmine = new FeatureConfig(config, "LandmineSetting", localizationManager.Cfg_GetString("Landmine")); + SpawnWebTrap = new FeatureConfig(config, "SpawnWebTrapSetting", localizationManager.Cfg_GetString("SpawnWebTrap")); + KillEnemy = new FeatureConfig(config, "KillEnemySetting", localizationManager.Cfg_GetString("KillEnemy")); + Map = new FeatureConfig(config, "MapSetting", localizationManager.Cfg_GetString("Map")); + FreeBuy = new FeatureConfig(config, "FreeBuySettings", localizationManager.Cfg_GetString("FreeBuy")); + RemoteTerminal = new FeatureConfig(config, "RemoteTerminalSettings", localizationManager.Cfg_GetString("RemoteTerminal")); + Nameless = new FeatureConfig(config, "NamelessSettings", localizationManager.Cfg_GetString("Nameless")); + Health = new FeatureConfig(config, "HealthSetting", localizationManager.Cfg_GetString("Health_Recover")); + RPCReport = new FeatureConfig(config, "RPCReportSetting", localizationManager.Cfg_GetString("RPCReport_Hit")); + + // ===== 独立参数 ===== + + ShipLight_Cooldown = config.Bind("ShipLightSettings", + "Cooldown", + 2000, + localizationManager.Cfg_GetString("Cooldown")); + + TerminalNoise_Cooldown = config.Bind("TerminalNoiseSettings", + "Cooldown", + 1000, + localizationManager.Cfg_GetString("Cooldown")); + + ChatReal_Cooldown = config.Bind("ChatRealSettings", + "Cooldown", + 100, + localizationManager.Cfg_GetString("Cooldown")); + + RPCReport_Delay = config.Bind("RPCReportSetting", + "Delay", + 1000, + localizationManager.Cfg_GetString("RPCReport_Delay")); + + DetectedMessageType = config.Bind("DetectedMessageType", + "Type", + MessageType.PublicChat, + localizationManager.Cfg_GetString("DetectedMessageType")); + + PlayerJoin = config.Bind("MsgSettings", + "PlayerJoinShip", + localizationManager.Msg_GetString("wlc_player"), + localizationManager.Msg_GetString("wlc_player")); + + CooldownManager.Reset(); + + RegisterCooldown("TerminalNoise", TerminalNoise._Enable, TerminalNoise_Cooldown); + RegisterCooldown("ShipLight", ShipLight._Enable, ShipLight_Cooldown); + RegisterCooldown("Chat", ChatReal._Enable, ChatReal_Cooldown); + + AntiCheatPlugin.LogInfo($"{localizationManager.Log_GetString("load")}"); + } + + private static void RegisterCooldown(string name,ConfigEntry enable,ConfigEntry cooldownMs) + { + CooldownManager.RegisterCooldownGroup( + name, + () => enable.Value, + () => cooldownMs.Value / 1000f + ); + } + } +} diff --git a/AntiCheat/Patch/CooldownManager.cs b/AntiCheat/Utils/CooldownManager.cs similarity index 96% rename from AntiCheat/Patch/CooldownManager.cs rename to AntiCheat/Utils/CooldownManager.cs index 3fafe53..2a282d3 100644 --- a/AntiCheat/Patch/CooldownManager.cs +++ b/AntiCheat/Utils/CooldownManager.cs @@ -3,13 +3,11 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using System.Text; -using System.Threading.Tasks; using UnityEngine; -namespace AntiCheat +namespace AntiCheat.Utils { public static class CooldownManager { diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 2e328c7..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,855 +0,0 @@ -# Beta(公开测试版) - -## Version 0.8.7 - -### 中文(100k下载!) - -* [+] 新增了一些 RPC 调用日志(在AntiCheat.log中查看他们!) -* [/] 修复了客户端使用反作弊也会生成日志内容的问题 -* [/] 客户端修改电量超过100时将会被拦截(目前没有做提醒,如果想检查是否有玩家使用了无限电量请查看日志文件) -* [/] 修复传送器补丁的报错 -* [/] 允许玩家在物品栏中有铲子,但手上是空手的情况下造成伤害了 -* [/] 现在引爆地雷应该不会存在误报了!(如果是FairAI引爆的,不算误报) -* [/] 修复击杀管家与其他模组的兼容性问题 -* [+] 新增韩文本地化 @P-Asta (如果你想固定语言至韩文,请手动设置 `locales\localization_cfg.json` 文件,将 `current_language` 改为 `ko_KR`) - -### English(100k Donwnloads!) - -* [+] Added some RPC call logs (check them in AntiCheat.log!) -* [/] Fixed an issue where the client would generate log content even when using anti-cheat -* [/] Client modifications to battery level exceeding 100 will now be blocked (no notification is currently implemented; check log files to identify players using infinite battery) -* [/] Fixed errors related to the teleporter patch -* [/] Players can now deal damage while having a shovel in their inventory but empty hands -* [/] LandMine detonations should no longer produce false positives! (If detonated by **FairAI**, it is not considered a false positive) -* [/] Fixed the compatibility issue between Kill Butler and other mods -* [+] New Korean localization @P-Asta (If you want to fix the language to Korean, please manually set the `locales\localization_cfg.json` file and change `current_language` to `ko_KR`) - - -## Version 0.8.6 - -### 中文 - -* [/] 修复客机使用礼物盒会卡手的问题 -* [/] 修复遥控器冷却未正确生效 - -### English - -* [/] Fixed an issue where using a gift box in the passenger aircraft would cause hands to get stuck -* [/] Fixed the remote cooldown not taking effect properly - -## Version 0.8.5 - -### 中文(重大更新) - -- [+] 新增 AntiCheat.log 文件,你在游戏根目录可以找到它,反作弊所有的日志都会输出到该文件 -- [+] 零元购新增对卡车的检测 -- [+] 现在投票完成后,可以立即拉杆起飞(无论有没有满足起飞条件) -- [+] 现在允许被抱脸虫报之后,短时间内空手造成伤害 -- [/] 新增部分 RPC 日志,优化大部分日志内容 -- [/] 修复重开房间未重置变量 -- [/] 修复因操作过快导致被检测远程终端 -- [/] 修复爆炸导致伤害异常检测 -- [/] 修复主机看不见客机使用部分物品 -- [-] 移除 Hit RPC 检测 - -### English(Major Update) - -- [+] Added AntiCheat.log file – you can find it in the game's root directory, where all anti-cheat logs will be recorded. -- [+] Zero-dollar purchases now include truck detection. -- [+] After voting is completed, the aircraft can now take off immediately by pulling the lever (regardless of whether the usual conditions are met). -- [+] Players can now deal melee damage briefly after being attacked by a facehugger. -- [/] Added partial RPC logs and optimized most log content. -- [/] Fixed an issue where room variables were not reset when reopening a room. -- [/] Fixed false remote terminal detection caused by excessively fast inputs. -- [/] Fixed abnormal damage detection caused by explosions. -- [/] Fixed an issue where the host couldn't see clients using certain items. -- [-] Removed Hit RPC detection. - -### 한국어(주요 업데이트) - -- [+] AntiCheat.log 파일이 추가되었습니다 – 게임 루트 디렉토리에서 찾을 수 있으며, 모든 안티치트 로그가 해당 파일에 기록됩니다. -- [+] 무료 구매에 트럭 감지 기능이 추가되었습니다. -- [+] 투표 완료 후 이제 레버를 당겨 즉시 이륙할 수 있습니다 (일반적인 조건 충족 여부와 무관). -- [+] 플레이어가 페이스허거에게 공격받은 후 잠시 동안 맨손으로 피해를 입힐 수 있습니다. -- [/] 부분적인 RPC 로그가 추가되고 대부분의 로그 내용이 최적화되었습니다. -- [/] 방을 다시 열 때 변수가 재설정되지 않는 문제가 수정되었습니다. -- [/] 너무 빠른 입력으로 인한 잘못된 원격 터미널 감지가 수정되었습니다. -- [/] 폭발로 인한 비정상적인 피해 감지가 수정되었습니다. -- [/] 호스트가 클라이언트의 특정 아이템 사용을 볼 수 없는 문제가 수정되었습니다. -- [-] Hit RPC 감지가 제거되었습니다. - -## Version 0.8.4 - -### 中文 - -- [+] 加入传送器冷却限制 -- [+] 远程终端现在会检测关闭机枪 -- [/] 现在可以在 v70 正常运行了 -- [/] 由于双手作弊过于泛滥,现在使用喷气背包的时候禁止抓取双手物品(如果你允许同时拥有多个双手物品,那么依旧可以抓取) - -### English - -- [+] Added warp drive cooling restrictions -- [+] Remote terminals now detect turret shutdowns -- [/] Fixed v70 compatibility issues -- [/] Due to widespread two-handed cheating, grabbing two-handed items is now disabled while using a jetpack (if you allow multiple two-handed items, grabbing is still permitted) - -### 한국어 - -- [+] 워프 드라이브 냉각 제한이 추가되었습니다 -- [+] 원격 터미널에서 터렛 종료를 감지합니다 -- [/] v70 호환성 문제가 수정되었습니다 -- [/] 양손 치트가 너무 만연하여, 이제 제트팩 사용 중에는 양손 아이템 잡기가 비활성화됩니다 (여러 양손 아이템을 허용하는 경우에는 여전히 잡기가 가능합니다) - -## Version 0.8.3 - -### 中文 - -- [/] 修复取消换弹会导致触发无限子弹检测 -- [/] 修复部分本地化内容没有正常获取 -- [/] 修复起飞/降落时两次检测提示 - -### English - -- [/] Fixed canceling reload triggering infinite ammo detection -- [/] Fixed some localized content not being fetched correctly -- [/] Fixed duplicate detection prompts during takeoff/landing - -### 한국어 - -- [/] 재장전 취소 시 무한 탄약 감지가 트리거되는 문제가 수정되었습니다 -- [/] 일부 현지화 콘텐츠가 제대로 불러와지지 않는 문제가 수정되었습니다 -- [/] 이륙/착륙 시 중복 감지 알림이 수정되었습니다 - -## Version 0.8.2 - -### 中文 - -- [/] i18방式从资源文件迁移到 json 文件,现在你可以完全自定义反作弊的提示消息 -- [/] 修复客户端在重新加入游戏后,无法看到家具的正确位置 -- [/] 修复在某些地点击杀管家检测到异常伤害的问题 - -### English - -- [/] The i18n method has been migrated from resource files to JSON files, now you can fully customize the anti-cheat warning messages -- [/] Fixed an issue where the client could not see the correct position of furniture after rejoining the game -- [/] Fixed abnormal damage detection when killing the butler in certain locations - -### 한국어 - -- [/] i18n 방식이 리소스 파일에서 JSON 파일로 마이그레이션되었으며, 이제 안티치트 경고 메시지를 완전히 사용자 정의할 수 있습니다 -- [/] 게임에 다시 참가한 후 클라이언트가 가구의 정확한 위치를 볼 수 없는 문제가 수정되었습니다 -- [/] 특정 위치에서 관리인을 죽일 때 비정상적인 피해가 감지되는 문제가 수정되었습니다 - -## Version 0.8.1 - -### 中文 - -- [/] 修复了房主无法从付费星球切换至免费星球的问题 -- [+] 新增配置 `ShipSetting.ChangToFreeMoon`,用于开关 玩家从付费星球切换到免费星球 检测 -- [+] 对于部分 RPC 进行限制,避免用于卡房 - -### English - -- [/] Fixed an issue where host were unable to switch from paid planets to free planets. -- [+] Added a new configuration `ShipSetting.ChangToFreeMoon` to toggle the detection of players switching from paid planets to free planets. -- [+] Implemented restrictions on certain RPCs to prevent their use for room exploits. - -### 한국어 - -- [/] 호스트가 유료 행성에서 무료 행성으로 전환할 수 없는 문제가 수정되었습니다. -- [+] `ShipSetting.ChangToFreeMoon` 설정이 추가되어 플레이어가 유료 행성에서 무료 행성으로 전환하는 것을 감지하는 기능을 토글할 수 있습니다. -- [+] 특정 RPC에 제한을 구현하여 방 익스플로잇에 사용되는 것을 방지합니다. - -## Version 0.8.0 - -### 中文 - -- [+] 新增配置 `VersionSetting.IgnoreClientConfig` ,用于忽略客户端配置有差异(这将缓解客户端出现发生错误的情况) -- [+] 新增配置 `LogSetting.OperationLog` ,显示玩家操作信息(加入房间/购买物品/切换星球) -- [/] 修复了星球零元购的误报 - -### English - -- [+] Added configuration `VersionSetting.IgnoreClientConfig` to ignore discrepancies in client configurations (this will alleviate the occurrence of errors on the client side). -- [+] Added configuration `LogSetting.OperationLog` to display player operation information (such as joining a room, purchasing items, switching planets). -- [/] Fixed false positives for Planet Zero purchase - -### 한국어 - -- [+] `VersionSetting.IgnoreClientConfig` 설정이 추가되어 클라이언트 설정 불일치를 무시합니다 (클라이언트 측에서 오류 발생을 완화합니다). -- [+] `LogSetting.OperationLog` 설정이 추가되어 플레이어 작업 정보를 표시합니다 (방 참가/아이템 구매/행성 전환). -- [/] 행성 무료 구매의 오탐이 수정되었습니다. - -## Version 0.7.9 - -### 中文 - -- [+] 增加了对无限子弹的两种检测 - -### English - -- [+] Added two kinds of detection for unlimited ammo - -### 한국어 - -- [+] 무한 탄약에 대한 두 가지 감지 방법이 추가되었습니다 - -## Version 0.7.8 - -### 中文 - -- [+] 修改配置文件后将会即时生效(不需要重启游戏了) -- [+] 新增 韩文 支持(@P-Asta),配置文件 `LanguageSetting.Language = Korean` 即可启用 - -### English - -- [+] Changes made to the configuration file will take effect immediately (no need to restart the game). -- [+] Added support for Korean (@P-Asta); set `LanguageSetting.Language = Korean` in the configuration file to enable. - -### 한국어 - -- [+] 설정 파일 변경 사항이 즉시 적용됩니다 (게임을 재시작할 필요가 없습니다). -- [+] 한국어 지원이 추가되었습니다 (@P-Asta); 설정 파일에서 `LanguageSetting.Language = Korean`으로 설정하여 활성화할 수 있습니다. - -## Version 0.7.7 - -### 中文 - -- [+] 작비玩家被踢出时将会显示被反作弊踢出的提示 -- [/] 修复了卡车击杀/击伤敌人时的误报 - -### English - -- [+] When a cheating player is kicked out, a message will be displayed saying that he was kicked out by anti-cheat -- [/] Fixed the false positive when the truck kills / injures the enemy - -### 한국어 - -- [+] 치트를 사용하는 플레이어가 킥당할 때 안티치트에 의해 킥되었다는 메시지가 표시됩니다 -- [/] 트럭이 적을 죽이거나 다치게 할 때의 오탐이 수정되었습니다 - -## Version 0.7.6 - -### 中文 - -- [/] GrabObject 配置新增了 MoreSlot TwoHand BeltBag 配置项 -- [+] GrabObject.BeltBag 启用时,可以禁用玩家使用腰包拾取废料 - -### English - -- [/] The GrabObject configuration has been updated with a new option: MoreSlot TwoHand BeltBag configuration. -- [+] When GrabObject.BeltBag is enabled, players can be disabled from picking up scrap using the belt bag. - -### 한국어 - -- [/] GrabObject 설정에 MoreSlot TwoHand BeltBag 설정 옵션이 추가되었습니다. -- [+] GrabObject.BeltBag가 활성화되면 플레이어가 벨트 백을 사용하여 스크랩을 줍는 것을 비활성화할 수 있습니다. - -## Version 0.7.5 - -### 中文 - -- [+] 现在禁止使用双手拿取物品了 -- [/] 修改了销毁物品的检测机制 -- [/] 修复死亡后投票提示问题 -- [/] 房主一票直接起飞 修改为 一个小时后起飞 -- [/] 修复客户端拉杆失败导致无法继续拉杆 - -### English - -- [+] Added chat speed limit `ChatRealSettings.Cooldown`, default 200 milliseconds -- [/] Optimized some log output -- [/] Optimized chat detection -- [+] Monster kills player, added detection for ogres - -### 한국어 - -- [+] 채팅 속도 제한 `ChatRealSettings.Cooldown`이 추가되었습니다 (기본값: 200밀리초) -- [/] 일부 로그 출력이 최적화되었습니다 -- [/] 채팅 감지가 최적화되었습니다 -- [+] 몬스터가 플레이어를 죽일 때 오우거에 대한 감지가 추가되었습니다 - -## Version 0.7.4 - -### 中文 - -- [+] 远程终端检测现在会检测使用信号发射器了 -- [/] 修复了 RPC 上报检测部分问题 -- [/] 修复了家具能被异常旋转 - -### English - -- [+] Remote terminal detection now detects the use of signal transmitters -- [/] Fixed some issues with RPC reporting detection -- [/] Fixed the problem that furniture can be rotated abnormally - -### 한국어 - -- [+] 원격 터미널 감지에서 이제 신호 발신기 사용을 감지합니다 -- [/] RPC 보고 감지의 일부 문제가 수정되었습니다 -- [/] 가구가 비정상적으로 회전될 수 있는 문제가 수정되었습니다 - -## Version 0.7.3 - -### 中文 - -- [+] 现在 隔空取物检测 开启时,会禁止使用喷气背包的玩家拿取双手重物 -- [/] 优化了盒子异常行为检测,应该能减少误报 - -### English - -- [+] Now when Picking Up Items Detection is on, players using jetpacks will be prohibited from picking up two-handed heavy objects -- [/] Optimized the abnormal behavior detection of jester, which should reduce false positives - -### 한국어 - -- [+] 이제 아이템 픽업 감지가 활성화되면 제트팩을 사용하는 플레이어가 양손 무거운 물체를 집는 것이 금지됩니다 -- [/] 제스터의 비정상적인 행동 감지가 최적화되어 오탐이 줄어들 것입니다 - -## Version 0.7.2 - -### 中文 - -- [/] 修复 0.4.6/0.4.7 版本导致의帧率过低问题 - -### English - -- [/] Fix low fps issue caused by version 0.4.6/0.4.7 - -### 한국어 - -- [/] 0.4.6/0.4.7 버전으로 인한 낮은 프레임률 문제가 수정되었습니다 - -## Version 0.7.1 - -### 中文 - -- [+] 新增玩家使用负伤害回血检测(0.7.0 已实装但未加配置) -- [/] 修复了部分检测在客机生效的问题 - -### English - -- [+] Added player health recovery detection when using negative damage (already implemented in 0.7.0 but not configured) -- [/] Fixed the problem that some detections were effective on client - -### 한국어 - -- [+] 음수 피해를 사용한 플레이어 체력 회복 감지가 추가되었습니다 (0.7.0에서 이미 구현되었지만 설정되지 않았음) -- [/] 일부 감지가 클라이언트에서 작동하는 문제가 수정되었습니다 - -## Version 0.7.0 - -### 中文 - -- [+] 新增 RPC 上报检测(用于检测玩家是否开启无敌) -- [/] 飞船物品位置异常检测新增旋转角度检测 - -### English - -- [+] Added RPC reporting detection (used to detect whether the player has turned on invincibility) -- [/] Added rotation angle detection to the abnormal position detection of furniture - -### 한국어 - -- [+] RPC 보고 감지가 추가되었습니다 (플레이어가 무적을 켰는지 감지하는 데 사용) -- [/] 가구의 비정상적인 위치 감지에 회전 각도 감지가 추가되었습니다 - -## Version 0.6.9 - -### 中文 - -- [/] 修复了铲子伤害检测误报的问题 - -### English - -- [/] Fixed a bug that caused shovel damage detection to be false positive - -### 한국어 - -- [/] 삽 피해 감지가 오탐을 일으키는 버그가 수정되었습니다 - -## Version 0.6.8 - -### 中文 - -- [-] 移除 serverTag 的 AC 标识(该标识导致新版本必须要输入标识才能找到房间) - -### English - -- [-] Remove the AC tag from serverTag (this tag requires you to enter the tag to find the lobby in the new version) - -### 한국어 - -- [-] serverTag에서 AC 태그가 제거되었습니다 (이 태그로 인해 새 버전에서 로비를 찾으려면 태그를 입력해야 했습니다) - -## Version 0.6.7 - -### 中文 - -- [+] 适配 v56 版본 -- [-] 移除玩家负重异常检测(zeekeers 在 v56 beta2 修复了该 bug) - -### English - -- [+] Adapt to v56 version -- [-] Removed abnormal player carry weight detection (zeekeers fixed this bug in v56 beta2) - -### 한국어 - -- [+] v56 버전에 적응 -- [-] 비정상적인 플레이어 운반 무게 감지가 제거되었습니다 (zeekeers가 v56 beta2에서 이 버그를 수정했습니다) - -## Version 0.6.6 - -### 中文 - -- [/] 更改强制引爆地雷逻辑 - -### English - -- [/] Change the logic for detecting landmine detonation - -### 한국어 - -- [/] 지뢰 폭발 감지 로직이 변경되었습니다 - -## Version 0.6.5 - -### 中文 - -- [+] 语言配置将会根据电脑区域设置来决定,如果你的区域设置为以下几种 香港特别行政区,澳门特别行政区,中国,中文(简体),新加坡,台湾,中文(繁体) 那么将会使用中文作为默认模组语言,否则将会使用英语作为默认语言 -- [+] 新增配置项 DetectedMessageType ,现在你可以更改配置决定检测的消息如何显示了 - -### English - -- [+] The language configuration will be determined according to the locale of the computer, if your locale is set to the following Hong Kong SAR, Macau SAR, China, Chinese (Simplified), Singapore, Taiwan, Chinese (Traditional) Then Chinese will be used as the default mod language, otherwise English will be used as the default language -- [+] Added DetectedMessageType to the config item, now you can change the configuration to determine how the detected messages are displayed - -### 한국어 - -- [+] 언어 설정은 컴퓨터의 지역 설정에 따라 결정됩니다. 지역 설정이 홍콩 특별행정구, 마카오 특별행정구, 중국, 중국어(간체), 싱가포르, 대만, 중국어(번체) 중 하나로 설정되어 있으면 중국어가 기본 모드 언어로 사용되고, 그렇지 않으면 영어가 기본 언어로 사용됩니다 -- [+] DetectedMessageType 설정 항목이 추가되어 이제 감지된 메시지가 어떻게 표시될지 설정으로 변경할 수 있습니다 - -## Version 0.6.4 - -### 中文 - -- [/] 修复胡桃夹子枪击其他怪物导致检测伤害异常 -- [/] 现在会正确兼容 MoreCompany 模组的化妆品了 -- [/] 修复了对玩家异常伤害的检测 - -### English - -- [/] Fixed Nutcracker shooting other monsters resulting in abnormal damage detection. -- [/] Cosmetics for MoreCompany modules are now correctly compatible. -- [/] Fixed detection of abnormal damage to players - -### 한국어 - -- [/] 호두까기 인형이 다른 몬스터를 사격할 때 비정상적인 피해 감지가 발생하는 문제가 수정되었습니다. -- [/] MoreCompany 모드의 코스메틱이 이제 올바르게 호환됩니다. -- [/] 플레이어에 대한 비정상적인 피해 감지가 수정되었습니다 - -## Version 0.6.3(0.6.2) - -### 中文 - -- [/] 修复 README.MD 跳转链接错误的问题 - -### English - -- [/] Fix README.MD Jump Link Error - -### 한국어 - -- [/] README.MD 이동 링크 오류 문제가 수정되었습니다 - -## Version 0.6.2(V50) - -### 中文 - -- [/] 当前版本仅支持 V50,不向下兼容 -- [+] 新增对小刀的伤害/攻速检测 -- [/] 优化部分日志信息 -- [/] 修复获得加班费之后导致的刷取金钱检测 - -### English - -- [/] Current version only supports V50, not backward compatible -- [+] Added damage/attack speed detection for knife -- [/] Optimized some log messages -- [/] Fixed swipe money detection after getting overtime payment - -### 한국어 - -- [/] 현재 버전은 V50만 지원하며 하위 호환되지 않습니다 -- [+] 칼의 피해/공격 속도 감지가 추가되었습니다 -- [/] 일부 로그 메시지가 최적화되었습니다 -- [/] 야근수당을 받은 후 돈 복사 감지가 수정되었습니다 - -## Version 0.6.1 - -### 中文 - -- [/] 新增配置 EmptyHand 你可以通过启用该项允许玩家空手的时候造成正常伤害 -- [/] 优化和补充缺失的英文翻译 - -### English - -- [/] Added configuration EmptyHand You can enable this item to allow players to deal normal damage when empty-handed. -- [/] Optimized and added missing English translations. - -### 한국어 - -- [/] EmptyHand 설정이 추가되었습니다. 이 항목을 활성화하여 플레이어가 맨손일 때 정상적인 피해를 입힐 수 있도록 허용할 수 있습니다. -- [/] 누락된 영어 번역이 최적화되고 추가되었습니다. - -## Version 0.6.0 - -### 中文 - -- [/] 禁止玩家重复加入游戏 -- [/] 零元购新增付费地图检测 -- [/] 零元购现在会检测将金钱设置为 0 以下了 -- [+] 检测玩家远程使用终端,新增配置项 RemoteTerminalSettings -- [/] 现在反作弊的补丁将会以安全的形式运行 -- [/] 修复拼写错误,之前的版本配置 LanguageSetting 被拼写成了 LangugeSetting ,现已更正,修改过配置的玩家需要重新设置 - -### English - -- [/] Prevent players from repeatedly joining the game. -- [/] Zero-dollar purchase now includes paid map detection. -- [/] Zero-dollar purchase will now detect if money is set below 0. -- [+] Added new configuration item "RemoteTerminalSettings" to detect players remotely using terminals. -- [/] The anti-cheat patch will now run in a safer form. -- [/] Fixed a typo. In previous versions, the configuration item "LanguageSetting" was misspelled as "LangugeSetting". This has now been corrected, and players who have modified this setting will need to reconfigure it. - -### 한국어 - -- [/] 플레이어가 게임에 반복적으로 참가하는 것을 방지합니다. -- [/] 무료 구매에 유료 맵 감지가 포함되었습니다. -- [/] 무료 구매에서 이제 돈이 0 이하로 설정되는 것을 감지합니다. -- [+] 플레이어가 원격으로 터미널을 사용하는 것을 감지하는 새로운 설정 항목 "RemoteTerminalSettings"가 추가되었습니다. -- [/] 안티치트 패치가 이제 안전한 형태로 실행됩니다. -- [/] 맞춤법 오류가 수정되었습니다. 이전 버전에서 "LanguageSetting" 설정 항목이 "LangugeSetting"으로 잘못 철자되었습니다. 이제 수정되었으며, 이 설정을 수정한 플레이어는 다시 설정해야 합니다. - -## Version 0.5.9 - -### 中文 - -- [/] 优化了英文翻译(@CoolLKKPS) - -### English - -- [/] Optimized the English translation(@CoolLKKPS) - -### 한국어 - -- [/] 영어 번역이 최적화되었습니다(@CoolLKKPS) - -## Version 0.5.8 - -### 中文 - -- [/] 部分空手打怪/销毁物品问题已兼容(?) -- [+] 新增配置 PlayerJoin 现在你可以자定义欢迎语句了! -- [/] 一票起飞功能修复 - -### English - -- [/] The problem of empty-handed fighting monsters/destruction of items has been resolved (?) -- [+] Added PlayerJoin configuration, now you can customize the welcome message! -- [/] One-ticket departure function is fixed - -### 한국어 - -- [/] 맨손으로 몬스터와 싸우기/아이템 파괴 문제가 해결되었습니다 (?) -- [+] PlayerJoin 설정이 추가되어 이제 환영 메시지를 사용자 정의할 수 있습니다! -- [/] 한 표 출발 기능이 수정되었습니다 - -## Version 0.5.7 - -### 中文 - -- [/] 回滚销毁检测机制 -- [+] 新增配置 OnlyOneVote 用于控制主机是否可以一票起飞 - -### English - -- [/] rollback destruction detection mechanism -- [+] Add configuration OnlyOneVote to control whether the host can take off with one ticket - -### 한국어 - -- [/] 파괴 감지 메커니즘이 롤백되었습니다 -- [+] 호스트가 한 표로 이륙할 수 있는지 제어하는 OnlyOneVote 설정이 추가되었습니다 - -## Version 0.5.6 - -### 中文 - -- [/] 修复出售货物导致销毁物品检测 - -### English - -- [/] Fix the issue of selling goods leading to the detection of destroyed items. - -### 한국어 - -- [/] 상품 판매가 아이템 파괴 감지로 이어지는 문제가 수정되었습니다. - -## Version 0.5.5 - -### 中文 - -- [/] 修复不是房主也能一票起飞的问题 -- [/] 现在被踢出的玩家在连接时就会被断开连接 -- [+] 现在使用 AntiKick 进入游戏将会在控制台显示玩家名称和 SteamId -- [+] 现在伪造 SteamId 加入游戏将会被自动踢出 - -### English - -- [/] Fixed the issue where non-hosts could initiate the game with a single vote. -- [/] Players who are kicked out will now be disconnected upon trying to reconnect. -- [+] Players who use AntiKick to enter the game will now have their usernames and SteamIds displayed in the console. -- [+] Players attempting to join the game with a falsified SteamId will now be automatically kicked out. - -### 한국어 - -- [/] 호스트가 아닌 플레이어도 한 표로 게임을 시작할 수 있는 문제가 수정되었습니다. -- [/] 킥당한 플레이어가 다시 연결을 시도할 때 즉시 연결이 끊어집니다. -- [+] AntiKick을 사용하여 게임에 입장하는 플레이어의 사용자명과 SteamId가 콘솔에 표시됩니다. -- [+] 위조된 SteamId로 게임에 참가하려는 플레이어는 자동으로 킥됩니다. - -## Version 0.5.4 - -### 中文 - -- [/] 修复房主投票少一票的问题 -- [/] 修复部分情况无法拉杆 -- [/] 现在不检测枪是否被销毁 - -### English - -- [/] Fixed the issue of homeowners voting one less vote -- [/] Fixed some situations where it was not possible to pull the rod -- [/] Currently, we are not checking if the gun has been destroyed - -### 한국어 - -- [/] 호스트의 투표가 한 표 부족한 문제가 수정되었습니다 -- [/] 일부 상황에서 레버를 당길 수 없는 문제가 수정되었습니다 -- [/] 현재 총이 파괴되었는지 확인하지 않습니다 - -## Version 0.5.3 - -### 中文 - -- [/] 修复投票导致游戏崩溃 - -### English - -- [/] Fix the voting system that causes the game to crash - -### 한국어 - -- [/] 게임을 크래시시키는 투표 시스템이 수정되었습니다 - -## Version 0.5.2 - -### 中文 - -- [/] 修复无法正常出售货物 - -### English - -- [/] Repair the goods that cannot be sold normally - -### 한국어 - -- [/] 정상적으로 판매할 수 없는 상품 문제가 수정되었습니다 - -## Version 0.5.1 - -### 中文 - -- [/] 修复出售货物导致销毁物品检测 -- [+] 进游戏卡黑屏将会自动退出房间(未测试) - -### English - -- [/] Fix the issue of selling goods leading to the detection of destroyed items. -- [+] The game will automatically exit the room if it crashes with a black screen (not tested) - -### 한국어 - -- [/] 상품 판매가 아이템 파괴 감지로 이어지는 문제가 수정되었습니다. -- [+] 게임이 검은 화면으로 크래시될 경우 자동으로 방에서 나갑니다 (테스트되지 않음) - -## Version 0.5.0 - -### 中文 - -- [+] 现在禁止使用双手拿取物品了 -- [/] 修改了销毁物品的检测机制 -- [/] 修复死亡后投票提示问题 -- [/] 房主一票直接起飞 修改为 一个小时后起飞 -- [/] 修复客户端拉杆失败导致无法继续拉杆 - -### English - -- [+] It is now prohibited to pick up items with both hands. -- [/] The detection mechanism for destroying items has been modified. -- [/] Fixed the issue with the voting prompt after death. -- [/] The rule where the host can immediately take off with one vote has been changed to taking off after one hour. -- [/] Fixed the issue where failing to pull the lever on the client side prevents further lever pulling. - -### 한국어 - -- [+] 이제 양손으로 아이템을 집는 것이 금지되었습니다. -- [/] 아이템 파괴 감지 메커니즘이 수정되었습니다. -- [/] 사망 후 투표 알림 문제가 수정되었습니다. -- [/] 호스트가 한 표로 즉시 이륙하는 규칙이 한 시간 후 이륙으로 변경되었습니다. -- [/] 클라이언트 측에서 레버 당기기 실패로 인해 더 이상 레버를 당길 수 없는 문제가 수정되었습니다. - -## Version 0.4.9 - -### 中文 - -- [+] 新增 ServerNameSetting.Prefix 配置,现在你可以通过改变配置来决定房间名的前缀(如果为空则为不启用) -- [/] 修复死亡后投票提示问题 -- [/] 修改了铲子范围异常检测部分机制 - -### English - -- [+] Added ServerNameSetting.Prefix configuration, now you can determine the prefix of the room name by changing the configuration (if empty, it is not enabled). -- [/] Fixed the issue of voting prompts after death. -- [/] Modified the mechanism for detecting shovel range abnormalities. - -### 한국어 - -- [+] ServerNameSetting.Prefix 설정이 추가되었습니다. 이제 설정을 변경하여 방 이름의 접두사를 결정할 수 있습니다 (비어있으면 비활성화됩니다). -- [/] 사망 후 투표 알림 문제가 수정되었습니다. -- [/] 삽 범위 이상 감지 메커니즘이 수정되었습니다. - -## Version 0.4.8 - -### 中文 - -- [/] 修复 0.4.6/0.4.7 版本导致的帧率过低问题 - -### English - -- [/] Fix low fps issue caused by version 0.4.6/0.4.7 - -### 한국어 - -- [/] 0.4.6/0.4.7 버전으로 인한 낮은 fps 문제가 수정되었습니다 - -## Version 0.4.7 - -### 中文 - -- [/] 是的,我忘记上传修改日志了,那么我们直接跳过 0.4.7 版本(当前版本改动和 0.4.6 一样,并且版本号使用 0.4.6) - -### English - -- [/] Yes, I forgot to upload the change log. Let's skip version 0.4.7 directly (the changes in the current version are the same as those in 0.4.6, and we'll use version number 0.4.6). - -### 한국어 - -- [/] 네, 변경 로그 업로드를 깜빡했습니다. 0.4.7 버전을 바로 건너뛰겠습니다 (현재 버전의 변경사항은 0.4.6과 동일하며, 버전 번호는 0.4.6을 사용합니다). - -## Version 0.4.6 - -### 中文 - -- [+] 当你创建房间时,房间名会自动新增[AC] 作为前缀,例如:"[v49] 战斗爽" 会变成 "[v49/AC] 战斗爽!" 或者 "战斗爽!" 会变成 "[AC] 战斗爽!" -- [+] 新增死亡投票提示(你是房主,投票直接起飞!) - -### English - -- [+] When you create a room, the room name will automatically have "[AC]" added as a prefix. For example, "[v49] The battle is thrilling!" will become "[v49/AC] The battle is thrilling!" or "The battle is thrilling!" will become "[AC] The battle is thrilling!". -- [+] You are the homeowner, and voting can immediately make the spaceship take off. - -### 한국어 - -- [+] 방을 생성할 때 방 이름에 자동으로 "[AC]"가 접두사로 추가됩니다. 예: "[v49] 전투 재미!" → "[v49/AC] 전투 재미!" 또는 "전투 재미!" → "[AC] 전투 재미!" -- [+] 사망 투표 알림이 추가되었습니다 (당신은 호스트입니다, 투표하면 즉시 이륙합니다!) - -## Version 0.4.5 - -### 中文 - -- [/] 修复了配置文件描述丢失的问题 - -### English - -- [/] Fix the issue of missing configuration file descriptions - -### 한국어 - -- [/] 설정 파일 설명이 누락되는 문제가 수정되었습니다 - -## Version 0.4.4 - -### 中文 - -- [/] 修复缺少描述导致语言无法正常加载 - -### English - -- [/] Fix the issue where missing descriptions cause languages to fail to load properly - -### 한국어 - -- [/] 설명이 누락되어 언어가 제대로 로드되지 않는 문제가 수정되었습니다 - -## Version 0.4.3 - -### 中文 - -- [+] 自动踢出开启防踢的玩家 -- [+] 新增 Log 配置,用于控制反作弊的日志输出 - -### English - -- [+] Automatically kick out players with anti-kick enabled -- [+] New Log configuration added to control the output of anti cheating logs - -### 한국어 - -- [+] 안티킥이 활성화된 플레이어를 자동으로 킥합니다 -- [+] 안티치트 로그 출력을 제어하는 새로운 Log 설정이 추가되었습니다 - -## Version 0.4.2 - -### 中文 - -- [/] 更改强制引爆地雷逻辑 - -### English - -- [/] Change the logic for detecting landmine detonation - -### 한국어 - -- [/] 지뢰 강제 폭발 로직이 변경되었습니다 - -## Version 0.4.1 - -### 中文 - -- [+] 从 0.4.1 版本以后将会发布更新日志 -- [/] 修复怪物不能正常击杀客机玩家 - -### English - -- [+] There will be modification logs in future versions -- [/] Monsters cannot kill client players normally - -### 한국어 - -- [+] 0.4.1 버전부터 업데이트 로그가 발표됩니다 -- [/] 몬스터가 클라이언트 플레이어를 정상적으로 죽일 수 없는 문제가 수정되었습니다 diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 261eeb9..0000000 --- a/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/README.md b/README.md index c02260b..2bba66d 100644 --- a/README.md +++ b/README.md @@ -223,4 +223,4 @@ ## 反馈 -如果你遇到误检测并确定不是模组导致,你可以提交 issue 来说明如何复现问题帮助我们修复问题! +如果你遇到误检测并确定不是模组导致,你可以提交 issue 来说明如何复现问题帮助我们修复问题! \ No newline at end of file diff --git a/docs/README-en.md b/docs/README-en.md index 6fac3d3..edc596e 100644 --- a/docs/README-en.md +++ b/docs/README-en.md @@ -175,4 +175,4 @@ We welcome contributions from capable developers to improve this mod. ## Feedback -If you encounter a false positive and can confirm it's not caused by another mod, please report the issue on my GitHub, explaining how to reproduce the problem. This will help us fix it! +If you encounter a false positive and can confirm it's not caused by another mod, please report the issue on my GitHub, explaining how to reproduce the problem. This will help us fix it! \ No newline at end of file diff --git a/docs/README-ko.md b/docs/README-ko.md index d1c4e10..422bcbb 100644 --- a/docs/README-ko.md +++ b/docs/README-ko.md @@ -234,4 +234,4 @@ - GeneralImprovements - ScrollFix -- OrbitRecharge +- OrbitRecharge \ No newline at end of file diff --git a/docs/README-ru.md b/docs/README-ru.md index 0698ad0..ed0a7e4 100644 --- a/docs/README-ru.md +++ b/docs/README-ru.md @@ -77,4 +77,4 @@ - 喜欢睡觉の极茶龙 - 东南枝 - Melissa -- 我不吃牛肉 +- 我不吃牛肉 \ No newline at end of file diff --git a/icon.png b/icon.png deleted file mode 100644 index 0e83623..0000000 Binary files a/icon.png and /dev/null differ diff --git a/manifest.json b/manifest.json deleted file mode 100644 index b7f912a..0000000 --- a/manifest.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "AntiCheat", - "version_number": "0.8.7", - "website_url": "https://github.com/chuxiaaaa/AntiCheat", - "description": "A Lethal Company AntiCheat Mod.", - "dependencies": [ - "BepInEx-BepInExPack-5.4.2100" - ] -} \ No newline at end of file