lohenien

Veteran
Veteran
Joined
Mar 15, 2012
Messages
153
Reaction score
8
First Language
english
//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?
 
Last edited by a moderator:

orcomarcio

Veteran
Veteran
Joined
Nov 26, 2015
Messages
106
Reaction score
22
First Language
Italian
I never go to deal with these specific part of the code but maybe i can help, but i need a couple of clarifications:
1) what the bug is exactely? it doesnt' elt u equip 2 one-handed weapons?
2) what is this line of code about?

slots[1] = 1;why puts a value 1 un the second slot?

3) What does "this.isDualWield()" return? if the weapong in dual wieldable or if the player can dual wield?

4) What doeas this mean? (sealed??)

Code:
this.isEquipTypeSealed(item.etypeId)
 
Last edited by a moderator:

lohenien

Veteran
Veteran
Joined
Mar 15, 2012
Messages
153
Reaction score
8
First Language
english
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.
 

orcomarcio

Veteran
Veteran
Joined
Nov 26, 2015
Messages
106
Reaction score
22
First Language
Italian
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 :p

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
 
Last edited by a moderator:

orcomarcio

Veteran
Veteran
Joined
Nov 26, 2015
Messages
106
Reaction score
22
First Language
Italian
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..
 
Last edited by a moderator:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,839
Reaction score
14,502
First Language
English
Primarily Uses
RMMV
orcomarcio, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.


If you have more to add, please just edit your last post instead of posting multiple times in succession.


OP, I haven't heard of this issue before. Do you have to equip them in a certain order?
 
Last edited by a moderator:

orcomarcio

Veteran
Veteran
Joined
Nov 26, 2015
Messages
106
Reaction score
22
First Language
Italian
Sry for the double post I will not do that again :p

About the Dual Wielding problem, i came out with the code that will do the work :D , 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 :p ), 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
 

lohenien

Veteran
Veteran
Joined
Mar 15, 2012
Messages
153
Reaction score
8
First Language
english
Shaz, yes you have to equip them in a certain order - the one handed weapon that enables dual wielding 1st (the weapon doesnt have to unlock dual wield, any skill/item that enables dual wielding will do) and it allows you to equip a second weapon in your other hand. The second weapon could be something that uses traits to seal shields and seal dual wielding but you can still equip it and it doesn't force you to unequip the original weapon.

orcomarcio - I'm not looking for a plugin fix, those exist already. I'm actually trying to understand how the default game code behaves such that it allows this 'bug' to occur.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,839
Reaction score
14,502
First Language
English
Primarily Uses
RMMV
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.
 

Prizm Daystar

Social Butt
Veteran
Joined
Nov 22, 2015
Messages
80
Reaction score
19
First Language
English
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.

The weird thing is that I tried this when I was using classes and/or actors with dual wielding, and it simply removed the weapon that had the "Seal Equip: Weapon" ability.

The way that I had to work around this is to not have d-w classes / actors, and instead put d-w on certain weapons, but then this probably ends up leading into the 3-handed problem of this thread to begin with...

My first project had one character doing things 4-handed.  I didn't even know what I was doing wrong...
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,846
Reaction score
1,605
First Language
English
Primarily Uses
RMMV
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?
 

okugi

Villager
Member
Joined
Oct 27, 2015
Messages
28
Reaction score
6
First Language
English
Why not make all classes dual wield by default, then simply grant you 2 h weapons the seal dual wield, seal shield, etc, traits?
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,846
Reaction score
1,605
First Language
English
Primarily Uses
RMMV
Ah, already fixed it using this:



<Custom Equip Requirement Condition>
 if (user.isDualWield()) {
   condition = false;
 } else {
   condition = true;
 }
</Custom Equip Requirement Condition>
 

Kikeluzi

Paladin
Veteran
Joined
Nov 18, 2015
Messages
50
Reaction score
26
First Language
Portuguese - Br
Primarily Uses
RMMV
Ah, already fixed it using this:



<Custom Equip Requirement Condition>
if (user.isDualWield()) {
condition = false;
} else {
condition = true;
}
</Custom Equip Requirement Condition>

My hero don't use cape!!!
(Or he uses... I don't know...)
 

Latest Threads

Latest Profile Posts

MythicRuss wrote on gothicvoid's profile.
hi, i was looking thru ur awesome stuff, and was looking around the internet, how in the heckin heck do i get the hiddendoors to open? im addng them to the doors event but they just appear as solid walls, btw am total noob lol
currently working on some template sprites and tweaking the walk cycle :)
Lunee.jpg
Early try to draw our Demon Countess, who destroyed her own soul leaving just an empty shell of a body - until our heroine unwillingly takes possession of it, every time she falls asleep.
(I know it’s a premade face from the Dark Fantasy Set, but I spent so much time with her, that I can’t bring myself to change the sprite anymore xD)
I finished setting up my new desk and apparently she thinks this is where she goes now.

20210411_082331.jpg

Forum statistics

Threads
110,305
Messages
1,052,147
Members
143,335
Latest member
claanxy
Top