Help with damage formula, acts up when variable included = 0

Hey all, thanks for your time in advance. Hoping one of you guys might know whats going on.

summary: i am working on implementing weapon skill levels. for example, if you have a dagger and use your basic attack with it, it will run a common event that puts experience towards a variable dedicated to your 1-hand pierce level. lets assume that 1h pierce level variable is v[55].

the problem: my attack formula:
(a.atk + a.level + 4) - ((b.def + b.level) * 0.75) will function normally as intended, however;
(a.atk + a.level + 4 + v[55]) - ((b.def + b.level) * 0.75) will not function at all if v[55] = 0. if v[55] = 0, the attack will do no damage to the target. however, once v[55] = 1 or higher, then the formula functions as intended.

my question: why does the formula behave that way when adding a 0 is introduced? is this a bug?

my solution is to just start all skill levels at 1, but the fact i dont understand why this is happening bugs me.

my plugins: all of visuMZ_1's, including battlecore. ive already poked around in the formula and i dont know js well enough to determine what to change, if that is whats happening. I have the damage style in the settings set to manual as well.

Thanks again!
I'm going to suggest that you're mistaken. If variable 55 is 0, there's no reason it should cause any problems.

However, if that variable is uninitialized, it will return a value of undefined when used in JavaScript code, which will cause all equations containing it to result in 0 - exactly what you're seeing here.

Therefore, I think that you're not setting the variable equal to 0 at the beginning of your game (or perhaps you presumed it would start at 0 if you didn't do anything).

Hopefully that's helpful.
I'm going to suggest that you're mistaken. If variable 55 is 0, there's no reason it should cause any problems.

However, if that variable is uninitialized, it will return a value of undefined when used in JavaScript code, which will cause all equations containing it to result in 0 - exactly what you're seeing here.

Therefore, I think that you're not setting the variable equal to 0 at the beginning of your game (or perhaps you presumed it would start at 0 if you didn't do anything).

Hopefully that's helpful.
I'm using it in the battle simulator... I'll try adding a command in the battle to set the variable to 0 to see if that changes. I assumed all variables started at 0, I didn't know they had another state until they were set to 0. Thank you Turan!

edit: that worked, thanks again!

Original thread: https://forums.rpgmakerweb.com/threads/help-with-damage-formula-acts-up-when-variable-included-0.151451/