Attacks display message but no damage

Hello, I have am having an issue with how an attack's damage is displayed. I changed the
Game_BattlerBase.prototype.attackSkillId function in order to be able to differentiate basic attacks (that part works, the damage is even dealt) but any attacks running through this new function do not display anything besides the basic message for the attack (like '%1 attacks').

The new function is below:
(function(){
var _GameBattlerBase_attackSkillId = Game_BattlerBase.prototype.attackSkillId;
Game_BattlerBase.prototype.attackSkillId = function() {
if (this.isActor()) { //if actor return a variable
if (this._classId === 1){
return $gameVariables.value(21);
} else if (this._classId === 2){
return $gameVariables.value(22);
} else if (this._classId === 3){
return $gameVariables.value(23);
} else {
console.error('Your class was not defined');
}
} else { //if enemy return default
_GameBattlerBase_attackSkillId.call(this)
}
}
})();

Where my $gameVariables.value[x] is set to the skill ID for the corresponding basic attack. The enemy's attack, which is routed through the old function, still displays damage correctly. Any ideas? I couldn't decipher why it wasn't displaying (but still calculated and did) damage.
A few general tips for you:
When you're posting code, you should use the CODE tags (the </> icon on the top bar). Not only does this preserve your indenting, but some code can get lost if you don't use it (things in brackets can be interpreted as BBCode by the forum).

You should check out the switch statement. It'll save you some typing over lots of if/else if statements.

As far as your actual code...I'm a bit confused by what you're trying to do here. Are you trying to change during gameplay what skill the classes use as their default Attack? So you'll change the value of one of those variables and have their Attack be that skill?

I'm putting my money on either an error with the value of the variables, or in the actual skills. If you leave this function but set the value of the variables to 1 so that the skill returned is Attack, what happens?

Also, note that you have a breaking mistake - if none of your class checks succeed, you print an error log but don't return a value. You should return 1 after the console call (or take away the "else" before the attackSkillId.call at the bottom).
If you want to change the default attack skill - there already is a trait for that in MZ:
attack.png


You can attach that trait to weapons or actors or classes or states, so it is reasonably dynamic to use to decide what skill will be used for attack.

unless you're trying to do something really complex you should use that option instead of changing the engine itself.
If you want to change the default attack skill - there already is a trait for that in MZ:
View attachment 221098

You can attach that trait to weapons or actors or classes or states, so it is reasonably dynamic to use to decide what skill will be used for attack.

unless you're trying to do something really complex you should use that option instead of changing the engine itself.
I was just about to say this. Unless you're going to be changing the attack skill on the fly as the game progresses, using this trait on the individual classes is probably going to be a better option.
So I followed the suggestions on here about removing that change and using the built in functionality. The attacks are still the right ones, but for some reason that bug is still not fixed. The enemies' damage is displayed right and their health is still kept calculated.
then either you have not removed the function, or the bug came from some other source anyway.

please keep in mind that after any engine change you should start a new playtest - part of the data and code is saved, and loading an old savegame can restore some old effects as well.

if that isn't the case and you really removed all that functionality you changed, then you now have to bughunt what else you changed that might have caused this bug.
Usually it's one of the plugins you added, especially if you didn't completely configure it.

I can't count the number of cases where people reported that their starting gear suddenly had variant numbers as a bug, because they all added the yanfly item core without disabling the default "randomize all gear" that is done by that plugin.

and your case could be something similar - you added a plugin where the default is to hide those numbers.
then either you have not removed the function, or the bug came from some other source anyway.

please keep in mind that after any engine change you should start a new playtest - part of the data and code is saved, and loading an old savegame can restore some old effects as well.

if that isn't the case and you really removed all that functionality you changed, then you now have to bughunt what else you changed that might have caused this bug.
Usually it's one of the plugins you added, especially if you didn't completely configure it.

I can't count the number of cases where people reported that their starting gear suddenly had variant numbers as a bug, because they all added the yanfly item core without disabling the default "randomize all gear" that is done by that plugin.

and your case could be something similar - you added a plugin where the default is to hide those numbers.
Turns out I had a line that was for some reason breaking it. Originally before I made my own plugin, I was just changing core files (but those were working). So I took those changes OUT of core and put them in my own plugin, and apparently I messed a line up. Thanks for your input!

I've moved this thread to Learning Javascript. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/attacks-display-message-but-no-damage.146149/