Damage formulas using variables

Long story short: "if(b.isStateAffected(4)){$gameVariables.setValue(27, 200);}(a.atk * 4 - b.def * 2 + v[27])"

This doesn't work because of the last part "+ v[27]". I do have no idea why. That the correct way to write variables in battle formulas right? I haven't found much examples but I see it in every explanation, so why?!?!?
That's because v[27] is an escape code used only inside messages, not the javascript code for variable 27.
That's because v[27] is an escape code used only inside messages.

Not really. v[id] is also valid in damage formulas as seen in the evalDamageFormula function in the rpg_objects.js file.

So, there's probably a different reason why it's not working.

Are you sure it's because of the "+ v[27]" part? Did you see if it works without that part?

Also, just in case, you could try using $gameVariables.value(27) instead of v[27], even though both should work.

Original thread: https://forums.rpgmakerweb.com/threads/damage-formulas-using-variables.81748/