code:
/*:
 * @plugindesc v1.19 Battlers perform actions instantly in an order decided by their agility. A turn ends after each battler acts.
 *
 * <DreamX ITB>
 * @author DreamX
 *
 * @param ---Elemental Extra Actions---
 * @default
 *
 * @param Max Elemental Extra Actions
 * @desc Eval. Max # extra actions battler can get in turn for hitting enemy weakness. 0 - none, -1: infinite. Default: 0
 * @default 0
 *
 * @param Max Elemental Extra Actions Per Opponent Per Turn
 * @desc Eval. Max # extra actions battler can get in turn for hitting enemy weakness per opponent. <= 0: infinite. Default: 0
 * @default 0
 *
 * @param Elemental Weakness State
 * @desc Eval. State ID to apply to battler when they're hit in their elemental weakness. 0 - disable. Default: 0
 * @default 0
 *
 * @param Elemental Weakness Animation
 * @desc Animation ID to play on battler when they get an extra action from hitting enemy in weakness. 0: disable. Default: 0
 * @default 0
 *
 * @param ---VE Damage Popups---
 *
 * @param Show Extra Action Popup
 * @desc Show popup when battler gets extra action from special actions. Requires VE Damage Popups Default: false
 * @default false
 *
 * @param Extra Action Popup Text
 * @desc Popup text to display when battler gets extra action from special actions.
 * @default 1 More!
 *
 * @param Extra Action Popup Motion
 * @desc Motion for extra action popup. Default: Pop High, Fall High, Pop Low, Fall Low, Wait, Wait
 * @default Pop High, Fall High, Pop Low, Fall Low, Wait, Wait
 *
 * @param Extra Action Popup Font
 * @desc Eval. Font for extra action popup. Default: Window_Base.prototype.standardFontFace()
 * @default Window_Base.prototype.standardFontFace()
 *
 * @param Extra Action Popup Size
 * @desc Eval. Font size for extra action popup. Default: Window_Base.prototype.standardFontSize()
 * @default Window_Base.prototype.standardFontSize()
 *
 * @param Extra Action Popup Color
 * @desc Font color for extra action popup. Default: #FFFFFF
 * @default #FFFFFF
 *
 * @param Extra Action Popup X
 * @desc X for extra action popup. Default: 0
 * @default 0
 *
 * @param Extra Action Popup Y
 * @desc Y for extra action popup. Default: 0
 * @default 0
 *
 * @param ---Turn Order Window---
 * @default
 *
 * @param Show Turn Orders
 * @desc Whether to show turn orders. Default: false
 * @default false
 *
 * @param Prevent Cutoff
 * @desc Don't show an icon if it would get cutoff. Default: true
 * @default true
 *
 * @param Generate Default Icons
 * @desc Show generated icons if a sheet name and index isn't specified. Default: false
 * @default false
 *
 * @param Hide On Battle Results
 * @desc Hide turn window on battle end. Default: true
 * @default true
 *
 * @param Show Dead Battlers
 * @desc Show dead battlers. Default: false
 * @default false
 *
 * @param # Action Display Type
 * @desc 1: Show 1 icon per battler. 2: # icons same as # actions. 3: Display action # text. 4: Show both. Default: 1
 * @default 1
 *
 * @param Max Action # Icons
 * @desc If using 2 as action display type, maximum amount of icons per battler. 0 - infinite Default: 0
 * @default 0
 *
 * @param Action # Text Min
 * @desc If using 3 as action display type, minimum amount of actions required before showing action # text. Default: 2
 * @default 2
 *
 * @param Action # Text X
 * @desc X of action # text. Default: x
 * @default x
 *
 * @param Action # Text Y
 * @desc Y of action # text. Default: y
 * @default y
 *
 * @param Action # Font Size
 * @desc Size of action # text. Default: Window_Base.prototype.standardFontSize()
 * @default Window_Base.prototype.standardFontSize()
 *
 * @param Show Plural Text
 * @desc Show plural letters for multiple of the same enemy type. Default: false
 * @default false
 *
 * @param Plural Text X
 * @desc X of plural text. Default: x
 * @default x
 *
 * @param Plural Text Y
 * @desc Y of plural text. Default: y
 * @default y
 *
 * @param Plural Text Size
 * @desc Font size of plural text. Default: Window_Base.prototype.standardFontSize()
 * @default Window_Base.prototype.standardFontSize()
 *
 * @param Turn Sheet Folder
 * @desc Folder for turn sheet icons. Default: img/faces/
 * @default img/faces/
 *
 * @param Default Turn Sheet
 * @desc Default turn sheet name if none is specified.
 * @default
 *
 * @param Turn Sheet Columns
 * @desc Default columns turn icon sheets. Default: 4
 * @default 4
 *
 * @param Turn Sheet Rows
 * @desc Default rows for turn icon sheets. Default: 2
 * @default 2
 *
 * @param Turn Window Orientation
 * @desc horizontal or vertical. default: horizontal
 * @default horizontal
 *
 * @param Turn Window Width (Horizontal)
 * @desc Width when turn window is orientated horizontally. Default: Graphics.boxWidth
 * @default Graphics.boxWidth
 *
 * @param Turn Window Width (Vertical)
 * @desc Width when turn window is orientated vertically. Default: (this.standardPadding() * 2) + 144
 * @default (this.standardPadding() * 2) + parameterTurnIconWidth
 *
 * @param Turn Window Height (Horizontal)
 * @desc Height when turn window is orientated horizontally. Default: (this.standardPadding() * 2) + 144
 * @default (this.standardPadding() * 2) + parameterTurnIconHeight
 *
 * @param Turn Window Height (Vertical)
 * @desc Height vertically. Default: Graphics.boxHeight - Window_PartyCommand.prototype.windowHeight()
 * @default Graphics.boxHeight - Window_PartyCommand.prototype.windowHeight()
 *
 * @param Turn Window X (Horizontal)
 * @desc X when horizontal. Default: 0
 * @default 0
 *
 * @param Turn Window X (Vertical)
 * @desc X when vertical. Default: Graphics.boxWidth - this.windowWidth()
 * @default Graphics.boxWidth - this.windowWidth()
 *
 * @param Turn Window Y (Horizontal)
 * @desc Y when horizontal. Default: 0
 * @default 0
 *
 * @param Turn Window Y (Vertical)
 * @desc Y when vertical. Default: 0
 * @default 0
 *
 * @param Turn Window Opacity
 * @desc Opacity of the turn order window skin. Default: 255
 * @default 255
 *
 * @param Turn Window Padding
 * @desc Padding of the window. Default: Window_Base.prototype.standardPadding()
 * @default Window_Base.prototype.standardPadding()
 *
 * @param Icon Spacing
 * @desc Spacing between icons. Default: 12
 * Default: 12
 * @default 12
 *
 * @param Max Icons
 * @desc Max turn icons to show. 0 - infinite. Default: 0
 * @default 0
 *
 * @param Show Next Turn
 * @desc Whether to show order of next turn. Default: false
 * @default false
 *
 * @param Show End Turn Icon
 * @desc Whether to show an end turn icon. Default: false
 * @default false
 *
 * @param End Turn Sheet
 * @desc Sheet that has end turn icon.
 * @default
 *
 * @param End Turn Sheet Index
 * @desc Index of end turn icon.
 * @default 0
 *
 * @param ---Ready Overlay---
 * @default
 *
 * @param Ready Overlay
 * @desc Whether to have a looping overlay on actor when they are ready to act. Default: false
 * @default false
 *
 * @param Ready Overlay Name
 * @desc Name of file in img/system that has ready animation. Default: States
 * @default States
 *
 * @param Ready Overlay Index
 * @desc Index of ready overlay image to use, starting at 0.
 * @default 0
 *
 * @param Ready Overlay Anchor X
 * @desc Anchor x position of ready overlay on sprite. Default: 0.5
 * @default 0.5
 *
 * @param Ready Overlay Anchor Y
 * @desc Anchor y position of ready overlay on sprite. Default: 1
 * @default 1
 *
 * @param ---Sound---
 * @default
 *
 * @param Ready Sound
 * @desc This is the sound played when an actor is ready. Use -1 to disable. Default: -1 Example: Decision1
 * @default -1
 *
 * @param Ready Volume
 * @desc This is the volume of the ready sound. Default: 100
 * @default 100
 *
 * @param Ready Pitch
 * @desc This is the pitch of the ready sound. Default: 100
 * @default 100
 *
 * @param Ready Pan
 * @desc This is the pan of the ready sound. Default: 0
 * @default 0
 *
 * @help
 * ============================================================================
 * How To Use
 * ============================================================================
 Set the battle type to itb in Yanfly's Battle Engine Core.

 You MUST turn Dynamic Actions off if you're using YEP Battle AI Core!

 Use <free_itb_action> as a skill/item notetag to prevent
 it from consuming an action for the battler - they will be able to act
 again after it is used.
 Do NOT use YEP Instant Cast to do this - it won't work.

 Make sure to set the parameters to your liking.
 Put the <noExtraElemenWeaknessAction> notetag on a state to disallow opponents
 from getting an extra action from hitting the battler in their weakness.

 Put <elemWeaknessState:x> with x as the state id as a notetag for an actor or
 enemy to define which state is applied when they are hit in their weakness.
 This overrides the parameter setting for that actor or enemy. Use 0 to disable
 states from being applied from being hit in the weakness.

 Use <reAddBattler> in a skill/item to readd a battler to the pool of battlers
 if they had already finished their previous actions. Must be used with a state
 that increases action times.

 To use a custom ready overlay, use a file in the same folder and same style as
 States.png in img/system, make sure the parameter is set to the custom file
 name.
 * ============================================================================
 * Turn Order Window
 * ============================================================================
 Use <ITBSheet: x y z> with x being whatever you want, y being the number of
 columns and z being the number of rows, to specify the image sheet for the
 turn order window icon for the actor or enemy. The filename required for the
 image will be the notetag without leading spaces. See example below.

 Use <ITBSheetIndex: x> to specify the index used for that image with x as
 the index.

 Example:
 <ITBSheet: TurnIcons 9 10>
 <ITBSheetIndex: 1>

 This will use the sheet "TurnIcons 10 10.png" with 9 rows and 10 columns.
 The index will be 1. Indices start at 0.
 If you do not specify the rows and columns in the filename, the default
 parameters will be used instead.

 You will name the end turn sheet used in the parameter "End Turn Sheet"
 the same way.

 The plugin will trim the spaces in the beginning and end of the
 notetag/parameter so do not use leading and trailing spaces in your filename.

 For example, use (without quotes)
 "turnIcons 9 10.png"

 instead of
 "     turnIcons 9 10   .png"
 * ============================================================================
 * Patch Notes/Known Issues/Future Updates
 * ============================================================================
 * See the forum thread for patch notes:
 * http://forums.rpgmakerweb.com/index.php?/topic/54880-instant-turn-battle-system/
 * ============================================================================
 * Terms Of Use
 * ============================================================================
 Free to use and modify for commercial and noncommercial games, with credit.
 This script was based off of Yanfly's Battle System - Charge Turn Battle
 and was programmed using Yanfly's Battle Engine Core turned on. Please credit
 them for both scripts.
 * ============================================================================
 * Credits
 * ============================================================================
 DreamX
 Yanfly - "Battle System - Charge Turn Battle" & "Battle Engine Core"
 */

//=============================================================================
// Import
//=============================================================================
var Imported = Imported || {};
Imported.DreamX_ITB = true;

var DreamX = DreamX || {};
DreamX.ITB = DreamX.ITB || {};

