Return # of equips of certain type?

I.E., you have 5 helmets in your inventory. Is there a quick way to count how many there are, including duplicates? I'm pretty sure you can, but I'm not sure where to find the details on the various equip types in order to do such a thing.
Bump! 🙂
To count the number of one particular item in the database, you can use Control Variables > Game Data > Item|Weapon|Armor. Nice and easy~ ^_^

If not, then it's scriptin' time! First, note that there are three equippable item types on the Types tab in the database: Weapon Type, Armor Type, and Equipment Type. (The corresponding properties in the game code are wtypeId, atypeId, and etypeId.) If you don't mind ignoring equipped items, I think the following snippets should work in the Control Variables > Script box; just pick the one corresponding to the appropriate type and change the number at the start as needed:
  • Count possessed Weapons of Weapon Type #1:
    Code:
    var wtypeId = 1; $gameParty.weapons().reduce(function(t, w) { return t + (w.wtypeId === wtypeId ? $gameParty.numItems(w) : 0); }, 0)
  • Count possessed Armors of Armor Type #2:
    Code:
    var atypeId = 2; $gameParty.armors().reduce(function(t, a) { return t + (a.atypeId === atypeId ? $gameParty.numItems(a) : 0); }, 0)
  • Count possessed Armors of Equipment Type #3:
    Code:
    var etypeId = 3; $gameParty.armors().reduce(function(t, a) { return t + (a.etypeId === etypeId ? $gameParty.numItems(a) : 0); }, 0)
Ah, perfect! This is incredibly helpful! Thank you a ton <3

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/return-of-equips-of-certain-type.97217/