MV Character revival after losing battle

Would ask in Game Mechanics Design, but I doubt I'd be able to ask without mentioning my project.

Alright, so I dunno where to look in MV for this, but I need a means of making it so that once the Player Character is killed in battle, even if there are allies present, to trigger an event that causes a death animation (I'm already figuring I'll have to make it myself - the animation) to activate (basically the moment HP hits 0 caused by anything in battle).
Then just after the character shown disintegrating (that is what the animation is), instead of a "game over" screen, it transfers the character to specified location, fully healed as if they had just used a tent.

The other bit that I need to figure out is making it so the Player Character gains exp points from each kill, regardless if they fully win a battle, or get killed themselves, or run away. That one I bet is likely more simple than my above mechanic idea.
Dunno if this would work but you could give it a try,
set a variable that measures the HP of your character
Then a conditional branch that looks if the variable is 0...
Should look something like this:
1637147805938.png



But then again, battling was never my strong side so im really not sure if this will work.
EDIT: seems not to work, guess the game over got priority.
@Spaske that won't help because map event don't work on battlescreen.

@Zanderfel you'll need a troop event in every troop (or use a base troop plugin to automatically copy it) that checks for actor HP=0 as condition, and then do whatever you want there.
this can include giving exp before aborting battle and a lot of your other effects.

Depending on how many actors you have and what the battle does you might have to give an immortal state at the beginning of the battle to prevent automatic game-over - if you need help with that we would have to get some more info about your party first.
I may have found another way:
1637149335440.png

Something like this, you can teleport them after the battle, it works btw. just tested it.
Player 1 reid was at 0 HP and the battle was aborted but i had another party member alive.
Dunno if it still works if they all dead and player 1 dies last, gonna test it rn.
I may have found another way:
no, that also has problems
you need to use the actor HP in the condition, not in the conditional branch
no, that also has problems
you need to use the actor HP in the condition, not in the conditional branch
True, thx.

Here:
1637150446291.png


As long as other members are alive, it will abort the battle or whatever you want it to do, if reid is the last living member and dies last then it will trigger game over.
@Zanderfel you'll need a troop event in every troop (or use a base troop plugin to automatically copy it) that checks for actor HP=0 as condition, and then do whatever you want there.
this can include giving exp before aborting battle and a lot of your other effects.

Depending on how many actors you have and what the battle does you might have to give an immortal state at the beginning of the battle to prevent automatic game-over - if you need help with that we would have to get some more info about your party first.
Its just for one character. There are points that I plan to add in Escort-Battle quests, and that is the only way that the player character will get allies. If won't happen often either.
And the idea for if the Player Character dies, it is considered the same as if the entire party was killed, so queue death animation, battle ends, character transfer to location, but the ally they had with them is no longer part of their party, cause for that NPC, your character is dead.
This in effect causes the quest to fail. If player wants to retry, then they'll have to reload.

Much later, I'll add the ability for the Player character to summon/create minions, but are only active via spell/ability used in battle, at battle's end, win/lose, minions go away like any other spell effect.

But yeah, that's all I have planned in terms of other allies. No permanent allies in mine.
Did you consider this?
1637151400302.png
Its just for one character.
in that case you'll need a second troop event on turn 0 to give the actor an immortal state (no messages, no icon, only resist death state) and have that immortal state removed at the end of the troop event above.

the problem is that if the last actor dies, the battle is ended immediatly without running the troop event.
by having the actor resist death at HP=0 the engine will execute the event and only end the battle after that state is removed.
Didn't know about that - @Andar would that work? I'm guessing I'd still have to apply it to every single battle.
Didn't know about that - @Andar would that work? I'm guessing I'd still have to apply it to every single battle.
No, it works, its a trait:
1637152693830.png

He wont die and you can run everything you want without fearing an gameover screen.
No, it works, its a trait:
the problem with that is that traits can't be removed from the actor.
with the trait in a state given on turn 0, the actor can die if the state is removed.
if you do the same as a trait, then the actor can never die no matter what.