(function () {

//=============================================================================
// Parameters
//=============================================================================
    var parameters = $plugins.filter(function (p) {
        return p.description.contains
                ('<DreamX ITB>');
    })[0].parameters; //Thanks to Iavra

    // store the parameter data in variables. The defaults are -1
    var paramMaxElementExtraActions =
            String(parameters['Max Elemental Extra Actions'] || '0');

    var paramMaxElemExtraPerOpponentPerTurn =
            String(parameters['Max Elemental Extra Actions Per Opponent Per Turn'] || '0');

    var paramElementWeaknessState =
            String(parameters['Elemental Weakness State'] || '0');
    var paramElementWeaknessAnimation =
            parseInt(parameters['Elemental Weakness Animation'] || 0);

    var paramShowDead =
            eval(parameters['Show Dead Battlers'] || false);
    var parameterShowTurnOrder =
            eval(parameters['Show Turn Orders'] || false);
    var parameterPreventCutoff =
            eval(parameters['Prevent Cutoff'] || true);
    var parameterHideOnBattleResults =
            eval(parameters['Hide On Battle Results'] || true);

    var parameterTurnOpacity =
            parseInt(parameters['Turn Window Opacity'] || 255);
    var parameterTurnIconWidth =
            parseInt(parameters['Icon Width'] || 144);
    var parameterTurnIconHeight =
            parseInt(parameters['Icon Height'] || 144);
    var parameterMaxIcons =
            parseInt(parameters['Max Icons'] || 0);

    var parameterIconSheetCols =
            parseInt(parameters['Turn Sheet Columns'] || 4);
    var parameterIconSheetRows =
            parseInt(parameters['Turn Sheet Rows'] || 2);

    var parameterActionDisplayType =
            parseInt(parameters['# Action Display Type'] || 1);
    var parameterMaxActionIcons =
            parseInt(parameters['Max Action # Icons'] || 0);

    var parameterPluralSize =
            String(parameters['Plural Text Size'] || 'Window_Base.prototype.standardFontSize()')
    var paramPadding =
            String(parameters['Turn Window Padding'] || 'Window_Base.prototype.standardPadding()');
    var parameterTurnWindowXHorizontal =
            String(parameters['Turn Window X (Horizontal)'] || 0);
    var parameterTurnWindowXVertical =
            String(parameters['Turn Window X (Vertical)'] || 0);
    var parameterTurnWindowYHorizontal =
            String(parameters['Turn Window Y (Horizontal)'] || 0);
    var parameterTurnWindowYVertical =
            String(parameters['Turn Window Y (Vertical)'] || 0);

    var paramGenerateIcons =
            eval(parameters['Generate Default Icons'] || false);
    var paramShowActionMin =
            eval(parameters['Action # Text Min'] || 2);
    var parameterActionNumSize =
            String(parameters['Action # Font Size'] || 'Window_Base.prototype.standardFontSize()')
    var parameterActionNumX =
            String(parameters['Action # Text X'] || 'x');
    var parameterActionNumY =
            String(parameters['Action # Text Y'] || 'y');

    var paramShowPlural =
            eval(parameters['Show Plural Text'] || false);
    var parameterPluralX =
            String(parameters['Plural Text X'] || 'x');
    var parameterPluralY =
            String(parameters['Plural Text Y'] || 'y');

    var parameterTurnIconSpacing =
            parseInt(parameters['Icon Spacing']);
    var parameterTurnIconOrientation =
            String(parameters['Turn Window Orientation'] || 'horizontal');
    var parameterTurnFolder =
            String(parameters['Turn Sheet Folder'] || 'img/faces/');
    var parameterTurnWindowWidthHorizontal =
            String(parameters['Turn Window Width (Horizontal)'] || 'Graphics.boxWidth');
    var parameterTurnWindowHeightHorizontal =
            String(parameters['Turn Window Height (Horizontal)'] || '(this.standardPadding() * 2) + 144');

    var parameterTurnDefaultSheet =
            String(parameters['Default Turn Sheet']);
    var parameterShowEndTurn =
            eval(parameters['Show End Turn Icon'] || false);
    var parameterShowNextTurn =
            eval(parameters['Show Next Turn'] || false);

    var parameterTurnWindowWidthVertical =
            String(parameters['Turn Window Width (Vertical)']
                    || '(this.standardPadding() * 2) + 144');
    var parameterTurnWindowHeightVertical =
            String(parameters['Turn Window Height (Vertical)'] || 'Graphics.boxHeight - Window_PartyCommand.prototype.windowHeight()');
    var parameterTurnWindowEndSheet = String(parameters['End Turn Sheet']);
    var parameterTurnWindowEndIndex =
            parseInt(parameters['End Turn Sheet Index'] || 0);

    var parameterReadySound =
            String(parameters['Ready Sound'] || '-1');
    var parameterReadyVolume =
            parseInt(parameters['Ready Volume'] || '90');
    var parameterReadyPitch =
            parseInt(parameters['Ready Pitch'] || '100');
    var parameterReadyPan =
            parseInt(parameters['Ready Pan'] || '0');
    var paramaterReadyOverlayEnabled =
            eval(parameters['Ready Overlay'] || false);
    var parameterReadyOverlayName =
            String(parameters['Ready Overlay Name'] || 'States');
    var parameterReadyOverlayIndex =
            parseInt(parameters['Ready Overlay Index'] || 0);
    var parameterReadyAnchorX =
            parseFloat(parameters['Ready Overlay Anchor X'] || 0.5);
    var parameterReadyAnchorY =
            parseFloat(parameters['Ready Overlay Anchor Y'] || 1);

    var paramShowExtraActionPopup = eval(parameters['Show Extra Action Popup'] || false);
    var paramShowExtraActionPopupText = String(parameters['Extra Action Popup Text']);
    var paramShowExtraActionPopupMotion = String(parameters['Extra Action Popup Motion']);
    var paramShowExtraActionPopupFont = String(parameters['Extra Action Popup Font']);
    var paramShowExtraActionPopupSize = String(parameters['Extra Action Popup Size']);
    var paramShowExtraActionPopupColor = String(parameters['Extra Action Popup Color']);
    var paramShowExtraActionPopupX = parseInt(parameters['Extra Action Popup X']);
    var paramShowExtraActionPopupY = parseInt(parameters['Extra Action Popup Y']);
//    var parameterTurnSound =
//            String(parameters['Turn Sound'] || '-1');

//=============================================================================
// Game_Battler
//=============================================================================
    //==========================================================================
    // Alias Functions
    //==========================================================================
    DreamX.ITB.Game_Battler_onTurnEnd = Game_Battler.prototype.onTurnEnd;
    Game_Battler.prototype.onTurnEnd = function () {
        DreamX.ITB.Game_Battler_onTurnEnd.call(this);
        this.resetActionNum();
    };

    DreamX.ITB.Game_Battler_onBattleStart = Game_Battler.prototype.onBattleStart;
    Game_Battler.prototype.onBattleStart = function () {
        DreamX.ITB.Game_Battler_onBattleStart.call(this);
        this.resetActionNum();
    };

    DreamX.ITB.Game_Battler_initMembers = Game_Battler.prototype.initMembers;
    Game_Battler.prototype.initMembers = function () {
        DreamX.ITB.Game_Battler_initMembers.call(this);
        this._ITBActions = 0;
        this._previousTraitITBActions = 0;
        this._extraActionsFromWeakness = 0;

        // holds ids and number of times hit in weakness by another battler
        this._weaknessHitMap = new Map();
    };

    //==========================================================================
    // Original Functions
    //==========================================================================

    // Checks if any states disallow elemental extra actions
    Game_Battler.prototype.allowExtraElemWeaknessAction = function (user) {
        var isAllowed = true;
        this.states().forEach(function (state) {
            if (state.meta.noExtraElemenWeaknessAction) {
                isAllowed = false;
            }
        });

        if (this._weaknessHitMap.get(user) && paramMaxElemExtraPerOpponentPerTurn >= 1
                && this._weaknessHitMap.get(user)
                >= paramMaxElemExtraPerOpponentPerTurn - 1) {
            return false;
        }
        return isAllowed;
    };

    // Adds ITB actions to the battler from hitting elemental weakness.
    Game_Battler.prototype.extraElementalWeaknessAction = function (target) {
        if ((this._extraActionsFromWeakness
                < eval(paramMaxElementExtraActions))
                || eval(paramMaxElementExtraActions) === -1) {

            if (paramElementWeaknessAnimation >= 1) {
                this.startAnimation(paramElementWeaknessAnimation, true, 0);
            }
            this._extraActionsFromWeakness += 1;
            this.addITBActions(1);
        }
    };

    // Adds ITB actions to the battler.
    Game_Battler.prototype.addITBActions = function (actions) {
        this._ITBActions += actions;
    };

    // Adds ITB actions from traits to the battler.
    Game_Battler.prototype.addTraitITBActions = function (actions) {
        this._previousTraitITBActions += actions;
        this.addITBActions(actions);
    };

    // Returns the previous number of actions added from traits.
    Game_Battler.prototype.previousTraitITBActions = function (actions) {
        return this._previousTraitITBActions;
    };

    // Returns extra actions from traits.
    Game_Battler.prototype.traitITBActions = function () {
        var actions = this.actionPlusSet().length;
//        for (var i = 0; i < this.actionPlusSet().length; i++) {
//            var value = this.actionPlusSet()[i];
//            var diceRoll = Math.random();
//            if (value >= diceRoll) {
//                actions++;
//            }
//        }
        return actions;
    };

    // Returns the current number of ITB actions left for the battler.
    Game_Battler.prototype.numITBActions = function () {
        return this._ITBActions;
    };

//    DreamX.ITB.Game_Battler_numActions = Game_Battler.prototype.numActions;
//    Game_Battler.prototype.numActions = function () {
//        if (BattleManager.isITB()) {
//            return this.numITBActions();
//        }
//        return DreamX.ITB.Game_Battler_numActions.call(this);
//    };

    // Returns the current number of ITB actions left for the battler.
    // Plus one if inputting.
    Game_Battler.prototype.numITBActionsForTurnWindow = function () {
        var num = this.numITBActions();
        if (this.isInputting()) {
            num++;
        }
        return num;
    };

    // Resets the ITB action variables for the battler.
    Game_Battler.prototype.resetActionNum = function () {
        this.clearITBActions();
        this._previousTraitITBActions = 0;
        this._extraActionsFromWeakness = 0;
        this._weaknessHitMap = new Map();
    };

    Game_Battler.prototype.clearITBActions = function () {
        this._ITBActions = 0;
    };

    // Decides whether to add ITB actions from traits.
    Game_Battler.prototype.decideITBTraitActions = function () {
        // if there is a difference between the current number of trait actions
        // and the previous number of them, add the difference to the battler's
        // itb action number
        var difference = this.traitITBActions() - this.previousTraitITBActions();
        this.addTraitITBActions(difference);
    };

    Game_Battler.prototype.endTurnAllITB = function () {
        this.clearActions();
        this.setActionState('undecided');
        if (this.battler())
            this.battler().refreshMotion();
    };

//=============================================================================
// BattleManager
//=============================================================================
    //==========================================================================
    // Alias Functions
    //==========================================================================
    DreamX.ITB.BattleManager_startTurn = BattleManager.startTurn;
    BattleManager.startTurn = function () {
        $gameTroop.clearActions();
        $gameParty.clearActions();
        DreamX.ITB.BattleManager_startTurn.call(this);
    };

    DreamX.BattleManager_initMembers = BattleManager.initMembers;
    BattleManager.initMembers = function () {
        DreamX.BattleManager_initMembers.call(this);
        this._ITBBattlers = [];
        this._itbReadySound = {
            name: parameterReadySound,
            volume: parameterReadyVolume,
            pitch: parameterReadyPitch,
            pan: parameterReadyPan
        };
    };

    DreamX.ITB.battleManager_endTurn = BattleManager.endTurn;
    BattleManager.endTurn = function () {
        DreamX.ITB.battleManager_endTurn.call(this);
        this.makeITBOrders();
        // give every battler one action.
        this.initializeITBActions();
    };

    DreamX.ITB.BattleManager_update = BattleManager.update;
    BattleManager.update = function () {
        if (this.isITB()) {
            if (this.isBusy()) {
                return;
            }

            if (this.updateEvent()) {
                return;
            }

            if (this._phase === 'battleEnd') {
                return DreamX.ITB.BattleManager_update.call(this);
            }
            if (this.checkBattleEnd()) {
                return;
            }

            if (this._phase === 'itb') {
                this.updateITBPhase();
            } else {
                DreamX.ITB.BattleManager_update.call(this);
            }
        } else {
            DreamX.ITB.BattleManager_update.call(this);
        }
    };

    DreamX.BattleManager_startBattle = BattleManager.startBattle;
    BattleManager.startBattle = function () {
        DreamX.BattleManager_startBattle.call(this);
        this.makeITBOrders();

        // give every battler one action.
        this.initializeITBActions();
    };

    DreamX.ITB.BattleManager_selectNextCommand = BattleManager.selectNextCommand;
    BattleManager.selectNextCommand = function () {
        if (this.isITB()) {
            if (!this.actor())
                return this.setITBPhase();
            if (this.isValidITBActorAction()) {
                this.startITBAction(this.actor());
            }
        } else {
            DreamX.ITB.BattleManager_selectNextCommand.call(this);
        }
    };

    DreamX.ITB.BattleManager_endAction = BattleManager.endAction;
    BattleManager.endAction = function () {
        if (this.isITB()) {
            this.endITBAction();
        } else {
            DreamX.ITB.BattleManager_endAction.call(this);
        }
    };

    DreamX.ITB.BattleManager_updateEventMain = BattleManager.updateEventMain;
    BattleManager.updateEventMain = function () {
        if (this.isITB()) {
            $gameTroop.updateInterpreter();
            $gameParty.requestMotionRefresh();
            if ($gameTroop.isEventRunning()) {
                return true;
            }
            $gameTroop.setupBattleEvent();
            if ($gameTroop.isEventRunning() || SceneManager.isSceneChanging()) {
                return true;
            }
            return false;
        } else {
            return DreamX.ITB.BattleManager_updateEventMain.call(this);
        }
    };
    // prevent escape from selecting previous actor
    // issue: causes the windows to jitter when you select fight again
    DreamX.ITB.BattleManager_selectPreviousCommand = BattleManager.selectPreviousCommand;
    BattleManager.selectPreviousCommand = function () {
        if (this.isITB()) {
            this.actor().addITBActions(1);
            this.changeActor(-1, 'undecided');
        } else {
            DreamX.ITB.BattleManager_selectPreviousCommand.call(this);
        }
    };

    // prevent surprise attacks from disallowing enemies to act
    DreamX.ITB.BattleManager_startInput = BattleManager.startInput;
    BattleManager.startInput = function () {
        if (this.isITB()) {
            this._phase = 'input';
            this.clearActor();
        } else {
            DreamX.ITB.BattleManager_startInput.call(this);
        }
    };

    // if itb the battle system is turn based
    DreamX.ITB.BattleManager_isTurnBased = BattleManager.isTurnBased;
    BattleManager.isTurnBased = function () {
        if (this.isITB())
            return true;
        return DreamX.ITB.BattleManager_isTurnBased.call(this);
    };

    //==========================================================================
    // Original Functions
    //==========================================================================
    // gives every battler one action.
    BattleManager.initializeITBActions = function () {
        for (var i = 0; i < this._ITBBattlers.length; i++) {
            var battler = this._ITBBattlers[i];
            battler.addITBActions(1);
        }
    };

    // for every battler, decide ITB trait actions.
    BattleManager.decideITBTraitActionsAll = function () {
        for (var i = 0; i < this._ITBBattlers.length; i++) {
            var battler = this._ITBBattlers[i];
            battler.decideITBTraitActions();
        }
    };

    BattleManager.getReadyITBBattler = function () {
        this.sortITBOrders();
        this.decideITBTraitActionsAll();

        // if the pool of ITB Battlers is empty, start the turn
        if (this._ITBBattlers.length <= 0) {
            this.startTurn();
            return;
        }

        var firstBattler = this._ITBBattlers[0];

        if (firstBattler.numITBActions() >= 1) {
            firstBattler.addITBActions(-1);
            return firstBattler;
        } else {
            this._ITBBattlers.shift();
            return this.getReadyITBBattler();
        }
    };

    BattleManager.playITBReadySound = function () {
        AudioManager.playSe(this._itbReadySound);
    };

    BattleManager.breakITBPhase = function () {
        if (this._victoryPhase)
            return true;
        if (this._processingForcedAction)
            return true;
        if ($gameTroop.isEventRunning())
            return true;
        return this._phase !== 'itb';
    };

    BattleManager.updateITBPhase = function () {
        for (; ; ) {
            if (this.breakITBPhase())
                break;
            var readyBattler = this.getReadyITBBattler();
            if (readyBattler) {
                return this.startITBInput(readyBattler);
            }
            break;
        }
    };

    BattleManager.startITBInput = function (battler) {
        if (battler.isDead())
            return;
        battler.makeActions();
        if (battler.isEnemy()) {
            this.startITBAction(battler);
        } else if (battler.canInput()) {
            this._actorIndex = battler.index();
            if (parameterReadySound !== '-1') {
                this.playITBReadySound();
            }
            battler.setActionState('inputting');
            battler.spriteStepForward();
            this._phase = 'input';
            return;
        } else if (battler.isConfused()) {
            battler.makeConfusionActions();
        } else {
            battler.makeAutoBattleActions();
        }

    };

    BattleManager.setITBPhase = function () {
        this._phase = 'itb';
    };

    BattleManager.isITB = function () {
        return this.isBattleSystem('itb');
    };

    BattleManager.isValidITBActorAction = function () {
        if (!this.actor())
            return false;
        if (!this.actor().currentAction())
            return false;
        return this.actor().currentAction().item();
    };

    BattleManager.startITBAction = function (battler) {
        this._subject = battler;
        var action = this._subject.currentAction();
        if (action && action.isValid()) {
            this.startAction();
        } else {
            this.endAction();
        }
    };

    BattleManager.endITBAction = function () {
        if (Imported.YEP_BattleEngineCore) {
            if (this._processingForcedAction)
                this._phase = this._preForcePhase;
            this._processingForcedAction = false;
        }
        if (this._subject)
            this._subject.onAllActionsEnd();
        if (this.updateEventMain())
            return;
        this._subject.endTurnAllITB();
        if (this.loadPreForceActionSettings())
            return;
        this.setITBPhase();
    };

    BattleManager.addBattler = function (battler) {
        if (this._ITBBattlers.indexOf(battler) === -1) {
            this._ITBBattlers.push(battler);
            this.sortITBOrders();
        }
    };

    BattleManager.ITBAllBattlers = function (disregardSurprise) {
        var battlers = [];
        if (!this._surprise || disregardSurprise) {
            battlers = battlers.concat($gameParty.members());
        }
        if (!this._preemptive || disregardSurprise) {
            battlers = battlers.concat($gameTroop.members());
        }
        return battlers;
    };

    // Creates battler array for this turn
    BattleManager.makeITBOrders = function () {
        this._ITBBattlers = this.ITBAllBattlers();
        this.sortITBOrders();
    };

    // Sorts the ITB Battlers for this turn
    BattleManager.sortITBOrders = function () {
        this.sortITBBattlers(this._ITBBattlers);
    };

    // Sorts the battlers passed to it according to
    // ITB specifications
    BattleManager.sortITBBattlers = function (battlers) {
        battlers.sort(function (a, b) {
            // if does not have same agi
            if (b.agi !== a.agi) {
                return b.agi - a.agi;
            } else {
                // if has same agi
                // if both actors then return one with higher id
                if (a.isActor() && b.isActor()) {
                    return b.actorId() - a.actorId();
                }
                // give enemy priority
                else if (b.isActor() && a.isEnemy()) {
                    return -1;
                }
                // give enemy priority
                else if (b.isEnemy() && a.isActor()) {
                    return 1;
                }
                // if both enemies then return one with higher id
                else if (b.isEnemy() && a.isEnemy()) {
                    return b.enemyId() - a.enemyId();
                }
            }
        });
    };

    BattleManager.ITBBattlersThisTurn = function () {
        return this._ITBBattlers;
    };

    BattleManager.ITBBattlers = function () {
        var battlers = this.ITBAllBattlers();
        this.sortITBBattlers(battlers);
        return battlers;
    };

    //==========================================================================
    // Turn Icon Stuff
    //==========================================================================
    Scene_Battle.prototype.pictureContainerSpritesetIndex = function () {
        var s = this._spriteset;
        return s.children.indexOf(s._pictureContainer);
    };

    DreamX.ITB.Scene_Battle_createSpriteset = Scene_Battle.prototype.createSpriteset;
    Scene_Battle.prototype.createSpriteset = function () {
        DreamX.ITB.Scene_Battle_createSpriteset.call(this);
        if (parameterShowTurnOrder) {
            this.createTurnOrderWindowITB();
        }

    };

    Scene_Battle.prototype.createTurnOrderWindowITB = function () {
        this._ITBTurnWindow = new Window_ITBTurnOrder();
        this._spriteset.addChild(this._ITBTurnWindow);
    };

    //==========================================================================
    // Window_ITBTurnOrder
    //==========================================================================

    function Window_ITBTurnOrder() {
        this.initialize.apply(this, arguments);
    }

    Window_ITBTurnOrder.prototype = Object.create(Window_Selectable.prototype);
    Window_ITBTurnOrder.prototype.constructor = Window_ITBTurnOrder;

    Window_ITBTurnOrder.prototype.initialize = function () {

        Window_Selectable.prototype.initialize.call(this, this.windowX(),
                this.windowY(), this.windowWidth(), this.windowHeight());

        this.makeTurnOrders();
        this.opacity = parameterTurnOpacity;
    };

    Window_ITBTurnOrder.prototype.windowX = function () {
        return this.isHorizontal() ? this.windowXHorizontal()
                : this.windowXVertical();
    };
    Window_ITBTurnOrder.prototype.windowY = function () {
        return this.isHorizontal() ? this.windowYHorizontal()
                : this.windowYVertical();
    };

    Window_ITBTurnOrder.prototype.windowXHorizontal = function () {
        return parseInt(eval(parameterTurnWindowXHorizontal));
    };
    Window_ITBTurnOrder.prototype.windowXVertical = function () {
        return parseInt(eval(parameterTurnWindowXVertical));
    };

    Window_ITBTurnOrder.prototype.windowYHorizontal = function () {
        return parseInt(eval(parameterTurnWindowYHorizontal));
    };
    Window_ITBTurnOrder.prototype.windowYVertical = function () {
        return parseInt(eval(parameterTurnWindowYVertical));
    };

    Window_ITBTurnOrder.prototype.windowWidth = function () {
        return this.isHorizontal() ? this.windowWidthHorizontal()
                : this.windowWidthVertical();
    };

    Window_ITBTurnOrder.prototype.windowHeight = function () {
        return this.isHorizontal() ? this.windowHeightHorizontal()
                : this.windowHeightVertical();
    };

    Window_ITBTurnOrder.prototype.windowWidthHorizontal = function () {
        return eval(parameterTurnWindowWidthHorizontal);
    };
    Window_ITBTurnOrder.prototype.windowWidthVertical = function () {
        return eval(parameterTurnWindowWidthVertical);
    };

    Window_ITBTurnOrder.prototype.windowHeightHorizontal = function () {
        return eval(parameterTurnWindowHeightHorizontal);
    };
    Window_ITBTurnOrder.prototype.windowHeightVertical = function () {
        return eval(parameterTurnWindowHeightVertical);
    };

    Window_ITBTurnOrder.prototype.update = function () {
        Window_Base.prototype.update.call(this);
        this.refresh();

        var battleEnded = Imported.YEP_VictoryAftermath
                ? BattleManager.isVictoryPhase() : BattleManager.isBattleEnd();
        if (parameterHideOnBattleResults && battleEnded) {
            this.parent.removeChild(this);
        }
    };

    Window_ITBTurnOrder.prototype.makeTurnOrders = function () {
        var turnBattlers = BattleManager.ITBBattlersThisTurn();
        var allBattlers = BattleManager.ITBBattlers();
        var data = [];

        for (var i = 0; i < turnBattlers.length; i++) {
            var battler = turnBattlers[i];
            this.handleBattler(battler, data, false);
        }
        if (parameterShowEndTurn) {
            data.push({sheetName: parameterTurnWindowEndSheet,
                sheetIndex: parameterTurnWindowEndIndex,
            });
        }
        if (parameterShowNextTurn) {
            for (var i = 0; i < allBattlers.length; i++) {
                var battler = allBattlers[i];
                this.handleBattler(battler, data, true);
            }
        }

        this._data = data;
    };

    Window_ITBTurnOrder.prototype.handleBattler = function (battler, array,
            nextTurn) {
        if (!paramShowDead && battler.isDead()) {
            return;
        }
        var sheetName = "";
        var sheetIndex = -1;
        var obj = {};
        var dataBattler = battler.isActor() ? battler.actor()
                : battler.enemy();
        var icons = 1;
        var letter = "";
        var numActions = battler.numITBActionsForTurnWindow();
        var generate = paramGenerateIcons && !dataBattler.meta.ITBSheetIndex;

        if (dataBattler.meta.ITBSheetIndex) {
            if (dataBattler.meta.ITBSheetIndex) {
                sheetName = dataBattler.meta.ITBSheet ? dataBattler.meta.ITBSheet
                        : parameterTurnDefaultSheet;
                sheetName = sheetName.trim();
                sheetIndex = parseInt(dataBattler.meta.ITBSheetIndex.trim());
            }

            // check if more than one enemy of same type
            if (battler._plural) {
                letter = battler._letter;
            }

            if (parameterActionDisplayType === 2
                    || parameterActionDisplayType === 4) {
                icons = numActions;

                if (parameterMaxActionIcons > 1
                        && icons > parameterMaxActionIcons) {
                    icons = parameterActionDisplayType === 4 ? 1
                            : parameterMaxActionIcons;
                }
            }

            if (nextTurn) {
                icons = 1;
                numActions = 1;
            }

            obj = {
                sheetName: sheetName,
                sheetIndex: sheetIndex,
                letter: letter,
                actions: numActions,
                generate: generate,
                gameBattler: battler
            };

            for (var i = 0; i < icons; i++) {
                array.push(obj);
            }
        }
    };

    Window_ITBTurnOrder.prototype.iconWidth = function () {
        return parameterTurnIconWidth;
    };
    Window_ITBTurnOrder.prototype.iconHeight = function () {
        return parameterTurnIconHeight;
    };

    Window_ITBTurnOrder.prototype.refresh = function () {
        this.makeTurnOrders();
        this.contents.clear();
        this.drawTurnIcons();
    };

    Window_ITBTurnOrder.prototype.getSheetBitmap = function (battler) {
        var sheetName = battler.sheetName;
        return ImageManager.loadBitmap(parameterTurnFolder, sheetName);
    };

    Window_ITBTurnOrder.prototype.drawTurnIconGenerated = function (battler, x, y) {
        var bitmap = this.getBitmap(battler);
        var width = Window_Base._faceWidth;

    };

    Window_ITBTurnOrder.prototype.drawTurnIconSheet = function (battler, x, y) {
        var bitmap = this.getSheetBitmap(battler);
        var columns = parameterIconSheetCols;
        var rows = parameterIconSheetRows;
        var sheetName = battler.sheetName;
        var index = battler.sheetIndex;
        var width;
        var height;
        var newCoor;
        var windowWidthHeight = this.isHorizontal() ? this.windowWidth()
                : this.windowHeight();

        if (sheetName.split(" ").length === 3) {
            columns = sheetName.split(" ")[1];
            rows = sheetName.split(" ")[2];
        }

        width = bitmap.width / columns;
        height = bitmap.height / rows;

        if (this.isHorizontal()) {
            newCoor = x + width + parameterTurnIconSpacing;
        } else {
            newCoor = y + height + parameterTurnIconSpacing;
        }

        if (parameterPreventCutoff && newCoor > windowWidthHeight - this.standardPadding()) {
            return -1;
        }

        var sx = (index % columns) * width;
        var sy = Math.floor(index / columns) * height;

        this.contents.blt(bitmap, sx, sy, width, height, x, y);

        return newCoor;
    };

    Window_ITBTurnOrder.prototype.drawTurnIcon = function (battler, x, y) {
        var letterX = eval(parameterPluralX);
        var letterY = eval(parameterPluralY);
        var actionX = eval(parameterActionNumX);
        var actionY = eval(parameterActionNumY);

        var newCoor = battler.generate ? 0
                : this.drawTurnIconSheet(battler, x, y);

        if (paramShowPlural && battler.letter) {
            this.contents.fontSize = eval(parameterPluralSize);
            this.drawText(battler.letter, letterX, letterY);
        }
        var actions = battler.actions;
        if (parameterActionDisplayType === 3
                || (parameterActionDisplayType === 4
                        && parameterMaxActionIcons > 1
                        && actions > parameterMaxActionIcons)) {

            if (paramShowActionMin <= actions) {
                this.contents.fontSize = eval(parameterActionNumSize);
                this.drawText(actions, actionX, actionY);
            }
        }

        return newCoor;
    };

    Window_ITBTurnOrder.prototype.drawTurnIcons = function () {
        var x = 0;
        var y = 0;
        var max = parameterMaxIcons ? parameterMaxIcons : this._data.length;

        for (var i = 0; i < max; i++) {
            var xY = this.drawTurnIcon(this._data[i], x, y);
            if (this.isHorizontal()) {
                x = xY;
            } else {
                y = xY;
            }
            if (x === -1 || y === -1) {
                break;
            }
        }
    };

    Window_ITBTurnOrder.prototype.isHorizontal = function () {
        return parameterTurnIconOrientation === 'horizontal';
    };

    Window_ITBTurnOrder.prototype.standardPadding = function () {
        return eval(paramPadding);
    };

//=============================================================================
// Game_Action
//=============================================================================
    DreamX.ITB.BattleManager_startAction = BattleManager.startAction;
    BattleManager.startAction = function () {
        var subject = this._subject;
        var action = subject.currentAction();
        if (action) {
            var item = action.item();
            if (item.meta.free_itb_action) {
                subject.addITBActions(1);
            }
        }
        DreamX.ITB.BattleManager_startAction.call(this);
    };

    // action is "free" if free_itb_action notetag present
    DreamX.ITB.Game_Action_apply = Game_Action.prototype.apply;
    Game_Action.prototype.apply = function (target) {
        DreamX.ITB.Game_Action_apply.call(this, target);
        var result = target.result();
        if (!result.isHit()) {
            return;
        }
        var item = this.item();
        if (item.meta.reAddBattler) {
            BattleManager.addBattler(target);
        }
    };

    Game_Action.prototype.handleElementalExtraActions = function (user, target) {
        var addedExtraFromElemental = false;

        if (eval(paramMaxElementExtraActions) !== 0) {
            var dataTarget = target.isEnemy() ? $dataEnemies[target.enemyId()] :
                    $dataActors[target.actorId()];

            var weaknessStateID = dataTarget.meta.elemWeaknessState
                    ? dataTarget.meta.elemWeaknessState
                    : eval(paramElementWeaknessState);

            if (this.calcElementRate(target) > 1) {
                // add an extra action to user
                if (target.allowExtraElemWeaknessAction(user)) {
                    var timesWeaknessHit = target._weaknessHitMap.get(user)
                            ? target._weaknessHitMap.get(user) : 0;
                    target._weaknessHitMap.set(user, timesWeaknessHit + 1);
                    user.extraElementalWeaknessAction();

                    if (Imported['VE - Damge Popup'] && paramShowExtraActionPopup) {
                        user.callCustomPopup(paramShowExtraActionPopupText,
                                paramShowExtraActionPopupMotion,
                                paramShowExtraActionPopupFont,
                                paramShowExtraActionPopupSize,
                                paramShowExtraActionPopupColor,
                                paramShowExtraActionPopupX,
                                paramShowExtraActionPopupY);
                    }

                }

                // apply state to target here
                if (parseInt(weaknessStateID) >= 1) {
                    target.addState(weaknessStateID);
                }

                addedExtraFromElemental = true;
            }
        }

        return addedExtraFromElemental;
    };

    // extra actions for hitting enemy weakness
    DreamX.ITB.Game_Action_makeDamageValue = Game_Action.prototype.makeDamageValue;
    Game_Action.prototype.makeDamageValue = function (target, critical) {
        // if param set to 0, it's disabled
        if (BattleManager.isITB()) {
            var user = this.subject();

            var addedExtraFromElemental = this.handleElementalExtraActions(user, target);

            if (critical) {
//                user.extraElementalWeaknessAction();
            }
        }

        return DreamX.ITB.Game_Action_makeDamageValue.call(this, target, critical);
    };

//-----------------------------------------------------------------------------
// Sprite_ReadyOverlay
//
// The sprite for displaying the ready image for an actor.

    DreamX.ITB.Sprite_Actor_setBattler = Sprite_Actor.prototype.setBattler;
    Sprite_Actor.prototype.setBattler = function (battler) {
        DreamX.ITB.Sprite_Actor_setBattler.call(this, battler);
        if (paramaterReadyOverlayEnabled) {
            this._readySprite.setup(battler);
        }
    };

    DreamX.ITB.Sprite_Actor_initMembers = Sprite_Actor.prototype.initMembers;
    Sprite_Actor.prototype.initMembers = function () {
        DreamX.ITB.Sprite_Actor_initMembers.call(this);
        if (paramaterReadyOverlayEnabled) {
            this.createReadySprite();
        }
    };

    Sprite_Actor.prototype.createReadySprite = function () {
        this._readySprite = new Sprite_ReadyOverlay();
        this.addChild(this._readySprite);
    };

    function Sprite_ReadyOverlay() {
        this.initialize.apply(this, arguments);
    }

    Sprite_ReadyOverlay.prototype = Object.create(Sprite_Base.prototype);
    Sprite_ReadyOverlay.prototype.constructor = Sprite_ReadyOverlay;

    Sprite_ReadyOverlay.prototype.initialize = function () {
        Sprite_Base.prototype.initialize.call(this);
        this.initMembers();
        this.loadBitmap();
    };

    Sprite_ReadyOverlay.prototype.initMembers = function () {
        this._battler = null;
        this._overlayIndex = 0;
        this._animationCount = 0;
        this._pattern = 0;
        this.anchor.x = parameterReadyAnchorX;
        this.anchor.y = parameterReadyAnchorY;
    };

    Sprite_ReadyOverlay.prototype.loadBitmap = function () {
        this.bitmap = ImageManager.loadSystem(parameterReadyOverlayName);
        this.setFrame(0, 0, 0, 0);
    };

    Sprite_ReadyOverlay.prototype.setup = function (battler) {
        this._battler = battler;
    };

    Sprite_ReadyOverlay.prototype.update = function () {
        Sprite_Base.prototype.update.call(this);
        this._animationCount++;
        if (this._animationCount >= this.animationWait()) {
            this.updatePattern();
            this.updateFrame();
            this._animationCount = 0;
        }
    };

    Sprite_ReadyOverlay.prototype.animationWait = function () {
        return 8;
    };

    Game_BattlerBase.prototype.readyOverlayIndex = function () {
        return parameterReadyOverlayIndex;
    };
    Sprite_ReadyOverlay.prototype.updatePattern = function () {
        this._pattern++;
        this._pattern %= 8;
        if (this._battler && this._battler === BattleManager.actor() && BattleManager._phase === 'input') {
            this._overlayIndex = this._battler.readyOverlayIndex() + 1;
            this.opacity = 255;
        } else {
            this.opacity = 0;
        }
    };

    Sprite_ReadyOverlay.prototype.updateFrame = function () {
        if (this._overlayIndex > 0) {
            var w = 96;
            var h = 96;
            var sx = this._pattern * w;
            var sy = (this._overlayIndex - 1) * h;
            this.setFrame(sx, sy, w, h);
        } else {
            this.setFrame(0, 0, 0, 0);
        }
    };

//=============================================================================
// Compatibility
//=============================================================================
    if (Imported.YEP_BattleAICore) {
        DreamX.ITB.BattleManager_updateAIPatterns = BattleManager.updateAIPatterns;
        BattleManager.updateAIPatterns = function () {
            if (BattleManager.isITB()) {
                return;
            }
            DreamX.ITB.BattleManager_updateAIPatterns.call(this);
        };
    }

})();

