Altering Immortal State

Right. I'm sure this topic is somewhere but I can't seem to find it anywhere. So sorry if this has already been asked somewhere else.

What I'm looking for is to have a state where a target who would have been killed by an attack survives with 1 HP (think Endure, Focus Sash etc. in Pokemon games). Ideally the state would be removed upon this happening, so that a character can only survive a lethal attack once.

The default immortal state in the database will keep HP at 0 if killed, and it seems to prevent skills from being used as well.

I'm not sure whether or how this state could be altered so that it will leave the character alive at 1 HP rather than 0 HP.
For focus slash: In the formula section, put 

(b.hp - 1)
I don't think you've got quite the right idea. It's not a skill to set a target's HP to 1, it's a state that will prevent ANY skill from killing the user, letting them survive at 1 HP.

Edit: I'm not sure what you're getting at. There's no formula box in the state part of the database...
Edit: disregard this and above; there's a whole topic on this already:

http://www.rpgmakervxace.net/topic/5913-a-very-easy-way-to-make-the-infamous-1-hp-attack-for-enemies-or-players/
Edit: I still think you've got the wrong idea. It's the state that I want to create, having an effect similar to 'resist state death' in the database. That means, no matter what skill your opponent uses, you will survive a lethal attack with 1 HP left, only if that state is applied.
you cannot create such a state (unless you resort to scripting), but you can simulate one such state.

1) copy the resist death state and rename the copy to the state you want.

2) make a common event that checks all actors for HP=0 AND state applied.

3) if the conditions are met, the CE should change HP to 1 and remove the state

Now you only have to determine when to run the common event.

It could be run at the end of each round, in that case the actor will survive all attacks in that round with 1 HP at the end.

If you want it run after each skill use, then you either need a script, or place a call for this event in any skill that should have such a result.
Okay, thanks a lot for the response.

Now, how can I check if an actor's HP is 0? As far as I'm aware, in a conditional branch you can check for the death state but if that is being resisted then it won't work. Am I missing something?
Here ya go, just whipped up this small snipplet.

class Game_Battler < Game_BattlerBase def die if state?(100) @hp = 1 remove_state(100) else @hp = 0 clear_states clear_buffs end endendJust change the 100 to whatever your state ID is in both parts.

Place it in a new slot below materials and above main. Hopefully none of your custom scripts (if any) overwrite this method. I doubt it though.
Works perfectly! Thanks so much everyone, I really appreciate your help.

Problem solved.
Now, how can I check if an actor's HP is 0? As far as I'm aware, in a conditional branch you can check for the death state but if that is being resisted then it won't work. Am I missing something?
You can use scripts (like above), script commands or the control variable command.

A lot of game data needs two steps to check because it isn't available in the conditional branches directly.

The first command would be control variable to get the game data into a variable, and then a conditional branch checking the content of the variable.

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/altering-immortal-state.20056/