code:
//=============================================================================
// Yanfly Engine Plugins - In-Battle Status
// YEP_X_InBattleStatus.js
//=============================================================================

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

var Yanfly = Yanfly || {};
Yanfly.IBS = Yanfly.IBS || {};
Yanfly.IBS.version = 1.01;

//=============================================================================
 /*:
 * @plugindesc v1.01 (Requires YEP_BattleEngineCore.js) Adds a 'Status'
 * option in the Party Window in battle.
 * @author Yanfly Engine Plugins
 *
 * @param ---General---
 * @default
 *
 * @param Command Text
 * @parent ---General---
 * @desc The text used for 'Status' command text in the Party Window.
 * @default Status
 *
 * @param Show Command
 * @parent ---General---
 * @type boolean
 * @on Show
 * @off Hide
 * @desc Show the in battle 'Status' command by default?
 * NO - false     YES - true
 * @default true
 *
 * @param Window X
 * @parent ---General---
 * @desc The default X location used for the in-battle status window.
 * You can use formulas.
 * @default 0
 *
 * @param Window Y
 * @parent ---General---
 * @desc The default Y location used for the in-battle status window.
 * You can use formulas.
 * @default this.fittingHeight(2)
 *
 * @param Window Width
 * @parent ---General---
 * @desc The default width used for the in-battle status window.
 * You can use formulas.
 * @default Graphics.boxWidth
 *
 * @param Window Height
 * @parent ---General---
 * @desc The default height used for the in-battle status window.
 * You can use formulas.
 * @default Graphics.boxHeight - this.fittingHeight(2) - this.fittingHeight(4)
 *
 * @param ---Status List---
 * @default
 *
 * @param Status Width
 * @parent ---Status List---
 * @desc The width of the status list.
 * You can use formulas.
 * @default Math.max(312, Graphics.boxWidth / 4);
 *
 * @param State Help Front
 * @parent ---Status List---
 * @desc Text placed in front of each state's help description.
 * %1 - State Icon     %2 - State Name
 * @default \i[%1]%2
 *
 * @param State Help End
 * @parent ---Status List---
 * @desc Text placed in end of each state's help description.
 * %1 - State Icon     %2 - State Name
 * @default
 *
 * @param Healthy Icon
 * @parent ---Status List---
 * @type number
 * @desc Icon ID used to indicate the battler is healthy (no states).
 * @default 127
 *
 * @param Healthy Text
 * @parent ---Status List---
 * @desc Text used to label the healthy status.
 * @default Healthy
 *
 * @param Healthy Help
 * @parent ---Status List---
 * @desc Text displayed in help window when selected.
 * @default User is currently unaffected by status effects.
 *
 * @param ---Buffs List---
 * @default
 *
 * @param MaxHP Buff Text
 * @parent ---Buffs List---
 * @desc The text used to display the MaxHP Buff Name.
 * @default MaxHP Up
 *
 * @param MaxHP Buff Help
 * @parent ---Buffs List---
 * @desc The text used for the MaxHP help description.
 * %1 - Rate     %2 - Stacks     %3 - Turns
 * @default Raises Maximum Health to %1%.
 *
 * @param MaxMP Buff Text
 * @parent ---Buffs List---
 * @desc The text used to display the MaxMP Buff Name.
 * @default MaxMP Up
 *
 * @param MaxMP Buff Help
 * @parent ---Buffs List---
 * @desc The text used for the MaxMP help description.
 * %1 - Rate     %2 - Stacks     %3 - Turns
 * @default Raises Maximum Mana to %1%.
 *
 * @param ATK Buff Text
 * @parent ---Buffs List---
 * @desc The text used to display the ATK Buff Name.
 * @default ATK Up
 *
 * @param ATK Buff Help
 * @parent ---Buffs List---
 * @desc The text used for the ATK help description.
 * %1 - Rate     %2 - Stacks     %3 - Turns
 * @default Raises Attack to %1%.
 *
 * @param DEF Buff Text
 * @parent ---Buffs List---
 * @desc The text used to display the DEF Buff Name.
 * @default DEF Up
 *
 * @param DEF Buff Help
 * @parent ---Buffs List---
 * @desc The text used for the DEF help description.
 * %1 - Rate     %2 - Stacks     %3 - Turns
 * @default Raises Defense to %1%.
 *
 * @param MAT Buff Text
 * @parent ---Buffs List---
 * @desc The text used to display the MAT Buff Name.
 * @default MAT Up
 *
 * @param MAT Buff Help
 * @parent ---Buffs List---
 * @desc The text used for the MAT help description.
 * %1 - Rate     %2 - Stacks     %3 - Turns
 * @default Raises Magic Attack to %1%.
 *
 * @param MDF Buff Text
 * @parent ---Buffs List---
 * @desc The text used to display the MDF Buff Name.
 * @default MDF Up
 *
 * @param MDF Buff Help
 * @parent ---Buffs List---
 * @desc The text used for the MDF help description.
 * %1 - Rate     %2 - Stacks     %3 - Turns
 * @default Raises Magic Defense to %1%.
 *
 * @param AGI Buff Text
 * @parent ---Buffs List---
 * @desc The text used to display the AGI Buff Name.
 * @default AGI Up
 *
 * @param AGI Buff Help
 * @parent ---Buffs List---
 * @desc The text used for the AGI help description.
 * %1 - Rate     %2 - Stacks     %3 - Turns
 * @default Raises Agility to %1%.
 *
 * @param LUK Buff Text
 * @parent ---Buffs List---
 * @desc The text used to display the LUK Buff Name.
 * @default LUK Up
 *
 * @param LUK Buff Help
 * @parent ---Buffs List---
 * @desc The text used for the LUK help description.
 * %1 - Rate     %2 - Stacks     %3 - Turns
 * @default Raises Luck to %1%.
 *
 * @param ---Debuffs List---
 * @default
 *
 * @param MaxHP Debuff Text
 * @parent ---Debuffs List---
 * @desc The text used to display the MaxHP Debuff Name.
 * @default MaxHP Down
 *
 * @param MaxHP Debuff Help
 * @parent ---Debuffs List---
 * @desc The text used for the MaxHP help description.
 * %1 - Rate     %2 - Stacks     %3 - Turns
 * @default Lowers Maximum Health to %1%.
 *
 * @param MaxMP Debuff Text
 * @parent ---Debuffs List---
 * @desc The text used to display the MaxMP Debuff Name.
 * @default MaxMP Down
 *
 * @param MaxMP Debuff Help
 * @parent ---Debuffs List---
 * @desc The text used for the MaxMP help description.
 * %1 - Rate     %2 - Stacks     %3 - Turns
 * @default Lowers Maximum Mana to %1%.
 *
 * @param ATK Debuff Text
 * @parent ---Debuffs List---
 * @desc The text used to display the ATK Debuff Name.
 * @default ATK Down
 *
 * @param ATK Debuff Help
 * @parent ---Debuffs List---
 * @desc The text used for the ATK help description.
 * %1 - Rate     %2 - Stacks     %3 - Turns
 * @default Lowers Attack to %1%.
 *
 * @param DEF Debuff Text
 * @parent ---Debuffs List---
 * @desc The text used to display the DEF Debuff Name.
 * @default DEF Down
 *
 * @param DEF Debuff Help
 * @parent ---Debuffs List---
 * @desc The text used for the DEF help description.
 * %1 - Rate     %2 - Stacks     %3 - Turns
 * @default Lowers Defense to %1%.
 *
 * @param MAT Debuff Text
 * @parent ---Debuffs List---
 * @desc The text used to display the MAT Debuff Name.
 * @default MAT Down
 *
 * @param MAT Debuff Help
 * @parent ---Debuffs List---
 * @desc The text used for the MAT help description.
 * %1 - Rate     %2 - Stacks     %3 - Turns
 * @default Lowers Magic Attack to %1%.
 *
 * @param MDF Debuff Text
 * @parent ---Debuffs List---
 * @desc The text used to display the MDF Debuff Name.
 * @default MDF Down
 *
 * @param MDF Debuff Help
 * @parent ---Debuffs List---
 * @desc The text used for the MDF help description.
 * %1 - Rate     %2 - Stacks     %3 - Turns
 * @default Lowers Magic Defense to %1%.
 *
 * @param AGI Debuff Text
 * @parent ---Debuffs List---
 * @desc The text used to display the AGI Debuff Name.
 * @default AGI Down
 *
 * @param AGI Debuff Help
 * @parent ---Debuffs List---
 * @desc The text used for the AGI help description.
 * %1 - Rate     %2 - Stacks     %3 - Turns
 * @default Lowers Agility to %1%.
 *
 * @param LUK Debuff Text
 * @parent ---Debuffs List---
 * @desc The text used to display the LUK Debuff Name.
 * @default LUK Down
 *
 * @param LUK Debuff Help
 * @parent ---Debuffs List---
 * @desc The text used for the LUK help description.
 * %1 - Rate     %2 - Stacks     %3 - Turns
 * @default Lowers Luck to %1%.
 *
 * @help
 * ============================================================================
 * Introduction
 * ============================================================================
 *
 * This plugin requires YEP_BattleEngineCore. Make sure this plugin is located
 * under YEP_BattleEngineCore in the plugin list.
 *
 * In battle by default, there's no way to check your party's status. This
 * plugin will add a new 'Status' command to the Party Command Window (with
 * Fight and Escape) to allow players to check party members. Here, the player
 * can view each party member's current parameters, get a list of all states,
 * buffs, and debuffs. The player can scroll through the list and view newly
 * added help descriptions of the states, buffs, and debuffs in a help window.
 *
 * *Note: If you are using YEP_X_BattleSysCTB.js, place this plugin under that
 * plugin for the best compatibility results.
 *
 * ============================================================================
 * Notetags
 * ============================================================================
 *
 * For those who would like to add help descriptions to states, use these
 * following notetags:
 *
 * State Notetags:
 *
 *   <Help Description>
 *    text
 *    text
 *   </Help Description>
 *   - This will set the help description of the state to the text used in the
 *   notetag. You can use text codes.
 *
 * ============================================================================
 * Text Codes
 * ============================================================================
 *
 * By using certain text codes in your messages, you can have the game replace
 * them with the following:
 *
 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 *
 * State Help     Function
 *   \th[x]       - Replaced by the text used in state x's help description.
 *
 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 *
 * ============================================================================
 * Plugin Commands
 * ============================================================================
 *
 * For those who would like to change whether the 'Status' option is shown or
 * hidden midway through the game, you can use the following plugin commands:
 *
 * Plugin Commands:
 *
 *   ShowInBattleStatus
 *   - This will cause the 'Status' command to show.
 *
 *   HideInBattleStatus
 *   - This will cause the 'Status' command to not show.
 *
 * ============================================================================
 * Changelog
 * ============================================================================
 *
 * Version 1.01:
 * - Updated for RPG Maker MV version 1.5.0.
 *
 * Version 1.00:
 * - Finished Plugin!
 */
