[XP] Juan's Custom Gameover

Started by Juan, September 02, 2008, 12:03:40 am

Previous topic - Next topic

Juan

September 02, 2008, 12:03:40 am Last Edit: April 27, 2016, 10:58:38 am by Juan
Juan's Custom Gameover
Authors: Juan
Version: 1.3
Type: GameOver Add-on
Key Term: Title / Save / Load / GameOver Add-on



Introduction

This script allows you have a custom gameover edit with the folllowing menu items return ot title, load game, or end game.


Features


  • Gameover Menu



Screenshots

Spoiler: ShowHide


Demo
N/A


Script

Spoiler: ShowHide
#==============================================================================
# ** Juan's Custom Gameover
#------------------------------------------------------------------------------
# Juan
# Version 1.3
# Date 9/1/08
#==============================================================================
#
#
# Compatibility:
# This script should be 100% compatibly with everything except other custom
# gameover scripts. Doesn't automatic setup variables if used from earlyer save
# but can be changed using variables in-game.
#
#
# Features:
#
# -> menu commands "Revive", "Return to title", "Load Game", "End Game"
# -> The load menu is disabled if theres no save files.
# -> Uses variables for respawn setup, gold lost and death toll
# meaning you can change respawn and gold lost using variables in-game
# -> Auto setups the respawn positon, and gold lost after player starts
# a new game.
#
# Version History
#
# Version 1.0
# -> This script was first made
# Version 1.3
# -> Added revive point with 1 hp, and sp or fully heal player.
# -> Added ability for player to lose gold
# -> Added ability to keep track of how many times a player died.
#
#
# Instructions
# Configure these parts
#   Whether or not to fully heal the party before spawning
#   or just with hp 1 and 1 sp
#  Full_Heal = false
#   Variable for map to transfer to
#  Respawn_Map_ID =  1
#   Default map number to transfer if gameover
#  Respawn__Current_Location = 1
#   Variable for map's x
#  Respawn_Map_X = 2
#   Default map's x postion to transfer if gameover
#  Respawn_Current_X = 9
#   Variable for map's y postion
#  Respawn_Map_Y = 3
#   Default map's y to transfer if gameover
#  Respawn_Current_Y = 11
#   Variable for which direction for player to face after respawning
#  Respawn_Position = 4
#   Current respawn postion 2 for down 4 for left 6 for right and 8 for up
#  Current_Respawn_Position = 2
#   Whether or not the player should lose gold after reving
#  Respawn_Gold = false
#   Respawn how much gold is lost
#  Respawn_Gold_Lost = 5
#   How much should the player lose if respawn gold is true
#  Respawn_Current_Gold_Lost = 1000
#   Whether or not death toll is enabled
#  Respawn_Death_Toll_Enabled = false
#   Variable for total times player revived or loaded.
#  Respawn_Death_Toll = 6
#   The number of save files starts from 0 not 1 keep that in mine.
#  Save_Files_Number = 3
#  The name of your savefiles (usually "Save")
#  Save_Name = 'Save'
#  The extension of your savefiles (usually "rxdata")
#  Save_Ext = 'rxdata'
#
#
#
# FAQ (Frequently Asked Questions):
# None so far
#
#
# Credits
# Juan I made this script.
# Starrodkirby86 for help with positioning.
# Blizzard death toll similar to the one in tons of add ons
#
#
# Author's Notes
# Any bugs
# Report them here:
# http://forum.chaos-project.com/index.php?topic=11.0
# or
# Email me
# Juanito119@yahoo.com
# Thats it
# enjoy

module Juan_Cfg
  # Whether or not to fully heal the party before spawning
  # or just with hp 1 and 1 sp
  Full_Heal = false
  # Variable for map to transfer to
  Respawn_Map_ID =  1
  # Default map number to transfer if gameover
  Respawn__Current_Location = 1
  # Variable for map's x
  Respawn_Map_X = 2
  # Default map's x postion to transfer if gameover
  Respawn_Current_X = 9
  # Variable for map's y postion
  Respawn_Map_Y = 3
  # Default map's y to transfer if gameover
  Respawn_Current_Y = 11
  # Variable for which direction for player to face after respawning
  Respawn_Position = 4
  # Current respawn postion 2 for down 4 for left 6 for right and 8 for up
  Current_Respawn_Position = 2
  # Whether or not the player should lose gold after reving
  Respawn_Gold = false
  # Respawn how much gold is lost
  Respawn_Gold_Lost = 5
  # How much should the player lose if respawn gold is true
  Respawn_Current_Gold_Lost = 1000
  # Whether or not death toll is enabled
  Respawn_Death_Toll_Enabled = false
  # Variable for total times player revived or loaded.
  Respawn_Death_Toll = 6
  # The number of save files starts from 0 not 1 keep that in mine.
  Save_Files_Number = 3
  #The name of your savefiles (usually "Save")
  Save_Name = 'Save'
  #The extension of your savefiles (usually "rxdata")
  Save_Ext = 'rxdata'
