Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Need help with my custome Game Over script

So not really super-custom, more like additions to the Scene and Update methods:

Code:
#==============================================================================

# ** Scene_Gameover

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

#  This class performs game over screen processing.

#==============================================================================

 

class Scene_Gameover

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

  # * Main Processing

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

  def main

    # Make game over graphic

    @sprite = Sprite.new

    @sprite.bitmap = RPG::Cache.gameover($data_system.gameover_name)

    # Stop BGM and BGS

    $game_system.bgm_play(nil)

    $game_system.bgs_play(nil)

    # Play game over ME

    $game_system.me_play($data_system.gameover_me)

    # Execute transition

    Graphics.transition(120)

    # Pre-Command Loop

    loop do

      Graphics.update

      Input.update

      if Input.trigger?(Input::C)

        break

      end

    end

    # Make command window

    s1 = "Continue"

    s2 = "Load Game"

    s3 = "Quit"

    @command_window = Window_Command.new(192, [s1, s2, s3])

    @command_window.back_opacity = 160

    @command_window.x = 320 - @command_window.width / 2

    @command_window.y = 288  

    # Main loop

    loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Frame update

      update

      # Abort loop if screen is changed

      if $scene != self

        break

      end

    end

    # Prepare for transition

    Graphics.freeze

    # Dispose of game over graphic

    @sprite.bitmap.dispose

    @sprite.dispose

    # Execute transition

    Graphics.transition(40)

    # Prepare for transition

    Graphics.freeze

    # If battle test

    if $BTEST

      $scene = nil

    end

  end

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

  # * Frame Update

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

  def update

    # Update command window

    @command_window.update

    # If C button was pressed

    if Input.trigger?(Input::C)

      # Branch by command window cursor position

      case @command_window.index

      when 0  # Continue

        $game_system.se_play($data_system.decision_se)

        $scene = Scene_Load.new

      when 1  # Load Game

        $game_system.se_play($data_system.decision_se)

        $scene = Scene_Load.new

      when 2  # Quit to Title

        $game_system.se_play($data_system.decision_se)

        $scene = Scene_Title.new

      end

    end

  end

end

 

Two problems.

First, when I choose "Load Game", the game keeps playing the Gameover ME when the loaded map loads. Is there a way around that?

Second, does anyone know of a good way to 'Continue', where-in the player is restored to a location of MapID, X, and Y, facing down and with the correct music, etc playing? I will store the MapID, X, and Y in three different variables.

Thanks in advance!
 
You may want to try to call to to turn the sound off before the scene changue.

Also, about your own continue method, i think that works with temporal variables for the defaults scripts, so, you can use the same or something similar. You save in game_temp x, y, map_id, and call scene map.new.

Then in the initialize method, or other, check for that variables and set it. You might want to add a flag variable (or use map id = nil, false...) for that, so you can make normal loading process.
 
Okay, so after a lot of hunting, learning, and trial-and-error, I have a good Game Over Script that mimics the way Kingdom Hearts does it:

Code:
#==============================================================================

# ** Scene_Gameover

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

#  This class performs game over screen processing.

#==============================================================================

 

class Scene_Gameover

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

  # * Main Processing

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

  def main

    # Make game over graphic

    @sprite = Sprite.new

    @sprite.bitmap = RPG::Cache.gameover($data_system.gameover_name)

    # Stop BGM and BGS

    $game_system.bgm_play(nil)

    $game_system.bgs_play(nil)

    # Play game over ME

    $game_system.me_play($data_system.gameover_me)

    # Execute transition

    Graphics.transition(120)

    # Pre-Command Loop

    loop do

      Graphics.update

      Input.update

      if Input.trigger?(Input::C)

        break

      end

    end

    # Make command window

    s1 = "Continue"

    s2 = "Load Game"

    s3 = "Quit"

    @command_window = Window_Command.new(192, [s1, s2, s3])

    @command_window.back_opacity = 160

    @command_window.x = 320 - @command_window.width / 2

    @command_window.y = 288  

    # Main loop

    loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Frame update

      update

      # Abort loop if screen is changed

      if $scene != self

        break

      end

    end

    # Prepare for transition

    Graphics.freeze

    # Dispose of game over graphic

    @sprite.bitmap.dispose

    @sprite.dispose

    # Execute transition

    Graphics.transition(40)

    # Prepare for transition

    Graphics.freeze

    # If battle test

    if $BTEST

      $scene = nil

    end

  end

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

  # * Frame Update

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

  def update

    # Update command window

    @command_window.update

    # If C button was pressed

    if Input.trigger?(Input::C)

      # Branch by command window cursor position

      case @command_window.index

      when 0  # Continue

        $game_system.se_play($data_system.decision_se)

        for i in 0..$game_party.actors.size - 1

          $game_party.actors[i].hp = ($game_party.actors[i].maxhp)/4

        end

        $game_temp.player_transferring = true

        $game_temp.player_new_map_id = $game_variables[23]

        $game_temp.player_new_x = $game_variables[24]

        $game_temp.player_new_y = $game_variables[25]

        $game_temp.player_new_direction = 2

        Audio.me_stop

        $game_switches[6] = true # Switch for Autoprocess to play proper music

        $scene = Scene_Map.new

        $game_temp.gameover = false

        $game_map.autoplay

      when 1  # Load Game

        $game_system.se_play($data_system.decision_se)

        Audio.me_stop

        $game_switches[6] = true # Switch for Autoprocess to play proper music

        $scene = Scene_Load.new

      when 2  # Quit to Title

        $game_system.se_play($data_system.decision_se)

        $scene = Scene_Title.new

      end

    end

  end

