[RMXP] Call common event on death

Introduction

Call a common event instead of a gameover on death.

Use this if you want to show a conversation, or do something else, on dying, controlled using a common event. You can use the gameover event command if you want to gameover as usual at the end of it.

Script

  1. #===============================================================================
  2. # Call common event on battle. By Amy @ http://www.hbgames.org
  3. #===============================================================================
  4. class Scene_Battle
  5.  
  6.   # Set this to the common event you wish to call.  
  7.   EVENT_ID = 2
  8.  
  9.   alias :amy_judge :judge
  10.  
  11.   # Judge, aliased to amy_judge
  12.   def judge
  13.     old_judge = amy_judge    
  14.    
  15.     # If we're in a gameover and not a "can lose" battle
  16.     if $game_temp.gameover and !$game_temp.battle_can_lose
  17.       # Get the common event
  18.       battle_event = $data_common_events[EVENT_ID]
  19.       # Call the interpreter for this event
  20.       $game_system.battle_interpreter.setup(battle_event.list, 0)
  21.       # No longer a game over!
  22.       $game_temp.gameover = false
  23.       return
  24.     end
  25.    
  26.     # Otherwise, call the former method
  27.     return old_judge
  28.   end
  29. end
Expand to see the code.


Instructions

Paste above main. Change EVENT_ID to the number of the common event you want to use.

Credits

None necessary.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=77280