From 841c50410347e8bd93c38f72b81e415adb97e024 Mon Sep 17 00:00:00 2001 From: Gurge44 Date: Sun, 23 Aug 2026 13:25:49 +0200 Subject: [PATCH] fix --- Gamemodes/SoloPVP.cs | 29 ++++++++++++++++------------- Patches/HudPatch.cs | 30 +++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/Gamemodes/SoloPVP.cs b/Gamemodes/SoloPVP.cs index bf780624f..9f2ba3c86 100644 --- a/Gamemodes/SoloPVP.cs +++ b/Gamemodes/SoloPVP.cs @@ -110,19 +110,22 @@ internal static class SoloPVP }, 3f); Utils.SendRPC(CustomRPC.SoloPVPSync, 1); - foreach (PlayerControl pc in Main.CachedAlivePlayerControls()) + foreach (PlayerControl pc in Main.EnumeratePlayerControls()) { - PlayerHPMax.TryAdd(pc.PlayerId, SoloPVP_HPMax.GetFloat()); - PlayerHP.TryAdd(pc.PlayerId, SoloPVP_HPMax.GetFloat()); - PlayerHPReco.TryAdd(pc.PlayerId, SoloPVP_RecoverPerSecond.GetFloat()); - PlayerATK.TryAdd(pc.PlayerId, SoloPVP_ATK.GetFloat()); - PlayerDF.TryAdd(pc.PlayerId, 0f); - - PlayerScore.TryAdd(pc.PlayerId, 0); - Utils.SendRPC(CustomRPC.SoloPVPSync, 2, pc.PlayerId, 0); - - LastHurt.TryAdd(pc.PlayerId, Utils.TimeStamp); - LastCountdownTime.TryAdd(pc.PlayerId, Utils.TimeStamp); + try + { + PlayerHPMax.TryAdd(pc.PlayerId, SoloPVP_HPMax.GetFloat()); + PlayerHP.TryAdd(pc.PlayerId, SoloPVP_HPMax.GetFloat()); + PlayerHPReco.TryAdd(pc.PlayerId, SoloPVP_RecoverPerSecond.GetFloat()); + PlayerATK.TryAdd(pc.PlayerId, SoloPVP_ATK.GetFloat()); + PlayerDF.TryAdd(pc.PlayerId, 0f); + PlayerScore.TryAdd(pc.PlayerId, 0); + LastHurt.TryAdd(pc.PlayerId, Utils.TimeStamp); + LastCountdownTime.TryAdd(pc.PlayerId, Utils.TimeStamp); + + Utils.SendRPC(CustomRPC.SoloPVPSync, 2, pc.PlayerId, 0); + } + catch (Exception e) { Utils.ThrowException(e); } } } @@ -342,7 +345,7 @@ internal static class SoloPVP if (!GameStates.IsInTask || ExileController.Instance || !Main.IntroDestroyed || Options.CurrentGameMode != CustomGameMode.SoloPVP || !AmongUsClient.Instance.AmHost || id >= 254) return; long now = Utils.TimeStamp; - if (LastCountdownTime[id] == now) return; + if (!LastCountdownTime.TryGetValue(id, out long ts) || ts == now) return; LastCountdownTime[id] = now; if (LastHurt[id] + SoloPVP_RecoverAfterSecond.GetInt() < now && PlayerHP[id] < PlayerHPMax[id] && __instance.SoloAlive() && !__instance.inVent) diff --git a/Patches/HudPatch.cs b/Patches/HudPatch.cs index 740a3cbc2..bf0abcb17 100644 --- a/Patches/HudPatch.cs +++ b/Patches/HudPatch.cs @@ -1273,13 +1273,29 @@ internal static class TaskPanelBehaviourPatch { byte playerId = player.PlayerId; - FinalTextBuilder.Append("\r\n\r\n") - .Append(GetString("PVP.ATK")).Append(": ").Append(SoloPVP.PlayerATK[playerId].ToString("N1")) - .Append("\r\n") - .Append(GetString("PVP.DF")).Append(": ").Append(SoloPVP.PlayerDF[playerId].ToString("N1")) - .Append("\r\n") - .Append(GetString("PVP.RCO")).Append(": ").Append(SoloPVP.PlayerHPReco[playerId].ToString("N1")) - .Append("\r\n").Append(""); + FinalTextBuilder.Append('\r'); + FinalTextBuilder.Append('\n'); + FinalTextBuilder.Append('\r'); + FinalTextBuilder.Append('\n'); + FinalTextBuilder.Append(GetString("PVP.ATK")); + FinalTextBuilder.Append(':'); + FinalTextBuilder.Append(' '); + FinalTextBuilder.Append(SoloPVP.PlayerATK.GetValueOrDefault(playerId).ToString("N1")); + FinalTextBuilder.Append('\r'); + FinalTextBuilder.Append('\n'); + FinalTextBuilder.Append(GetString("PVP.DF")); + FinalTextBuilder.Append(':'); + FinalTextBuilder.Append(' '); + FinalTextBuilder.Append(SoloPVP.PlayerDF.GetValueOrDefault(playerId).ToString("N1")); + FinalTextBuilder.Append('\r'); + FinalTextBuilder.Append('\n'); + FinalTextBuilder.Append(GetString("PVP.RCO")); + FinalTextBuilder.Append(':'); + FinalTextBuilder.Append(' '); + FinalTextBuilder.Append(SoloPVP.PlayerHPReco.GetValueOrDefault(playerId).ToString("N1")); + FinalTextBuilder.Append('\r'); + FinalTextBuilder.Append('\n'); + FinalTextBuilder.Append(""); SortedPlayers.Clear(); foreach (var key in playerStates.Keys)