设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 59|回复: 0

[转载发布] Custom Game Over behavior

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    7959

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    29925
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    38778

    灌水之王

    发表于 3 天前 | 显示全部楼层 |阅读模式

    Custom Game Over

    Version 1.3.2

    by McKathlin


    Introduction
        Change what happens when the party dies or an event calls Game Over processing.

        In some games, after the party dies they find themselves in a recently visited safe place, where they can continue their game with all experience and progress intact, but some money or items lost. With Custom Game Over, you can have party death cause something similar to that, or something completely different!

    Features

    • New: Set a common event to run when the party dies, before the fade to game over.
    • Choose whether or not the Game Over Screen shows first.
    • Choose whether to reload from the last save.
    • Set a common event to run after game over, instead of going back to the title screen.
    How to Use
        Download or copy this plugin, and save it inside your project's js\plugins folder as Kath_GameOver.js -- The filename is important, because the plugin manager refers to it when retrieving the plugin parameters. Add and enable it in the plugin manager, as you would with any other plugin. It should function properly regardless of where it's placed in the plugin list.

        This plugin offers parameters that accept common events by their ID. First create a common event in the database, take note of its ID, then go to the plugin manager and enter that ID number for the value of the common event parameter you would like to set.

        Your Party Death Common Event will run in the same scene that the party dies, in place of a standard Game Over. If the party dies in battle, then this common event will play out in battle, unless the common event explicitly calls a scene change command (such as the Game Over command).

        Your After Game Over Common Event can do practically anything you want. The default post-Game-Over state is dark and silent to provide a blank slate for the common event to work from. At minimum, you'll need to make sure that your After Game Over Common Event includes the following commands:

    • Transfer Player
    • Fadein Screen
        Everything else you add is up to you.

    Full Help Text

    Spoiler                Code:       
    1. This plugin is designed to play well by itself and with other plugins.
    2. There are no known conflicts, but conflict is possible with other plugins
    3. that directly alter Game Over behavior.
    4. ================================
    5. = Party Death Common Event ID  =
    6. ================================
    7. Assigning a Party Death Common Event replaces the usual Game Over scene
    8. call with a common event call. This lets you (the game designer) make
    9. something happen instead of (or before) the standard Game Over screen.
    10. Open the database to Common Events to find the ID of the common event
    11. to call on party death, and enter this ID number as the parameter.
    12. Here are some pointers:
    13. * The Party Death common event will run in the same scene where the party
    14.   was just defeated. If the party died in battle, the common event will run
    15.   in battle, right after the party-is-defeated message and music effect.
    16.   So if you want to make something happen after a slow fadeout
    17.   and return to the map, I recommend using the After Game Over Common Event
    18.   instead.
    19. * Using the Abort Battle command in your Party Death Common Event will
    20.   interfere with scene control, so do not use the Abort Battle command
    21.   in a Party Death Common Event that also uses the Game Over command.
    22. * If you would like the Game Over screen (or a fadeout and cut to the map
    23.   if "Show Game Over Scene" is false) to show at the end of your common
    24.   event, remember to use the Game Over command in your common event.
    25.   Avoiding the Game Over screen is easy: avoid calling the Game Over command.
    26. * Directly calling the Game Over command from any event will still show
    27.   the Game Over screen normally (unless you've set Show Game Over Scene to
    28.   false). To force your custom party death behavior, use a command that
    29.   calls your party death common event instead.
    30. =========================
    31. = Show Game Over Scene  =
    32. =========================
    33. RPG Maker's default behavior takes the player to Scene_GameOver on
    34. party death or on a scene processing call to Scene_GameOver.
    35. This processing shows a Game Over screen.
    36. After the player sees the screen and presses any key,
    37. the game exits to the title screen.
    38. If Show Game Over Scene is set to false, player will see a fade to black
    39. before going to the next scene. This will be the case regardless of whether
    40. Game Over state is reached by party death or by a direct command in an event.
    41. Whether or not the Game Over screen shows, which scene is next depends on
    42. whether the After Game Over Common Event is set, and what it is set to.
    43. ====================
    44. = Reload Last Save =
    45. ====================
    46. Set Reload Last Save to true to make the game automatically reload from its
    47. most recent save on game over. If a Game Over Common Event is specified,
    48. the reload occurs before the common event is reserved. If no common event
    49. is given, then the reload happens instead of going to the title screen.
    50. If Reload Last Save is true but the player has not yet saved,
    51. then the player is returned to the Title Screen.
    52. ====================================
    53. = After Game Over Common Event ID  =
    54. ====================================
    55. Assigning a After Game Over common event makes gameplay continue after
    56. the party loses, instead of RPG Maker's default behavior of returning the
    57. party to the title screen. Open the database to Common Events to find the
    58. ID of the common event to call on game over, and enter this ID number as
    59. the parameter.
    60. In the content of the common event, the game designer can customize what
    61. happens when the party dies or reaches an event-dictated Game Over state.
    62. The After Game Over common event might do some of the following things:
    63. * Take away gold and/or items
    64. * Return the player to a safe place
    65. * Restore HP to one or more party members
    66. * Have the party's rescuer say something
    67. * ...anything that suits this game!
    68. IMPORTANT: When control flows to the Game Over common event,
    69. the screen will start blacked out. This gives the event time to handle
    70. transfers and other processing before showing the player the screen.
    71. Once those things are ready, remember to fade in!
    72. The After Game Over Common Event (AGOCE) differs from the Party Death Common
    73. Event (PDCE) in the following ways:
    74. * The PDCE runs instead of or before the Game Over screen or fadeout;
    75.   the AGOCE runs after the Game Over scene or fadeout completes.
    76. * The PDCE only automatically replaces Game Overs caused by party death.
    77.   The AGOCE autoruns after all Game Overs, regardless of their cause.
    78. * The PDCE runs in the same scene where party death occurred.
    79.   The AGOCE runs in a newly started map scene, with the screen faded to
    80.   black, and the party leader revived to 1 HP.
    复制代码







    Script

    Spoiler                Code:       
    1. //=============================================================================
    2. // Custom Game Over, version 1.3.2
    3. // by McKathlin
    4. // Kath_GameOver.js
    5. // Last Update: 2024-10-07
    6. //=============================================================================
    7. /*:
    8. * @plugindesc Change what happens when the party dies or Game Over is called.
    9. *
    10. * @param Party Death Common Event ID
    11. * @desc The ID of the common event to run as soon as the party dies.
    12. * Leave blank to fade immediately to Game Over.
    13. * @default
    14. *
    15. * @param Show Game Over Scene
    16. * @desc Whether to show Scene_Gameover. If false, only a brief fade to black is seen.
    17. * @default true
    18. *
    19. * @param Reload Last Save
    20. * @desc If true, reload from last save instead of title screen,
    21. * or before common event, if any.
    22. * @default false
    23. *
    24. * @param After Game Over Common Event ID
    25. * @desc The ID of the common event to run AFTER the Game Over scene (or fadeout).
    26. * Leave blank to go to title.
    27. * @default
    28. *
    29. * @help This plugin is designed to play well by itself and with other plugins.
    30. * There are no known conflicts, but conflict is possible with other plugins
    31. * that directly alter Game Over behavior.
    32. *
    33. * ================================
    34. * = Party Death Common Event ID  =
    35. * ================================
    36. * Assigning a Party Death Common Event replaces the usual Game Over scene
    37. * call with a common event call. This lets you (the game designer) make
    38. * something happen instead of (or before) the standard Game Over screen.
    39. * Open the database to Common Events to find the ID of the common event
    40. * to call on party death, and enter this ID number as the parameter.
    41. * Here are some pointers:
    42. * * The Party Death common event will run in the same scene where the party
    43. *   was just defeated. If the party died in battle, the common event will run
    44. *   in battle, right after the party-is-defeated message and music effect.
    45. *   So if you want to make something happen after a slow fadeout
    46. *   and return to the map, I recommend using the After Game Over Common Event
    47. *   instead.
    48. * * Using the Abort Battle command in your Party Death Common Event will
    49. *   interfere with scene control, so do not use the Abort Battle command
    50. *   in a Party Death Common Event that also uses the Game Over command.
    51. * * If you would like the Game Over screen (or a fadeout and cut to the map
    52. *   if "Show Game Over Scene" is false) to show at the end of your common
    53. *   event, remember to use the Game Over command in your common event.
    54. *   Avoiding the Game Over screen is easy: avoid calling the Game Over command.
    55. * * Directly calling the Game Over command from any event will still show
    56. *   the Game Over screen normally (unless you've set Show Game Over Scene to
    57. *   false). To force your custom party death behavior, use a command that
    58. *   calls your party death common event instead.
    59. *
    60. * =========================
    61. * = Show Game Over Scene  =
    62. * =========================)
    63. * RPG Maker's default behavior takes the player to Scene_GameOver on
    64. * party death or on a scene processing call to Scene_GameOver.
    65. * This processing shows a Game Over screen.
    66. * After the player sees the screen and presses any key,
    67. * the game exits to the title screen.
    68. *
    69. * If Show Game Over Scene is set to false, player will see a fade to black
    70. * before going to the next scene. This will be the case regardless of whether
    71. * Game Over state is reached by party death or by a direct command in an event.
    72. *
    73. * Whether or not the Game Over screen shows, which scene is next depends on
    74. * whether the After Game Over Common Event is set, and what it is set to.
    75. *
    76. * ====================
    77. * = Reload Last Save =
    78. * ====================
    79. * Set Reload Last Save to true to make the game automatically reload from its
    80. * most recent save on game over. If a Game Over Common Event is specified,
    81. * the reload occurs before the common event is reserved. If no common event
    82. * is given, then the reload happens instead of going to the title screen.
    83. *
    84. * If Reload Last Save is true but the player has not yet saved,
    85. * then the player is returned to the Title Screen.
    86. *
    87. * ====================================
    88. * = After Game Over Common Event ID  =
    89. * ====================================
    90. * Assigning a After Game Over common event makes gameplay continue after
    91. * the party loses, instead of RPG Maker's default behavior of returning the
    92. * party to the title screen. Open the database to Common Events to find the
    93. * ID of the common event to call on game over, and enter this ID number as
    94. * the parameter.
    95. *
    96. * In the content of the common event, the game designer can customize what
    97. * happens when the party dies or reaches an event-dictated Game Over state.
    98. * The After Game Over common event might do some of the following things:
    99. * * Take away gold and/or items
    100. * * Return the player to a safe place
    101. * * Restore HP to one or more party members
    102. * * Have the party's rescuer say something
    103. * * ...anything that suits this game!
    104. *
    105. * IMPORTANT: When control flows to the Game Over common event,
    106. * the screen will start blacked out. This gives the event time to handle
    107. * transfers and other processing before showing the player the screen.
    108. * Once those things are ready, remember to fade in!
    109. *
    110. * The After Game Over Common Event (AGOCE) differs from the Party Death Common
    111. * Event (PDCE) in the following ways:
    112. * * The PDCE runs instead of or before the Game Over screen or fadeout;
    113. *   the AGOCE runs after the Game Over scene or fadeout completes.
    114. * * The PDCE only automatically replaces Game Overs caused by party death.
    115. *   The AGOCE autoruns after all Game Overs, regardless of their cause.
    116. * * The PDCE runs in the same scene where party death occurred.
    117. *   The AGOCE runs in a newly started map scene, with the screen faded to
    118. *   black, and the party leader revived to 1 HP.
    119. */
    120. var Imported = Imported || {};
    121. Imported.Kath_GameOver = true;
    122. //=============================================================================
    123. // Helper method: parseBoolean
    124. //=============================================================================
    125. var Kath = Kath || {};
    126. Kath.Core = Kath.Core || {};
    127. // Convert a user-entered string into a Boolean true or false value.
    128. Kath.Core.parseBoolean = function(parameter, defaultValue) {
    129.     switch (String(parameter).trim().toLowerCase()) {
    130.         case 'true':
    131.         case 't':
    132.         case 'yes':
    133.         case 'y':
    134.         case 'on':
    135.         case '1':
    136.             return true;
    137.         case 'false':
    138.         case 'f':
    139.         case 'no':
    140.         case 'n':
    141.         case 'off':
    142.         case '0':
    143.             return false;
    144.         default:
    145.             return defaultValue;
    146.     } // end switch
    147. };
    148. //=============================================================================
    149. // Parameters and Constants
    150. //=============================================================================
    151. Kath.Parameters = PluginManager.parameters('Kath_GameOver');
    152. Kath.Param = Kath.Param || {};
    153. Kath.Param.PartyDeathCommonEventID =
    154.     Number.parseInt(Kath.Parameters['Party Death Common Event ID']);
    155. Kath.Param.ShowGameOverScene =
    156.     Kath.Core.parseBoolean(Kath.Parameters['Show Game Over Scene'], true);
    157. Kath.Param.ReloadLastSave =
    158.     Kath.Core.parseBoolean(Kath.Parameters['Reload Last Save'], false);
    159. Kath.Param.AfterGameOverCommonEventID =
    160.     Number.parseInt(Kath.Parameters['After Game Over Common Event ID']);
    161. Kath.GameOver = {};
    162. Kath.GameOver.RELOAD_FADE_DELAY = 60;
    163. //=============================================================================
    164. // Party death common event
    165. //=============================================================================
    166. // Replacement method
    167. // Like original, but with handling added for Party Death Common Event case.
    168. BattleManager.processDefeat = function() {
    169.     this.displayDefeatMessage();
    170.     this.playDefeatMe();
    171.     if (this._canLose) {
    172.         this.replayBgmAndBgs();
    173.         this.endBattle(2);
    174.     } else {
    175.         AudioManager.stopBgm();
    176.         if (Kath.Param.PartyDeathCommonEventID) {
    177.             $gameParty.reviveLeader();
    178.             $gameTemp.reserveCommonEvent(Kath.Param.PartyDeathCommonEventID);
    179.             $gameTroop.setupBattleEvent(); // Run the reserved common event.
    180.             // the battle doesn't end here in this case,
    181.             // unless a scene control command ends it in the common event.
    182.         } else {
    183.             this.endBattle(2);
    184.         }
    185.     }
    186. };
    187. // replacement method
    188. Scene_Base.prototype.checkGameover = function() {
    189.     if ($gameParty.isAllDead()) {
    190.         if (Kath.Param.PartyDeathCommonEventID) {
    191.             $gameParty.reviveLeader();
    192.             $gameTemp.reserveCommonEvent(Kath.Param.PartyDeathCommonEventID);
    193.         } else {
    194.             SceneManager.goto(Scene_Gameover);
    195.         }
    196.     }
    197. };
    198. Game_Party.prototype.reviveLeader = function() {
    199.     if ($gameParty.isAllDead()) {
    200.         $gameParty.leader().setHp(1);
    201.         $gameParty.leader().clearStates();
    202.     }
    203. };
    204. //=============================================================================
    205. // Skip Game Over Scene
    206. // Redefine several methods of Scene_GameOver
    207. // so that it skips straight to the next scene.
    208. //=============================================================================
    209. if (!Kath.Param.ShowGameOverScene) {
    210.     Scene_Gameover.prototype.create = function() {
    211.         Scene_Base.prototype.create.call(this);
    212.         //this.playGameoverMusic(); // No music.
    213.         this.createBackground();
    214.     };
    215.     Scene_Gameover.prototype.start = function() {
    216.         Scene_Base.prototype.start.call(this);
    217.         //this.startFadeIn(this.slowFadeSpeed(), false); // No fadein.
    218.     };
    219.     Scene_Gameover.prototype.update = function() {
    220.         // Do not require a trigger.
    221.         if (this.isActive() && !this.isBusy()) {
    222.             this.gotoTitle();
    223.         }
    224.         Scene_Base.prototype.update.call(this);
    225.     };
    226.     Scene_Gameover.prototype.createBackground = function() {
    227.         // Load image to avoid potential conflicts.
    228.         this._backSprite = new Sprite();
    229.         this._backSprite.bitmap = ImageManager.loadSystem('GameOver');
    230.         //this.addChild(this._backSprite); // But don't show it!
    231.     };
    232. }
    233. // new method
    234. Kath.GameOver.findPostGameOverSceneClass = function() {
    235.     if (Kath.Param.ReloadLastSave) {
    236.         if (DataManager.isThisGameFile(DataManager.lastAccessedSavefileId())) {
    237.             return Scene_Map;
    238.         } else {
    239.             return Scene_Title;
    240.         }
    241.     } else if (Kath.Param.AfterGameOverCommonEventID) {
    242.         return Scene_Map;
    243.     } else {
    244.         return Scene_Title;
    245.     }
    246. };
    247. //=============================================================================
    248. // After-Game-Over behavior. This includes reload last save, if called for.
    249. //=============================================================================
    250. if (Kath.Param.ReloadLastSave) {
    251.     // extended method
    252.     Kath.GameOver.Scene_Gameover_gotoTitle = Scene_Gameover.prototype.gotoTitle;
    253.     Scene_Gameover.prototype.gotoTitle = function() {
    254.         var saveId = DataManager.lastAccessedSavefileId();
    255.         if (!DataManager.isThisGameFile(saveId)) {
    256.             // This game hasn't been saved yet. Go to the title screen.
    257.             return Kath.GameOver.Scene_Gameover_gotoTitle.call(this);
    258.         }
    259.         DataManager.loadGame(saveId);
    260.         $gamePlayer.requestMapReload();
    261.         $gameScreen.startFadeOut(1); // start next scene blacked out
    262.         if (Kath.Param.AfterGameOverCommonEventID > 0) {
    263.             $gameTemp.reserveCommonEvent(Kath.Param.AfterGameOverCommonEventID);
    264.             SceneManager.goto(Scene_Map);
    265.         } else {
    266.             SceneManager.goto(Scene_Map);
    267.             // Transfer to where we are, to set BGM, map fadein, etc.
    268.             $gamePlayer.reserveTransfer($gameMap.mapId(),
    269.                 $gamePlayer.x, $gamePlayer.y, $gamePlayer.direction(), 0);
    270.             $gameScreen.startFadeIn(this.slowFadeSpeed());
    271.         }
    272.     };
    273. } else if (Kath.Param.AfterGameOverCommonEventID > 0) {
    274.     // replacement method
    275.     Scene_Gameover.prototype.gotoTitle = function() {
    276.         $gameScreen.startFadeOut(1); // start next scene blacked out
    277.         $gameParty.reviveLeader();
    278.         $gameTemp.reserveCommonEvent(Kath.Param.AfterGameOverCommonEventID);
    279.         SceneManager.goto(Scene_Map);
    280.     };
    281. }
    复制代码






    Download here: Kath_GameOver.js

    Version History
    Version 1.0.1
    - Minor edits to Version 1.0, mostly in help text.

    Version 1.0.2 - Show/Skip Game Over Screen bugfix attempted, but found to cause the game to freeze on some machines.

    Version 1.0.3 - Show/Skip Game Over Screen feature removed for now.

    Version 1.1 - Show/Skip Game Over Screen feature is back. The bug appears to be fixed.

    Version 1.2 - New parameter allows you to reload data from the player's last save

    Version 1.3 - Set the Party Death Common Event to customize what happens before (or instead of!) the Game Over fadeout.

    Version 1.3.2 - Added a note to the help text to avoid using "Abort Battle" and "Game Over" commands in the same Party Death Common Event.

    FAQ

    Q:
    I've set a common event to occur after Game Over, but when I try it, the screen stays black and I can't see anything. Help!
    A: After Game Over, the screen starts out faded to black to give the After Game Over Common Event a chance to handle transfers and other "behind-the-scenes" processing before showing the screen. To get rid of the blackness, make sure to run a "Fade In" command as part of your After Game Over Common Event.

    Q: My game lets the player continue exactly where they left off after they die. But when they continue, the music for the map they're in doesn't autoplay like it's supposed to. Is this a bug, or do I need to do something differently?
    A: This is not a bug. The silence gives the Game Over common event a chance to run its course without being interrupted by the BGM of the map where the player died. A transfer will cause the music of the destination to autoplay. Though you don't need the player to go anywhere, transferring the player to where they already are will fix your music problem. Here's how to do it:

    • At the start of your Game Over common event, use the Control Variables command three times to assign three variables: the player's current map ID, X coordinate, and Y coordinate.
    • Place a Player Transfer command at the part of the event when the map's BGM should start playing.
    • As always, remember to use a Fadein Screen command!  (The fade that accompanies the Player Transfer command won't cut it.)
    Terms of Use
        This plugin is free for all use, including commercial use. Please credit me (McKathlin) where appropriate. Sending me a free copy of your completed game is encouraged but not required.


    本贴来自国际rpgmaker官方论坛作者:McKathlin处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/custom-game-over-behavior.55072/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-1 02:37 , Processed in 0.081024 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表