code:
//=============================================================================
// PictureVariableSetting.js
// ----------------------------------------------------------------------------
// (C) 2015 Triacontane
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
// ----------------------------------------------------------------------------
// Version
// 1.5.2 2019/06/02 P_OUT_OF_SCREEN_SHAKE_ON設定時、シェイクの強さ次第で僅かに揺れていた問題を修正
// 1.5.1 2019/05/02 P_OUT_OF_SCREEN_SHAKE_ONのヘルプを追記
// 1.5.0 2016/08/06 ピクチャを画面のシェイクと連動しないようにするコマンドを追加
// 1.4.0 2016/06/23 ピクチャをシェイクさせるコマンドを追加
// 1.3.0 2016/04/29 ピクチャを指定した角度まで回転させるコマンドを追加
// 1.2.1 2016/04/14 処理を適用するピクチャを範囲指定もしくは複数指定する機能を追加
// 1.2.0 2016/03/19 表示中のすべてのピクチャに処理を適用するコマンドを追加
// 1.1.2 2016/01/24 ピクチャの最大表示数を設定できる機能を追加
// 1.1.1 2015/12/20 番号の変数指定の初期値を有効/無効で設定できるよう修正
// 1.1.0 2015/11/27 ピクチャのファイル名に変数を組み込むことが出来る機能を追加
// 1.0.0 2015/11/24 初版
// ----------------------------------------------------------------------------
// [Blog]   : https://triacontane.blogspot.jp/
// [Twitter]: https://twitter.com/triacontane/
// [GitHub] : https://github.com/triacontane/
//=============================================================================

/*:
 * @plugindesc ピクチャ関連のイベント機能拡張プラグイン
 * @author トリアコンタン
 *
 * @param 初期値
 * @desc 初期状態での有効/無効の設定値(ON/OFF)
 * @default OFF
 *
 * @param ピクチャ表示最大数
 * @desc ピクチャ表示最大数（デフォルト100個）を設定します。
 * 変えない場合は何も入力しないでください。
 * @default
 *
 * @help ピクチャ関連のイベント命令の機能を拡張します。
 * プラグインコマンドから機能を有効にしてください。
 *
 * １．ピクチャ関連のイベント命令で番号が「指定された変数の値」になるよう
 * 仕様を変更します。
 * 例えば番号に「1」を設定すると「1」番の変数の値をピクチャ番号として設定します。
 * プラグインコマンドから「P_VARIABLE_VALID」「P_VARIABLE_INVALID」で
 * 有効/無効を切り替えてください。（初期状態では無効です）
 *
 * ２．ピクチャのファイル名に変数を組み込むことが出来るようになります。
 * 連番を含むファイル名などの柔軟な指定に有効です。
 * プラグインコマンド「P_D_FILENAME」を実行してから
 * 「画像」を指定せず「ピクチャの表示」を行ってください。
 *
 * 要注意！　ピクチャのファイル名を動的指定した場合、デプロイメント時に
 * 未使用ファイルとして除外される可能性があります。
 * その場合、削除されたファイルを入れ直す等の対応が必要です。
 *
 * ３．以下のイベントコマンドの対象が「複数のピクチャ」になります。
 * 　　詳細は各プラグインコマンドの説明を確認してください。
 *  ・ピクチャの移動
 *  ・ピクチャの色調変更
 *  ・ピクチャの回転
 *  ・ピクチャの消去
 *
 * プラグインコマンド詳細
 *  イベントコマンド「プラグインコマンド」から実行。
 *  （引数の間は半角スペースで区切る）
 *
 *  P_VARIABLE_VALID : ピクチャ番号の変数設定が有効になります。
 *  P_VARIABLE_INVALID : ピクチャ番号の変数設定が無効になります。
 *  ※ 一度有効に設定したら、無効にするまでずっとそのままです。
 *  例 P_VARIABLE_VALID
 *
 *  P_D_FILENAME [ファイル名]
 *  次に表示するピクチャのファイル名に変数を含めることができます。
 *  変数は「文章の表示」と同様の書式\V[n]で組み込んでください。
 *  拡張子は指定しないでください。
 *  例 P_D_FILENAME file\V[1]
 *
 *  P_TARGET_ALL
 *  ピクチャ関連のイベントコマンドの対象を
 *  「表示している全てのピクチャ」に変更します。
 *  1回実行すると設定はもとに戻ります。
 *  例 P_TARGET_ALL
 *
 *  P_TARGET_RANGE [開始番号] [終了番号]
 *  ピクチャ関連のイベントコマンドの対象を
 *  「開始番号から終了番号までのピクチャ」に変更します。
 *  1回実行すると設定はもとに戻ります。
 *  例 P_TARGET_RANGE 3 5 // 3番から5番までの表示しているピクチャが対象
 *
 *  P_TARGET_MULTI [ピクチャ番号]
 *  ピクチャ関連のイベントコマンドの対象を
 *  「指定したすべてのピクチャ」に変更します。カンマで区切ってください。
 *  1回実行すると設定はもとに戻ります。
 *  例 P_TARGET_MULTI 3,5,6,\v[1] // 3番、5番、6番、変数「1」番のピクチャが対象
 *
 *  P_SPIN [ピクチャ番号] [角度] [時間(フレーム)] [完了までウェイト]
 *  対象のピクチャを指定した角度(degree)まで回転させます。正の値が時計回りです。
 *  時間を0にすると即座に指定した角度に設定されます。
 *  このコマンドには「P_TARGET_ALL」等が適用されます。
 *  一番後ろに「WAIT」と付けると、回転が完了するまでウェイトします。
 *  例 P_SPIN 1 90 60 WAIT
 *  -> ピクチャ番号「1」を60フレーム掛けて90度回転させる。
 *
 *  P_SPIN_RELATIVE [ピクチャ番号] [角度] [時間(フレーム)] [完了までウェイト]
 *  対象のピクチャを現在の角度を基準に、指定した角度のぶんだけ回転させます。
 *  それ以外は「P_SPIN」と同様です。
 *  例 P_SPIN_RELATIVE \v[1] -90 0
 *  -> 変数「1」の値のピクチャを、現在の角度から-90度まで即座に回転させる。
 *
 *  P_SHAKE [ピクチャ番号] [強さ] [速さ] [角度] [時間(フレーム)] [完了までウェイト]
 *  対象のピクチャをシェイクさせます。強さと速さはイベント「画面のシェイク」と
 *  同様の9段階の数値で指定します。角度(degree)はシェイク方向を0から360までの
 *  値で指定します。(90で縦方向にシェイクします)
 *  時間を指定しないと、停止するまでシェイクし続けます。
 *  一番後ろに「WAIT」と付けると、回転が完了するまでウェイトします。
 *  このコマンドには「P_TARGET_ALL」等が適用されます。
 *  例 P_SHAKE 1 3 9 0 60 WAIT
 *  -> ピクチャ番号「1」を60フレームのあいだ、強さ3、速さ9で横方向にシェイクします。
 *
 *  P_STOP_SHAKE [ピクチャ番号]
 *  対象のピクチャをシェイクを止めます。P_SHAKEで時間を指定しないと
 *  ずっとシェイクし続けるので当コマンドで無効にします。
 *  このコマンドには「P_TARGET_ALL」等が適用されます。
 *　例 P_STOP_SHAKE \v[1]
 *  -> 変数「1」の値のピクチャのシェイクを止めます。
 *
 *  P_OUT_OF_SCREEN_SHAKE_ON [ピクチャ番号]
 *  対象のピクチャが画面のシェイクと連動しないようになります。
 *  メッセージウィンドウ等と同じ扱いになります。
 *  このコマンドはピクチャの表示後に実行する必要があります。
 *  また、このコマンド実行後に同一番号でピクチャを再表示すると無効になります。
 *
 *  例 P_OUT_OF_SCREEN_SHAKE_ON 1
 *  -> ピクチャ番号「1」が画面のシェイクと連動しないようになります。
 *
 *  P_OUT_OF_SCREEN_SHAKE_OFF [ピクチャ番号]
 *  対象のピクチャが画面のシェイクと再度、連動するようになります。
 *  例 P_OUT_OF_SCREEN_SHAKE_OFF 1
 *  -> ピクチャ番号「1」が画面のシェイクと再度、連動するようになります。
 *
 * 利用規約：
 *  作者に無断で改変、再配布が可能で、利用形態（商用、18禁利用等）
 *  についても制限はありません。
 *  このプラグインはもうあなたのものです。
 */