//=============================================================================

if (Imported.YEP_BattleEngineCore) {

//=============================================================================
// Parameter Variables
//=============================================================================

Yanfly.Parameters = PluginManager.parameters('YEP_X_InBattleStatus');
Yanfly.Param = Yanfly.Param || {};

Yanfly.Param.IBSCmdName = String(Yanfly.Parameters['Command Text']);
Yanfly.Param.IBSCmdShow = eval(String(Yanfly.Parameters['Show Command']));
Yanfly.Param.IBSWinX = String(Yanfly.Parameters['Window X']);
Yanfly.Param.IBSWinY = String(Yanfly.Parameters['Window Y']);
Yanfly.Param.IBSWinWidth = String(Yanfly.Parameters['Window Width']);
Yanfly.Param.IBSWinHeight = String(Yanfly.Parameters['Window Height']);

Yanfly.Param.IBSStatusListWidth = String(Yanfly.Parameters['Status Width']);
Yanfly.Param.IBSStateHelp1 = String(Yanfly.Parameters['State Help Front']);
Yanfly.Param.IBSStateHelp2 = String(Yanfly.Parameters['State Help End']);
Yanfly.Param.IBSHealthyIcon = Number(Yanfly.Parameters['Healthy Icon']);
Yanfly.Param.IBSHealthyText = String(Yanfly.Parameters['Healthy Text']);
Yanfly.Param.IBSHealthyHelp = String(Yanfly.Parameters['Healthy Help']);

Yanfly.Param.IBSBuffText = [];
Yanfly.Param.IBSBuffText.push(String(Yanfly.Parameters['MaxHP Buff Text']));
Yanfly.Param.IBSBuffText.push(String(Yanfly.Parameters['MaxMP Buff Text']));
Yanfly.Param.IBSBuffText.push(String(Yanfly.Parameters['ATK Buff Text']));
Yanfly.Param.IBSBuffText.push(String(Yanfly.Parameters['DEF Buff Text']));
Yanfly.Param.IBSBuffText.push(String(Yanfly.Parameters['MAT Buff Text']));
Yanfly.Param.IBSBuffText.push(String(Yanfly.Parameters['MDF Buff Text']));
Yanfly.Param.IBSBuffText.push(String(Yanfly.Parameters['AGI Buff Text']));
Yanfly.Param.IBSBuffText.push(String(Yanfly.Parameters['LUK Buff Text']));
Yanfly.Param.IBSBuffHelp = [];
Yanfly.Param.IBSBuffHelp.push(String(Yanfly.Parameters['MaxHP Buff Help']));
Yanfly.Param.IBSBuffHelp.push(String(Yanfly.Parameters['MaxMP Buff Help']));
Yanfly.Param.IBSBuffHelp.push(String(Yanfly.Parameters['ATK Buff Help']));
Yanfly.Param.IBSBuffHelp.push(String(Yanfly.Parameters['DEF Buff Help']));
Yanfly.Param.IBSBuffHelp.push(String(Yanfly.Parameters['MAT Buff Help']));
Yanfly.Param.IBSBuffHelp.push(String(Yanfly.Parameters['MDF Buff Help']));
Yanfly.Param.IBSBuffHelp.push(String(Yanfly.Parameters['AGI Buff Help']));
Yanfly.Param.IBSBuffHelp.push(String(Yanfly.Parameters['LUK Buff Help']));

Yanfly.Param.IBSDebuffText = [];
Yanfly.Param.IBSDebuffText.push(String(Yanfly.Parameters['MaxHP Debuff Text']));
Yanfly.Param.IBSDebuffText.push(String(Yanfly.Parameters['MaxMP Debuff Text']));
Yanfly.Param.IBSDebuffText.push(String(Yanfly.Parameters['ATK Debuff Text']));
Yanfly.Param.IBSDebuffText.push(String(Yanfly.Parameters['DEF Debuff Text']));
Yanfly.Param.IBSDebuffText.push(String(Yanfly.Parameters['MAT Debuff Text']));
Yanfly.Param.IBSDebuffText.push(String(Yanfly.Parameters['MDF Debuff Text']));
Yanfly.Param.IBSDebuffText.push(String(Yanfly.Parameters['AGI Debuff Text']));
Yanfly.Param.IBSDebuffText.push(String(Yanfly.Parameters['LUK Debuff Text']));
Yanfly.Param.IBSDebuffHelp = [];
Yanfly.Param.IBSDebuffHelp.push(String(Yanfly.Parameters['MaxHP Debuff Help']));
Yanfly.Param.IBSDebuffHelp.push(String(Yanfly.Parameters['MaxMP Debuff Help']));
Yanfly.Param.IBSDebuffHelp.push(String(Yanfly.Parameters['ATK Debuff Help']));
Yanfly.Param.IBSDebuffHelp.push(String(Yanfly.Parameters['DEF Debuff Help']));
Yanfly.Param.IBSDebuffHelp.push(String(Yanfly.Parameters['MAT Debuff Help']));
Yanfly.Param.IBSDebuffHelp.push(String(Yanfly.Parameters['MDF Debuff Help']));
Yanfly.Param.IBSDebuffHelp.push(String(Yanfly.Parameters['AGI Debuff Help']));
Yanfly.Param.IBSDebuffHelp.push(String(Yanfly.Parameters['LUK Debuff Help']));

//=============================================================================
// DataManager
//=============================================================================

Yanfly.IBS.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
  if (!Yanfly.IBS.DataManager_isDatabaseLoaded.call(this)) return false;

  if (!Yanfly._loaded_YEP_X_InBattleStatus) {
    this.processIBSNotetags1($dataStates);
    Yanfly._loaded_YEP_X_InBattleStatus = true;
  }

  return true;
};

DataManager.processIBSNotetags1 = function(group) {
  for (var n = 1; n < group.length; n++) {
    var obj = group[n];
    var notedata = obj.note.split(/[\r\n]+/);

    var fmt1 = Yanfly.Param.IBSStateHelp1;
    obj.description = fmt1.format(obj.iconIndex, obj.name);
    var descLength = obj.description.length;
    var evalMode = 'none';

    for (var i = 0; i < notedata.length; i++) {
      var line = notedata[i];
      if (line.match(/<(?:HELP|DESCRIPTION|HELP DESCRIPTION)>/i)) {
        evalMode = 'help description';
      } else if (line.match(/<\/(?:HELP|DESCRIPTION|HELP DESCRIPTION)>/i)) {
        evalMode = 'none';
      } else if (evalMode === 'help description') {
        if (obj.description.length > descLength) obj.description += '\n';
        obj.description += line;
      }
    }

    var fmt2 = Yanfly.Param.IBSStateHelp2;
    obj.description += fmt2.format(obj.iconIndex, obj.name);
  }
};

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

Yanfly.IBS.Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
  Yanfly.IBS.Game_System_initialize.call(this);
  this.initIBSSettings();
};

Game_System.prototype.initIBSSettings = function() {
  this._showInBattleStatus = Yanfly.Param.IBSCmdShow;
};

Game_System.prototype.isShowInBattleStatus = function() {
  if (this._showInBattleStatus === undefined) this.initIBSSettings();
  return this._showInBattleStatus;
};

Game_System.prototype.setShowInBattleStatus = function(value) {
  if (this._showInBattleStatus === undefined) this.initIBSSettings();
  this._showInBattleStatus = value;
};

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

