Advertisement
Maliki79

MalDualWield

Nov 7th, 2015 (edited)
5,174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Maliki's Dual Weilding/Two-Handed Weapons
  3. // MalDualWield.js
  4. // version 2.5a
  5. //=============================================================================
  6. /*:  
  7. * @plugindesc ver2.5a - Allows you to set weapons as twohanded, disallowing you from equipping weapons to the Off-hand.  
  8.  * @author Maliki79
  9.  * @param ShieldsArmor
  10.  * @desc Type 1 to place Shield weapons in Menu Screens' Armor category.
  11.  * Default: 0
  12.  * @default 0
  13.  *
  14.  * @param MustUseMain
  15.  * @desc Type 1 to force equips to be placed in Main hand before they can be place in Off hand.
  16.  * Default: 0
  17.  * @default 0
  18.  *
  19.  * @param OffhandAdjust
  20.  * @desc Percentage of stats offhand weapons add to actors. (Make the number lower than 100 to lower stats and higher to raise)
  21.  * Default: 100
  22.  * @default 100
  23.  *
  24.  * @param OffhandSlotName
  25.  * @desc Name used for offhand weapon slot.
  26.  * Default: Off-Hand
  27.  * @default Off-Hand
  28.  *
  29.  * @param ShowTraitsInConsole
  30.  * @desc Type 1 to show trait code,dataId and value data on console upon item equip.
  31.  * Default: 0
  32.  * @default 0
  33.  *
  34.  * @param PowerAdjustement0
  35.  * @desc Amount of "weight" given to HP when determining strength of weapons as a percent.
  36.  * Default: 100
  37.  * @default 100
  38.  *
  39.  * @param PowerAdjustement1
  40.  * @desc Amount of "weight" given to MP when determining strength of weapons as a percent.
  41.  * Default: 100
  42.  * @default 100
  43.  *
  44.  * @param PowerAdjustement2
  45.  * @desc Amount of "weight" given to ATK when determining strength of weapons as a percent.
  46.  * Default: 100
  47.  * @default 100
  48.  *
  49.  * @param PowerAdjustement3
  50.  * @desc Amount of "weight" given to DEF when determining strength of weapons as a percent.
  51.  * Default: 100
  52.  * @default 100
  53.  *
  54.  * @param PowerAdjustement4
  55.  * @desc Amount of "weight" given to M.ATK when determining strength of weapons as a percent.
  56.  * Default: 100
  57.  * @default 100
  58.  *
  59.  * @param PowerAdjustement5
  60.  * @desc Amount of "weight" given to M.DEF when determining strength of weapons as a percent.
  61.  * Default: 100
  62.  * @default 100
  63.  *
  64.  * @param PowerAdjustement6
  65.  * @desc Amount of "weight" given to AGI when determining strength of weapons as a percent.
  66.  * Default: 100
  67.  * @default 100
  68.  *
  69.  * @param PowerAdjustement7
  70.  * @desc Amount of "weight" given to LUK when determining strength of weapons as a percent.
  71.  * Default: 100
  72.  * @default 100
  73.  *
  74.  * @param PotentialPointsInShop
  75.  * @desc Shows Equipment "Potential" as a point total in shops.  Make this value 1 to enable, otherwise, the default calculations will be used.
  76.  * Default: 1
  77.  * @default 1
  78.  *
  79.  * @param 2H_DisableOtherSlot
  80.  * @desc If 1, equipping a 2Handed Weapon will completely disable the other equip slot.
  81.  * default: 0
  82.  * @default 0
  83.  *
  84.  * @help You need two steps to use this plugin:
  85.  * 1: Set your actor(s) up to have Dual-Wield in the Database. TRAITS => EQUIP => SLOT TYPE => DUAL WIELD
  86.  * 2: Add the Notetag <twohand> to any two handed weapons in your Database.
  87.  * 3: (Optional) For Shields, make them weapons in your database and add the tag <shld> to their notes. "Shields" can only be equipped to the off-hand.
  88.  * 3a: Conversly, if you tag a weapon with <mainWeaponOnly> , it will only be equippable on the main hand.
  89.  * 4: (Optional) For one handed Actors you wish to equip shields that are considered weapons in the DB, tag <handnshld>
  90.  *    to the Actor's Class notes. (Those Actors still need to have the Dual Wield trait.)
  91.  * 5: (Optional) An Actor's Class notes can be tagged with <monkeygrip> to allow two handed weapons to be dual wielded or allow a 2H weapon and shield.
  92.  * 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.
  93.  * 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.
  94.  * 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.
  95.  *    Weapons with the Mainweapon tag will exhibit those traits ONLY while in the main weapon slot while supweapon tagged weapons will exhibit
  96.  *    thier traits while in the off hand only.
  97.  * 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.
  98.  *    When one tagged weapon is equipped and while the actor has the <doubleGrip> tag on either class notes or a state's notes,
  99.  *    the double grip traits will be applied to the actor.
  100.  * 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
  101.  *    calculations.  Usful if things other than raw stats are used and will fator into the potential score in your project.
  102.  *
  103.  * Notes on main/sub/double-grip weapon traits:
  104.  * Codes are the number representation of traits as they appear in the database.
  105.  *  Trait codes are listed below:
  106.  *  11-TRAIT_ELEMENT_RATE      41-TRAIT_STYPE_ADD       61-TRAIT_ACTION_PLUS
  107.  *  12-TRAIT_DEBUFF_RATE       42-TRAIT_STYPE_SEAL      62-TRAIT_SPECIAL_FLAG
  108.  *  13-TRAIT_STATE_RATE        43-TRAIT_SKILL_ADD       63-TRAIT_COLLAPSE_TYPE
  109.  *  14-TRAIT_STATE_RESIST      44-TRAIT_SKILL_SEAL      64-TRAIT_PARTY_ABILITY
  110.  *  21-TRAIT_PARAM             51-TRAIT_EQUIP_WTYPE
  111.  *  22-TRAIT_XPARAM            52-TRAIT_EQUIP_ATYPE
  112.  *  23-TRAIT_SPARAM            53-TRAIT_EQUIP_LOCK
  113.  *  31-TRAIT_ATTACK_ELEMENT    54-TRAIT_EQUIP_SEAL
  114.  *  32-TRAIT_ATTACK_STATE      55-TRAIT_SLOT_TYPE
  115.  *  33-TRAIT_ATTACK_SPEED
  116.  *  34-TRAIT_ATTACK_TIMES
  117.  *
  118.  * 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.
  119.  * The numbers here can vary based on the quantity of things in your database and what code is being used.
  120.  *
  121.  * The value is the amount of the effect the code will express as a float.  So, revisiting the about example, if you wanted attack to be raised by 20%,
  122.  * you would use the value 1.2, which is 120%.
  123.  * The final tag for this example would be:  <subweaponTrait: 21, 2, 1.2>
  124.  *
  125.  * A method to assist with finding the code, dataId and value figures lies in the ShowTraitsInConsole param.  Setting it to 1
  126.  * will allow the console to print out an array of normal traits on an equipped item on the moment it is equipped.
  127.  * (Press F8 to open the console by default.)
  128.  * 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
  129.  * equip with the traits you want and note what their values are via the console.
  130.  * (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.)
  131.  *
  132.  * As of version 2.2, a "potential" value has been introduced.
  133.  * This value is a combination of the default stats of a weapon with differing user defined "weights" for each one.
  134.  * This value is used for two parts of this plugin: the choosing of weapons when optimizing and when comparing equips in the
  135.  * the shop scene.  (The shop scene potential can be deactivated by changing the PotentialPointsInShop param).
  136.  *
  137.  * As of version 2.3, the Shop Scene has received a small update.  Players can now cycle through PC in the scene to get detailed info
  138.  * of an equip item.  This can be used if the Potential value is still a bit too vague.
  139.  *
  140.  * A script call has been added to aid those wishing to know which equip slot is housing what equip type.
  141.  * Using the script call $gameActors.isWeaponEquipped(type) will return a number based on the defined type
  142.  * (type is the weapon type ID in the database.)
  143.  * 0 if in the first equip slot,
  144.  * 1 if it's in the second,
  145.  * 2 if it's in both,
  146.  * and -1 if in neither.
  147.  * You can omit the type arguement and the function will return those numbers if their is ANY weapon is equipped in those slots.
  148.  *
  149.  * Equip Groups have been added!
  150.  * Tag weapon equips and shield type armor equips with this tag in thier notes:
  151.  *
  152.  * <mdwEquipGroup: x> with x being an integer higher than 0.
  153.  * If an equip has this tag, it will only be able to be dual wielded with other equips with the same group number.
  154.  */
  155.  
  156. var Mal = Mal || {};
  157.  
  158. Mal.Parameters = PluginManager.parameters('MalDualWield');
  159. Mal.Param = Mal.Param || {};
  160.  
  161. Mal.power = [];
  162.  Mal.power.push(Number(Mal.Parameters['PowerAdjustement0']));
  163.  Mal.power.push(Number(Mal.Parameters['PowerAdjustement1']));
  164.  Mal.power.push(Number(Mal.Parameters['PowerAdjustement2']));
  165.  Mal.power.push(Number(Mal.Parameters['PowerAdjustement3']));
  166.  Mal.power.push(Number(Mal.Parameters['PowerAdjustement4']));
  167.  Mal.power.push(Number(Mal.Parameters['PowerAdjustement5']));
  168.  Mal.power.push(Number(Mal.Parameters['PowerAdjustement6']));
  169.  Mal.power.push(Number(Mal.Parameters['PowerAdjustement7']));
  170.  
  171.  Mal.Par2HLock = Number((Mal.Parameters['2H_DisableOtherSlot']))
  172.  
  173.  var MalDualDatabaseLoad = DataManager.isDatabaseLoaded;
  174. DataManager.isDatabaseLoaded = function() {
  175.   if (!MalDualDatabaseLoad.call(this)) return false;
  176.   if (!DataManager._malDual_DatabaseLoaded) {
  177.     this.processDualNotetags($dataWeapons);
  178.     this.processDualNotetags($dataArmors);
  179.     DataManager._malDual_DatabaseLoaded = true;
  180.   }
  181.   return true;
  182. };
  183.  
  184. DataManager.processDualNotetags = function(group) {
  185.     for (var n = 1; n < group.length; n++) {
  186.         var obj = group[n];
  187.         obj.mdwEquipGroup = -1;
  188.         this.createDualTraits(obj);
  189.     }
  190. };
  191.  
  192. DataManager.createDualTraits = function(obj) {
  193.  
  194. var traits = [];
  195. var noteread = obj.note;
  196. while(noteread.indexOf("mainweaponTrait") > -1)
  197. {
  198.     var notereg = noteread.split("<mainweaponTrait: ");
  199.     var match = notereg[1].split(", ");
  200.     var match2 = match[2].split(">");
  201.     match2 = match2[0];
  202.     traits.push({"code": parseInt(match[0]), "dataId": parseInt(match[1]), "value": Number(match2)});
  203.     noteread = noteread.replace("<mainweaponTrait: ", " ");
  204. }
  205. obj.mainWTraits = traits;
  206.  
  207. traits = [];
  208. while(noteread.indexOf("subweaponTrait") > -1)
  209. {
  210.     var notereg = noteread.split("<subweaponTrait: ");
  211.     var match = notereg[1].split(", ");
  212.     var match2 = match[2].split(">");
  213.     match2 = match2[0];
  214.     traits.push({"code": parseInt(match[0]), "dataId": parseInt(match[1]), "value": Number(match2)});
  215.     noteread = noteread.replace("<subweaponTrait: ", " ");
  216. }
  217. obj.subWTraits = traits;
  218.  
  219. traits = [];
  220. while(noteread.indexOf("doubleGripTrait") > -1)
  221. {
  222.     var notereg = noteread.split("<doubleGripTrait: ");
  223.     var match = notereg[1].split(", ");
  224.     var match2 = match[2].split(">");
  225.     match2 = match2[0];
  226.     traits.push({"code": parseInt(match[0]), "dataId": parseInt(match[1]), "value": Number(match2)});
  227.     noteread = noteread.replace("<doubleGripTrait: ", " ");
  228. }
  229. obj.doubleGripTraits = traits;
  230. if(noteread.indexOf("mdwEquipGroup") > -1) {
  231.     var notereg = noteread.split("<mdwEquipGroup: ");
  232.     var match = parseInt(notereg[1]);
  233.     obj.mdwEquipGroup = match;
  234. }
  235. };
  236.  
  237. var MalEquipChangeOK = Game_Actor.prototype.isEquipChangeOk
  238. Game_Actor.prototype.isEquipChangeOk = function(slotId) {
  239.     if (this.twohanding > -1 && Mal.Par2HLock == 1) {
  240.         if (this.twohanding == 0 && slotId == 1) return false;
  241.         if (this.twohanding == 1 && slotId == 0) return false;
  242.     }
  243.     return MalEquipChangeOK.call(this, slotId);
  244. };
  245.  
  246. var MalOnSlotOK = Scene_Equip.prototype.onItemOk
  247. Scene_Equip.prototype.onItemOk = function() {
  248.     if (this._slotWindow.index() === 0 && !(this._itemWindow.item()) && (this._actor.equips()[1] && Mal.Parameters['MustUseMain'] == 1)) {
  249.     SoundManager.playBuzzer();
  250.     }else {
  251.     SoundManager.playEquip();
  252.     this.actor().changeEquip(this._slotWindow.index(), this._itemWindow.item());
  253.     if (this._itemWindow.item() && Mal.Parameters['ShowTraitsInConsole'] == 1) {
  254.     console.log(this._itemWindow.item().name + "'s traits are:");
  255.     console.log(this._itemWindow.item().traits);
  256.     }
  257.     }
  258.     this._slotWindow.activate();
  259.     this._slotWindow.refresh();
  260.     this._itemWindow.deselect();
  261.     this._itemWindow.refresh();
  262.     if (typeof Yanfly !== "undefined" && Yanfly.Equip) this._itemWindow.hide(); //Added this for compatibility with YF's Equip Core
  263.     this._statusWindow.refresh();
  264.    
  265. };
  266.  
  267. Game_Actor.prototype.changeEquip = function(slotId, item) {
  268.     if (this.tradeItemWithParty(item, this.equips()[slotId]) &&
  269.             (!item || this.equipSlots()[slotId] === item.etypeId)) {
  270.         this._equips[slotId].setObject(item);
  271.         if (slotId == 0) {
  272.         var slot = 1;
  273.         } else {
  274.         var slot = 0;
  275.         }
  276.         if (slotId < 2) {
  277.         if (item && item.meta.twohand && !this.currentClass().meta.monkeygrip) {
  278.         this.tradeItemWithParty(null, this.equips()[slot])
  279.         this._equips[slot].setObject(null);
  280.         }
  281.         if (item && this.equips()[slot] && this.equips()[slot].meta.twohand && !this.currentClass().meta.monkeygrip){
  282.         this.tradeItemWithParty(null, this.equips()[slot])
  283.         this._equips[slot].setObject(null);
  284.         }
  285.         if (Mal.Parameters['MustUseMain'] == 1 && !this.equips()[0] && this.equips()[1]){
  286.         if(!this.equips()[1].meta.shld) this._equips[0].setObject(this.equips()[1]);
  287.         this._equips[1].setObject(null);
  288.         }
  289.         }
  290. this.check2Hand();
  291.         this.refresh();
  292.     }
  293. };
  294.  
  295. Game_Actor.prototype.forceChangeEquip = function(slotId, item) {
  296.     if (item) {
  297.         this._equips[slotId].setObject(item);
  298.         if (slotId == 0) {
  299.             var slot = 1;
  300.         } else {
  301.             var slot = 0;
  302.         }
  303.         if (slotId < 2) {
  304.             if (item && item.meta.twohand && !this.currentClass().meta.monkeygrip) {
  305.                 this._equips[slot].setObject(null);
  306.             }
  307.             if (item && this.equips()[slot] && this.equips()[slot].meta.twohand && !this.currentClass().meta.monkeygrip){
  308.                 this._equips[slot].setObject(null);
  309.             }
  310.             if (Mal.Parameters['MustUseMain'] == 1 && !this.equips()[0] && this.equips()[1]){
  311.                 this._equips[0].setObject(this.equips()[1]);
  312.                 this._equips[1].setObject(null);
  313.             }
  314.         }
  315.     } else {
  316.         this._equips[slotId].setObject(null);
  317.     }
  318.     this.releaseUnequippableItems(true);
  319. this.check2Hand();
  320.     this.refresh();
  321. };
  322.  
  323. var MalreleaseUnEI = Game_Actor.prototype.releaseUnequippableItems;
  324. Game_Actor.prototype.releaseUnequippableItems = function(forcing) {
  325. MalreleaseUnEI.call(this, forcing);
  326. this.check2Hand();
  327. };
  328.  
  329. Game_Actor.prototype.check2Hand = function() {
  330.     this.twohanding = -1;
  331.     var equip = this.equips()[0];
  332.     if (equip && equip.meta.twohand && !this.currentClass().meta.monkeygrip) this.twohanding = 0;
  333.     var equip = this.equips()[1];
  334.     if (equip && equip.meta.twohand && !this.currentClass().meta.monkeygrip) this.twohanding = 1;
  335. };
  336.  
  337. var MalEquip = Window_EquipItem.prototype.includes
  338. Window_EquipItem.prototype.includes = function(item) {
  339.     if (item === null) {
  340.         if (this._slotId === 0 && (this._actor.equips()[1] && Mal.Parameters['MustUseMain'] == 1)){
  341.         return; // false;
  342.         } else {
  343.         return true;
  344.     }}
  345.     if (this._slotId === 0 && item.meta.shld && this._actor.currentClass().meta.monkeygrip) {
  346.     return this._actor.canEquip(item);
  347.     }
  348.     if (this._slotId === 0 && item.meta.shld) {
  349.     return false;
  350.     }
  351.     if (this._slotId === 1 && !(item.meta.shld) && this._actor.currentClass().meta.handnshld) {
  352.     return false;
  353.     }
  354.     if (this._slotId === 1 && !(this._actor.equips()[0]) && Mal.Parameters['MustUseMain'] == 1 ) {
  355.     return false;
  356.     }
  357.     if (this._slotId === 1 && item.meta.mainWeaponOnly) {
  358.     return false;
  359.     }
  360.     if (this._slotId < 0 || item.etypeId !== this._actor.equipSlots()[this._slotId]) {
  361.         return false;
  362.     }
  363.     if (this._slotId === 0 && this._actor.equips()[1] && item.mdwEquipGroup != this._actor.equips()[1].mdwEquipGroup) return false;
  364.     if (this._slotId === 1 && this._actor.equips()[0] && item.mdwEquipGroup != this._actor.equips()[0].mdwEquipGroup) return false;
  365.     return this._actor.canEquip(item);
  366. };
  367.  
  368.  
  369. Game_Actor.prototype.optimizeEquipments = function() {
  370.     var maxSlots = this.equipSlots().length;
  371.     this.clearEquipments();
  372.     this.setWeapons();
  373.     for (var i = 2; i < maxSlots; i++) {
  374.         if (this.isEquipChangeOk(i)) {
  375.             this.changeEquip(i, this.bestEquipItem(i));
  376.         }
  377.     }
  378. };
  379.  
  380. Game_Actor.prototype.setWeapons = function() {
  381.     var mode = 1;
  382.     if (this.currentClass().meta.handnshld) mode = 2;
  383.     if (this.currentClass().meta.monkeygrip) mode = 3;
  384.     //First weapon selection
  385.     if (mode == 1 || mode == 2) {
  386.         var items = $gameParty.equipItems().filter(function(item) {
  387.         return item.etypeId === 1 && this.canEquip(item) && !item.meta.shld;
  388.     }, this);
  389.     }
  390.     if (mode == 3) {
  391.         var items = $gameParty.equipItems().filter(function(item) {
  392.         return item.etypeId === 1 && this.canEquip(item);
  393.     }, this);
  394.     }
  395.     var mainW1 = this.bestEquipW(items);
  396.     //End first weapon
  397.     //Second Weapon Selection (First sub)
  398.     if (mode == 1) {
  399.         var newItems = $gameParty.equipItems().filter(function(item) {
  400.         return item.etypeId === 1 && this.canEquip(item) && item != mainW1 && !item.meta.twohand && !item.meta.mainWeaponOnly;
  401.     }, this);
  402.     }
  403.     if (mode == 2) {
  404.         var newItems = $gameParty.equipItems().filter(function(item) {
  405.         return item.etypeId === 1 && this.canEquip(item) && item != mainW1  && !item.meta.twohand && item.meta.shld && !item.meta.mainWeaponOnly;
  406.     }, this);
  407.     }
  408.     if (mode == 3) {
  409.         var newItems = $gameParty.equipItems().filter(function(item) {
  410.         return item.etypeId === 1 && this.canEquip(item) && item != mainW1;
  411.     }, this);
  412.     }
  413.     var subW1 = this.bestEquipW(newItems);
  414.     //End Second
  415.     //Third weapon selection (Second Main)
  416.     var subW2 = null;
  417.     if (mode == 1 || mode == 2) {
  418.     items = $gameParty.equipItems().filter(function(item) {
  419.         return item.etypeId === 1 && this.canEquip(item) && !item.meta.shld && !item.meta.twohand && item != mainW1 && item != subW1;
  420.     }, this);
  421.     var subW2 = this.bestEquipW(items);
  422.     }
  423.     //End Third
  424.     if (subW2 !== null) {
  425.     if(this.potential(mainW1) > this.potential(subW1) + this.potential(subW2)) {
  426.     if (this.isEquipChangeOk(0)) this.changeEquip(0, mainW1);
  427.     } else {
  428.     if (this.isEquipChangeOk(0)) this.changeEquip(0, subW2);
  429.     if (this.isEquipChangeOk(1) && subW1 && (subW2.mdwEquipGroup == subW1.mdwEquipGroup)) this.changeEquip(1, subW1);
  430.     }
  431.     } else {
  432.     if (this.isEquipChangeOk(0)) this.changeEquip(0, mainW1);
  433.     if (this.isEquipChangeOk(1) && subW1 && (mainW1.mdwEquipGroup == subW1.mdwEquipGroup)) this.changeEquip(1, subW1);
  434.     }
  435. }
  436.  
  437. Game_Actor.prototype.bestEquipW = function(itemSet) {
  438.     var items = itemSet;
  439.     var bestItem = null;
  440.     var bestPerformance = -1000;
  441.     for (var i = 0; i < items.length; i++) {
  442.         var performance = this.potential(items[i]);
  443.         if (performance > bestPerformance) {
  444.             bestPerformance = performance;
  445.             bestItem = items[i];
  446.         }
  447.     }
  448.     return bestItem;
  449. };
  450.  
  451. MalBestEquip = Game_Actor.prototype.bestEquipItem
  452. Game_Actor.prototype.bestEquipItem = function(slotId) {
  453.     var etypeId = this.equipSlots()[slotId];
  454.     var items = $gameParty.equipItems().filter(function(item) {
  455.         return item.etypeId === etypeId && this.canEquip(item);
  456.     }, this);
  457.     var bestItem = null;
  458.     var bestPerformance = -1000000;
  459.     for (var i = 0; i < items.length; i++) {
  460.         var performance = this.potential(items[i]);
  461.         if (performance > bestPerformance) {
  462.             bestPerformance = performance;
  463.             bestItem = items[i];
  464.         }
  465.     }
  466.     return bestItem;
  467. };
  468.  
  469. Game_Actor.prototype.potential = function(item) {
  470. if (item === null) return 0;
  471. var potent = item.meta.PotentialP || 0;
  472. for (var i = 0; i < 8; i++) {
  473.         potent += item.params[i] * (Mal.power[i] / 100);
  474.     }
  475. potent = Math.round(potent);
  476. return potent;
  477. };
  478.  
  479. //Addition for shop scene
  480. var malShop_drawParamChange = Window_ShopStatus.prototype.drawActorParamChange;
  481. Window_ShopStatus.prototype.drawActorParamChange = function(x, y, actor, item1) {
  482.     if (Mal.Parameters['PotentialPointsInShop'] == 1) {
  483.     var width = this.contents.width - this.textPadding() - x;
  484.     var change = this.potential(this._item) - (item1 ? this.potential(item1) : 0);
  485.     this.changeTextColor(this.paramchangeTextColor(change));
  486.     this.drawText((change > 0 ? '+' : '') + change, x, y, width, 'right');
  487.     } else {
  488.     malShop_drawParamChange.call(this, x, y, actor, item1);
  489.     }
  490. };
  491.  
  492. Window_ShopStatus.prototype.potential = function(item) {
  493. if (item === null) return 0;
  494. var potent = item.meta.PotentialP || 0;
  495. for (var i = 0; i < 8; i++) {
  496.         potent += item.params[i] * (Mal.power[i] / 100);
  497.     }
  498. potent = Math.round(potent);
  499. return potent;
  500. };
  501. //End Shop Scene
  502.  
  503. var MalItemList = Window_ItemList.prototype.includes
  504. Window_ItemList.prototype.includes = function(item) {
  505.     switch (this._category) {
  506.     case 'item':
  507.         return DataManager.isItem(item) && item.itypeId === 1;
  508.     case 'weapon':
  509.         if (Mal.Parameters['ShieldsArmor'] == 1){
  510.         return DataManager.isWeapon(item) && !item.meta.shld;
  511.         } else{
  512.         return DataManager.isWeapon(item);
  513.         }
  514.     case 'armor':
  515.     if (Mal.Parameters['ShieldsArmor'] == 1){
  516.         return DataManager.isArmor(item) || (item && item.meta.shld);
  517.         } else {
  518.         return DataManager.isArmor(item);
  519.         }
  520.     case 'keyItem':
  521.         return DataManager.isItem(item) && item.itypeId === 2;
  522.     default:
  523.         return false;
  524.     }
  525. };
  526.  
  527. var MalSlotName = Window_EquipSlot.prototype.slotName
  528. Window_EquipSlot.prototype.slotName = function(index) {
  529.     var slots = this._actor.equipSlots();
  530.     if (index === 1 && this._actor.isDualWield()) return this._actor ? Mal.Parameters['OffhandSlotName'] : '';
  531.     return this._actor ? $dataSystem.equipTypes[slots[index]] : '';
  532. };
  533.  
  534. var MalDrawItem = Window_ItemList.prototype.drawItem
  535. Window_ItemList.prototype.drawItem = function(index) {
  536.     var item = this._data[index];
  537.     var setting = 0;
  538.     if (typeof Window_AugmentItemList != "undefined") {
  539.         if (this instanceof Window_AugmentItemList) setting++;
  540.     }
  541.     if (item) {
  542.         var numberWidth = this.numberWidth();
  543.         var rect = this.itemRect(index);
  544.         rect.width -= this.textPadding();
  545.         this.changePaintOpacity(this.isEnabled(item));
  546.         this.drawItemName(item, rect.x, rect.y, rect.width - numberWidth);
  547.         this.drawItemNumber(item, rect.x, rect.y, rect.width);
  548.         this.changePaintOpacity(1);
  549.     } else {
  550.         var numberWidth = this.numberWidth();
  551.         var rect = this.itemRect(index);
  552.         rect.width -= this.textPadding();
  553.         if (setting == 0) this.drawText('-UNEQUIP-', rect.x, rect.y, rect.width - numberWidth);
  554.     }
  555. };
  556. Window_ShopStatus.prototype.initialize = function(x, y, width, height) {
  557.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  558.     this._item = null;
  559.     this._maxCharPages = null;
  560.     this._characterPage = this.setupCharPages();
  561.     this._pageIndex = 0;
  562.     this.refresh();
  563. };
  564.  
  565. Window_ShopStatus.prototype.setupCharPages = function() {
  566.     if (this._maxCharPages === null) {
  567.     var count = this.statusMembers().length;
  568.     if (count < 2) return -2;
  569.     this._maxCharPages = count - 1;
  570.     this._cursorFixed = false;
  571.     return -1;
  572.     }
  573. };
  574.  
  575. Window_ShopStatus.prototype.refresh = function() {
  576.     this.contents.clear();
  577.     this._cursorFixed = true;
  578.     if (!this._maxCharPages) this._characterPage = this.setupCharPages();
  579.     if (this._item) {
  580.         var x = this.textPadding();
  581.         this.drawPossession(x, 0);
  582.         if (this.isEquipItem()) {
  583.             this.drawEquipInfo(x, this.lineHeight() * 2);
  584.         }
  585.     }
  586. };
  587.  
  588. Window_ShopStatus.prototype.updatePage = function() {
  589.     if (this.isPageChangeEnabled() && this.isPageChangeRequested()) {
  590.         this.changePage();
  591.     }
  592.     if (this.isCharPageChangeEnabled() && this.isCharPageChangeRequested()) {
  593.         if (Input.isTriggered('left')) {
  594.             this.changeCharPage("L");
  595.         } else {
  596.             this.changeCharPage("R");
  597.         }
  598.         this.refresh();
  599.            
  600.     }
  601. };
  602.  
  603. Window_ShopStatus.prototype.isCharPageChangeEnabled = function() {
  604.     return (this._characterPage != -2 && this.visible && this.isEquipItem());
  605. };
  606.  
  607. Window_ShopStatus.prototype.isCharPageChangeRequested = function() {
  608.     if (Input.isTriggered('left') || Input.isTriggered('right')) {
  609.         return true;
  610.     }
  611.     if (TouchInput.isTriggered() && this.isTouchedInsideFrame()) {
  612.         return true;
  613.     }
  614.     return false;
  615. };
  616.  
  617. Window_ShopStatus.prototype.changeCharPage = function (dir) {
  618. var code = 1;
  619. SoundManager.playCursor();
  620. if (dir === "L") code = 0;
  621. if(code == 0) {
  622.     this._characterPage--;
  623.     if(this._characterPage == -2) this._characterPage = this._maxCharPages;
  624. }
  625. if(code == 1) {
  626.     this._characterPage++;
  627.     if(this._characterPage > this._maxCharPages) this._characterPage = -1;
  628. }
  629.         this.refresh();
  630. };
  631.  
  632. Window_ShopStatus.prototype.drawEquipInfo = function(x, y) {
  633.     var members = this.statusMembers();
  634.     if(this._characterPage == -2) {
  635.         this.drawActorEquipInfoSingle(x, y + this.lineHeight() * (0 * 2.4), members[0]);
  636.     } else if (this._characterPage == -1){
  637.         for (var i = 0; i < members.length; i++) {
  638.             this.drawActorEquipInfo(x, y + this.lineHeight() * (i * 2.4), members[i]);
  639.         }
  640.     } else this.drawActorEquipInfoSingle(x, y + this.lineHeight() * (0 * 2.4), members[this._characterPage]);
  641. };
  642.  
  643. Window_ShopStatus.prototype.drawActorEquipInfoSingle = function(x, y, actor) {
  644.   var enabled = actor.canEquip(this._item);
  645.   var paramHeight = 0;
  646.   this.changePaintOpacity(enabled);
  647.   this.resetTextColor();
  648.   this.drawText(actor.name(), x, y, 168);
  649.   var item1 = this.currentEquippedItem(actor, this._item.etypeId);
  650.   if (enabled) {
  651.     paramHeight = this.drawActorParamChangeSingle(x, y, actor, item1);
  652.   }
  653.   this.drawItemName(item1, x, y + (paramHeight || this.lineHeight()));
  654.   this.changePaintOpacity(true);
  655. };
  656.  
  657. Window_ShopStatus.prototype.drawActorParamChangeSingle = function(x, y, actor, item1) {
  658.   var width = this.contents.width - this.textPadding() - x;
  659.   var change = 0;
  660.   var lines = 0;
  661.   var actorParam = 0;
  662.   var paramName = ['MHP', 'MMP', 'ATK', 'DEF', 'MAT', 'MDF', 'AGI', 'LUK'];
  663.  
  664.   for (var id = 0; id < paramName.length; id++) {
  665.     change = this._item.params[id] - (item1 ? item1.params[id] : 0);
  666.     if (item1) {
  667.         if (this.doublewielding(actor) && DataManager.isWeapon(item1)) {
  668.         if(item1 === actor.equips()[0]) var item2 = actor.equips()[1];
  669.         if(item1 === actor.equips()[1]) var item2 = actor.equips()[0];
  670.         }
  671.         if(this._item.meta.twohand && item2) change -= item2.params[id];
  672.         if (item1.etypeId !== this._item.etypeId && item1.id !== this._item.id) {
  673.         actorParam = this._item.params[id] > 0 ? actor.param(id) - this._item.params[id] : actor.param(id) + this._item.params[id];
  674.       } else {
  675.         actorParam = actor.param(id);
  676.       }
  677.     } else {
  678.       actorParam = actor.param(id);
  679.     }
  680.     this.changeTextColor(this.paramchangeTextColor(change));
  681.     if (change == 0) {
  682.         this.drawText((change > 0 ? '+' : '') + '  ' + ' ' + paramName[id] + ' ' + (actorParam + change), x, y + lines, width, 'right');
  683.     } else {
  684.         this.drawText((change > 0 ? '+' : '') + change + ' ' + paramName[id] + ' ' + (actorParam + change), x, y + lines, width, 'right');
  685.     };
  686.     lines += this.lineHeight();
  687.   }
  688.  
  689.   return lines;
  690. };
  691.  
  692. Window_ShopStatus.prototype.currentEquippedItem = function(actor, etypeId) {
  693.     var list = [];
  694.     var equips = actor.equips();
  695.     var slots = actor.equipSlots();
  696.     for (var i = 0; i < slots.length; i++) {
  697.         if (slots[i] === etypeId) {
  698.         if (i < 2 && $dataClasses[actor._classId].meta.monkeygrip) {
  699.             list.push(equips[i]);
  700.         } else {
  701.             if (i == 0 && !this.ignoreWeap1(actor)) list.push(equips[i]);
  702.             if (i == 1 && !this.ignoreWeap2(actor)) list.push(equips[i]);
  703.         }
  704.         if (i >= 2) list.push(equips[i]);
  705.         }
  706.     }
  707.     var paramId = this.paramId();
  708.     var worstParam = Number.MAX_VALUE;
  709.     var worstItem = null;
  710.     for (var j = 0; j < list.length; j++) {
  711.         if (!list[j]) {
  712.           return null;
  713.         }
  714.         if (list[j] && list[j].params[paramId] < worstParam) {
  715.             worstParam = list[j].params[paramId];
  716.             worstItem = list[j];
  717.         }
  718.     }
  719.     return worstItem;
  720. };
  721.  
  722. Window_ShopStatus.prototype.ignoreWeap1 = function (actor) {
  723.  
  724.     if (this._item.meta.twohand && !actor.equips()[0]) return true;
  725.     if (this._item.meta.shld && !this.dualwielding(actor)) return true;
  726.     if (this._item.meta.shld && actor.equips()[1] && actor.equips()[1].meta.shld) return true;
  727.     if (this.dualwielding(actor) && !actor.equips()[0]) return true;
  728.     return false;
  729. };
  730.  
  731. Window_ShopStatus.prototype.ignoreWeap2 = function (actor) {
  732.  
  733.     if (!actor.equips()[0]) return false;
  734.     if (this.dualwielding(actor)) return true;
  735.     if (this._item.meta.mainWeaponOnly) return true
  736.     if (this._item.meta.twohand && actor.equips()[0] && !actor.equips()[0].meta.twohand) return true;
  737.     return false;
  738.    
  739. };
  740.  
  741. Window_ShopStatus.prototype.dualwielding = function (actor) {
  742.  
  743.     if(actor.equips()[0] && actor.equips()[0].meta.twohand) return true;
  744.     if(actor.equips()[1] && actor.equips()[1].meta.twohand) return true;
  745.     return false;
  746. };
  747.  
  748. Window_ShopStatus.prototype.doublewielding = function (actor) {
  749.  
  750.     if(actor.equips()[0] && actor.equips()[1]) return true;
  751.     return false;
  752. };
  753.  
  754. var MalDualBuyWindow = Scene_Shop.prototype.createBuyWindow
  755. Scene_Shop.prototype.createBuyWindow = function() {
  756.     MalDualBuyWindow.call(this);
  757.     this._buyWindow.setHandler('left',     this.cycleLeft.bind(this));
  758.     this._buyWindow.setHandler('Menu',     this.cycleRight.bind(this));
  759. };
  760.  
  761. Scene_Shop.prototype.cycleLeft = function () {
  762. this._statusWindow.changeCharPage("L");
  763. };
  764.  
  765. Scene_Shop.prototype.cycleRight = function () {
  766. this._statusWindow.changeCharPage("R");
  767. };
  768.  
  769. var MalparamPlus = Game_Actor.prototype.paramPlus
  770. Game_Actor.prototype.paramPlus = function(paramId) {
  771.     var value = Game_Battler.prototype.paramPlus.call(this, paramId);
  772.     var equips = this.equips();
  773.     for (var i = 0; i < equips.length; i++) {
  774.         var item = equips[i];
  775.         if (item) {
  776.             if (i == 1) {
  777.             if (item.meta.OffhandAdjust) {
  778.             value += (item.params[paramId] * item.meta.OffhandAdjust / 100) ;
  779.             } else {
  780.                 value += (item.params[paramId] * Mal.Parameters['OffhandAdjust'] / 100) ;
  781.                 }} else {
  782.                 value += item.params[paramId];
  783.                 }
  784.         }
  785.     }
  786.     return value;
  787. };
  788.  
  789. Game_Actor.prototype.attackAnimationId2 = function() {
  790.     var weapons = this.weapons();
  791.     if (weapons[1] && weapons[1].meta.subweapon) return 0;
  792.     return weapons[1] ? weapons[1].animationId : 0;
  793. };
  794.  
  795.  
  796. var MalGame_Actor_allTraits = Game_Actor.prototype.allTraits;
  797. Game_Actor.prototype.allTraits = function() {
  798.     var traits = MalGame_Actor_allTraits.call(this);
  799.     var equips = this.equips();
  800.     for (var i = 0; i < equips.length; i++) {
  801.         var item = equips[i];
  802.         if(item) {
  803.             if (i == 0 && item.mainWTraits) traits = traits.concat(item.mainWTraits);
  804.             if (i == 1 && item.subWTraits) traits = traits.concat(item.subWTraits);
  805.             if(item.doubleGripTraits && this.isDoubleGripping()) traits = traits.concat(item.doubleGripTraits);
  806.         }
  807.     }
  808.     return traits;
  809. };
  810.  
  811.  
  812. Game_Actor.prototype.isDoubleGripping = function() {
  813.     var equips = this.equips();
  814.     return (this.hasDoubleGrip() && ((equips[0] && !equips[1]) || (equips[1] && !equips[0])));
  815. };
  816.  
  817. Game_Actor.prototype.hasDoubleGrip = function() {
  818.     if (this.currentClass().note.indexOf("<doubleGrip>") > -1) return true;
  819.     var equips = this.equips();
  820.     for (var i = 0; i < equips.length; i++) {
  821.         if (equips[i] && equips[i].note.indexOf("<doubleGrip>") > -1) return true;
  822.     }
  823.     var states = this.states();
  824.     for (var i = 0; i < states.length; i++) {
  825.         if (states[i].note.indexOf("<doubleGrip>") > -1) return true;
  826.     }
  827.     return false;
  828. }
  829.  
  830. Game_Actor.prototype.isWeaponEquipped = function(type) {
  831. if (type) {
  832. var type = Number(type);
  833. } else {
  834. var type = 0;
  835. }
  836. if (type == 0){
  837.     if (this.equips()[0]) {
  838.         if (this.equips()[1]) return 2;
  839.         return 0;
  840.     }
  841.     if (this.equips()[1]) return 1;
  842.     return -1;
  843. } else {
  844.     if (this.equips()[0] && this.equips()[0].wtypeId == type) {
  845.         if (this.equips()[1] && this.equips()[1].wtypeId == type) return 2;
  846.         return 0;
  847.     }
  848.     if (this.equips()[1] && this.equips()[1].wtypeId == type) return 1;
  849.     return -1;
  850. }
  851. };
  852.  
  853. Game_Enemy.prototype.isWeaponEquipped = function(type) {
  854. return -1;
  855. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement