Any way to make an item that automatically revives someone when they die if the item exists in your inventory?

Since the game I'm working on only has one single party member, I felt that maybe it would be unfair if you just instantly game over if your one character gets killed. So I'd like to implement an item that sits in your inventory, and if you die with one in your possession, the item is consumed and you are automatically revived, instead of getting a Game Over.

How can I achieve this effect?
depends on how the actor dies.

if this is about battles, you'll need two troop events in every troop (perhaps using a base troop script to simplyfy this).
one event runs on turn 0, checks if the item is in inventory and if yes applies an immortal state that has no message at all to the player (this is to delay the engine and to allow the other event to run before game-over)
the second event runs on HP=0 for the actor, checks if more than one of the items is available. if yes, simply reduce number by one and apply the heal effect. if no then apply heal effect but remove the immortal state so that the next case does kill.

if this is by map events, you need to have every event check before applying damage - that is most easily done by calling a common event that handles the damage from every single event that can damage the actor.

if the death is by tile damage, that is more difficult - so do you have any use of damage tiles on your maps?
Would you really want that? If you die in a random battle, then you loose the item.
I would prefer when you use the item, and then when he/she dies, he/she ressurects.
i prefer auto revive state 'after' using the the item.
take the item out of storage for a boss fight, get killed by some fluke crit or other cheap crap b4 reach the boss, item gone, boss kills you n he only has 5% HP left,
throw controller because some mechanic screwed over your plans that woulda worked out perfectly if just had control over when the thing got used up instead of it being auto consumed at the 1st opportunity.

at the very least it needs to be an option to consume it or just accept that death.
theres been other games that dont have an easy 'exit to title' option and just try to kill yourself and reload cus f'd up somewhere. no option means need to kill yourself intentionally more then once now,
and sometimes even just commiting suicide is a hassle
depends on how the actor dies.

if this is about battles, you'll need two troop events in every troop (perhaps using a base troop script to simplyfy this).
one event runs on turn 0, checks if the item is in inventory and if yes applies an immortal state that has no message at all to the player (this is to delay the engine and to allow the other event to run before game-over)
the second event runs on HP=0 for the actor, checks if more than one of the items is available. if yes, simply reduce number by one and apply the heal effect. if no then apply heal effect but remove the immortal state so that the next case does kill.

if this is by map events, you need to have every event check before applying damage - that is most easily done by calling a common event that handles the damage from every single event that can damage the actor.

if the death is by tile damage, that is more difficult - so do you have any use of damage tiles on your maps?

Hmm... But wouldn't that just leave you at zero HP and need to be hit again to die? Unless I'm misunderstanding.

I don't have any regular damage tiles, but I do have a few traps that reduce HP, though they also forbid knockout. Poison does not persist out of battle either, if you were wondering.

Would you really want that? If you die in a random battle, then you loose the item.
I would prefer when you use the item, and then when he/she dies, he/she ressurects.

Yeah, this is definitely how I wanna do it. Because see, what I wanna do is have an NPC that will sell you the item in question - but if you already possess one, they won't let you buy another. This keeps you from stacking them and gives you only one extra life.

i prefer auto revive state 'after' using the the item.
take the item out of storage for a boss fight, get killed by some fluke crit or other cheap crap b4 reach the boss, item gone, boss kills you n he only has 5% HP left,
throw controller because some mechanic screwed over your plans that woulda worked out perfectly if just had control over when the thing got used up instead of it being auto consumed at the 1st opportunity.

at the very least it needs to be an option to consume it or just accept that death.
theres been other games that dont have an easy 'exit to title' option and just try to kill yourself and reload cus f'd up somewhere. no option means need to kill yourself intentionally more then once now,
and sometimes even just commiting suicide is a hassle

You raise a good point! Okay so... how do I accomplish this event, while also allowing the player to decide if they want to use the item or accept death?
But wouldn't that just leave you at zero HP and need to be hit again to die? Unless I'm misunderstanding.
that is why I included the comment about healing effect in the description - of course the actor needs to be healed up by the item to prevent that.
You can also use scripts if they meet your requirement.
I have two variations in this thread.

I also have a script made by GGZiron called afterlife, which makes you go to a new map as a ghost and you do something (talk to an event) to return back to normal.
You can also use scripts if they meet your requirement.
I have two variations in this thread.

I also have a script made by GGZiron called afterlife, which makes you go to a new map as a ghost and you do something (talk to an event) to return back to normal.

That Death Common Event thing works exactly how I need it to! Thanks! 😀

Original thread: https://forums.rpgmakerweb.com/threads/any-way-to-make-an-item-that-automatically-revives-someone-when-they-die-if-the-item-exists-in-your-inventory.140008/