Yanfly.IBS.Game_Interpreter_pluginCommand =
    Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
  Yanfly.IBS.Game_Interpreter_pluginCommand.call(this, command, args);
  if (command === 'ShowInBattleStatus') {
    $gameSystem.setShowInBattleStatus(true);
  } else if (command === 'HideInBattleStatus') {
    $gameSystem.setShowInBattleStatus(false);
  }
};

//=============================================================================
// Window_Base
//=============================================================================

Yanfly.IBS.Window_Base_convertEscapeCharacters =
  Window_Base.prototype.convertEscapeCharacters;
Window_Base.prototype.convertEscapeCharacters = function(text) {
  text = this.convertStateHelpText(text);
  return Yanfly.IBS.Window_Base_convertEscapeCharacters.call(this, text);
};

Window_Base.prototype.convertStateHelpText = function(text) {
  text = text.replace(/\\V\[(\d+)\]/gi, function() {
    return $gameVariables.value(parseInt(arguments[1]));
  }.bind(this));
  text = text.replace(/\\V\[(\d+)\]/gi, function() {
    return $gameVariables.value(parseInt(arguments[1]));
  }.bind(this));
  text = text.replace(/\\TH\[(\d+)\]/gi, function() {
    return $dataStates[parseInt(arguments[1])].description;
  }.bind(this));
  text = text.replace(/\x1bV\[(\d+)\]/gi, function() {
    return $gameVariables.value(parseInt(arguments[1]));
  }.bind(this));
  text = text.replace(/\x1bV\[(\d+)\]/gi, function() {
    return $gameVariables.value(parseInt(arguments[1]));
  }.bind(this));
  text = text.replace(/\x1bTH\[(\d+)\]/gi, function() {
    return $dataStates[parseInt(arguments[1])].description;
  }.bind(this));
  return text;
};

if (Imported.YEP_X_MessageMacros1) {

Yanfly.IBS.Window_Base_convertMacroText =
    Window_Base.prototype.convertMacroText;
Window_Base.prototype.convertMacroText = function(text) {
  text = Yanfly.IBS.Window_Base_convertMacroText.call(this, text);
  text = this.convertStateHelpText(text);
  return text;
};

}; // Imported.YEP_X_MessageMacros1

//=============================================================================
// Window_Command
//=============================================================================

Window_Command.prototype.addCommandAt = function(index, name, symbol, en, ext) {
  if (en === undefined) enabled = true;
  if (ext === undefined) ext = null;
  var obj = { name: name, symbol: symbol, enabled: en, ext: ext};
  this._list.splice(index, 0, obj);
};

//=============================================================================
// Window_PartyCommand
//=============================================================================

Yanfly.IBS.Window_PartyCommand_makeCommandList =
  Window_PartyCommand.prototype.makeCommandList;
Window_PartyCommand.prototype.makeCommandList = function() {
  Yanfly.IBS.Window_PartyCommand_makeCommandList.call(this);
  this.makeInBattleStatusCommand();
};

Window_PartyCommand.prototype.makeInBattleStatusCommand = function() {
  if (!$gameSystem.isShowInBattleStatus()) return;
  var index = this.findSymbol('escape');
  var text = Yanfly.Param.IBSCmdName;
  this.addCommandAt(index, text, 'inBattleStatus', true);
};

//=============================================================================
// Window_InBattleStatus
//=============================================================================

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

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

Window_InBattleStatus.prototype.initialize = function() {
  var x = eval(Yanfly.Param.IBSWinX);
  var y = eval(Yanfly.Param.IBSWinY);
  var w = eval(Yanfly.Param.IBSWinWidth);
  var h = eval(Yanfly.Param.IBSWinHeight);
  this._battler = $gameParty.battleMembers()[0];
  Window_Base.prototype.initialize.call(this, x, y, w, h);
  this.hide();
};

Window_InBattleStatus.prototype.setBattler = function(battler) {
  this._battler = battler;
  this.refresh();
};

Window_InBattleStatus.prototype.refresh = function() {
  this.contents.clear();
  if (!this._battler) return;
  var x = this.standardPadding() + eval(Yanfly.Param.IBSStatusListWidth);
  this.drawActorFace(this._battler, x, 0, Window_Base._faceWidth);
  var x2 = x + Window_Base._faceWidth + this.standardPadding();
  var w = this.contents.width - x2;
  this.drawActorSimpleStatus(this._battler, x2, 0, w);
  w = this.contents.width - x;
  var y = Math.ceil(this.lineHeight() * 4.5);
  var h = this.contents.height - y;
  if (h >= this.lineHeight() * 6) {
    for (var i = 2; i < 8; ++i) {
      this.drawParam(i, x, y, w, this.lineHeight());
      y += this.lineHeight();
    }
  } else {
    w = Math.floor(w / 2);
    x2 = x;
    for (var i = 2; i < 8; ++i) {
      this.drawParam(i, x2, y, w, this.lineHeight());
      if (i % 2 === 0) {
        x2 += w;
      } else {
        x2 = x;
        y += this.lineHeight();
      }
    }
  }
};

Window_InBattleStatus.prototype.drawParam = function(paramId, dx, dy, dw, dh) {
  this.drawDarkRect(dx, dy, dw, dh);
  var level = this._battler._buffs[paramId];
  var icon = this._battler.buffIconIndex(level, paramId);
  this.drawIcon(icon, dx + 2, dy + 2);
  dx += Window_Base._iconWidth + 4;
  dw -= Window_Base._iconWidth + 4 + this.textPadding() + 2;
  this.changeTextColor(this.systemColor());
  this.drawText(TextManager.param(paramId), dx, dy, dw);
  var value = this._battler.param(paramId);
  this.changeTextColor(this.paramchangeTextColor(level));
  this.drawText(Yanfly.Util.toGroup(value), dx, dy, dw, 'right');
};

Window_InBattleStatus.prototype.drawDarkRect = function(dx, dy, dw, dh) {
  var color = this.gaugeBackColor();
  this.changePaintOpacity(false);
  this.contents.fillRect(dx + 1, dy + 1, dw - 2, dh - 2, color);
  this.changePaintOpacity(true);
};

//=============================================================================
// Window_InBattleStateList
//=============================================================================

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

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

Window_InBattleStateList.prototype.initialize = function(parentWindow) {
  this._parentWindow = parentWindow;
  this._battler = $gameParty.battleMembers()[0];
  var x = parentWindow.x;
  var y = parentWindow.y;
  var width = eval(Yanfly.Param.IBSStatusListWidth);
  width += this.standardPadding() * 2;
  width = Math.ceil(width);
  var height = parentWindow.height;
  Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  this.deactivate();
  this.backOpacity = 0;
  this.opacity = 0;
  this.hide();
  this._data = [];
};

Window_InBattleStateList.prototype.setStatusWindow = function(win) {
  this._statusWindow = win;
};

Window_InBattleStateList.prototype.setBattler = function(battler) {
  this._battler = battler;
  this._parentWindow.setBattler(battler);
  this.refresh();
  this.select(0);
  if (this._statusWindow) {
    var index = $gameParty.battleMembers().indexOf(battler)
    this._statusWindow.select(index);
  }
};

Window_InBattleStateList.prototype.maxItems = function() {
  return this._data ? this._data.length : 1;
};

Window_InBattleStateList.prototype.item = function() {
  var index = this.index();
  return this._data && index >= 0 ? this._data[index] : null;
};

Window_InBattleStateList.prototype.includes = function(item) {
  if (!item) return false;
  if (item.name.length <= 0) return false;
  if (item.iconIndex <= 0) return false;
  return true;
};

Window_InBattleStateList.prototype.makeItemList = function() {
  this._data = [];
  if (this._battler) {
    var states = this._battler.states();
    var length = states.length;
    for (var i = 0; i < length; ++i) {
      var state = states[i];
      if (this.includes(state)) this._data.push(state);
    }
    for (var i = 0; i < 8; ++i) {
      if (this._battler.isBuffAffected(i) ||
      this._battler.isDebuffAffected(i)) {
        this._data.push('buff ' + i);
      }
    }
  }
  if (this._data.length <= 0) this._data.push(null);
};

