//default codeGame_BattlerBase.prototype.canEquipWeapon = function(item) { return this.isEquipWtypeOk(item.wtypeId) && !this.isEquipTypeSealed(item.etypeId);};//proposed changeGame_BattlerBase.prototype.canEquipWeapon = function(item) { if this.isEquipTypeSealed(item.etypeId) return false; else return this.isEquipWtypeOk(item.wtypeId); };//alternately maybe it's this code?Game_Actor.prototype.equipSlots = function() { var slots = []; for (var i = 1; i < $dataSystem.equipTypes.length; i++) { slots.push(i); } if (slots.length >= 2 && this.isDualWield()) { slots[1] = 1; } return slots;};//proposed change if !this.isEquipTypeSealed(item.etypeId){ (slots.length >= 2 && this.isDualWield()) { slots[1] = 1; }}I'm trying to sort out where in the base code the dual wield option goes wrong and allows you to equip a weapon in one hand that lets you dual wield and another weapon that seals the dual wield option.
I'm not sure if this is the correct code bit to blame. I'm also not super familiar with javascript (I'm a c++ guy) so I'm not sure if my syntax is good.
Does anyone know the actual offending code for this issue?
I did explain the bug: if you equip one item that lets you dual wield and one that should be "2 handed" it basically lets you have "3 hands" per se. As for the specific code bits, I'm not 100% sure how they function, which is why I posted here. With a proper understanding of what those code pieces do it should be a simple matter to adjust them to fix the issue.
So let me understand, YOU created the dual wielding type right? I don't think there's already.
If so, you modified the equipments types like this right?
1h weapon
2h weapon
shield
amror
etc..
And you don't the game to let you wield a 2h weapon while you have a 1h equipped right?
EDIT: Ok, since I dont' use the default battle system I didn't know there was a built-in dual wielding system, I know what's your problem, basically RMMV doesn't distinguish between 1h and 2h weapons, those are all just weapons for the code, if you want to have 1h and 2h weapons you have to specify that. You can do that in 2 ways:
1) choosing that some weapons are by default 1 or 2 handed in the code. This is not optimal because you have to specify this behaviour via code and not through the database.
2) put a piece of text in the description that defines if the weapon is 2h or 2h. This is the best methond in my opinion because u can modify a specific weapon without a long runaround in the code, also this way the player can se if hte weapon is 1h or 2h ni the description. I'll tell you later how to do that i'm gonna eat now 😛
3) Create specific weapon types, like Sword 1h or Axe 2h. This works as well as option 2 but u have to do a couple of things to make it work, I'll explain you later which if this is the way you want to go with
First of all, in a js plugin file of yours, put this function that I created to find if a piece of string is contained in another one:
// Returns true when the first string given contains // the second oneUtils.String_in_String = function(container, inlcuded) { if (~container.indexOf(inlcuded)) return true; else return false;};You can just use this line "~container.indexOf(inlcuded)" but I prefer to have a function for that for order reasons, but both ways are equally ok. From now on anyway I'll use my method to acheive the resutl, if you want to use the other methond you can swap the lines.
So, now we have to chose the keywords to put in the description (or in the notes if you dont' the player to able to read it, but it might aswell know if the weapon in 2 or 1 handed) to identify either types, since those strings will be constants they will be written in upper case letter (it's a common agreement, best to use but not strictly necessary)
// remember, you can't start a variable name witha numbervar ONE_HANDED_KEYWORD = '1 Hand'; //you can choose the keyword u want obviouslyvar TWO_HANDED_KEYWORD = '2 Hands';Continued..
Sry for the double post I will not do that again 😛
About the Dual Wielding problem, i came out with the code that will do the work 😀 , it's not the most elegant piece of code and may have some issues in very specific situations ( i'm not familiar with the functions I played with so a sloppy command could have an unexpected effect with the right conditions, but I'm pretty optimistic), anyway it works for the tests I've done, so here it is:
// My personal keyword check function:// Returns true when the first string given contains // the second oneUtils.String_in_String = function(container, inlcuded) { if (~container.indexOf(inlcuded)) return true; else return false;};// Keywords for 1h and 2h//you can choose the keywords u wantvar ONE_HANDED_KEYWORD = '1 Hand'; var TWO_HANDED_KEYWORD = '2 Hands';// Modified pre-existing functionGame_Actor.prototype.changeEquip = function(slotId, item) { if (this.tradeItemWithParty(item, this.equips()[slotId]) && (!item || this.equipSlots()[slotId] === item.etypeId)) { if (this.isDualWield() && (slotId == 0 || slotId ==1) && !(item === null)) { var other_slot = 1 - slotId; var description = item.description; if (Utils.String_in_String(description, ONE_HANDED_KEYWORD)) { if (slotId == 0) { // equip 1h weapon in the first slot this._equips[slotId].setObject(item); } else if (this.equips()[0] !== null && Utils.String_in_String(this.equips()[0].description , TWO_HANDED_KEYWORD)) { // if you equip a 1h weapon in the second slot clears the the first slot if there is a 2h weapon if (this.isEquipChangeOk(0)) { this.changeEquip(0, null); this._equips[1].setObject(item); } } else { // equip 1h weapon in the slot if no 2h weapon is equipped this._equips[slotId].setObject(item); } } else if (Utils.String_in_String(description, TWO_HANDED_KEYWORD)) { // equips 2 hands weapon in the first slot and clears the second one if (this.isEquipChangeOk(0) && this.isEquipChangeOk(1)) { if (!(this._equips[1] === null)) $gameParty.gainItem(this._equips[1], 1, true); this.changeEquip(other_slot, null); this._equips[1].setObject(null); this._equips[0].setObject(item); $gameParty.allItems() } } else throw new Error("weapon type (1 or 2 handed) is not specified. Weapon: " + item.name); // throws an error if weapon type i not specified } else { // executed if it's not a weapon or character doesn't have dual wielding this._equips[slotId].setObject(item); } this.refresh(); }}; Put this lines into your plugin file (remembet to add the plug-in and put it on 😛 ), then change the tag for 1h and 2h weapons to put in the description of ALL the weapons (otherwise gives you an error), put either tag in every weapon description (ex. 1 Hand).
Remember that:
1) you can put the tag in the note rather than the descriprion, but u have to change all the "descriprion" in the code in "note" and remember to tell someway to the player if the weapon is either 1 or 2 handed
2) you can decide that u don't have to specify one of the 2 types, so the code checks like only "1 Hands" and if doesn't find it it makes the weapon 2 handed. If you want this to be the case tell me because the script should be modified
I suspect it probably just doesn't check to see what combination of weapons you have and whether you have two features that negate each other. If you equip a weapon that seals the weapon slot, it should automatically unequip any other weapon that's currently held.
Bump. I also have this 3-handed issue. My one-handed weapons grant dual wield, which adds 2nd weapons slot, but the player can still equip a 2h weapon in that 2nd slot. Is there some sort of way to make the actor unequip the 1st weapon if they try to equip a 2h? or remove the dual wield trait?
Why not make all classes dual wield by default, then simply grant you 2 h weapons the seal dual wield, seal shield, etc, traits?
Ah, already fixed it using this:
<Custom Equip Requirement Condition>
if (user.isDualWield()) {
condition = false;
} else {
condition = true;
}
</Custom Equip Requirement Condition>