Skills requiring shield usage

If I use this,

<Custom Requirement>
value = false;
for (i = ; i < user._equips.length; i++) {
if (user._equips._dataClass == 'armor' && user._equips._itemId == 1) value = true;
}
</Custom Requirement>


Does that make the skill ONLY usable when they have that singular item equipped?

For example, I'd like the character to only be able to use 'Shield Bash' when a shield is equipped.

But I'm unsure of how to code that in.

I thought I could do it using Yanfly's Skill core but i get confused on Notetags -_-
Well, I know this isint a coding related answer to your question, but personally I would just give the shield equipment an attribute in the database that adds the skill when equipped. When unequipped, I believe it should no longer be available. Is that like what you were going for?

EDIT: ...assuming that you are using the default turn based battle system.
I would try this:

<Custom Requirement>
value = user.equips()[1].atypeId === "shield type ID"
</Custom Requirement>

This code assumes that the shield is equipped in the second equipment slot and that shields are considered an armor type in the Systems tab. If that's not the case, the code may need a bit of tweaking.
Well, I know this isint a coding related answer to your question, but personally I would just give the shield equipment an attribute in the database that adds the skill when equipped. When unequipped, I believe it should no longer be available. Is that like what you were going for?

EDIT: ...assuming that you are using the default turn based battle system.

So I had multiple characters using’ shield’ but I realized the White Mage character and black Mage character equips the small shield and the main hero can equip all shields.

I just gave the Main Hero only the Large Shields and they all add the skill now


I would try this:

<Custom Requirement>
value = user.equips()[1].atypeId === "shield type ID"
</Custom Requirement>

This code assumes that the shield is equipped in the second equipment slot and that shields are considered an armor type in the Systems tab. If that's not the case, the code may need a bit of tweaking.

I did try this but it doesn’t seem to want to work, so I just used the above method.
The way I'd do it, which is much simpler, is simply to give the shield equipment the Add Skill: Shield Bash feature in their features box. The only reason I can think of that this wouldn't fit your needs is if you want to require the player has already learned Shield Bash thru levels or skill-learn events first, in order for it to be available when shields are equip.

If you do need that, then I'd recommend using a Custom Show Eval rather than a Custom Requirement. And while your javascript lines look close, they are definitely not correct. You have a set operator without an expression on the right-hand side when you say i = ; this needs to be i = 0; and you never use i in the evaluation - my guess is that you need to say equips[0] rather than equips in both places you use it. This might or might not get you there; checking equips is always tough and I'm much more used to the way it's handled in Ace.

One more thing, @Zakarijah - please don't double post. If you need to quote multiple posts, there's a Multi-Quote function (click the "+ Quote" action on the posts, and then click the button that says Insert Quotes right below your post entry box). I've merged your posts together for you this time.
I did try this but it doesn’t seem to want to work, so I just used the above method.

The code wouldn't be identical to what I typed. 'Shield Type ID' would have to be replaced by the ID of the Armor Type. So if the shield Armor Type is 2, the code would be:

<Custom Requirement>
value = user.equips()[1].atypeId === 2;
</Custom Requirement>

Original thread: https://forums.rpgmakerweb.com/threads/skills-requiring-shield-usage.113257/