Window_InBattleStateList.prototype.drawItem = function(index) {
  var item = this._data[index];
  var rect = this.itemRect(index);
  rect.width -= this.textPadding();
  if (item === null) {
    var icon = Yanfly.Param.IBSHealthyIcon;
    var text = Yanfly.Param.IBSHealthyText;
    var ibw = Window_Base._iconWidth + 4;
    this.resetTextColor();
    this.drawIcon(icon, rect.x + 2, rect.y + 2);
    this.drawText(text, rect.x + ibw, rect.y, rect.width - ibw);
  } else if (typeof item === 'string' && item.match(/BUFF[ ](\d+)/i)) {
    var paramId = parseInt(RegExp.$1);
    var level = this._battler._buffs[paramId];
    var icon = this._battler.buffIconIndex(level, paramId);
    var ibw = Window_Base._iconWidth + 4;
    this.drawIcon(icon, rect.x + 2, rect.y + 2);
    if (level > 0) {
      var text = Yanfly.Param.IBSBuffText[paramId];
    } else {
      var text = Yanfly.Param.IBSDebuffText[paramId];
    }
    this.drawText(text, rect.x + ibw, rect.y, rect.width - ibw);
    if (!Imported.YEP_BuffsStatesCore) return;
    this.drawBuffTurns(this._battler, paramId, rect.x + 2, rect.y);
    if (Yanfly.Param.BSCShowBuffRate) {
      this.drawBuffRate(this._battler, paramId, rect.x + 2, rect.y);
    }
  } else if (item) {
    this.drawItemName(item, rect.x, rect.y, rect.width);
    if (!Imported.YEP_BuffsStatesCore) return;
    if (item.autoRemovalTiming > 0) {
      this.drawStateTurns(this._battler, item, rect.x + 2, rect.y);
    }
    this.drawStateCounter(this._battler, item, rect.x + 2, rect.y);
  }
};

Window_InBattleStateList.prototype.updateHelp = function() {
  if (this.item() === null) {
    var text = Yanfly.Param.IBSHealthyHelp;
    this._helpWindow.setText(text);
  } else if (typeof this.item() === 'string' &&
  this.item().match(/BUFF[ ](\d+)/i)) {
    var paramId = parseInt(RegExp.$1);
    var level = this._battler._buffs[paramId];
    if (level > 0) {
      var fmt = Yanfly.Param.IBSBuffHelp[paramId];
    } else {
      var fmt = Yanfly.Param.IBSDebuffHelp[paramId];
    }
    var rate = Math.floor(this._battler.paramBuffRate(paramId) * 100);
    var turns = this._battler._buffTurns[paramId];
    var text = fmt.format(rate, Math.abs(level), turns);
    this._helpWindow.setText(text);
  } else if (this.item()) {
    this.setHelpWindowItem(this.item());
  }
};

Window_InBattleStateList.prototype.refresh = function() {
  this.makeItemList();
  this.createContents();
  this.drawAllItems();
};

Window_InBattleStateList.prototype.update = function() {
  Window_Selectable.prototype.update.call(this);
  if (this.active && this._battler) this.updateLeftRight();
};

Window_InBattleStateList.prototype.updateLeftRight = function() {
  var index = $gameParty.battleMembers().indexOf(this._battler);
  var current = index;
  if (Input.isRepeated('left')) {
    index -= 1;
  } else if (Input.isRepeated('right')) {
    index += 1;
  }
  index = index.clamp(0, $gameParty.battleMembers().length - 1);
  if (current !== index) {
    var battler = $gameParty.battleMembers()[index];
    this.setBattler(battler);
    SoundManager.playCursor();
  }
};

//=============================================================================
// Window_CTBIcon
//=============================================================================

if (Imported.YEP_X_BattleSysCTB) {

Yanfly.IBS.Window_CTBIcon_isReduceOpacity =
  Window_CTBIcon.prototype.isReduceOpacity;
Window_CTBIcon.prototype.isReduceOpacity = function() {
  if (SceneManager._scene._inBattleStatusWindow) {
    if (SceneManager._scene._inBattleStatusWindow.visible) return true;
  }
  return Yanfly.IBS.Window_CTBIcon_isReduceOpacity.call(this);
};

}; // Imported.YEP_X_BattleSysCTB

//=============================================================================
// Window_BattleStatus
//=============================================================================

Window_BattleStatus.prototype.setInBattleStatusWindow = function(win) {
  this._inBattleStatusWindow = win;
};

Yanfly.IBS.Window_BattleStatus_update = Window_BattleStatus.prototype.update;
Window_BattleStatus.prototype.update = function() {
  Yanfly.IBS.Window_BattleStatus_update.call(this);
  this.processInBattleStatusTouch();
};

Window_BattleStatus.prototype.processInBattleStatusTouch = function() {
  if (!this._inBattleStatusWindow) return;
  if (!this._inBattleStatusWindow.active) return;
  if (TouchInput.isTriggered() && this.isTouchedInsideFrame()) {
    this.onInBattleStatusTouch();
  }
};

Window_BattleStatus.prototype.onInBattleStatusTouch = function() {
  var lastIndex = this.index();
  var x = this.canvasToLocalX(TouchInput.x);
  var y = this.canvasToLocalY(TouchInput.y);
  var hitIndex = this.hitTest(x, y);
  if (hitIndex >= 0) {
    var actor = $gameParty.battleMembers()[hitIndex];
    var win = this._inBattleStatusWindow;
    if (win && actor) {
      win.setBattler(actor);
      SoundManager.playCursor();
    }
  }
};

//=============================================================================
// Scene_Battle
//=============================================================================

Yanfly.IBS.Scene_Battle_createAllWindows =
  Scene_Battle.prototype.createAllWindows;
Scene_Battle.prototype.createAllWindows = function() {
  Yanfly.IBS.Scene_Battle_createAllWindows.call(this);
  this.createInBattleStatusWindows();
};

Scene_Battle.prototype.createInBattleStatusWindows = function() {
  this._inBattleStatusWindow = new Window_InBattleStatus();
  this.addChild(this._inBattleStatusWindow);
  var win = this._inBattleStatusWindow;
  this._inBattleStateList = new Window_InBattleStateList(win);
  this._inBattleStateList.setHelpWindow(this._helpWindow);
  this._inBattleStateList.setStatusWindow(this._statusWindow);
  this.addChild(this._inBattleStateList);
  this._inBattleStateList.setHandler('cancel',
    this.onInBattleStatusCancel.bind(this));
  this._statusWindow.setInBattleStatusWindow(this._inBattleStateList);
};

Yanfly.IBS.Scene_Battle_createPartyCommandWindow =
  Scene_Battle.prototype.createPartyCommandWindow;
Scene_Battle.prototype.createPartyCommandWindow = function() {
  Yanfly.IBS.Scene_Battle_createPartyCommandWindow.call(this);
  var win = this._partyCommandWindow;
  win.setHandler('inBattleStatus', this.commandInBattleStatus.bind(this));
};

Scene_Battle.prototype.commandInBattleStatus = function() {
  this._helpWindow.show();
  this._inBattleStatusWindow.show();
  this._inBattleStateList.show();
  this._inBattleStateList.activate();
  this._inBattleStateList.setBattler($gameParty.battleMembers()[0]);
  if (Imported.YEP_X_PartyLimitGauge) {
    this._showPartyLimitGauge = $gameSystem.isShowPartyLimitGauge();
    this._showTroopLimitGauge = $gameSystem.isShowTroopLimitGauge();
    $gameSystem.setShowPartyLimitGauge(false);
    $gameSystem.setShowTroopLimitGauge(false);
  }
};

Scene_Battle.prototype.onInBattleStatusCancel = function() {
  this._helpWindow.hide();
  this._inBattleStatusWindow.hide();
  this._inBattleStateList.hide();
  this._inBattleStateList.deactivate();
  this._partyCommandWindow.activate();
  this._statusWindow.deselect();
  if (Imported.YEP_X_PartyLimitGauge) {
    $gameSystem.setShowPartyLimitGauge(this._showPartyLimitGauge);
    $gameSystem.setShowTroopLimitGauge(this._showTroopLimitGauge);
  }
};

Yanfly.IBS.Scene_Battle_isAnyInputWindowActive =
  Scene_Battle.prototype.isAnyInputWindowActive;
Scene_Battle.prototype.isAnyInputWindowActive = function() {
  if (this._inBattleStateList && this._inBattleStateList.active) return true;
  return Yanfly.IBS.Scene_Battle_isAnyInputWindowActive.call(this);
};

if (Imported.YEP_X_BattleSysCTB) {

Yanfly.IBS.Scene_Battle_updateWindowPositionsCTB =
  Scene_Battle.prototype.updateWindowPositionsCTB;
Scene_Battle.prototype.updateWindowPositionsCTB = function() {
  if (this._inBattleStatusWindow && this._inBattleStatusWindow.visible) {
    return;
  }
  Yanfly.IBS.Scene_Battle_updateWindowPositionsCTB.call(this);
};

}; // Imported.YEP_X_BattleSysCTB

//=============================================================================
// Utilities
//=============================================================================

Yanfly.Util = Yanfly.Util || {};

if (!Yanfly.Util.toGroup) {

Yanfly.Util.toGroup = function(inVal) {
  return inVal;
}

};

//=============================================================================
// End of File
//=============================================================================
};


code:
//=============================================================================
// Yanfly Engine Plugins - Item Core Extension - Item Menu Categories
// YEP_X_ItemCategories.js
//=============================================================================

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

var Yanfly = Yanfly || {};
Yanfly.ItemCat = Yanfly.ItemCat || {};
Yanfly.ItemCat.version = 1.01;

