Checkpoint and GameOver

Faherya

The Knight of the Sad Figure
Veteran
Joined
Jul 25, 2013
Messages
254
Reaction score
582
First Language
Portuguese
Primarily Uses
RMVXA
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:

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/
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
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
 

Faherya

The Knight of the Sad Figure
Veteran
Joined
Jul 25, 2013
Messages
254
Reaction score
582
First Language
Portuguese
Primarily Uses
RMVXA
Hi @TheoAllen , thank you!
I have tried the following:
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:
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
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"
 

Faherya

The Knight of the Sad Figure
Veteran
Joined
Jul 25, 2013
Messages
254
Reaction score
582
First Language
Portuguese
Primarily Uses
RMVXA
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:
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. ;_;
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
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?
 

Faherya

The Knight of the Sad Figure
Veteran
Joined
Jul 25, 2013
Messages
254
Reaction score
582
First Language
Portuguese
Primarily Uses
RMVXA
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:



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

 
Last edited:

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
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)
 

Faherya

The Knight of the Sad Figure
Veteran
Joined
Jul 25, 2013
Messages
254
Reaction score
582
First Language
Portuguese
Primarily Uses
RMVXA
It works perfectly now. Thank you very much. o/
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top