From 3cdd99f57e801d813a62214bff49f9d8f4526293 Mon Sep 17 00:00:00 2001 From: ivan tkachenko Date: Mon, 6 Apr 2026 07:36:34 +0300 Subject: [PATCH] When player dies, check for nearby Jester music source to show Game Over text --- CHANGELOG.md | 2 +- MuzikaGromche/DeathScreenManager.cs | 26 ++++++++++++++++++++++++++ MuzikaGromche/Plugin.cs | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df1f9c0..7c380f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ - Added lyrics to the existing track HighLow. - New random track will be selected every time instead of having the same track all day. - Groupped tracks (verses of the same song) are still played together in a sequence. -- Don't reset overridden Game Over text prematurely at the end of round. +- Override Death Screen / Game Over text in more cases. - Attempted to fix issue when Jester wouldn't select any track after the first one. ## MuzikaGromche 1337.9001.68 - LocalHost hotfix diff --git a/MuzikaGromche/DeathScreenManager.cs b/MuzikaGromche/DeathScreenManager.cs index 1dbfa40..554004c 100644 --- a/MuzikaGromche/DeathScreenManager.cs +++ b/MuzikaGromche/DeathScreenManager.cs @@ -1,4 +1,5 @@ using System.Collections; +using GameNetcodeStuff; using HarmonyLib; using TMPro; using UnityEngine; @@ -73,4 +74,29 @@ namespace MuzikaGromche DeathScreenGameOverTextManager.Clear(); } } + + [HarmonyPatch(typeof(PlayerControllerB))] + static class PlayerControllerBKillPlayerPatch + { + // Use prefix to test distance from listener before the listener is reassigned + [HarmonyPatch(nameof(PlayerControllerB.KillPlayer))] + [HarmonyPrefix] + static void KillPlayerPrefix(PlayerControllerB __instance) + { + if (__instance.IsOwner && !__instance.isPlayerDead && __instance.AllowPlayerDeath()) + { + // KILL LOCAL PLAYER + var list = Object.FindObjectsByType(FindObjectsInactive.Exclude, FindObjectsSortMode.None); + foreach (var jester in list) + { + if (jester.TryGetComponent(out var behaviour) && + behaviour.IsPlaying && Plugin.LocalPlayerCanHearMusic(jester)) + { + behaviour.OverrideDeathScreenGameOverText(); + break; + } + } + } + } + } } diff --git a/MuzikaGromche/Plugin.cs b/MuzikaGromche/Plugin.cs index 0e44520..2ba28a3 100644 --- a/MuzikaGromche/Plugin.cs +++ b/MuzikaGromche/Plugin.cs @@ -162,6 +162,7 @@ namespace MuzikaGromche Harmony.PatchAll(typeof(DiscoBallDespawnPatch)); Harmony.PatchAll(typeof(SpawnRatePatch)); Harmony.PatchAll(typeof(DeathScreenGameOverTextResetPatch)); + Harmony.PatchAll(typeof(PlayerControllerBKillPlayerPatch)); Harmony.PatchAll(typeof(ScreenFiltersManager.HUDManagerScreenFiltersPatch)); Harmony.PatchAll(typeof(ClearAudioClipCachePatch)); NetcodePatcher();