A little help with circumstantial formulas

Hi, I'm a noob I'm terrible with formulas, could you please help me ?

I want an spelll that gives x dmg + y dmg if the target has a certain state, but not just one state. Like Y dmg for poison, α dmg for burning, ß dmg for blind and so on.

I saw someone somewhere using this formula: if b.isStateAfffeced(x) ? a.atk * 6 - b.def * 2 : a.atk * 4 - b.def

My noob question is how do I add more states to this formula ? Do I use a comma and repeat the formula or a "if" ? I have no idea.
I don't know how to do the short version of ifs but you can do the long and ugly version until someone more experienced show up :rswt2:. Something like this should work.

if (b.isStateAffected(x)) {damage formula for state x here} else if (b.isStateAffected(y)) {damage formula for state y here}

and so on until the last one where you use just 'else' instead of 'else if'.
How many states are you looking at?

I'm using parentheses to keep things organized - use state ids instead of descriptions:

(b.isStateAffected(poison) ? 10 : 0) + (b.isStateAffected(burning) ? 15 : 0) + (b.isStateAffected(blind) ? 20 : 0)

and just keep going until you go through all your states.

What is after the ? is what will be used if the state is present; what is after the : is what will be used if the state is not present.

The 10/15/20 is what will be added to the damage if those states are inflicted. 0 damage will be added if the state isn't inflicted. So if the target has all of those 3 states, the damage will be 45, and if they have none of them, the damage will be 0.

The MV damage formula box can hold a LOT of text, but I suggest if it's going to be long, you write it somewhere else and save it, because if you make a mistake, it's going to be hard to find!
the formula has a maximum length, so, depending on the amount of checks, you'll run out of space.
I suggest you make up a system of states that univocally negate one another, just so they will remove the need for checks on that formula, if not remove them from the formula completely.

EDIT:
would it be practical to send the value to a manager event and recieve the result?
I'm asking to expert MV users.
if one could send the value elsewhere, then it wouldn't matter how many checks there would be.
the formula has a maximum length
Are you sure about that, and do you know what the maximum length is? When MV first came out I did a test with this - I got to a couple thousand characters and stopped because I got bored. I'd like to know the maximum if there is one.
Are you sure about that, and do you know what the maximum length is? When MV first came out I did a test with this - I got to a couple thousand characters and stopped because I got bored. I'd like to know the maximum if there is one.

the object itself is a string, so it's as long as the string object in JS could be (which is a LOT of characters), but I don't know if the editor's length is capped.

if you were to send the formula in through another process, you could send any length, but I don't remember if the editor's text box had a length..... my MV trial expired a long time ago and I only have the JS code, I can't open the editor anymore :/
Thanks @Shaz and Thanks @gstv87, and you too @Robin Hoot .

About the character limit, I just copied and paste my old formula a few thousand times and it didn`t cut the text, it was more than 7k characters so the lenght is definitely not a problem.

(b.isStateAffected(poison) ? 10 : 0) + (b.isStateAffected(burning) ? 15 : 0) + (b.isStateAffected(blind) ? 20 : 0)

I will use this as a example, Thanks again @Shaz for explaining how the formula works, the ? and the :, it was really helpful. But I prefer using the number of the skill instead of the name, It works better for me.
use state ids instead of descriptions

But I prefer using the number of the skill instead of the name, It works better for me.

I did say to use the number instead of the name. If you had used the name, you would have gotten an error. The name was just there for the example, and to not confuse state ids with the damage amounts.
Hi, sorry the late reply. I was focusing on other things in the game.

For some reason the formula is not working. It gives 0 dmg if the foe has the state or without it.

Here is the formula I'm using:

a.level + 80 + (a.mat * 7 - b.mdf * 5) + b.isStateAffected(3) ? a.level : 0) + (b.isStateAffected(4) ? a.level / 2 : 0) + (b.isStateAffected(5) ? a.level : 0) + (b.isStateAffected(6) ? a.level : 0) + (b.isStateAffected(7) ? a.level * 2 : 0) + (b.isStateAffected(8) ? a.level * 2 : 0) + (b.isStateAffected(9) ? a.level : 0) + (b.isStateAffected(10) ? a.level : 0) + (b.isStateAffected(11) ? a.level * 2 : 0) + (b.isStateAffected(12) ? a.level / 12 : 0) + (b.isStateAffected(13) ? a.level * 2 : 0)

should I type if instead of + ??
There is a missing left-parentheses on the first line which is going to cause a syntax error, and if there is an error it sets the damage to zero.

Spoiler
b.isStateAffected(3) ? a.level : 0)
This one is missing the opening parentheses.

I don't remember if it logs the error to the console, but if the damage still doesn't work then press F8 to open the console and see what the error is.
Thanks its working now

Original thread: https://forums.rpgmakerweb.com/threads/a-little-help-with-circumstantial-formulas.89794/