MV Formula Box: Deal Damage and Add a State in a Boolean?

Good morning,

I am currently creating a "shield bash" skill, and I would like to have the condition where if the user has a larger % of HP than the target enemy, they are able to deal damage as AND add a "stun" state to the enemy. HOWEVER, if the user does not have a larger % of HP than the target enemy, the damage is dealt without adding the stun state. This is what I have so far:

(b.hp * 100 / b.mhp) <= (a.hp * 100 / a.mhp) ? b.addState(5) + a.def * 4 - b.def * 2 : a.def * 4 - b.def * 2

So my question is:
-How do I manipulate the first conditional section (b.addState(5) + a.def * 4 - b.def * 2) to deal damage as well as add the state? Am I just using the wrong operator?
-Is there any way to give the state a percentage chance of success through the formula/database settings?

Thank you for your time,
-pkdarmstrong
don't add the value of b.addState(5), put that in the beginning.

b.addState(5); (b.hp * 100 / b.mhp) <= (a.hp * 100 / a.mhp) ? a.def * 4 - b.def * 2 : a.def * 4 - b.def * 2
b.addState(5); (b.hp * 100 / b.mhp) <= (a.hp * 100 / a.mhp) ? a.def * 4 - b.def * 2 : a.def * 4 - b.def * 2

I may not have been clear in my original post, let me rephrase what I am looking for. Sorry!

I want the condition of stunning an enemy to be after the boolean operator in the sense that it is conditional, not added on just for using the skill.

So in this case, if the user has more % HP than the enemy, then the state will be added along with the damage dealt. If the user has less % HP than the enemy, the conditions will just deal the damage, without including the added stun state.
Placing the addstate at the beginning will make it unconditional, so that is the wrong solution.

What you need to do is not use an operator, but use the command seperator ; between the two parts of the effects. And for that to be detected as part of the same conditional you need to put {} around both commands, but keep them at the same place.
I got the formula to work, however I did not use the simplified boolean formula, but used the "if-else" conditional formula instead. Made things a bit easier.

if (b.hp * 100 / b.mhp <= a.hp * 100 / a.mhp) {b.addState(5) ; a.def * 4 - b.def * 2} else {a.def * 4 - b.def * 2}

If I may ask some further questions, how would this formula translate into the more simplified boolean formula (x ? a : b)?
Again, thank you Windows i7 and Andar for you assistance.
Simplify the conditional formula, you don't need to multiple both sides with 100. Then place it in () just like you did with the if Variante - your mistake was to make that condition without brackets in your first post (the brackets were only around the parts, where they were not needed, instead of around the entire condition).
Simplify the conditional formula, you don't need to multiple both sides with 100. Then place it in () just like you did with the if Variante - your mistake was to make that condition without brackets in your first post (the brackets were only around the parts, where they were not needed, instead of around the entire condition).
Got it, thank you very much! This thread can be closed now, however that works. 🙂

Original thread: https://forums.rpgmakerweb.com/threads/mv-formula-box-deal-damage-and-add-a-state-in-a-boolean.88261/