Getting the type of weapon the actor is wielding in the formula box

I want to make a skill that is not restricted to the type of weapon the caster is wielding, but its damage increases if the caster is using the right type of weapon. Here is my pseudo code:

a.weapons[0].type==sword ? a.atk+a.mat-b.def : a.mat-b.def

I was able to get all the way to putting a.weapons[0].id ==1 into the if condition, but how do I get and compare the type parameter of the weapon object?

Also, if I strip my actor naked, the a.weapons[0].id will also return null, which results in no damage, is there a way to get around that?
You would be better to use a custom damage formula script.
I can't remember what I had to do, but I found a page with a custom script for damage formulas

Something like this
Ruby:
class Game_Battler < Game_BattlerBase
  #==========================================================================
#                              Lucky 7    
#==========================================================================
    # a.lucky7(a, b)
  def lucky7(a, b)
    if a.mhp >= 100000
      if a.hp % 10 == 7
        777777
      else
        1
      end
    elsif a.mhp >= 10000
      if a.hp % 10 == 7
        77777
      else
        1
      end
    elsif a.mhp >= 1000
      if a.hp % 10 == 7
        7777
      else
        1
      end
    elsif a.hp % 10 == 7
      777
    else
      1
    end
  end
end
With the skill formula like this
1671070423447.png


Then you can put whatever code you want to determine what the weapon type is.

Which would be like this a.equips[0].wtype_id == 1
NVM, I just checked the scripts again and found wtype_equipped?() under Actors that does exactly what I want.

Original thread: https://forums.rpgmakerweb.com/threads/getting-the-type-of-weapon-the-actor-is-wielding-in-the-formula-box.153305/