repo_name: Rexhunk/karryn

license: unknown


code:
//=============================================================================
// EnemyBook.js
//=============================================================================

/*:
 * @plugindesc Displays detailed statuses of enemies.
 * @author Yoji Ojima
 *
 * @param Unknown Data
 * @desc The index name for an unknown enemy.
 * @default ??????
 *
 * @help
 *
 * Plugin Command:
 *   EnemyBook open         # Open the enemy book screen
 *   EnemyBook add 3        # Add enemy #3 to the enemy book
 *   EnemyBook remove 4     # Remove enemy #4 from the enemy book
 *   EnemyBook complete     # Complete the enemy book
 *   EnemyBook clear        # Clear the enemy book
 *
 * Enemy Note:
 *   <desc1:foobar>         # Description text in the enemy book, line 1
 *   <desc2:blahblah>       # Description text in the enemy book, line 2
 *   <book:no>              # This enemy does not appear in the enemy book
 */

/*:ja
 * @plugindesc モンスター図鑑です。敵キャラの詳細なステータスを表示します。
 * @author Yoji Ojima
 *
 * @param Unknown Data
 * @desc 未確認の敵キャラの索引名です。
 * @default ？？？？？？
 *
 * @help
 *
 * プラグインコマンド:
 *   EnemyBook open         # 図鑑画面を開く
 *   EnemyBook add 3        # 敵キャラ３番を図鑑に追加
 *   EnemyBook remove 4     # 敵キャラ４番を図鑑から削除
 *   EnemyBook complete     # 図鑑を完成させる
 *   EnemyBook clear        # 図鑑をクリアする
 *
 * 敵キャラのメモ:
 *   <desc1:なんとか>       # 説明１行目
 *   <desc2:かんとか>       # 説明２行目
 *   <book:no>              # 図鑑に載せない場合
 */

