/
DarkPlasma_RemoveBuffAtBattleEnd.js
103 lines (89 loc) · 3.11 KB
/
DarkPlasma_RemoveBuffAtBattleEnd.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
// DarkPlasma_RemoveBuffAtBattleEnd 1.0.0
// Copyright (c) 2022 DarkPlasma
// This software is released under the MIT license.
// http://opensource.org/licenses/mit-license.php
/**
* 2022/08/13 1.0.0 公開
*/
/*:ja
* @plugindesc 戦闘終了時に強化・弱体を解除するかどうか
* @author DarkPlasma
* @license MIT
*
* @target MV
* @url https://github.com/elleonard/DarkPlasma-MV-Plugins/tree/release
*
* @param removeBuffAtBattleEnd
* @desc 戦闘終了時、逃走したバトラー含む全バトラーの強化・弱体を解除します。
* @text 戦闘終了で強化・弱体を解除
* @type boolean
* @default true
*
* @help
* version: 1.0.0
* 戦闘終了時に全バトラーの強化・弱体を解除するかどうかを設定します。
*
* MVデフォルトの仕様では、行動による逃走で戦闘を離脱したアクターの強化・弱体は
* 戦闘終了時に解除されません。
* 本プラグインでは、逃走したバトラーを含めて全バトラーの強化・弱体を
* 解除するか否かを設定します。
*/
(() => {
'use strict';
const pluginName = document.currentScript.src.replace(/^.*\/(.*).js$/, function () {
return arguments[1];
});
const pluginParameters = PluginManager.parameters(pluginName);
const settings = {
removeBuffAtBattleEnd: String(pluginParameters.removeBuffAtBattleEnd || true) === 'true',
};
/**
* @param {Game_Temp.prototype} gameTemp
*/
function Game_Temp_RemoveBuffAtBattleEndMixIn(gameTemp) {
gameTemp.isProcessingBattleEnd = function () {
return this._isProcessingBattleEnd || false;
};
gameTemp.startProcessingBattleEnd = function () {
this._isProcessingBattleEnd = true;
};
gameTemp.completeProcessingBattleEnd = function () {
this._isProcessingBattleEnd = false;
};
}
Game_Temp_RemoveBuffAtBattleEndMixIn(Game_Temp.prototype);
/**
* @param {Game_Battler.prototype} gameBattler
*/
function Game_Battler_RemoveBuffAtBattleEndMixIn(gameBattler) {
const _removeAllBuffs = gameBattler.removeAllBuffs;
gameBattler.removeAllBuffs = function () {
if ($gameTemp.isProcessingBattleEnd()) {
if (settings.removeBuffAtBattleEnd) {
const evacuatedIsAlive = this.isAlive;
/**
* 戦闘を離脱したバトラーも生存扱いとし、強化・弱体解除の対象とする
*/
this.isAlive = () => evacuatedIsAlive.call(this) || this.isHidden();
_removeAllBuffs.call(this);
this.isAlive = evacuatedIsAlive;
}
} else {
_removeAllBuffs.call(this);
}
};
}
Game_Battler_RemoveBuffAtBattleEndMixIn(Game_Battler.prototype);
/**
* @param {Scene_Battle.prototype} sceneBattle
*/
function Scene_Battle_RemoveBuffAtBattleEndMixIn(sceneBattle) {
const _terminate = sceneBattle.terminate;
sceneBattle.terminate = function () {
$gameTemp.startProcessingBattleEnd();
_terminate.call(this);
$gameTemp.completeProcessingBattleEnd();
};
}
Scene_Battle_RemoveBuffAtBattleEndMixIn(Scene_Battle.prototype);
})();