Damage Formula Help [SOLVED]

Hello! I hope I posted this in the right section. Anyways, I have this thing with my revive skill where it gives you an AutoLife state when you're alive and revives you normally without the state when you're dead. I got it to work with this formula " if (b.isDeathStateAffected() ? 10000 : 1) b.addState(32); else b.mhp / 2; " but there's a problem. When the skill is used on a dead ally instead of reviving them with half their health, it just gives them 0 hp and revives them. I have that it removes the dead state under the effects tab, as it should be, but I'm struggling a bit here since my code-fu is absolutely horrible. Any help is appreciated!
if (b.isDeathStateAffected() ? 10000 : 1) b.addState(32); else b.mhp / 2;
youve used an if-else statement, but youve also used a ternary operation as the condition thatll only ever result in a truthy value. both if (1) and if (10000) will result in the state being added (which will fail on a dead battler as those cannot gain states normally), and the healing will be 0 because addState() doesnt return a number. that condition cannot be false

were you trying to heal alive targets by 10000 + give reraise / revive dead targets by half of their max hp? or did you just want the revival to 50% hp if dead / + reraise with no healing if they were alive?
youve used an if-else statement, but youve also used a ternary operation as the condition thatll only ever result in a truthy value. both if (1) and if (10000) will result in the state being added (which will fail on a dead battler as those cannot gain states normally), and the healing will be 0 because addState() doesnt return a number. that condition cannot be false

were you trying to heal alive targets by 10000 + give reraise / revive dead targets by half of their max hp? or did you just want the revival to 50% hp if dead / + reraise with no healing if they were alive?

or did you just want the revival to 50% hp if dead / + reraise with no healing if they were alive?
Yeah that's pretty much the idea. Also

both if (1) and if (10000) will result in the state being added (which will fail on a dead battler as those cannot gain states normally), and the healing will be 0 because addState() doesnt return a number.
Oh good to know. Truth is I just copied that from the "Damage Formulas 101" guide and didn't really know what the (1) and (10000) did so I just left it like that lol.
then
Code:
if (b.isDeathStateAffected()){b.mhp/2} else {b.addState(32); 0}
should do what you want.

However, the caveat is that if you have an actor set to auto battle, it may cause battlers to be revived/gain reraise without the skill needing to be used at all.
if you dont use the autobattle flag it shouldnt be an issue, but otherwise youll want to use a plugin to change when/how the effects happen
then
Code:
if (b.isDeathStateAffected()){b.mhp/2} else {b.addState(32); 0}
should do what you want.

However, the caveat is that if you have an actor set to auto battle, it may cause battlers to be revived/gain reraise without the skill needing to be used at all.
if you dont use the autobattle flag it shouldnt be an issue, but otherwise youll want to use a plugin to change when/how the effects happen
It works! Thank you so much! And no, I don't use autobattle so it shouldn't be an issue. Again, thank you 🙂

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/damage-formula-help-solved.176951/