(function() {

    var parameters = PluginManager.parameters('EnemyBook');
    var unknownData = String(parameters['Unknown Data'] || '??????');

    var _Game_Interpreter_pluginCommand =
            Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
        _Game_Interpreter_pluginCommand.call(this, command, args);
        if (command === 'EnemyBook') {
            switch (args[0]) {
            case 'open':
                SceneManager.push(Scene_EnemyBook);
                break;
            case 'add':
                $gameSystem.addToEnemyBook(Number(args[1]));
                break;
            case 'remove':
                $gameSystem.removeFromEnemyBook(Number(args[1]));
                break;
            case 'complete':
                $gameSystem.completeEnemyBook();
                break;
            case 'clear':
                $gameSystem.clearEnemyBook();
                break;
            }
        }
    };

    Game_System.prototype.addToEnemyBook = function(enemyId) {
        if (!this._enemyBookFlags) {
            this.clearEnemyBook();
        }
        this._enemyBookFlags[enemyId] = true;
    };

    Game_System.prototype.removeFromEnemyBook = function(enemyId) {
        if (this._enemyBookFlags) {
            this._enemyBookFlags[enemyId] = false;
        }
    };

    Game_System.prototype.completeEnemyBook = function() {
        this.clearEnemyBook();
        for (var i = 1; i < $dataEnemies.length; i++) {
            this._enemyBookFlags[i] = true;
        }
    };

    Game_System.prototype.clearEnemyBook = function() {
        this._enemyBookFlags = [];
    };

    Game_System.prototype.isInEnemyBook = function(enemy) {
        if (this._enemyBookFlags && enemy) {
            return !!this._enemyBookFlags[enemy.id];
        } else {
            return false;
        }
    };

    var _Game_Troop_setup = Game_Troop.prototype.setup;
    Game_Troop.prototype.setup = function(troopId) {
        _Game_Troop_setup.call(this, troopId);
        this.members().forEach(function(enemy) {
            if (enemy.isAppeared()) {
                $gameSystem.addToEnemyBook(enemy.enemyId());
            }
        }, this);
    };

    var _Game_Enemy_appear = Game_Enemy.prototype.appear;
    Game_Enemy.prototype.appear = function() {
        _Game_Enemy_appear.call(this);
        $gameSystem.addToEnemyBook(this._enemyId);
    };

    var _Game_Enemy_transform = Game_Enemy.prototype.transform;
    Game_Enemy.prototype.transform = function(enemyId) {
        _Game_Enemy_transform.call(this, enemyId);
        $gameSystem.addToEnemyBook(enemyId);
    };

    function Scene_EnemyBook() {
        this.initialize.apply(this, arguments);
    }

    Scene_EnemyBook.prototype = Object.create(Scene_MenuBase.prototype);
    Scene_EnemyBook.prototype.constructor = Scene_EnemyBook;

    Scene_EnemyBook.prototype.initialize = function() {
        Scene_MenuBase.prototype.initialize.call(this);
    };

    Scene_EnemyBook.prototype.create = function() {
        Scene_MenuBase.prototype.create.call(this);
        this._indexWindow = new Window_EnemyBookIndex(0, 0);
        this._indexWindow.setHandler('cancel', this.popScene.bind(this));
        var wy = this._indexWindow.height;
        var ww = Graphics.boxWidth;
        var wh = Graphics.boxHeight - wy;
        this._statusWindow = new Window_EnemyBookStatus(0, wy, ww, wh);
        this.addWindow(this._indexWindow);
        this.addWindow(this._statusWindow);
        this._indexWindow.setStatusWindow(this._statusWindow);
    };

    function Window_EnemyBookIndex() {
        this.initialize.apply(this, arguments);
    }

    Window_EnemyBookIndex.prototype = Object.create(Window_Selectable.prototype);
    Window_EnemyBookIndex.prototype.constructor = Window_EnemyBookIndex;

    Window_EnemyBookIndex.lastTopRow = 0;
    Window_EnemyBookIndex.lastIndex  = 0;

    Window_EnemyBookIndex.prototype.initialize = function(x, y) {
        var width = Graphics.boxWidth;
        var height = this.fittingHeight(6);
        Window_Selectable.prototype.initialize.call(this, x, y, width, height);
        this.refresh();
        this.setTopRow(Window_EnemyBookIndex.lastTopRow);
        this.select(Window_EnemyBookIndex.lastIndex);
        this.activate();
    };

    Window_EnemyBookIndex.prototype.maxCols = function() {
        return 3;
    };

    Window_EnemyBookIndex.prototype.maxItems = function() {
        return this._list ? this._list.length : 0;
    };

    Window_EnemyBookIndex.prototype.setStatusWindow = function(statusWindow) {
        this._statusWindow = statusWindow;
        this.updateStatus();
    };

    Window_EnemyBookIndex.prototype.update = function() {
        Window_Selectable.prototype.update.call(this);
        this.updateStatus();
    };

    Window_EnemyBookIndex.prototype.updateStatus = function() {
        if (this._statusWindow) {
            var enemy = this._list[this.index()];
            this._statusWindow.setEnemy(enemy);
        }
    };

    Window_EnemyBookIndex.prototype.refresh = function() {
        this._list = [];
        for (var i = 1; i < $dataEnemies.length; i++) {
            var enemy = $dataEnemies[i];
            if (enemy.name && enemy.meta.book !== 'no') {
                this._list.push(enemy);
            }
        }
        this.createContents();
        this.drawAllItems();
    };

    Window_EnemyBookIndex.prototype.drawItem = function(index) {
        var enemy = this._list[index];
        var rect = this.itemRectForText(index);
        var name;
        if ($gameSystem.isInEnemyBook(enemy)) {
            name = enemy.name;
        } else {
            name = unknownData;
        }
        this.drawText(name, rect.x, rect.y, rect.width);
    };

    Window_EnemyBookIndex.prototype.processCancel = function() {
        Window_Selectable.prototype.processCancel.call(this);
        Window_EnemyBookIndex.lastTopRow = this.topRow();
        Window_EnemyBookIndex.lastIndex = this.index();
    };

    function Window_EnemyBookStatus() {
        this.initialize.apply(this, arguments);
    }

    Window_EnemyBookStatus.prototype = Object.create(Window_Base.prototype);
    Window_EnemyBookStatus.prototype.constructor = Window_EnemyBookStatus;

    Window_EnemyBookStatus.prototype.initialize = function(x, y, width, height) {
        Window_Base.prototype.initialize.call(this, x, y, width, height);
        this._enemy = null;
        this._enemySprite = new Sprite();
        this._enemySprite.anchor.x = 0.5;
        this._enemySprite.anchor.y = 0.5;
        this._enemySprite.x = width / 2 + 90;
        this._enemySprite.y = height / 2;
        this.addChildToBack(this._enemySprite);
        this.refresh();
    };

    Window_EnemyBookStatus.prototype.setEnemy = function(enemy) {
        if (this._enemy !== enemy) {
            this._enemy = enemy;
            this.refresh();
        }
    };

    Window_EnemyBookStatus.prototype.update = function() {
        Window_Base.prototype.update.call(this);
        if (this._enemySprite.bitmap) {
            var bitmapHeight = this._enemySprite.bitmap.height;
            var contentsHeight = this.contents.height;
            var scale = 1;
            if (bitmapHeight > contentsHeight) {
                scale = contentsHeight / bitmapHeight;
            }
            this._enemySprite.scale.x = scale;
            this._enemySprite.scale.y = scale;
        }
    };

    Window_EnemyBookStatus.prototype.refresh = function() {
        var enemy = this._enemy;
        var x = 0;
        var y = 0;
        var lineHeight = this.lineHeight();

        this.contents.clear();

        if (!enemy || !$gameSystem.isInEnemyBook(enemy)) {
            this._enemySprite.bitmap = null;
            return;
        }

        var name = enemy.battlerName;
        var hue = enemy.battlerHue;
        var bitmap;
        if ($gameSystem.isSideView()) {
            bitmap = ImageManager.loadSvEnemy(name, hue);
        } else {
            bitmap = ImageManager.loadEnemy(name, hue);
        }
        this._enemySprite.bitmap = bitmap;

        this.resetTextColor();
        this.drawText(enemy.name, x, y);

        x = this.textPadding();
        y = lineHeight + this.textPadding();

        for (var i = 0; i < 4; i++) {
            this.changeTextColor(this.systemColor());
            this.drawText(TextManager.param(i), x, y, 160);
            this.resetTextColor();
            this.drawText(enemy.params[i], x + 160, y, 60, 'right');
            y += lineHeight;
        }

        var rewardsWidth = 280;
  //     x = this.contents.width - rewardsWidth;
  //      y = lineHeight + this.textPadding();

        this.resetTextColor();
        this.drawText(enemy.exp, x, y);
        x += this.textWidth(enemy.exp) + 6;
        this.changeTextColor(this.systemColor());
        this.drawText(TextManager.expA, x, y);
        x += this.textWidth(TextManager.expA + '  ');

        this.resetTextColor();
        this.drawText(enemy.gold, x, y);
        x += this.textWidth(enemy.gold) + 6;
        this.changeTextColor(this.systemColor());
        this.drawText(TextManager.currencyUnit, x, y);

 //       x = this.contents.width - rewardsWidth;
        y += lineHeight;

        for (var j = 0; j < enemy.dropItems.length; j++) {
            var di = enemy.dropItems[j];
            if (di.kind > 0) {
                var item = Game_Enemy.prototype.itemObject(di.kind, di.dataId);
                this.drawItemName(item, 0, y, rewardsWidth);
                y += lineHeight;
            }
        }

       var descWidth = 480;
  //      x = this.contents.width - descWidth;
  //      y = this.textPadding() + lineHeight * 7;
        this.drawTextEx(enemy.meta.desc1, 0, y + lineHeight * 0, descWidth);
        this.drawTextEx(enemy.meta.desc2, 0, y + lineHeight * 1, descWidth);
    };

})();