if that is desired, then you can go that route - for most cases however it is not.
No, it works, its a trait: View attachment 206974
He wont die and you can run everything you want without fearing an gameover screen.

the problem with that is that traits can't be removed from the actor.
with the trait in a state given on turn 0, the actor can die if the state is removed.
if you do the same as a trait, then the actor can never die no matter what.

if that is desired, then you can go that route - for most cases however it is not.
What do you mean? There is a remove state function or not?
1637157127387.png



Edit: ok just tested it and i know what you mean but what could be done to fix this, just manually put a game over if desired, so the trait does not have to be changed.
What do you mean? There is a remove state function or not?
you can remove any state, but not the trait "resist death" unless it is placed on a state.
if you place the trait "resist death" on the actor like you did in your screenshot, that trait can never be removed in the game, and as a result that actor will never die - not even when the developer want it to die.
you can remove any state, but not the trait "resist death" unless it is placed on a state.
if you place the trait "resist death" on the actor like you did in your screenshot, that trait can never be removed in the game, and as a result that actor will never die - not even when the developer want it to die.
Yes i already counted 1+1 and realised its not possible. 😀
But as stated above, he can easily bypass this by adding a game over screen, just tested it and works.
1637157863553.png


or he could make another 1:1 character without the trait and change them but then he had to make variables for change armor, weapons, level ect... as well...

I think the manual game over is the easier method.
I have a system in place such that when anyone of my players die in battle, should they not be revived before the battle ends, they are removed from the party and transported elsewhere. Upon retrieval they are healed...is this something akin to what you're wanting?

EDIT: Nevermind, I just read what you want. I might be able to think something up anyway.
I have a system in place such that when anyone of my players die in battle, should they not be revived before the battle ends, they are removed from the party and transported elsewhere. Upon retrieval they are healed...is this something akin to what you're wanting?

EDIT: Nevermind, I just read what you want. I might be able to think something up anyway.
Damn close to it though
The other bit that I need to figure out is making it so the Player Character gains exp points from each kill, regardless if they fully win a battle, or get killed themselves, or run away. That one I bet is likely more simple than my above mechanic idea.
This is similar to the Action XP Gain mechanic I use:
JavaScript:
<Custom React Effect>
target._oldHp = target.hp;
</Custom React Effect>
<Custom Establish Effect>
if (user.isActor() && target.result()) {
  if (target.isEnemy() && target.result().hpDamage > 0) {
    var XP = Math.round(Math.PI * target.exp() * Math.min(target.result().hpDamage, target._oldHp) / target.mhp);
    user.gainExp(XP);
    BattleManagerTBS.activeEntity().addTextPopup("+" + XP + "xp", 28, "#fd5ca8");
  } else if (target.isActor() && target.result().hpDamage < 0) {
    var XP = (target.result().hpDamage + target._oldHp - target.mhp) * target.level;
    user.gainExp(XP);
    BattleManagerTBS.activeEntity().addTextPopup("+" + XP + "xp", 28, "#fd5ca8");
  }
}
</Custom Establish Effect>
You'll have to modify it to grant XP on kill instead of on dmg dealt, but that shouldn't be too hard. This is just to give you some idea/inspiration.
So...is there still a question? I just scanned through the thread, and I think you have your solution.
You give your actor (either by trait or a Yanfly passive state) immortality, then have a troop event that looks for him to be at 0 HP and do all the stuff you want.

I would use something like Yanfly's Base Troop Events so that every battle works the same way, but it's also not that hard to copy/paste the page onto your troops.

As far as the XP goes, you could do something like Frostorm has, although you'd then also need to work around the normal battle aftermath which gives you XP.

I think a simpler solution would be inside of the troop event that yanks you out on death, have a short bit of script that checks for any dead enemies and gives you the XP for them.
Why not just create a event page in the battle and make the condition if enemy = 0% HP give XP...?

Original thread: https://forums.rpgmakerweb.com/threads/character-revival-after-losing-battle.142222/