Help with skill with condition and multiple results.

Hello, everyone! There's a skill I want to make. I want it to check if the target is affected by a state. If true, the skill should affect the target with another state and then inflict dmg. If false, it should only inflict dmg. I thought it would be something like this, but it doesn't work.

b.isStateAffected(x) ? a.addState(x); (a.mat * 2 - b.mdf * 1) * 1 : (a.mat * 2 - b.mdf * 1) * 1 ;

Can you tell me what am I doing wrong? Thanks for reading!
sorry, i too stupid to read that kind of code... its really beyond me.

are you using any plugins?
sorry, i too stupid to read that kind of code... its really beyond me.

are you using any plugins?
No plugins at least for the formula.

This post helps you with many things regarding codes, but I can't find how to add more than one "event" in a "sentence."

Also, you're not stupid for not knowing how to read that. There's always something that we don't know.

let me rephrase, then: which plugins youve got? all read the suggested thread meanwhile.

EDIT: it looks like you can javascript the thing in there.
Code:
if(b.isStateaffected(X)){a.addState(X); a.mat * 2 - b.mdf;}else{a.mat * 2 - b.mdf;}
if (b.isStateAffected(x)) b.addState(x); (a.mat * 2 - b.mdf * 1) * 1 else (a.mat * 2 - b.mdf * 1) * 1


Try this. I'm not 100% certain I got this right, but I'm definitely close if not.
if (b.isStateAffected(x)) b.addState(x); (a.mat * 2 - b.mdf * 1) * 1 else (a.mat * 2 - b.mdf * 1) * 1


Try this. I'm not 100% certain I got this right, but I'm definitely close if not.
That's real close, but without any brackets it won't work.

@Gargoyle77 The ternary operation won't do it for you because the semicolon is used to identify the end of the operation and you can't execute multiple lines of code without it (and you're asking too much for the poor operator).

Try using a simple if-else statement instead, I just tested it at works great:

if(b.isStateAffected(x)){ b.addState(x); <formula>} else{ <formula>;}
@Jeivalien Ah, I was close indeed. Thanks for the correction.
looks like i got my edit wrong...
let me rephrase, then: which plugins youve got? all read the suggested thread meanwhile.

EDIT: it looks like you can javascript the thing in there.
Code:
if(b.isStateaffected(X)){a.addState(X); a.mat * 2 - b.mdf;}else{a.mat * 2 - b.mdf;}

it should be like this:
Code:
if(b.isStateaffected(X)){b.addState(Y); a.mat * 2 - b.mdf;}else{a.mat * 2 - b.mdf;}
I don't know if you got everything worked out with this yet, but couldn't you just do this:
JavaScript:
b.isStateAffected(x) ? b.addState(x) : 0; a.mat * 2 - b.mdf
So Jeivalien, Nuke and Black are all close (and by close, I mean they're all correct, any of their solutions will work, but none are the simplest).

Because your damage formula isn't actually different, there's zero reason for you to type it twice. It also means there's no reason for you to use the ternary operator in any way. Similarly, there's no reason to use if/else.

You can just do:
Code:
if (b.isStateAffected(x))  b.addState(y); a.mat * 2 - b.mdf

(speaking of things with no reason, the places where you multiply by 1 also logically don't achieve anything, so I left them out)
So Jeivalien, Nuke and Black are all close (and by close, I mean they're all correct, any of their solutions will work, but none are the simplest).

Because your damage formula isn't actually different, there's zero reason for you to type it twice. It also means there's no reason for you to use the ternary operator in any way. Similarly, there's no reason to use if/else.

You can just do:
Code:
if (b.isStateAffected(x))  b.addState(y); a.mat * 2 - b.mdf

(speaking of things with no reason, the places where you multiply by 1 also logically don't achieve anything, so I left them out)

What Jeivalien said worked pretty well, but yours is shorter, so I'll go with it. Thanks for your explanation too. I'll take it into account the next time I'm attempting to do something similar.

Thanks everyone for your help too!

PS: The "* 1" at the end of the dmg formula is written in case I want to lower the dmg done by the skill.​

So Jeivalien, Nuke and Black are all close (and by close, I mean they're all correct, any of their solutions will work, but none are the simplest).

Because your damage formula isn't actually different, there's zero reason for you to type it twice. It also means there's no reason for you to use the ternary operator in any way. Similarly, there's no reason to use if/else.

You can just do:
Code:
if (b.isStateAffected(x))  b.addState(y); a.mat * 2 - b.mdf

(speaking of things with no reason, the places where you multiply by 1 also logically don't achieve anything, so I left them out)

i noticed that, but left that way anyway. he would be providing a generic formula since he used (X) instead of real numbers and would need a real if; else if; else statement to work with this and other formulas.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-skill-with-condition-and-multiple-results.149729/