Advertisement
Unconnected42

RMMV Plug-in _ Unco_ChangeEquipOnBattle_v1_0_1_UpToDate

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