YEP CUSTOM PASSIVE CONDITION

Please help. Copy and pasted this snippet of code from the Yanfly tips and tricks page to check to make sure a certain weapon is equipped. However when I set everything up it only applies the bonus atk and doesn't actually check the equipped weapons.

Spoiler: CODE
<Custom Passive Condition>

var weapons = user.weapons();

var 1 Hand Sword = 1;

condition = false;

for (var i = 0; i < weapons.length; ++i) {

var weapon = weapons;

if (weapon && weapon.wtypeId === 1 Hand Sword) {

condition = true;

break;

}
}

Spoiler: CODE
</Custom Passive Condition>
You're using Yanfly's Passive states plugins I see. I'm assuming you put the passive state on the actor, and want an attack bonus only if they equip a certain weapon or weapon type.
If you want the passive active for a certain weapon only:
JavaScript:
<Custom Passive Condition>
  if (user.hasWeapon($dataWeapons[1])) {
condition = true;
  } else {
    condition = false;
  }
</Custom Passive Condition>
And change the [1] to whatever the weapon ID is in your database.
If you want the passive active for a certain weapon TYPE - so any time the actor has a Sword equipped for example - use:
JavaScript:
<Custom Passive Condition>
if(user.isWtypeEquipped(1)) {
condition = true;
} else {
condition = false;
}
</Custom Passive Condition>
This time, change the [1] to whatever the weapon type ID is in your database. This works even on dual-wielding weapons. If one of those weapons is that type ID, the passive is active.
Let me know if that does what you want!
Thanks so much! The one YF wrote wasn't working right for what i needed. This was a big help!
Thanks so much! The one YF wrote wasn't working right for what i needed. This was a big help!

@mods this is solved.
Code:
<Custom Passive Condition>
if(user.isWtypeEquipped(1)) {
condition = true;
} else {
condition = false;
}
</Custom Passive Condition>
Sorry to necro here, but any idea what the equivalent syntax for armor would be here? I can tell you that isAtypeEquipped(x) does not seem to work.

EDIT: If you find the "isWtypeEquipped" function in rpg_objects.js and simply copy that function and replace every instance in the function of "weapon" with "armor" and "weapons" with "armors" and finally "wtype" with "atype", then name the new function isAtypeEquipped, it will then properly function with the same code above. Weird that this wasn't default code, no?
Weird that this wasn't default code, no?
Not really - it typically doesn't matter. The equipped weapon type is used to determine what animation and graphics are displayed when the actor attacks in combat. Nothing in the engine cares whether you're wearing a piece of leather armor as opposed to plate mail.

Original thread: https://forums.rpgmakerweb.com/threads/yep-custom-passive-condition.121956/