From bd22791ddca3489ccfddcdf58619779870fbd041 Mon Sep 17 00:00:00 2001 From: Gurge44 Date: Sat, 2 Dec 2023 16:06:02 +0100 Subject: [PATCH] Don't send unnecessary RPCs --- GameMode/FFAManager.cs | 26 +++++++++++----------- Modules/ExtendedPlayerControl.cs | 14 ++++++------ Modules/GameState.cs | 2 +- Modules/Utils.cs | 5 +++-- Patches/GameManagerPatch.cs | 2 +- Patches/LadderPatch.cs | 4 ++-- Patches/PlayerContorolPatch.cs | 4 ++-- Patches/onGameStartedPatch.cs | 4 ++++ Roles/Crewmate/Admirer.cs | 1 + Roles/Crewmate/Alchemist.cs | 3 ++- Roles/Crewmate/Analyzer.cs | 2 +- Roles/Crewmate/Benefactor.cs | 2 +- Roles/Crewmate/Bloodhound.cs | 2 ++ Roles/Crewmate/CameraMan.cs | 1 + Roles/Crewmate/CandleLighter.cs | 4 ++-- Roles/Crewmate/Chameleon.cs | 3 ++- Roles/Crewmate/Cleanser.cs | 1 + Roles/Crewmate/CopyCat.cs | 1 + Roles/Crewmate/Crusader.cs | 18 ++++++++-------- Roles/Crewmate/Deputy.cs | 1 + Roles/Crewmate/Divinator.cs | 1 + Roles/Crewmate/DonutDelivery.cs | 2 +- Roles/Crewmate/Doormaster.cs | 1 + Roles/Crewmate/Drainer.cs | 2 +- Roles/Crewmate/Druid.cs | 10 ++++----- Roles/Crewmate/Enigma.cs | 4 ++-- Roles/Crewmate/Escort.cs | 2 +- Roles/Crewmate/Gaulois.cs | 2 +- Roles/Crewmate/Jailer.cs | 1 + Roles/Crewmate/Judge.cs | 1 + Roles/Crewmate/Marshall.cs | 37 -------------------------------- Roles/Crewmate/Medic.cs | 2 ++ Roles/Crewmate/Mediumshiper.cs | 1 + Roles/Crewmate/Merchant.cs | 35 ++++++------------------------ Roles/Crewmate/Monarch.cs | 1 + Roles/Crewmate/Mortician.cs | 1 + Roles/Crewmate/NiceEraser.cs | 1 + Roles/Crewmate/NiceHacker.cs | 1 + Roles/Crewmate/NiceSwapper.cs | 1 + Roles/Crewmate/Oracle.cs | 1 + Roles/Crewmate/Psychic.cs | 1 + Roles/Crewmate/Ricochet.cs | 2 ++ Roles/Crewmate/SabotageMaster.cs | 3 ++- Roles/Crewmate/Sheriff.cs | 1 + Roles/Crewmate/Spy.cs | 3 +++ Roles/Crewmate/SwordsMan.cs | 5 ++++- Roles/Crewmate/Tether.cs | 2 ++ Roles/Crewmate/Tracefinder.cs | 3 +-- Roles/Crewmate/Tracker.cs | 1 + Roles/Impostor/Assassin.cs | 15 +++++++------ Roles/Impostor/BallLightning.cs | 1 + Roles/Impostor/BountyHunter.cs | 1 + Roles/Impostor/Cantankerous.cs | 2 +- Roles/Impostor/Chronomancer.cs | 2 ++ Roles/Impostor/Consort.cs | 2 +- Roles/Impostor/Councillor.cs | 1 + Roles/Impostor/Duellist.cs | 2 +- Roles/Impostor/Eraser.cs | 1 + Roles/Impostor/EvilDiviner.cs | 1 + Roles/Impostor/EvilTracker.cs | 1 + Roles/Impostor/FireWorks.cs | 2 ++ Roles/Impostor/Gambler.cs | 6 +++--- Roles/Impostor/Gangster.cs | 1 + Roles/Impostor/Greedier.cs | 1 + Roles/Impostor/Hacker.cs | 1 + Roles/Impostor/Hitman.cs | 1 + Roles/Impostor/Librarian.cs | 4 ++-- Roles/Impostor/Mafioso.cs | 4 ++-- Roles/Impostor/Mastermind.cs | 31 +++++++++++--------------- Roles/Impostor/Penguin.cs | 2 +- Roles/Impostor/QuickShooter.cs | 1 + Roles/Impostor/Sniper.cs | 1 + Roles/Impostor/Swooper.cs | 2 +- Roles/Impostor/Undertaker.cs | 15 +++++++------ Roles/Impostor/Wildling.cs | 1 + Roles/Impostor/Witch.cs | 1 + Roles/Impostor/YinYanger.cs | 2 +- Roles/Neutral/Amnesiac.cs | 23 +------------------- Roles/Neutral/Bandit.cs | 3 ++- Roles/Neutral/BloodKnight.cs | 1 + Roles/Neutral/Collector.cs | 1 + Roles/Neutral/CursedSoul.cs | 1 + Roles/Neutral/DarkHide.cs | 2 +- Roles/Neutral/Doomsayer.cs | 4 ++-- Roles/Neutral/Doppelganger.cs | 2 +- Roles/Neutral/Eclipse.cs | 3 ++- Roles/Neutral/Executioner.cs | 1 + Roles/Neutral/Gamer.cs | 1 + Roles/Neutral/Glitch.cs | 6 ++++++ Roles/Neutral/HexMaster.cs | 1 + Roles/Neutral/Imitator.cs | 1 + Roles/Neutral/Infectious.cs | 1 + Roles/Neutral/Jackal.cs | 1 + Roles/Neutral/Lawyer.cs | 1 + Roles/Neutral/Pelican.cs | 1 + Roles/Neutral/PlagueBearer.cs | 1 + Roles/Neutral/PlagueDoctor.cs | 2 +- Roles/Neutral/Pursuer.cs | 1 + Roles/Neutral/Ritualist.cs | 1 + Roles/Neutral/Romantic.cs | 2 ++ Roles/Neutral/Spiritcaller.cs | 1 + Roles/Neutral/Succubus.cs | 1 + Roles/Neutral/Totocalcio.cs | 1 + Roles/Neutral/Vengeance.cs | 2 ++ Roles/Neutral/Virus.cs | 1 + Roles/Neutral/Vulture.cs | 1 + Roles/Neutral/WeaponMaster.cs | 1 + Roles/Neutral/Werewolf.cs | 2 +- Roles/Neutral/Wraith.cs | 2 +- 109 files changed, 207 insertions(+), 199 deletions(-) diff --git a/GameMode/FFAManager.cs b/GameMode/FFAManager.cs index 143a55bc0..c54b3873c 100644 --- a/GameMode/FFAManager.cs +++ b/GameMode/FFAManager.cs @@ -16,7 +16,7 @@ internal static class FFAManager public static Dictionary FFALowerVisionList = []; private static Dictionary originalSpeed = []; - public static Dictionary KBScore = []; + public static Dictionary KillCount = []; public static int RoundTime; //Options @@ -90,12 +90,12 @@ internal static class FFAManager FFAShieldedList = []; originalSpeed = []; - KBScore = []; + KillCount = []; RoundTime = FFA_GameTime.GetInt() + 8; foreach (PlayerControl pc in Main.AllAlivePlayerControls) { - KBScore.TryAdd(pc.PlayerId, 0); + KillCount.TryAdd(pc.PlayerId, 0); } _ = new LateTask(Utils.SetChatVisible, 7f, "Set Chat Visible for Everyone"); @@ -104,13 +104,13 @@ internal static class FFAManager { MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncFFAPlayer, SendOption.Reliable, -1); writer.Write(playerId); - writer.Write(KBScore[playerId]); + writer.Write(KillCount[playerId]); AmongUsClient.Instance.FinishRpcImmediately(writer); } public static void ReceiveRPCSyncFFAPlayer(MessageReader reader) { byte PlayerId = reader.ReadByte(); - KBScore[PlayerId] = reader.ReadInt32(); + KillCount[PlayerId] = reader.ReadInt32(); } public static void SendRPCSyncNameNotify(PlayerControl pc) { @@ -141,7 +141,7 @@ internal static class FFAManager public static string GetDisplayScore(byte playerId) { int rank = GetRankOfScore(playerId); - string score = KBScore.TryGetValue(playerId, out var s) ? $"{s}" : "Invalid"; + string score = KillCount.TryGetValue(playerId, out var s) ? $"{s}" : "Invalid"; string text = string.Format(GetString("KBDisplayScore"), rank.ToString(), score); Color color = Utils.GetRoleColor(CustomRoles.Killer); return Utils.ColorString(color, text); @@ -150,9 +150,9 @@ internal static class FFAManager { try { - int ms = KBScore[playerId]; - int rank = 1 + KBScore.Values.Where(x => x > ms).Count(); - rank += KBScore.Where(x => x.Value == ms).ToList().IndexOf(new(playerId, ms)); + int ms = KillCount[playerId]; + int rank = 1 + KillCount.Values.Where(x => x > ms).Count(); + rank += KillCount.Where(x => x.Value == ms).ToList().IndexOf(new(playerId, ms)); return rank; } catch @@ -235,7 +235,7 @@ internal static class FFAManager } killer.Notify(GetString("FFA-Event-GetIncreasedSpeed"), FFA_ModifiedSpeedDuration.GetFloat()); Main.AllPlayerKillCooldown[killer.PlayerId] = FFA_KCD.GetFloat(); - sync = true; + mark = true; break; case 2: Main.AllPlayerKillCooldown[killer.PlayerId] = System.Math.Clamp(FFA_KCD.GetFloat() - 3f, 1f, 60f); @@ -244,7 +244,6 @@ internal static class FFAManager break; default: Main.AllPlayerKillCooldown[killer.PlayerId] = FFA_KCD.GetFloat(); - sync = true; break; } } @@ -268,7 +267,7 @@ internal static class FFAManager } killer.Notify(GetString("FFA-Event-GetDecreasedSpeed"), FFA_ModifiedSpeedDuration.GetFloat()); Main.AllPlayerKillCooldown[killer.PlayerId] = FFA_KCD.GetFloat(); - sync = true; + mark = true; break; case 1: Main.AllPlayerKillCooldown[killer.PlayerId] = System.Math.Clamp(FFA_KCD.GetFloat() + 3f, 1f, 60f); @@ -283,7 +282,6 @@ internal static class FFAManager break; default: Main.AllPlayerKillCooldown[killer.PlayerId] = FFA_KCD.GetFloat(); - sync = true; break; } } @@ -313,7 +311,7 @@ internal static class FFAManager if (PlayerControl.LocalPlayer.Is(CustomRoles.GM)) PlayerControl.LocalPlayer.KillFlash(); - KBScore[killer.PlayerId]++; + KillCount[killer.PlayerId]++; } public static string GetPlayerArrow(PlayerControl seer, PlayerControl target = null) diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs index 67fa02791..2e0be356e 100644 --- a/Modules/ExtendedPlayerControl.cs +++ b/Modules/ExtendedPlayerControl.cs @@ -304,22 +304,22 @@ static class ExtendedPlayerControl } else if (PlayerControl.LocalPlayer == target) { - //targetがホストだった場合 + // If target is host PlayerControl.LocalPlayer.Data.Role.SetCooldown(); } else { - //targetがホスト以外だった場合 + // If target is not host MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(target.NetId, (byte)RpcCalls.ProtectPlayer, SendOption.None, target.GetClientId()); writer.WriteNetObject(target); writer.Write(0); AmongUsClient.Instance.FinishRpcImmediately(writer); } /* - プレイヤーがバリアを張ったとき、そのプレイヤーの役職に関わらずアビリティーのクールダウンがリセットされます。 - ログの追加により無にバリアを張ることができなくなったため、代わりに自身に0秒バリアを張るように変更しました。 - この変更により、役職としての守護天使が無効化されます。 - ホストのクールダウンは直接リセットします。 + When a player guards someone, ability cooldowns are reset regardless of that player's role. + Due to the addition of logs, it is no longer possible to guard no one, so it has been changed to the player guarding themselves for 0 seconds instead. + This change disables Guardian Angel as a position. + Reset host cooldown directly. */ } public static void RpcDesyncRepairSystem(this PlayerControl target, SystemTypes systemType, int amount) @@ -366,6 +366,8 @@ static class ExtendedPlayerControl return GameOptionsData.FromBytes(optByte); }*/ + public static bool IsNonHostModClient(this PlayerControl pc) => pc.IsModClient() && pc.PlayerId != 0; + public static string GetDisplayRoleName(this PlayerControl player, bool pure = false) { return Utils.GetDisplayRoleName(player.PlayerId, pure); diff --git a/Modules/GameState.cs b/Modules/GameState.cs index b8c8d47bd..38e7e59ad 100644 --- a/Modules/GameState.cs +++ b/Modules/GameState.cs @@ -498,7 +498,7 @@ public class TaskState Main.AllPlayerSpeed[player.PlayerId] = Options.ExpressSpeed.GetFloat(); Main.ExpressSpeedUp.Remove(player.PlayerId); Main.ExpressSpeedUp.TryAdd(player.PlayerId, Utils.GetTimeStamp()); - player.SyncSettings(); + player.MarkDirtySettings(); break; case CustomRoles.Alchemist: Alchemist.OnTaskComplete(player); diff --git a/Modules/Utils.cs b/Modules/Utils.cs index a323d6b1e..21eca1132 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -195,6 +195,7 @@ public static class Utils return false; } } + public static bool DoRPC => AmongUsClient.Instance.AmHost && Main.AllPlayerControls.Any(x => x.IsModClient() && x.PlayerId != 0); public static void SetVision(this IGameOptions opt, bool HasImpVision) { if (HasImpVision) @@ -302,7 +303,7 @@ public static class Utils var Duration = Options.KillFlashDuration.GetFloat(); if (ReactorCheck) Duration += 0.2f; // Extend blackout during reactor - //実行 + // Execution Main.PlayerStates[player.PlayerId].IsBlackOut = true; // Blackout if (player.AmOwner) { @@ -314,7 +315,7 @@ public static class Utils MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.KillFlash, SendOption.Reliable, player.GetClientId()); AmongUsClient.Instance.FinishRpcImmediately(writer); } - else if (!ReactorCheck) player.ReactorFlash(0f); // reactor flash + else if (!ReactorCheck) player.ReactorFlash(0f); // Reactor flash player.MarkDirtySettings(); _ = new LateTask(() => { diff --git a/Patches/GameManagerPatch.cs b/Patches/GameManagerPatch.cs index b86b437fa..fd4dfc191 100644 --- a/Patches/GameManagerPatch.cs +++ b/Patches/GameManagerPatch.cs @@ -32,7 +32,7 @@ class LogicOptionsSerializePatch { public static bool Prefix(LogicOptions __instance, ref bool __result, MessageWriter writer, bool initialState) { - // 初回以外はブロックし、CustomSyncSettingsでのみ同期する + // Block all but the first time and synchronize only with CustomSyncSettings if (!initialState) { __result = false; diff --git a/Patches/LadderPatch.cs b/Patches/LadderPatch.cs index 3749cf6f7..4507b6995 100644 --- a/Patches/LadderPatch.cs +++ b/Patches/LadderPatch.cs @@ -17,7 +17,7 @@ public class FallFromLadder if (!Options.LadderDeath.GetBool()) return; var sourcePos = source.transform.position; var targetPos = source.Destination.transform.position; - //降りているのかを検知 + if (sourcePos.y > targetPos.y) { int chance = IRandom.Instance.Next(1, 101); @@ -33,7 +33,7 @@ public class FallFromLadder if (TargetLadderData.ContainsKey(player.PlayerId) && Vector2.Distance(TargetLadderData[player.PlayerId], player.transform.position) < 0.5f) { if (player.Data.IsDead) return; - //LateTaskを入れるため、先に死亡判定を入れておく + // In order to insert LateTask, first enter the death judgment. player.Data.IsDead = true; _ = new LateTask(() => { diff --git a/Patches/PlayerContorolPatch.cs b/Patches/PlayerContorolPatch.cs index e202d9c7d..688cccee7 100644 --- a/Patches/PlayerContorolPatch.cs +++ b/Patches/PlayerContorolPatch.cs @@ -2264,7 +2264,7 @@ class FixedUpdatePatch { player.RpcResetAbilityCooldown(); Main.isCursed = false;//変身クールを1秒に変更 - player.SyncSettings(); + player.MarkDirtySettings(); Main.WarlockTimer.Remove(player.PlayerId); } else Main.WarlockTimer[player.PlayerId] = Main.WarlockTimer[player.PlayerId] + Time.fixedDeltaTime;//時間をカウント @@ -2440,7 +2440,7 @@ class FixedUpdatePatch { Main.ExpressSpeedUp.Remove(player.PlayerId); Main.AllPlayerSpeed[player.PlayerId] = Main.ExpressSpeedNormal; - player.SyncSettings(); + player.MarkDirtySettings(); } break; diff --git a/Patches/onGameStartedPatch.cs b/Patches/onGameStartedPatch.cs index 833730685..82a455448 100644 --- a/Patches/onGameStartedPatch.cs +++ b/Patches/onGameStartedPatch.cs @@ -235,6 +235,7 @@ internal class ChangeRoleSettings Gaulois.Init(); Analyzer.Init(); Escort.Init(); + Marshall.Init(); Consort.Init(); Drainer.Init(); Pursuer.Init(); @@ -684,6 +685,9 @@ internal class SelectRolesPatch case CustomRoles.Escort: Escort.Add(pc.PlayerId); break; + case CustomRoles.Marshall: + Marshall.Add(pc.PlayerId); + break; case CustomRoles.Consort: Consort.Add(pc.PlayerId); break; diff --git a/Roles/Crewmate/Admirer.cs b/Roles/Crewmate/Admirer.cs index 1fee8abf1..1358db63b 100644 --- a/Roles/Crewmate/Admirer.cs +++ b/Roles/Crewmate/Admirer.cs @@ -41,6 +41,7 @@ public static class Admirer public static void SendRPC() { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetAdmireLimit, SendOption.Reliable, -1); writer.Write(AdmireLimit); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Alchemist.cs b/Roles/Crewmate/Alchemist.cs index 86ba86101..b72343984 100644 --- a/Roles/Crewmate/Alchemist.cs +++ b/Roles/Crewmate/Alchemist.cs @@ -72,6 +72,7 @@ namespace TOHE.Roles.Crewmate public static void SendRPCData(bool isProtected, byte potionId, string playerName, bool visionPotionActive, bool fixNextSabo) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetAlchemistPotion, SendOption.Reliable, -1); writer.Write(isProtected); writer.Write(potionId); @@ -207,7 +208,7 @@ namespace TOHE.Roles.Crewmate public static bool IsInvis(byte id) => InvisTime.ContainsKey(id); private static void SendRPC(PlayerControl pc) { - if (pc.AmOwner) return; + if (!IsEnable || !Utils.DoRPC || pc.AmOwner) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetAlchemistTimer, SendOption.Reliable, pc.GetClientId()); writer.Write((InvisTime.TryGetValue(pc.PlayerId, out var x) ? x : -1).ToString()); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Analyzer.cs b/Roles/Crewmate/Analyzer.cs index 940297c30..be23aa5ec 100644 --- a/Roles/Crewmate/Analyzer.cs +++ b/Roles/Crewmate/Analyzer.cs @@ -90,7 +90,7 @@ namespace TOHE.Roles.Crewmate private static void SendRPCSyncTarget() { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncAnalyzerTarget, SendOption.Reliable, -1); writer.Write(CurrentTarget.ID); writer.Write(CurrentTarget.TIME); diff --git a/Roles/Crewmate/Benefactor.cs b/Roles/Crewmate/Benefactor.cs index 908188f80..b1af7b050 100644 --- a/Roles/Crewmate/Benefactor.cs +++ b/Roles/Crewmate/Benefactor.cs @@ -48,7 +48,7 @@ namespace TOHE.Roles.Crewmate } private static void SendRPC(byte benefactorID, int taskIndex = -1, bool IsShield = false, bool clearAll = false, bool shieldExpire = false, byte shieldedId = byte.MaxValue) { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncBenefactorMarkedTask, SendOption.Reliable, -1); writer.Write(benefactorID); writer.Write(taskIndex); diff --git a/Roles/Crewmate/Bloodhound.cs b/Roles/Crewmate/Bloodhound.cs index 9e7ae0bea..a1a6ddb17 100644 --- a/Roles/Crewmate/Bloodhound.cs +++ b/Roles/Crewmate/Bloodhound.cs @@ -52,6 +52,7 @@ private static void SendRPC(byte playerId, bool add, Vector3 loc = new()) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBloodhoundArrow, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(add); @@ -76,6 +77,7 @@ public static void SendRPCPlus(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.BloodhoundIncreaseAbilityUseByOne, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(UseLimit[playerId]); diff --git a/Roles/Crewmate/CameraMan.cs b/Roles/Crewmate/CameraMan.cs index 1915314a5..9509cb018 100644 --- a/Roles/Crewmate/CameraMan.cs +++ b/Roles/Crewmate/CameraMan.cs @@ -43,6 +43,7 @@ namespace TOHE.Roles.Crewmate public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCameraManLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(UseLimit[playerId]); diff --git a/Roles/Crewmate/CandleLighter.cs b/Roles/Crewmate/CandleLighter.cs index 302995898..d1bb9c04e 100644 --- a/Roles/Crewmate/CandleLighter.cs +++ b/Roles/Crewmate/CandleLighter.cs @@ -77,7 +77,7 @@ public static void OnTasksFinished(PlayerControl pc) { active = false; - pc.SyncSettings(); + pc.MarkDirtySettings(); } public static void OnFixedUpdate(PlayerControl player) { @@ -91,7 +91,7 @@ { ElapsedTime -= Time.fixedDeltaTime; - if (UpdateTime == 1.0f) player.SyncSettings(); + if (UpdateTime == 1.0f) player.MarkDirtySettings(); } } } diff --git a/Roles/Crewmate/Chameleon.cs b/Roles/Crewmate/Chameleon.cs index 04577e0ed..fcb6c171b 100644 --- a/Roles/Crewmate/Chameleon.cs +++ b/Roles/Crewmate/Chameleon.cs @@ -52,7 +52,7 @@ public static class Chameleon public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(PlayerControl pc) { - if (pc.AmOwner) return; + if (!IsEnable || !Utils.DoRPC || pc.AmOwner) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetChameleonTimer, SendOption.Reliable, pc.GetClientId()); writer.Write((InvisTime.TryGetValue(pc.PlayerId, out var x) ? x : -1).ToString()); writer.Write((lastTime.TryGetValue(pc.PlayerId, out var y) ? y : -1).ToString()); @@ -69,6 +69,7 @@ public static class Chameleon } public static void SendRPCPlus(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetChameleonLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(UseLimit[playerId]); diff --git a/Roles/Crewmate/Cleanser.cs b/Roles/Crewmate/Cleanser.cs index 0b5e71dfd..e07c47536 100644 --- a/Roles/Crewmate/Cleanser.cs +++ b/Roles/Crewmate/Cleanser.cs @@ -57,6 +57,7 @@ public static class Cleanser } public static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCleanserCleanLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(CleanserUses[playerId]); diff --git a/Roles/Crewmate/CopyCat.cs b/Roles/Crewmate/CopyCat.cs index 5af89d4af..ac85783b6 100644 --- a/Roles/Crewmate/CopyCat.cs +++ b/Roles/Crewmate/CopyCat.cs @@ -50,6 +50,7 @@ public static class CopyCat private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCopyCatMiscopyLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(MiscopyLimit[playerId]); diff --git a/Roles/Crewmate/Crusader.cs b/Roles/Crewmate/Crusader.cs index 2c3b7d087..82b9a9a1a 100644 --- a/Roles/Crewmate/Crusader.cs +++ b/Roles/Crewmate/Crusader.cs @@ -49,15 +49,15 @@ public static class Crusader Main.ResetCamPlayerList.Remove(playerId); } public static bool IsEnable => playerIdList.Count > 0; - public static void ReceiveRPC(MessageReader reader) - { - byte PlayerId = reader.ReadByte(); - int Limit = reader.ReadInt32(); - if (CrusaderLimit.ContainsKey(PlayerId)) - CrusaderLimit[PlayerId] = Limit; - else - CrusaderLimit.Add(PlayerId, SkillLimitOpt.GetInt()); - } + //public static void ReceiveRPC(MessageReader reader) + //{ + // byte PlayerId = reader.ReadByte(); + // int Limit = reader.ReadInt32(); + // if (CrusaderLimit.ContainsKey(PlayerId)) + // CrusaderLimit[PlayerId] = Limit; + // else + // CrusaderLimit.Add(PlayerId, SkillLimitOpt.GetInt()); + //} public static bool CanUseKillButton(byte playerId) => !Main.PlayerStates[playerId].IsDead && (CrusaderLimit.TryGetValue(playerId, out var x) ? x : 1) >= 1; diff --git a/Roles/Crewmate/Deputy.cs b/Roles/Crewmate/Deputy.cs index bf2b4044c..4b8d0cacd 100644 --- a/Roles/Crewmate/Deputy.cs +++ b/Roles/Crewmate/Deputy.cs @@ -49,6 +49,7 @@ public static class Deputy public static void SendRPC() { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDeputyHandcuffLimit, SendOption.Reliable, -1); writer.Write(HandcuffLimit); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Divinator.cs b/Roles/Crewmate/Divinator.cs index 63540415d..e9d4a4ced 100644 --- a/Roles/Crewmate/Divinator.cs +++ b/Roles/Crewmate/Divinator.cs @@ -45,6 +45,7 @@ public static class Divinator public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDivinatorLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(CheckLimit[playerId]); diff --git a/Roles/Crewmate/DonutDelivery.cs b/Roles/Crewmate/DonutDelivery.cs index 8b77d1da9..dd2ee892e 100644 --- a/Roles/Crewmate/DonutDelivery.cs +++ b/Roles/Crewmate/DonutDelivery.cs @@ -45,7 +45,7 @@ namespace TOHE.Roles.Crewmate public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC() { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDonutLimit, SendOption.Reliable, -1); writer.Write(DeliverLimit); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Doormaster.cs b/Roles/Crewmate/Doormaster.cs index 27c6996a1..c97828dfe 100644 --- a/Roles/Crewmate/Doormaster.cs +++ b/Roles/Crewmate/Doormaster.cs @@ -44,6 +44,7 @@ namespace TOHE.Roles.Crewmate public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDoormasterLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(UseLimit[playerId]); diff --git a/Roles/Crewmate/Drainer.cs b/Roles/Crewmate/Drainer.cs index 07e5c0f3b..b7a0ef752 100644 --- a/Roles/Crewmate/Drainer.cs +++ b/Roles/Crewmate/Drainer.cs @@ -55,7 +55,7 @@ namespace TOHE.Roles.Crewmate public static void SendRPC() { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDrainerLimit, SendOption.Reliable, -1); writer.Write(DrainLimit); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Druid.cs b/Roles/Crewmate/Druid.cs index 65d6f4e8f..8106edc9a 100644 --- a/Roles/Crewmate/Druid.cs +++ b/Roles/Crewmate/Druid.cs @@ -60,7 +60,7 @@ namespace TOHE.Roles.Crewmate public static void SendRPCSyncAbilityUse(byte playerId) { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDruidLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(UseLimit[playerId]); @@ -74,7 +74,7 @@ namespace TOHE.Roles.Crewmate } public static void SendRPCAddTriggerDelay(byte playerId, long timestamp) { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DruidAddTriggerDelay, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(timestamp); @@ -91,7 +91,7 @@ namespace TOHE.Roles.Crewmate } public static void SendRPCAddTrigger(byte playerId, Vector2 position, string roomName) { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DruidAddTriggerDelay, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(position.x); @@ -114,7 +114,7 @@ namespace TOHE.Roles.Crewmate } public static void SendRPCRemoveTrigger(byte playerId, Vector2 position) { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DruidAddTriggerDelay, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(position.x); @@ -133,7 +133,7 @@ namespace TOHE.Roles.Crewmate } public static void SendRPCSyncLastUpdate() { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DruidAddTriggerDelay, SendOption.Reliable, -1); writer.Write(lastUpdate); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Enigma.cs b/Roles/Crewmate/Enigma.cs index 9dbe4d9be..1a4f334ea 100644 --- a/Roles/Crewmate/Enigma.cs +++ b/Roles/Crewmate/Enigma.cs @@ -331,9 +331,9 @@ namespace TOHE.Roles.Crewmate if (showStageClue) return GetStage3Clue(length); if (rd.Next(0, 100) < EnigmaClueStage2Probability.GetInt()) return GetStage2Clue(length); return GetStage1Clue(length); + default: + return null; } - - return null; } private string GetStage1Clue(int length) diff --git a/Roles/Crewmate/Escort.cs b/Roles/Crewmate/Escort.cs index 3cd094e55..39457e76e 100644 --- a/Roles/Crewmate/Escort.cs +++ b/Roles/Crewmate/Escort.cs @@ -47,7 +47,7 @@ namespace TOHE.Roles.Crewmate public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC() { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetEscortLimit, SendOption.Reliable, -1); writer.Write(BlockLimit); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Gaulois.cs b/Roles/Crewmate/Gaulois.cs index 93d6574d9..5712c9ce0 100644 --- a/Roles/Crewmate/Gaulois.cs +++ b/Roles/Crewmate/Gaulois.cs @@ -48,7 +48,7 @@ namespace TOHE.Roles.Crewmate public static void SendRPC(byte playerId) { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGauloisLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(UseLimit[playerId]); diff --git a/Roles/Crewmate/Jailer.cs b/Roles/Crewmate/Jailer.cs index 8cae1e89b..951c703b5 100644 --- a/Roles/Crewmate/Jailer.cs +++ b/Roles/Crewmate/Jailer.cs @@ -53,6 +53,7 @@ public static class Jailor public static void SendRPC(byte jailerId, byte targetId = byte.MaxValue, bool setTarget = true) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer; if (!setTarget) { diff --git a/Roles/Crewmate/Judge.cs b/Roles/Crewmate/Judge.cs index 130bcafb6..d6bbd3020 100644 --- a/Roles/Crewmate/Judge.cs +++ b/Roles/Crewmate/Judge.cs @@ -227,6 +227,7 @@ public static class Judge private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.Judge, SendOption.Reliable, -1); writer.Write(playerId); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Marshall.cs b/Roles/Crewmate/Marshall.cs index 79367c8bf..cf2c925b5 100644 --- a/Roles/Crewmate/Marshall.cs +++ b/Roles/Crewmate/Marshall.cs @@ -72,43 +72,6 @@ public static class Marshall NameNotifyManager.Notify(marshall, Translator.GetString("MarshallDoneTasks")); IsComplete[marshallId] = true; } - - /// - /// タスクが進んだスニッチに警告マーク - /// - /// キラーの場合有効 - /// スニッチの場合有効 - /// public static string GetWarningMark(PlayerControl seer, PlayerControl target) => IsMarshallTarget(seer) && GetExpose(target) ? Utils.ColorString(RoleColor, "★") : string.Empty; - - /// - /// キラーからスニッチに対する矢印 - /// - /// キラーの場合有効 - /// キラーの場合有効 - /// - public static string GetWarningArrow(PlayerControl seer, PlayerControl target = null) - { - if (GameStates.IsMeeting || !IsMarshallTarget(seer)) return string.Empty; - if (target != null && seer.PlayerId != target.PlayerId) return string.Empty; - - if (!playerIdList.Any(s => !Main.PlayerStates[s].IsDead && IsExposed[s])) return string.Empty; - - var warning = "★"; - - return Utils.ColorString(RoleColor, warning); - } - /// - /// スニッチからキラーへの矢印 - /// - /// スニッチの場合有効 - /// スニッチの場合有効 - /// - - public static void OnCompleteTask(PlayerControl player) - { - if (!IsThisRole(player.PlayerId) /*|| player.Is(CustomRoles.Madmate)*/) return; - CheckTask(player); - } } diff --git a/Roles/Crewmate/Medic.cs b/Roles/Crewmate/Medic.cs index becee00fa..5b1d5278b 100644 --- a/Roles/Crewmate/Medic.cs +++ b/Roles/Crewmate/Medic.cs @@ -85,6 +85,7 @@ public static class Medic public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetMedicalerProtectLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(ProtectLimit[playerId]); @@ -101,6 +102,7 @@ public static class Medic } private static void SendRPCForProtectList() { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetMedicalerProtectList, SendOption.Reliable, -1); writer.Write(ProtectList.Count); foreach (byte x in ProtectList.ToArray()) diff --git a/Roles/Crewmate/Mediumshiper.cs b/Roles/Crewmate/Mediumshiper.cs index 692d9dbcd..607d913fe 100644 --- a/Roles/Crewmate/Mediumshiper.cs +++ b/Roles/Crewmate/Mediumshiper.cs @@ -41,6 +41,7 @@ public static class Mediumshiper public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetMediumshiperLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(ContactLimit[playerId]); diff --git a/Roles/Crewmate/Merchant.cs b/Roles/Crewmate/Merchant.cs index 41e0cbb80..f71a7c42d 100644 --- a/Roles/Crewmate/Merchant.cs +++ b/Roles/Crewmate/Merchant.cs @@ -112,35 +112,12 @@ namespace TOHE.Roles.Crewmate addonsSold = []; bribedKiller = []; - if (OptionCanSellHelpful.GetBool()) - { - addons.AddRange(helpfulAddons); - } - - if (OptionCanSellBalanced.GetBool()) - { - addons.AddRange(balancedAddons); - } - - if (OptionCanSellHarmful.GetBool()) - { - addons.AddRange(harmfulAddons); - } - - if (OptionCanSellNeutral.GetBool()) - { - addons.AddRange(neutralAddons); - } - - if (OptionCanSellExperimental.GetBool()) - { - addons.AddRange(experimentalAddons); - } - - if (OptionSellOnlyEnabledAddons.GetBool()) - { - addons = addons.Where(role => role.GetMode() != 0).ToList(); - } + if (OptionCanSellHelpful.GetBool()) addons.AddRange(helpfulAddons); + if (OptionCanSellBalanced.GetBool()) addons.AddRange(balancedAddons); + if (OptionCanSellHarmful.GetBool()) addons.AddRange(harmfulAddons); + if (OptionCanSellNeutral.GetBool()) addons.AddRange(neutralAddons); + if (OptionCanSellExperimental.GetBool()) addons.AddRange(experimentalAddons); + if (OptionSellOnlyEnabledAddons.GetBool()) addons = addons.Where(role => role.GetMode() != 0).ToList(); } public static void Add(byte playerId) diff --git a/Roles/Crewmate/Monarch.cs b/Roles/Crewmate/Monarch.cs index 31997f1fc..2ca540e92 100644 --- a/Roles/Crewmate/Monarch.cs +++ b/Roles/Crewmate/Monarch.cs @@ -44,6 +44,7 @@ public static class Monarch public static void SendRPC() { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetMonarchKnightLimit, SendOption.Reliable, -1); writer.Write(KnightLimit); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Mortician.cs b/Roles/Crewmate/Mortician.cs index 8a899bcf9..2676d8b7f 100644 --- a/Roles/Crewmate/Mortician.cs +++ b/Roles/Crewmate/Mortician.cs @@ -33,6 +33,7 @@ public static class Mortician public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(byte playerId, bool add, Vector3 loc = new()) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetMorticianArrow, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(add); diff --git a/Roles/Crewmate/NiceEraser.cs b/Roles/Crewmate/NiceEraser.cs index 6a304fbea..01868a78a 100644 --- a/Roles/Crewmate/NiceEraser.cs +++ b/Roles/Crewmate/NiceEraser.cs @@ -39,6 +39,7 @@ internal static class NiceEraser public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetEraseLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(EraseLimit[playerId]); diff --git a/Roles/Crewmate/NiceHacker.cs b/Roles/Crewmate/NiceHacker.cs index 29bac6b81..613dd7524 100644 --- a/Roles/Crewmate/NiceHacker.cs +++ b/Roles/Crewmate/NiceHacker.cs @@ -63,6 +63,7 @@ public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC(byte playerId, float secondsLeft) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetNiceHackerLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(secondsLeft); diff --git a/Roles/Crewmate/NiceSwapper.cs b/Roles/Crewmate/NiceSwapper.cs index 37d2839e9..aa8c68783 100644 --- a/Roles/Crewmate/NiceSwapper.cs +++ b/Roles/Crewmate/NiceSwapper.cs @@ -238,6 +238,7 @@ public static class NiceSwapper } private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetNiceSwapperVotes, SendOption.Reliable, -1); writer.Write(playerId); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Oracle.cs b/Roles/Crewmate/Oracle.cs index 37c684752..7832ffdd4 100644 --- a/Roles/Crewmate/Oracle.cs +++ b/Roles/Crewmate/Oracle.cs @@ -48,6 +48,7 @@ public static class Oracle public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetOracleLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(CheckLimit[playerId]); diff --git a/Roles/Crewmate/Psychic.cs b/Roles/Crewmate/Psychic.cs index 6c9d66b58..05fd9da55 100644 --- a/Roles/Crewmate/Psychic.cs +++ b/Roles/Crewmate/Psychic.cs @@ -42,6 +42,7 @@ public static class Psychic public static bool IsEnable => playerIdList.Any(); private static void SendRPC() { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncPsychicRedList, SendOption.Reliable, -1); writer.Write(RedPlayer.Count); foreach (byte pc in RedPlayer.ToArray()) diff --git a/Roles/Crewmate/Ricochet.cs b/Roles/Crewmate/Ricochet.cs index 5ee877bac..a0ff8158e 100644 --- a/Roles/Crewmate/Ricochet.cs +++ b/Roles/Crewmate/Ricochet.cs @@ -42,6 +42,7 @@ namespace TOHE.Roles.Crewmate public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetRicochetLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(UseLimit[playerId]); @@ -49,6 +50,7 @@ namespace TOHE.Roles.Crewmate } public static void SendRPCSyncTarget(byte targetId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetRicochetTarget, SendOption.Reliable, -1); writer.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/SabotageMaster.cs b/Roles/Crewmate/SabotageMaster.cs index 80bda32b0..4e7f9f92f 100644 --- a/Roles/Crewmate/SabotageMaster.cs +++ b/Roles/Crewmate/SabotageMaster.cs @@ -51,9 +51,10 @@ public static class SabotageMaster { playerIdList.Add(playerId); } - public static bool IsEnable() => playerIdList.Count > 0; + public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC(float count) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetSabotageMasterLimit, SendOption.Reliable, -1); writer.Write(count); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Sheriff.cs b/Roles/Crewmate/Sheriff.cs index 3456209b6..3ad737c51 100644 --- a/Roles/Crewmate/Sheriff.cs +++ b/Roles/Crewmate/Sheriff.cs @@ -101,6 +101,7 @@ public static class Sheriff public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetSheriffShotLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(ShotLimit[playerId]); diff --git a/Roles/Crewmate/Spy.cs b/Roles/Crewmate/Spy.cs index 9326de21e..7f039aa81 100644 --- a/Roles/Crewmate/Spy.cs +++ b/Roles/Crewmate/Spy.cs @@ -47,6 +47,7 @@ namespace TOHE.Roles.Crewmate public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC(byte susId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SpyRedNameSync, SendOption.Reliable, -1); writer.Write(susId); writer.Write(SpyRedNameList[susId].ToString()); @@ -54,6 +55,7 @@ namespace TOHE.Roles.Crewmate } public static void SendAbilityRPC(byte spyId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SpyAbilitySync, SendOption.Reliable, -1); writer.Write(spyId); writer.Write(UseLimit[spyId]); @@ -62,6 +64,7 @@ namespace TOHE.Roles.Crewmate } public static void SendRPC(byte susId, bool changeColor) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SpyRedNameRemove, SendOption.Reliable, -1); //writer.Write(spyId); writer.Write(susId); diff --git a/Roles/Crewmate/SwordsMan.cs b/Roles/Crewmate/SwordsMan.cs index 32ce3782b..b18e4a06a 100644 --- a/Roles/Crewmate/SwordsMan.cs +++ b/Roles/Crewmate/SwordsMan.cs @@ -1,4 +1,5 @@ -using Hazel; +using Epic.OnlineServices; +using Hazel; using System.Collections.Generic; using UnityEngine; @@ -36,8 +37,10 @@ public static class SwordsMan if (!Main.ResetCamPlayerList.Contains(playerId)) Main.ResetCamPlayerList.Add(playerId); } + public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SwordsManKill, SendOption.Reliable, -1); writer.Write(playerId); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Tether.cs b/Roles/Crewmate/Tether.cs index 22702feac..4c31bd1b8 100644 --- a/Roles/Crewmate/Tether.cs +++ b/Roles/Crewmate/Tether.cs @@ -45,6 +45,7 @@ namespace TOHE.Roles.Crewmate public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetTetherLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(UseLimit[playerId]); @@ -52,6 +53,7 @@ namespace TOHE.Roles.Crewmate } public static void SendRPCSyncTarget(byte targetId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetTetherTarget, SendOption.Reliable, -1); writer.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Crewmate/Tracefinder.cs b/Roles/Crewmate/Tracefinder.cs index 97a6529d1..ab0fa57d0 100644 --- a/Roles/Crewmate/Tracefinder.cs +++ b/Roles/Crewmate/Tracefinder.cs @@ -42,6 +42,7 @@ public static class Tracefinder public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(byte playerId, bool add, Vector3 loc = new()) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetTracefinderArrow, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(add); @@ -74,9 +75,7 @@ public static class Tracefinder LocateArrow.RemoveAllTarget(apc); SendRPC(apc, false); } - } - public static void OnPlayerDead(PlayerControl target) { var pos = target.Pos(); diff --git a/Roles/Crewmate/Tracker.cs b/Roles/Crewmate/Tracker.cs index 24e54831c..98b81c05c 100644 --- a/Roles/Crewmate/Tracker.cs +++ b/Roles/Crewmate/Tracker.cs @@ -56,6 +56,7 @@ namespace TOHE.Roles.Crewmate } public static void SendRPC(byte trackerId = byte.MaxValue, byte targetId = byte.MaxValue) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetTrackerTarget, SendOption.Reliable, -1); writer.Write(trackerId); writer.Write(targetId); diff --git a/Roles/Impostor/Assassin.cs b/Roles/Impostor/Assassin.cs index 0bdcd68a5..73d90e402 100644 --- a/Roles/Impostor/Assassin.cs +++ b/Roles/Impostor/Assassin.cs @@ -40,6 +40,7 @@ internal static class Assassin public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetMarkedPlayer, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(MarkedPlayer.ContainsKey(playerId) ? MarkedPlayer[playerId] : byte.MaxValue); @@ -97,17 +98,19 @@ internal static class Assassin if (MarkedPlayer.ContainsKey(pc.PlayerId)) { var target = Utils.GetPlayerById(MarkedPlayer[pc.PlayerId]); - MarkedPlayer.Remove(pc.PlayerId); - SendRPC(pc.PlayerId); _ = new LateTask(() => { if (!(target == null || !target.IsAlive() || Pelican.IsEaten(target.PlayerId) || target.inVent || !GameStates.IsInTask)) { pc.TP(target.Pos()); - pc.ResetKillCooldown(); - pc.SyncSettings(); - pc.SetKillCooldown(DefaultKillCooldown); - pc.RpcCheckAndMurder(target); + if (pc.RpcCheckAndMurder(target)) + { + MarkedPlayer.Remove(pc.PlayerId); + SendRPC(pc.PlayerId); + pc.ResetKillCooldown(); + pc.SyncSettings(); + pc.SetKillCooldown(DefaultKillCooldown); + } } }, UsePets.GetBool() ? 0.1f : 0.2f, "Assassin Assassinate"); return; diff --git a/Roles/Impostor/BallLightning.cs b/Roles/Impostor/BallLightning.cs index 18a4c3bfe..7ac7c62e0 100644 --- a/Roles/Impostor/BallLightning.cs +++ b/Roles/Impostor/BallLightning.cs @@ -41,6 +41,7 @@ public static class BallLightning public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGhostPlayer, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(IsGhost(playerId)); diff --git a/Roles/Impostor/BountyHunter.cs b/Roles/Impostor/BountyHunter.cs index 7fab7d6d8..8cdb6d11b 100644 --- a/Roles/Impostor/BountyHunter.cs +++ b/Roles/Impostor/BountyHunter.cs @@ -63,6 +63,7 @@ public static class BountyHunter public static bool IsEnable; private static void SendRPC(byte bountyId, byte targetId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBountyTarget, SendOption.Reliable, -1); writer.Write(bountyId); writer.Write(targetId); diff --git a/Roles/Impostor/Cantankerous.cs b/Roles/Impostor/Cantankerous.cs index c213dbe19..30630c5a5 100644 --- a/Roles/Impostor/Cantankerous.cs +++ b/Roles/Impostor/Cantankerous.cs @@ -47,7 +47,7 @@ namespace TOHE.Roles.Impostor private static void SendRPC(byte playerId, bool isPlus) { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncCantankerousLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(isPlus); diff --git a/Roles/Impostor/Chronomancer.cs b/Roles/Impostor/Chronomancer.cs index e8ff2913f..3256af709 100644 --- a/Roles/Impostor/Chronomancer.cs +++ b/Roles/Impostor/Chronomancer.cs @@ -33,6 +33,7 @@ namespace TOHE.Roles.Impostor } public static void SendRPC() { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetAdmireLimit, SendOption.Reliable, -1); writer.Write(isRampaging); writer.Write(chargePercent); @@ -59,6 +60,7 @@ namespace TOHE.Roles.Impostor } public static void SetKillCooldown(byte id) => Main.AllPlayerKillCooldown[id] = isRampaging ? 0.01f : KCD.GetFloat(); public static bool IsEnable => playerIdList.Count > 0; + public static bool IsRPCNecessary => Utils.DoRPC; public static void OnCheckMurder(PlayerControl killer, PlayerControl target) { if (killer == null) return; diff --git a/Roles/Impostor/Consort.cs b/Roles/Impostor/Consort.cs index 6a59a86bd..33031d6ab 100644 --- a/Roles/Impostor/Consort.cs +++ b/Roles/Impostor/Consort.cs @@ -42,7 +42,7 @@ namespace TOHE.Roles.Impostor public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC() { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetConsortLimit, SendOption.Reliable, -1); writer.Write(BlockLimit); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Impostor/Councillor.cs b/Roles/Impostor/Councillor.cs index ab7aaf4e3..de7cd81a5 100644 --- a/Roles/Impostor/Councillor.cs +++ b/Roles/Impostor/Councillor.cs @@ -227,6 +227,7 @@ public static class Councillor private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.MeetingKill, SendOption.Reliable, -1); writer.Write(playerId); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Impostor/Duellist.cs b/Roles/Impostor/Duellist.cs index a4c20280e..0f8dccb46 100644 --- a/Roles/Impostor/Duellist.cs +++ b/Roles/Impostor/Duellist.cs @@ -43,7 +43,7 @@ namespace TOHE.Roles.Impostor private static void SendRPC(byte duellistId, byte targetId, bool remove) { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncDuellistTarget, SendOption.Reliable, -1); writer.Write(duellistId); writer.Write(targetId); diff --git a/Roles/Impostor/Eraser.cs b/Roles/Impostor/Eraser.cs index c9972e2e3..6197865fa 100644 --- a/Roles/Impostor/Eraser.cs +++ b/Roles/Impostor/Eraser.cs @@ -56,6 +56,7 @@ internal static class Eraser public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetEraseLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(EraseLimit[playerId]); diff --git a/Roles/Impostor/EvilDiviner.cs b/Roles/Impostor/EvilDiviner.cs index 9214a5a1c..3264e33f8 100644 --- a/Roles/Impostor/EvilDiviner.cs +++ b/Roles/Impostor/EvilDiviner.cs @@ -47,6 +47,7 @@ namespace TOHE.Roles.Impostor private static void SendRPC(byte playerId, byte targetId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetEvilDiviner, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(DivinationCount[playerId]); diff --git a/Roles/Impostor/EvilTracker.cs b/Roles/Impostor/EvilTracker.cs index 2a211c41b..306e8ed24 100644 --- a/Roles/Impostor/EvilTracker.cs +++ b/Roles/Impostor/EvilTracker.cs @@ -170,6 +170,7 @@ public static class EvilTracker } if (!AmongUsClient.Instance.AmHost) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetEvilTrackerTarget, SendOption.Reliable, -1); writer.Write(trackerId); writer.Write(targetId); diff --git a/Roles/Impostor/FireWorks.cs b/Roles/Impostor/FireWorks.cs index 29f35c16c..a71c5d083 100644 --- a/Roles/Impostor/FireWorks.cs +++ b/Roles/Impostor/FireWorks.cs @@ -1,3 +1,4 @@ +using Epic.OnlineServices; using Hazel; using System.Collections.Generic; using TOHE.Roles.Crewmate; @@ -61,6 +62,7 @@ public static class FireWorks public static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; Logger.Info($"Player{playerId}:SendRPC", "FireWorks"); MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SendFireWorksState, SendOption.Reliable, -1); writer.Write(playerId); diff --git a/Roles/Impostor/Gambler.cs b/Roles/Impostor/Gambler.cs index e14ca9e12..db53b2756 100644 --- a/Roles/Impostor/Gambler.cs +++ b/Roles/Impostor/Gambler.cs @@ -167,7 +167,7 @@ namespace TOHE.Roles.Impostor killer.Notify(string.Format(GetString("GamblerGet.Speedup"), SpeedDur.GetInt(), Speed.GetFloat())); isSpeedChange.TryAdd(killer.PlayerId, (Main.AllPlayerSpeed[killer.PlayerId], GetTimeStamp())); Main.AllPlayerSpeed[killer.PlayerId] = Speed.GetFloat(); - killer.SyncSettings(); + killer.MarkDirtySettings(); break; default: Logger.Error("Invalid Effect ID (positive)", "Gambler.OnCheckMurder"); @@ -191,12 +191,12 @@ namespace TOHE.Roles.Impostor killer.Notify(string.Format(GetString("GamblerGet.Freeze"), FreezeDur.GetInt())); isSpeedChange.TryAdd(killer.PlayerId, (Main.AllPlayerSpeed[killer.PlayerId], GetTimeStamp())); Main.AllPlayerSpeed[killer.PlayerId] = Main.MinSpeed; - killer.SyncSettings(); + killer.MarkDirtySettings(); break; case 3: // Low vision killer.Notify(string.Format(GetString("GamblerGet.LowVision"), LowVisionDur.GetInt(), LowVision.GetFloat())); isVisionChange.TryAdd(killer.PlayerId, GetTimeStamp()); - killer.SyncSettings(); + killer.MarkDirtySettings(); break; case 4: // High KCD killer.Notify(string.Format(GetString("GamblerGet.HighKCD"), HighKCD.GetFloat())); diff --git a/Roles/Impostor/Gangster.cs b/Roles/Impostor/Gangster.cs index f126fe8d4..ab1d96800 100644 --- a/Roles/Impostor/Gangster.cs +++ b/Roles/Impostor/Gangster.cs @@ -53,6 +53,7 @@ public static class Gangster public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGangsterRecruitLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(RecruitLimit[playerId]); diff --git a/Roles/Impostor/Greedier.cs b/Roles/Impostor/Greedier.cs index 76208477c..9114cc6f0 100644 --- a/Roles/Impostor/Greedier.cs +++ b/Roles/Impostor/Greedier.cs @@ -40,6 +40,7 @@ public static class Greedier private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGreedierOE, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(IsOdd[playerId]); diff --git a/Roles/Impostor/Hacker.cs b/Roles/Impostor/Hacker.cs index 6b61c41ff..20a6948b3 100644 --- a/Roles/Impostor/Hacker.cs +++ b/Roles/Impostor/Hacker.cs @@ -45,6 +45,7 @@ public static class Hacker public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetHackerHackLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(HackLimit[playerId]); diff --git a/Roles/Impostor/Hitman.cs b/Roles/Impostor/Hitman.cs index dfc2772d2..2890fabbe 100644 --- a/Roles/Impostor/Hitman.cs +++ b/Roles/Impostor/Hitman.cs @@ -43,6 +43,7 @@ namespace TOHE.Roles.Impostor public static void SendRPC(byte targetId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetHitmanTarget, SendOption.Reliable, -1); writer.Write(targetId); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Impostor/Librarian.cs b/Roles/Impostor/Librarian.cs index 255a585a7..69312384b 100644 --- a/Roles/Impostor/Librarian.cs +++ b/Roles/Impostor/Librarian.cs @@ -67,7 +67,7 @@ namespace TOHE.Roles.Impostor private static void SendRPC(byte playerId, bool isInSilenceMode) { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetLibrarianMode, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(isInSilenceMode); @@ -85,7 +85,7 @@ namespace TOHE.Roles.Impostor private static void SendRPCSyncList() { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncLibrarianList, SendOption.Reliable, -1); writer.Write(sssh.Count); foreach (var item in sssh.ToArray()) diff --git a/Roles/Impostor/Mafioso.cs b/Roles/Impostor/Mafioso.cs index 5896bc876..59a72a78b 100644 --- a/Roles/Impostor/Mafioso.cs +++ b/Roles/Impostor/Mafioso.cs @@ -92,7 +92,7 @@ namespace TOHE.Roles.Impostor } public static void SendRPC() { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncMafiosoData, SendOption.Reliable, -1); writer.Write(Tier); writer.Write(XP); @@ -110,7 +110,7 @@ namespace TOHE.Roles.Impostor } public static void SendRPCSyncPistolCD() { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncMafiosoPistolCD, SendOption.Reliable, -1); writer.Write(Pistol1CD); writer.Write(Pistol2CD); diff --git a/Roles/Impostor/Mastermind.cs b/Roles/Impostor/Mastermind.cs index c0741565d..490636ed3 100644 --- a/Roles/Impostor/Mastermind.cs +++ b/Roles/Impostor/Mastermind.cs @@ -9,7 +9,7 @@ namespace TOHE.Roles.Impostor public static class Mastermind { private static readonly int Id = 640600; - public static List playerIdList = []; + public static byte mastermindId = byte.MaxValue; public static Dictionary ManipulatedPlayers = []; public static Dictionary ManipulateDelays = []; @@ -21,6 +21,8 @@ namespace TOHE.Roles.Impostor public static float ManipulateCD; + private static PlayerControl Mastermind_ => GetPlayerById(mastermindId); + public static void SetupCustomOption() { SetupRoleOptions(Id, TabGroup.ImpostorRoles, CustomRoles.Mastermind); @@ -35,7 +37,7 @@ namespace TOHE.Roles.Impostor public static void Init() { - playerIdList = []; + mastermindId = byte.MaxValue; ManipulatedPlayers = []; ManipulateDelays = []; TempKCDs = []; @@ -43,11 +45,11 @@ namespace TOHE.Roles.Impostor public static void Add(byte playerId) { - playerIdList.Add(playerId); + mastermindId = playerId; ManipulateCD = KillCooldown.GetFloat() + TimeLimit.GetFloat() + Delay.GetFloat(); } - public static bool IsEnable => playerIdList.Count > 0; + public static bool IsEnable => mastermindId != byte.MaxValue; public static bool OnCheckMurder(PlayerControl killer, PlayerControl target) { @@ -92,8 +94,7 @@ namespace TOHE.Roles.Impostor pc.SetKillCooldown(time: 1f); } - PlayerControl mastermind = GetPlayerById(playerIdList[0]); - NotifyRoles(SpecifySeer: mastermind, SpecifyTarget: mastermind); + NotifyRoles(SpecifySeer: Mastermind_, SpecifyTarget: Mastermind_); } } @@ -111,10 +112,8 @@ namespace TOHE.Roles.Impostor { ManipulatedPlayers.Remove(x.Key); TempKCDs.Remove(x.Key); - player.SetRealKiller(GetPlayerById(playerIdList[0])); - Main.PlayerStates[x.Key].deathReason = PlayerState.DeathReason.Suicide; - player.Kill(player); - RPC.PlaySoundRPC(playerIdList[0], Sounds.KillSound); + player.Suicide(PlayerState.DeathReason.Suicide, Mastermind_); + RPC.PlaySoundRPC(mastermindId, Sounds.KillSound); } var time = TimeLimit.GetInt() - (GetTimeStamp() - x.Value); @@ -129,12 +128,7 @@ namespace TOHE.Roles.Impostor foreach (var x in ManipulatedPlayers) { var pc = GetPlayerById(x.Key); - if (pc.IsAlive()) - { - pc.SetRealKiller(GetPlayerById(playerIdList[0])); - Main.PlayerStates[pc.PlayerId].deathReason = PlayerState.DeathReason.Suicide; - pc.Kill(pc); - } + if (pc.IsAlive()) pc.Suicide(PlayerState.DeathReason.Suicide, Mastermind_); } ManipulateDelays.Clear(); ManipulatedPlayers.Clear(); @@ -187,9 +181,8 @@ namespace TOHE.Roles.Impostor private static void NotifyMastermindTargetSurvived() { if (!IsEnable) return; - var mastermind = GetPlayerById(playerIdList[0]); - mastermind.Notify(GetString("ManipulatedKilled")); - if (mastermind.killTimer > KillCooldown.GetFloat()) mastermind.SetKillCooldown(time: KillCooldown.GetFloat()); + Mastermind_.Notify(GetString("ManipulatedKilled")); + if (Mastermind_.killTimer > KillCooldown.GetFloat()) Mastermind_.SetKillCooldown(time: KillCooldown.GetFloat()); } } } diff --git a/Roles/Impostor/Penguin.cs b/Roles/Impostor/Penguin.cs index 6059b38a3..18819c00d 100644 --- a/Roles/Impostor/Penguin.cs +++ b/Roles/Impostor/Penguin.cs @@ -51,7 +51,7 @@ namespace TOHE.Roles.Impostor public static void ApplyGameOptions(IGameOptions opt) => AURoleOptions.ShapeshifterCooldown = AbductVictim != null ? AbductTimer : AbductTimerLimit; private static void SendRPC() { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.PenguinSync, SendOption.Reliable, -1); writer.Write(AbductVictim?.PlayerId ?? 255); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Impostor/QuickShooter.cs b/Roles/Impostor/QuickShooter.cs index b5a6c0b41..ae8beb686 100644 --- a/Roles/Impostor/QuickShooter.cs +++ b/Roles/Impostor/QuickShooter.cs @@ -39,6 +39,7 @@ internal static class QuickShooter public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetQuickShooterShotLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(ShotLimit[playerId]); diff --git a/Roles/Impostor/Sniper.cs b/Roles/Impostor/Sniper.cs index 789132773..b9f4f9fda 100644 --- a/Roles/Impostor/Sniper.cs +++ b/Roles/Impostor/Sniper.cs @@ -81,6 +81,7 @@ public static class Sniper public static bool IsThisRole(byte playerId) => PlayerIdList.Contains(playerId); public static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; Logger.Info($"Player{playerId}:SendRPC", "Sniper"); MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SniperSync, SendOption.Reliable, -1); writer.Write(playerId); diff --git a/Roles/Impostor/Swooper.cs b/Roles/Impostor/Swooper.cs index e10ee9496..5f76d25a4 100644 --- a/Roles/Impostor/Swooper.cs +++ b/Roles/Impostor/Swooper.cs @@ -57,7 +57,7 @@ public static class Swooper public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(PlayerControl pc) { - if (pc.AmOwner) return; + if (!IsEnable || !Utils.DoRPC || pc.AmOwner) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetSwooperTimer, SendOption.Reliable, pc.GetClientId()); writer.Write((InvisTime.TryGetValue(pc.PlayerId, out var x) ? x : -1).ToString()); writer.Write((lastTime.TryGetValue(pc.PlayerId, out var y) ? y : -1).ToString()); diff --git a/Roles/Impostor/Undertaker.cs b/Roles/Impostor/Undertaker.cs index 8c0c33d61..49a00de82 100644 --- a/Roles/Impostor/Undertaker.cs +++ b/Roles/Impostor/Undertaker.cs @@ -40,6 +40,7 @@ internal static class Undertaker public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetMarkedPlayerV2, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(MarkedPlayer.ContainsKey(playerId) ? MarkedPlayer[playerId] : byte.MaxValue); @@ -98,17 +99,19 @@ internal static class Undertaker if (MarkedPlayer.ContainsKey(pc.PlayerId)) { var target = Utils.GetPlayerById(MarkedPlayer[pc.PlayerId]); - MarkedPlayer.Remove(pc.PlayerId); - SendRPC(pc.PlayerId); _ = new LateTask(() => { if (!(target == null || !target.IsAlive() || Pelican.IsEaten(target.PlayerId) || target.inVent || !GameStates.IsInTask)) { target.TP(new UnityEngine.Vector2(pc.transform.position.x, pc.transform.position.y + 0.3636f)); - pc.ResetKillCooldown(); - pc.SyncSettings(); - pc.SetKillCooldown(); - pc.RpcCheckAndMurder(target); + if (pc.RpcCheckAndMurder(target)) + { + MarkedPlayer.Remove(pc.PlayerId); + SendRPC(pc.PlayerId); + pc.ResetKillCooldown(); + pc.SyncSettings(); + pc.SetKillCooldown(); + } } }, UsePets.GetBool() ? 0.1f : 0.2f, "Undertaker Assassinate"); } diff --git a/Roles/Impostor/Wildling.cs b/Roles/Impostor/Wildling.cs index 0a78bb252..dccd6e067 100644 --- a/Roles/Impostor/Wildling.cs +++ b/Roles/Impostor/Wildling.cs @@ -47,6 +47,7 @@ public static class Wildling public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBKTimer, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(TimeStamp[playerId].ToString()); diff --git a/Roles/Impostor/Witch.cs b/Roles/Impostor/Witch.cs index 30ccf0409..2189c5f97 100644 --- a/Roles/Impostor/Witch.cs +++ b/Roles/Impostor/Witch.cs @@ -56,6 +56,7 @@ public static class Witch public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(bool doSpell, byte witchId, byte target = 255) { + if (!IsEnable || !Utils.DoRPC) return; if (doSpell) { MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DoSpell, SendOption.Reliable, -1); diff --git a/Roles/Impostor/YinYanger.cs b/Roles/Impostor/YinYanger.cs index 30c1d0bdd..8867ea79f 100644 --- a/Roles/Impostor/YinYanger.cs +++ b/Roles/Impostor/YinYanger.cs @@ -47,7 +47,7 @@ namespace TOHE.Roles.Impostor public static void SendRPC(bool isClear, byte playerId = byte.MaxValue) { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncYinYanger, SendOption.Reliable, -1); writer.Write(isClear); if (!isClear) writer.Write(playerId); diff --git a/Roles/Neutral/Amnesiac.cs b/Roles/Neutral/Amnesiac.cs index 26f4f2f09..527b7c0f6 100644 --- a/Roles/Neutral/Amnesiac.cs +++ b/Roles/Neutral/Amnesiac.cs @@ -379,28 +379,7 @@ public static class Amnesiac public static bool CanBeRememberedBloodKnight(this PlayerControl pc) => pc != null && pc.Is(CustomRoles.BloodKnight); public static bool KnowRole(PlayerControl player, PlayerControl target) { - if (player.Is(CustomRoles.Infectious) && target.Is(CustomRoles.Infectious)) return true; - if (player.Is(CustomRoles.Glitch) && target.Is(CustomRoles.Glitch)) return true; - if (player.Is(CustomRoles.Wraith) && target.Is(CustomRoles.Wraith)) return true; - if (player.Is(CustomRoles.Medusa) && target.Is(CustomRoles.Medusa)) return true; - if (player.Is(CustomRoles.Pelican) && target.Is(CustomRoles.Pelican)) return true; - if (player.Is(CustomRoles.Refugee) && target.Is(CustomRoles.Refugee)) return true; - if (player.Is(CustomRoles.Parasite) && target.Is(CustomRoles.Parasite)) return true; - if (player.Is(CustomRoles.NSerialKiller) && target.Is(CustomRoles.NSerialKiller)) return true; - if (player.Is(CustomRoles.PlagueDoctor) && target.Is(CustomRoles.PlagueDoctor)) return true; - if (player.Is(CustomRoles.Magician) && target.Is(CustomRoles.Magician)) return true; - if (player.Is(CustomRoles.WeaponMaster) && target.Is(CustomRoles.WeaponMaster)) return true; - if (player.Is(CustomRoles.Reckless) && target.Is(CustomRoles.Reckless)) return true; - if (player.Is(CustomRoles.Eclipse) && target.Is(CustomRoles.Eclipse)) return true; - if (player.Is(CustomRoles.Pyromaniac) && target.Is(CustomRoles.Pyromaniac)) return true; - if (player.Is(CustomRoles.Imitator) && target.Is(CustomRoles.Imitator)) return true; - if (player.Is(CustomRoles.Werewolf) && target.Is(CustomRoles.Werewolf)) return true; - if (player.Is(CustomRoles.Pickpocket) && target.Is(CustomRoles.Pickpocket)) return true; - if (player.Is(CustomRoles.Traitor) && target.Is(CustomRoles.Traitor)) return true; - if (player.Is(CustomRoles.Virus) && target.Is(CustomRoles.Virus)) return true; - if (player.Is(CustomRoles.Spiritcaller) && target.Is(CustomRoles.Spiritcaller)) return true; - if (player.Is(CustomRoles.Succubus) && target.Is(CustomRoles.Succubus)) return true; - if (player.Is(CustomRoles.Poisoner) && target.Is(CustomRoles.Poisoner)) return true; + if (player.IsNeutralKiller() && target.IsNeutralKiller() && player.GetCustomRole() == target.GetCustomRole()) return true; if (player.Is(CustomRoles.Refugee) && target.Is(CustomRoleTypes.Impostor)) return true; if (player.Is(CustomRoleTypes.Impostor) && target.Is(CustomRoles.Refugee)) return true; return false; diff --git a/Roles/Neutral/Bandit.cs b/Roles/Neutral/Bandit.cs index f5e0e0a01..e7b8d5e9c 100644 --- a/Roles/Neutral/Bandit.cs +++ b/Roles/Neutral/Bandit.cs @@ -64,7 +64,8 @@ public static class Bandit public static void ApplyGameOptions(IGameOptions opt) => opt.SetVision(HasImpostorVision.GetBool()); private static void SendRPC(byte playerId/*, bool isTargetList = false*/) - { + { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBanditStealLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(TotalSteals[playerId]); diff --git a/Roles/Neutral/BloodKnight.cs b/Roles/Neutral/BloodKnight.cs index 2fab7b972..5a8b3b77c 100644 --- a/Roles/Neutral/BloodKnight.cs +++ b/Roles/Neutral/BloodKnight.cs @@ -46,6 +46,7 @@ public static class BloodKnight public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBKTimer, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(TimeStamp[playerId].ToString()); diff --git a/Roles/Neutral/Collector.cs b/Roles/Neutral/Collector.cs index a2b1b3dea..149450813 100644 --- a/Roles/Neutral/Collector.cs +++ b/Roles/Neutral/Collector.cs @@ -32,6 +32,7 @@ public static class Collector public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCollectorVotes, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(CollectVote[playerId]); diff --git a/Roles/Neutral/CursedSoul.cs b/Roles/Neutral/CursedSoul.cs index bcad0cef8..373d7025d 100644 --- a/Roles/Neutral/CursedSoul.cs +++ b/Roles/Neutral/CursedSoul.cs @@ -51,6 +51,7 @@ public static class CursedSoul private static void SendRPC() { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetCursedSoulCurseLimit, SendOption.Reliable, -1); writer.Write(CurseLimit); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Neutral/DarkHide.cs b/Roles/Neutral/DarkHide.cs index 57458791f..5002f782d 100644 --- a/Roles/Neutral/DarkHide.cs +++ b/Roles/Neutral/DarkHide.cs @@ -64,7 +64,7 @@ public static class DarkHide } public static void DRpcSetKillCount(this PlayerControl player) { - if (!AmongUsClient.Instance.AmHost) return; + if (!IsEnable || !Utils.DoRPC || !AmongUsClient.Instance.AmHost) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDarkHiderKillCount, SendOption.Reliable, -1); writer.Write(player.PlayerId); writer.Write(IsWinKill[player.PlayerId]); diff --git a/Roles/Neutral/Doomsayer.cs b/Roles/Neutral/Doomsayer.cs index 81754aef6..ee9a7e7be 100644 --- a/Roles/Neutral/Doomsayer.cs +++ b/Roles/Neutral/Doomsayer.cs @@ -75,8 +75,8 @@ public static class Doomsayer public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC(PlayerControl player) { - MessageWriter writer; - writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDoomsayerProgress, SendOption.Reliable, -1); + if (!IsEnable || !Utils.DoRPC) return; + MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDoomsayerProgress, SendOption.Reliable, -1); writer.Write(player.PlayerId); AmongUsClient.Instance.FinishRpcImmediately(writer); } diff --git a/Roles/Neutral/Doppelganger.cs b/Roles/Neutral/Doppelganger.cs index 944c22ece..07311942b 100644 --- a/Roles/Neutral/Doppelganger.cs +++ b/Roles/Neutral/Doppelganger.cs @@ -50,7 +50,7 @@ public static class Doppelganger private static void SendRPC(byte playerId, bool isTargetList = false) { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetDoppelgangerStealLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(TotalSteals[playerId]); diff --git a/Roles/Neutral/Eclipse.cs b/Roles/Neutral/Eclipse.cs index bbeec1ee5..1207aa4e1 100644 --- a/Roles/Neutral/Eclipse.cs +++ b/Roles/Neutral/Eclipse.cs @@ -52,6 +52,7 @@ public static class Eclipse public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC(float vision) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetEclipseVision, SendOption.Reliable, -1); writer.Write(vision); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -80,7 +81,7 @@ public static class Eclipse if (Vision != currentVision) { SendRPC(Vision); - pc.SyncSettings(); + pc.MarkDirtySettings(); } } } diff --git a/Roles/Neutral/Executioner.cs b/Roles/Neutral/Executioner.cs index c587ed4cd..d91a69a3a 100644 --- a/Roles/Neutral/Executioner.cs +++ b/Roles/Neutral/Executioner.cs @@ -98,6 +98,7 @@ public static class Executioner public static bool IsEnable() => playerIdList.Count > 0; public static void SendRPC(byte executionerId, byte targetId = 0x73, string Progress = "") { + if (!IsEnable() || !Utils.DoRPC) return; MessageWriter writer; switch (Progress) { diff --git a/Roles/Neutral/Gamer.cs b/Roles/Neutral/Gamer.cs index 11c35cbdd..9ea5ea393 100644 --- a/Roles/Neutral/Gamer.cs +++ b/Roles/Neutral/Gamer.cs @@ -69,6 +69,7 @@ public static class Gamer } private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetGamerHealth, SendOption.Reliable, -1); writer.Write(playerId); if (GamerHealth.ContainsKey(playerId)) diff --git a/Roles/Neutral/Glitch.cs b/Roles/Neutral/Glitch.cs index 9faade8e7..c5c643014 100644 --- a/Roles/Neutral/Glitch.cs +++ b/Roles/Neutral/Glitch.cs @@ -93,6 +93,7 @@ public static class Glitch public static bool IsEnable => playerIdList.Count > 0; public static void SendRPCSyncTimers(int mimicCDTimer, int mimicDurTimer, int hackCDTimer, int KCDTimer) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncGlitchTimers, SendOption.Reliable, -1); writer.Write(mimicCDTimer); writer.Write(mimicDurTimer); @@ -102,6 +103,7 @@ public static class Glitch } public static void SendRPCSyncMimic(int mimicCDTimer, int mimicDurTimer, long lastMimic) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncGlitchMimic, SendOption.Reliable, -1); writer.Write(mimicCDTimer); writer.Write(mimicDurTimer); @@ -110,6 +112,7 @@ public static class Glitch } public static void SendRPCSyncLongs(long lastKill, long lastHack, long lastMimic) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncGlitchLongs, SendOption.Reliable, -1); writer.Write(lastKill); writer.Write(lastHack); @@ -118,6 +121,7 @@ public static class Glitch } public static void SendRPCSyncKill(long lastKill, int KCDtimer) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncGlitchKill, SendOption.Reliable, -1); writer.Write(lastKill); writer.Write(KCDtimer); @@ -125,6 +129,7 @@ public static class Glitch } public static void SendRPCSyncHack(long lastHack, int hackCDTimer) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncGlitchHack, SendOption.Reliable, -1); writer.Write(lastHack); writer.Write(hackCDTimer); @@ -132,6 +137,7 @@ public static class Glitch } public static void SendRPCSyncSS(bool isShifted) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncGlitchSS, SendOption.Reliable, -1); writer.Write(isShifted); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Neutral/HexMaster.cs b/Roles/Neutral/HexMaster.cs index 7361a4388..effad1207 100644 --- a/Roles/Neutral/HexMaster.cs +++ b/Roles/Neutral/HexMaster.cs @@ -65,6 +65,7 @@ public static class HexMaster public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(bool doHex, byte hexId, byte target = 255) { + if (!IsEnable || !Utils.DoRPC) return; if (doHex) { MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.DoHex, SendOption.Reliable, -1); diff --git a/Roles/Neutral/Imitator.cs b/Roles/Neutral/Imitator.cs index f83c8df05..83e29d38e 100644 --- a/Roles/Neutral/Imitator.cs +++ b/Roles/Neutral/Imitator.cs @@ -49,6 +49,7 @@ public static class Imitator private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetImitatorOE, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(IsOdd[playerId]); diff --git a/Roles/Neutral/Infectious.cs b/Roles/Neutral/Infectious.cs index 78f974591..d6dc3ceaf 100644 --- a/Roles/Neutral/Infectious.cs +++ b/Roles/Neutral/Infectious.cs @@ -56,6 +56,7 @@ public static class Infectious public static bool IsEnable => playerIdList.Count > 0; //private static void SendRPC() //{ + // if (!IsEnable || !Utils.DoRPC) return; // MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetInfectiousBiteLimit, SendOption.Reliable, -1); // writer.Write(BiteLimit); // AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Neutral/Jackal.cs b/Roles/Neutral/Jackal.cs index 9c175afd4..6fb53d4f4 100644 --- a/Roles/Neutral/Jackal.cs +++ b/Roles/Neutral/Jackal.cs @@ -90,6 +90,7 @@ public static class Jackal private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetJackalRecruitLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(RecruitLimit[playerId]); diff --git a/Roles/Neutral/Lawyer.cs b/Roles/Neutral/Lawyer.cs index 547eef129..206f17e59 100644 --- a/Roles/Neutral/Lawyer.cs +++ b/Roles/Neutral/Lawyer.cs @@ -101,6 +101,7 @@ public static class Lawyer public static bool IsEnable() => playerIdList.Count > 0; public static void SendRPC(byte lawyerId, byte targetId = 0x73, string Progress = "") { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer; switch (Progress) { diff --git a/Roles/Neutral/Pelican.cs b/Roles/Neutral/Pelican.cs index a0e969908..a78d6aa8e 100644 --- a/Roles/Neutral/Pelican.cs +++ b/Roles/Neutral/Pelican.cs @@ -42,6 +42,7 @@ public static class Pelican } private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetPelicanEtenNum, SendOption.Reliable, -1); writer.Write(playerId); if (playerId != byte.MaxValue) diff --git a/Roles/Neutral/PlagueBearer.cs b/Roles/Neutral/PlagueBearer.cs index 53f8bb4db..f027ddcfd 100644 --- a/Roles/Neutral/PlagueBearer.cs +++ b/Roles/Neutral/PlagueBearer.cs @@ -59,6 +59,7 @@ public static class PlagueBearer public static bool IsPlagued(byte pc, byte target) => PlaguedList.TryGetValue(pc, out var x) && x.Contains(target); public static void SendRPC(PlayerControl player, PlayerControl target) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer; writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.setPlaguedPlayer, SendOption.Reliable, -1);//RPCによる同期 writer.Write(player.PlayerId); diff --git a/Roles/Neutral/PlagueDoctor.cs b/Roles/Neutral/PlagueDoctor.cs index 0f191d399..2106c50e4 100644 --- a/Roles/Neutral/PlagueDoctor.cs +++ b/Roles/Neutral/PlagueDoctor.cs @@ -103,7 +103,7 @@ namespace TOHE.Roles.Neutral } public static void SendRPC(byte targetId, float rate) { - if (!IsEnable) return; + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncPlagueDoctor, SendOption.Reliable, -1); writer.Write(targetId); writer.Write(rate); diff --git a/Roles/Neutral/Pursuer.cs b/Roles/Neutral/Pursuer.cs index ed1392e70..2be1e698f 100644 --- a/Roles/Neutral/Pursuer.cs +++ b/Roles/Neutral/Pursuer.cs @@ -42,6 +42,7 @@ public static class Pursuer public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetPursuerSellLimit, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(SeelLimit[playerId]); diff --git a/Roles/Neutral/Ritualist.cs b/Roles/Neutral/Ritualist.cs index fbaf8d2d7..8be5e8a6c 100644 --- a/Roles/Neutral/Ritualist.cs +++ b/Roles/Neutral/Ritualist.cs @@ -53,6 +53,7 @@ namespace TOHE.Roles.Neutral private static void SendRPC(byte playerId, byte targetId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetRitualist, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(RitualCount[playerId]); diff --git a/Roles/Neutral/Romantic.cs b/Roles/Neutral/Romantic.cs index c48eefaee..5135a9092 100644 --- a/Roles/Neutral/Romantic.cs +++ b/Roles/Neutral/Romantic.cs @@ -69,6 +69,7 @@ public static class Romantic public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncRomanticTarget, SendOption.Reliable, -1); writer.Write(playerId); //writer.Write(BetTimes.TryGetValue(playerId, out var times) ? times : MaxBetTimes); @@ -280,6 +281,7 @@ public static class VengefulRomantic } public static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncVengefulRomanticTarget, SendOption.Reliable, -1); writer.Write(playerId); //writer.Write(BetTimes.TryGetValue(playerId, out var times) ? times : MaxBetTimes); diff --git a/Roles/Neutral/Spiritcaller.cs b/Roles/Neutral/Spiritcaller.cs index 3d172a760..44bc8d8a6 100644 --- a/Roles/Neutral/Spiritcaller.cs +++ b/Roles/Neutral/Spiritcaller.cs @@ -73,6 +73,7 @@ namespace TOHE.Roles.Neutral private static void SendRPC() { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetSpiritcallerSpiritLimit, SendOption.Reliable, -1); writer.Write(SpiritLimit); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Neutral/Succubus.cs b/Roles/Neutral/Succubus.cs index 4ed42cba3..a4a83ef3a 100644 --- a/Roles/Neutral/Succubus.cs +++ b/Roles/Neutral/Succubus.cs @@ -61,6 +61,7 @@ public static class Succubus private static void SendRPC() { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetSuccubusCharmLimit, SendOption.Reliable, -1); writer.Write(CharmLimit); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Neutral/Totocalcio.cs b/Roles/Neutral/Totocalcio.cs index 91f0279a5..42f9a7994 100644 --- a/Roles/Neutral/Totocalcio.cs +++ b/Roles/Neutral/Totocalcio.cs @@ -56,6 +56,7 @@ public static class Totocalcio public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(byte playerId) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncTotocalcioTargetAndTimes, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(BetTimes.TryGetValue(playerId, out var times) ? times : MaxBetTimes.GetInt()); diff --git a/Roles/Neutral/Vengeance.cs b/Roles/Neutral/Vengeance.cs index a34afe612..caacb6be2 100644 --- a/Roles/Neutral/Vengeance.cs +++ b/Roles/Neutral/Vengeance.cs @@ -54,6 +54,7 @@ public static class Vengeance public static bool IsEnable => playerIdList.Count > 0; public static void SendRPCSyncTimer(int timer) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncVengeanceTimer, SendOption.Reliable, -1); writer.Write(timer); AmongUsClient.Instance.FinishRpcImmediately(writer); @@ -66,6 +67,7 @@ public static class Vengeance } public static void SendRPC(bool isRevenge, bool success, byte killer, float tempKillTimer) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SyncVengeanceData, SendOption.Reliable, -1); writer.Write(isRevenge); writer.Write(success); diff --git a/Roles/Neutral/Virus.cs b/Roles/Neutral/Virus.cs index 2c0633cf3..7ef530980 100644 --- a/Roles/Neutral/Virus.cs +++ b/Roles/Neutral/Virus.cs @@ -66,6 +66,7 @@ namespace TOHE.Roles.Neutral private static void SendRPC() { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetVirusInfectLimit, SendOption.Reliable, -1); writer.Write(InfectLimit); AmongUsClient.Instance.FinishRpcImmediately(writer); diff --git a/Roles/Neutral/Vulture.cs b/Roles/Neutral/Vulture.cs index 984472abf..68b7a2df0 100644 --- a/Roles/Neutral/Vulture.cs +++ b/Roles/Neutral/Vulture.cs @@ -67,6 +67,7 @@ public static class Vulture private static void SendRPC(byte playerId, bool add, Vector3 loc = new()) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetVultureArrow, SendOption.Reliable, -1); writer.Write(playerId); writer.Write(add); diff --git a/Roles/Neutral/WeaponMaster.cs b/Roles/Neutral/WeaponMaster.cs index c0363ca69..b8ff7ca77 100644 --- a/Roles/Neutral/WeaponMaster.cs +++ b/Roles/Neutral/WeaponMaster.cs @@ -57,6 +57,7 @@ public static class WeaponMaster public static bool IsEnable => playerIdList.Count > 0; public static void SendRPC(byte mode, bool shieldUsed) { + if (!IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetWeaponMasterMode, SendOption.Reliable, -1); writer.Write(mode); writer.Write(shieldUsed); diff --git a/Roles/Neutral/Werewolf.cs b/Roles/Neutral/Werewolf.cs index 4803bc498..286f66807 100644 --- a/Roles/Neutral/Werewolf.cs +++ b/Roles/Neutral/Werewolf.cs @@ -53,7 +53,7 @@ public static class Werewolf public static void ApplyGameOptions(IGameOptions opt) => opt.SetVision(HasImpostorVision.GetBool()); private static void SendRPC(PlayerControl pc) { - if (pc.AmOwner) return; + if (pc.AmOwner || !IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetWWTimer, SendOption.Reliable, pc.GetClientId()); writer.Write((RampageTime.TryGetValue(pc.PlayerId, out var x) ? x : -1).ToString()); writer.Write((lastTime.TryGetValue(pc.PlayerId, out var y) ? y : -1).ToString()); diff --git a/Roles/Neutral/Wraith.cs b/Roles/Neutral/Wraith.cs index ffbe92d32..824357e52 100644 --- a/Roles/Neutral/Wraith.cs +++ b/Roles/Neutral/Wraith.cs @@ -52,7 +52,7 @@ public static class Wraith public static bool IsEnable => playerIdList.Count > 0; private static void SendRPC(PlayerControl pc) { - if (pc.AmOwner) return; + if (pc.AmOwner || !IsEnable || !Utils.DoRPC) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetWraithTimer, SendOption.Reliable, pc.GetClientId()); writer.Write((InvisTime.TryGetValue(pc.PlayerId, out var x) ? x : -1).ToString()); writer.Write((lastTime.TryGetValue(pc.PlayerId, out var y) ? y : -1).ToString());