end

 

Note that Switch 6 is in a Parallel Process Event on the continue maps that starts up the correct BGM.

I am having some annoying problems that I cannot seem to fix. Let me list them:


  • 1. The command window with 'Continue, Load Game, and Quit' doesn't go away until either the Title Screen is fully up (using a customized version of MogHunter's Opening), or a Loaded Game is fully up in the loaded map. Otherwise, that command window persists.
    2. Continue does NOT work. The game goes to the new map, then the Game Over Screen immediately reappears. Nothing I have done can stop this.
    3. The Gameover ME persists unless I use Audio.me_stop, but it's very abrupt. If I try using Audio.me_fade(), it's not the same and doesn't work. Anyway to smooth it out?

Thanks in advance!
 
This works for me. I didn't get the repeating Game_Over problem, and the me_fade seems to work just fine.
(this is in a brand new project, so the map BGM works normally from Scene_Map.)

Code:
#==============================================================================

# ** Scene_Gameover

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

#  This class performs game over screen processing.

#==============================================================================

 

class Scene_Gameover

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

  # * Main Processing

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

  def main

    # Make game over graphic

    @sprite = Sprite.new

    @sprite.bitmap = RPG::Cache.gameover($data_system.gameover_name)

    # Stop BGM and BGS

    $game_system.bgm_play(nil)

    $game_system.bgs_play(nil)

    # Play game over ME

    $game_system.me_play($data_system.gameover_me)

    # Execute transition

    Graphics.transition(120)

    # Pre-Command Loop

    loop do

      Graphics.update

      Input.update

      if Input.trigger?(Input::C)

        break

      end

    end

    # Make command window

    s1 = "Continue"

    s2 = "Load Game"

    s3 = "Quit"

    @command_window = Window_Command.new(192, [s1, s2, s3])

    @command_window.back_opacity = 160

    @command_window.x = 320 - @command_window.width / 2

    @command_window.y = 288  

    # Main loop

    loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Frame update

      update

      # Abort loop if screen is changed

      if $scene != self

        break

      end

    end

    # Prepare for transition

    Graphics.freeze

    # Dispose of game over graphic

    @sprite.bitmap.dispose

    @sprite.dispose

    @command_window.dispose

    # Execute transition

    #Graphics.transition(40)

    # Prepare for transition

    #Graphics.freeze

    # If battle test

    if $BTEST

      $scene = nil

    end

  end

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

  # * Frame Update

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

  def update

    # Update command window

    @command_window.update

    # If C button was pressed

    if Input.trigger?(Input::C)

      # Branch by command window cursor position

      case @command_window.index

      when 0  # Continue

        $game_system.se_play($data_system.decision_se)

        for i in 0..$game_party.actors.size - 1

          $game_party.actors[i].hp = ($game_party.actors[i].maxhp)/4

        end

        $game_temp.player_transferring = true

        $game_temp.player_new_map_id = $game_variables[1]

        $game_temp.player_new_x = $game_variables[2]

        $game_temp.player_new_y = $game_variables[3]

        $game_temp.player_new_direction = 2

        Audio.me_fade(2000)

        $game_switches[6] = true # Switch for Autoprocess to play proper music

        $game_temp.gameover = false

        $game_player.moveto($game_variables[2], $game_variables[3])

        $game_map.setup($game_variables[1])

        $game_map.autoplay

        $game_map.update

        $scene = Scene_Map.new

      when 1  # Load Game

        $game_system.se_play($data_system.decision_se)

        Audio.me_stop

        $game_switches[6] = true # Switch for Autoprocess to play proper music

        $scene = Scene_Load.new

      when 2  # Quit to Title

        $game_system.se_play($data_system.decision_se)

        $scene = Scene_Title.new

      end

    end

  end

end

 
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top