(function() {
    'use strict';
    var pluginName = 'PictureVariableSetting';

    //=============================================================================
    // ローカル関数
    //  プラグインパラメータやプラグインコマンドパラメータの整形やチェックをします
    //=============================================================================
    var getParamBoolean = function(paramNames) {
        var value = getParamOther(paramNames);
        return (value || '').toUpperCase() === 'ON';
    };

    var getParamNumber = function(paramNames, min, max) {
        var value = getParamOther(paramNames);
        if (arguments.length < 2) min = -Infinity;
        if (arguments.length < 3) max = Infinity;
        return (parseInt(value, 10) || 0).clamp(min, max);
    };

    var getParamOther = function(paramNames) {
        if (!Array.isArray(paramNames)) paramNames = [paramNames];
        for (var i = 0; i < paramNames.length; i++) {
            var name = PluginManager.parameters(pluginName)[paramNames[i]];
            if (name) return name;
        }
        return null;
    };

    var getCommandName = function(command) {
        return (command || '').toUpperCase();
    };

    var getArgString = function(arg, upperFlg) {
        arg = convertEscapeCharactersAndEval(arg, false);
        return upperFlg ? arg.toUpperCase() : arg;
    };

    var getArgNumber = function(arg, min, max) {
        if (arguments.length < 2) min = -Infinity;
        if (arguments.length < 3) max = Infinity;
        return (parseInt(convertEscapeCharactersAndEval(arg, true), 10) || 0).clamp(min, max);
    };

    var getArgArrayString = function(args, upperFlg) {
        var values = getArgString(args, upperFlg).split(',');
        for (var i = 0; i < values.length; i++) values[i] = values[i].trim();
        return values;
    };

    var getArgArrayNumber = function(args, min, max) {
        var values = getArgArrayString(args, false);
        if (arguments.length < 2) min = -Infinity;
        if (arguments.length < 3) max = Infinity;
        for (var i = 0; i < values.length; i++) values[i] = (parseInt(values[i], 10) || 0).clamp(min, max);
        return values;
    };

    var convertEscapeCharactersAndEval = function(text, evalFlg) {
        if (text === null || text === undefined) text = '';
        var window = SceneManager._scene._windowLayer.children[0];
        if (window) {
            var result = window.convertEscapeCharacters(text);
            return evalFlg ? eval(result) : result;
        } else {
            return text;
        }
    };

    //=============================================================================
    // Game_Interpreter
    //  プラグインコマンド[P_VARIABLE_VALID]などを追加定義します。
    //  ピクチャ番号を変数で指定するよう変更します。
    //=============================================================================
    var _Game_Interpreter_pluginCommand      = Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
        _Game_Interpreter_pluginCommand.call(this, command, args);
        switch (getCommandName(command)) {
            case 'P_VARIABLE_VALID':
                $gameSystem.pictureNumVariable = true;
                break;
            case 'P_VARIABLE_INVALID':
                $gameSystem.pictureNumVariable = false;
                break;
            case 'P_D_FILENAME':
                $gameScreen.dPictureFileName = getArgString(args[0]);
                break;
            case 'P_TARGET_ALL':
                $gameScreen.setPictureTargetAll();
                break;
            case 'P_TARGET_RANGE':
                $gameScreen.setPictureTargetRange(getArgNumber(args[0], 1), getArgNumber(args[1], 1));
                break;
            case 'P_TARGET_MULTI':
                $gameScreen.setPictureTargetMulti(getArgArrayNumber(args[0], 1));
                break;
            case 'P_SPIN':
                var spinDuration = getArgNumber(args[2], 0);
                $gameScreen.spinPicture(getArgNumber(args[0], 1), getArgNumber(args[1]), spinDuration);
                if (args[3]) this.wait(spinDuration);
                break;
            case 'P_SPIN_RELATIVE':
                var spinRelativeDuration = getArgNumber(args[2], 0);
                $gameScreen.spinPictureRelative(getArgNumber(args[0], 1), getArgNumber(args[1]), spinRelativeDuration);
                if (args[3]) this.wait(spinRelativeDuration);
                break;
            case 'P_SHAKE':
                var shakeDuration = getArgNumber(args[4], 0) || Infinity;
                var power         = getArgNumber(args[1], 1, 9);
                var speed         = getArgNumber(args[2], 1, 9);
                var rotation      = getArgNumber(args[3], 0, 360);
                $gameScreen.shakePicture(getArgNumber(args[0], 1), power, speed, rotation, shakeDuration);
                if (args[5] && shakeDuration !== Infinity) this.wait(shakeDuration);
                break;
            case 'P_STOP_SHAKE':
                $gameScreen.shakePicture(getArgNumber(args[0], 1), 0, 0, 0, 0);
                break;
            case 'P_OUT_OF_SCREEN_SHAKE_ON':
                $gameScreen.setOutOfScreenShakePicture(getArgNumber(args[0], 1), true);
                break;
            case 'P_OUT_OF_SCREEN_SHAKE_OFF':
                $gameScreen.setOutOfScreenShakePicture(getArgNumber(args[0], 1), false);
                break;
        }
    };

    var _Game_Interpreter_command231      = Game_Interpreter.prototype.command231;
    Game_Interpreter.prototype.command231 = function() {
        return this.transPictureNumber(_Game_Interpreter_command231.bind(this));
    };

    var _Game_Interpreter_command232      = Game_Interpreter.prototype.command232;
    Game_Interpreter.prototype.command232 = function() {
        return this.transPictureNumber(_Game_Interpreter_command232.bind(this));
    };

    var _Game_Interpreter_command233      = Game_Interpreter.prototype.command233;
    Game_Interpreter.prototype.command233 = function() {
        return this.transPictureNumber(_Game_Interpreter_command233.bind(this));
    };

    var _Game_Interpreter_command234      = Game_Interpreter.prototype.command234;
    Game_Interpreter.prototype.command234 = function() {
        return this.transPictureNumber(_Game_Interpreter_command234.bind(this));
    };

    var _Game_Interpreter_command235      = Game_Interpreter.prototype.command235;
    Game_Interpreter.prototype.command235 = function() {
        return this.transPictureNumber(_Game_Interpreter_command235.bind(this));
    };

    Game_Interpreter.prototype.transPictureNumber = function(handler) {
        var result;
        if ($gameSystem.pictureNumVariable) {
            var oldValue    = this._params[0];
            this._params[0] = $gameVariables.value(this._params[0]).clamp(1, $gameScreen.maxPictures());
            result          = handler();
            this._params[0] = oldValue;
        } else {
            result = handler();
        }
        return result;
    };

    //=============================================================================
    // Game_System
    //  ピクチャ番号の変数指定フラグを追加定義します。
    //=============================================================================
    var _Game_System_initialize      = Game_System.prototype.initialize;
    Game_System.prototype.initialize = function() {
        _Game_System_initialize.call(this);
        this.pictureNumVariable = getParamBoolean('初期値');
    };

    //=============================================================================
    // Game_Screen
    //  動的ファイル名指定用のプロパティを追加定義します。
    //=============================================================================
    var _Game_Screen_clear      = Game_Screen.prototype.clear;
    Game_Screen.prototype.clear = function() {
        _Game_Screen_clear.call(this);
        this.dPictureFileName      = null;
        this._pictureTargetStart   = null;
        this._pictureTargetEnd     = null;
        this._pictureTargetNumbers = null;
    };

    Game_Screen.prototype.setPictureTargetAll = function() {
        this._pictureTargetAll = 1;
    };

    Game_Screen.prototype.setPictureTargetRange = function(start, end) {
        this._pictureTargetAll   = 2;
        this._pictureTargetStart = start;
        this._pictureTargetEnd   = end;
    };

    Game_Screen.prototype.setPictureTargetMulti = function(args) {
        this._pictureTargetAll     = 3;
        this._pictureTargetNumbers = args;
    };

    var _Game_Screen_movePicture      = Game_Screen.prototype.movePicture;
    Game_Screen.prototype.movePicture = function(pictureId, origin, x, y, scaleX,
                                                 scaleY, opacity, blendMode, duration) {
        if (this._pictureTargetAll > 0) {
            this.iteratePictures(function(picture) {
                picture.move(origin, x, y, scaleX, scaleY, opacity, blendMode, duration);
            }.bind(this));
            this._pictureTargetAll = 0;
        } else {
            _Game_Screen_movePicture.apply(this, arguments);
        }
    };

    var _Game_Screen_rotatePicture      = Game_Screen.prototype.rotatePicture;
    Game_Screen.prototype.rotatePicture = function(pictureId, speed) {
        if (this._pictureTargetAll > 0) {
            this.iteratePictures(function(picture) {
                picture.rotate(speed);
            }.bind(this));
            this._pictureTargetAll = 0;
        } else {
            _Game_Screen_rotatePicture.apply(this, arguments);
        }
    };

    var _Game_Screen_tintPicture      = Game_Screen.prototype.tintPicture;
    Game_Screen.prototype.tintPicture = function(pictureId, tone, duration) {
        if (this._pictureTargetAll > 0) {
            this.iteratePictures(function(picture) {
                picture.tint(tone, duration);
            }.bind(this));
            this._pictureTargetAll = 0;
        } else {
            _Game_Screen_tintPicture.apply(this, arguments);
        }
    };

    var _Game_Screen_erasePicture      = Game_Screen.prototype.erasePicture;
    Game_Screen.prototype.erasePicture = function(pictureId) {
        if (this._pictureTargetAll) {
            this.iteratePictures(function(picture, pictureId) {
                var realPictureId             = this.realPictureId(pictureId);
                this._pictures[realPictureId] = null;
            }.bind(this));
            this._pictureTargetAll = 0;
        } else {
            _Game_Screen_erasePicture.apply(this, arguments);
        }
    };

    Game_Screen.prototype.spinPicture = function(pictureId, rotation, duration) {
        if (this._pictureTargetAll > 0) {
            this.iteratePictures(function(picture) {
                picture.spin(rotation, duration);
            }.bind(this));
            this._pictureTargetAll = 0;
        } else {
            var picture = this.picture(pictureId);
            if (picture) {
                picture.spin(rotation, duration);
            }
        }
    };

    Game_Screen.prototype.spinPictureRelative = function(pictureId, relativeRotation, duration) {
        if (this._pictureTargetAll > 0) {
            this.iteratePictures(function(picture) {
                picture.spinRelative(relativeRotation, duration);
            }.bind(this));
            this._pictureTargetAll = 0;
        } else {
            var picture = this.picture(pictureId);
            if (picture) {
                picture.spinRelative(relativeRotation, duration);
            }
        }
    };

    Game_Screen.prototype.shakePicture = function(pictureId, power, speed, rotation, duration) {
        if (this._pictureTargetAll > 0) {
            this.iteratePictures(function(picture) {
                picture.shake(power, speed, rotation, duration);
            }.bind(this));
            this._pictureTargetAll = 0;
        } else {
            var picture = this.picture(pictureId);
            if (picture) {
                picture.shake(power, speed, rotation, duration);
            }
        }
    };

    Game_Screen.prototype.setOutOfScreenShakePicture = function(pictureId, value) {
        if (this._pictureTargetAll > 0) {
            this.iteratePictures(function(picture) {
                picture.setOutOfScreenShake(value);
            }.bind(this));
            this._pictureTargetAll = 0;
        } else {
            var picture = this.picture(pictureId);
            if (picture) {
                picture.setOutOfScreenShake(value);
            }
        }
    };

    Game_Screen.prototype.iteratePictures = function(callBack) {
        for (var i = 1, n = this.maxPictures(); i <= n; i++) {
            var picture = this.picture(i);
            if (picture && this.isTargetPicture(i)) {
                callBack.call(this, picture, i);
            }
        }
    };

    Game_Screen.prototype.isTargetPicture = function(number) {
        switch (this._pictureTargetAll) {
            case 2:
                return this._pictureTargetStart <= number && this._pictureTargetEnd >= number;
            case 3:
                return this._pictureTargetNumbers.contains(number);
            default:
                return true;
        }
    };

    var _Game_Screen_maxPictures      = Game_Screen.prototype.maxPictures;
    Game_Screen.prototype.maxPictures = function() {
        var max = getParamNumber('ピクチャ表示最大数', 0);
        return max > 0 ? max : _Game_Screen_maxPictures.apply(this, arguments);
    };

    //=============================================================================
    // Game_Picture
    //  ファイル名の動的生成処理を追加定義します。
    //=============================================================================
    var _Game_Picture_show      = Game_Picture.prototype.show;
    Game_Picture.prototype.show = function(name, origin, x, y, scaleX,
                                           scaleY, opacity, blendMode) {
        if ($gameScreen.dPictureFileName != null) {
            arguments[0]                 = $gameScreen.dPictureFileName;
            $gameScreen.dPictureFileName = null;
        }
        _Game_Picture_show.apply(this, arguments);
    };

    var _Game_Picture_x      = Game_Picture.prototype.x;
    Game_Picture.prototype.x = function() {
        return _Game_Picture_x.apply(this, arguments) + this.getShakeX() -
            (this._outOfScreenShake ? Math.round($gameScreen.shake()) : 0);
    };

    var _Game_Picture_y      = Game_Picture.prototype.y;
    Game_Picture.prototype.y = function() {
        return _Game_Picture_y.apply(this, arguments) + this.getShakeY();
    };

    Game_Picture.prototype.setOutOfScreenShake = function(value) {
        this._outOfScreenShake = !!value;
    };

    Game_Picture.prototype.spin = function(targetRotation, duration) {
        this._targetRotation = targetRotation;
        this._angle          = (this._angle % 360);
        if (duration === 0) {
            this._angle = this._targetRotation;
        } else {
            this._spinDuration = duration;
        }
    };

    Game_Picture.prototype.spinRelative = function(targetRelativeRotation, duration) {
        this._angle = (this._angle % 360);
        this.spin(this._angle + targetRelativeRotation, duration);
    };

    Game_Picture.prototype.shake = function(power, speed, rotation, duration) {
        this.stopShake();
        this._shakePower     = power;
        this._shakeSpeed     = speed;
        this._shakeDuration  = duration;
        this._shakeRotation  = rotation * Math.PI / 180;
    };

    Game_Picture.prototype.stopShake = function() {
        this._shakeDirection = 1;
        this._shake          = 0;
    };

    var _Game_Picture_update      = Game_Picture.prototype.update;
    Game_Picture.prototype.update = function() {
        _Game_Picture_update.apply(this, arguments);
        this.updateSpin();
        this.updateShake();
    };

    Game_Picture.prototype.updateSpin = function() {
        if (this._spinDuration > 0) {
            var d       = this._spinDuration;
            this._angle = (this._angle * (d - 1) + this._targetRotation) / d;
            this._spinDuration--;
        }
    };

    Game_Picture.prototype.updateShake = function() {
        if (this._shakeDuration > 0) {
            var delta = (this._shakePower * this._shakeSpeed * this._shakeDirection) / 3;
            if (this._shakeDuration <= 1 && this._shake * (this._shake + delta) < 0) {
                this._shake = 0;
            } else {
                this._shake += delta;
            }
            if (this._shake > this._shakePower * 2) {
                this._shakeDirection = -1;
            }
            if (this._shake < -this._shakePower * 2) {
                this._shakeDirection = 1;
            }
            this._shakeDuration--;
        }
    };

    Game_Picture.prototype.getShakeX = function() {
        return this._shake ? this._shake * Math.cos(this._shakeRotation) : 0;
    };

    Game_Picture.prototype.getShakeY = function() {
        return this._shake ? this._shake * Math.sin(this._shakeRotation) : 0;
    };
})();


