A little help with a formula

a.level * 2 + 15 + (a.mat - b.mdf) + (b.isStateAffected(3) ? b.addState(8) : 0)

I want my formula to deal damage and if the target has state 3 add the state 8. But the spell only gives damage if the target don't have state 3. When has the state 3 it gets the state 8 but gets 0 damage.

How can I make the formula add the state and also deal damage ?

I already tried changing that 0 in the formula for 1 and for another whole formula but the damage is still 0.

Thanks in advance.
The damage formula needs to return a value. You are doing something that is not related to the damage value, and adding the result to the damage value.

Put the state stuff first, followed by a ; and then the damage formula, so it does it in two parts.

b.isStateAffected(3) ? b.addState(8) : null; a.level * 2 + 15 + (a.mat - b.mdf)

I'm not sure about the : null - whether it needs to be there or not.
The damage processed is always the last number used in the formula. The zero in the case of the conditional.

Check and place the state first, then calculate the damage and it will work.
Edit: ninja'd
@Andar
@Shaz

Thanks you both, now its working. I'm using the null thing.

Original thread: https://forums.rpgmakerweb.com/threads/a-little-help-with-a-formula.92320/