Reference Weapon Type in Formula

Is it possible to reference a character's weapon type in a formula? I want to have an ability for one of my characters that adds their attack to their defense when equipped with axes.
Code:
wtype_equipped?(id)
An example of using it, though I went with adding defense to attack in this case:
Code:
x = 0; x = a.def if (a.actor? and a.wtype_equipped?(1)); (a.atk + x) * 4 - b.def * 2
The a.actor? call is there to prevent the formula from erroring if the attack is an enemy due to lack of a wtype_equipped? method. Alternatively, you could add the following scriptlet and remove that part of the formula:
Code:
class Game_Enemy < Game_Battler  #--------------------------------------------------------------------------  # * Determine if Specific Type of Weapon Is Equipped  #--------------------------------------------------------------------------  def wtype_equipped?(wtype_id)    false  endend
The previous formula can then be shortened to
Code:
x = 0; x = a.def if a.wtype_equipped?(1); (a.atk + x) * 4 - b.def * 2
or
Code:
x = a.wtype_equipped?(1) ? a.def : 0; (a.atk + x) * 4 - b.def * 2
Thanks, this thread can be closed now.

Original thread: https://forums.rpgmakerweb.com/threads/reference-weapon-type-in-formula.35758/