code:
//=============================================================================
// EventEffects.js (Ver1.0.1)
//=============================================================================
// Ver 1.0.0  2017.May.05  First Release
// Ver 1.0.1  2018.Aug.23  Fix bug of wait behaviour on parallel events.

/*:
 * @plugindesc [Ver 1.0.1] set various effects to events and player
 * @author Sasuke KANNAZUKI
 *
 * @help This plugin does not provide plugin commands.
 *
 * Call follows from 'Move Route' -> 'Script'.
 * ■change tint
 * this.tint(Array[red,green,blue,gray], # of frame ,waitFlag);
 * color: -255～255, 60frame = 1sec.
 * ex：
 * this.tint([255,255,255,0], 20, true);  # whiten within 20 frames
 * this.tint([0,0,0,0], 20, true);        # reset within 20 frames
 * ■change opacity
 * this.opaque(opacity, # of frame, waitFlag);
 * this.opaque(128, 20, true);        # set half-transparent within 20 frames
 * ■set above of all
 * this.tint2(Array[red,green,blue,gray], opacity, # of frame ,waitFlag);
 * this.tint2([64,64,64,0], 20, 128, false);
 *   # set whithen and half-transparent in 20 franmes
 *
 * ■shorten notation of tint
 * this.tintB(frame, waitF);   # change tint to be Black(=[-255,-255,-255,0])
 * this.tintW(frame, waitF);   # change tint to be White(=[255,255,255,0])
 * this.tintN(frame, waitF);   # change tint to be Normal(=[0,0,0,0])
 * above of all, frame and waitF are omissible.
 * default value is frame=60, waitF=true.
 *
 * ■baloon icon
 * this.balloon(num, wait);   # num:1～10, wait:true/false
 * num: 1/exclamation, 2/question, 3/music note, 4/heart, 5/anger,
 * 6/sweat, 7/cobweb, 8/silence, 9/light bulb, 10/Zzz
 * 例：
 * this.balloon(1, true);     # exclamation icon with wait
 * this.balloon(2, false);    # qustion icon without wait
 *
 * ■set up side down
 * this.setUpSideDown();        # display up side down
 * this.resetUpSideDown();      # stop up side down
 * note: this function is realized by rotating 180 degree and changing offsets.
 * ■set angle
 * this.setAngle(90);           # set right 90 degree
 * this.setAngle(-90);          # set left 90 degree
 * this.setAngle(0);            # set original angle
 * ■set offset
 * this.setOffsets(10,20);      # set X+10, Y+20
 * this.setOffsets(0,0);        # set original position
 * ■set above of all:
 * this.setEffects(ox,oy,usd,angle);
 * ox,oy:offsets, usd:flag up side down(true/false), angle:degree(360 is round)
 * 例：
 * this.setEffects(-15,20,false,45); #move(-15,20), rotate 45 defree clockwise
 *
 * ■priority type
 * this.setPriorityType(priority);  # priority 0:under 1:normal 2:over
 * note: this is preset function.
 *
 * ■Change character with cross fade
 * this.setGrid2(dir, pattern, frames, wait);
 * this.setImageGrid2(name, index, dir, pattern, frames, wait);
 * dir=2,4,6,or8, pattern=0,1,or2, frames(60frame=1sec), wait: wait until end?
 * name=character graphic name, index=character index(0～7)
 *
 * ■Set Offset and Viewport
 * this.setOffset2(dx, dy[, slx, sly, srx, sry]);
 *   (dx, dy): Offset Coord.
 *   (slx, sly) - (srx, sry): range of viewport of character bitmap.
 *    | when these 4 parameters are omitted, it'll be all range of character.
 * this.resetOffset2();
 *   reset setting of setOffset2.
 *
 * [License]
 * this plugin is released under MIT license.
 * http://opensource.org/licenses/mit-license.php
 */