//=============================================================================
 /*:
 * @plugindesc v1.01 (Requires YEP_ItemCore.js) Assign items to various
 * categories under the item menu.
 * @author Yanfly Engine Plugins + Sylvester Collaboration
 *
 * @param ---General---
 * @default
 *
 * @param Category Order
 * @parent ---General---
 * @desc Here is the order of all the categories shown in the item
 * menu. Look in the plugin's help file for more information.
 * @default Items, Weapons, Armors, KeyItems
 *
 * @param ---Naming---
 * @default
 *
 * @param Hidden Item A
 * @parent ---Naming---
 * @desc How this category is named in the Item Menu
 * @default Special Items
 *
 * @param Hidden Item B
 * @parent ---Naming---
 * @desc How this category is named in the Item Menu
 * @default Unique Items
 *
 * @param Consumable
 * @parent ---Naming---
 * @desc How this category is named in the Item Menu
 * @default Consumable
 *
 * @param Nonconsumable
 * @parent ---Naming---
 * @desc How this category is named in the Item Menu
 * @default Nonconsumable
 *
 * @param Always Usable
 * @parent ---Naming---
 * @desc How this category is named in the Item Menu
 * @default Usable
 *
 * @param Battle Usable
 * @parent ---Naming---
 * @desc How this category is named in the Item Menu
 * @default Battle
 *
 * @param Field Usable
 * @parent ---Naming---
 * @desc How this category is named in the Item Menu
 * @default Field
 *
 * @param Never Usable
 * @parent ---Naming---
 * @desc How this category is named in the Item Menu
 * @default Misc
 *
 * @help
 * ============================================================================
 * Introduction
 * ============================================================================
 *
 * This plugin requires YEP_ItemCore. Make sure this plugin is located under
 * YEP_ItemCore in the plugin list.
 *
 * In RPG Maker MV, there exists only four categories seen in the item menu:
 * Items, Weapons, Armors, and Key Items. Adding extra categories wouldn't be
 * possible without plugins. This plugin, through the help of Item Core, will
 * allow you to add in many more categories in addition to many premade ones
 * that are automatically added based on weapon types, armor types, equipment
 * types, item usage, and more!
 *
 * This is a collaboration plugin by Sylvester and Yanfly to ensure
 * compatibility with the Yanfly Engine Plugins library.
 *
 * ============================================================================
 * Instructions
 * ============================================================================
 *
 * To change the item categories that appear in the item menu, go to the plugin
 * parameters and alter the list. Separate each category with a comma (,). Each
 * category must be spelled correctly using the following formats:
 *
 * -----------------------   --------------------------------------------------
 * Plugin Parameter Syntax   Description
 * -----------------------   --------------------------------------------------
 * Items                     Lists only Regular Item types
 * AllItems                  All items in the items database with Key Items
 *
 * RegularItems              Lists only Regular Item types
 * KeyItems                  Lists only Key Item types
 * HiddenItemA               Lists only Hidden Item A types
 * HiddenItemB               Lists only Hidden Item B types
 * Consumable                Lists only consumable items
 * Nonconsumable             Lists only nonconsumeable items
 * AlwaysUsable              Lists only always usable items
 * BattleUsable              Lists only battle usable items
 * FieldUsable               Lists only field usable items
 * NeverUsable               Lists only never usable items
 *
 * Weapons                   Lists all weapons
 * WType:x                   Lists weapons of type x (replace x with ID)
 *
 * Armors                    Lists all armors
 * AType:x                   Lists armors of armor type x (replace x with ID)
 *
 * EType:x                   Lists items of equip type x (replace x with ID)
 *
 * Category:x                Lists items of category x (replace x with text)
 *
 * An example of a list that would display something like:
 *   Items
 *   Key Items
 *   Dagger
 *   Sword
 *   Bodygear
 *   Accessory
 *   Herbs
 *
 * Would look like this for the plugin parameters:
 *
 *   Items, KeyItems, WType:1, WType2, AType1, AType2, Category:Herbs
 *
 * The categories go in the order they're listed so plan them out accordingly.
 *
 * ============================================================================
 * Notetags
 * ============================================================================
 *
 * To add custom categories to items, use the following notetag:
 *
 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 *
 * Item, Weapon, and Armor Notetags:
 *
 *   <Menu Category: x>
 *   <Menu Category: x, x, x>
 *   - Replace 'x' with the category name you wish to give the item. Insert
 *   multiples of this tag to insert more categories. These categories will be
 *   used in combination with the Category:x plugin parameter syntax keyword.
 *
 *   For Example:
 *
 *     <Menu Category: Herbs>
 *
 *   Would require this syntax keyword in the plugin parameters:
 *
 *     Category:Herbs
 *
 *   If you use the version of the notetag with multiple categories, it would
 *   work something like this:
 *
 *     <Menu Category: Herbs, Potions, Elixirs>
 *
 *   Plugin Parameter:
 *
 *     Category:Herbs, Category:Potions, Category:Elixirs
 *
 *   **Note** The notetag does not apply for any of the pre-made categories.
 *
 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 *
 * ============================================================================
 * Changelog
 * ============================================================================
 *
 * Version 1.01:
 * - Updated for RPG Maker MV version 1.5.0.
 *
 * Version 1.00:
 * - Finished Plugin!
 */
//=============================================================================

if (Imported.YEP_ItemCore) {

//=============================================================================
// Parameter Variables
//=============================================================================

Yanfly.Parameters = PluginManager.parameters('YEP_X_ItemCategories');
Yanfly.Param = Yanfly.Param || {};

Yanfly.SetupParameters = function() {
  Yanfly.Param.ItemCatOrder = String(Yanfly.Parameters['Category Order']);
  Yanfly.Param.ItemCatOrder = Yanfly.Param.ItemCatOrder.split(',');
  //---
  var length = Yanfly.Param.ItemCatOrder.length;
  for (var i = 0; i < 0; i++) {
    Yanfly.Param.ItemCatOrder[i] = Yanfly.Param.ItemCatOrder[i].trim();
  }
  Yanfly.Param.ItemCatNames = {
    HiddenItemA: String(Yanfly.Parameters['Hidden Item A']),
    HiddenItemB: String(Yanfly.Parameters['Hidden Item B']),
    Consumable: String(Yanfly.Parameters['Consumable']),
    Nonconsumable: String(Yanfly.Parameters['Nonconsumable']),
    AlwaysUsable: String(Yanfly.Parameters['Always Usable']),
    BattleUsable: String(Yanfly.Parameters['Battle Usable']),
    FieldUsable: String(Yanfly.Parameters['Field Usable']),
    NeverUsable: String(Yanfly.Parameters['Never Usable'])
  }
};
Yanfly.SetupParameters();

//=============================================================================
// DataManager
// ----------------------------------------------------------------------------
// Notetags added by Yanfly
//=============================================================================

Yanfly.ItemCat.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
  if (!Yanfly.ItemCat.DataManager_isDatabaseLoaded.call(this)) return false;

  if (!Yanfly._loaded_YEP_X_ItemCategories) {
    this.processItemCategoriesNotetags1($dataItems);
    this.processItemCategoriesNotetags1($dataWeapons);
    this.processItemCategoriesNotetags1($dataArmors);
    Yanfly._loaded_YEP_X_ItemCategories = true;
  }

  return true;
};

DataManager.processItemCategoriesNotetags1 = function(group) {
  for (var n = 1; n < group.length; n++) {
    var obj = group[n];
    var notedata = obj.note.split(/[\r\n]+/);

    obj.itemCategory = [];

    for (var i = 0; i < notedata.length; i++) {
      var line = notedata[i];
      if (line.match(/<MENU[ ](?:CATEGORY|CATEGORIES):[ ](.*)>/i)) {
        var str = String(RegExp.$1).split(',');
        var length = str.length;
        for (var s = 0; s < length; s++) {
          obj.itemCategory.push(str[s].trim());
        }
      }
    }
  }
};

//=============================================================================
// Window_ItemCategory
//=============================================================================

Yanfly.ItemCat.Window_ItemCategory_update =
  Window_ItemCategory.prototype.update;
Window_ItemCategory.prototype.update = function() {
  Yanfly.ItemCat.Window_ItemCategory_update.call(this);
  if (this._itemWindow) {
    this._itemWindow.setExt(this.currentExt());
  }
};

Window_ItemCategory.prototype.makeCommandList = function() {
  var data = Yanfly.Param.ItemCatOrder;
  var length = data.length;
  for (var i = 0; i < length; i++) {
    var category = data[i].trim();
    this.addItemCategory(category);
  }
};