end

#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
#  This class performs title screen processing.
#==============================================================================
class Scene_Title
  alias command_new_game_juan_gameover_later command_new_game
  #--------------------------------------------------------------------------
  # * Command: New Game
  #--------------------------------------------------------------------------
  def command_new_game
    command_new_game_juan_gameover_later
    # Initial map id, map x, map y, and map position to face, gold if
    # respawn gold is true.
    $game_variables[Juan_Cfg::Respawn_Map_ID] = Juan_Cfg::Respawn__Current_Location
    $game_variables[Juan_Cfg::Respawn_Map_X] = Juan_Cfg::Respawn_Current_X
    $game_variables[Juan_Cfg::Respawn_Map_Y] = Juan_Cfg::Respawn_Current_Y
    $game_variables[Juan_Cfg::Respawn_Position] = Juan_Cfg::Current_Respawn_Position
    if Juan_Cfg::Respawn_Gold
    $game_variables[Juan_Cfg::Respawn_Gold_Lost] = Juan_Cfg::Current_Respawn_Position
    end
  end
end


#==============================================================================
# ** Scene_Gameover
#------------------------------------------------------------------------------
#  This class performs game over screen processing.
#==============================================================================

class Scene_Gameover
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Creates command window
    create_command_window   
    # Make game over graphic
    create_gameover_graphic
    # plays gameover music
    play_gameover_music
    # Execute transition
    Graphics.transition
    # Main loop
    loop {
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      break if $scene != self
    }
    # Prepare for transition
    Graphics.freeze
    # Dispose of processes
    terminate
    # Execute transition
    Graphics.transition
    # Prepare for transition
    Graphics.freeze
    # If battle test
    if $BTEST
      $scene = nil
    end
  end
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  def create_command_window
    s1 = 'Revive'
    s2 = 'Return to title'
    s3 = 'Load Game'
    s4 = 'End Game'
    # Make command window
    @command_window = Window_Command.new(192, [s1, s2, s3, s4])
    @command_window.index = @menu_index   
    @command_window.back_opacity = 160
    @command_window.x = 320 - @command_window.width / 2
    @command_window.y = 288   
    @continue = (0..Juan_Cfg::Save_Files_Number).any? {|i|
    FileTest.exist?("#{Juan_Cfg::Save_Name}#{i + 1}.#{Juan_Cfg::Save_Ext}")}
    # If there are no save files disable load.
    @command_window.disable_item(2) unless @continue
  end 
  #--------------------------------------------------------------------------
  # * Create Game Over Graphic
  #--------------------------------------------------------------------------
  def create_gameover_graphic
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.gameover($data_system.gameover_name)
  end 
  #--------------------------------------------------------------------------
  # * Play Music on Game Over Screen
  #-------------------------------------------------------------------------
  def play_gameover_music
    # 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)
  end 
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    @command_window.dispose
    @sprite.bitmap.dispose
    @sprite.dispose
  end 
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @command_window.update
    # If command window is active: call update_command
    if @command_window.active
      update_command
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when command window is active)
  #--------------------------------------------------------------------------
  def update_command   
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to title screen
      $scene = Scene_Title.new
    # If C button was pressed
    elsif Input.trigger?(Input::C)
      # if Death toll is enabled
        if Juan_Cfg::Respawn_Death_Toll_Enabled
        # increase death count by 1
        $game_variables[Respawn_Death_Toll] += 1
        end
      # Branch by command window cursor position
      case @command_window.index
      when 0 # Revive     
        # Clear gameover flag
        $game_temp.gameover = false
        # Clear player place move call flag
        $game_temp.player_transferring = false
        # Clear battle calling flag
        $game_temp.battle_calling = false
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Set up a new map
        $game_map.setup($game_variables[Juan_Cfg::Respawn_Map_ID])
        # Set up player position
        $game_player.moveto($game_variables[Juan_Cfg::Respawn_Map_X], $game_variables[Juan_Cfg::Respawn_Map_Y])
        case $game_variables[Juan_Cfg::Respawn_Position]
         when 2
          $game_player.turn_down
         when 4
           $game_player.turn_left
         when 6
           $game_player.turn_right
         when 8
           $game_player.turn_up
         end       
        # Straighten player position
        $game_player.straighten
        # Heal party
        if Juan_Cfg::Full_Heal
          $game_party.actors.each {|actor| actor.recover_all}
         else
          $game_party.actors.each {|actor|
          actor.remove_state(1)
          actor.hp += 1
          actor.sp += 1}
        end
        # checks if respawn gold is true
        if Juan_Cfg::Respawn_Gold
        # makes the player loses game from respawn gold lost variable
        $game_party.lose_gold($game_variables[Respawn_Gold_Lost])
        end
        # refreshes map
        $game_map.refresh
        # Run automatic change for BGM and BGS set on the map
        $game_map.autoplay
        # update game map
        $game_map.update
        # Switch to map screen
        $scene = Scene_Map.new
        # Frame reset
        Graphics.frame_reset
        # Update input information
        Input.update
      when 1  # Return to title
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to item screen
        $scene = Scene_Title.new
      when 2  # Load Game
        unless @continue
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end       
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to load game screen
        $scene = Scene_Gameover_Load.new       
      when 3  # End Game
        # Play decision SE
        $game_system.se_play($data_system.decision_se)           
        # Switch to title screen
      $scene = nil
      end
    end
  end
