From 9be8253fc8f65dd2c30fd6f6e1811961ff2815c9 Mon Sep 17 00:00:00 2001 From: CCraigen Date: Thu, 14 Mar 2024 22:45:50 -0500 Subject: [PATCH] Cancels spawn invuln with TB charge. Also tweaks some of the windows in the packet loss meter. --- GameMod/MPPacketStatus.cs | 15 ++++++++------- GameMod/MPSpawnInvuln.cs | 13 +++++++++++++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/GameMod/MPPacketStatus.cs b/GameMod/MPPacketStatus.cs index 021ec9bc..bbaccab2 100644 --- a/GameMod/MPPacketStatus.cs +++ b/GameMod/MPPacketStatus.cs @@ -12,7 +12,7 @@ public static class MPPacketStatus { // do yourself a favour and make sure that holdTime is a multiple of sampleTime public const int sampleTime = 1; // sample window size in seconds - public const int holdTime = 10; // length of time to hold a visible loss value on-screen + public const int holdTime = 5; // length of time to hold a visible loss value on-screen public const int holdSize = holdTime / sampleTime; // array size for the stats arrays @@ -60,10 +60,11 @@ public static void UpdateStatus() running = true; if (Time.unscaledTime >= shortUpdate) { - int loss = NetworkTransport.GetOutgoingPacketNetworkLossPercent(connection.hostId, connection.connectionId, out _); - int drop = NetworkTransport.GetOutgoingPacketOverflowLossPercent(connection.hostId, connection.connectionId, out _); + //int loss = NetworkTransport.GetOutgoingPacketNetworkLossPercent(connection.hostId, connection.connectionId, out _); + //int drop = NetworkTransport.GetOutgoingPacketOverflowLossPercent(connection.hostId, connection.connectionId, out _); //outErr = Math.Max(loss + drop, outErr); // this one keeps the max 1/4-second recorded value - outErr += loss + drop; // this one is for the average over the sampleTime + //outErr += loss + drop; // this one is for the average over the sampleTime + outErr += NetworkTransport.GetOutgoingPacketNetworkLossPercent(connection.hostId, connection.connectionId, out _); shortUpdate = Time.unscaledTime + 0.25f; } @@ -91,8 +92,8 @@ public static void UpdateStatus() OutStatus = Math.Max(OutStatus, outStats[i]); } - InColor = Color.Lerp(UIManager.m_col_good_ping, UIManager.m_col_em5, InStatus / 10f); // 10f since anything over 0% is bad, if you're at 10% it's terrible - OutColor = Color.Lerp(UIManager.m_col_good_ping, UIManager.m_col_em5, OutStatus / 10f); + InColor = Color.Lerp(UIManager.m_col_good_ping, UIManager.m_col_em5, InStatus / 20f); // 20f since anything over 0% is bad, if you're at 20% it's terrible + OutColor = Color.Lerp(UIManager.m_col_good_ping, UIManager.m_col_em5, OutStatus / 20f); if (InStatus > InMin) { @@ -131,7 +132,7 @@ public static void UpdateStatus() } } - [HarmonyPatch(typeof(Client), "Update")] + [HarmonyPatch(typeof(Client), "FixedUpdate")] class MPPacketStatus_Client_Update { static void Postfix() diff --git a/GameMod/MPSpawnInvuln.cs b/GameMod/MPSpawnInvuln.cs index 811c05a2..46c41ca8 100644 --- a/GameMod/MPSpawnInvuln.cs +++ b/GameMod/MPSpawnInvuln.cs @@ -26,4 +26,17 @@ static IEnumerable Transpiler(IEnumerable code } } } + + // Cancels spawn invuln if a player starts charging Thunderbolt + [HarmonyPatch(typeof(PlayerShip), "ThunderCharge")] + internal class MPSpawnInvuln_PlayerShip_ThunderCharge + { + static void Postfix(Player ___c_player) + { + if (GameplayManager.IsMultiplayerActive && ___c_player.m_spawn_invul_active) + { + ___c_player.m_timer_invuln = (float)___c_player.m_timer_invuln - (float)NetworkMatch.m_respawn_shield_seconds; + } + } + } } \ No newline at end of file