-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMcKathlin_GameOver.js
349 lines (328 loc) · 14.7 KB
/
McKathlin_GameOver.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
//=============================================================================
// Custom Game Over, version 1.3
// by McKathlin
// McKathlin_GameOver.js
//=============================================================================
/*
* MIT License
*
* Copyright (c) 2023 Kathy Bunn and Scott Tyrus Washburn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*:
* @plugindesc MV v1.3.1 Change what happens when the party dies or Game Over is called.
*
* @param Party Death Common Event ID
* @desc The ID of the common event to run as soon as the party dies.
* Leave blank to fade immediately to Game Over.
* @default
*
* @param Show Game Over Scene
* @desc Whether to show Scene_Gameover. If false, only a brief fade to black is seen.
* @default true
*
* @param Reload Last Save
* @desc If true, reload from last save instead of title screen,
* or before common event, if any.
* @default false
*
* @param After Game Over Common Event ID
* @desc The ID of the common event to run AFTER the Game Over scene (or fadeout).
* Leave blank to go to title.
* @default
*
* @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 Game Over behavior.
*
* ================================
* = Party Death Common Event ID =
* ================================
* Assigning a Party Death Common Event replaces the usual Game Over scene
* call with a common event call. This lets you (the game designer) make
* something happen instead of (or before) the standard Game Over screen.
* Open the database to Common Events to find the ID of the common event
* to call on party death, and enter this ID number as the parameter.
* Here are some pointers:
* * The Party Death common event will run in the same scene where the party
* was just defeated. If the party died in battle, the common event will run
* in battle, right after the party-is-defeated message and music effect.
* So if you want to make something happen after a slow fadeout
* and return to the map, I recommend using the After Game Over Common Event
* instead.
* * Using the Abort Battle command in your Party Death Common Event will
* interfere with scene control, so do not use the Abort Battle command
* in a Party Death Common Event that also uses the Game Over command.
* * If you would like the Game Over screen (or a fadeout and cut to the map
* if "Show Game Over Scene" is false) to show at the end of your common
* event, remember to use the Game Over command in your common event.
* Avoiding the Game Over screen is easy: avoid calling the Game Over command.
* * Directly calling the Game Over command from any event will still show
* the Game Over screen normally (unless you've set Show Game Over Scene to
* false). To force your custom party death behavior, use a command that
* calls your party death common event instead.
*
* =========================
* = 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, player will see a fade to black
* before going to the next scene. This will be the case regardless of whether
* Game Over state is reached by party death or by a direct command in an event.
*
* Whether or not the Game Over screen shows, which scene is next depends on
* whether the After Game Over Common Event is set, and what it is set to.
*
* ====================
* = 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.
*
* ====================================
* = After Game Over Common Event ID =
* ====================================
* Assigning a After 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 After 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!
*
* The After Game Over Common Event (AGOCE) differs from the Party Death Common
* Event (PDCE) in the following ways:
* * The PDCE runs instead of or before the Game Over screen or fadeout;
* the AGOCE runs after the Game Over scene or fadeout completes.
* * The PDCE only automatically replaces Game Overs caused by party death.
* The AGOCE autoruns after all Game Overs, regardless of their cause.
* * The PDCE runs in the same scene where party death occurred.
* The AGOCE runs in a newly started map scene, with the screen faded to
* black, and the party leader revived to 1 HP.
*
* ============================================================================
* Visit Tyruswoo.com to ask for help, donate, or browse more of our plugins.
* ============================================================================
* MIT License
*
* Copyright (c) 2023 Kathy Bunn and Scott Tyrus Washburn
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the “Software”), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
var Imported = Imported || {};
Imported.McKathlin_GameOver = true;
//=============================================================================
// Helper method: parseBoolean
//=============================================================================
var McKathlin = McKathlin || {};
McKathlin.Core = McKathlin.Core || {};
// Convert a user-entered string into a Boolean true or false value.
McKathlin.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
};
//=============================================================================
// Parameters and Constants
//=============================================================================
McKathlin.Parameters = PluginManager.parameters('Kath_GameOver');
McKathlin.Param = McKathlin.Param || {};
McKathlin.Param.PartyDeathCommonEventID =
Number.parseInt(McKathlin.Parameters['Party Death Common Event ID']);
McKathlin.Param.ShowGameOverScene =
McKathlin.Core.parseBoolean(McKathlin.Parameters['Show Game Over Scene'], true);
McKathlin.Param.ReloadLastSave =
McKathlin.Core.parseBoolean(McKathlin.Parameters['Reload Last Save'], false);
McKathlin.Param.AfterGameOverCommonEventID =
Number.parseInt(McKathlin.Parameters['After Game Over Common Event ID']);
McKathlin.GameOver = {};
McKathlin.GameOver.RELOAD_FADE_DELAY = 60;
//=============================================================================
// Party death common event
//=============================================================================
// Replacement method
// Like original, but with handling added for Party Death Common Event case.
BattleManager.processDefeat = function() {
this.displayDefeatMessage();
this.playDefeatMe();
if (this._canLose) {
this.replayBgmAndBgs();
this.endBattle(2);
} else {
AudioManager.stopBgm();
if (McKathlin.Param.PartyDeathCommonEventID) {
$gameParty.reviveLeader();
$gameTemp.reserveCommonEvent(McKathlin.Param.PartyDeathCommonEventID);
$gameTroop.setupBattleEvent(); // Run the reserved common event.
// the battle doesn't end here in this case,
// unless a scene control command ends it in the common event.
} else {
this.endBattle(2);
}
}
};
// replacement method
Scene_Base.prototype.checkGameover = function() {
if ($gameParty.isAllDead()) {
if (McKathlin.Param.PartyDeathCommonEventID) {
$gameParty.reviveLeader();
$gameTemp.reserveCommonEvent(McKathlin.Param.PartyDeathCommonEventID);
} else {
SceneManager.goto(Scene_Gameover);
}
}
};
Game_Party.prototype.reviveLeader = function() {
if ($gameParty.isAllDead()) {
$gameParty.leader().setHp(1);
$gameParty.leader().clearStates();
}
};
//=============================================================================
// Skip Game Over Scene
// Redefine several methods of Scene_GameOver
// so that it skips straight to the next scene.
//=============================================================================
if (!McKathlin.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!
};
}
// new method
McKathlin.GameOver.findPostGameOverSceneClass = function() {
if (McKathlin.Param.ReloadLastSave) {
if (DataManager.isThisGameFile(DataManager.lastAccessedSavefileId())) {
return Scene_Map;
} else {
return Scene_Title;
}
} else if (McKathlin.Param.AfterGameOverCommonEventID) {
return Scene_Map;
} else {
return Scene_Title;
}
};
//=============================================================================
// After-Game-Over behavior. This includes reload last save, if called for.
//=============================================================================
if (McKathlin.Param.ReloadLastSave) {
// extended method
McKathlin.GameOver.Scene_Gameover_gotoTitle = Scene_Gameover.prototype.gotoTitle;
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 McKathlin.GameOver.Scene_Gameover_gotoTitle.call(this);
}
DataManager.loadGame(saveId);
$gamePlayer.requestMapReload();
$gameScreen.startFadeOut(1); // start next scene blacked out
if (McKathlin.Param.AfterGameOverCommonEventID > 0) {
$gameTemp.reserveCommonEvent(McKathlin.Param.AfterGameOverCommonEventID);
SceneManager.goto(Scene_Map);
} else {
SceneManager.goto(Scene_Map);
// Transfer to where we are, to set BGM, map fadein, etc.
$gamePlayer.reserveTransfer($gameMap.mapId(),
$gamePlayer.x, $gamePlayer.y, $gamePlayer.direction(), 0);
$gameScreen.startFadeIn(this.slowFadeSpeed());
}
};
} else if (McKathlin.Param.AfterGameOverCommonEventID > 0) {
// replacement method
Scene_Gameover.prototype.gotoTitle = function() {
$gameScreen.startFadeOut(1); // start next scene blacked out
$gameParty.reviveLeader();
$gameTemp.reserveCommonEvent(McKathlin.Param.AfterGameOverCommonEventID);
SceneManager.goto(Scene_Map);
};
}