Multiple states in a damage formula.

Greetings and salutations, wise people of the internet! I am having troubles with a particular type of damage formula, that being one that utilizes multiple possible states as modifiers of the final resulting damage. I shall post it below:


a.atk * 4 - b.def * 1 b.isStateAffected(11) ? 2500 + a.atk * 10 - b.def; && b.isStateAffected(4) ? 2500 + a.atk * 10 - b.def; && b.isStateAffected(5) ? 2500 + a.atk * 10 - b.def;

The issue is most likely trivial, and comes from my lack of experience with the MV engine. I thank anyone who responds to this.
The formula is a bit messed up in its syntax and ignoring a few quirks of the eval function.
can you tell us what that formula is supposed to do exactly?

that said, the most important quirk is that the damage result is always the last number calculated in the formula, especially if stringing along with conditions and functions - so the first part (that is missing the ; anyway) would be almost never be used.
Second the AND operator doesn't make much sense in that line at all

which is why I asked what you want it to do...
I want the damage to increase with each state applied.
So for example: If the enemy had been both blinded and stunned, it would do 5000 additional damage, but if he was only stunned, it would do only an additional 2500 damage.
I want the damage to increase with each state applied.
So for example: If the enemy had been both blinded and stunned, it would do 5000 additional damage, but if he was only stunned, it would do only an additional 2500 damage.
Try using a variable to hold the length of the array that includes the states 4, 5, and 11, and simplify it by making it a multiplier of that specific damage formula.
If there is no value for the variable, it defaults to the normal attack times 4 minus defense:
JavaScript:
const m = b._states.filter(s=>[4,5,11].includes(s)).length; m ? m*(2500+a.atk*10-b.def) : a.atk*4-b.def

Or, use the same code above but remove the parentheses for the damage portion to modify only the 2500 value by doing
Code:
m*2500+a.atk*10-b.def
if you only want it to increase by 2500 rather than the whole formula.
That works! Thank you for help.

Original thread: https://forums.rpgmakerweb.com/threads/multiple-states-in-a-damage-formula.170869/