code:
//=============================================================================
// Ricon_BattleTransition.js
// Version: 1.0.0
//----------------------------------------------------------------------------
// Copyright (c) 2019 RiceConstruction
// Released under the MIT license
// http://opensource.org/licenses/mit-license.php
//----------------------------------------------------------------------------
// Versions
// 1.1.0 2019/02/06 プラグインコマンドを追加
// 1.0.0 2019/01/02 初版
//----------------------------------------------------------------------------
// [ホームページ] https://riceconstruction.weebly.com/
// [GitHub] https://github.com/RiceConstruction/
// [Twitter] https://twitter.com/riceconstr/
// [Fantia] https://fantia.jp/rice-construction/
//=============================================================================

/*:
 * @plugindesc 戦闘開始時トランジション変更プラグイン
 * @author べるろ＊(Ricon)
 *
 * @help 戦闘開始時のトランジションの色合いやタイミングを変更することができます。
 *
 * ----------------------------------------------------------------------------
 * プラグインコマンド
 *
 * 「BattleTransition」はBとTのみ大文字、その他は小文字で入力してください。
 * コマンドの他の部分については大文字・小文字の区別はありません。
 *
 * BattleTransition Speed 数値
 * 戦闘開始時エフェクトの効果時間を変更します。
 * 数値の部分には処理時間をフレーム単位で入力してください。
 * defaultと入力するとパラメータで指定した数値に戻ります。
 * 有効範囲：0～600
 * 初期値：60
 *
 * BattleTransition zoom 番号
 * 一度のエフェクト中にズームを行う回数を切り替えます。
 * 番号の部分にの下記いずれかの数字を入力してください。
 * 0(ズームなし)、1(1段階ズーム)、2(2段階ズーム)
 * defaultと入力するとパラメータで指定した数値に戻ります。
 * 初期値：2
 *
 * BattleTransition ZoomMode in/out
 * ズームの種類を切り替えます。
 * 下記いずれかの文字を入力してください。
 * in(ズームイン)、out(ズームアウト)
 * defaultと入力するとパラメータで指定した数値に戻ります。
 * 初期値：in
 *
 * BattleTransition Flash on/off
 * フラッシュの有効・無効を切り替えます。
 * 下記いずれかの文字を入力してください。
 * on(有効)、off(無効)
 * defaultと入力するとパラメータで指定した数値に戻ります。
 * 初期値：on
 *
 * BattleTransition FlashR 数値
 * フラッシュ色調の赤の強さを変更します。
 * 数値の部分に値を入力してください。
 * defaultと入力するとパラメータで指定した数値に戻ります。
 * 有効範囲：0～255
 * 初期値：255
 *
 * BattleTransition FlashG 数値
 * フラッシュ色調の緑の強さを変更します。
 * 数値の部分に値を入力してください。
 * defaultと入力するとパラメータで指定した数値に戻ります。
 * 有効範囲：0～255
 * 初期値：255
 *
 * BattleTransition FlashB 数値
 * フラッシュ色調の青の強さを変更します。
 * 数値の部分に値を入力してください。
 * defaultと入力するとパラメータで指定した数値に戻ります。
 * 有効範囲：0～255
 * 初期値：255
 *
 * BattleTransition FlashI 数値
 * フラッシュの強さを変更します。
 * 数値の部分に値を入力してください。
 * defaultと入力するとパラメータで指定した数値に戻ります。
 * 有効範囲：0～255
 * 初期値：255
 *
 *
 * ----------------------------------------------------------------------------
 * このプラグインは他のトランジション変更プラグインと併用することは出来ません。
 *
 * @param Speed
 * @type number
 * @min 0
 * @max 600
 * @default 60
 * @desc トランジション効果の実行時間(フレーム)。短いほど速くなります。
 *
 * @param Zoom
 * @type combo
 * @option 0
 * @option 1
 * @option 2
 * @default 2
 * @desc ズーム回数。
 * 0:ズームなし　1:1段階ズーム　2(デフォルト):2段階ズーム
 *
 * @param ZoomMode
 * @parent Zoom
 * @type boolean
 * @on ズームイン
 * @off ズームアウト
 * @default true
 * @desc ズームの種類。
 * ON(デフォルト):ズームイン　OFF:ズームアウト
 *
 * @param Flash
 * @type boolean
 * @on 有効
 * @off 無効
 * @default true
 * @desc フラッシュの有効化切り替え。
 *
 * @param FlashRed
 * @parent Flash
 * @type number
 * @min 0
 * @max 255
 * @default 255
 * @desc フラッシュ色の設定(赤)。
 *
 * @param FlashGreen
 * @parent Flash
 * @type number
 * @min 0
 * @max 255
 * @default 255
 * @desc フラッシュ色の設定(緑)。
 *
 * @param FlashBlue
 * @parent Flash
 * @type number
 * @min 0
 * @max 255
 * @default 255
 * @desc フラッシュ色の設定(青)。
 *
 * @param FlashIntensity
 * @parent Flash
 * @type number
 * @min 0
 * @max 255
 * @default 255
 * @desc フラッシュ色の設定(強さ)。
 *
 */

