Checkpoint and GameOver

Hello people, good night / afternoon / day.
I'm trying to create a checkpoint system, but I could not identify where Game Over is called to be able to replace the code. I imagine there are two ways: when the player loses a battle and when his character dies from damage on the map. The first one I found in the following method of BattleManager:

Spoiler: RGSS3
Code:
  def self.process_defeat
    $game_message.add(sprintf(Vocab::Defeat, $game_party.name))
    wait_for_message
    if @can_lose
      revive_battle_members
      replay_bgm_and_bgs
      SceneManager.return
    else
      SceneManager.goto(Scene_Gameover)
    end
    battle_end(2)
    return true
  end

I tried to just replace the command that calls the GameOver Scene by a line that calls a common event directly (that's how I'm going to base the system), but it did not work. The event is not only not called as, even removing the line, the GameOver Scene starts. The second mode, when player lost HP on the map, I did not even find it. Could someone explain to me how this type of code works? I tried to study this Himeworks code, but I did not understand anything and I do not want to use it because I need to learn how to create my own codes.

Thanks in advance. o/
Hi, the method that checks gameover from map is handled by check_gameover from Scene_Base.
About reserving a common event, can you show how you did the edit? We don't know what's wrong if you just said "it didn't work" without showing what you've done.

Also about Hime's script, I also have no idea how the script works. More like, if I write it myself, it's likely won't be like that
Hi @TheoAllen , thank you!
I have tried the following:
Spoiler
Code:
#===============================================================================
# CheckPoint System 1.0.0.0
#===============================================================================

# Check from map:
class Scene_Base
  def check_gameover
    if $game_party.all_dead?
      fadeout_all
      $game_temp.reserve_common_event(4)
    end
  end 
end

#-------------------------------------------------------------------------------

# Check from battle
module BattleManager
    def self.process_defeat
    $game_message.add(sprintf(Vocab::Defeat, $game_party.name))
    wait_for_message
    if @can_lose
      revive_battle_members
      replay_bgm_and_bgs
      SceneManager.return
    else
      fadeout_all
      SceneManager.goto(Scene_Map)
      $game_temp.reserve_common_event(4)
    end
    battle_end(2)
    return true
  end
 
  def fadeout_all(time = 1000)
    RPG::BGM.fade(time)
    RPG::BGS.fade(time)
    RPG::ME.fade(time)
    Graphics.fadeout(time * Graphics.frame_rate / 1000)
    RPG::BGM.stop
    RPG::BGS.stop
    RPG::ME.stop
  end
 
end
The common event simply teleports the player to a specific position and applies a fade in. But the GamveOver scene is still called. :headshake:
Have you tried to at least revive the battle member before the common event using script?
Additionally, you might want to setup the common event right away instead of reserving it for later.
Try to add "$game_map.setup_starting_event" right after "reserve_common_event"
Yes, I tried using the command $game_party.members.each { |actor| actor.recover_all }, it works. And you mean like that?
Code:
    $game_map.reserve_common_event(4)
    $game_map.setup_starting_event
    or
    $game_map.setup_starting_event(4)
None of them worked, you may have noticed what I did wrong. The first forced me to insert the reserve_common_event in Game_Map and the second one returns error in the arguments (0 of 1). Well, it looks like it's easier to edit GameOver than these conditions. Now the code is like this, the only thing that is not working is the common event that does not start:
Spoiler
Code:
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
class Game_Map
  def reserve_common_event(common_event_id)
    @common_event_id = common_event_id
  end
end
#==============================================================================
# ** Scene_Gameover
#------------------------------------------------------------------------------
class Scene_Gameover < Scene_Base
  #--------------------------------------------------------------------------
  # * Screen Update
  #--------------------------------------------------------------------------
  def update
    super
    call_event if Input.trigger?(:C)
  end
  #--------------------------------------------------------------------------
  # * Call Common Event
  #--------------------------------------------------------------------------
  def call_event
    fadeout_all
    $game_party.members.each { |actor| actor.recover_all }
    SceneManager.goto(Scene_Map)
    $game_map.reserve_common_event(4)
    $game_map.setup_starting_event
  end
end
I'm sorry, I'm pretty slow to understand, and Google Translate does not do much. ;_;
None of them worked
You don't use $game_map to reserve common event. The correct one would be
Code:
   $game_temp.reserve_common_event(4)
   $game_map.setup_starting_event

Also, unless you're releasing public script, personally I don't bother with common event.
You want the common event to transfer the player into specific location, right?
Why not write lines of codes that equivalent of transferring the player instead?
Or you don't know how to?
Oops, I did not know that, thank you. Now the common event is working, but the following error occurred: Unable to find file: Data/Map000.rvdata2. Both in battle and on the map. And I still really do not know how to rewrite it in code. The common event in question is this:

ImZgr9y.png


"Utility" is a variable that I use whenever I need a random number or some simple calculation. This is the check point itself:

3YJ4jQP.png
The reason could be, the value of variable 5 is zero which leads the map name being Map000.rvdata2 which is non-existent.
Maybe you haven't set the value of variable 5 yet? Could be because you haven't accessed checkpoint (which leads variable 5 being zero)
Spoiler: These little details of which I forget ...
a5RnDd5.jpg
It works perfectly now. Thank you very much. o/

Original thread: https://forums.rpgmakerweb.com/threads/checkpoint-and-gameover.92142/