/*:ja
 * @plugindesc [Ver 1.0.1]イベントやプレイヤーに様々な効果をセットします
 * @author 神無月サスケ
 *
 * @help このプラグインには、プラグインコマンドはありません。
 *
 * 「移動ルートの設定」で「スクリプト」から以下の書式で呼び出してください：
 * ■色合いの変更
 * this.tint(色合いの配列[赤,緑,青,灰], フレーム数, 終了まで待つか);
 * 色：-255～255, 60フレーム＝1秒
 * 例：
 * this.tint([255,255,255,0], 20, true);  # 20フレームで真っ白に変化
 * this.tint([0,0,0,0], 20, true);        # 20フレームで元の色に戻す
 * ■不透明度の変更
 * this.opaque(不透明度, フレーム数, 終了までwaitか);
 * this.opaque(128, 20, true);        # 20 フレームで不透明度を128(半透明)に
 * ■一括設定
 * this.tint2(色合いの配列[赤,緑,青,灰], 不透明度, フレーム数, 終了までwait);
 * this.tint2([64,64,64,0], 128, 20, false);  # 20フレームで白化と半透明に
 *
 * ■色合い変更の短縮指定
 * this.tintB(フレーム数, 待つか);   # 色合いを黒(=[-255,-255,-255,0])にします
 * this.tintW(フレーム数, 待つか);   # 色合いを白(=[255,255,255,0])にします。
 * this.tintN(フレーム数, 待つか);   # 色合いを通常(=[0,0,0,0])にします。
 * 上記の「フレーム数」と「待つか」は省略可能です。
 * 省略時は「フレーム数」=60、「待つか」=trueになります。
 *
 * ■フキダシアイコン
 * this.balloon(num, wait);   # num:1～10, wait:true/false
 * num: 1/びっくり, 2/はてな, 3/音符, 4/ハート, 5/怒り, 6/汗
 * 7/くしゃくしゃ, 8/沈黙, 9/電球, 10/Zzz
 * 例：
 * this.balloon(1, true);     # びっくりアイコン、ウェイトあり
 * this.balloon(2, false);    # はてなアイコン、ウェイトなし
 *
 * ■上下反転
 * this.setUpSideDown();        # 反転表示
 * this.resetUpSideDown();      # 反転表示終了
 * 注意：上下反転は180度回転＋位置移動で実現しています。
 * ■角度設定
 * this.setAngle(90);           # 90度右回転(元の姿勢から見て)
 * this.setAngle(-90);          # 90度左回転(元の姿勢から見て)
 * this.setAngle(0);            # 元の姿勢に戻す
 * ■オフセット(位置補正)設定
 * this.setOffsets(10,20);      # X右方向に10,Y左方向に20移動
 * this.setOffsets(0,0);        # 元の位置に戻す
 * ■一括設定
 * this.setEffects(ox,oy,usd,angle);
 * ox,oy:オフセット値, usd:逆さまか(true/false), angle:角度(一周=360度)
 * 例：
 * this.setEffects(-15,20,false,45); #(-15,20)ずらし、逆さまにせず 45度右回転
 *
 * ■プライオリティ
 * this.setPriorityType(0);         # 通常キャラの下に
 * this.setPriorityType(1);         # 通所キャラと同じに
 * this.setPriorityType(2);         # 通常キャラの上に
 * ↑これはコアスクリプトに入っています。ページが切り替わると元に戻ります。
 *
 * ■クロスフェードさせてキャラ画像変更
 * this.setGrid2(dir, pattern, frames, wait);
 * this.setImage2(name, index, frames, wait);
 * this.setImageGrid2(name, index, dir, pattern, frames, wait);
 * dir=向き(2,4,6,8), pattern=0,1,or2, frames=フレーム数, wait=完了まで待つ？
 * name=画像名, index=画像内インデックス(0～7)
 *
 * ■視点範囲を制限したオフセット指定
 * this.setOffset2(dx, dy[, slx, sly, srx, sry]);
 *   (dx, dy):表示するオフセット(この座標だけずらす)
 *   (slx, sly) - (srx, sry): 画像の表示範囲座標(省略時はキャラのサイズ)
 * this.resetOffset2();
 *   setOffset2 の設定をリセット
 *
 * ■Ver1.0.1 変更点：並列処理中にイベントのある処理を行うと
 * うまく作動しなかったバグを修正
 *
 * ■ライセンス表記
 * このプラグインは MIT ライセンスで配布されます。
 * ご自由にお使いください。
 * http://opensource.org/licenses/mit-license.php
 */