(function(){
    'use strict';

    //=============================================================================
    // プラグインパラメータ
    //=============================================================================

    var parameters = PluginManager.parameters('Ricon_BattleTransition');

    var getParamBoolean = function(paramName) {
        var value = parameters[paramName];
        return (value || '').toUpperCase() === 'ON' || (value || '').toUpperCase() === 'TRUE';
    };

    var getParamNumber = function(paramName) {
        var value = parameters[paramName];
        return (parseInt(value, 10) || 0).clamp(-Infinity,Infinity);
    };

    var RBT = {};
    RBT.speed = getParamNumber('Speed');
    RBT.zoom = getParamNumber('Zoom');
    RBT.zoomMode = getParamBoolean('ZoomMode');
    RBT.flash = getParamBoolean('Flash');
    RBT.flashR = getParamNumber('FlashRed');
    RBT.flashG = getParamNumber('FlashGreen');
    RBT.flashB = getParamNumber('FlashBlue');
    RBT.flashI = getParamNumber('FlashIntensity');

    //=============================================================================
    // ゲーム内データ
    //=============================================================================

    RBT.game = {};
    RBT.game.speed = null;
    RBT.game.zoom = null;
    RBT.game.zoomMode = null;
    RBT.game.flash = null;
    RBT.game.flashR = null;
    RBT.game.flashG = null;
    RBT.game.flashB = null;
    RBT.game.flashI = null;

    RBT.setData = function(args) {
        var mode = String(args[0]).toLowerCase();
        var value = String(args[1]).toLowerCase();
        if(value == 'default') {
            RBT.game[mode] = null;
        }
        switch(mode) {
            case 'speed':
                this.setSpeed(value);
                break;
            case 'zoom':
                this.setZoom(value);
                break;
            case 'zoommode':
                this.setZoomMode(value);
                break;
            case 'flash':
                this.setFlash(value);
                break;
            case 'flashr':
                this.setFlashR(value);
                break;
            case 'flashg':
                this.setFlashG(value);
                break;
            case 'flashb':
                this.setFlashB(value);
                break;
            case 'flashi':
                this.setFlashI(value);
                break;
        }
    };

    function valueLimit(val,min,max) {
        return val < min ? min : (val > max ? max : val);
    };

    RBT.setSpeed = function(value) {
        RBT.game.speed = valueLimit(Number(value),0,600);
    };

    RBT.setZoom = function(value) {
        RBT.game.zoom = Number(value);
    };

    RBT.setZoomMode = function(value) {
        RBT.game.zoomMode = value;
    };

    RBT.setFlash = function(value) {
        RBT.game.flash = value == 'on' ? true: false;
    };

    RBT.setFlashR = function(value) {
        RBT.game.flashR = valueLimit(Number(value),0,255);
    };

    RBT.setFlashG = function(value) {
        RBT.game.flashG = valueLimit(Number(value),0,255);
    };

    RBT.setFlashB = function(value) {
        RBT.game.flashB = valueLimit(Number(value),0,255);
    };

    RBT.setFlashI = function(value) {
        RBT.game.flashI = valueLimit(Number(value),0,255);
    };

    //=============================================================================
    // Game_Interpreter
    //=============================================================================

    var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
        _Game_Interpreter_pluginCommand.call(this, command, args);
        if(command == 'BattleTransition') {
            RBT.setData(args);
        }
    };

    //=============================================================================
    // Game_System
    //=============================================================================

    var _Game_System_initialize = Game_System.prototype.initialize;
    Game_System.prototype.initialize = function() {
        _Game_System_initialize.call(this);
        this.RBT = {};
    };

    var _Game_System_onBeforeSave = Game_System.prototype.onBeforeSave;
    Game_System.prototype.onBeforeSave = function() {
        _Game_System_onBeforeSave.call(this);
        this.RBT = RBT.game;
    };

    var _Game_System_onAfterLoad = Game_System.prototype.onAfterLoad;
    Game_System.prototype.onAfterLoad = function() {
        _Game_System_onAfterLoad.call(this);
        RBT.game = this.RBT;
    };

    //=============================================================================
    // Scene_Map
    //=============================================================================

    Scene_Map.prototype.updateEncounterEffect = function() {
        if (this._encounterEffectDuration > 0) {
            this._encounterEffectDuration--;
            var speed = this.encounterEffectSpeed();
            var n = speed - this._encounterEffectDuration;
            var p = n / speed;
            var zoomX = $gamePlayer.screenX();
            var zoomY = $gamePlayer.screenY() - 24;
            var flash = (typeof RBT.game.flash == 'boolean') ? RBT.game.flash : RBT.flash;
            if (n === 2) {
                $gameScreen.setZoom(zoomX, zoomY, 1);
                this.snapForBattleBackground();
                if(RBT.flash) {
                    this.startFlashForEncounter(speed / 2);
                }
            }
            this.riconZoom(zoomX, zoomY, p);
            if (n === Math.floor(speed / 6)) {
                if(flash) {
                    this.startFlashForEncounter(speed / 2);
                }
            }
            if (n === Math.floor(speed / 2)) {
                BattleManager.playBattleBgm();
                this.startFadeOut(this.fadeSpeed());
            }
        }
    };

    Scene_Map.prototype.riconZoom = function(x,y,p) {
        var in1 = (20 * p * p + 5) * p / 2 + 1;
        var in2 = ((p - 1) * 20 * p + 5) * p + 1;
        var out1 = 1 / in1;
        var out2 = 1 / in2;
        var mode = (typeof RBT.game.zoomMode == 'string') ? RBT.game.zoomMode : (RBT.zoomMode ? 'in' : 'out');
        var repeat = (typeof RBT.game.zoom == 'number') ? RBT.game.zoom : RBT.zoom;
        if(mode == 'in' && repeat == 1) {
            $gameScreen.setZoom(x,y,in1);
        }
        if(mode == 'in' && repeat == 2) {
            $gameScreen.setZoom(x,y,in2);
        }
        if(mode == 'out' && repeat == 1) {
            $gameScreen.setZoom(x,y,out1);
        }
        if(mode == 'out' && repeat == 2) {
            $gameScreen.setZoom(x,y,out2);
        }
    };

    Scene_Map.prototype.startFlashForEncounter = function(duration) {
        var flashR = (typeof RBT.game.flashR == 'number') ? RBT.game.flashR : RBT.flashR;
        var flashG = (typeof RBT.game.flashG == 'number') ? RBT.game.flashG : RBT.flashG;
        var flashB = (typeof RBT.game.flashB == 'number') ? RBT.game.flashB : RBT.flashB;
        var flashI = (typeof RBT.game.flashI == 'number') ? RBT.game.flashI : RBT.flashI;
        var color = [flashR, flashG, flashB, flashI];
        $gameScreen.startFlash(color, duration);
    };

    Scene_Map.prototype.encounterEffectSpeed = function() {
        return (typeof RBT.game.speed == 'number') ? RBT.game.speed : RBT.speed;
    };
})()

