Shaz, thank you very much your help ^^
I was just facing a similar problem when I found this topic with your solution.
(I work on a method that makes it easier to count and replace equipment (for example older saves and newer game versions, I could change the modified items)
But with Yanfly's ItemCore and independent items, there are not counted, so I make a workaround for it, which is working fine for me.
I know this is an old topic, but if someone faces the same problem, it will be useful for him/her.
The common event uses 2 variables (one for the weaponID, and one for the return value)
inside this common event, create a script event command.
Code:
var id = $gameVariables.value(76); // the variable #76 which I used for the weaponId, change if you want
var qty1 = $gameParty.numItems($dataWeapons[id]); // the quantity of the base item
var qty2 = $gameParty.numIndependentItems($dataWeapons[id]); // the quantity of the independent item
var qty3 = $gameParty.members().filter(function(a) { return a.hasWeapon($dataWeapons[id]) }).length; // the quantity of the equipped item
var qty = qty1 + qty2 + qty3; // total quantity
$gameVariables.setValue(77, qty); // the variable #77 which I used for return value with the total quantity, change if you want
console.log('Weapon ID: '+id+' Weapon Name: '+$dataWeapons[id].name); // some debug info to console
console.log('Base: '+qty1+' Independent: '+qty2+' Equipped: '+qty3+' Total: '+qty); // some debug info to console
Outside a common event, where you want to use:
Control Variables: #0076: WeaponID = 8
Common Event: Weapon Count
Text: "You have \V[77] of the specified weapon."
For armors, just change the $dataWeapons to $dataArmors and a.hasWeapon to a.hasArmor
🙂