(function() {

  var _Game_CharacterBase_initialize = Game_CharacterBase.prototype.initialize;
  Game_CharacterBase.prototype.initialize = function() {
    _Game_CharacterBase_initialize.call(this);
    this.initTone();
    this.initEffects();
    this.initImageGrid();
  };

  var _Game_CharacterBase_update = Game_CharacterBase.prototype.update;
  Game_CharacterBase.prototype.update = function() {
    this.updateTone();
    this.updateOpacity();
    this.updateImageGrid();
    _Game_CharacterBase_update.call(this);
  };

  var _Sprite_Character_update = Sprite_Character.prototype.update;
  Sprite_Character.prototype.update = function() {
    _Sprite_Character_update.call(this);
    this.updateTone();
    this.updateAngle();
    this.updateCrossFade();
  };

  Game_CharacterBase.prototype.currentInterpreter = function () {
    return this._trigger === 4 ? this._interpreter :  $gameMap._interpreter;
  };

  // ----------------------------------------
  // set tone and opacity
  //
  Game_CharacterBase.prototype.initTone = function() {
    this._tone = null;
    this._toneTarget = null;
    this._toneDuration = 0;
    this._opacityTarget = null;
    this._opacityDuration = 0;
  };

  // this function is called from 'Move Route' -> 'Script'.
  Game_CharacterBase.prototype.tint = function(tone, duration, needsWait) {
    if (!this._tone) {
      this._tone = [0, 0, 0, 0];
    }
    this._toneTarget = tone.clone();
    this._toneDuration = duration;
    if (this._toneDuration === 0) {
      this._tone = this._toneTarget.clone();
    }
    if (needsWait) {
      this.currentInterpreter().wait(duration);
      this._waitCount = duration;
    }
  };

  //
  // shorten notations of tint.
  //
  Game_CharacterBase.prototype.tintB = function (duration, needsWait) {
    duration = duration != null ? duration : 60;
    needsWait = needsWait != null ? needsWait : true;
    this.tint([-255,-255,-255,0], duration, needsWait);
  };

  Game_CharacterBase.prototype.tintW = function (duration, needsWait) {
    duration = duration != null ? duration : 60;
    needsWait = needsWait != null ? needsWait : true;
    this.tint([255,255,255,0], duration, needsWait);
  };

  Game_CharacterBase.prototype.tintN = function (duration, needsWait) {
    duration = duration != null ? duration : 60;
    needsWait = needsWait != null ? needsWait : true;
    this.tint([0,0,0,0], duration, needsWait);
  };

  // this function is called from 'Move Route' -> 'Script'.
  Game_CharacterBase.prototype.opaque = function(opacity, duration, fWait) {
    this._opacityTarget = opacity;
    this._opacityDuration = duration;
    if (this._opacityDuration === 0) {
      this._opacity = this._opacityTarget;
    }
    if (fWait) {
      this.currentInterpreter().wait(duration);
      this._waitCount = duration;
    }
  };

  // this function is called from 'Move Route' -> 'Script'.
  Game_CharacterBase.prototype.tint2 = function(tone, opacity, d, wait) {
    this.tint(tone, d, false);
    this.opaque(opacity, d, wait);
  };

  Game_CharacterBase.prototype.updateTone = function() {
    this._toneDuration = this._toneDuration || 0;
    if (this._toneDuration > 0) {
      var d = this._toneDuration;
      for (var i = 0; i < 4; i++) {
        this._tone[i] = (this._tone[i] * (d - 1) + this._toneTarget[i]) / d;
      }
      this._toneDuration--;
    }
  };

  Game_CharacterBase.prototype.updateOpacity = function() {
    this._opacityDuration = this._opacityDuration || 0;
    if (this._opacityDuration > 0) {
      var d = this._opacityDuration;
      this._opacity = (this._opacity * (d - 1) + this._opacityTarget) / d;
      this._opacityDuration--;
    }
  };

  Game_CharacterBase.prototype.tone = function() {
    return this._tone;
  };

  Sprite_Character.prototype.updateTone = function() {
    if (this._character.tone()) {
      this.setColorTone(this._character.tone());
    }
  };

  // ----------------------------------------
  // set ballon icon
  //
  Game_CharacterBase.prototype.balloon = function(num, wait) {
    this._balloonId = num;
    if (wait) {
      this.currentInterpreter().setWaitMode('balloon');
      this._waitCount = 76;
    }
    return true;
  };

  // ----------------------------------------
  // set offset, upSideDown, angle
  //
  Game_CharacterBase.prototype.initEffects = function() {
    this._offsetX = 0;
    this._offsetY = 0;
    this._upSideDown = false;
    this._angle = 0;
    this.resetOffset2();
  };

  Game_CharacterBase.prototype.setEffects = function(x, y, u, a) {
    this._offsetX = x;
    this._offsetY = y;
    this._upSideDown = u;
    this._angle = a;
  };

  Game_CharacterBase.prototype.setOffsets = function(x, y) {
    this._offsetX = x;
    this._offsetY = y;
  };

  Game_CharacterBase.prototype.setOffset2 = function(dx, dy, slx, sly, srx, sry) {
    slx = slx || 0;
    sly = sly || 0;
    srx = srx || slx;
    sry = sry || sly;
    this._offsets2 = new Point(dx, dy);
    this._frameOffsets = new Rectangle(slx, sly, srx-slx, sry-sly);
  };

  Game_CharacterBase.prototype.resetOffset2 = function() {
    this._offsets2 = null;
    this._frameOffsets = null;
  };

  Game_CharacterBase.prototype.setUpSideDown = function() {
    this._upSideDown = true;
  };

  Game_CharacterBase.prototype.resetUpSideDown = function() {
    this._upSideDown = false;
  };

  Game_CharacterBase.prototype.setAngle = function(d) {
    this._angle = d;
  };

  Sprite_Character.prototype.updateAngle = function() {
    if (this._character._upSideDown) {
      this.anchor.y = 0;
      this.rotation = Math.PI + this._character._angle * Math.PI / 180;
    } else {
      this.anchor.y = 1;
      this.rotation = this._character._angle * Math.PI / 180;
    }
  };

  var _Sprite_Character_updatePosition =
    Sprite_Character.prototype.updatePosition;
  Sprite_Character.prototype.updatePosition = function() {
    _Sprite_Character_updatePosition.call(this);
    // null or undefined : compatibility for older version
    if (this._character._offsetX == null) {
      this._character.initEffects();
    }
    this.x += this._character._offsetX;
    this.y += this._character._offsetY;

    if (this._character._offsets2) {
      var frameOffsets = this._character._frameOffsets;
      frameOffsets.width = frameOffsets.width || this.patternWidth();
      frameOffsets.height = frameOffsets.height || this.patternHeight();
      var offsets2 = this._character._offsets2;
      var sry = frameOffsets.y + frameOffsets.height;
      this.x += offsets2.x / 2 + frameOffsets.x;
      this.x -= (this.patternWidth() - frameOffsets.width) / 2;
      this.y -= Math.max(this.patternHeight() - sry, -offsets2.y, 0);
    }
  };

  var _Sprite_Character_setFrame = Sprite_Character.prototype.setFrame;
  Sprite_Character.prototype.setFrame = function(sx, sy, pw, ph) {
    if (this._character._offsets2) {
      var frameOffsets = this._character._frameOffsets;
      frameOffsets.width = frameOffsets.width || this.patternWidth();
      frameOffsets.height = frameOffsets.height || this.patternHeight();
      var offsets2 = this._character._offsets2;
      sx += frameOffsets.x + Math.max(-offsets2.x, 0);
      sy += frameOffsets.y + Math.max(-offsets2.y, 0);
      var srx = frameOffsets.x + frameOffsets.width;
      var sry = frameOffsets.y + frameOffsets.height;
      pw -= Math.min(Math.max(pw - srx, 0) + frameOffsets.x + Math.abs(offsets2.x), pw);
      ph -= Math.min(Math.max(ph - sry - Math.max(-offsets2.y, 0), 0) + frameOffsets.y + Math.abs(offsets2.y), ph);
      console.log(pw,ph);
    }
    _Sprite_Character_setFrame.call(this, sx, sy, pw, ph);
  };

  // ----------------------------------------
  // perform cross fade
  //
  Game_CharacterBase.prototype.initImageGrid = function() {
    this._hasChildSprite = false;
    this._newIgName = null;
    this._newIgIndex = 0;
    this._newIgDirection = 0;
    this._newIgPattern = 0;
    this._oldIgOpacity = 255;
    this._IgFrames = 0;
    this._IgDuration = 0;
  };

  Game_CharacterBase.prototype.setImageGrid2 = function(name, index, dir, pattern, duration, needsWait) {
    if (duration > 0) {
      this._newIgName = name;
      this._newIgIndex = index;
      this.setGrid2(dir, pattern, duration, needsWait);
    } else {
      // perform normal setImageGrid.
      this.setImage(name, index);
      this.setGrid2(dir, pattern, duration, needsWait);
    }
  };

  Game_CharacterBase.prototype.setImage2 = function (name, index, duration,  needsWait) {
    if (duration > 0) {
      this._newIgName = name;
      this._newIgIndex = index;
      this._newIgDirection = this._direction;
      this._newIgPattern = this._pattern;
      this._oldIgOpacity = this.opacity();
      this._IgFrames = duration;
      this._IgDuration = duration + 1;
      if (needsWait) {
        this.currentInterpreter().wait(duration);
        this._waitCount = duration;
      };
    } else {
      // perform normal setImage.
      this.setImage(name, index);
    }
  };

  Game_CharacterBase.prototype.setGrid2 = function(dir, pattern, duration, needsWait) {
    if (duration > 0) {
      this._newIgDirection = dir;
      this._newIgPattern = pattern;
      this._oldIgOpacity = this.opacity();
      this._IgFrames = duration;
      this._IgDuration = duration + 1;
      if (needsWait) {
        this.currentInterpreter().wait(duration);
        this._waitCount = duration;
      };
    } else {
      // perform normal setGrid.
      this._originalDirection = dir;
      this.setDirection(dir);
      this._originalPattern = pattern;
      this.setPattern(pattern);
    }
  };

  Game_CharacterBase.prototype.setupNewImageGrid = function () {
    if (this._newIgName) {
      this.setImage(this._newIgName, this._newIgIndex);
      this._newIgName = null;
    }
    this._originalDirection = this._newIgDirection;
    this.setDirection(this._newIgDirection);
    this._originalPattern = this._newIgPattern;
    this.setPattern(this._newIgPattern);
  };

  Game_CharacterBase.prototype.makeCrossFadeSpriteRequested = function () {
    return this._IgDuration > 0 && this._IgFrames === this._IgDuration &&
     !this._hasChildSprite;
  };

  Game_CharacterBase.prototype.igOpacity = function () {
    return this._oldIgOpacity * this._IgDuration / this._IgFrames;
  };

  Game_CharacterBase.prototype.updateImageGrid = function () {
    if (this._IgDuration > 0) {
      if (!ImageManager.isReady()) {
        return;
      }
      this._IgDuration--;
      var igCount = this._IgFrames - this._IgDuration;
      if (igCount === 0) {
        return; // wait until sprite set the sprite.
      }
      if (igCount === 1) {
        this.setupNewImageGrid();
      }
      if (igCount >= 1) {
        this._opacity = 255.0 * (igCount + 1) / this._IgFrames;
      }
    }
  };

  Sprite_Character.prototype.updateCrossFade = function() {
    var spriteset = SceneManager._scene._spriteset;
    if (spriteset) {
      if (this._character && this._character.makeCrossFadeSpriteRequested()) {
        var parent = spriteset._tilemap;
        this._character._hasChildSprite = true;
        parent.addChild(new Sprite_CrossFade(this._character));
      }
    }
  };

  function Sprite_CrossFade() {
    this.initialize.apply(this, arguments);
  }
  Sprite_CrossFade.prototype = Object.create(Sprite_Character.prototype);
  Sprite_CrossFade.prototype.constructor = Sprite_CrossFade;

  Sprite_CrossFade.prototype.initialize = function(character) {
    Sprite_Character.prototype.initialize.call(this, character);
    Sprite_Character.prototype.update.call(this);
  };

   Sprite_CrossFade.prototype.update = function() {
    this.opacity = this._character.igOpacity();
    this.updatePosition();
    if (this._character._IgDuration === 1) {
      this.parent.removeChild(this);
      this._character._hasChildSprite = false;
      this._character._IgDuration = 0;
    }
  };

})();


code:
//=============================================================================
// ExcludeStatus.js
// ----------------------------------------------------------------------------
// <利用規約>
//  利用はRPGツクールMV/RPGMakerMVの正規ユーザーに限られます。
//  商用、非商用、ゲームの内容を問わず利用可能です。
//  ゲームへの利用の際、報告や出典元の記載等は必須ではありません。
//  二次配布や転載は禁止します。
//  ソースコードURL、ダウンロードURLへの直接リンクも禁止します。
//  不具合対応以外のサポートやリクエストは受け付けておりません。
//  スクリプト利用により生じたいかなる問題においても、一切責任を負いかねます。
// ----------------------------------------------------------------------------
//  Ver1.01  2016/01/30  装備画面に対応しました。
//  Ver1.00  2016/01/29  初版
//=============================================================================

/*:
 * @plugindesc 指定したステータス項目を、ステータス画面と装備画面に表示しないようにします。
 * @author こま
 *
 * @param Exclude Status
 * @desc ステータス画面と装備画面で表示しない項目を指定します。
 *（詳細はヘルプを参照）
 * @default 0
 *
 * @help Exclude Statusパラメータに、非表示にしたい項目を指定してください。
 * 項目はカンマ区切りで複数指定できます。
 *
 * 1：攻撃力
 * 2：防御力
 * 3：魔法力
 * 4：魔法防御
 * 5：敏捷性
 * 6：運
 *
 * 3,4と指定すると、魔法力と魔法防御を表示しなくなります。
 */

(function(){
    var parameters = PluginManager.parameters('ExcludeStatus');
    var ExcludeStatus = parameters['Exclude Status'];

    ExcludeStatus = ExcludeStatus.split(',');

    Window_Status.prototype.drawParameters = function(x, y) {
        var lineHeight = this.lineHeight();
        var line = 0;
        for (var i = 0; i < 6; i++) {
            if (!ExcludeStatus.some(function(s) { return i + 1 === Number(s); })) {
                var paramId = i + 2;
                var y2 = y + lineHeight * line;
                this.changeTextColor(this.systemColor());
                this.drawText(TextManager.param(paramId), x, y2, 160);
                this.resetTextColor();
                this.drawText(this._actor.param(paramId), x + 160, y2, 60, 'right');
                line++;
            }
        }
    };

    Window_EquipStatus.prototype.refresh = function() {
        this.contents.clear();
        if (this._actor) {
//            this.drawActorName(this._actor, this.textPadding(), 0);
            var line = -1;
            for (var i = 0; i < 6; i++) {
                if (!ExcludeStatus.some(function(s) { return i + 1 === Number(s); })) {
                    this.drawItem(0, this.lineHeight() * (1 + line), 2 + i);
                    line++;
//            this.drawActorHp(this._actor, 6, 70);
//            this.drawActorMp(this._actor, 6, 110);
                }
            }
        }
    };
}());


