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