MV Variable in Damage Formula

I'm trying to make a state that increases damage if past a threshold of gold.
I have a plugin that allows me to put damage increases in states
This is the current formula but it isn't working:

<state damage modifier: attacker>

if (v[18] > 1000)

return (Math.round(d * 1.5))

</state damage modifier>
v[18] is not a programming syntax, \\v[18] is only used inside Game Messages. Use $gameVariables.value(18) instead.
I changed it to:

<state damage modifier: attacker>

if ($gameVariables.value(18) > 1000)

return (Math.round(d * 1.5))

</state damage modifier>

and it is still not working.
I apologise for not having any code knowledge
which is the plugin you're using?
sometimes they need specific formats, and in this case the return function might or might not be correct use...

so we need to check the website of the plugin for instructions.
It looks like you're using Hime's State Damage Modifiers? Next time you should name the plugin explicitly. You should also describe what you mean by "it isn't working", as that could be literally anything.

Assuming that is the plugin you're using, I think your issue could be that you don't always return a value? You could try this:

Code:
<state damage modifier: attacker>
if (v[18] > 1000)
  d = (Math.round(d * 1.5));
return d;
</state damage modifier>
Yes sorry, it was Hime's State Damage Modifiers
The issue I was having was an error code of an unexpected identifier.
I put in the new code and it doesn't seem to work still.
When I put:
<state damage modifier: attacker>
if (v[18] > 1000)
d = (Math.round(d * 1.5));
return d;
</state damage modifier>
It doesn't seem to add the bonus
and when I put:
<state damage modifier: attacker>
if ($gameVariables.value(18) > 1000)
d = (Math.round(d * 1.5));
return d;
</state damage modifier>
It gives me the same error as before.
Now that I know what damage modifier plugin you are using, I can correct myself: In this case, v[x] is a valid syntax.

Maybe try this formula:

Code:
return (v[18] > 1000) ? d * 1.5 : d
That has stopped it from giving me an error, but it still isn't giving me any damage bonus when the variable is larger than 1000.
Ah, I see now. The v must be called the javascript way.

Code:
return (v.value(18) > 1000) ? d * 1.5 : d
That worked perfectly! Thank you for the help!
If you would like to make it consistent with the damage formula's use of the reference v (where you can use v[18] to reference variable 18), make this change to the last method .applyStateDamageModifier() in the plugin for line 'var v = $gameVariables;'
JavaScript:
var v = $gameVariables._data;
This will allow you to use v[18] or v[x] to reference the game variables.

Either way, glad it is working now.
If you would like to make it consistent with the damage formula's use of the reference v (where you can use v[18] to reference variable 18), make this change to the last method .applyStateDamageModifier() in the plugin for line 'var v = $gameVariables;'
JavaScript:
var v = $gameVariables._data;
This will allow you to use v[18] or v[x] to reference the game variables.
That is the typical method to use for these, but I like to make v a Proxy object instead. Then you get the best of both worlds – indexing syntax (v[n]) but also calling the update() method whenever you write to it, and returning a default of 0 if it's not previously defined.

…though, this is not something to recommend to beginners.

Original thread: https://forums.rpgmakerweb.com/threads/variable-in-damage-formula.180867/