repo_name: onms/melphias

license: unknown


code:
/*:
 * @plugindesc Allows you to add/customize backgrounds and change window opacity for all menu scenes.
 * @author SumRndmDde
 *
 * @param Scale Background
 * @desc Set this to 'true' and the backgrounds will automatically scale to the window size.
 * @default true
 *
 * @param == Main Menu ==
 * @default
 *
 * @param Menu Background
 * @desc The background used for the main menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Menu Opacity
 * @desc The opacity of the windows in the main menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Menu Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Menu Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Item Menu ==
 * @default
 *
 * @param Item Background
 * @desc The background used for the item menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Item Opacity
 * @desc The opacity of the windows in the item menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Item Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Item Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Skill Menu ==
 * @default
 *
 * @param Skill Background
 * @desc The background used for the skill menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Skill Opacity
 * @desc The opacity of the windows in the skill menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Skill Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Skill Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Equip Menu ==
 * @default
 *
 * @param Equip Background
 * @desc The background used for the equip menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Equip Opacity
 * @desc The opacity of the windows in the equip menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Equip Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Equip Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Status Menu ==
 * @default
 *
 * @param Status Background
 * @desc The background used for the status menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Status Opacity
 * @desc The opacity of the windows in the status menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Status Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Status Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Save Menu ==
 * @default
 *
 * @param Save Background
 * @desc The background used for the save menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Save Opacity
 * @desc The opacity of the windows in the save menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Save Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Save Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Options Menu ==
 * @default
 *
 * @param Options Background
 * @desc The background used for the options menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Options Opacity
 * @desc The opacity of the windows in the options menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Options Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Options Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == End Menu ==
 * @default
 *
 * @param End Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param End Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param End Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param End Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 1 ==
 * @default
 *
 * @param Custom 1 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 1 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 1 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 1 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 1 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 2 ==
 * @default
 *
 * @param Custom 2 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 2 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 2 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 2 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 2 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 3 ==
 * @default
 *
 * @param Custom 3 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 3 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 3 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 3 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 3 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 4 ==
 * @default
 *
 * @param Custom 4 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 4 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 4 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 4 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 4 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 5 ==
 * @default
 *
 * @param Custom 5 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 5 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 5 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 5 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 5 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 6 ==
 * @default
 *
 * @param Custom 6 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 6 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 6 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 6 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 6 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 7 ==
 * @default
 *
 * @param Custom 7 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 7 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 7 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 7 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 7 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 8 ==
 * @default
 *
 * @param Custom 8 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 8 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 8 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 8 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 8 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 9 ==
 * @default
 *
 * @param Custom 9 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 9 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 9 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 9 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 9 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 10 ==
 * @default
 *
 * @param Custom 10 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 10 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 10 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 10 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 10 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 11 ==
 * @default
 *
 * @param Custom 11 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 11 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 11 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 11 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 11 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 12 ==
 * @default
 *
 * @param Custom 12 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 12 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 12 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 12 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 12 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 13 ==
 * @default
 *
 * @param Custom 13 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 13 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 13 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 13 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 13 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 14 ==
 * @default
 *
 * @param Custom 14 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 14 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 14 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 14 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 14 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 15 ==
 * @default
 *
 * @param Custom 15 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 15 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 15 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 15 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 15 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 16 ==
 * @default
 *
 * @param Custom 16 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 16 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 16 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 16 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 16 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 17 ==
 * @default
 *
 * @param Custom 17 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 17 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 17 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 17 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 17 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 18 ==
 * @default
 *
 * @param Custom 18 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 18 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 18 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 18 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 18 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 19 ==
 * @default
 *
 * @param Custom 19 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 19 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 19 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 19 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 19 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @param == Custom 20 ==
 * @default
 *
 * @param Custom 20 Scene
 * @desc The name of the custom menu's scene
 * @default
 *
 * @param Custom 20 Background
 * @desc The background used for the end menu screen.
 * Place it in img/SumRndmDde/menu/
 * @default
 *
 * @param Custom 20 Opacity
 * @desc The opacity of the windows in the end menu screen.
 * Set to a number between 0 and 255
 * @default 255
 *
 * @param Custom 20 Scale
 * @desc The base scale of the background image.
 * 1 is a normal scale; 0.5 is half; 2 is double; etc...
 * @default 1
 *
 * @param Custom 20 Motion
 * @desc The motion of the background image.
 * Visit the HELP section for a list of motions.
 * @default
 *
 * @help
 *
 * Menu Backgrounds
 * Version 2.05
 * SumRndmDde
 *
 *
 * This allows you to give all the menu pages of your menu custom
 * backgrounds!
 *
 * You can control the scale of the background images, the opacity of the
 * windows in the menus, and the motion of the background images.
 *
 *
 * ==============================================================================
 *  How to set up the images
 * ==============================================================================
 *
 * Place all the background images you wish to use in:
 *
 * img/SumRndmDde/menu
 *
 * (this is so that when you export your game, all you have to do is copy
 * the SumRndmDde folder inside of the img folder to the exported game files)
 *
 * Anyway, simply input the picture's name without the file extension
 * into the Parameter of choice and it should work perfectly.
 *
 *
 * ==============================================================================
 *  How to set up Custom Scenes
 * ==============================================================================
 *
 * In order to set up a background for a custom menu scene, input the scene's
 * name in a "Custom X Scene". Then input all of the other informtion you wish
 * for that scene to have within the other Custom X parameters.
 *
 *
 * ==============================================================================
 *  Background Image Motions
 * ==============================================================================
 *
 * Here is a list of all the motions that can be used in the "Motion" parameters:
 *
 * ==============================================================================
 *
 *   scroll [xSpeed] [ySpeed]
 *
 * This makes it so the background scrolls at the X and Y speeds provided.
 *
 * Here is an example:
 *    scroll 3 3
 *
 * ==============================================================================
 *
 *   zoom [zoomSpeed] [maxZoom]
 *
 * This makes the background image zooms in and out at a certain speed.
 *
 * Here is an example:
 *    zoom 0.01 5
 *
 * ==============================================================================
 *
 *   rotate [rotateSpeed] [maxRotate]
 *
 * This makes the background image rotate at a certain speed.
 *
 * Here is an example:
 *    rotate 0.01 0.5
 *
 * ==============================================================================
 *
 *   blur [blurSpeed] [maxBlur]
 *
 * This makes the background image blur at a certain speed.
 *
 * Here is an example:
 *    blur 0.01 1
 *
 *
 * ==============================================================================
 *  End of Help File
 * ==============================================================================
 *
 * Welcome to the bottom of the Help file.
 *
 *
 * Thanks for reading!
 * If you have questions, or if you enjoyed this Plugin, please check
 * out my YouTube channel!
 *
 * https://www.youtube.com/c/SumRndmDde
 *
 *
 * Until next time,
 *   ~ SumRndmDde
 */