end


#==============================================================================
# ** Scene_Load
#------------------------------------------------------------------------------
#  This class performs load screen processing.
#==============================================================================

class Scene_Gameover_Load < Scene_Load
  #--------------------------------------------------------------------------
  # * Cancel Processing
  #--------------------------------------------------------------------------
  def on_cancel
    # Play cancel SE
    $game_system.se_play($data_system.cancel_se)
    # Switch to title screen
    $scene = Scene_Gameover.new(2)
  end
end


Instructions

Configure these parts
Spoiler: ShowHide
  # The number of save files starts from 0 not 1 keep that in mine.
#   Whether or not to fully heal the party before spawning
#   or just with hp 1 and 1 sp
#  Full_Heal = false
#   Variable for map to transfer to
#  Respawn_Map_ID =  1
#   Default map number to transfer if gameover
#  Respawn__Current_Location = 1
#   Variable for map's x
#  Respawn_Map_X = 2
#   Default map's x postion to transfer if gameover
#  Respawn_Current_X = 9
#   Variable for map's y postion
#  Respawn_Map_Y = 3
#   Default map's y to transfer if gameover
#  Respawn_Current_Y = 11
#   Variable for which direction for player to face after respawning
#  Respawn_Position = 4
#   Current respawn postion 2 for down 4 for left 6 for right and 8 for up
#  Current_Respawn_Position = 2
#   Whether or not the player should lose gold after reving
#  Respawn_Gold = false
#   Respawn how much gold is lost
#  Respawn_Gold_Lost = 5
#   How much should the player lose if respawn gold is true
#  Respawn_Current_Gold_Lost = 1000
#   Whether or not death toll is enabled
#  Respawn_Death_Toll_Enabled = false
#   Variable for total times player revived or loaded.
#  Respawn_Death_Toll = 6
#   The number of save files starts from 0 not 1 keep that in mine.
#  Save_Files_Number = 3
#  The name of your savefiles (usually "Save")
#  Save_Name = 'Save'
#  The extension of your savefiles (usually "rxdata")
#  Save_Ext = 'rxdata'



Compatibility

This script should be 100% compatibly with everything except other custom gameover scripts. Doesn't automatic setup variables if used from earlyer save but can be changed using variables in-game.


Credits and Thanks


  • Juan I made this script.
  • Starrodkirby86 for help with positioning.
  • Blizzard death toll similar to the one in tons of add ons



Author's Notes

Any bugs report them here or email me at Juanito119@yahoo.com
Dropbox Who need luck when you can make your own.
3ds Friend code: ShowHide
 4468 1422  6617

Aqua

Looks good...
You made a messup with the spoiler though...

And you should say that there isn't a demo.

Starrodkirby86

Since you have to leave, I corrected those minor formatting errors. :)

This instantly follows all the items in the template, so I'll move this. A very convenient script at such a low cost. I can easily see you rushed a lot of areas (keep that in mine). Good job, and this is a good practice script to further develop RGSS skills. XD

What's osu!? It's a rhythm game. Thought I should have a signature with a working rank. ;P It's now clickable!
Still Aqua's biggest fan (Or am I?).




Diokatsu

Nearly everyone credits SRK86....NUUUU I feel worthless!


Great little nugget of scripting here Juan! I like it ^_^

Juan

thanks I was rused to get off the computer thats why I made some mistakes.
Dropbox Who need luck when you can make your own.
3ds Friend code: ShowHide
 4468 1422  6617

Diokatsu

Woah Juan O.o You make good use of comments. I wish I was that faithful to nice looking and readable stuff :'(

Blizzard

Juan, you should add yourself to the credits and add that you are thanking SRK. O.o; People will assume he made it otherwise. xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Juan

Dropbox Who need luck when you can make your own.
3ds Friend code: ShowHide
 4468 1422  6617