Check if an item is equipped (item-based, not actor-based)

I know how to check and see if an actor has a particular item equipped - I'm trying to do the inverse, sort of.

I need to check and see if an item is equipped to any actor or not. This is because I'm using Yanfly's Attachable Augments plugin and running an augment attach eval that should only run if the item it's being attached to is already equipped on someone, and not if it's just sitting in the inventory. Something like:

Code:
<Augment Attach Eval>
if (<item is equipped to anyone>), {
a whole whack of code
} else {
}
</Augment Attach Eval>

I know that "item" in this case does refer to the target item that's being augmented. I just have no idea how to check if item is equipped. It can't as as easy as item.isEquipped() can it? Haha

EDIT: The code within the if...else statement does different things based on which actor is using the item, just fyi.
# Check Conditional Branch: if [Actor] has [Weapon] Equipped
# ----------------------------------------------
$game_actors[actor id].weapons.include?($data_weapons[weapon id])
right_hand = $game_actors[actor_id].equips[0]
left_hand = $game_actors[actor_id].equips[1]

# To get the items. Replace the index in equips for the item you're looking for:
# 0 = right hand, 1 = left hand, 2 = head, 3 = body, 4 = accessory
# provided you're not using any scripts that change that. You can check their types with:

if right_hand.is_a?(RPG::Weapon)
# do something
elsif right_hand.is_a?(RPG::Armor)
# do something else
end

# Or get their properties with with:
right_hand.id
right_hand.name
right_hand.icon_index
right_hand.description
# etc..

# Example: if you want to check if you have a Prinny Gun equipped on your first weapon slot:
right_hand = $game_actors[actor_id].equips[0]
if !right_hand.nil? && right_hand.name.eql?("Prinny Gun")
# Do something
end

# You don't even need to keep track of the IDs, really (unless you want to, for some reason).
# If there's no way to not have a weapon equipped in your game, you can also take out the ".nil?" check.

(This is from here row 168
I'm not really sure if this works in Yanfly's notetags, but you can try!
Code:
<Augment Attach Eval>
var actors = $gameParty.allMembers();
var item = $dataWeapons[id] // or $dataArmors[id], depending on the type of the item!
var cond = actors.some(function(actor) { return actor.equips().some(function(equip) { equip == item }) })
if (cond) {
a whole whack of code
} else {
}
</Augment Attach Eval>

EDIT: The code up there check if the item is equipped to ONE of the actors in all the party. If you want to check if the item is equipped to a specific actor, the code is like that:

Code:
<Augment Attach Eval>
var actor = $gameActors.actor(id);
var item = $dataWeapons[id] // or $dataArmors[id], depending on the type of the item!
var cond =  actor.equips().some(function(equip) { equip == item })
if (cond) {
a whole whack of code
} else {
}
Try this. Not sure if it'll work but it should:

Code:
<Augment Attach Eval>
var actors = $gameActors;

var a1Eq = actors.actor(1).equips().some(function(equip) {return equip === item;});
var a2Eq = actors.actor(2).equips().some(function(equip) {return equip === item;});
var a3Eq = actors.actor(3).equips().some(function(equip) {return equip === item;});
var a4Eq = actors.actor(4).equips().some(function(equip) {return equip === item;});
// Continue on if more actors.

if (a1Eq) {
// Stuff if actor 1 equipped.
} else if (a2Eq) {
// Stuff if actor 2 equipped.
} else if (a3Eq) {
// Stuff if actor 3 equipped.
} else if (a4Eq) {
// Stuff if actor 4 equipped.
} // Continue on if more actors.
</Augment Attach Eval>

On another note, the <Augment Attach Eval> is only evaluated when the augment is being attached. That means if you attach an augment to an item not equipped to an actor, then have that actor equip the item, the eval will not run.
As it turns out, what I needed was this:
Code:
$gameParty.isAnyMemberEquipped(item)
Worked perfectly. Thanks, though, guys, I'll have this thread closed now 🙂
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/check-if-an-item-is-equipped-item-based-not-actor-based.82022/