Return a value for "Weapon Type Equiped"

My question is simple, but I haven't found the answer yet.

I am developing a method that changes an Actor's combat chart according to the type of weapon he has equipped, by placing a suffix on the sprites.

For example:
If equipped with weapon type ID: 1, the graphic would be "Actor_1", if equipped with weapon type ID: 7, the graphic would be "Actor_7".

I have already found the lines of code that allow me to use the suffixes that I mentioned.
JavaScript:
Sprite_Actor.prototype.updateBitmap = function() {
    Sprite_Battler.prototype.updateBitmap.call(this);
    var name = this._actor.battlerName() + "_" + WeaponTypeId; //This Line!
    if (this._battlerName !== name) {
        this._battlerName = name;
        this._mainSprite.bitmap = ImageManager.loadSvActor(name);
    }
};

However, I have not found which code I use to return the value of the type of weapon the actor is equipped with.
Which line of code should I use to return the equipped weapon type value to enter in the "var name"?
Isn't there a script were when you equip a weapon it runs a common event? And can't you change actor graphics in common events?
Do a search for isWtypeEquipped or something like that. It'll show you how to get the type of weapon equipped
Because I have a massive amount of "Change Graphics" of the Actors in my game. This method of using suffix in make more sense for me.

I search for the WType sentence in all Core scripts in RMMV and I don't find the correct code to get the WType like I get other Actors atributes like Name, Level, Graphic and etc.
Maybe you used case-sensitive? Cause I ran a search and found this quickly

Code:
Game_Actor.prototype.isWtypeEquipped = function(wtypeId) {
    return this.weapons().some(function(weapon) {
        return weapon.wtypeId === wtypeId;
    });
};
Maybe you used case-sensitive? Cause I ran a search and found this quickly

Code:
Game_Actor.prototype.isWtypeEquipped = function(wtypeId) {
    return this.weapons().some(function(weapon) {
        return weapon.wtypeId === wtypeId;
    });
};
But how I use this in a sentence to obtain the suffix?

When I use this:
JavaScript:
    var name = this._actor.battlerName() + "_" + this._actor.wtypeId();

I got a error saying "wtypeId() it's not a function".

And when I use:
JavaScript:
    var name = this._actor.battlerName() + "_" + this._actor.wtypeId;

I got "Undefined" valor in Suffix.
Basically you need to take the equipped weapons wtypeId. The example I showed you is how you do it.
wtypeId is a property of weapons, not actors. That's why you're getitng errors and undefineds.

Code:
((a.weapons()[0] || {}).wtypeId || 0)

Replace "a" with whatever you're using to reference a given actor. It'll return the wtypeId of their equipped weapon (in the first slot) or 0 if no weapon is equipped.
wtypeId is a property of weapons, not actors. That's why you're getitng errors and undefineds.

Code:
((a.weapons()[0] || {}).wtypeId || 0)

Replace "a" with whatever you're using to reference a given actor. It'll return the wtypeId of their equipped weapon (in the first slot) or 0 if no weapon is equipped.
That's It! I inset a new variable calling this sentence for this._actor. And it's Works!
JavaScript:
Sprite_Actor.prototype.updateBitmap = function() {
    Sprite_Battler.prototype.updateBitmap.call(this);    
    var name = this._actor.battlerName(); //VonDaft
    var wpType = ((this._actor.weapons()[0] || {}).wtypeId || 0);
    if (this._battlerName !== name) {
        this._battlerName = name;
        this._mainSprite.bitmap = ImageManager.loadSvActor(name + "_" + wpType);
    }
};

Thank You!

Original thread: https://forums.rpgmakerweb.com/threads/return-a-value-for-weapon-type-equiped.125345/