Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // Maliki's Dual Weilding/Two-Handed Weapons MZ Version
- // MalMZDualWield.js
- // version 1.3cMZ
- //=============================================================================
- /*:
- * @target MZ
- *
- * @plugindesc ver1.3cMZ - Allows you to set weapons as twohanded, disallowing you from equipping weapons to the Off-hand.
- * @author Maliki79
- * @param ShieldsArmor
- * @desc Type 1 to place Shield weapons in Menu Screens' Armor category.
- * Default: 0
- * @default 0
- *
- * @param MustUseMain
- * @desc Type 1 to force equips to be placed in Main hand before they can be placed in Off hand.
- * Default: 0
- * @default 0
- *
- * @param OffhandAdjust
- * @desc Percentage of stats offhand weapons add to actors. (Make the number lower than 100 to lower stats and higher to raise)
- * Default: 100
- * @default 100
- *
- * @param OffhandSlotName
- * @desc Name used for offhand weapon slot.
- * Default: Off-Hand
- * @default Off-Hand
- *
- * @param ShowTraitsInConsole
- * @desc Type 1 to show trait code,dataId and value data on console upon item equip.
- * Default: 0
- * @default 0
- *
- * @param PowerAdjustement0
- * @desc Amount of "weight" given to HP when determining strength of weapons as a percent.
- * Default: 100
- * @default 100
- *
- * @param PowerAdjustement1
- * @desc Amount of "weight" given to MP when determining strength of weapons as a percent.
- * Default: 100
- * @default 100
- *
- * @param PowerAdjustement2
- * @desc Amount of "weight" given to ATK when determining strength of weapons as a percent.
- * Default: 100
- * @default 100
- *
- * @param PowerAdjustement3
- * @desc Amount of "weight" given to DEF when determining strength of weapons as a percent.
- * Default: 100
- * @default 100
- *
- * @param PowerAdjustement4
- * @desc Amount of "weight" given to M.ATK when determining strength of weapons as a percent.
- * Default: 100
- * @default 100
- *
- * @param PowerAdjustement5
- * @desc Amount of "weight" given to M.DEF when determining strength of weapons as a percent.
- * Default: 100
- * @default 100
- *
- * @param PowerAdjustement6
- * @desc Amount of "weight" given to AGI when determining strength of weapons as a percent.
- * Default: 100
- * @default 100
- *
- * @param PowerAdjustement7
- * @desc Amount of "weight" given to LUK when determining strength of weapons as a percent.
- * Default: 100
- * @default 100
- *
- * @param PotentialPointsInShop
- * @desc Shows Equipment "Potential" as a point total in shops. Make this value 1 to enable, otherwise, the default calculations will be used.
- * Default: 1
- * @default 1
- *
- * @param 2H_DisableOtherSlot
- * @desc If 1, equipping a 2Handed Weapon will completely disable the other equip slot.
- * default: 0
- * @default 0
- *
- * @param Matched_Equip_Omit_Traits
- * @desc If 1, double equip traits will be the only plugin provided traits exhibited. Main and Sub traits will be omitted.
- * default: 0
- * @default 0
- *
- * @help You need two steps to use this plugin:
- * 1: Set your actor(s) up to have Dual-Wield in the Database. TRAITS => EQUIP => SLOT TYPE => DUAL WIELD
- * 2: Add the Notetag <twohand> to any two handed weapons in your Database.
- * 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.
- * 3a: Conversly, if you tag a weapon with <mainWeaponOnly> , it will only be equippable on the main hand.
- * 4: (Optional) For one handed Actors you wish to equip shields that are considered weapons in the DB, tag <handnshld>
- * to the Actor's Class notes. (Those Actors still need to have the Dual Wield trait.)
- * 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.
- * 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.
- * 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.
- * 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.
- * Weapons with the Mainweapon tag will exhibit those traits ONLY while in the main weapon slot while supweapon tagged weapons will exhibit
- * thier traits while in the off hand only.
- * 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.
- * When one tagged weapon is equipped and while the actor has the <doubleGrip> tag on either class notes or an applied state's notes,
- * the double grip traits will be applied to the actor.
- * 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
- * calculations. Usful if things other than raw stats are used and will factor into the potential score of equipment in your project.
- *
- * Notes on main/sub/double-grip weapon traits:
- * Codes are the number representation of traits as they appear in the database.
- * Trait codes are listed below:
- * 11-TRAIT_ELEMENT_RATE 41-TRAIT_STYPE_ADD 61-TRAIT_ACTION_PLUS
- * 12-TRAIT_DEBUFF_RATE 42-TRAIT_STYPE_SEAL 62-TRAIT_SPECIAL_FLAG
- * 13-TRAIT_STATE_RATE 43-TRAIT_SKILL_ADD 63-TRAIT_COLLAPSE_TYPE
- * 14-TRAIT_STATE_RESIST 44-TRAIT_SKILL_SEAL 64-TRAIT_PARTY_ABILITY
- * 21-TRAIT_PARAM 51-TRAIT_EQUIP_WTYPE
- * 22-TRAIT_XPARAM 52-TRAIT_EQUIP_ATYPE
- * 23-TRAIT_SPARAM 53-TRAIT_EQUIP_LOCK
- * 31-TRAIT_ATTACK_ELEMENT 54-TRAIT_EQUIP_SEAL
- * 32-TRAIT_ATTACK_STATE 55-TRAIT_SLOT_TYPE
- * 33-TRAIT_ATTACK_SPEED
- * 34-TRAIT_ATTACK_TIMES
- *
- * 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.
- * The numbers here can vary based on the quantity of things in your database and what code is being used.
- *
- * 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%,
- * you would use the value 1.2, which is 120%.
- * The final tag for this example would be: <subweaponTrait: 21, 2, 1.2>
- *
- * A method to assist with finding the code, dataId and value figures lies in the ShowTraitsInConsole param. Setting it to 1
- * will allow the console to print out an array of normal traits on an equipped item on the moment it is equipped.
- * (Press F12 to open the console by default.)
- * 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
- * equip with the traits you want and note what their values are via the console.
- * (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.)
- *
- * A "potential" value has been introduced.
- * This value is a combination of the default stats of a weapon with differing user defined "weights" for each one.
- * This value is used mainly for the choosing of weapons when optimizing.
- *
- * A script call has been added to aid those wishing to know which equip slot is housing what equip type.
- * Using the script call $gameActors.isWeaponEquipped(type) will return a number based on the defined type
- * (type is the weapon type ID in the database.)
- * 0 if in the first equip slot,
- * 1 if it's in the second,
- * 2 if it's in both,
- * and -1 if in neither.
- * You can omit the type arguement and the function will return those numbers if there is ANY weapon is equipped in those slots.
- *
- * Equip Groups have been added!
- * Tag weapon equips and shield type armor equips with this tag in thier notes:
- *
- * <mdwEquipGroup: x> with x being an integer higher than 0.
- * If an equip has this tag, it will only be able to be dual wielded with other equips with the same group number.
- * <doubleEquipTrait: x, y, z> Use this tag paired with setting an equip group. If two equips with matching equip group sets
- * number are equipped together, the traits created will be exhibited.
- * Remember that a matching mdwEquipGroup tag MUST exist on the items for the trait to be seen.
- * <syncTrait: x, y, z> If two equips are the same in the database, the traits created will be exhibited.
- * Using the plugin Param Matched_Equip_Omit_Traits, the only traits shown will be the double equip or sync traits.
- * Main or Sub weapon traits will not be used when those traits are active. (Other traits provided by different plugins and the database WILL
- * still be active.)
- *
- * Added Dual Groups. You can specify any number of groups to give specific sets of weapon equips traits.
- * First, add the equip to groups by adding this notetag:
- *
- * <duGroup: x>
- *
- * With x being any interger above 0.
- * You can add as many copies of this tag as you need to give a single equip multiple group numbers.
- * Then use the following notetag to assign traits to each group:
- *
- * <dualGroupTrait: a, x, y, z>
- *
- * Noting the extra a interger which will match one of your group numbers.
- * You can make a = 0 to make that trait activate whenever a group is formed.
- *
- * Now, if you equip two weapons with the same group number, those group triats will be added to the PC
- * (Again, the 0 group traits will also be added)
- * If you equip two of the same item, those traits will only be counted once.
- *
- * Note about param ShieldsArmor
- * The ShieldsArmor param allows devs to make it so offhand only weapons show up as armor in default item Menu.
- * For those that wish for some offhand weapons to remain in the Weapon category while still using the param,
- * use the notetag <offHWeapon> to create an exception and have that weapon show up in the weapon category.
- */
- var Mal = Mal || {};
- Mal.Parameters = PluginManager.parameters('MalMZDualWield');
- Mal.Param = Mal.Param || {};
- Mal.power = [];
- Mal.power.push(Number(Mal.Parameters['PowerAdjustement0']));
- Mal.power.push(Number(Mal.Parameters['PowerAdjustement1']));
- Mal.power.push(Number(Mal.Parameters['PowerAdjustement2']));
- Mal.power.push(Number(Mal.Parameters['PowerAdjustement3']));
- Mal.power.push(Number(Mal.Parameters['PowerAdjustement4']));
- Mal.power.push(Number(Mal.Parameters['PowerAdjustement5']));
- Mal.power.push(Number(Mal.Parameters['PowerAdjustement6']));
- Mal.power.push(Number(Mal.Parameters['PowerAdjustement7']));
- Mal.Par2HLock = Number((Mal.Parameters['2H_DisableOtherSlot']))
- var MalDualDatabaseLoad = DataManager.isDatabaseLoaded;
- DataManager.isDatabaseLoaded = function() {
- if (!MalDualDatabaseLoad.call(this)) return false;
- if (!DataManager._malDual_DatabaseLoaded) {
- this.processDualNotetags($dataWeapons);
- this.processDualNotetags($dataArmors);
- DataManager._malDual_DatabaseLoaded = true;
- }
- return true;
- };
- DataManager.processDualNotetags = function(group) {
- for (var n = 1; n < group.length; n++) {
- var obj = group[n];
- obj.mdwEquipGroup = -1;
- obj.syncNum = obj.id;
- obj.dualGroup = [];
- obj.dualGroupTraits = [];
- this.createDualTraits(obj);
- }
- };
- DataManager.createDualTraits = function(obj) {
- var traits = [];
- var noteread = obj.note;
- while(noteread.indexOf("mainweaponTrait") > -1)
- {
- var notereg = noteread.split("<mainweaponTrait: ");
- var match = notereg[1].split(", ");
- var match2 = match[2].split(">");
- match2 = match2[0];
- traits.push({"code": parseInt(match[0]), "dataId": parseInt(match[1]), "value": Number(match2)});
- noteread = noteread.replace("<mainweaponTrait: ", " ");
- }
- obj.mainWTraits = traits;
- traits = [];
- while(noteread.indexOf("subweaponTrait") > -1)
- {
- var notereg = noteread.split("<subweaponTrait: ");
- var match = notereg[1].split(", ");
- var match2 = match[2].split(">");
- match2 = match2[0];
- traits.push({"code": parseInt(match[0]), "dataId": parseInt(match[1]), "value": Number(match2)});
- noteread = noteread.replace("<subweaponTrait: ", " ");
- }
- obj.subWTraits = traits;
- traits = [];
- while(noteread.indexOf("doubleGripTrait") > -1)
- {
- var notereg = noteread.split("<doubleGripTrait: ");
- var match = notereg[1].split(", ");
- var match2 = match[2].split(">");
- match2 = match2[0];
- traits.push({"code": parseInt(match[0]), "dataId": parseInt(match[1]), "value": Number(match2)});
- noteread = noteread.replace("<doubleGripTrait: ", " ");
- }
- obj.doubleGripTraits = traits;
- traits = [];
- while(noteread.indexOf("doubleEquipTrait") > -1)
- {
- var notereg = noteread.split("<doubleEquipTrait: ");
- var match = notereg[1].split(", ");
- var match2 = match[2].split(">");
- match2 = match2[0];
- traits.push({"code": parseInt(match[0]), "dataId": parseInt(match[1]), "value": Number(match2)});
- noteread = noteread.replace("<doubleEquipTrait: ", " ");
- }
- obj.doubEquTraits = traits;
- traits = [];
- while(noteread.indexOf("syncTrait") > -1)
- {
- var notereg = noteread.split("<syncTrait: ");
- var match = notereg[1].split(", ");
- var match2 = match[2].split(">");
- match2 = match2[0];
- traits.push({"code": parseInt(match[0]), "dataId": parseInt(match[1]), "value": Number(match2)});
- noteread = noteread.replace("<syncTrait: ", " ");
- }
- obj.syncTraits = traits;
- traits = [];
- while(noteread.indexOf("dualGroupTrait") > -1)
- {
- var notereg = noteread.split("<dualGroupTrait: ");
- var match = notereg[1].split(", ");
- var match2 = match[3].split(">");
- match2 = match2[0];
- var DSGroup = parseInt(match[0]);
- obj.dualGroupTraits[DSGroup] = obj.dualGroupTraits[DSGroup] || [];
- obj.dualGroupTraits[DSGroup].push({"code": parseInt(match[1]), "dataId": parseInt(match[2]), "value": Number(match2)});
- noteread = noteread.replace("<dualGroupTrait: ", " ");
- }
- traits = [];
- while(noteread.indexOf("duGroup") > -1)
- {
- var match = noteread.split("<duGroup: ");
- var match2 = match[1].split(">");
- obj.dualGroup = obj.dualGroup || []
- obj.dualGroup.push(parseInt(match2[0]));
- noteread = noteread.replace("<duGroup: ", " ");
- }
- obj.PotentialP = 0;
- while(noteread.indexOf("<PotentialP:") > -1)
- {
- var notereg = noteread.split("<PotentialP: ");
- var match = notereg[1].split("> ");
- obj.PotentialP = parseInt(match[0]);
- noteread = noteread.replace("<PotentialP:", " ");
- };
- if(noteread.indexOf("mdwEquipGroup") > -1) {
- var notereg = noteread.split("<mdwEquipGroup: ");
- var match = parseInt(notereg[1]);
- obj.mdwEquipGroup = match;
- }
- };
- var MalEquipChangeOK = Game_Actor.prototype.isEquipChangeOk
- Game_Actor.prototype.isEquipChangeOk = function(slotId) {
- if (this.twohanding > -1 && Mal.Par2HLock == 1) {
- if (this.twohanding == 0 && slotId == 1) return false;
- if (this.twohanding == 1 && slotId == 0) return false;
- }
- return MalEquipChangeOK.call(this, slotId);
- };
- var MalOnSlotOK = Scene_Equip.prototype.onItemOk
- Scene_Equip.prototype.onItemOk = function() {
- if (this._slotWindow.index() === 0 && !(this._itemWindow.item()) && (this._actor.equips()[1] && Mal.Parameters['MustUseMain'] == 1)) {
- SoundManager.playBuzzer();
- }else {
- SoundManager.playEquip();
- this.actor().changeEquip(this._slotWindow.index(), this._itemWindow.item());
- if (this._itemWindow.item() && Mal.Parameters['ShowTraitsInConsole'] == 1) console.log(this._itemWindow.item().traits);
- }
- this._slotWindow.activate();
- this._slotWindow.refresh();
- this._itemWindow.deselect();
- this._itemWindow.refresh();
- this._statusWindow.refresh();
- this._slotWindow.show();
- this._itemWindow.hide();
- this._slotWindow.select(this._slotWindow.index());
- };
- Game_Actor.prototype.changeEquip = function(slotId, item) {
- if (this.tradeItemWithParty(item, this.equips()[slotId]) &&
- (!item || this.equipSlots()[slotId] === item.etypeId)) {
- this._equips[slotId].setObject(item);
- if (slotId == 0) {
- var slot = 1;
- } else {
- var slot = 0;
- }
- if (slotId < 2) {
- if (item && item.meta.twohand && !this.currentClass().meta.monkeygrip) {
- this.tradeItemWithParty(null, this.equips()[slot])
- this._equips[slot].setObject(null);
- }
- if (item && this.equips()[slot] && this.equips()[slot].meta.twohand && !this.currentClass().meta.monkeygrip){
- this.tradeItemWithParty(null, this.equips()[slot])
- this._equips[slot].setObject(null);
- }
- if (Mal.Parameters['MustUseMain'] == 1 && !this.equips()[0] && this.equips()[1]){
- if(!this.equips()[1].meta.shld) this._equips[0].setObject(this.equips()[1]);
- this._equips[1].setObject(null);
- }
- }
- this.check2Hand();
- this.refresh();
- }
- };
- Game_Actor.prototype.check2Hand = function() {
- this.twohanding = -1;
- var equip = this.equips()[0];
- if (equip && equip.meta.twohand && !this.currentClass().meta.monkeygrip) this.twohanding = 0;
- var equip = this.equips()[1];
- if (equip && equip.meta.twohand && !this.currentClass().meta.monkeygrip) this.twohanding = 1;
- };
- Game_Actor.prototype.forceChangeEquip = function(slotId, item) {
- if (item) {
- this._equips[slotId].setObject(item);
- if (slotId == 0) {
- var slot = 1;
- } else {
- var slot = 0;
- }
- if (slotId < 2) {
- if (item && item.meta.twohand && !this.currentClass().meta.monkeygrip) {
- this._equips[slot].setObject(null);
- }
- if (item && this.equips()[slot] && this.equips()[slot].meta.twohand && !this.currentClass().meta.monkeygrip){
- this._equips[slot].setObject(null);
- }
- if (Mal.Parameters['MustUseMain'] == 1 && !this.equips()[0] && this.equips()[1]){
- this._equips[0].setObject(this.equips()[1]);
- this._equips[1].setObject(null);
- }
- }
- } else {
- this._equips[slotId].setObject(null);
- }
- this.releaseUnequippableItems(true);
- this.check2Hand();
- this.refresh();
- };
- var MalreleaseUnEI = Game_Actor.prototype.releaseUnequippableItems;
- Game_Actor.prototype.releaseUnequippableItems = function(forcing) {
- MalreleaseUnEI.call(this, forcing);
- this.check2Hand();
- };
- var MalEquip = Window_EquipItem.prototype.includes
- Window_EquipItem.prototype.includes = function(item) {
- if (item === null) {
- if (this._slotId === 0 && (this._actor.equips()[1] && Mal.Parameters['MustUseMain'] == 1)){
- return;
- } else {
- return true;
- }}
- if (this._slotId === 0 && item.meta.shld && this._actor.currentClass().meta.monkeygrip) {
- return this._actor.canEquip(item);
- }
- if (this._slotId === 0 && item.meta.shld) {
- return false;
- }
- if (this._slotId === 1 && !(item.meta.shld) && this._actor.currentClass().meta.handnshld) {
- return false;
- }
- if (this._slotId === 1 && !(this._actor.equips()[0]) && Mal.Parameters['MustUseMain'] == 1 ) {
- return false;
- }
- if (this._slotId === 1 && item.meta.mainWeaponOnly) {
- return false;
- }
- if (this._slotId < 0 || item.etypeId !== this._actor.equipSlots()[this._slotId]) {
- return false;
- }
- if (this._slotId === 0 && this._actor.equips()[1] && item.mdwEquipGroup != this._actor.equips()[1].mdwEquipGroup) return false;
- if (this._slotId === 1 && this._actor.equips()[0] && item.mdwEquipGroup != this._actor.equips()[0].mdwEquipGroup) return false;
- return this._actor.canEquip(item);
- };
- Game_Actor.prototype.optimizeEquipments = function() {
- var maxSlots = this.equipSlots().length;
- this.clearEquipments();
- this.setWeapons();
- for (var i = 2; i < maxSlots; i++) {
- if (this.isEquipChangeOk(i)) {
- this.changeEquip(i, this.bestEquipItem(i));
- }
- }
- };
- Game_Actor.prototype.setWeapons = function() {
- var mode = 1;
- if (this.currentClass().meta.handnshld) mode = 2;
- if (this.currentClass().meta.monkeygrip) mode = 3;
- //First weapon selection
- if (mode == 1 || mode == 2) {
- var items = $gameParty.equipItems().filter(function(item) {
- return item.etypeId === 1 && this.canEquip(item) && !item.meta.shld;
- }, this);
- }
- if (mode == 3) {
- var items = $gameParty.equipItems().filter(function(item) {
- return item.etypeId === 1 && this.canEquip(item);
- }, this);
- }
- var mainW1 = this.bestEquipW(items);
- //End first weapon
- //Second Weapon Selection (First sub)
- if (mode == 1) {
- var newItems = $gameParty.equipItems().filter(function(item) {
- return item.etypeId === 1 && this.canEquip(item) && !(item == mainW1 && $gameParty.oneOfAKind(mainW1)) && !item.meta.twohand && !item.meta.mainWeaponOnly;
- }, this);
- }
- if (mode == 2) {
- var newItems = $gameParty.equipItems().filter(function(item) {
- return item.etypeId === 1 && this.canEquip(item) && !(item == mainW1 && $gameParty.oneOfAKind(mainW1)) && !item.meta.twohand && item.meta.shld && !item.meta.mainWeaponOnly;
- }, this);
- }
- if (mode == 3) {
- var newItems = $gameParty.equipItems().filter(function(item) {
- return item.etypeId === 1 && this.canEquip(item) && !(item == mainW1 && $gameParty.oneOfAKind(mainW1));
- }, this);
- }
- var subW1 = this.bestEquipW(newItems);
- //End Second
- //Third weapon selection (Second Main)
- var subW2 = null;
- if (mode == 1 || mode == 2) {
- items = $gameParty.equipItems().filter(function(item) {
- return item.etypeId === 1 && this.canEquip(item) && !item.meta.shld && !item.meta.twohand && !(item == mainW1 && $gameParty.oneOfAKind(mainW1)) && !(item == subW1 && $gameParty.oneOfAKind(subW1));
- }, this);
- var subW2 = this.bestEquipW(items);
- }
- //End Third
- if (subW2 !== null) {
- if(this.potential(mainW1) > this.potential(subW1) + this.potential(subW2)) {
- if (this.isEquipChangeOk(0)) this.changeEquip(0, mainW1);
- if (!mainW1.meta.twohand) this.changeEquip(1, subW2);
- } else {
- if (this.isEquipChangeOk(0)) this.changeEquip(0, subW2);
- if (this.isEquipChangeOk(1) && subW1 && (subW2.mdwEquipGroup == subW1.mdwEquipGroup)) this.changeEquip(1, subW1);
- }
- } else {
- if (this.isEquipChangeOk(0)) this.changeEquip(0, mainW1);
- if (this.isEquipChangeOk(1) && subW1 && (mainW1.mdwEquipGroup == subW1.mdwEquipGroup)) this.changeEquip(1, subW1);
- }
- }
- Game_Party.prototype.oneOfAKind = function (item) {
- if(this.numItems(item) == 1) return true;
- return false;
- };
- Game_Actor.prototype.bestEquipW = function(itemSet) {
- var items = itemSet;
- var bestItem = null;
- var bestPerformance = -1000;
- for (var i = 0; i < items.length; i++) {
- var performance = this.potential(items[i]);
- if (performance > bestPerformance) {
- bestPerformance = performance;
- bestItem = items[i];
- }
- }
- return bestItem;
- };
- var MalBestEquip = Game_Actor.prototype.bestEquipItem
- Game_Actor.prototype.bestEquipItem = function(slotId) {
- const etypeId = this.equipSlots()[slotId];
- const items = $gameParty
- .equipItems()
- .filter(item => item.etypeId === etypeId && this.canEquip(item));
- let bestItem = null;
- let bestPerformance = -1000;
- for (let i = 0; i < items.length; i++) {
- //const performance = this.calcEquipItemPerformance(items[i]);
- const performance = this.potential(items[i]);
- if (performance > bestPerformance) {
- bestPerformance = performance;
- bestItem = items[i];
- }
- }
- return bestItem;
- };
- Game_Actor.prototype.potential = function(item) {
- if (!item) return -1001;
- var potent = item.PotentialP;
- var potent2 = Number(item.params.reduce((a, b) => a + b));
- return potent + potent2;
- };
- var MalItemList = Window_ItemList.prototype.includes
- Window_ItemList.prototype.includes = function(item) {
- switch (this._category) {
- case 'item':
- return DataManager.isItem(item) && item.itypeId === 1;
- case 'weapon':
- if (Mal.Parameters['ShieldsArmor'] == 1){
- return DataManager.isWeapon(item) && (!item.meta.shld || item.meta.offHWeapon);
- } else{
- return DataManager.isWeapon(item);
- }
- case 'armor':
- if (Mal.Parameters['ShieldsArmor'] == 1){
- return DataManager.isArmor(item) || (item && item.meta.shld && !item.meta.offHWeapon);
- } else {
- return DataManager.isArmor(item);
- }
- case 'keyItem':
- return DataManager.isItem(item) && item.itypeId === 2;
- default:
- return false;
- }
- };
- var MalSlotName = Window_StatusBase.prototype.actorSlotName
- Window_StatusBase.prototype.actorSlotName = function(actor, index) {
- var slots = this._actor.equipSlots();
- if (index === 1 && this._actor.isDualWield()) return this._actor ? Mal.Parameters['OffhandSlotName'] : '';
- return $dataSystem.equipTypes[slots[index]];
- };
- var MalparamPlus = Game_Actor.prototype.paramPlus
- Game_Actor.prototype.paramPlus = function(paramId) {
- var value = Game_Battler.prototype.paramPlus.call(this, paramId);
- var equips = this.equips();
- for (var i = 0; i < equips.length; i++) {
- var item = equips[i];
- if (item) {
- if (i == 1) {
- if (item.meta.OffhandAdjust) {
- value += (item.params[paramId] * item.meta.OffhandAdjust / 100) ;
- } else {
- value += (item.params[paramId] * Mal.Parameters['OffhandAdjust'] / 100) ;
- }} else {
- value += item.params[paramId];
- }
- }
- }
- return value;
- };
- Game_Actor.prototype.attackAnimationId2 = function() {
- var weapons = this.weapons();
- if (weapons[1] && weapons[1].meta.subweapon) return 0;
- return weapons[1] ? weapons[1].animationId : 0;
- };
- var MalGame_Actor_allTraits = Game_Actor.prototype.allTraits;
- Game_Actor.prototype.allTraits = function() {
- var traits = MalGame_Actor_allTraits.call(this);
- var equips = this.equips();
- var syncFlag = false;
- var matchFlag = false;
- var dualFlag = false;
- if (this.hasMatchedEquip()) {
- traits = traits.concat(equips[0].doubEquTraits);
- traits = traits.concat(equips[1].doubEquTraits);
- matchFlag = true;
- }
- if (this.useSyncTrait()) {
- traits = traits.concat(equips[0].syncTraits);
- syncFlag = true;
- }
- if (this.useDuoTrait()) {
- var dGrp1 = equips[0].dualGroup;
- var dGrp2 = equips[1].dualGroup;
- for (var i = 0; i < dGrp1.length; i++) {
- var point = dGrp1[i];
- if (dGrp2.contains(point)) {
- if(equips[0].dualGroupTraits[point]) {
- traits = traits.concat(equips[0].dualGroupTraits[point]);
- dualFlag = true;
- }
- if(equips[1].dualGroupTraits[point]) {
- if (equips[0].syncNum == equips[1].syncNum) continue;
- traits = traits.concat(equips[1].dualGroupTraits[point]);
- dualFlag = true;
- }
- }
- if(equips[0].dualGroupTraits[0]) {
- traits = traits.concat(equips[0].dualGroupTraits[0]);
- dualFlag = true;
- }
- if(equips[1].dualGroupTraits[0]) {
- if (equips[0].syncNum == equips[1].syncNum) continue;
- traits = traits.concat(equips[1].dualGroupTraits[0]);
- dualFlag = true;
- }
- }
- }
- if (Mal.Parameters['Matched_Equip_Omit_Traits'] == 1 && (matchFlag || syncFlag || dualFlag)) {
- //Do Nothing
- } else {
- for (var i = 0; i < equips.length; i++) {
- var item = equips[i];
- if(item) {
- if (i == 0 && item.mainWTraits) traits = traits.concat(item.mainWTraits);
- if (i == 1 && item.subWTraits) traits = traits.concat(item.subWTraits);
- if(item.doubleGripTraits && this.isDoubleGripping()) traits = traits.concat(item.doubleGripTraits);
- }
- }
- }
- return traits;
- };
- Game_Actor.prototype.hasMatchedEquip = function() {
- var equips = this.equips();
- if (!equips[0] || !equips[1]) return false;
- if (equips[0] && equips[0].mdwEquipGroup != -1) return false;
- if (equips[1] && equips[1].mdwEquipGroup != -1) return false;
- return (((equips[0] && equips[0].doubEquTraits) && (equips[1] && equips[1].doubEquTraits)) && equips[0].mdwEquipGroup != -1 && (equips[0].mdwEquipGroup == equips[1].mdwEquipGroup));
- return false;
- };
- Game_Actor.prototype.useSyncTrait = function() {
- var equips = this.equips();
- return (((equips[0] && equips[0].syncTraits) && (equips[1] && equips[1].syncTraits)) && (equips[0].syncNum == equips[1].syncNum));
- return false;
- };
- Game_Actor.prototype.useDuoTrait = function() {
- var equips = this.equips();
- return ((equips[0] && equips[0].dualGroup != []) && (equips[1] && equips[1].dualGroup != []));
- return false;
- };
- Game_Actor.prototype.isSameWeapon = function() {
- var equips = this.equips();
- if (equips[0] && equips[1]) return (equips[0].syncNum == equips[1].syncNum);
- return false;
- };
- Game_Actor.prototype.isDoubleGripping = function() {
- var equips = this.equips();
- return (this.hasDoubleGrip() && ((equips[0] && !equips[1]) || (equips[1] && !equips[0])));
- };
- Game_Actor.prototype.hasDoubleGrip = function() {
- if (this.currentClass().note.indexOf("<doubleGrip>") > -1) return true;
- var equips = this.equips();
- for (var i = 0; i < equips.length; i++) {
- if (equips[i] && equips[i].note.indexOf("<doubleGrip>") > -1) return true;
- }
- var states = this.states();
- for (var i = 0; i < states.length; i++) {
- if (states[i].note.indexOf("<doubleGrip>") > -1) return true;
- }
- return false;
- }
- Game_Actor.prototype.isWeaponEquipped = function(type) {
- if (type) {
- var type = Number(type);
- } else {
- var type = 0;
- }
- if (type == 0){
- if (this.equips()[0]) {
- if (this.equips()[1]) return 2;
- return 0;
- }
- if (this.equips()[1]) return 1;
- return -1;
- } else {
- if (this.equips()[0] && this.equips()[0].wtypeId == type) {
- if (this.equips()[1] && this.equips()[1].wtypeId == type) return 2;
- return 0;
- }
- if (this.equips()[1] && this.equips()[1].wtypeId == type) return 1;
- return -1;
- }
- };
- Game_Enemy.prototype.isWeaponEquipped = function(type) {
- return -1;
- };
Add Comment
Please, Sign In to add comment