Maliki79

MalDualWieldVZ

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