Advertisement
Unconnected42

RMMV Plug-in _ Unco_ChangeEquipOnBattle_v1_0_0

Dec 6th, 2016
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Change Equip On Battle, ver1.0.0
  3. //   by Unconnected42
  4. // Based on ChangeWeaponOnBattle, by Kannazuki Sasuke
  5. //
  6. // UNCO_ChangeEquipOnBattle.js
  7. // Last Updated : 2015/12/01
  8. //=============================================================================
  9.  
  10. var Imported = Imported || {};
  11. Imported.UNCO_ChangeEquip = true;
  12.  
  13. var Unco = Unco || {};
  14. Unco.CEB = Unco.CEB || {};
  15.  
  16.  
  17. //=============================================================================
  18.  /*:
  19.  * @plugindesc  Allows player to change certain slots of equipment during battle.
  20.  * <Unco Equip>
  21.  * @author Unconnected42
  22.  *
  23.  * @param Equip Command Name
  24.  * @desc  Name of the equip command in actor battle menu.
  25.  * @default Equip
  26.  *
  27.  * @param Equip Command Icon
  28.  * @desc  Id of the icon to be displayed in front of Equip command when Bobstah's
  29.  * Battle Command List is present.
  30.  * @default 76
  31.  *
  32.  * @param Default Battle Equip Slots
  33.  * @desc  The equip slots that can be changed by all classes by default (separated by commas ',').
  34.  * @default 1
  35.  *
  36.  * @param Equip Skip Turn
  37.  * @desc  'full'=turn skipped as soon as one equip changed. 'half'=turn skipped when leaving equip menu. 'none'=no skip.
  38.  * @default full
  39.  *
  40.  * @param Equip Skill Id
  41.  * @desc  The Id of the dummy skill that the actor will use after changing equipment, when turn is consumed.
  42.  * @default 7
  43.  *
  44.  * @param No Equip Icon Id
  45.  * @desc  Id of the icon to use for equip slots currently without equipment.
  46.  * @default 16
  47.  *
  48.  * @param No Equip Text
  49.  * @desc  Text to use for equip slots currently without equipment.
  50.  * @default <Empty>
  51.  *
  52.  * @param No Change Icon Id
  53.  * @desc  Id of the icon to use for equip slots with no changes planned.
  54.  * @default 16
  55.  *
  56.  * @param No Change Text
  57.  * @desc  Text to use for equip slots with no changes planned.
  58.  * @default <No Changes>
  59.  *
  60.  * @help
  61.  * ============================================
  62.  * Introduction
  63.  * ============================================
  64.  *
  65.  * This plug-in is based on the official plug-in ChangeWeaponOnBattle,
  66.  * with the following differences:
  67.  * - allow maker to decide each equipments may be changed, for each class.
  68.  * - guarantees a minimum level of compatibility with Bobstah's Battle
  69.  *   Command List plug-in (equip command can have an icon, but cannot
  70.  *   currently be moved freely at any place in the command list).
  71.  * - guarantee compatibility with Ammunition System.
  72.  * - also provide some compatibility with EquipCore.
  73.  * - changing equipment can consume actor's turn.
  74.  *
  75.  * ============================================
  76.  * Known Compatibility Issues
  77.  * ============================================
  78.  *
  79.  * This plug-in should be placed below any other plug-in that it
  80.  * interacts with, namely: Battle Command List, EquipCore,
  81.  * Ammunition System.
  82.  *
  83.  * ============================================
  84.  * Use
  85.  * ============================================
  86.  *
  87.  * Some very important points that must be understood before using
  88.  * this plug-in:
  89.  * - because this plug-in aims to allow turn skipping when changing
  90.  *   equipment, the actual equip change is done *NOT* while into equip
  91.  *   menu, but when the actor performs the equip action.
  92.  * - therefore, an equip skill must be defined (its id must be set
  93.  *   in plug-in's parameters). This skill will be automatically
  94.  *   selected as the actor's next action when equip
  95.  *   change is decided through battle equip menu.
  96.  * - the equip skill must have the following requirements:
  97.  *   + the scope must be 'the user'
  98.  *   + if Yanfly's action sequences are used, be sure that the
  99.  *     'target action' section allows the actor to actually use
  100.  *     the skill and apply its effects. Otherwise, equip changes
  101.  *     will not be made.
  102.  * However, if you put 'Equip Skip Turn' at 'none', equip changes will
  103.  * be made normally in the battle equip menu.
  104.  *
  105.  * Enabling equipment change during battle is class-based: you have to
  106.  * put notetags inside a class notebox.
  107.  * Lines to put in class notebox :
  108.  *    <Battle Change Equip: s1,s2,...>
  109.  * ...where 's1,s2,...' are the equip slots that the actor will be
  110.  * able to change during battle.
  111.  * For ex. : <Battle Change Equip: 1,2,5> will allow any actor having
  112.  * the class where the tag is put to change the three listed equip slots
  113.  * (in that case, probably weapon, shield and some accessory).
  114.  *
  115.  */
  116. //=============================================================================
  117.  
  118. //=============================================================================
  119. // Parameter Variables
  120. //=============================================================================
  121.  
  122.  
  123. (function() {
  124.    Unco.Parameters = $plugins.filter(function(p) {
  125.           return p.description.contains('<Unco Equip>');
  126.       })[0].parameters; //Copied from Ellye, who thanks Iavra
  127.    Unco.Param = Unco.Param || {};
  128.  
  129.    Unco.Param.equipCommandName = String(Unco.Parameters['Equip Command Name']) || 'Equip';
  130.    Unco.Param.equipConsumeTurn = String(Unco.Parameters['Equip Skip Turn']).toLowerCase() || 'full';
  131.    Unco.Param.equipIconId = parseInt(Unco.Parameters['Equip Command Icon']) || 76;
  132.    Unco.Param.equipSkillId = parseInt(Unco.Parameters['Equip Skill Id']) || 7;
  133.    Unco.Param.equipNoEquipIconId = parseInt(Unco.Parameters['No Equip Icon Id']) || 16;
  134.    Unco.Param.equipNoChangeIconId = parseInt(Unco.Parameters['No Change Icon Id']) || 16;
  135.    Unco.Param.equipNoEquipText = String(Unco.Parameters['No Equip Text']) || '<Empty>';
  136.    Unco.Param.equipNoChangeText = String(Unco.Parameters['No Change Text']) || '<No Changes>';
  137.    Unco.Param.equipDefaultSlots = [];
  138.    var prepareEquipDefaultSlots = String(Unco.Parameters['Default Battle Equip Slots']).split(',') || [];
  139.    for (var i=0; i < prepareEquipDefaultSlots.length; i++) {
  140.       var slot = parseInt(prepareEquipDefaultSlots[i]);
  141.       if (!isNaN(slot) && (slot > 0)) Unco.Param.equipDefaultSlots.push(slot);
  142.    }
  143.  
  144.   //=============================================================================
  145.   // DataManager
  146.   //  * Tags Processing
  147.   //=============================================================================
  148.  
  149.    Unco.CEB.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  150.    DataManager.isDatabaseLoaded = function() {
  151.       if (!Unco.CEB.DataManager_isDatabaseLoaded.call(this)) return false;
  152.       this.processUncoEquipChangeNotetags($dataClasses);
  153.       return true;
  154.    };
  155.  
  156.    DataManager.processUncoEquipChangeNotetags = function(group) {
  157.       for (var n = 1; n < group.length; n++) {
  158.          var obj = group[n];
  159.          var notedata = obj.note.split(/[\r\n]+/);
  160.          obj.equipChangeSlots = Unco.Param.equipDefaultSlots.slice();
  161.          for (var i = 0; i < notedata.length; i++) {
  162.             var line = notedata[i];
  163.             if (line.match(/<(?:BATTLE)[ ](?:CHANGE)[ ](?:EQUIP):[ ](.*)>/i)) {
  164.                var slotList = String(RegExp.$1).split(',');
  165.                for (var i in slotList) {
  166.                   var slot = parseInt(slotList[i])
  167.                   if (!isNaN(slot) && (slot > 0) && (!obj.equipChangeSlots.contains(slot))) obj.equipChangeSlots.push(slot);
  168.                }
  169.             }
  170.          }
  171.       }
  172.    };
  173.  
  174.  
  175.    //=============================================================================
  176.    // Window_BattleEquipStatus
  177.   //  * Display Equip Bonuses
  178.    //=============================================================================
  179.    function Window_BattleEquipStatus() {
  180.       this.initialize.apply(this, arguments);
  181.    }
  182.  
  183.    Window_BattleEquipStatus.prototype =
  184.       Object.create(Window_EquipStatus.prototype);
  185.    Window_BattleEquipStatus.prototype.constructor = Window_BattleEquipStatus;
  186.  
  187.    Window_BattleEquipStatus.prototype.initialize = function(x, y) {
  188.       Window_EquipStatus.prototype.initialize.call(this, x, y);
  189.    };
  190.  
  191.    Window_BattleEquipStatus.prototype.numVisibleRows = function() {
  192.       return 7;
  193.    };
  194.    
  195.    //=============================================================================
  196.    // Window_BattleEquipItem
  197.   //  * One-column Equip Item Window
  198.    //=============================================================================
  199.    function Window_BattleEquipItem() {
  200.       this.initialize.apply(this, arguments);
  201.    }
  202.  
  203.    Window_BattleEquipItem.prototype = Object.create(Window_EquipItem.prototype);
  204.    Window_BattleEquipItem.prototype.constructor = Window_BattleEquipItem;
  205.  
  206.    Window_BattleEquipItem.prototype.initialize  = function(x, y, width, height) {
  207.       Window_EquipItem.prototype.initialize.call(this, x, y, width, height);
  208.    };
  209.  
  210.    Window_BattleEquipItem.prototype.maxCols = function() {
  211.       return 1;
  212.    };
  213.  
  214.    //=============================================================================
  215.    // Window_BattleEquipSlot
  216.    //  * Battle Equip Slot, with slot list based on the contents of Battle Change Equip Tag.
  217.    //=============================================================================
  218.    function Window_BattleEquipSlot() {
  219.       this.initialize.apply(this, arguments);
  220.    }
  221.  
  222.    Window_BattleEquipSlot.prototype = Object.create(Window_EquipSlot.prototype);
  223.    Window_BattleEquipSlot.prototype.constructor = Window_BattleEquipSlot;
  224.  
  225.    Window_BattleEquipSlot.prototype.initialize  = function(x, y, width, height) {
  226.       Window_EquipSlot.prototype.initialize.call(this, x, y, width, height);
  227.    };
  228.    
  229.    Unco.CEB.Window_BattleEquipSlot_lineHeight = Window_BattleEquipSlot.prototype.lineHeight;
  230.    Window_BattleEquipSlot.prototype.lineHeight = function() {
  231.       if (Unco.Param.equipConsumeTurn === 'none') return Unco.CEB.Window_BattleEquipSlot_lineHeight.call(this);
  232.       return Unco.CEB.Window_BattleEquipSlot_lineHeight.call(this)*2;
  233.    };
  234.  
  235.    Window_BattleEquipSlot.prototype.maxItems = function() {
  236.       return this._actor ? ($dataClasses[$dataActors[this._actor._actorId].classId].equipChangeSlots.length) : 0;
  237.    };
  238.  
  239.    Window_BattleEquipSlot.prototype.drawRightArrow = function(x, y) {
  240.       this.changeTextColor(this.systemColor());
  241.       this.drawText('\u2192', x, y, 32, 'center');
  242.    };
  243.    Window_BattleEquipSlot.prototype.update = function() {
  244.       Window_Selectable.prototype.update.call(this);
  245.       if (this._itemWindow) {
  246.          if ( this._actor) {
  247.             if (Imported.YEP_EquipCore === true) {
  248.                Yanfly.Equip.Window_EquipItem_setSlotId.call(this._itemWindow , $dataClasses[$dataActors[this._actor._actorId].classId].equipChangeSlots[this.index()]-1);
  249.             } else {
  250.                this._itemWindow.setSlotId( $dataClasses[$dataActors[this._actor._actorId].classId].equipChangeSlots[this.index()]-1 );
  251.             }
  252.          } else this._itemWindow.setSlotId( this.index() );
  253.       }
  254.    };
  255.  
  256.    Window_BattleEquipSlot.prototype.item = function() {
  257.       return this._actor ? this._actor.equips()[ $dataClasses[$dataActors[this._actor._actorId].classId].equipChangeSlots[this.index()]-1 ] : null;
  258.    };
  259.  
  260.    Window_BattleEquipSlot.prototype.drawItemName = function(item, x, y, width) {
  261.       width = width || 312;
  262.       var iconBoxWidth = this.lineHeight();
  263.       var iconYpadding = (iconBoxWidth - Window_Base._iconWidth) / 2;
  264.       var iconXpadding = (iconBoxWidth - Window_Base._iconWidth) / 2 - 8;
  265.       this.resetTextColor();
  266.       var icon = ( (item && item.iconIndex) ? item.iconIndex : Unco.Param.equipNoEquipIconId);
  267.       var name = ( (item && item.name) ? item.name : Unco.Param.equipNoEquipText);
  268.       this.drawIcon(icon, x + iconXpadding, y + iconYpadding);
  269.       this.drawText(name, x + iconXpadding + Window_Base._iconWidth + 4, y, width - iconBoxWidth);
  270.    };
  271.    
  272.    Window_BattleEquipSlot.prototype.drawUnchangedSlot = function(x, y, width) {
  273.       width = width || 312;
  274.       this.changePaintOpacity(false);
  275.       var iconBoxWidth = this.lineHeight();
  276.       var iconYpadding = (iconBoxWidth - Window_Base._iconWidth) / 2;
  277.       var iconXpadding = (iconBoxWidth - Window_Base._iconWidth) / 2 - 8;
  278.       this.resetTextColor();
  279.       this.drawIcon(Unco.Param.equipNoChangeIconId, x + iconXpadding, y + iconYpadding);
  280.       this.drawText(Unco.Param.equipNoChangeText, x + iconXpadding + Window_Base._iconWidth + 4, y, width - iconBoxWidth);
  281.    };
  282.  
  283.    Window_BattleEquipSlot.prototype.drawItem = function(index) {
  284.       if (this._actor) {
  285.          var realIndex = $dataClasses[$dataActors[this._actor._actorId].classId].equipChangeSlots[index]-1;
  286.          var rect = this.itemRectForText(index);
  287.          this.changeTextColor(this.systemColor());
  288.          this.changePaintOpacity(this.isEnabled(realIndex));
  289.          var yOffset = ( (Unco.Param.equipConsumeTurn === 'none') ? 0 : this.lineHeight()/4);
  290.          this.drawText(this.slotName(index), rect.x, rect.y - yOffset, 138, this.lineHeight());
  291.          var itemCurrent = this._actor.equips()[realIndex];
  292.          this.drawItemName(itemCurrent, rect.x + 138, rect.y - yOffset);
  293.          if (Unco.Param.equipConsumeTurn !== 'none') {
  294.             var itemChanged = this._actor.changedEquips()[realIndex];
  295.             this.drawRightArrow(rect.x + 118, rect.y + yOffset);
  296.             if (itemChanged !== itemCurrent) {
  297.                this.drawItemName(itemChanged, rect.x + 138, rect.y + yOffset);
  298.             } else {
  299.                this.drawUnchangedSlot(rect.x + 138, rect.y + yOffset, rect.width - 138);
  300.             }
  301.          }
  302.          this.changePaintOpacity(true);
  303.       }
  304.    };
  305.  
  306.    Window_BattleEquipSlot.prototype.slotName = function(index) {
  307.       var slots = this._actor.equipSlots();
  308.       return this._actor ? $dataSystem.equipTypes[slots[ $dataClasses[$dataActors[this._actor._actorId].classId].equipChangeSlots[index]-1 ]] : '';
  309.    };
  310.  
  311.    Window_BattleEquipSlot.prototype.show = function() {
  312.       Window_EquipSlot.prototype.show.call(this);
  313.       this.showHelpWindow();
  314.    };
  315.  
  316.    Window_BattleEquipSlot.prototype.hide = function() {
  317.       Window_EquipSlot.prototype.hide.call(this);
  318.       this.hideHelpWindow();
  319.    };
  320.  
  321.    
  322.    //=============================================================================
  323.    // Scene_Battle
  324.    //  * Adding the new windows to Scene_Battle, and managing turn skipping.
  325.    //=============================================================================
  326.    var _Scene_Battle_isAnyInputWindowActive = Scene_Battle.prototype.isAnyInputWindowActive;
  327.    Scene_Battle.prototype.isAnyInputWindowActive = function() {
  328.       if (_Scene_Battle_isAnyInputWindowActive.call(this)) {
  329.          return true;
  330.       }
  331.       return (this._equipSlotWindow.active || this._equipItemWindow.active);
  332.    };
  333.    
  334.    var _Scene_Battle_createAllWindows = Scene_Battle.prototype.createAllWindows;
  335.    Scene_Battle.prototype.createAllWindows = function() {
  336.       _Scene_Battle_createAllWindows.call(this);
  337.       this.createEquipStatusWindow();
  338.       this.createEquipSlotWindow();
  339.       this.createEquipItemWindow();
  340.    };
  341.  
  342.    Scene_Battle.prototype.createEquipStatusWindow = function() {
  343.       this._equipStatusWindow = new Window_BattleEquipStatus(0, this._helpWindow.height);
  344.       this._equipStatusWindow.hide();
  345.       this.addWindow(this._equipStatusWindow);
  346.    };
  347.  
  348.    Scene_Battle.prototype.createEquipSlotWindow = function() {
  349.       var wx = this._equipStatusWindow.width;
  350.       var wy = this._helpWindow.height;
  351.       var ww = Graphics.boxWidth - this._equipStatusWindow.width;
  352.       var wh = Window_Base.prototype.lineHeight()*3;
  353.       this._equipSlotWindow = new Window_BattleEquipSlot(wx, wy, ww, wh);
  354.       this._equipSlotWindow.setHelpWindow(this._helpWindow);
  355.       this._equipSlotWindow.setStatusWindow(this._equipStatusWindow);
  356.       this._equipSlotWindow.setHandler('ok', this.onEquipSlotOk.bind(this));
  357.       this._equipSlotWindow.setHandler('cancel', this.onEquipSlotCancel.bind(this));
  358.       this._equipSlotWindow.hide();
  359.       this.addWindow(this._equipSlotWindow);
  360.    };
  361.  
  362.    Scene_Battle.prototype.createEquipItemWindow = function() {
  363.       var wx = this._equipStatusWindow.width;
  364.       var wy = this._equipStatusWindow.y + Window_Base.prototype.lineHeight()*3;
  365.       var ww = Graphics.boxWidth - wx;
  366.       var wh = Graphics.boxHeight - wy - this._statusWindow.height;
  367.       this._equipItemWindow = new Window_BattleEquipItem(wx, wy, ww, wh);
  368.       this._equipItemWindow.setHelpWindow(this._helpWindow);
  369.       this._equipItemWindow.setStatusWindow(this._equipStatusWindow);
  370.       this._equipItemWindow.setHandler('ok',     this.onEquipItemOk.bind(this));
  371.       this._equipItemWindow.setHandler('cancel', this.onEquipItemCancel.bind(this));
  372.       this._equipSlotWindow.setItemWindow(this._equipItemWindow);
  373.       this._equipItemWindow.hide();
  374.       this.addWindow(this._equipItemWindow);
  375.    };
  376.  
  377.    var _Scene_Battle_createActorCommandWindow = Scene_Battle.prototype.createActorCommandWindow;
  378.    Scene_Battle.prototype.createActorCommandWindow = function() {
  379.       _Scene_Battle_createActorCommandWindow.call(this);
  380.       this._actorCommandWindow.setHandler('equip', this.commandEquip.bind(this));
  381.    };
  382.  
  383.    var _Window_ActorCommand_makeCommandList = Window_ActorCommand.prototype.makeCommandList;
  384.    Window_ActorCommand.prototype.makeCommandList = function() {
  385.       _Window_ActorCommand_makeCommandList.call(this);
  386.       if (this._actor && ($dataClasses[$dataActors[this._actor._actorId].classId].equipChangeSlots.length > 0) ) {
  387.          this._actor.setChangedEquips();
  388.          this.addEquipCommand();
  389.       }
  390.    };
  391.  
  392.    Window_ActorCommand.prototype.addEquipCommand = function() {
  393.       if (Imported.BOB_BattleCommandList === true) {
  394.          this.addCommand(Unco.Param.equipCommandName, 'equip', true, null, Unco.Param.equipIconId);
  395.        } else {
  396.          this.addCommand(Unco.Param.equipCommandName, 'equip');
  397.        }
  398.    };
  399.  
  400.    Scene_Battle.prototype.refreshActor = function() {
  401.       var actor = BattleManager.actor();
  402.       this._equipStatusWindow.setActor(actor);
  403.       this._equipSlotWindow.setActor(actor);
  404.       this._equipItemWindow.setActor(actor);
  405.    };
  406.  
  407.    Scene_Battle.prototype.commandEquip = function() {
  408.       this.refreshActor();
  409.       if (Imported.UNCO_AmmunitionSystem === true) {
  410.          this._ammoWindow.hide();
  411.       }
  412.       this._equipStatusWindow.show();
  413.       this._equipItemWindow.refresh();
  414.       this._equipItemWindow.show();
  415.       this._equipSlotWindow.refresh();
  416.       this._equipSlotWindow.show();
  417.       this._equipSlotWindow.activate();
  418.       this._equipSlotWindow.select(0);
  419.       if (this._equipsChanged) delete this._equipsChanged;
  420.    };
  421.  
  422.    Scene_Battle.prototype.onEquipSlotOk = function() {
  423.       this._equipItemWindow.activate();
  424.       this._equipItemWindow.select(0);
  425.    };
  426.  
  427.    Scene_Battle.prototype.onEquipSlotCancel = function() {
  428.       this._equipStatusWindow.hide();
  429.       this._equipItemWindow.hide();
  430.       this._equipSlotWindow.hide();
  431.       if (Unco.Param.equipConsumeTurn === 'half' && this._equipsChanged) {
  432.          var skill = $dataSkills[Unco.Param.equipSkillId];
  433.          var action = BattleManager.inputtingAction();
  434.          action.setSkill(skill.id);
  435.          BattleManager.actor().setLastBattleSkill(skill);
  436.          this.onSelectAction();
  437.       } else {
  438.          if (Imported.UNCO_AmmunitionSystem === true) {
  439.             this.showAmmoWindow();
  440.          }
  441.          this._actorCommandWindow.activate();
  442.          this._actorCommandWindow.select(0);
  443.       }
  444.    };
  445.  
  446.    Scene_Battle.prototype.onEquipItemOk = function() {
  447.       SoundManager.playEquip();
  448.       this._equipsChanged = true;
  449.       if (Unco.Param.equipConsumeTurn === 'none') {
  450.          BattleManager.actor().changeEquip(  $dataClasses[$dataActors[this._equipSlotWindow._actor._actorId].classId].equipChangeSlots[this._equipSlotWindow.index()]-1 , this._equipItemWindow.item());
  451.       } else {
  452.          BattleManager.actor().setBattleChangedEquip(  $dataClasses[$dataActors[this._equipSlotWindow._actor._actorId].classId].equipChangeSlots[this._equipSlotWindow.index()]-1 , this._equipItemWindow.item());
  453.       }
  454.       if (Unco.Param.equipConsumeTurn === 'full') {
  455.          this._equipItemWindow.deselect();
  456.          this._equipStatusWindow.hide();
  457.          this._equipItemWindow.hide();
  458.          this._equipSlotWindow.hide();
  459.          var skill = $dataSkills[Unco.Param.equipSkillId];
  460.          var action = BattleManager.inputtingAction();
  461.          action.setSkill(skill.id);
  462.          BattleManager.actor().setLastBattleSkill(skill);
  463.          this.onSelectAction();
  464.       } else {
  465.          this._equipSlotWindow.activate();
  466.          this._equipSlotWindow.refresh();
  467.          this._equipItemWindow.deselect();
  468.          this._equipItemWindow.refresh();
  469.          this._equipStatusWindow.refresh();
  470.       }
  471.    };
  472.  
  473.    Scene_Battle.prototype.onEquipItemCancel = function() {
  474.       this._equipSlotWindow.activate();
  475.       this._equipItemWindow.deselect();
  476.    };
  477.  
  478.    //=============================================================================
  479.    // Game_Actor
  480.    //  * Saving equip choices for delayed equip change.
  481.    //=============================================================================
  482.  
  483.    Game_Actor.prototype.setChangedEquips = function() {
  484.       var maxSlots = this.equipSlots().length;
  485.       var equips = this.equips();
  486.       if (typeof this._changedEquips === 'undefined') {
  487.          this._changedEquips = [];
  488.          for (var i = 0; i < maxSlots; i++) {
  489.             this._changedEquips[i] = new Game_Item();
  490.          }
  491.       }
  492.       for (var i = 0; i < maxSlots; i++) {
  493.          this._changedEquips[i].setObject(equips[i]);
  494.       }
  495.    };
  496.  
  497.    Game_Actor.prototype.changedEquips = function() {
  498.       return this._changedEquips.map(function(item) {
  499.          return item.object();
  500.       });
  501.    };
  502.  
  503.    Game_Actor.prototype.setBattleChangedEquip = function(slotId, item) {
  504.       this._changedEquips[slotId].setObject(item);
  505.    };
  506.  
  507.    //=============================================================================
  508.    // Game_Action
  509.    //  * Application of equipment changes during actual skill use.
  510.    //=============================================================================
  511.    
  512.    Unco.CEB.Game_Action_apply = Game_Action.prototype.apply;
  513.    Game_Action.prototype.apply = function(target) {
  514.       Unco.CEB.Game_Action_apply.call(this,target);
  515.       if (this.isSkill() && (this._item._itemId === Unco.Param.equipSkillId)) {
  516.          var actor = this.subject();
  517.          var maxSlots = actor.equipSlots().length;
  518.          var currentEquips = actor.equips();
  519.          var changedEquips = actor.changedEquips();          
  520.          for (var i = 0; i < maxSlots; i++) {
  521.             if (currentEquips[i] !== changedEquips[i]) {
  522.                actor.changeEquip( i , changedEquips[i] );
  523.                if (changedEquips[i] === actor.equips()[i]) {
  524.                   target.result().success = true;
  525.                }
  526.             }
  527.          }
  528.       }
  529.    };
  530.    
  531.    
  532. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement