Trying to set up a skill that's based on a number of a specific item

I'm trying to setup a skill for a Pixie Queen character, and initially I had a variable in the damage formula that would go up by 1 when triggered by events in the game.

this is the current formula:

v[33] = (v[33] || 0); (((a.atk + a.mat + v[33])) * 2) / (((b.def + b.mdf))

However, no matter what i can get the variable set to, (either by items or actually tracking the event variable) the damage
still rounds to Zero.

For context, the game is built around some of the concepts inspired by pokemon, so I'm trying to keep the damage received around the ~x to ~xx range, as many monsters (at least where I'm at in development) aren't even close to triple digit health.
However, no matter what i can get the variable set to, (either by items or actually tracking the event variable) the damage
still rounds to Zero.
its not that its rounding to 0, its that the formula is encountering an error thats making it return a non number, and the engine by default resolves that by making the value 0.

use $gameVariables.value(33) to get variable 33's value and $gameVariables.setValue(33, some value) to set it.

v[33] = (v[33] || 0); (((a.atk + a.mat + v[33])) * 2) / (((b.def + b.mdf))
\v[] is just the escape code to get the value within a text box (you dropped the "\"). it doesnt return anything in a formula, which is the cause of the 0. and even if it worked in a formula box, you wouldnt be able to set it here because all it does is retrieve the value.

v[33] = (v[33] || 0)
also, while its good to check if a value exists before using it, game variables initialize at 0. Unless you put something in the game to make it undefined, its always going to have a value to make that OR choose the first value
(((a.atk + a.mat + $gameVariables.value(33))) * 2) / (((b.def + b.mdf))

so would that look correct?

on new game, i have variable 33 set to 0, currently (for the attack) it increases based on the number of the item (in this case, a key item named Pixie Dust, that you get from various mini sidequests)
(((a.atk + a.mat + $gameVariables.value(33))) * 2) / (((b.def + b.mdf))
youre missing a closing parentheses at the end, but youre also using more than you need.
Code:
(a.atk + a.mat + $gameVariables.value(33)) * 2 / (b.def + b.mdf)
that should do

it increases based on the number of the item (in this case, a key item named Pixie Dust, that you get from various mini sidequests)
you can cut the need to make a variable be a part of the calculation by using the script call to count the number of dusts the party has directly. you wont have to increment the variable when the party gets one and itll eliminate any possible desync issues that may occur
For Item count: $gameParty.numItems($dataItems[123]). Replace 123 with the Item ID; replace $dataItems with $dataWeapons or $dataArmors for weapons/armors respectively.

@Robro33 - v is a damage formula shorthand for $gameVariables._data (raw variable values). Hence no preceding \ (invalid JS) and the safety check, v[33] || 0, because if that variable has not yet been assigned a value then v[33] will be undefined. $gameVariables.value(33) is the standard getter and includes an equivalent safety check.
v is a damage formula shorthand for $gameVariables._data (raw variable values). Hence no preceding \ (invalid JS) and the safety check, v[33] || 0, because if that variable has not yet been assigned a value then v[33] will be undefined. $gameVariables.value(33) is the standard getter and includes an equivalent safety check.
huh... TIL 😀. I had never seen that used anywhere before so i assumed they were going for the escape code. good to know.
also looking back now, i see the the missed closing parentheses in the original formula too. so that would just have been the cause then?

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-set-up-a-skill-thats-based-on-a-number-of-a-specific-item.163828/