How to check in formula if actor has weapon equipped?

I've spent several hours pounding my head against this with my dad and we got nowhere. To find out if the user of a skill has a particular weapon equipped, I should use "a.hasWeapon", right? Because that isn't working. a.hasWeapon is always returning false no matter what. Now, after doing some digging, we found out why: a.weapons.length = 0. 'a' doesn't have any weapons, even though the actor does have weapons equipped.


What the hell am I doing wrong?
Are you doing this in the damage formula or in a script call?  Can you please show a screenshot or copy/paste so we can see exactly what you've entered?  


In MV, it's not a.weapons.length - it's a.weapons().length
Ugh, of course it's weapons()...that's what I get for doing this while I'm exhausted. Anyway, I've tried a few different scenarios and none of them have worked. Here's the simplest one, which I did as a test (in the damage formula):


a.hasWeapon(1) ? 50 : 20
Sorry - I was looking in your post to see the context, and completely forgot you already said it in the thread title.

Here you go:

Code:
a.hasWeapon($dataWeapons[1]) ? 50 : 20



You were so close 🙂
Over my RPG Maker 'career' I used RGSS for like an hour, total...but I miss it so much  🙁


This may be straying a bit from my original question but is there an easy way to check if an actor has a particular weapon type equipped rather than a particular weapon?
If you're after weapon type 2, for instance, something like this might work:


a.weapons().some(function(wpn) { return wpn.wtypeId === 2; }) ? 50 : 20




I haven't tested it, so if it doesn't work post back with the complete error message, and anything shown in the console (F8)

Original thread: https://forums.rpgmakerweb.com/threads/how-to-check-in-formula-if-actor-has-weapon-equipped.59363/