Window_ItemCategory.prototype.addItemCategory = function(category) {
  var text = Yanfly.Param.ItemCatNames[category];
  if (category.match(/Category:(.*)/i)) {
    var type = String(RegExp.$1);
    return this.addCommand(type, 'Category', true, type);
  }
  if (category.match(/AllItems/i)) {
    return this.addCommand(TextManager.item, 'AllItems');
  }
  if (category.match(/RegularItems/i)) {
    return this.addCommand(text, 'item');
  }
  if (category.match(/KeyItems/i)) {
    return this.addCommand(TextManager.keyItem, 'keyItem');
  }
  if (category.match(/HiddenItemA/i)) {
    return this.addCommand(text, 'HiddenItemA');
  }
  if (category.match(/HiddenItemB/i)) {
    return this.addCommand(text, 'HiddenItemB');
  }
  if (category.match(/Nonconsumable/i)) {
    return this.addCommand(text, 'Nonconsumable');
  }
  if (category.match(/Consumable/i)) {
    return this.addCommand(text, 'Consumable');
  }
  if (category.match(/AlwaysUsable/i)) {
    return this.addCommand(text, 'AlwaysUsable');
  }
  if (category.match(/BattleUsable/i)) {
    return this.addCommand(text, 'BattleUsable');
  }
  if (category.match(/FieldUsable/i)) {
    return this.addCommand(text, 'FieldUsable');
  }
  if (category.match(/NeverUsable/i)) {
    return this.addCommand(text, 'NeverUsable');
  }
  if (category.match(/Items/i)) {
    return this.addCommand(TextManager.item, 'item');
  }
  if (category.match(/Weapons/i)) {
    return this.addCommand(TextManager.weapon, 'weapon');
  }
  if (category.match(/WType:(\d+)/i)) {
    var id = parseInt(RegExp.$1);
    return this.addCommand($dataSystem.weaponTypes[id], 'WType', true, id);
  }
  if (category.match(/Armors/i)) {
    return this.addCommand(TextManager.armor, 'armor');
  }
  if (category.match(/AType:(\d+)/i)) {
    var id = parseInt(RegExp.$1);
    return this.addCommand($dataSystem.armorTypes[id], 'AType', true, id);
  }
  if (category.match(/EType:(\d+)/i)) {
    var id = parseInt(RegExp.$1);
    return this.addCommand($dataSystem.equipTypes[id], 'EType', true, id);
  }
};

//=============================================================================
// Window_ItemList
//=============================================================================

Yanfly.ItemCat.Window_ItemList_initialize =
  Window_ItemList.prototype.initialize;
Window_ItemList.prototype.initialize = function(x, y, width, height) {
  Yanfly.ItemCat.Window_ItemList_initialize.call(this, x, y, width, height);
  this._ext = 'none';
};

Window_ItemList.prototype.setExt = function(ext) {
  if (this._ext !== ext) {
    this._ext = ext;
    this.refresh();
    this.resetScroll();
  }
};

Window_ItemList.prototype.includes = function(item) {
  switch (this._category) {
  case 'AllItems':
    return DataManager.isItem(item);
    break;
  case 'item':
    return DataManager.isItem(item) && item.itypeId === 1;
    break;
  case 'RegularItems':
    return DataManager.isItem(item) && item.itypeId === 1;
    break;
  case 'keyItem':
    return DataManager.isItem(item) && item.itypeId === 2;
    break;
  case 'HiddenItemA':
    return DataManager.isItem(item) && item.itypeId === 3;
    break;
  case 'HiddenItemB':
    return DataManager.isItem(item) && item.itypeId === 4;
    break;
  case 'Consumable':
    return DataManager.isItem(item) && item.consumable;
    break;
  case 'Nonconsumable':
    return DataManager.isItem(item) && !item.consumable;
    break;
  case 'AlwaysUsable':
    return DataManager.isItem(item) && [0].contains(item.occasion);
    break;
  case 'BattleUsable':
    return DataManager.isItem(item) && [0, 1].contains(item.occasion);
    break;
  case 'FieldUsable':
    return DataManager.isItem(item) && [0, 2].contains(item.occasion);
    break;
  case 'NeverUsable':
    return DataManager.isItem(item) && [3].contains(item.occasion);
    break;
  case 'weapon':
    return DataManager.isWeapon(item);
    break;
  case 'WType':
    return DataManager.isWeapon(item) && item.wtypeId === this._ext;
    break;
  case 'armor':
    return DataManager.isArmor(item);
    break;
  case 'AType':
    return DataManager.isArmor(item) && item.atypeId === this._ext;
    break;
  case 'EType':
    return item && item.etypeId === this._ext;
    break;
  case 'Category':
    return item && item.itemCategory.contains(this._ext);
    break;
  default:
    return false;
  }
};

//=============================================================================
// End of File
//=============================================================================
} else {

var text = '================================================================\n';
text += 'YEP_X_ItemCategories requires YEP_ItemCore and to be at the latest '
text += 'version to run properly. '
text += '\n\nPlease go to www.yanfly.moe and update to the latest version for ';
text += 'the YEP_ItemCore plugin.\n';
text += '================================================================\n';
console.log(text);
require('nw.gui').Window.get().showDevTools();

}

license: unknown


code:
//=============================================================================
// Yanfly Engine Plugins - Item Core Extension - Item Requirements
// YEP_X_ItemRequirements.js
//=============================================================================

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

var Yanfly = Yanfly || {};
Yanfly.ItemReq = Yanfly.ItemReq || {};
Yanfly.ItemReq.version = 1.01;