code:
//=============================================================================
// メッセージウィンドウの行数を変更するプラグイン
// FTKR_MessageWindowLines.js
// プラグインNo : 62
// 作成者     : フトコロ
// 作成日     : 2018/01/05
// 最終更新日 : 2018/04/28
// バージョン : v1.1.2
//=============================================================================

var Imported = Imported || {};
Imported.FTKR_MWL = true;

var FTKR = FTKR || {};
FTKR.MWL = FTKR.MWL || {};

//=============================================================================
/*:
 * @plugindesc v1.1.2 メッセージウィンドウの行数を変更するプラグイン
 * @author フトコロ
 *
 * @help
 *-----------------------------------------------------------------------------
 * 概要
 *-----------------------------------------------------------------------------
 * 以下のプラグインコマンドを実行することで、メッセージウィンドウの
 * 表示行数を n行 に変更します。
 *
 *   MWL_行数変更 n
 *   MWL_CHANGE_LINES n
 *
 * この時、イベントコマンド「文章の表示」を２つ以上連続で実行していた場合
 * 連続した「文章の表示」コマンドの内容を連結し、変更した行数に合わせて
 * ウィンドウに表示、改ページを行います。
 *
 * なお、複数の「文章の表示」コマンドを連結した場合は、
 * ウィンドウの設定(顔画像や表示位置など)は、最初の「文章の表示」コマンドの
 * 内容のみ反映されます。
 *
 * また、「文章のスクロール表示」コマンドとも連結が可能です。
 * 行数変更中は、「文章のスクロール表示」コマンドを実行すると
 * メッセージウィンドウに表示するようになります。
 *
 * 変更した行数は、以下のプラグインコマンドを実行することで、元の行数に戻ります。
 *
 *    MWL_行数リセット
 *    MWL_RESET_LINES
 *
 *
 * 例）以下の様にイベントを組んだ場合
 *
 * ◆プラグインコマンド：MWL_行数変更 7
 * ◆文章：なし, ウィンドウ, 下
 * ：　　：１行目
 * ：　　：２行目
 * ：　　：３行目
 * ：　　：４行目
 * ◆文章：なし, ウィンドウ, 下
 * ：　　：５行目
 * ：　　：６行目
 * ：　　：７行目
 * ：　　：次ページの１行目
 * ◆プラグインコマンド：MWL_行数リセット
 *
 * このイベントを実行した場合、７行サイズのメッセージウィンドウに
 * １つめの文章の内容すべてと２つめの文章の３行目までの内容をを表示し
 * 改ページ後に、２つめの文章の４行目を表示します。
 *
 *
 *-----------------------------------------------------------------------------
 * 設定方法
 *-----------------------------------------------------------------------------
 * 1.「プラグインマネージャー(プラグイン管理)」に、本プラグインを追加して
 *    ください。
 *
 *
 *-----------------------------------------------------------------------------
 * 競合対策
 *-----------------------------------------------------------------------------
 * 1. MessageWindowPopup.jsと組み合わせる場合は、以下の通りに使用してください。
 *
 *    1. プラグインマネージャー(プラグイン管理)では、本プラグインを
 *       下にしてください。
 *
 *    2. フキダシ有効の状態で表示行数を変更する場合は、
 *       かならず文章の表示コマンドの連結部と表示行数を合わせてください。
 *
 *       例) 表示行数を 6 行に変更する場合は、以下の様にイベントを組みます。
 *        ◆プラグインコマンド：MWL_行数変更 6
 *        ◆文章：なし, ウィンドウ, 下
 *        ：　　：１行目
 *        ：　　：２行目
 *        ：　　：３行目
 *        ◆文章：なし, ウィンドウ, 下
 *        ：　　：４行目
 *        ：　　：５行目
 *        ：　　：６行目
 *        ◆文章：なし, ウィンドウ, 下
 *        ：　　：２ページ目の１行目
 *        ：　　：２行目
 *        ：　　：３行目
 *        ◆プラグインコマンド：MWL_行数リセット
 *        上のように新しいページの１行目は、かならず文章の表示コマンドの
 *        最初にします。
 *
 *
 *       間違った例）下の場合は、２ページ目を表示できません。
 *        ◆プラグインコマンド：MWL_行数変更 6
 *        ◆文章：なし, ウィンドウ, 下
 *        ：　　：１行目
 *        ：　　：２行目
 *        ：　　：３行目
 *        ：　　：４行目
 *        ◆文章：なし, ウィンドウ, 下
 *        ：　　：５行目
 *        ：　　：６行目
 *        ：　　：２ページ目の１行目
 *        ：　　：２行目
 *        ◆文章：なし, ウィンドウ, 下
 *        ：　　：３行目
 *        ◆プラグインコマンド：MWL_行数リセット
 *
 *-----------------------------------------------------------------------------
 * 本プラグインのライセンスについて(License)
 *-----------------------------------------------------------------------------
 * 本プラグインはMITライセンスのもとで公開しています。
 * This plugin is released under the MIT License.
 *
 * Copyright (c) 2017 Futokoro
 * http://opensource.org/licenses/mit-license.php
 *
 *
 * プラグイン公開元
 * https://github.com/futokoro/RPGMaker/blob/master/README.md
 *
 *
 *-----------------------------------------------------------------------------
 * 変更来歴
 *-----------------------------------------------------------------------------
 *
 * v1.1.2 - 2018/04/28 : 不具合修正
 *    1. 行数変更後のメッセージウィンドウ表示位置が、ウィンドウサイズに合わせて
 *       調整されない不具合を修正。
 *
 * v1.1.1 - 2018/02/03 : 処理見直し
 *    1. 競合対策として、ウィンドウサイズを変更する処理と、連結した
 *       文章の表示イベントの処理を見直し。
 *
 * v1.1.0 - 2018/01/06 : 機能追加
 *    1. 行数変更時に、「文章のスクロール表示」を実行すると
 *       メッセージウィンドウに表示するように変更。
 *
 * v1.0.0 - 2018/01/05 : 初版作成
 *
 *-----------------------------------------------------------------------------
*/
//=============================================================================

(function() {

    var convertEscapeCharacters = function(text) {
        if (text == null) text = '';
        var window = SceneManager._scene._windowLayer.children[0];
        return window ? window.convertEscapeCharacters(text) : text;
    };

    var setArgNumber = function(arg) {
        try {
            var arg = convertEscapeCharacters(arg);
            return Number(eval(arg));
        } catch (e) {
            console.error(e);
            return 0;
        }
    };

    var isExistPlugin = function(pluginName) {
        return Object.keys(PluginManager.parameters(pluginName)).length > 0;
    };

    var MessageWindowPopup = isExistPlugin('MessageWindowPopup');

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

    var _MWL_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
        _MWL_Game_Interpreter_pluginCommand.call(this, command, args);
        if (!command.match(/MWL_(.+)/i)) return;
        command = (RegExp.$1 + '').toUpperCase();
        switch (command) {
            case '行数変更':
            case 'CHANGE_LINES':
                $gameParty.setMwlMessageLines(setArgNumber(args[0]));
                break;
            case '行数リセット':
            case 'RESET_LINES':
                $gameParty.resetMwlMessageLines();
                break;
        }
    };

    Game_Interpreter.prototype.continueAddMwlMessages = function() {
        var count = 0;
        while ([105, 405, 101, 401].contains(this.nextEventCode())) {  // Text data
            if (MessageWindowPopup && count >= $gameParty.mwlMessageLines()) {
                break;
            }
            if ([101, 105].contains(this.nextEventCode())) {
                this._index++;
                continue;
            }
            this._index++;
            count++;
            $gameMessage.add(this.currentCommand().parameters[0]);
        }
    };

    var _MWL_Game_Interpreter_command101 = Game_Interpreter.prototype.command101;
    Game_Interpreter.prototype.command101 = function() {
        if (!$gameMessage.isBusy() && $gameParty.mwlMessageLines()) {
            $gameMessage.setFaceImage(this._params[0], this._params[1]);
            $gameMessage.setBackground(this._params[2]);
            $gameMessage.setPositionType(this._params[3]);
            this.continueAddMwlMessages();
            switch (this.nextEventCode()) {
            case 102:  // Show Choices
                this._index++;
                this.setupChoices(this.currentCommand().parameters);
                break;
            case 103:  // Input Number
                this._index++;
                this.setupNumInput(this.currentCommand().parameters);
                break;
            case 104:  // Select Item
                this._index++;
                this.setupItemChoice(this.currentCommand().parameters);
                break;
            }
            this._index++;
            this.setWaitMode('message');
            return false;
        } else {
            return _MWL_Game_Interpreter_command101.call(this);
        }
    };

    var _MWL_Game_Interpreter_command105 = Game_Interpreter.prototype.command105;
    Game_Interpreter.prototype.command105 = function() {
        if (!$gameMessage.isBusy() && $gameParty.mwlMessageLines()) {
            this.continueAddMwlMessages();
            switch (this.nextEventCode()) {
            case 102:  // Show Choices
                this._index++;
                this.setupChoices(this.currentCommand().parameters);
                break;
            case 103:  // Input Number
                this._index++;
                this.setupNumInput(this.currentCommand().parameters);
                break;
            case 104:  // Select Item
                this._index++;
                this.setupItemChoice(this.currentCommand().parameters);
                break;
            }
            this._index++;
            this.setWaitMode('message');
            return false;
        } else {
            return _MWL_Game_Interpreter_command105.call(this);
        }
    };

    //=============================================================================
    // Game_Party
    // メッセージスプライトを設定する
    //=============================================================================

    Game_Party.prototype.setMwlMessageLines = function(lines) {
        this._mwlMessageLines = lines;
        this._requestResetWindowSize = true;
    };

    Game_Party.prototype.resetMwlMessageLines = function() {
        this._mwlMessageLines = 0;
        this._requestResetWindowSize = true;
    };

    Game_Party.prototype.mwlMessageLines = function() {
        return this._mwlMessageLines;
    };

    Game_Party.prototype.isRequestResetWindowSize = function() {
        return this._requestResetWindowSize;
    }

    Game_Party.prototype.clearRequestResetWindowSize = function() {
        this._requestResetWindowSize = false;
    };

    //=============================================================================
    // Window_Message
    //=============================================================================

    var _MWL_Window_Message_numVisibleRows = Window_Message.prototype.numVisibleRows;
    Window_Message.prototype.numVisibleRows = function() {
        return $gameParty.mwlMessageLines() || _MWL_Window_Message_numVisibleRows.call(this);
    };

    Window_Message.prototype.setMWLWindowSize = function() {
        if ($gameParty.isRequestResetWindowSize()) {
            this.y = this._positionType * (Graphics.boxHeight - this.windowHeight()) / 2;
            this.move(this.x, this.y, this.windowWidth(), this.windowHeight());
            this.contents = new Bitmap(this.contentsWidth(), this.contentsHeight());
            $gameParty.clearRequestResetWindowSize();
        }
    };

    var _MWL_Window_Message_updatePlacement = Window_Message.prototype.updatePlacement;
    Window_Message.prototype.updatePlacement = function() {
        _MWL_Window_Message_updatePlacement.call(this);
        this.setMWLWindowSize();
    };

}());//EOF