217 lines
No EOL
8.7 KiB
JavaScript
217 lines
No EOL
8.7 KiB
JavaScript
//=============================================================================
|
||
// PP_EventCollapse.js
|
||
//
|
||
// Copyright (c) 2020 punipunion
|
||
// Released under the MIT license
|
||
// http://opensource.org/licenses/mit-license.php
|
||
//=============================================================================
|
||
|
||
/*:
|
||
* @plugindesc 戦闘時のエネミーの消滅エフェクト、ボス消滅エフェクトぽいものを、マップのイベントにも適用できるようになります。
|
||
* @author punipunion
|
||
*
|
||
* @help 使い方
|
||
* ・プラグインコマンドで「EVENT_COLLAPSE イベントID」と指定すると、
|
||
* 指定したイベントが戦闘時と同じように消滅します。イベントID「0」は「このイベント」になります。
|
||
* 例:EVENT_COLLAPSE 3
|
||
*
|
||
* ・プラグインコマンドで「EVENT_BOSS_COLLAPSE イベントID」と指定すると、
|
||
* 指定したイベントが戦闘時と同じようにボス消滅します。イベントID「0」は「このイベント」になります。
|
||
* 例:EVENT_BOSS_COLLAPSE 3
|
||
*
|
||
* ・プラグインコマンドで「WAIT_COLLAPSE」と指定すると、
|
||
* プラグインコマンドを実行したイベントの消滅エフェクトが終わるまで待機します。
|
||
* 例:EVENT_BOSS_COLLAPSE 3
|
||
* WAIT_COLLAPSE
|
||
* と続けてプラグインコマンドを指定すると、ボス消滅が終わるまで「WAIT_COLLAPSE」以降のイベントコマンドは実行されなくなります。
|
||
*
|
||
* ※消滅したイベントは消去されます。
|
||
* イベントコマンドの「イベントの一時消去」と同じ効果。
|
||
*
|
||
* @param collapseDuration
|
||
* @desc 通常消滅の消滅速度です。
|
||
* @type number
|
||
* @min 1
|
||
* @default 32
|
||
*/
|
||
|
||
(function () {
|
||
'use strict';
|
||
|
||
/** プラグインパラメータ */
|
||
var parameters = PluginManager.parameters('PP_EventCollapse');
|
||
var collapseDuration = parseInt(parameters['collapseDuration']);
|
||
|
||
/** 通常消滅 */
|
||
var EFFECT_TYPE_COLLAPSE = 'collapse';
|
||
/** ボス消滅 */
|
||
var EFFECT_TYPE_BOSS_COLLAPSE = 'bossCollapse';
|
||
/** 消滅エフェクトのウェイトモード */
|
||
var WAIT_MODE_EFFECT = 'effect';
|
||
|
||
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
|
||
Game_Interpreter.prototype.pluginCommand = function(command, args) {
|
||
_Game_Interpreter_pluginCommand.apply(this, arguments);
|
||
|
||
switch (command) {
|
||
case 'EVENT_COLLAPSE':
|
||
if (args[0] && parseInt(args[0]) >= 0 && this.character(parseInt(args[0]))) {
|
||
this.character(parseInt(args[0])).startCollapse();
|
||
}
|
||
break;
|
||
case 'EVENT_BOSS_COLLAPSE':
|
||
if (args[0] && parseInt(args[0]) >= 0 && this.character(parseInt(args[0]))) {
|
||
this.character(parseInt(args[0])).startBossCollapse();
|
||
}
|
||
break;
|
||
case 'WAIT_COLLAPSE':
|
||
if (!$gameParty.inBattle()) {
|
||
this._character = this.character(this._eventId);
|
||
this.setWaitMode(WAIT_MODE_EFFECT);
|
||
}
|
||
break;
|
||
}
|
||
};
|
||
|
||
// 消滅エフェクトのパラメータ追加
|
||
var _Game_Character_initMembers = Game_Character.prototype.initMembers;
|
||
Game_Character.prototype.initMembers = function() {
|
||
_Game_Character_initMembers.call(this);
|
||
this._effectType = '';
|
||
};
|
||
|
||
Game_Character.prototype.startCollapse = function() {
|
||
this._effectType = EFFECT_TYPE_COLLAPSE;
|
||
};
|
||
|
||
Game_Character.prototype.startBossCollapse = function() {
|
||
this._effectType = EFFECT_TYPE_BOSS_COLLAPSE;
|
||
};
|
||
|
||
Game_Character.prototype.isEffectPlaying = function() {
|
||
return this._effectType;
|
||
};
|
||
|
||
Sprite_Character.prototype.isCollapseEffectPlaying = function() {
|
||
return this._effectDuration > 0 && this._character && this._character._effectType === EFFECT_TYPE_COLLAPSE;
|
||
};
|
||
|
||
Sprite_Character.prototype.isBossCollapseEffectPlaying = function() {
|
||
return this._effectDuration > 0 && this._character && this._character._effectType === EFFECT_TYPE_BOSS_COLLAPSE;
|
||
};
|
||
|
||
// 消滅エフェクトのパラメータ追加
|
||
var _Sprite_Character_initMembers = Sprite_Character.prototype.initMembers;
|
||
Sprite_Character.prototype.initMembers = function() {
|
||
_Sprite_Character_initMembers.call(this);
|
||
this._shake = 0;
|
||
this._effectDuration = 0;
|
||
this._effectDurationMax = 0;
|
||
};
|
||
|
||
// 消滅エフェクトの更新処理追加
|
||
var _Sprite_Character_update = Sprite_Character.prototype.update;
|
||
Sprite_Character.prototype.update = function() {
|
||
_Sprite_Character_update.call(this);
|
||
|
||
if (this._character && this._character._effectType && this._effectDuration < 1) {
|
||
switch(this._character._effectType) {
|
||
case EFFECT_TYPE_COLLAPSE:
|
||
this._effectDuration = collapseDuration;
|
||
this._effectDurationMax = this._effectDuration;
|
||
break;
|
||
case EFFECT_TYPE_BOSS_COLLAPSE:
|
||
this._effectDuration = this.patternHeight();
|
||
break;
|
||
}
|
||
}
|
||
|
||
this.updateCollapse();
|
||
this.updateBossCollapse();
|
||
};
|
||
|
||
// 消滅エフェクトの更新処理追加
|
||
Sprite_Character.prototype.updateCollapse = function() {
|
||
if (this.isCollapseEffectPlaying()) {
|
||
this._effectDuration--;
|
||
|
||
this.blendMode = Graphics.BLEND_ADD;
|
||
this.setBlendColor([255, 128, 128, 128]);
|
||
this.opacity *= this._effectDuration / this._effectDurationMax;
|
||
|
||
if (this._effectDuration < 1 && this._character) {
|
||
this._character._effectType = '';
|
||
this._character.erase();
|
||
}
|
||
}
|
||
};
|
||
|
||
// ボス消滅エフェクトの更新処理追加
|
||
Sprite_Character.prototype.updateBossCollapse = function() {
|
||
if (this.isBossCollapseEffectPlaying()) {
|
||
this._effectDuration--;
|
||
|
||
this._shake = this._effectDuration % 2 * 4 - 2;
|
||
this.blendMode = Graphics.BLEND_ADD;
|
||
this.opacity *= this._effectDuration / (this._effectDuration + 1);
|
||
this.setBlendColor([255, 255, 255, 255 - this.opacity]);
|
||
|
||
if (this._effectDuration < 1 && this._character) {
|
||
this._character._effectType = '';
|
||
this._character.erase();
|
||
}
|
||
}
|
||
};
|
||
|
||
// ボス消滅エフェクト時、シェイク処理追加
|
||
var _Sprite_Character_updatePosition = Sprite_Character.prototype.updatePosition;
|
||
Sprite_Character.prototype.updatePosition = function () {
|
||
_Sprite_Character_updatePosition.call(this);
|
||
if (this.isBossCollapseEffectPlaying()) {
|
||
if (this._character) {
|
||
this._character._x += this._shake;
|
||
}
|
||
}
|
||
};
|
||
|
||
// ボス消滅エフェクト時、高さ調整
|
||
var _Sprite_Character_updateCharacterFrame = Sprite_Character.prototype.updateCharacterFrame;
|
||
Sprite_Character.prototype.updateCharacterFrame = function() {
|
||
if (this.isBossCollapseEffectPlaying()) {
|
||
var pw = this.patternWidth();
|
||
var ph = this.patternHeight();
|
||
var sx = (this.characterBlockX() + this.characterPatternX()) * pw;
|
||
var sy = (this.characterBlockY() + this.characterPatternY()) * ph;
|
||
this.updateHalfBodySprites();
|
||
if (this._bushDepth > 0) {
|
||
var d = this._bushDepth;
|
||
this._upperBody.setFrame(sx, sy, pw, ph - d);
|
||
this._lowerBody.setFrame(sx, sy + ph - d, pw, d);
|
||
this.setFrame(sx, sy, 0, this._effectDuration);
|
||
} else {
|
||
this.setFrame(sx, sy, pw, this._effectDuration);
|
||
}
|
||
} else {
|
||
_Sprite_Character_updateCharacterFrame.call(this);
|
||
}
|
||
};
|
||
|
||
// エフェクトのウェイトモードを追加
|
||
var _Game_Interpreter_updateWaitMode = Game_Interpreter.prototype.updateWaitMode;
|
||
Game_Interpreter.prototype.updateWaitMode = function() {
|
||
if (this._waitMode === WAIT_MODE_EFFECT) {
|
||
var waiting = false;
|
||
if (this._character) {
|
||
waiting = this._character.isEffectPlaying();
|
||
}
|
||
|
||
if (!waiting) {
|
||
this._waitMode = '';
|
||
}
|
||
return waiting;
|
||
} else {
|
||
return _Game_Interpreter_updateWaitMode.call(this);
|
||
}
|
||
};
|
||
|
||
})(); |