//=============================================================================
 /*:
 * @plugindesc v1.01 (Requires YEP_ItemCore.js) Place requirements on
 * items before they can be used.
 * @author Yanfly Engine Plugins
 *
 * @help
 * ============================================================================
 * Introduction
 * ============================================================================
 *
 * This plugin requires YEP_ItemCore. Make sure this plugin is located under
 * YEP_ItemCore in the plugin list.
 *
 * In RPG Maker MV, items only have a few restrictions on them by default,
 * whether or not they can be used in or out of battle or never. There aren't
 * any other conditions that you can set that would otherwise determine if an
 * item can or cannot be used. This plugin gives more ways to restrict item
 * usage based on switches, variables, the actors using them, classes, state
 * requirements, and more.
 *
 * ============================================================================
 * Notetags
 * ============================================================================
 *
 * Use the following notetags to enforce requirements for items before they can
 * be used.
 *
 * Item Notetags:
 *
 *   <Enable Requirements>
 *    condition
 *    condition
 *   </Enable Requirements>
 *   - Replace 'condition' with the desired condition setup. You can insert any
 *   number of conditions inside the notetags. All of the conditions must be
 *   met before the item can be used. Look below for a list of the possible
 *   conditions that can be used.
 *
 * ---
 *
 * Conditions:
 *
 * ---
 *
 * Eval: code
 * - Replace 'code' with JavaScript code that you'd like to run a check against
 * to enable the item. If the check returns false, the item will be disabled
 * regardless of other conditions.
 *
 * Examples:
 *   Eval: $gameActors.actor(1).name() === 'Harold'
 *   Eval: $gameActors.leader().name() !== 'Ralph'
 *
 * ---
 *
 * Actor: x
 * Actor: x, x, x
 * - Requires actor(s) ID 'x' to use the item. If the actor isn't the one using
 * the said item, then the item is disabled and cannot be used regardless of
 * other conditions.
 *
 * Not Actor: x
 * Not Actor: x, x, x
 * - Requires the actor using the item to NOT be actor ID 'x'. If the actor's
 * ID matches one of the listed 'x', then the item is disabled and cannot be
 * used regardless of other conditions.
 *
 * Examples:
 *   Actor: 1
 *   Actor: 2, 3, 4, 5, 6
 *   Not Actor: 7
 *   Not Actor: 8, 9, 10
 *
 * ---
 *
 * Armor: x
 * Armor: x, x, x
 * - Requires the actor to specifically have armor ID 'x' equipped to use the
 * item. If multiple 'x' are used, the actor can have any of them equipped. If
 * the actor does not have armor 'x' equipped, then the item is disabled and
 * cannot be used regardless of other conditions.
 *
 * Not Armor: x
 * Not Armor: x, x, x
 * - Requires the actor to not have armor ID 'x' equipped to use the item.
 * If multiple 'x' are used, the actor cannot have any of them equipped. If
 * the actor does have armor 'x' equipped, then the item is disabled and
 * cannot be used regardless of other conditions.
 *
 * Examples:
 *   Armor: 1
 *   Armor: 2, 3, 4, 5, 6
 *   Not Armor: 7
 *   Not Armor: 8, 9, 10
 *
 * ---
 *
 * Class: x
 * Class: x, x, x
 * - Requires class(es) ID 'x' to use the item. If the actor's class doesn't
 * match the item requirement, then the item is disabled and cannot be used
 * regardless of other conditions.
 *
 * Not Class: x
 * Not Class: x, x, x
 * - Requires the actor using the item to NOT be class ID 'x'. If the actor's
 * class ID matches one of the listed 'x', then the item is disabled and cannot
 * be used regardless of other conditions.
 *
 * Examples:
 *   Class: 1
 *   Class: 2, 3, 4, 5, 6
 *   Not Class: 7
 *   Not Class: 8, 9, 10
 *
 * ---
 *
 * Subclass: x
 * Subclass: x, x, x
 * - Requires YEP_X_Subclass.js
 * - Requires subclass(es) ID 'x' to use the item. If the actor's class doesn't
 * match the item requirement, then the item is disabled and cannot be used
 * regardless of other conditions.
 *
 * Not Subclass: x
 * Not Subclass: x, x, x
 * - Requires YEP_X_Subclass.js
 * - Requires the actor using the item to NOT be subclass ID 'x'. If the
 * actor's subclass ID matches one of the listed 'x', then the item is disabled
 * and cannot be used regardless of other conditions.
 *
 * Examples:
 *   Subclass: 1
 *   Subclass: 2, 3, 4, 5, 6
 *   Not Subclass: 7
 *   Not Subclass: 8, 9, 10
 *
 * ---
 *
 * Either Class: x
 * Either Class: x, x, x
 * - Requires YEP_X_Subclass.js
 * - The actor's primary class or subclass ID has to match 'x'. If at least one
 * of them match, then the condition passes. Otherwise, the condition fails and
 * the item is disabled and cannot be used regardless of other conditions.
 *
 * Neither Class: x
 * Neither Class: x, x, x
 * - Requires YEP_X_Subclass.js
 * - Requires YEP_X_Subclass.js
 * - The actor's primary class or subclass ID has to NOT match 'x'. If at least
 * one of them match, then the condition fails and the item is disabled and
 * cannot be used regardless of other conditions.
 *
 * Examples:
 *   Either Class: 1
 *   Either Class: 2, 3, 4, 5, 6
 *   Neither Class: 7
 *   Neither Class: 8, 9, 10
 *
 * ---
 *
 * State: x
 * State: x, x, x
 * - Requires the actor using the item to be affected by state 'x'. If multiple
 * 'x' are used, the actor can be affected by any of them. If the actor is not
 * affected by state 'x', then the condition fails and the item is disabled
 * and cannot be used regardless of other conditions.
 *
 * Not State: x
 * Not State: x, x, x
 * - Requires the actor using the item to be not affected by state 'x'. If
 * multiple 'x' are used, the actor cannot be affected by any of them. If the
 * actor is not affected by state 'x', then the condition fails and the item is
 * disabled and cannot be used regardless of other conditions.
 *
 * Examples:
 *   State: 10
 *   State: 11, 12, 13, 14, 15
 *   Not State: 16
 *   Not Stage: 17, 18, 19, 20
 *
 * ---
 *
 * Switch Off: x
 * Switch Off: x, x, x
 * - Requires switch(es) x to be OFF before the item can be used. If the switch
 * is ON, then the item is disabled and cannot be used regardless of other
 * conditions.
 *
 * Examples:
 *   Switch Off: 1
 *   Switch Off: 2, 3, 4, 5, 6
 *
 * ---
 *
 * Switch On: x
 * Switch On: x, x, x
 * - Requires switch(es) x to be ON before the item can be used. If the switch
 * is OFF, then the item is disabled and cannot be used regardless of other
 * conditions.
 *
 * Examples:
 *   Switch On: 1
 *   Switch On: 2, 3, 4, 5, 6
 *
 * ---
 *
 * Variable x eval
 * - Makes a check against variable x. Replace 'x' with an integer value and
 * 'eval' with the code check you wish to run it against.
 *
 * Examples:
 *   Variable 1 >= 5
 *   Variable 2 < 6
 *   Variable 3 === 7
 *   Variable 4 !== 8
 *
 * ---
 *
 * Weapon: x
 * Weapon: x, x, x
 * - Requires the actor to specifically have weapon ID 'x' equipped to use the
 * item. If multiple 'x' are used, the actor can have any of them equipped. If
 * the actor does not have weapon 'x' equipped, then the item is disabled and
 * cannot be used regardless of other conditions.
 *
 * Not Weapon: x
 * Not Weapon: x, x, x
 * - Requires the actor to not have weapon ID 'x' equipped to use the item.
 * If multiple 'x' are used, the actor cannot have any of them equipped. If
 * the actor does have weapon 'x' equipped, then the item is disabled and
 * cannot be used regardless of other conditions.
 *
 * Examples:
 *   Weapon: 1
 *   Weapon: 2, 3, 4, 5, 6
 *   Not Weapon: 7
 *   Not Weapon: 8, 9, 10
 *
 * ---
 *
 * Weapon Type: x
 * Weapon Type: x, x, x
 * - Requires the actor to have weapon type 'x' equipped. If multiple 'x' are
 * used, the actor can have any of the 'x' weapon types equipped. If the actor
 * does not have the matching weapon types, then the item is disabled and
 * cannot be used regardless of other conditions.
 *
 * Not Weapon Type: x
 * Not Weapon Type: x, x, x
 * - Requires the actor to not have weapon type 'x' equipped. If multiple 'x'
 * are used, the actor cannot have any of the 'x' weapon types equipped. If the
 * actor does have the matching weapon types, then the item is disabled and
 * cannot be used regardless of other conditions.
 *
 * Examples:
 *   Weapon Type: 1
 *   Weapon Type: 2, 3, 4, 5, 6
 *   Not Weapon Type: 7
 *   Not Weapon Type: 8, 9, 10
 *
 * ============================================================================
 * Lunatic Mode - Custom Enable Requirements
 * ============================================================================
 *
 * For those with JavaScript experience, you can create your own custom
 * requirements for whether or not items can be used using the following
 * notetag setup:
 *
 * Item Notetags:
 *
 *   <Custom Enable Requirement>
 *    condition = battler.level >= item.price;
 *   </Custom Enable Requirement>
 *   - The 'condition' variable will determine whether or not the item will be
 *   enabled/disabled. If the 'condition' variable returns true, then the item
 *   is enabled provided all other conditions (if any) are also met. Otherwise,
 *   the item is disabled and cannot be used. The 'battler' variable will refer
 *   to the battler using the item. The 'item' variable will refer to the item
 *   being checked.
 *
 * ============================================================================
 * Changelog
 * ============================================================================
 *
 * Version 1.01:
 * - Updated for RPG Maker MV version 1.5.0.
 *
 * Version 1.00:
 * - Finished Plugin!
 */
//=============================================================================

if (Imported.YEP_ItemCore) {

//=============================================================================
// DataManager
//=============================================================================

Yanfly.ItemReq.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
  if (!Yanfly.ItemReq.DataManager_isDatabaseLoaded.call(this)) return false;

  if (!Yanfly._loaded_YEP_X_ItemRequirements) {
    this.processItemRequirementsNotetags1($dataItems);
    Yanfly._loaded_YEP_X_ItemRequirements = true;
  }

  return true;
};

DataManager.processItemRequirementsNotetags1 = function(group) {
  for (var n = 1; n < group.length; n++) {
    var obj = group[n];
    var notedata = obj.note.split(/[\r\n]+/);

    obj.itemRequirements = [];
    var evalMode = 'none';
    obj.customItemRequirements = '';

    for (var i = 0; i < notedata.length; i++) {
      var line = notedata[i];
      if (line.match(/<ENABLE (?:REQUIREMENT|REQUIREMENTS)>/i)) {
        evalMode = 'enable requirements';
      } else if (line.match(/<\/ENABLE (?:REQUIREMENT|REQUIREMENTS)>/i)) {
        evalMode = 'none';
      } else if (evalMode === 'enable requirements') {
        obj.itemRequirements.push(line);
      } else if (line.match(/<CUSTOM ENABLE (?:REQUIREMENT|REQUIREMENTS)>/i)) {
        evalMode = 'custom enable requirements';
      } else if (line.match(/<\/CUSTOM ENABLE (?:REQUIREMENT|REQUIREMENTS)>/i)) {
        evalMode = 'none';
      } else if (evalMode === 'custom enable requirements') {
        obj.customItemRequirements += line + '\n';
      }
    }
  }
};

//=============================================================================
// Game_BattlerBase
//=============================================================================

Yanfly.ItemReq.Game_BattlerBase_mIC =
  Game_BattlerBase.prototype.meetsItemConditions;
Game_BattlerBase.prototype.meetsItemConditions = function(item) {
  if (!Yanfly.ItemReq.Game_BattlerBase_mIC.call(this, item)) {
    return false;
  }
  return ItemManager.meetsUsableItemRequirements(item, this);
};

//=============================================================================
// Game_Actor
//=============================================================================

Game_Actor.prototype.isAtypeEquipped = function(atypeId) {
  return this.armors().some(function(armor) {
    return armor.atypeId === atypeId;
  });
};

//=============================================================================
// ItemManager
//=============================================================================

ItemManager.meetsUsableItemRequirements = function(item, battler) {
  if (!item) return false;
  if (!item.itemRequirements) {
    var baseItem = DataManager.getBaseItem(item);
    item.itemRequirements = JsonEx.makeDeepCopy(baseItem.itemRequirements);
  }
  var length = item.itemRequirements.length;
  if ($gameParty.inBattle()) var battler = this.battleSubject() || battler;
  for (var i = 0; i < length; ++i) {
    var line = item.itemRequirements[i];
    if (!line) continue;
    if (!this.checkUsableItemRequirement(line, item, battler)) return false;
  }
  if (item.customItemRequirements && item.customItemRequirements.length >= 1) {
    if (!this.checkCustomUsableItemRequirement(item, battler)) return false;
  }
  return true;
};

ItemManager.battleSubject = function() {
  return BattleManager.actor() || BattleManager._subject;
};

