MV Is there a plugin that allows me to change the Game Over screen ME throughout the game? (MV)

Hello, I made a couple different game over themes for my game and I was wondering if it was possible to have the game use a different one depending on how far you are in the game (so like with a plugin command that changes it or a script or something that checks if a switch is on or a variable is at a certain number)

I think it's kinda weird that a plugin like this doesn't exist yet, is it just not possible to do?

Other posts I've found that have asked the same but didn't find a solution: https://forums.rpgmakerweb.com/index.php?threads/change-game-over-music.163881/

(The closest I've gotten to getting this to work is by using SumRndmDde's Game Over Core and having it run a comment event as the Game Over screen starts that plays a different song (using BGM or SE because ME is overridden by the one that tries to be played even if i set it to (none) in System) depending on if certain switches are activated, but the way it works causes pictures to stay over the game over image and i can only erase them either before the fadein to black starts (which just leaves the player without that picture until its done) or having it happen after the Game Over screen has fully faded in (which feels weird since the fade in is entirely gone.)
I did find an event command to change the Defeat ME, so it's just a matter of building a Common Event to make the changes at chosen points during the game.
I did find an event command to change the Defeat ME, so it's just a matter of building a Common Event to make the changes at chosen points during the game.
Yeahh but the Defeat ME refers to the jingle that plays when you lose a battle, not on the Game Over screen sadly (like on the battle screen when it says you lost it plays the Defeat ME, theres also the one for when you win and that's the Victory ME, you can change those mid game but not the Game Over one)
I haven't tested, but here~
Spoiler: plugin code v1
JavaScript:
/*:
 * @target MV MZ
 * @plugindesc Change gameover ME mid-playthrough.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/177248/
 * @help In a Script field:
 *
 *   • Set the gameover ME to "Fanfare.ogg":
 *     $gameSystem.customGameoverMe = "Fanfare";
 *
 *   • Reset the gameover ME to its default:
 *     delete $gameSystem.customGameoverMe;
 *
 * Free to use and/or modify for any project, no credit required.
 */
;void (function() {
"use strict";

  /** Identifier for new, optional property on `Game_System`. @type {string} */
  const P = "customGameoverMe";

  // Patch - play custom gameover ME as appropriate.
  const alias = Scene_Gameover.prototype.playGameoverMusic;
  Scene_Gameover.prototype.playGameoverMusic = function() {
    // Memorise current ME.
    const a = $gameSystem[P];
    const m = a ? $dataSystem.gameoverMe : null;
    // Apply custom ME.
    if (m)
      $dataSystem.gameoverMe = a;
    // Play gameover music as usual.
    alias.apply(this, arguments);
    // Restore previous ME.
    if (m)
      $dataSystem.gameoverMe = m;
  };

})();

Edit - oops, I was replacing the ME object with a string instead of changing its name. 😴 Attempted correction (replace 3 instances of $dataSystem.gameoverMe with $dataSystem.gameoverMe.name):
Spoiler: plugin code v2
JavaScript:
/*:
 * @target MV MZ
 * @plugindesc Change gameover ME mid-playthrough.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/177248/
 * @help In a Script field:
 *
 *   • Set the gameover ME to "Fanfare.ogg":
 *     $gameSystem.customGameoverMe = "Fanfare";
 *
 *   • Reset the gameover ME to its default:
 *     delete $gameSystem.customGameoverMe;
 *
 * Free to use and/or modify for any project, no credit required.
 */
;void (function() {
"use strict";

  /** Identifier for new, optional property on `Game_System`. @type {string} */
  const P = "customGameoverMe";

  // Patch - play custom gameover ME as appropriate.
  const alias = Scene_Gameover.prototype.playGameoverMusic;
  Scene_Gameover.prototype.playGameoverMusic = function() {
    // Memorise current ME.
    const a = $gameSystem[P];
    const m = a ? $dataSystem.gameoverMe.name : null;
    // Apply custom ME.
    if (m)
      $dataSystem.gameoverMe.name = a;
    // Play gameover music as usual.
    alias.apply(this, arguments);
    // Restore previous ME.
    if (m)
      $dataSystem.gameoverMe.name = m;
  };

})();
I haven't tested, but here~
Oh thanks I really appreciate it! Though I thinkk it doesn't work yet for some reason, using the script makes it play nothing for me at the moment (unless there's something i'm doing wrong)
I threw my own version of this together for you.

DL and try this and see if it helps.
LINK - Pastebin
I threw my own version of this together for you.

DL and try this and see if it helps.
LINK - Pastebin
Thanks! However it seems to return this error whenever I launch the game with it on
1745741217285.png

Does the same on a new empty game with no other plugins too
1745741285339.png
Sorry about that.

It was a quick fix, tho.
Please redownload and try it again.

Thanks
Sorry about that.

It was a quick fix, tho.
Please redownload and try it again.

Thanks
Works perfectly fine now, thanks a lot!

I haven't tested, but here~
Works great too now! Thanks a bunch!

Original thread: https://forums.rpgmakerweb.com/threads/is-there-a-plugin-that-allows-me-to-change-the-game-over-screen-me-throughout-the-game-mv.177248/