More weapon requirements for skills

I wanted to create a warrior class with a lot of different physical skills, depending on the weapon he uses. But I felt that choosing two different weapons as a requirement for the skill wasn't enough. With Yanflys Weapon Mastery Passive (Tips and Tricks) as inspiration and Skill Core plugin I came up with a solution.

So for anyone who was looking for something like this or maybe for those who didn't know they could need it.

Spoiler: Code
<Custom Requirement>
// Get all currently equipped weapons for the user.
var weapons = user.weapons();
// Set the weapon types to use the skill with. In this case weapon types 1 to 6.
var fav = [1,2,3,4,5,6];
// Set the initial condition to be false.
value = false;
// Loop through each of the weapons.
for (var i = 0; i < weapons.length; ++i) {
// Get the currently looped weapon.
var weapon = weapons;
// Check if the weapon exists and if the weapon type ID is in the array of required weapons.
if (fav.indexOf(weapon && weapon.wtypeId) !== -1) {
// Set the condition to be true.
value = true;
// Break the loop.
break;
}
}
</Custom Requirement>

This could be useful if the warrior has some melee aswell as ranged skills (with bows for example). He could now use his melee skills only with all the melee weapons and the ranged skills only with all the ranged weapons ingame.
I typed your code in skill notebox, edited only red one for my one-handed, two-handed weapon types. (1,2,3,4 for one-handed weapon skill and 5,6,7 for two-handed weapon skill). but sadly it turns out skill can't be used even my characters has correct weapon equipped.

My weapon type list:
1,2,3,4 = Dagger, Sword, Axe, Mace.
5,6,7 = Greatsword, Greataxe, Warhammer.
8,9 (No prob with that) = Staff, Bow.
@imdb55
Notetags have exactly zero function unless they're read by a plugin - and that notetag above is no exception.
So if it didn't work, either the plugin didn't work or something in the skill is not correct.

If the solution isn't as simple as you forgetting to install the plugin, please give screenshots of both the skill and your plugin manager so that we can check for your mistake.
@Andar

Here's the Notetags for my Whrilwind(One-hand Skill) and Cleave(Two-hand Skill)
Sorry for copy/pasting

Spoiler: Whrilwind (One-hand)
<Custom Requirement>

var weapons = user.weapons();

var fav = [1,2,3,4];

value = false;

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

var weapon = weapons;

if (fav.indexOf(weapon && weapon.wtypeId) !== -1) {

value = true;

break;

}

}

</Custom Requirement>

Spoiler: Cleave (Two-hand)
<Custom Requirement>

var weapons = user.weapons();

var fav = [5,6,7];

value = false;

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

var weapon = weapons;

if (fav.indexOf(weapon && weapon.wtypeId) !== -1) {

value = true;

break;

}

}

</Custom Requirement>

Or the SkillCore Plugin is outdated so I may download the newer one?
20170326235610_1.jpg
and as a lot of people do, you mixed up the order of your yanfly plugins - please reorder them according to yanfly's website and start a new game after reordering.
At minimum your skill core is at the wrong position (it needs to follow the item core), so there is no surprise that you have problems with your skills. Other plugins might be in thew wrong order as well, I didn't check everything and the screenshot doesn't show all your plugins either)
I reordered ItemCore and SkillCore sections and try to run BattleTest. But still unusable though. Or something wrong with my script?

And here's the rest of my plugins list you ask for (I using HIMEwork's too).
20170327031007_1.jpg
20170327031041_1.jpg
20170327030835_1.jpg
I suggest you make your own topic for finding that bug, instead of using this one - it is more complex.
In that new topic, please link here, give the screenshots of the plugin manager again and also give the screenshots of the skills (the full data, I wasn't interested in the notebox only when I asked above)
I found the bug in this code.

Just replace this:
// Get the currently looped weapon.
var weapon = weapons;

With this:
// Get the currently looped weapon.
var weapon = weapons[i ];

(the [i ] is without space, the bbcode editor parses it text formatting)

And it works perfectly for me.
I hope it helps for anybody who read this topic and trying to solve this problem. ^^
BUG!!!!
I found a mistake related to the enemies. If you give skill to the enemy.
upload_2017-9-29_15-6-7.png
Using YEP Skill Core i have found a more simple formula for the Weapon Type equipped that it worked for me:

<Custom Requirement>
if (user.isWtypeEquipped(1)
|| user.isWtypeEquipped(2)
|| user.isWtypeEquipped(3)
|| user.isWtypeEquipped(12)
|| user.isWtypeEquipped(17)
|| user.isWtypeEquipped(38)) {
value = true;
} else {
value = false;
}
</Custom Requirement>

For add more weapon type simply add one more || user.isWtypeEquipped(#)
Or remove it for less requrement.

I hope is useful to somebody!

EDIT: The first formula that i have posted i have figure that not work very well when i tink first.

BUG!!!!
I found a mistake related to the enemies. If you give skill to the enemy.View attachment 72870
I think is because the enemies doesn't wield a weapon ; )

And sorry if i had some error language but i'm not english ^^

Original thread: https://forums.rpgmakerweb.com/threads/more-weapon-requirements-for-skills.74609/