is something wrong with this formula

what i want is "if A have state 407 then add state 408 to A then damage formula if not damage formula
..but it won't work plz help

a.state?(407)? a.add_state(408); a.mhp / 4 : a.mhp / 4
a.add_state(408) if a.state?(407); return a.mhp / 4.0;

swap the IF, make the 4 a float.
The problem with your formula is that you did not use any parenthesis at all. With them you would have not experienced the issue at all. That said, you can do it even shorter if you get rid of the return statement, which is not necessary in ruby and is also considered bad practice when you only have to return a single value:
Code:
a.add_state(408) if a.state?(407); a.mhp / 4;

make the 4 a float
VX Ace does not automatically convert float into integers. This will result in damage being a float. Not only does it look ugly, it might also create issues when checking battlers' HP when using "==".
An integer division here is perfectly fine, if you want to be more accurate, round the result, like this:
Code:
r = a.mhp / 4.0; a.add_state(409) if a.state?(407); r.round
However, I would rather not add the round part. I doubt a single digit is going to have a huge impact on the game-play.
thank you all of work for the help
the formula work now
if you don't divide between floats, Ace might round the number down, returning 0.
VX Ace does not automatically convert float into integers. This will result in damage being a float.
The damage is already in float, probably not in the damage formula if you didn't do it, but when counting to element rate and physical/magical damage rate, the final damage number is in float, so there is nothing wrong changing the damage formula into a float number. It will be returned back to an integer when executing damage.
round the number down, returning 0
That only happens if the numerator is smaller than the denominator, which is unlikely going to happen since the denominator is 4 and mhp will likely be higher than that, no matter what (and the designer is going to set a fixed value for that in the classes/enemies database tab).

@TheoAllen you are indeed correct, there is a call to the to_i method in the call to make_damage after evaluating the formula. However, to_i only cuts decimal digits, while round rounds the number up or down. If you let the engine do it you might have a X.75 transform into X rather than (X + 1). Of course, whether or not this is necessary depends on how the OP wants to use the skill, but overall, I have to admit that using a float will not create any issue as the final damage is converted into an integer. Thank you for pointing that out, I honestly missed that to_i completely.

Original thread: https://forums.rpgmakerweb.com/threads/is-something-wrong-with-this-formula.115717/