Double Conditionals in damage formula?

Hello, this is just a lil thing I'm wondering. Can you have double conditionals in the damage formula, and if so, how?
I'm trying to make a skill that if the enemy is under 30% HP and frozen, they shatter.

if b.hp<=(b.hp * 0.3) ; b.add_state(1); else; 100; end;

That's what I got.

Any help would be appreciated. Thank you. 😀
Sure, you just need the && operator. I don't have Ace in front of me (I'm at work) so I'm not 100% sure how to check for a state, but I think something like the following would work (assuming your Frozen state is 2) -
Code:
if (b.hp <= b.mhp * 0.3) && b.state?(2); b.add_state(1); else; 100; end;
That will make it so that IF b has HP less than 30% of b's MHP stat, AND they have state 2 (or whatever your frozen state is), they will have state 1 (death) added to them; otherwise, 100 damage will result.

You can also make it look a little cleaner with the "ternary" operator. In Ruby, this boils down to something like:
Code:
a ? b : c
If a is true, then it will execute b; if not, it will execute c.

So the above code in this style would look like -
Code:
(b.hp <= b.mhp * 0.3) && b.state?(2) ? b.add_state(1) : 100
Sure, you just need the && operator. I don't have Ace in front of me (I'm at work) so I'm not 100% sure how to check for a state, but I think something like the following would work (assuming your Frozen state is 2) -
Code:
if (b.hp <= b.mhp * 0.3) && b.state?(2); b.add_state(1); else; 100; end;
That will make it so that IF b has HP less than 30% of b's MHP stat, AND they have state 2 (or whatever your frozen state is), they will have state 1 (death) added to them; otherwise, 100 damage will result.

You can also make it look a little cleaner with the "ternary" operator. In Ruby, this boils down to something like:
Code:
a ? b : c
If a is true, then it will execute b; if not, it will execute c.

So the above code in this style would look like -
Code:
(b.hp <= b.mhp * 0.3) && b.state?(2) ? b.add_state(1) : 100

Oh yeah, that worked amazingly. I couldn't find anything like this, so, thank you. I really needed this. 😀
Have a good day.
Just for efficiency's sake.
Code:
b.hp_rate < 0.3 && b.state?(2) ? b.add_state(1) : 100
Just for efficiency's sake.
Code:
b.hp_rate < 0.3 && b.state?(2) ? b.add_state(1) : 100
Oh, thank you as well.
For future references:
the damage formula is an EVAL of RGSS3-code, which in itself is Ruby-based.
So any regular ruby syntax will work in the damage formula as well as all ruby-functions implemented in RGSS3 (which is why the add_state function works as well, that is originally an internal ruby function of the engine)

Original thread: https://forums.rpgmakerweb.com/threads/double-conditionals-in-damage-formula.81612/