Maliki79

MalDualWieldVZ

Mar 19th, 2023 (edited)
860
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Maliki's Dual Weilding/Two-Handed Weapons Combined MV/MZ Version
  3. // MalDualWieldVZ.js
  4. // version 1.7 MVMZ
  5. //=============================================================================
  6. /*:
  7.  * @target MZ
  8.  *  
  9.  * @plugindesc ver1.7 VZ - Allows you to set weapons as twohanded, disallowing you from equipping weapons to the Off-hand.  
  10.  * @author Maliki79
  11.  *
  12.  * @param MustUseMain
  13.  * @desc Type 1 to force equips to be placed in Main hand before they can be placed in Off hand.
  14.  * Default: 0
  15.  * @default 0
  16.  *
  17.  * @param OffhandAdjust
  18.  * @desc Percentage of stats offhand weapons add to actors. (Make the number lower than 100 to lower stats and higher to raise)
  19.  * Default: 100
  20.  * @default 100
  21.  *
  22.  * @param OffhandSlotName
  23.  * @desc Name used for offhand weapon slot.
  24.  * Default: Off-Hand
  25.  * @default Off-Hand
  26.  *
  27.  * @param ShowTraitsInConsole
  28.  * @desc Type 1 to show trait code,dataId and value data on console upon item equip.
  29.  * Default: 0
  30.  * @default 0
  31.  *
  32.  * @param PowerAdjustement0
  33.  * @desc Amount of "weight" given to HP when determining strength of weapons as a percent.
  34.  * Default: 100
  35.  * @default 100
  36.  *
  37.  * @param PowerAdjustement1
  38.  * @desc Amount of "weight" given to MP when determining strength of weapons as a percent.
  39.  * Default: 100
  40.  * @default 100
  41.  *
  42.  * @param PowerAdjustement2
  43.  * @desc Amount of "weight" given to ATK when determining strength of weapons as a percent.
  44.  * Default: 100
  45.  * @default 100
  46.  *
  47.  * @param PowerAdjustement3
  48.  * @desc Amount of "weight" given to DEF when determining strength of weapons as a percent.
  49.  * Default: 100
  50.  * @default 100
  51.  *
  52.  * @param PowerAdjustement4
  53.  * @desc Amount of "weight" given to M.ATK when determining strength of weapons as a percent.
  54.  * Default: 100
  55.  * @default 100
  56.  *
  57.  * @param PowerAdjustement5
  58.  * @desc Amount of "weight" given to M.DEF when determining strength of weapons as a percent.
  59.  * Default: 100
  60.  * @default 100
  61.  *
  62.  * @param PowerAdjustement6
  63.  * @desc Amount of "weight" given to AGI when determining strength of weapons as a percent.
  64.  * Default: 100
  65.  * @default 100
  66.  *
  67.  * @param PowerAdjustement7
  68.  * @desc Amount of "weight" given to LUK when determining strength of weapons as a percent.
  69.  * Default: 100
  70.  * @default 100
  71.  *
  72.  * @param PotentialPointsInShop
  73.  * @desc Shows Equipment "Potential" as a point total in shops.  Make this value 1 to enable, otherwise, the default calculations will be used.
  74.  * Default: 1
  75.  * @default 1
  76.  *
  77.  * @param 2H_DisableOtherSlot
  78.  * @desc If 1, equipping a 2Handed Weapon will completely disable the other equip slot.
  79.  * default: 0
  80.  * @default 0
  81.  *
  82.  * @param Matched_Equip_Omit_Traits
  83.  * @desc If 1, double equip traits will be the only plugin provided traits exhibited.  Main and Sub traits will be omitted.
  84.  * default: 0
  85.  * @default 0
  86.  *
  87.  * @help You need two steps to use this plugin:
  88.  * 1: Set your actor(s) up to have Dual-Wield in the Database. TRAITS => EQUIP => SLOT TYPE => DUAL WIELD.
  89.  *    ALL ACTORS MUST HAVE THIS TRAIT ACTIVE FOR THIS PLUGIN TO WORK CORRECTLY.
  90.  * 2: Add the Notetag <twohand> to any two handed weapons in your Database.  When equipped, these weapons will unequip any equipment in the other slot.  Attempting to add an equip will
  91.  *    unequip the twohanded equip.  (This can be circumvented with the <monkeygrip> tag explained below.)
  92.  * 3: (Optional) For Off-hand only weapons, like shields, make them weapons in your database and add the tag <shld> or <offHWeapon> to their notes.
  93.  *    These weapons can only be equipped to the off-hand.  Note that weapons tagged with <shld> will show up in your armor equipment category in the menu.
  94.  * 3a: Conversly, if you tag a weapon with <mainWeaponOnly> , it will only be equippable on the main hand.
  95.  * 4: (Optional) For one handed Actors you wish to equip shields that are considered weapons in the DB, tag <handnshld>
  96.  *    to the Actor's Class notes. (Those Actors still need to have the Dual Wield trait.)
  97.  * 4a:To enable Dual Wielding on a class that has the handnshld tag, add the tag <dualW> to equip or state notes and add them to the actor.
  98.  * 5: (Optional) An Actor's Class, Equips or State notes can be tagged with <monkeygrip> to allow two handed weapons to be dual wielded or allow a 2H weapon and shield.
  99.  * 6: (Optional) You can tag any weapons with <OffhandAdjust: x> with x being a number. This will allow the specific weapon to use the given value instead of the default.
  100.  * 6a: You can also tag states and actors with the same tag.  Only one tag will be active. Priority will be given in this order:
  101.  *    Actors => States (lower numbered states first and only one) => Equip => Plugin Param
  102.  * 7: (Optional) You can tag a weapon with <subweapon> so that it's basic attack animation will not be shown in battles when in the off hand.
  103.  * 8: (Optional) You can tag a weapon with <mainweaponTrait: x, y, z>>> or <subweaponTrait: x, y, z>>> with x being the trait code, y being the dataId, and z being the value.
  104.  *    Weapons with the Mainweapon tag will exhibit those traits ONLY while in the main weapon slot while supweapon tagged weapons will exhibit
  105.  *    thier traits while in the off hand only. (NOTE the 3 >>> )
  106.  * 9: (Optional) You can tag a weapon with <doubleGripTrait: x, y, z>>> with x being the trait code, y being the dataId, and z being the value.
  107.  *    When one tagged weapon is equipped and while the actor has the <doubleGrip> tag on either class notes or an applied state's notes,
  108.  *    the double grip traits will be applied to the actor.
  109.  * 10:(Optional) You can tag Weapons or Armor with <PotentialP:Number> with Number being a whole number to assign a starting value to the Potential Point
  110.  *    calculations.  Usful if things other than raw stats are used and will factor into the potential score of equipment in your project.
  111.  * 11: (Optional) You can tag Weapons with <mdwEquipMismatch> to make it so the same weapon type cannot be equipped to both hands.
  112.  *
  113.  * Notes on main/sub/double-grip weapon traits:
  114.  * Codes are the number representation of traits as they appear in the database.
  115.  *  Trait codes are listed below:
  116.  *  11-TRAIT_ELEMENT_RATE      41-TRAIT_STYPE_ADD       61-TRAIT_ACTION_PLUS
  117.  *  12-TRAIT_DEBUFF_RATE       42-TRAIT_STYPE_SEAL      62-TRAIT_SPECIAL_FLAG
  118.  *  13-TRAIT_STATE_RATE        43-TRAIT_SKILL_ADD       63-TRAIT_COLLAPSE_TYPE
  119.  *  14-TRAIT_STATE_RESIST      44-TRAIT_SKILL_SEAL      64-TRAIT_PARTY_ABILITY
  120.  *  21-TRAIT_PARAM             51-TRAIT_EQUIP_WTYPE
  121.  *  22-TRAIT_XPARAM            52-TRAIT_EQUIP_ATYPE
  122.  *  23-TRAIT_SPARAM            53-TRAIT_EQUIP_LOCK
  123.  *  31-TRAIT_ATTACK_ELEMENT    54-TRAIT_EQUIP_SEAL
  124.  *  32-TRAIT_ATTACK_STATE      55-TRAIT_SLOT_TYPE
  125.  *  33-TRAIT_ATTACK_SPEED
  126.  *  34-TRAIT_ATTACK_TIMES
  127.  *
  128.  * DataId is the code's parameter.  For example, if you wanted to add a boost to Atk power, you would use code: 21 and the dataId would be 2.
  129.  * The numbers here can vary based on the quantity of things in your database and what code is being used.
  130.  *
  131.  * The value is the amount of the effect the code will express as a float.  So, revisiting the above example, if you wanted attack to be raised by 20%,
  132.  * you would use the value 1.2, which is 120%.
  133.  * The final tag for this example would be:  <subweaponTrait: 21, 2, 1.2>>>
  134.  *
  135.  * A method to assist with finding the code, dataId and value figures lies in the ShowTraitsInConsole param.  Setting it to 1
  136.  * will allow the console to print out an array of normal traits on an equipped item on the moment it is equipped.
  137.  * (Press F12 to open the console by default.)
  138.  * The array will list the traits in the order that they were added in the database.  So if you need to know the values, just make a dummy/temp
  139.  * equip with the traits you want and note what their values are via the console.
  140.  * (Note that notetag related bonuses/traits/etc not provided by this plugin cannot be used here; Those traits will be active as stipulated in thier respective plugins.)
  141.  *
  142.  * A "potential" value has been introduced.
  143.  * This value is a combination of the default stats of a weapon with differing user defined "weights" for each one.
  144.  * This value is used mainly for the choosing of weapons when optimizing.  
  145.  *
  146.  * A script call has been added to aid those wishing to know which equip slot is housing what equip type.
  147.  * Using the script call $gameActors.isWeaponEquipped(type) will return a number based on the defined type
  148.  * (type is the weapon type ID in the database.)
  149.  * 0 if in the first equip slot,
  150.  * 1 if it's in the second,
  151.  * 2 if it's in both,
  152.  * and -1 if in neither.
  153.  * You can omit the type arguement and the function will return those numbers if there is ANY weapon is equipped in those slots.
  154.  *
  155.  * Equip Groups have been added!
  156.  * Tag weapon equips and shield type armor equips with this tag in thier notes:
  157.  *
  158.  * <mdwEquipGroup: x> with x being an integer higher than 0.
  159.  * If an equip has this tag, it will only be able to be dual wielded with other equips with the same group number.
  160.  * <groupEquipTrait: x, y, z>>> Use this tag paired with setting an equip group.  If two weapon equips with matching equip group sets
  161.  * number are equipped together, the traits created will be exhibited.
  162.  * Remember that a matching mdwEquipGroup tag MUST exist on the items for the trait to be seen.
  163.  * <syncTrait: x, y, z>>> If two weapon equips are the same in the database, the traits created will be exhibited.    
  164.  * Using the plugin Param Matched_Equip_Omit_Traits, the only traits shown will be the double equip or sync traits.
  165.  * Main or Sub weapon traits will not be used when those traits are active.  (Other traits provided by different plugins and the database WILL
  166.  * still be active.)
  167.  *
  168.  * Added Dual Groups.  You can specify any number of groups to give specific sets of weapon equips traits.
  169.  * First, add the equip to groups by adding this notetag:
  170.  *
  171.  * <duGroup: x>
  172.  *
  173.  * With x being any interger above 0.
  174.  * You can add as many copies of this tag as you need to give a single equip multiple group numbers.
  175.  * Then use the following notetag to assign traits to each group:
  176.  *
  177.  * <dualGroupTrait: a, x, y, z>>>
  178.  *
  179.  * Noting the extra a interger which will match one of your group numbers.
  180.  * You can make a = 0 to make that trait activate whenever a group is formed.
  181.  *
  182.  * Now, if you equip two weapons with the same group number, those group triats will be added to the PC
  183.  * (Again, the 0 group traits will also be added)
  184.  * If you equip two of the same item, those traits will only be counted once.
  185.  *
  186.  * Note about param ShieldsArmor
  187.  * The ShieldsArmor param allows devs to make it so offhand only weapons show up as armor in default item Menu.
  188.  * For those that wish for some offhand weapons to remain in the Weapon category while still using the param,
  189.  * use the notetag <offHWeapon> to create an exception and have that weapon show up in the weapon category.
  190.  *
  191.  * Conditional evals have been added to all trait notes!
  192.  * You can add any javascript code that evals to true or false to allow for traits to be changed mid-game.
  193.  * Just use the syntax noted above but adding the code between the Z and the >>>.
  194.  * For example:
  195.  *
  196.  * <mainweaponTrait: 21, 2, 50, $gameParty.gold() > 500>>>
  197.  *
  198.  * This trait will only take effect while the party has more than 500 gold!
  199.  * s[x] and v[x] can be used for switches and variables respectively.
  200.  * Example   <doubleGripTrait: x, y, z, actor.level > v[1]>>>
  201.  * Example 2 <dualGroupTrait: a, x, y, z, $gameParty.numItems($dataItems[1] == 1)>>>
  202.  *
  203.  * Added Standard traits.
  204.  *
  205.  * <standardTrait: x, y, z, code>>>
  206.  *
  207.  * Will add the noted trait to weapons or armors.
  208.  * (This one is basically just to add conditionals to standard traits.)
  209.  *
  210.  * The follow tags can be used on non-weapon equips:
  211.  * syncTraits (If the currently equipped weapons are the same in the database, these traits will be used)
  212.  * groupEquTraits (If the 2 currently equipped weapons AND the non-weapon equip share the same mdwEquipGroup number,
  213.  * these traits will be used.)
  214.  * doubleGripTraits (Same conditions as weapon traits.)
  215.  * standardTraits (No outside conditions required)
  216.  */
  217.  
  218. var Mal = Mal || {};
  219.  
  220. Mal.Parameters = PluginManager.parameters('MalDualWieldVZ');
  221. Mal.Param = Mal.Param || {};
  222.  
  223. Mal.power = [];
  224.  Mal.power.push(Number(Mal.Parameters['PowerAdjustement0']));
  225.  Mal.power.push(Number(Mal.Parameters['PowerAdjustement1']));
  226.  Mal.power.push(Number(Mal.Parameters['PowerAdjustement2']));
  227.  Mal.power.push(Number(Mal.Parameters['PowerAdjustement3']));
  228.  Mal.power.push(Number(Mal.Parameters['PowerAdjustement4']));
  229.  Mal.power.push(Number(Mal.Parameters['PowerAdjustement5']));
  230.  Mal.power.push(Number(Mal.Parameters['PowerAdjustement6']));
  231.  Mal.power.push(Number(Mal.Parameters['PowerAdjustement7']));
  232.  
  233.  Mal.Par2HLock = Number((Mal.Parameters['2H_DisableOtherSlot']))
  234.  
  235.  var MalDualDatabaseLoad = DataManager.isDatabaseLoaded;
  236. DataManager.isDatabaseLoaded = function() {
  237.   if (!MalDualDatabaseLoad.call(this)) return false;
  238.   if (!DataManager._malDual_DatabaseLoaded) {
  239.     this.processDualNotetags($dataWeapons);
  240.     this.processDualNotetags($dataArmors);
  241.     DataManager._malDual_DatabaseLoaded = true;
  242.   }
  243.   return true;
  244. };
  245.  
  246. DataManager.processDualNotetags = function(group) {
  247.     for (var n = 1; n < group.length; n++) {
  248.         var obj = group[n];
  249.         obj.mdwEquipGroup = [-1];
  250.         obj.syncNum = obj.id;
  251.         obj.dualGroup = [];
  252.         obj.dualGroupTraits = [];
  253.         this.createDualTraits(obj);
  254.     }
  255. };
  256.  
  257. DataManager.createDualTraits = function(obj) {
  258. var traits = [];
  259. var noteread = obj.note;
  260. while(noteread.indexOf("mainweaponTrait") > -1)
  261. {
  262.     var notereg = noteread.split("<mainweaponTrait: ");
  263.     var match = notereg[1].split(">>>");
  264.     match = match[0].split(", ");
  265.     if (!!match[3]) {
  266.         var code = (match[3].split(">>>"))[0];
  267.     } else {
  268.         var code = "true";
  269.     }
  270.     traits.push({"code": parseInt(match[0]), "dataId": parseInt(match[1]), "value": Number(match[2]), "dwEval": code});
  271.     noteread = noteread.replace("<mainweaponTrait: ", " ");
  272. }
  273. obj.mainWTraits = traits;
  274.  
  275. traits = [];
  276. while(noteread.indexOf("standardTrait") > -1)
  277. {
  278.     var notereg = noteread.split("<standardTrait: ");
  279.     var match = notereg[1].split(">>>");
  280.     match = match[0].split(", ");
  281.     if (!!match[3]) {
  282.         var code = (match[3].split(">>>"))[0];
  283.     } else {
  284.         var code = "true";
  285.     }
  286.     traits.push({"code": parseInt(match[0]), "dataId": parseInt(match[1]), "value": Number(match[2]), "dwEval": code});
  287.     noteread = noteread.replace("<standardTrait: ", " ");
  288. }
  289. obj.standardTraits = traits;
  290.  
  291. traits = [];
  292. while(noteread.indexOf("subweaponTrait") > -1)
  293. {
  294.     var notereg = noteread.split("<subweaponTrait: ");
  295.     var match = notereg[1].split(">>>");
  296.     match = match[0].split(", ");
  297.     if (!!match[3]) {
  298.         var code = (match[3].split(">>>"))[0];
  299.     } else {
  300.         var code = "true";
  301.     }
  302.     traits.push({"code": parseInt(match[0]), "dataId": parseInt(match[1]), "value": Number(match[2]), "dwEval": code});
  303.     noteread = noteread.replace("<subweaponTrait: ", " ");
  304. }
  305. obj.subWTraits = traits;
  306.  
  307. traits = [];
  308. while(noteread.indexOf("doubleGripTrait") > -1)
  309. {
  310.     var notereg = noteread.split("<doubleGripTrait: ");
  311.     var match = notereg[1].split(">>>");
  312.     match = match[0].split(", ");
  313.     if (!!match[3]) {
  314.         var code = (match[3].split(">>>"))[0];
  315.     } else {
  316.         var code = "true";
  317.     }
  318.     traits.push({"code": parseInt(match[0]), "dataId": parseInt(match[1]), "value": Number(match[2]), "dwEval": code});
  319.     noteread = noteread.replace("<doubleGripTrait: ", " ");
  320. }
  321. obj.doubleGripTraits = traits;
  322.  
  323. traits = [];
  324. while(noteread.indexOf("groupEquipTrait") > -1)
  325. {
  326.     var notereg = noteread.split("<groupEquipTrait: ");
  327.     var match = notereg[1].split(">>>");
  328.     match = match[0].split(", ");
  329.     if (!!match[3]) {
  330.         var code = (match[3].split(">>>"))[0];
  331.     } else {
  332.         var code = "true";
  333.     }
  334.     traits.push({"code": parseInt(match[0]), "dataId": parseInt(match[1]), "value": Number(match[2]), "dwEval": code});
  335.     noteread = noteread.replace("<groupEquipTrait: ", " ");
  336. }
  337. obj.groupEquTraits = traits;
  338.  
  339. traits = [];
  340. while(noteread.indexOf("syncTrait") > -1)
  341. {
  342.     var notereg = noteread.split("<syncTrait: ");
  343.     var match = notereg[1].split(">>>");
  344.     match = match[0].split(", ");
  345.     if (!!match[3]) {
  346.         var code = (match[3].split(">>>"))[0];
  347.     } else {
  348.         var code = "true";
  349.     }
  350.     traits.push({"code": parseInt(match[0]), "dataId": parseInt(match[1]), "value": Number(match[2]), "dwEval": code});
  351.     noteread = noteread.replace("<syncTrait: ", " ");
  352. }
  353. obj.syncTraits = traits;
  354.  
  355. traits = [];
  356. while(noteread.indexOf("dualGroupTrait") > -1)
  357. {
  358.     var notereg = noteread.split("<dualGroupTrait: ");
  359.     var match = notereg[1].split(">>>");
  360.     match = match[0].split(", ");
  361.     var DSGroup = parseInt(match[0]);
  362.     if (!!match[4]) {
  363.         var code = (match[4].split(">>>"))[0];
  364.     } else {
  365.         var code = "true";
  366.     }
  367.     obj.dualGroupTraits[DSGroup] = obj.dualGroupTraits[DSGroup] || [];
  368.     obj.dualGroupTraits[DSGroup].push({"code": parseInt(match[1]), "dataId": parseInt(match[2]), "value": Number(match[3]), "dwEval": code});
  369.     noteread = noteread.replace("<dualGroupTrait: ", " ");
  370. }
  371.  
  372. traits = [];
  373.  
  374. while(noteread.indexOf("duGroup") > -1)
  375. {
  376.     var match = noteread.split("<duGroup: ");
  377.     var match2 = match[1].split(">");
  378.     obj.dualGroup = obj.dualGroup || []
  379.     obj.dualGroup.push(parseInt(match2[0]));
  380.     noteread = noteread.replace("<duGroup: ", " ");
  381. }
  382.        
  383. obj.PotentialP = 0;
  384. while(noteread.indexOf("<PotentialP:") > -1)
  385. {
  386.     var notereg = noteread.split("<PotentialP: ");
  387.     var match = notereg[1].split("> ");
  388.     obj.PotentialP = parseInt(match[0]);
  389.     noteread = noteread.replace("<PotentialP:", " ");
  390. };
  391. if(noteread.indexOf("mdwEquipGroup") > -1) {
  392.     obj.mdwEquipGroup = [];
  393.     while(noteread.indexOf("<mdwEquipGroup:") > -1)
  394.     {
  395.         var notereg = noteread.split("<mdwEquipGroup: ");
  396.         var match = notereg[1].split("> ");
  397.         obj.mdwEquipGroup.push(parseInt(match[0]));
  398.         noteread = noteread.replace("<mdwEquipGroup:", " ");
  399.     };
  400.     //obj.mdwEquipGroup = Number(obj.meta.mdwEquipGroup);
  401.     //console.log(obj.mdwEquipGroup);
  402. };
  403. };
  404.  
  405. var MalEquipChangeOK = Game_Actor.prototype.isEquipChangeOk
  406. Game_Actor.prototype.isEquipChangeOk = function(slotId) {
  407.  
  408.     if (this.twohanding > -1 && Mal.Par2HLock == 1) {
  409.         if (this.twohanding == 0 && slotId == 1) return false;
  410.         if (this.twohanding == 1 && slotId == 0) return false;
  411.     }
  412.     return MalEquipChangeOK.call(this, slotId);
  413. };
  414.  
  415. var MalOnSlotOK = Scene_Equip.prototype.onItemOk
  416. Scene_Equip.prototype.onItemOk = function() {
  417.     if (this._slotWindow.index() === 0 && !(this._itemWindow.item()) && (this._actor.equips()[1] && Mal.Parameters['MustUseMain'] == 1)) {
  418.     SoundManager.playBuzzer();
  419.     }else {
  420.     SoundManager.playEquip();
  421.     this.actor().changeEquip(this._slotWindow.index(), this._itemWindow.item());
  422.     if (this._itemWindow.item() && Mal.Parameters['ShowTraitsInConsole'] == 1) console.log(this._itemWindow.item().traits);
  423.     }
  424.     this._slotWindow.activate();
  425.     this._slotWindow.refresh();
  426.     this._itemWindow.deselect();
  427.     this._itemWindow.refresh();
  428.     if(Utils.RPGMAKER_NAME === "MV"){
  429.         if (typeof Yanfly !== "undefined" && Yanfly.Equip) this._itemWindow.hide(); //Added this for compatibility with YF's Equip Core
  430.         this._statusWindow.refresh();
  431.     }else{
  432.         this._statusWindow.refresh();
  433.         this._slotWindow.show();
  434.         this._itemWindow.hide();
  435.         this._slotWindow.select(this._slotWindow.index());
  436.     }
  437.  
  438.  
  439. };
  440.  
  441. Game_Actor.prototype.changeEquip = function(slotId, item) {
  442.     if (this.tradeItemWithParty(item, this.equips()[slotId]) &&
  443.             (!item || this.equipSlots()[slotId] === item.etypeId)) {
  444.         this._equips[slotId].setObject(item);
  445.         if (slotId == 0) {
  446.         var slot = 1;
  447.         } else {
  448.         var slot = 0;
  449.         }
  450.         if (slotId < 2) {
  451.         if (item && item.meta.twohand && !this.hasMonkeyGrip()) {
  452.         this.tradeItemWithParty(null, this.equips()[slot])
  453.         this._equips[slot].setObject(null);
  454.         }
  455.         if (item && this.equips()[slot] && this.equips()[slot].meta.twohand && !this.hasMonkeyGrip()){
  456.         this.tradeItemWithParty(null, this.equips()[slot])
  457.         this._equips[slot].setObject(null);
  458.         }
  459. /*      if (Mal.Parameters['MustUseMain'] == 1 && !this.equips()[0] && this.equips()[1]){
  460.         if(!this.equips()[1].meta.shld) {
  461.             this._equips[0].setObject(this.equips()[1]);
  462.             this._equips[1].setObject(null);
  463.         }
  464.         }
  465. */
  466.         }
  467.     this.check2Hand();
  468.         this.refresh();
  469.     }
  470. };
  471.  
  472. Game_Actor.prototype.check2Hand = function() {
  473.     this.twohanding = -1;
  474.     var equip = this.equips()[0];
  475.     if (equip && equip.meta.twohand && !this.hasMonkeyGrip()) this.twohanding = 0;
  476.     var equip2 = this.equips()[1];
  477.     if (equip2 && equip2.meta.twohand && !this.hasMonkeyGrip()) this.twohanding = 1;
  478. };
  479.  
  480. Game_Actor.prototype.checkMHand = function() {
  481.     if (this.hasMonkeyGrip()) return;
  482.     var equip = this.equips()[0];
  483.     var equip2 = this.equips()[1];
  484.     //console.log(equip2);
  485.     //console.log(this._equips[1].isWeapon());
  486.     if (equip  && equip.meta.twohand  && (this._equips[1].isWeapon() || this._equips[1].isArmor())) this._equips[1].setObject(null);
  487.     if (equip2 && equip2.meta.twohand && (this._equips[0].isWeapon() || this._equips[0].isArmor())) this._equips[0].setObject(null);
  488. };
  489.  
  490. Game_Actor.prototype.forceChangeEquip = function(slotId, item) {
  491.     if (item) {
  492.         this._equips[slotId].setObject(item);
  493.         if (slotId == 0) {
  494.             var slot = 1;
  495.         } else {
  496.             var slot = 0;
  497.         }
  498.         if (slotId < 2) {
  499.             if (item && item.meta.twohand && !this.hasMonkeyGrip()) {
  500.                 this._equips[slot].setObject(null);
  501.             }
  502.             if (item && this.equips()[slot] && this.equips()[slot].meta.twohand && !this.hasMonkeyGrip()){
  503.                 this._equips[slot].setObject(null);
  504.             }
  505.             if (Mal.Parameters['MustUseMain'] == 1 && !this.equips()[0] && this.equips()[1]){
  506.                 //this._equips[0].setObject(this.equips()[1]);
  507.                 //this._equips[1].setObject(null);
  508.                 this.tradeItemWithParty(null, this.equips()[1]);
  509.             }
  510.         }
  511.     } else {
  512.         this._equips[slotId].setObject(null);
  513.     }
  514.     this.releaseUnequippableItems(true);
  515.     this.check2Hand();
  516.     this.refresh();
  517. };
  518.  
  519. var MalreleaseUnEI = Game_Actor.prototype.releaseUnequippableItems;
  520. Game_Actor.prototype.releaseUnequippableItems = function(forcing) {
  521. MalreleaseUnEI.call(this, forcing);
  522. this.check2Hand();
  523. this.checkMHand();
  524. };
  525.  
  526. var MalEquip = Window_EquipItem.prototype.includes
  527. Window_EquipItem.prototype.includes = function(item) {
  528.     if (item === null) {
  529.         if (this._slotId === 0 && (this._actor.equips()[1] && Mal.Parameters['MustUseMain'] == 1)){
  530.         return;
  531.         } else {
  532.         return true;
  533.     }}
  534.     if (this._slotId === 0 && (item.meta.shld || item.meta.offHWeapon) && this._actor.hasMonkeyGrip()) {
  535.     return this._actor.canEquip(item);
  536.     }
  537.     if (this._slotId === 0 && (item.meta.shld || item.meta.offHWeapon)) {
  538.     return false;
  539.     }
  540.     if (this._slotId === 1 && !(item.meta.shld || item.meta.offHWeapon) && this._actor.currentClass().meta.handnshld && !(this._actor.enableDW())) {
  541.     return false;
  542.     }
  543.     if (this._slotId === 1 && !(this._actor.equips()[0]) && Mal.Parameters['MustUseMain'] == 1 ) {
  544.     return false;
  545.     }
  546.     if (this._slotId === 1 && item.meta.mainWeaponOnly) {
  547.     return false;
  548.     }
  549.     //Need to fix to allow equipping of non weapon equips when dual weilding.  (Slot eats equips when placed!)
  550.     //if (this._slotId === 1) return this._actor.canEquipOH(item);
  551.     if (this._slotId < 0 || item.etypeId !== this._actor.equipSlots()[this._slotId]) {
  552.         return false;
  553.     }
  554.     if (this._slotId === 0 && this._actor.equips()[1] && !(item.mdwEquipGroup.some(element => this._actor.equips()[1].mdwEquipGroup.includes(element)))) return false;
  555.     if (this._slotId === 1 && this._actor.equips()[0] && !(item.mdwEquipGroup.some(element => this._actor.equips()[0].mdwEquipGroup.includes(element)))) return false;
  556.     if (this._slotId === 0 && this._actor.equips()[1] && (item.meta.mdwEquipMismatch || this._actor.equips()[1].meta.mdwEquipMismatch) && (item.wtypeId == this._actor.equips()[1].wtypeId)) return false;
  557.     if (this._slotId === 1 && this._actor.equips()[0] && (item.meta.mdwEquipMismatch || this._actor.equips()[0].meta.mdwEquipMismatch) && (item.wtypeId == this._actor.equips()[0].wtypeId)) return false;
  558.     return this._actor.canEquip(item);
  559. };
  560.  
  561. Game_BattlerBase.prototype.canEquipOH = function(item) {
  562.     console.log("Enter OFFHAND SETTING TEST");
  563.     console.log(item);
  564.     var setting = -1;
  565.     if (!item) {
  566.         return false;
  567.     }
  568.     if (DataManager.isWeapon(item)) if (this.canEquipWeapon(item)) setting = 1;
  569.     console.log(DataManager.isArmor(item));
  570.     if (DataManager.isArmor(item))  if (this.canEquipArmor(item))  setting = 2;
  571.     console.log(setting);
  572.     if (setting != -1) return true;
  573.     return false;
  574. };
  575.  
  576. Game_Actor.prototype.optimizeEquipments = function() {
  577.     var maxSlots = this.equipSlots().length;
  578.     this.clearEquipments();
  579.     this.setWeapons();
  580.     for (var i = 2; i < maxSlots; i++) {
  581.         if (this.isEquipChangeOk(i)) {
  582.             this.changeEquip(i, this.bestEquipItem(i));
  583.         }
  584.     }
  585. };
  586.  
  587. Game_Actor.prototype.setWeapons = function() {
  588.     var mode = 1;
  589.     if (this.currentClass().meta.handnshld) mode = 2;
  590.     if (this.hasMonkeyGrip()) mode = 3;
  591.     //First weapon selection
  592.     if (mode == 1 || mode == 2) {
  593.         var items = $gameParty.equipItems().filter(function(item) {
  594.         return item.etypeId === 1 && this.canEquip(item) && !this.equipIsOffhand(item);
  595.     }, this);
  596.     }
  597.     if (mode == 3) {
  598.         var items = $gameParty.equipItems().filter(function(item) {
  599.         return item.etypeId === 1 && this.canEquip(item);
  600.     }, this);
  601.     }
  602.     var mainW1 = this.bestEquipW(items);
  603.     //End first weapon
  604.     //Second Weapon Selection (First sub)
  605.     if (mode == 1) {
  606.         var newItems = $gameParty.equipItems().filter(function(item) {
  607.         return item.etypeId === 1 && this.canEquip(item) && !(item == mainW1 && $gameParty.oneOfAKind(mainW1)) && !(item.wtypeId == mainW1.wtypeId && $gameParty.misMatched(mainW1, item)) && !item.meta.twohand && !item.meta.mainWeaponOnly;
  608.     }, this);
  609.     }
  610.     if (mode == 2) {
  611.         var newItems = $gameParty.equipItems().filter(function(item) {
  612.         return item.etypeId === 1 && this.canEquip(item) && !(item == mainW1 && $gameParty.oneOfAKind(mainW1))  && !item.meta.twohand && this.equipIsOffhand(item) && !item.meta.mainWeaponOnly && !(item.wtypeId == mainW1.wtypeId && $gameParty.misMatched(mainW1, item));
  613.     }, this);
  614.     }
  615.     if (mode == 3) {
  616.         var newItems = $gameParty.equipItems().filter(function(item) {
  617.         return item.etypeId === 1 && this.canEquip(item) && !(item == mainW1 && $gameParty.oneOfAKind(mainW1));
  618.     }, this);
  619.     }
  620.     var subW1 = this.bestEquipW(newItems);
  621.     //End Second
  622.     //Third weapon selection (Second Main)
  623.     var subW2 = null;
  624.     if (mode == 1 || mode == 2) {
  625.     items = $gameParty.equipItems().filter(function(item) {
  626.         return item.etypeId === 1 && this.canEquip(item) && !this.equipIsOffhand(item) && !item.meta.twohand && !(item == mainW1 && $gameParty.oneOfAKind(mainW1)) && !(item == subW1 && $gameParty.oneOfAKind(subW1));
  627.     }, this);
  628.     var subW2 = this.bestEquipW(items);
  629.     }
  630.     //End Third
  631.     if (subW2 !== null) {
  632.     if(this.potential(mainW1) > this.potential(subW1) + this.potential(subW2)) {
  633.     if (this.isEquipChangeOk(0)) this.changeEquip(0, mainW1);
  634.     if (!mainW1.meta.twohand) this.changeEquip(1, subW2);
  635.     } else {
  636.     if (this.isEquipChangeOk(0)) this.changeEquip(0, subW2);
  637.     if (this.isEquipChangeOk(1) && subW1 && (subW1.mdwEquipGroup.some(element => subW2.mdwEquipGroup.includes(element)))) this.changeEquip(1, subW1);
  638.     }
  639.     } else {
  640.     if (this.isEquipChangeOk(0)) this.changeEquip(0, mainW1);
  641.     if (this.isEquipChangeOk(1) && subW1 && (subW1.mdwEquipGroup.some(element => mainW1.mdwEquipGroup.includes(element)))) this.changeEquip(1, subW1);
  642.     }
  643. }
  644.  
  645. Game_Party.prototype.oneOfAKind = function (item) {
  646.     if(this.numItems(item) == 1) return true;
  647.     return false;
  648. };
  649.  
  650. Game_Party.prototype.misMatched = function (item1, item2) {
  651.     if(!item1 || !item2) return false;
  652.     if(item1.meta.mdwEquipMismatch || item2.meta.mdwEquipMismatch) return true;
  653.     return false;
  654. };
  655.  
  656. Game_Actor.prototype.bestEquipW = function(itemSet) {
  657.     var items = itemSet;
  658.     var bestItem = null;
  659.     var bestPerformance = -1000;
  660.     for (var i = 0; i < items.length; i++) {
  661.         var performance = this.potential(items[i]);
  662.         if (performance > bestPerformance) {
  663.             bestPerformance = performance;
  664.             bestItem = items[i];
  665.         }
  666.     }
  667.     return bestItem;
  668. };
  669.  
  670. var MalBestEquip = Game_Actor.prototype.bestEquipItem
  671. Game_Actor.prototype.bestEquipItem = function(slotId) {
  672.     const etypeId = this.equipSlots()[slotId];
  673.     const items = $gameParty
  674.         .equipItems()
  675.         .filter(item => item.etypeId === etypeId && this.canEquip(item));
  676.     let bestItem = null;
  677.     let bestPerformance = -1000;
  678.     for (let i = 0; i < items.length; i++) {
  679.         //const performance = this.calcEquipItemPerformance(items[i]);
  680.         const performance = this.potential(items[i]);
  681.         if (performance > bestPerformance) {
  682.             bestPerformance = performance;
  683.             bestItem = items[i];
  684.         }
  685.     }
  686.     return bestItem;
  687. };
  688.  
  689. Game_Actor.prototype.potential = function(item) {
  690.     if (!item) return -1001;
  691.     var potent = item.PotentialP;
  692.     var potent2 = Number(item.params.reduce((a, b) => a + b));
  693.     return potent + potent2;
  694. };
  695.  
  696. if(Utils.RPGMAKER_NAME === "MV"){
  697. //Addition for shop scene (MV Only)
  698. var malShop_drawParamChange = Window_ShopStatus.prototype.drawActorParamChange;
  699. Window_ShopStatus.prototype.drawActorParamChange = function(x, y, actor, item1) {
  700.     if (Mal.Parameters['PotentialPointsInShop'] == 1) {
  701.     var width = this.contents.width - this.textPadding() - x;
  702.     var change = this.potential(this._item) - (item1 ? this.potential(item1) : 0);
  703.     this.changeTextColor(this.paramchangeTextColor(change));
  704.     this.drawText((change > 0 ? '+' : '') + change, x, y, width, 'right');
  705.     } else {
  706.     malShop_drawParamChange.call(this, x, y, actor, item1);
  707.     }
  708. };
  709.  
  710. Window_ShopStatus.prototype.potential = function(item) {
  711. if (item === null) return 0;
  712. var potent = item.meta.PotentialP || 0;
  713. for (var i = 0; i < 8; i++) {
  714.         potent += item.params[i] * (Mal.power[i] / 100);
  715.     }
  716. potent = Math.round(potent);
  717. return potent;
  718. };
  719. //End Shop Scene
  720.  
  721. var MalSlotName = Window_EquipSlot.prototype.slotName
  722. Window_EquipSlot.prototype.slotName = function(index) {
  723.     var slots = this._actor.equipSlots();
  724.     if (index === 1 && this._actor.isDualWield()) return this._actor ? Mal.Parameters['OffhandSlotName'] : '';
  725.     return this._actor ? $dataSystem.equipTypes[slots[index]] : '';
  726. };
  727.  
  728. var MalDrawItem = Window_ItemList.prototype.drawItem //MV
  729. Window_ItemList.prototype.drawItem = function(index) {
  730.     var item = this._data[index];
  731.     var setting = 0;
  732.     if (typeof Window_AugmentItemList != "undefined") {
  733.         if (this instanceof Window_AugmentItemList) setting++;
  734.     }
  735.     if (item) {
  736.         var numberWidth = this.numberWidth();
  737.         var rect = this.itemRect(index);
  738.         rect.width -= this.textPadding();
  739.         this.changePaintOpacity(this.isEnabled(item));
  740.         this.drawItemName(item, rect.x, rect.y, rect.width - numberWidth);
  741.         this.drawItemNumber(item, rect.x, rect.y, rect.width);
  742.         this.changePaintOpacity(1);
  743.     } else {
  744.         var numberWidth = this.numberWidth();
  745.         var rect = this.itemRect(index);
  746.         rect.width -= this.textPadding();
  747.         if (setting == 0) this.drawText('-UNEQUIP-', rect.x, rect.y, rect.width - numberWidth);
  748.     }
  749. };
  750. Window_ShopStatus.prototype.initialize = function(x, y, width, height) {
  751.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  752.     this._item = null;
  753.     this._maxCharPages = null;
  754.     this._characterPage = this.setupCharPages();
  755.     this._pageIndex = 0;
  756.     this.refresh();
  757. };
  758.  
  759. Window_ShopStatus.prototype.setupCharPages = function() {
  760.     if (this._maxCharPages === null) {
  761.     var count = this.statusMembers().length;
  762.     if (count < 2) return -2;
  763.     this._maxCharPages = count - 1;
  764.     this._cursorFixed = false;
  765.     return -1;
  766.     }
  767. };
  768.  
  769. Window_ShopStatus.prototype.refresh = function() {
  770.     this.contents.clear();
  771.     this._cursorFixed = true;
  772.     if (!this._maxCharPages) this._characterPage = this.setupCharPages();
  773.     if (this._item) {
  774.         var x = this.textPadding();
  775.         this.drawPossession(x, 0);
  776.         if (this.isEquipItem()) {
  777.             this.drawEquipInfo(x, this.lineHeight() * 2);
  778.         }
  779.     }
  780. };
  781.  
  782. Window_ShopStatus.prototype.updatePage = function() {
  783.     if (this.isPageChangeEnabled() && this.isPageChangeRequested()) {
  784.         this.changePage();
  785.     }
  786.     if (this.isCharPageChangeEnabled() && this.isCharPageChangeRequested()) {
  787.         if (Input.isTriggered('left')) {
  788.             this.changeCharPage("L");
  789.         } else {
  790.             this.changeCharPage("R");
  791.         }
  792.         this.refresh();
  793.            
  794.     }
  795. };
  796.  
  797. Window_ShopStatus.prototype.isCharPageChangeEnabled = function() {
  798.     return (this._characterPage != -2 && this.visible && this.isEquipItem());
  799. };
  800.  
  801. Window_ShopStatus.prototype.isCharPageChangeRequested = function() {
  802.     if (Input.isTriggered('left') || Input.isTriggered('right')) {
  803.         return true;
  804.     }
  805.     if (TouchInput.isTriggered() && this.isTouchedInsideFrame()) {
  806.         return true;
  807.     }
  808.     return false;
  809. };
  810.  
  811. Window_ShopStatus.prototype.changeCharPage = function (dir) {
  812. var code = 1;
  813. SoundManager.playCursor();
  814. if (dir === "L") code = 0;
  815. if(code == 0) {
  816.     this._characterPage--;
  817.     if(this._characterPage == -2) this._characterPage = this._maxCharPages;
  818. }
  819. if(code == 1) {
  820.     this._characterPage++;
  821.     if(this._characterPage > this._maxCharPages) this._characterPage = -1;
  822. }
  823.         this.refresh();
  824. };
  825.  
  826. Window_ShopStatus.prototype.drawEquipInfo = function(x, y) {
  827.     var members = this.statusMembers();
  828.     if(this._characterPage == -2) {
  829.         this.drawActorEquipInfoSingle(x, y + this.lineHeight() * (0 * 2.4), members[0]);
  830.     } else if (this._characterPage == -1){
  831.         for (var i = 0; i < members.length; i++) {
  832.             this.drawActorEquipInfo(x, y + this.lineHeight() * (i * 2.4), members[i]);
  833.         }
  834.     } else this.drawActorEquipInfoSingle(x, y + this.lineHeight() * (0 * 2.4), members[this._characterPage]);
  835. };
  836.  
  837. Window_ShopStatus.prototype.drawActorEquipInfoSingle = function(x, y, actor) {
  838.   var enabled = actor.canEquip(this._item);
  839.   var paramHeight = 0;
  840.   this.changePaintOpacity(enabled);
  841.   this.resetTextColor();
  842.   this.drawText(actor.name(), x, y, 168);
  843.   var item1 = this.currentEquippedItem(actor, this._item.etypeId);
  844.   if (enabled) {
  845.     paramHeight = this.drawActorParamChangeSingle(x, y, actor, item1);
  846.   }
  847.   this.drawItemName(item1, x, y + (paramHeight || this.lineHeight()));
  848.   this.changePaintOpacity(true);
  849. };
  850.  
  851. Window_ShopStatus.prototype.drawActorParamChangeSingle = function(x, y, actor, item1) {
  852.   var width = this.contents.width - this.textPadding() - x;
  853.   var change = 0;
  854.   var lines = 0;
  855.   var actorParam = 0;
  856.   var paramName = ['MHP', 'MMP', 'ATK', 'DEF', 'MAT', 'MDF', 'AGI', 'LUK'];
  857.  
  858.   for (var id = 0; id < paramName.length; id++) {
  859.     change = this._item.params[id] - (item1 ? item1.params[id] : 0);
  860.     if (item1) {
  861.         if (this.doublewielding(actor) && DataManager.isWeapon(item1)) {
  862.         if(item1 === actor.equips()[0]) var item2 = actor.equips()[1];
  863.         if(item1 === actor.equips()[1]) var item2 = actor.equips()[0];
  864.         }
  865.         if(this._item.meta.twohand && item2) change -= item2.params[id];
  866.         if (item1.etypeId !== this._item.etypeId && item1.id !== this._item.id) {
  867.         actorParam = this._item.params[id] > 0 ? actor.param(id) - this._item.params[id] : actor.param(id) + this._item.params[id];
  868.       } else {
  869.         actorParam = actor.param(id);
  870.       }
  871.     } else {
  872.       actorParam = actor.param(id);
  873.     }
  874.     this.changeTextColor(this.paramchangeTextColor(change));
  875.     if (change == 0) {
  876.         this.drawText((change > 0 ? '+' : '') + '  ' + ' ' + paramName[id] + ' ' + (actorParam + change), x, y + lines, width, 'right');
  877.     } else {
  878.         this.drawText((change > 0 ? '+' : '') + change + ' ' + paramName[id] + ' ' + (actorParam + change), x, y + lines, width, 'right');
  879.     };
  880.     lines += this.lineHeight();
  881.   }
  882.  
  883.   return lines;
  884. };
  885.  
  886. Window_ShopStatus.prototype.currentEquippedItem = function(actor, etypeId) {
  887.     var list = [];
  888.     var equips = actor.equips();
  889.     var slots = actor.equipSlots();
  890.     for (var i = 0; i < slots.length; i++) {
  891.         if (slots[i] === etypeId) {
  892.         if (i < 2 && actor.hasMonkeyGrip()) {
  893.             list.push(equips[i]);
  894.         } else {
  895.             if (i == 0 && !this.ignoreWeap1(actor)) list.push(equips[i]);
  896.             if (i == 1 && !this.ignoreWeap2(actor)) list.push(equips[i]);
  897.         }
  898.         if (i >= 2) list.push(equips[i]);
  899.         }
  900.     }
  901.     var paramId = this.paramId();
  902.     var worstParam = Number.MAX_VALUE;
  903.     var worstItem = null;
  904.     for (var j = 0; j < list.length; j++) {
  905.         if (!list[j]) {
  906.           return null;
  907.         }
  908.         if (list[j] && list[j].params[paramId] < worstParam) {
  909.             worstParam = list[j].params[paramId];
  910.             worstItem = list[j];
  911.         }
  912.     }
  913.     return worstItem;
  914. };
  915.  
  916. Window_ShopStatus.prototype.ignoreWeap1 = function (actor) {
  917.  
  918.     if (this._item.meta.twohand && !actor.equips()[0]) return true;
  919.     if ((this._item.meta.shld || this._item.meta.offHWeapon)&& !this.dualwielding(actor)) return true;
  920.     if ((this._item.meta.shld || this._item.meta.offHWeapon) && actor.equips()[1] && (actor.equips()[1].meta.shld || actor.equips()[1].meta.offHWeapon)) return true;
  921.     if (this.dualwielding(actor) && !actor.equips()[0]) return true;
  922.     return false;
  923. };
  924.  
  925. Window_ShopStatus.prototype.ignoreWeap2 = function (actor) {
  926.  
  927.     if (!actor.equips()[0]) return false;
  928.     if (this.dualwielding(actor)) return true;
  929.     if (this._item.meta.mainWeaponOnly) return true
  930.     if (this._item.meta.twohand && actor.equips()[0] && !actor.equips()[0].meta.twohand) return true;
  931.     return false;
  932.    
  933. };
  934.  
  935. Window_ShopStatus.prototype.dualwielding = function (actor) {
  936.  
  937.     if(actor.equips()[0] && actor.equips()[0].meta.twohand) return true;
  938.     if(actor.equips()[1] && actor.equips()[1].meta.twohand) return true;
  939.     return false;
  940. };
  941.  
  942. Window_ShopStatus.prototype.doublewielding = function (actor) {
  943.  
  944.     if(actor.equips()[0] && actor.equips()[1]) return true;
  945.     return false;
  946. };
  947.  
  948. var MalDualBuyWindow = Scene_Shop.prototype.createBuyWindow
  949. Scene_Shop.prototype.createBuyWindow = function() {
  950.     MalDualBuyWindow.call(this);
  951.     this._buyWindow.setHandler('left',     this.cycleLeft.bind(this));
  952.     this._buyWindow.setHandler('Menu',     this.cycleRight.bind(this));
  953. };
  954.  
  955. Scene_Shop.prototype.cycleLeft = function () {
  956. this._statusWindow.changeCharPage("L");
  957. };
  958.  
  959. Scene_Shop.prototype.cycleRight = function () {
  960. this._statusWindow.changeCharPage("R");
  961. };
  962. } else {
  963. var MalSlotName = Window_StatusBase.prototype.actorSlotName
  964. Window_StatusBase.prototype.actorSlotName = function(actor, index) {
  965.     var slots = this._actor.equipSlots();
  966.     if (index === 1 && this._actor.isDualWield()) return this._actor ? Mal.Parameters['OffhandSlotName'] : '';
  967.     return $dataSystem.equipTypes[slots[index]];
  968. };
  969. };
  970.  
  971.  
  972. if(Utils.RPGMAKER_NAME === "MZ") {
  973. Window_EquipItem.prototype.drawItemName = function(item, x, y, width) {
  974.     if (item) {
  975.         const iconY = y + (this.lineHeight() - ImageManager.iconHeight) / 2;
  976.         const textMargin = ImageManager.iconWidth + 4;
  977.         const itemWidth = Math.max(0, width - textMargin);
  978.         this.resetTextColor();
  979.         this.drawIcon(item.iconIndex, x, iconY);
  980.         this.drawText(item.name, x + textMargin, y, itemWidth);
  981.     } else {
  982.         const iconY = y + (this.lineHeight() - ImageManager.iconHeight) / 2;
  983.         const textMargin = ImageManager.iconWidth + 4;
  984.         const itemWidth = Math.max(0, width - textMargin);
  985.         this.resetTextColor();
  986.         //this.drawIcon(item.iconIndex, x, iconY);
  987.         this.drawText("-Butter-", x + textMargin, y, itemWidth);
  988.        
  989.     }
  990. };
  991. };
  992.  
  993. var MalItemList = Window_ItemList.prototype.includes
  994. Window_ItemList.prototype.includes = function(item) {
  995.     switch (this._category) {
  996.     case 'item':
  997.         return DataManager.isItem(item) && item.itypeId === 1;
  998.     case 'weapon':
  999.         return DataManager.isWeapon(item) && (!item.meta.shld);
  1000.     case 'armor':
  1001.         return DataManager.isArmor(item) || (item && item.meta.shld);
  1002.     case 'keyItem':
  1003.         return DataManager.isItem(item) && item.itypeId === 2;
  1004.     default:
  1005.         return false;
  1006.     }
  1007. };
  1008.  
  1009. var MalparamPlus = Game_Actor.prototype.paramPlus
  1010. Game_Actor.prototype.paramPlus = function(paramId) {
  1011.     var value = MalparamPlus.call(this, paramId);
  1012.     var subValue = 0;
  1013.     var equips = this.equips();
  1014.     for (var i = 0; i < equips.length; i++) {
  1015.         var item = equips[i];
  1016.         if (item) {
  1017.             if (i == 1) {
  1018.                 value -= item.params[paramId];
  1019.                 subValue = this.offhandAdjust(item.params[paramId], item);
  1020.             }
  1021.         }
  1022.     }
  1023.     return value + subValue;
  1024. };
  1025.  
  1026. Game_Actor.prototype.offhandAdjust = function(value, item) {
  1027.     var value = value;
  1028.     var item = item;
  1029.     var adjust = Number(Mal.Parameters['OffhandAdjust']);
  1030.     if (item.meta.OffhandAdjust) adjust = Number(item.meta.OffhandAdjust);
  1031.     for (var i = 0; i < this.states().length; i++) {
  1032.         var state = this.states()[i].id;
  1033.         if ($dataStates[state].meta.OffhandAdjust) {
  1034.             adjust = Number($dataStates[state].meta.OffhandAdjust);
  1035.             break;
  1036.         };
  1037.     };
  1038.     //console.log(this);
  1039.     if ($dataActors[this._actorId].meta.OffhandAdjust) adjust = Number($dataActors[this._actorId].meta.OffhandAdjust);
  1040.     return Math.floor(value * adjust / 100.0);
  1041. };
  1042.    
  1043. Game_Actor.prototype.performAttack = function() {
  1044.     var weapons = this.weapons();
  1045.     var wtypeChId = -1;
  1046.     if (weapons[0] && weapons[1] && weapons[0].meta.subweapon) {
  1047.         wtypeChId = weapons[1].wtypeId;
  1048.     } else {
  1049.         wtypeChId = weapons[0] ? weapons[0].wtypeId : 0;
  1050.     }
  1051.     var wtypeId = wtypeChId;
  1052.     var attackMotion = $dataSystem.attackMotions[wtypeId];
  1053.     if (attackMotion) {
  1054.         if (attackMotion.type === 0) {
  1055.             this.requestMotion("thrust");
  1056.         } else if (attackMotion.type === 1) {
  1057.             this.requestMotion("swing");
  1058.         } else if (attackMotion.type === 2) {
  1059.             this.requestMotion("missile");
  1060.         }
  1061.         this.startWeaponAnimation(attackMotion.weaponImageId);
  1062.     }
  1063. };
  1064.  
  1065. Game_Actor.prototype.attackAnimationId1 = function() {
  1066.     if (this.hasNoWeapons()) {
  1067.         return this.bareHandsAnimationId();
  1068.     } else {
  1069.         var weapons = this.weapons();
  1070.         var aniSet = weapons[0] ? weapons[0].animationId : 0;
  1071.         if (weapons[0] && weapons[1] && weapons[0].meta.subweapon && !weapons[1].meta.subweapon) aniSet = weapons[1] ? weapons[1].animationId : 0;
  1072.         return aniSet;
  1073.     }
  1074. };
  1075.  
  1076. Game_Actor.prototype.attackAnimationId2 = function() {
  1077.     var weapons = this.weapons();
  1078.     var aniSet = weapons[1] ? weapons[1].animationId : 0;
  1079.     if (weapons[0] && weapons[1] && weapons[1].meta.subweapon) aniSet = 0;
  1080.     if (weapons[0] && weapons[1] && weapons[0].meta.subweapon) aniSet = 0;
  1081.     return aniSet;
  1082. };
  1083.  
  1084. var MalGame_Actor_allTraits = Game_Actor.prototype.allTraits;
  1085. Game_Actor.prototype.allTraits = function() {
  1086.     var traits = MalGame_Actor_allTraits.call(this);
  1087.     var equips = this.equips();
  1088.     var dualFlag = false;
  1089.     if (this.useDuoTrait()) {
  1090.         var dGrp1 = equips[0].dualGroup;
  1091.         var dGrp2 = equips[1].dualGroup;
  1092.         for (var i = 0; i < dGrp1.length; i++) {
  1093.             var point = dGrp1[i];
  1094.             if (dGrp2.contains(point)) {
  1095.                 if(equips[0].dualGroupTraits[point]) {
  1096.                     traits = traits.concat(this.traitEval(equips[0].dualGroupTraits[point]));
  1097.                     dualFlag = true;
  1098.                 }
  1099.                 if(equips[1].dualGroupTraits[point]) {
  1100.                     if (equips[0].syncNum == equips[1].syncNum) continue;
  1101.                     traits = traits.concat(this.traitEval(equips[1].dualGroupTraits[point]));
  1102.                     dualFlag = true;
  1103.                 }
  1104.             }
  1105.                 if(equips[0].dualGroupTraits[0]) {
  1106.                     traits = traits.concat(this.traitEval(equips[0].dualGroupTraits[0]));
  1107.                     dualFlag = true;
  1108.                 }
  1109.                 if(equips[1].dualGroupTraits[0]) {
  1110.                     if (equips[0].syncNum == equips[1].syncNum) continue;
  1111.                     traits = traits.concat(this.traitEval(equips[1].dualGroupTraits[0]));
  1112.                     dualFlag = true;
  1113.                 }
  1114.         }      
  1115.     }
  1116.     for (var i = 0; i < equips.length; i++) {
  1117.         var item = equips[i];
  1118.         if(item) {
  1119.             if (i == 0 && item.mainWTraits) traits = traits.concat(this.traitEval(item.mainWTraits));
  1120.             if (i == 1 && item.subWTraits)  traits = traits.concat(this.traitEval(item.subWTraits));
  1121.             if (item.doubleGripTraits && this.isDoubleGripping()) traits = traits.concat(this.traitEval(item.doubleGripTraits));
  1122.             if (item.standardTraits) traits = traits.concat(this.traitEval(item.standardTraits));
  1123.             if (i == 0 && item.syncTraits && this.useSyncTrait()) traits = traits.concat(this.traitEval(item.syncTraits));
  1124.             if (i == 0 && this.hasMatchedEquip() && item.groupEquTraits)  traits = traits.concat(this.traitEval(item.groupEquTraits));
  1125.             if (Mal.Parameters['Matched_Equip_Omit_Traits'] == 1 && i == 1 && this.isSameWeapon()) continue;
  1126.             if (i == 1 && item.syncTraits && this.useSyncTrait()) traits = traits.concat(this.traitEval(item.syncTraits));
  1127.             if (i == 1 && this.hasMatchedEquip() && item.groupEquTraits)  traits = traits.concat(this.traitEval(item.groupEquTraits));
  1128.             if (i > 1) {
  1129.                 if(this.hasMatchedEquip() && item.groupEquTraits && item.mdwEquipGroup == equips[0].mdwEquipGroup)  traits = traits.concat(this.traitEval(item.groupEquTraits));
  1130.                 if(this.useSyncTrait() && item.syncTraits) traits = traits.concat(this.traitEval(item.syncTraits));
  1131.             }
  1132.         }
  1133.     }
  1134.     return traits;
  1135. };
  1136.  
  1137. Game_Actor.prototype.traitEval = function(traitSet) {
  1138.     var origSet = traitSet;
  1139.     var newSet = [];
  1140.     var actor = this;
  1141.     var s = $gameSwitches._data;
  1142.     var v = $gameVariables._data;
  1143.     for (var i = 0; i < origSet.length; i++) {
  1144.         var trait = origSet[i];
  1145.         var check = Function("var actor = $gameTemp.actor; var equip = $gameTemp.equip; var s = $gameSwitches._data; var v = $gameVariables._data; return " + trait.dwEval);
  1146.         if(check) newSet.push(trait);
  1147.     }
  1148.     return newSet;
  1149. };
  1150.    
  1151. Game_Actor.prototype.hasMatchedEquip = function() {
  1152.     var equips = this.equips();
  1153.     if (!equips[0] || !equips[1]) return false;
  1154.     if (equips[0] && equips[0].mdwEquipGroup == [-1]) return false;
  1155.     if (equips[1] && equips[1].mdwEquipGroup == [-1]) return false;
  1156.     return (equips[0].mdwEquipGroup.some(element => equips[1].mdwEquipGroup.includes(element)));
  1157.     return false;
  1158. };
  1159.  
  1160. Game_Actor.prototype.useSyncTrait = function() {
  1161.     var equips = this.equips();
  1162.     return (((equips[0] && equips[1])) && (equips[0].syncNum == equips[1].syncNum));
  1163.     return false;
  1164. };
  1165.  
  1166. Game_Actor.prototype.useDuoTrait = function() {
  1167.     var equips = this.equips();
  1168.     return ((equips[0] && equips[0].dualGroup != []) && (equips[1] && equips[1].dualGroup != []));
  1169.     return false;
  1170. };
  1171.  
  1172. Game_Actor.prototype.isSameWeapon = function() {
  1173.     var equips = this.equips();
  1174.     if (equips[0] && equips[1]) return (equips[0].syncNum == equips[1].syncNum);
  1175.     return false;
  1176. };
  1177.    
  1178. Game_Actor.prototype.isDoubleGripping = function() {
  1179.     var equips = this.equips();
  1180.     return (this.hasDoubleGrip() && ((equips[0] && !equips[1]) || (equips[1] && !equips[0])));
  1181. };
  1182.  
  1183. Game_Actor.prototype.hasDoubleGrip = function() {
  1184.     if (this.currentClass().note.indexOf("<doubleGrip>") > -1) return true;
  1185.     var equips = this.equips();
  1186.     for (var i = 0; i < equips.length; i++) {
  1187.         if (equips[i] && equips[i].note.indexOf("<doubleGrip>") > -1) return true;
  1188.     }
  1189.     var states = this.states();
  1190.     for (var i = 0; i < states.length; i++) {
  1191.         if (states[i].note.indexOf("<doubleGrip>") > -1) return true;
  1192.     }
  1193.     if (this._passiveSkills && this._passiveSkills != []){
  1194.         var passives = this._passiveSkills;
  1195.         for (var i = 0; i < passives.length; i++) {
  1196.             if ($dataSkills[passives[i]].meta.doubleGrip) return true;
  1197.         }
  1198.     }
  1199.     return false;
  1200. }
  1201.  
  1202. Game_Actor.prototype.hasMonkeyGrip = function() {
  1203.     if (this.currentClass().note.indexOf("<monkeygrip>") > -1) return true;
  1204.     var equips = this.equips();
  1205.     for (var i = 0; i < equips.length; i++) {
  1206.         if (equips[i] && equips[i].note.indexOf("<monkeygrip>") > -1) return true;
  1207.     }
  1208.     var states = this.states();
  1209.     for (var i = 0; i < states.length; i++) {
  1210.         if (states[i].note.indexOf("<monkeygrip>") > -1) return true;
  1211.     }
  1212.     if (this._passiveSkills && this._passiveSkills != []){
  1213.         var passives = this._passiveSkills;
  1214.         for (var i = 0; i < passives.length; i++) {
  1215.             if ($dataSkills[passives[i]].meta.monkeygrip) return true;
  1216.         }
  1217.     }
  1218.     return false;
  1219. }
  1220.  
  1221. Game_Actor.prototype.enableDW = function() {
  1222.     var equips = this.equips();
  1223.     for (var i = 0; i < equips.length; i++) {
  1224.         if (equips[i] && equips[i].note.indexOf("<dualW>") > -1) return true;
  1225.     }
  1226.     var states = this.states();
  1227.     for (var i = 0; i < states.length; i++) {
  1228.         if (states[i].note.indexOf("<dualW>") > -1) return true;
  1229.     }
  1230.     if (this._passiveSkills && this._passiveSkills != []){
  1231.         var passives = this._passiveSkills;
  1232.         for (var i = 0; i < passives.length; i++) {
  1233.             if ($dataSkills[passives[i]].meta.dualW) return true;
  1234.         }
  1235.     }
  1236.     return false;
  1237. }
  1238.  
  1239. Game_Actor.prototype.isWeaponEquipped = function(type) {
  1240. if (type) {
  1241. var type = Number(type);
  1242. } else {
  1243. var type = 0;
  1244. }
  1245. if (type == 0){
  1246.     if (this.equips()[0]) {
  1247.         if (this.equips()[1]) return 2;
  1248.         return 0;
  1249.     }
  1250.     if (this.equips()[1]) return 1;
  1251.     return -1;
  1252. } else {
  1253.     if (this.equips()[0] && this.equips()[0].wtypeId == type) {
  1254.         if (this.equips()[1] && this.equips()[1].wtypeId == type) return 2;
  1255.         return 0;
  1256.     }
  1257.     if (this.equips()[1] && this.equips()[1].wtypeId == type) return 1;
  1258.     return -1;
  1259. }
  1260. };
  1261.  
  1262. Game_Enemy.prototype.isWeaponEquipped = function(type) {
  1263. return -1;
  1264. };
  1265.  
  1266. Game_Actor.prototype.equipIsOffhand = function(item) {
  1267.     if (item.meta.shld || item.meta.offHWeapon) return true;
  1268.     return false;
  1269. };
Add Comment
Please, Sign In to add comment