Preventing a weapon wield if an armor type is equipped

Hi all!

I have a weapon that can't be worn over gloves, so I'd like to prevent wielding it if the actor has gloves on.

I feel like I'm close -- I have a plugin that permits me to run common events on wield, and they work perfectly. So I'm using the following to check if gloves are worn:

Code:
!!$gameActors.actor(1).equips()[5]

I know this works from testing elsewhere, and the [5] is correct to the gloves slot.

But once I check for that in a Conditional Branch, well, that's where I'm stuck. The hacky thing to do would be to force an unequip of the weapon if the gloves check comes back positive. But that's a very wonky solution since we will hear the equip and unequip sounds, and besides, I'm not sure how to script the unequip at the moment.

I feel like there must be a solution to this that simply prevents the wield in the first place if this slot of equipment is populated.

Any thoughts or nudges would be super appreciated as always, you folks are the best :LZSgrin:
I'd personally use Yanfly's Equip Requirements for this.
Though I am sure there are free alternativea out there if you don't have that.
I'd personally use Yanfly's Equip Requirements for this.
Though I am sure there are free alternativea out there if you don't have that.

I purchased this plugin a while back with the full collection, but looking at its help text, I'm still unsure how I might provide specific worn equip slot as a condition to prevent wielding.

I'll report this thread to move it to plugin support, but @eomereolsson if you would be able to advise more specifically, that would be amazing.

Thanks!
To clarify -- the Yanfly plugin provides for a switch condition. So, a weapon can only be equipped if a switch is on.

That means I do technically have a solution -- I could set a switch to be on at the beginning of the game, and turn the switch off every time the player equips a pair of gloves.

That sounds good as a "if all else fails" solution, but it would represent a large amount of work in my project's case. So in the event there's a cleaner way to make use of this plugin, I'd love to know!
The Lunatic Mode section is what you're looking for.

"For those with JavaScript proficiency, you can use these notetags to give
certain pieces of equipment a special requirement before it can be equipped.

Weapon and Armor Notetags:

<Custom Equip Requirement Condition>
Your code here
</Custom Equip Requirement Condition>
The 'condition' variable will determine whether or not the piece of
equipment can be worn by the user. If 'condition' returns 'true', then the
piece of equipment can be worn. If 'condition' returns 'false', then the
piece of equipment can't be worn."

I don't know the correct code offhand, as JS still isn't my area of expertise, but if you can set up code to see if your Glove armor slot has anything in it, that will solve your problem.
I’ve this this thread over to Javascript/Plugin Support.

cuby, please avoid double posting, as it is against the forum rules. You can use the "Edit" function on your posts to add additional information you've forgotten or respond to multiple people. You can review our forum rules here. Thank you.
The Lunatic Mode section is what you're looking for.

"For those with JavaScript proficiency, you can use these notetags to give
certain pieces of equipment a special requirement before it can be equipped.

Weapon and Armor Notetags:

<Custom Equip Requirement Condition>
Your code here
</Custom Equip Requirement Condition>
The 'condition' variable will determine whether or not the piece of
equipment can be worn by the user. If 'condition' returns 'true', then the
piece of equipment can be worn. If 'condition' returns 'false', then the
piece of equipment can't be worn."

I don't know the correct code offhand, as JS still isn't my area of expertise, but if you can set up code to see if your Glove armor slot has anything in it, that will solve your problem.
Code:
if (user.equips()[5]){
condition = false
} else {
condition = true
}

If the user has something in his gloves slot, the weapon cannot be equipped, otherwise it can be.
-make the one weapon, and all like it, it's own weapon type.
-make a state with the clause "equip weapon", and allow that weapon type.
-make another state that "resist state" that other state.
-put the resistance state as a property on the gloves.
-put a common event or a post-transfer event constantly adding that "equip weapon" state to the player.

if the player has the gloves on, the resistance will block the allowance to use that weapon.
if not, the engine will land that allowance state on the player enabling them to use the weapon.

no plugins.
-put the resistance state as a property on the gloves.
...
no plugins.
Maybe I'm misunderstanding what you mean, but how can you do that with no plugins? I don't know of a way to put a state on equipment without using a plugin like Yanfly's Auto Passive States.
@ATT_Turan you don't.... I slipped off on that one.
what I mean is, use the state resist property on the item itself, to pop the other state added by the transfer (or, update, or common event)
it's a double negation of negatives... as long as you tie the allowance of it to a state, it can be popped out by another state, and that state popped out by itself if need be.
and since the engine drives the check for adding and removing states, you don't need another check.
While that does technically work without plugins, you run into an issue where the state could disappear and not be reapplied right away.

Common events aren't running during battle, for example. If the actor died in a fight, and was then resurrected, the state would be gone, and if he had the weapon equipped already, it'd be removed because he'd no longer be able to equip that etypeId. Even if you had something that ran on the skill that revived him, or an every turn battle event in every troop, that reapplied the state every turn, or after every action, there'd still be a split second where between being revived and the next run of that event, he'd have no state, so the weapon would be removed. Once removed, you wouldn't be able to automatically re-equip it, either.

Stuff like this can be solved by four lines in a note tag on an item, as above, and prevents you from having to account for every little scenario. Plugins aren't always bad.
you run into an issue where the state could disappear and not be reapplied right away.
right.
that's why I say depending on how you drive it.
what I mean by no plugin, is no 3rd party bulk of an engine that does a million other things on top of what you want and will be hard to control.
if you can wire this logic to the engine with a small edit, it'll drive itself, no need for more.
"For those with JavaScript proficiency, you can use these notetags to give
certain pieces of equipment a special requirement before it can be equipped.

Weapon and Armor Notetags:

<Custom Equip Requirement Condition>
Your code here
</Custom Equip Requirement Condition>
The 'condition' variable will determine whether or not the piece of
equipment can be worn by the user. If 'condition' returns 'true', then the
piece of equipment can be worn. If 'condition' returns 'false', then the
piece of equipment can't be worn."

Hmm ... so if I know how to get a check that returns "true" for wearing gloves -- which is what I have -- I'm curious how I could use that to prevent equipping.

I think it might just be easier to just a "glove wearing" switch. Seems like the Yanfly plugin is easier to use if it's just checking for a switch, and I just need to set that switch on at game start, and turn it off on glove equip. Marking as solved.
Thread closed

Original thread: https://forums.rpgmakerweb.com/threads/preventing-a-weapon-wield-if-an-armor-type-is-equipped.157452/