//============================================================================= // Custom Game Over, version 1.2 (dev) // by McKathlin // Kath_GameOver.js // Last Update: 2016.02.26 //============================================================================= /*: * @plugindesc Change what happens when the party dies or Game Over is called. * * @param Show Game Over Scene * @desc Whether to show Scene_Gameover. If false, only a brief fade to black * is seen. * @default true * * @param Game Over Common Event ID * @desc The ID of the common event to run after (or instead of) * the Game Over scene. Leave blank for default game over behavior. * @default * * @param Reload Last Save * @desc If true, reload from last save instead of title screen, or before * the common event, if any. * @default false * * @help This plugin is designed to play well by itself and with other plugins. * There are no known conflicts, but conflict is possible with other plugins * that directly alter the Game Over scene. * * ========================= * = Show Game Over Scene = * ========================= * RPG Maker's default behavior takes the player to Scene_GameOver on * party death or on a scene processing call to Scene_GameOver. * This processing shows a Game Over screen. * After the player sees the screen and presses any key, * the game exits to the title screen. * * If Show Game Over Scene is set to false, control will technically flow * to Scene_GameOver, but the player will only notice a brief fade to black * before the next scene loads. * * Whether or not the Game Over screen shows, which scene is next depends on * whether the Game Over Common Event is set, and what it is set to. * * ============================== * = Game Over Common Event ID = * ============================== * Assigning a Game Over common event makes gameplay continue after * the party loses, instead of RPG Maker's default behavior of returning the * party to the title screen. Open the database to Common Events to find the * ID of the common event to call on game over, and enter this ID number as * the parameter. * * In the content of the common event, the game designer can customize what * happens when the party dies or reaches an event-dictated Game Over state. * The Game Over common event might do some of the following things: * * Take away gold and/or items * * Return the player to a safe place * * Restore HP to one or more party members * * Have the party's rescuer say something * * ...anything that suits this game! * * IMPORTANT: When control flows to the Game Over common event, * the screen will start blacked out. This gives the event time to handle * transfers and other processing before showing the player the screen. * Once those things are ready, remember to fade in! * * ==================== * = Reload Last Save = * ==================== * Set Reload Last Save to true to make the game automatically reload from its * most recent save on game over. If a Game Over Common Event is specified, * the reload occurs before the common event is reserved. If no common event * is given, then the reload happens instead of going to the title screen. * * If Reload Last Save is true but the player has not yet saved, * then the player is returned to the Title Screen. */ var Imported = Imported || {}; Imported.Kath_GameOver = true; //============================================================================= // Helper method: parseBoolean //============================================================================= var Kath = Kath || {}; Kath.Core = Kath.Core || {}; Kath.GameOver = {}; // Convert a user-entered string into a Boolean true or false value. Kath.Core.parseBoolean = function(parameter, defaultValue) { switch (String(parameter).trim().toLowerCase()) { case 'true': case 't': case 'yes': case 'y': case 'on': case '1': return true; case 'false': case 'f': case 'no': case 'n': case 'off': case '0': return false; default: return defaultValue; } // end switch }; //============================================================================= // Parameter Init //============================================================================= Kath.Parameters = PluginManager.parameters('Kath_GameOver'); Kath.Param = Kath.Param || {}; Kath.Param.ShowGameOverScene = Kath.Core.parseBoolean(Kath.Parameters['Show Game Over Scene'], true); Kath.Param.GameOverCommonEventID = Number.parseInt(Kath.Parameters['Game Over Common Event ID']); Kath.Param.ReloadLastSave = Kath.Core.parseBoolean(Kath.Parameters['Reload Last Save'], false); //============================================================================= // Skip Game Over Scene // Redefine several methods of Scene_GameOver // so that it skips straight to the next scene. //============================================================================= if (!Kath.Param.ShowGameOverScene) { Scene_Gameover.prototype.create = function() { Scene_Base.prototype.create.call(this); //this.playGameoverMusic(); // No music. this.createBackground(); }; Scene_Gameover.prototype.start = function() { Scene_Base.prototype.start.call(this); //this.startFadeIn(this.slowFadeSpeed(), false); // No fadein. }; Scene_Gameover.prototype.update = function() { // Do not require a trigger. if (this.isActive() && !this.isBusy()) { this.gotoTitle(); } Scene_Base.prototype.update.call(this); }; Scene_Gameover.prototype.createBackground = function() { // Load image to avoid potential conflicts. this._backSprite = new Sprite(); this._backSprite.bitmap = ImageManager.loadSystem('GameOver'); //this.addChild(this._backSprite); // But don't show it! }; } //============================================================================= // Change post-GameOver behavior //============================================================================= Kath.GameOver.Scene_Gameover_gotoTitle = Scene_Gameover.prototype.gotoTitle; if (Kath.Param.ReloadLastSave) { Scene_Gameover.prototype.gotoTitle = function() { var saveId = DataManager.lastAccessedSavefileId(); if (!DataManager.isThisGameFile(saveId)) { // This game hasn't been saved yet. Go to the title screen. return Kath.GameOver.Scene_Gameover_gotoTitle.call(this); } DataManager.loadGame(saveId); $gamePlayer.requestMapReload(); $gameScreen.startFadeOut(1); // instant if (Kath.Param.GameOverCommonEventID > 0) { $gameTemp.reserveCommonEvent(Kath.Param.GameOverCommonEventID); SceneManager.goto(Scene_Map); } else { SceneManager.goto(Scene_Map); $gamePlayer.reserveTransfer($gameMap.mapId(), $gamePlayer.x, $gamePlayer.y); $gameScreen.startFadeIn(30); } }; } else if (Kath.Param.GameOverCommonEventID > 0) { Scene_Gameover.prototype.gotoTitle = function() { $gameScreen.startFadeOut(1); // instant $gameParty.reviveBattleMembers(); $gameTemp.reserveCommonEvent(Kath.Param.GameOverCommonEventID); SceneManager.goto(Scene_Map); }; }