ItemManager.checkUsableItemRequirement = function(line, item, battler) {
  // EVAL
  if (line.match(/EVAL:(.*)/i)) {
    var code = String(RegExp.$1);
    return this.usableItemRequirementEval(code);
  }
  // NOT ACTOR
  if (line.match(/NOT ACTOR:(.*)/i)) {
    var data = String(RegExp.$1);
    return this.usableItemRequirementActor(data, battler, false);
  }
  // ACTOR
  if (line.match(/ACTOR:(.*)/i)) {
    var data = String(RegExp.$1);
    return this.usableItemRequirementActor(data, battler, true);
  }
  // NOT ARMOR TYPE
  if (line.match(/NOT ARMOR TYPE:(.*)/i)) {
    var data = String(RegExp.$1);
    return this.usableItemRequirementAtype(data, battler, false);
  }
  // ARMOR TYPE
  if (line.match(/ARMOR TYPE:(.*)/i)) {
    var data = String(RegExp.$1);
    return this.usableItemRequirementAtype(data, battler, true);
  }
  // NOT ARMOR
  if (line.match(/NOT ARMOR:(.*)/i)) {
    var data = String(RegExp.$1);
    return this.usableItemRequirementArmor(data, battler, false);
  }
  // ARMOR
  if (line.match(/ARMOR:(.*)/i)) {
    var data = String(RegExp.$1);
    return this.usableItemRequirementArmor(data, battler, true);
  }
  if (Imported.YEP_X_Subclass) {
    // NOT SUBCLASS
    if (line.match(/NOT SUBCLASS:(.*)/i)) {
      var data = String(RegExp.$1);
      return this.usableItemRequirementSubclass(data, battler, false);
    }
    // SUBCLASS
    if (line.match(/SUBCLASS:(.*)/i)) {
      var data = String(RegExp.$1);
      return this.usableItemRequirementSubclass(data, battler, true);
    }
    // EITHER CLASS
    if (line.match(/EITHER CLASS:(.*)/i)) {
      var data = String(RegExp.$1);
      return this.usableItemRequirementDuoClass(data, battler, true);
    }
    // NEITHER CLASS
    if (line.match(/NEITHER CLASS:(.*)/i)) {
      var data = String(RegExp.$1);
      return this.usableItemRequirementDuoClass(data, battler, false);
    }
  }
  // NOT CLASS
  if (line.match(/NOT CLASS:(.*)/i)) {
    var data = String(RegExp.$1);
    return this.usableItemRequirementClass(data, battler, false);
  }
  // CLASS
  if (line.match(/CLASS:(.*)/i)) {
    var data = String(RegExp.$1);
    return this.usableItemRequirementClass(data, battler, true);
  }
  // NOT STATE
  if (line.match(/NOT STATE:(.*)/i)) {
    var data = String(RegExp.$1);
    return this.usableItemRequirementState(data, battler, false);
  }
  // STATE
  if (line.match(/STATE:(.*)/i)) {
    var data = String(RegExp.$1);
    return this.usableItemRequirementState(data, battler, true);
  }
  // NOT WEAPON TYPE
  if (line.match(/NOT WEAPON TYPE:(.*)/i)) {
    var data = String(RegExp.$1);
    return this.usableItemRequirementWtype(data, battler, false);
  }
  // WEAPON TYPE
  if (line.match(/WEAPON TYPE:(.*)/i)) {
    var data = String(RegExp.$1);
    return this.usableItemRequirementWtype(data, battler, true);
  }
  // NOT WEAPON
  if (line.match(/NOT WEAPON:(.*)/i)) {
    var data = String(RegExp.$1);
    return this.usableItemRequirementWeapon(data, battler, false);
  }
  // WEAPON
  if (line.match(/WEAPON:(.*)/i)) {
    var data = String(RegExp.$1);
    return this.usableItemRequirementWeapon(data, battler, true);
  }
  // SWITCH OFF
  if (line.match(/SWITCH OFF:(.*)/i)) {
    var data = String(RegExp.$1);
    return this.usableItemRequirementSwitch(data, false);
  }
  // SWITCH ON
  if (line.match(/SWITCH ON:(.*)/i)) {
    var data = String(RegExp.$1);
    return this.usableItemRequirementSwitch(data, true);
  }
  // VARIABLE
  if (line.match(/VARIABLE[ ](\d+)[ ](.*)/i)) {
    var variableId = parseInt(RegExp.$1);
    var code = String(RegExp.$2);
    return this.usableItemRequirementVariable(variableId, code);
  }
  return true;
};

ItemManager.usableItemRequirementEval = function(code) {
  var value = false;
  try {
    eval(code);
  } catch (e) {
    Yanfly.Util.displayError(e, code, 'CUSTOM ITEM USE EVAL CODE ERROR');
  }
  return value;
};

ItemManager.usableItemRequirementActor = function(data, battler, condition) {
  var array = data.split(',');
  var length = array.length;
  for (var i = 0; i < length; ++i) {
    var actorId = parseInt(array[i].trim());
    if (battler.actorId() === actorId) return condition;
  }
  return !condition;
};

ItemManager.usableItemRequirementClass = function(data, battler, condition) {
  var array = data.split(',');
  var length = array.length;
  for (var i = 0; i < length; ++i) {
    var classId = parseInt(array[i].trim());
    if (battler._classId === classId) return condition;
  }
  return !condition;
};

ItemManager.usableItemRequirementDuoClass = function(data, battler, condition) {
  var array = data.split(',');
  var length = array.length;
  for (var i = 0; i < length; ++i) {
    var classId = parseInt(array[i].trim());
    var subclassId = parseInt(array[i].trim());
    if (battler._classId === classId || battler._subclassId === subclassId) {
      return condition;
    }
  }
  return !condition;
};

ItemManager.usableItemRequirementSubclass = function(data, battler, condition) {
  var array = data.split(',');
  var length = array.length;
  for (var i = 0; i < length; ++i) {
    var subclassId = parseInt(array[i].trim());
    if (battler._subclassId === subclassId) return condition;
  }
  return !condition;
};

ItemManager.usableItemRequirementState = function(data, battler, condition) {
  var array = data.split(',');
  var length = array.length;
  for (var i = 0; i < length; ++i) {
    var stateId = parseInt(array[i].trim());
    var state = $dataStates[stateId];
    if (battler.states().contains(state)) return condition;
  }
  return !condition;
};

ItemManager.usableItemRequirementWtype = function(data, battler, condition) {
  var array = data.split(',');
  var length = array.length;
  for (var i = 0; i < length; ++i) {
    var id = parseInt(array[i].trim());
    if (battler.isWtypeEquipped(id)) return condition;
  }
  return !condition;
};

ItemManager.usableItemRequirementWeapon = function(data, battler, condition) {
  var array = data.split(',');
  var length = array.length;
  for (var i = 0; i < length; ++i) {
    var id = parseInt(array[i].trim());
    var equip = $dataWeapons[id];
    if (battler.hasWeapon(equip)) return condition;
  }
  return !condition;
};

ItemManager.usableItemRequirementAtype = function(data, battler, condition) {
  var array = data.split(',');
  var length = array.length;
  for (var i = 0; i < length; ++i) {
    var id = parseInt(array[i].trim());
    if (battler.isAtypeEquipped(id)) return condition;
  }
  return !condition;
};

ItemManager.usableItemRequirementArmor = function(data, battler, condition) {
  var array = data.split(',');
  var length = array.length;
  for (var i = 0; i < length; ++i) {
    var id = parseInt(array[i].trim());
    var equip = $dataArmors[id];
    if (battler.hasArmor(equip)) return condition;
  }
  return !condition;
};

ItemManager.usableItemRequirementSwitch = function(data, condition) {
  var array = data.split(',');
  var length = array.length;
  for (var i = 0; i < length; ++i) {
    var switchId = parseInt(array[i].trim());
    if ($gameSwitches.value(switchId) !== condition) return false;
  }
  return true;
};

ItemManager.usableItemRequirementVariable = function(variableId, code) {
  return eval('$gameVariables.value(variableId) ' + code);
};

ItemManager.checkCustomUsableItemRequirement = function(item, battler) {
  var condition = false;
  var user = battler;
  var a = battler;
  var b = battler;
  var target = battler;
  var subject = battler;
  var s = $gameSwitches._data;
  var v = $gameVariables._data;
  var code = item.customItemRequirements;
  try {
    eval(code);
  } catch (e) {
    Yanfly.Util.displayError(e, code, 'CUSTOM ITEM USE REQUIREMENT CODE ERROR');
  }
  return condition;
};

//=============================================================================
// Utilities
//=============================================================================

Yanfly.Util = Yanfly.Util || {};

Yanfly.Util.displayError = function(e, code, message) {
  console.log(message);
  console.log(code || 'NON-EXISTENT');
  console.error(e);
  if (Utils.isNwjs() && Utils.isOptionValid('test')) {
    if (!require('nw.gui').Window.get().isDevToolsOpen()) {
      require('nw.gui').Window.get().showDevTools();
    }
  }
};

//=============================================================================
// End of File
//=============================================================================
} else {

var text = '================================================================\n';
text += 'YEP_X_ItemRequirements requires YEP_ItemCore to be at the ';
text += 'latest version to run properly.\n\nPlease go to www.yanfly.moe and ';
text += 'update to the latest version for the YEP_ItemCore plugin.\n';
text += '================================================================\n';
console.log(text);
require('nw.gui').Window.get().showDevTools();

} // // Imported.YEP_ItemCore