var SRD = SRD || {};
SRD.MenuBackgrounds = SRD.MenuBackgrounds || {};

var Imported = Imported || {};
Imported["SumRndmDde Menu Backgrounds"] = 2.05;

(function(_) {

"use strict";

//-----------------------------------------------------------------------------
// SRD.MenuBackgrounds
//-----------------------------------------------------------------------------

const params = PluginManager.parameters('SRD_MenuBackgrounds');

_.scale = String(params['Scale Background']).trim().toLowerCase() === 'true';

_.backgrounds = {};
_.backgrounds["Scene_Menu"] = String(params['Menu Background']);
_.backgrounds["Scene_Item"] = String(params['Item Background']);
_.backgrounds["Scene_Skill"] = String(params['Skill Background']);
_.backgrounds["Scene_Equip"] = String(params['Equip Background']);
_.backgrounds["Scene_Status"] = String(params['Status Background']);
_.backgrounds["Scene_Save"] = String(params['Save Background']);
_.backgrounds["Scene_Options"] = String(params['Options Background']);
_.backgrounds["Scene_GameEnd"] = String(params['End Background']);

_.opacity = {};
_.opacity["Scene_Menu"] = parseInt(params['Menu Opacity']);
_.opacity["Scene_Item"] = parseInt(params['Item Opacity']);
_.opacity["Scene_Skill"] = parseInt(params['Skill Opacity']);
_.opacity["Scene_Equip"] = parseInt(params['Equip Opacity']);
_.opacity["Scene_Status"] = parseInt(params['Status Opacity']);
_.opacity["Scene_Save"] = parseInt(params['Save Opacity']);
_.opacity["Scene_Options"] = parseInt(params['Options Opacity']);
_.opacity["Scene_GameEnd"] = parseInt(params['End Opacity']);

_.scales = {};
_.scales["Scene_Menu"] = parseFloat(params['Menu Scale']);
_.scales["Scene_Item"] = parseFloat(params['Item Scale']);
_.scales["Scene_Skill"] = parseFloat(params['Skill Scale']);
_.scales["Scene_Equip"] = parseFloat(params['Equip Scale']);
_.scales["Scene_Status"] = parseFloat(params['Status Scale']);
_.scales["Scene_Save"] = parseFloat(params['Save Scale']);
_.scales["Scene_Options"] = parseFloat(params['Options Scale']);
_.scales["Scene_GameEnd"] = parseFloat(params['End Scale']);

_.motions = {};
_.motions["Scene_Menu"] = String(params['Menu Motion']);
_.motions["Scene_Item"] = String(params['Item Motion']);
_.motions["Scene_Skill"] = String(params['Skill Motion']);
_.motions["Scene_Equip"] = String(params['Equip Motion']);
_.motions["Scene_Status"] = String(params['Status Motion']);
_.motions["Scene_Save"] = String(params['Save Motion']);
_.motions["Scene_Options"] = String(params['Options Motion']);
_.motions["Scene_GameEnd"] = String(params['End Motion']);

for(let i = 1; i <= 20; i++) {
	const scene = String(params['Custom ' + i + ' Scene']);
	if(scene.trim().length > 0) {
		_.backgrounds[scene] = String(params['Custom ' + i + ' Background']);
		_.opacity[scene] = parseInt(params['Custom ' + i + ' Opacity']);
		_.scales[scene] = String(params['Custom ' + i + ' Scale']);
		_.motions[scene] = String(params['Custom ' + i + ' Motion']);
	}
}

_.loadImage = function(filename, hue) {
	return ImageManager.loadBitmap('img/SumRndmDde/menu/', filename, hue, true);
};

_.loadAllImages = function() {
	for (let property in _.backgrounds) {
		if (_.backgrounds.hasOwnProperty(property)) {
			const name = _.backgrounds[property];
			if(name.trim().length > 0) {
				_.loadImage(name);
			}
		}
	}
};

_.loadAllImages();

//-----------------------------------------------------------------------------
// Scene_MenuBase
//-----------------------------------------------------------------------------

_.Scene_MenuBase_create = Scene_MenuBase.prototype.create;
Scene_MenuBase.prototype.create = function() {
	this._menuBackgroundConstructorName = String(this.constructor.name);
	_.Scene_MenuBase_create.apply(this, arguments);
};

_.Scene_MenuBase_start = Scene_MenuBase.prototype.start;
Scene_MenuBase.prototype.start = function() {
	_.Scene_MenuBase_start.apply(this, arguments);
	this.setupWindowOpacities();
};

Scene_MenuBase.prototype.setupWindowOpacities = function() {
	if(!this._windowLayer) return;
	const opac = _.opacity[this._menuBackgroundConstructorName];
	const childs = this._windowLayer.children;
	if((opac || opac === 0) && childs) {
		for(let i = 0; i < childs.length; i++) {
			const win = childs[i];
			if(win._isWindow) {
				win.opacity = opac;
			}
		}
	}

};

_.Scene_MenuBase_createBackground = Scene_MenuBase.prototype.createBackground;
Scene_MenuBase.prototype.createBackground = function() {
	if(_.backgrounds[this._menuBackgroundConstructorName]) {
		this._backgroundSprite = new TilingSprite();
		this._backgroundSprite.anchor.x = 0.5;
		this._backgroundSprite.anchor.y = 0.5;
		this._backgroundSprite.origin.x  = -(Graphics.boxWidth / 2);
		this._backgroundSprite.origin.y  = -(Graphics.boxHeight / 2);
		this._backgroundSprite.move(Graphics.boxWidth/2, Graphics.boxHeight/2, Graphics.boxWidth, Graphics.boxHeight);
		const bit = _.loadImage(_.backgrounds[this._menuBackgroundConstructorName]);
		let newWidth = bit.width;
		let newHeight = bit.height;
		if(_.scale) {
			newWidth = Graphics.boxWidth;
			newHeight = Graphics.boxHeight;
		}
		this._backgroundSprite.bitmap = new Bitmap(newWidth, newHeight);
		this._backgroundSprite.bitmap.blt(bit, 0, 0, bit.width, bit.height, 0, 0, newWidth, newHeight);
		this.addChild(this._backgroundSprite);
		this.createBackgroundMotion();
		this.createBackgroundScale();
		if(Utils.RPGMAKER_VERSION && Utils.RPGMAKER_VERSION >= '1.3.0') this.createBackgroundBlur();
	} else {
		_.Scene_MenuBase_createBackground.call(this);
	}
};

Scene_MenuBase.prototype.createBackgroundMotion = function() {
	if(_.motions[this._menuBackgroundConstructorName]) {
		const motion = _.motions[this._menuBackgroundConstructorName];
		if(!motion) {
			this._hasBackgroundMotion = false;
			this._backgroundMotionInfo = [''];
			return;
		}
		this._hasBackgroundMotion = true;
		this._backgroundMotionInfo = motion.split(' ');
		for(let i = 1; i < this._backgroundMotionInfo.length; i++) {
			this._backgroundMotionInfo[i] = parseFloat(this._backgroundMotionInfo[i]);
		}
		this._backgroundMotionSign = 1;
	}
};

Scene_MenuBase.prototype.createBackgroundScale = function() {
	if(_.scales[this._menuBackgroundConstructorName]) {
		this._backgroundMotionScale = _.scales[this._menuBackgroundConstructorName];
	} else {
		this._backgroundMotionScale = 1;
	}
	this._backgroundSprite.scale.x = this._backgroundMotionScale;
	this._backgroundSprite.scale.y = this._backgroundMotionScale;
};

Scene_MenuBase.prototype.createBackgroundBlur = function() {
	this._backgroundMotionFilter = new PIXI.filters.BlurFilter();
	this._backgroundMotionFilter.blur = 0;
	this._backgroundSprite.filters = [this._backgroundMotionFilter];
};

_.Scene_MenuBase_update = Scene_MenuBase.prototype.update;
Scene_MenuBase.prototype.update = function() {
	_.Scene_MenuBase_update.apply(this, arguments);
	if(this._hasBackgroundMotion) {
		this.updateBackgroundMotion();
	}
};

Scene_MenuBase.prototype.updateBackgroundMotion = function() {
	const motionType = this._backgroundMotionInfo[0];
	if(motionType === 'scroll') {
		this.updateBackgroundScroll();
	} else if(motionType === 'zoom') {
		this.updateBackgroundZoom();
	} else if(motionType === 'rotate') {
		this.updateBackgroundRotate();
	} else if(motionType === 'blur' && this._backgroundMotionFilter) {
		this.updateBackgroundBlur();
	}
};

Scene_MenuBase.prototype.updateBackgroundScroll = function() {
	this._backgroundSprite.origin.x += this._backgroundMotionInfo[1];
	this._backgroundSprite.origin.y += this._backgroundMotionInfo[2];
};

Scene_MenuBase.prototype.updateBackgroundZoom = function() {
	this._backgroundSprite.scale.x += (this._backgroundMotionInfo[1] * this._backgroundMotionSign);
	this._backgroundSprite.scale.y += (this._backgroundMotionInfo[1] * this._backgroundMotionSign);
	if(this._backgroundSprite.scale.x >= this._backgroundMotionInfo[2] || this._backgroundSprite.scale.x <= this._backgroundMotionScale) {
		this._backgroundMotionSign *= (-1);
	}
};

Scene_MenuBase.prototype.updateBackgroundRotate = function() {
	this._backgroundSprite.rotation += (this._backgroundMotionInfo[1] * this._backgroundMotionSign);
	if(this._backgroundMotionInfo[2]) {
		if(Math.abs(this._backgroundSprite.rotation) > this._backgroundMotionInfo[2]) {
			this._backgroundMotionSign *= (-1);
		}
	} else {
		if(this._backgroundSprite.rotation > (Math.PI*2)) {
			this._backgroundSprite.rotation -= (Math.PI*2);
		} else if(this._backgroundSprite.rotation < (Math.PI*2)) {
			this._backgroundSprite.rotation += (Math.PI*2);
		}
	}
};

Scene_MenuBase.prototype.updateBackgroundBlur = function() {
	this._backgroundMotionFilter.blur += (this._backgroundMotionInfo[1] * this._backgroundMotionSign);
	if(Math.abs(this._backgroundMotionFilter.blur) > this._backgroundMotionInfo[2]) {
		this._backgroundMotionSign *= (-1);
	}
};

})(SRD.MenuBackgrounds);