How to make a "second life" ring?

In Dark Souls, there is a ring that, if it is equipped when the player dies, the ring will shatter and the player, instead of dying, will go to half health and be alive.

How exactly would one make something like this? How do you tell the game "if the player would die, instead do x"? Thank you.

I have written a haiku in appreciation to your responses:

What is death after all?

Perhaps just a second chance

At a life not lived.
https://yanflychannel.wordpress.com/rmvxa/battle-scripts/death-common-event/

:<>

How do I haiku?

I'm not good at writing them

Good luck with this script!
The "die" method, a method of Game_Battler, is as follows:

#-------------------------------------------------------------------------- # * Knock Out #-------------------------------------------------------------------------- def die @hp = 0 clear_states clear_buffs endSo I'm just guessing here, but I'd probably alias it with something like this:

class Game_Battler < Game_BattlerBasealias :die_with_ring :diedef die # Enemies can't have equips if self.is_a?(Game_Actor) # 4 is the Equip Slot for Accessories; make sure it's not empty! if @equips[4] != nil # 72 is the arbitrary ID of the second chance ring if @equips[4].id == 72 # Remove the ring from the actor change_equip(4, nil) # Then remove it from the party's inventory $game_party.lose_armors($data_armors[72]) # Revive the actor instead of killing them remove_state(death_state_id) @hp = mhp / 2 # Don't do the normal die processing return end end end # If the "return" wasn't hit, it means the ring wasn't equipped, so do the normal processing instead die_with_ringendendI haven't tested this, so there might be an error somewhere.  Let me know if it works.
Definitely was not expecting such swift replies this late!

@Rose thanks so much for this script I will certainly test it out 🙂 edit: not sure how this script deals with the item requirement? I just read through it.

@Wavelength, testing that code right now! Good to see you out and about on here 😛

Wavelength, I get the following error:

4JE2pQD.jpg
I am no real scripter yet, but it looks like its searching for the Item ID with the ring? does that screen come up Before after the title screen, and before you play, or does it come up when you die?
I am no real scripter yet, but it looks like its searching for the Item ID with the ring? does that screen come up Before after the title screen, and before you play, or does it come up when you die?
The moment I press New Game.
hmm...

no idea
Definitely was not expecting such swift replies this late!

@Rose thanks so much for this script I will certainly test it out 🙂 edit: not sure how this script deals with the item requirement? I just read through it.
If you make a common event upon death that check to see if their wearing (x) item, revives your actor, and restores 50% of the hp. You'll be able to emulate the ring... oh yeah, you'll need to unequip the ring and remove it from inventory too. :X
Oh that's extremely helpful! Testing now 😀
Wavelength should never/

Try to write his complex code/

Right before bedtime.

OK, just woke up and did some testing myself.  Yeah, there were some errors with my code.  Here's how it should be:

class Game_Battler < Game_BattlerBasealias :die_with_ring :diedef die # Enemies can't have equips if self.is_a?(Game_Actor) # 4 is the Equip Slot for Accessories; make sure it's not empty! if equips[4] != nil # 72 is the arbitrary ID of the second chance ring if equips[4].id == 72 # Remove the ring from the actor change_equip(4, nil) # Then remove it from the party's inventory $game_party.lose_item($data_armors[72], 1) # Revive the actor instead of killing them remove_state(death_state_id) @hp = mhp / 2 # Don't do the normal die processing return end end end # If the "return" wasn't hit, it means the ring wasn't equipped, so do the normal processing instead die_with_ringendendNote that I used equips instead of @equips and lose_item instead of the nonexistant lose_armors.

But the fact that you were getting the errors as soon as a new game is started - not at runtime, not when an actor dies, but as soon as the new game begins - is very weird.  So when I tested, I found that the Ring equipped to a starting actor was already gone.  However, this is just a quirk that happens during the new game phase for some reason.  When the actor equips a ring normally and brings it into battle, it's working perfectly with this new code.

Try it out and I hope it works well for you!

Alternatively, as Rose mentioned, I do believe the Common Events solution would work - but it's technically riskier and I think more processing-intensive.
I do appreciate both of you, like you said Wavelength, I prefer the less processing route. Also, love the haiku. Many thanks guys

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-a-second-life-ring.46746/