Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: tech williams on March 21, 2011, 02:35:04 pm

Title: [XP] Revival Point
Post by: tech williams on March 21, 2011, 02:35:04 pm
Revival point
Authors: Tech Williams
Version: 1.1
Type: Game Over Over-ride
Key Term: Title / Save / Load / GameOver Add-on



Introduction
I looked for ages for a script like this, and when I couldn't find it I decided to try my hand at scripting, so may I present to you, my very first script.

1.0- Uploaded
1.1- Moved variable configuration to the top of the script for your convenience.


Features




Screenshots
Spoiler: ShowHide
(http://i1086.photobucket.com/albums/j442/Armicost/Gameover.jpg)




Demo

I doubt one is needed.


Script
This script replaces the default scene_gameover
Spoiler: ShowHide

#==============================================================================
# ** Scene_Gameover
#------------------------------------------------------------------------------
#  This class performs game over screen processing.
#------------------------------------------------------------------------------
#  Created by Tech Williams. Credit is unnecessary for such a simple script but you can say thanks if you want.
#  Make sure you set the variables below and that its valid. If the variables arn't valid the game will crash.
#==============================================================================

class Scene_Gameover
  #--------------------------------------------------------------------------
  # Configuration
  #--------------------------------------------------------------------------
  # This command respawns to a location specified by three game variables.
  # You can change which variables it looks at by modifying the numbers below.
  # At the moment, there is no error catching, so if the map ID specified in
  # said variable doesn't exist, the game will crash. Use with care!
  #--------------------------------------------------------------------------
  RESPAWN_MAP_VAR = 1
  RESPAWN_X_VAR = 2
  RESPAWN_Y_VAR = 3
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   @transferring = false
   # Make game over graphic
   @sprite = Sprite.new
   @sprite.bitmap = RPG::Cache.gameover($data_system.gameover_name)
   # Make choice window
 #--------------------------------------------------------------------------
 # Here are the choices that will be displayed in the box that is shown on
 # the gameover screen. Just change the strings to change what the options
 # are. Bear in mind, however, that this will only change the text - it
 # won't have any effect on the command that takes place when each command
 # is selected.
 #--------------------------------------------------------------------------
   s1 = "Wake up"
   s2 = "Return to title"
   s3 = "End game"
   @choice_window = Window_Command.new(392, [s1, s2, s3])
   @choice_window.back_opacity = 160
   @choice_window.x = 320 - @choice_window.width / 2
   @choice_window.y = 308
   # 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)
   # 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 choice window
   @choice_window.dispose
   # Dispose of game over graphic
   @sprite.bitmap.dispose
   @sprite.dispose
   # Execute transition
   Graphics.transition(20)
   # Prepare for transition
   Graphics.freeze
   # If battle test
   if $BTEST
     $scene = nil
   end
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
   # Update command window
   @choice_window.update
   # If C button was pressed
   if Input.trigger?(Input::C)
     # Branch by command window cursor position
     case @choice_window.index
     when 0  # New game
       command_respawn
     when 1  # Continue
       command_title
     when 2  # End game
       command_shutdown
     end
   end
 end
 
 #--------------------------------------------------------------------------
 # * Command: Respawn (TO SPECIFIED LOCATION)
 #--------------------------------------------------------------------------
 def command_respawn
   #------------------------------------------------------------------------
   respawn_map_id = $game_variables[RESPAWN_MAP_VAR]
    respawn_map_x  = $game_variables[RESPAWN_X_VAR]
    respawn_map_y  = $game_variables[RESPAWN_Y_VAR]
   #------------------------------------------------------------------------
   #Lets commands like transfer player work properly
   $game_temp.in_battle = false
   #Keeps the gameover from playing repetitively.
   $game_temp.gameover = false
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Fade ME
   Audio.me_stop
   # Recover party
   for actor in $game_party.actors
     actor.recover_all
   end
   $game_map.setup(respawn_map_id)
   # Move player to initial position
   $game_player.moveto(respawn_map_x, respawn_map_y)
   # Refresh player
   $game_player.refresh
   # Run automatic change for BGM and BGS set with map
   $game_map.autoplay
   # Update map (run parallel process event)
   $game_map.update
   # Switch to map screen
   $scene = Scene_Map.new
 end

 #--------------------------------------------------------------------------
 # * Command: Return to title
 #--------------------------------------------------------------------------
 def command_title
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Fade out BGM, BGS, and ME
   Audio.me_fade(800)
   # Shutdown
   $scene = Scene_Title.new
 end

 #--------------------------------------------------------------------------
 # * Command: Shutdown
 #--------------------------------------------------------------------------
 def command_shutdown
   # Play decision SE
   $game_system.se_play($data_system.decision_se)
   # Fade out BGM, BGS, and ME
   Audio.me_fade(800)
   # Shutdown
   $scene = nil
 end
end



Instructions
Make sure you set the variables, I don't know how to make an error check so if you don't have valid points the game will crash.
This script replaces scene_gameover.


Compatibility

Well the only thing I tried it on was the default battle system


Credits and Thanks




Author's Notes

Im thinking of updates like being able to chose what way they face, an option to skip the game over screen completely and an automatic save when you die.
Title: Re: [XP] Revival Point
Post by: The Niche on March 21, 2011, 02:41:28 pm
Quote from: tech williams on March 21, 2011, 02:35:04 pm
Credits and Thanks


  • brewmeister for giving me the 2 commands I couldn't find and ending my insanity  :haha:

  • Do I have to credit the makers of RPG Maker?






No, you don't, but you should probably credit yourself.
Title: Re: [XP] Revival Point
Post by: KoenLemmen on March 21, 2011, 02:47:35 pm
NICE! DOWNLOADING!!!
Title: Re: [XP] Revival Point
Post by: Xuroth on March 21, 2011, 03:35:12 pm
Very nice! Once I decide on a plotline and develop my game a little more, I may use this. Level up!
Title: Re: [XP] Revival Point
Post by: Ryex on March 21, 2011, 11:35:16 pm
Nice, it's true, there really wasn't a script for this. good job finding something that hadn't been done before. *moves*
Title: Re: [XP] Revival Point
Post by: LiTTleDRAgo on March 22, 2011, 03:28:05 am
suggestion

    #------------------------------------------------------------------------
    respawn_map_id = $game_variables[X]
    respawn_map_x = $game_variables[X]
    respawn_map_y = $game_variables[X]
    #------------------------------------------------------------------------


I think you should done it like this


class Scene_Gameover

  RESPAWN_MAP_VAR = 1
  RESPAWN_X_VAR = 2
  RESPAWN_Y_VAR = 3
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    @transferring = false
    # Make game over graphic
    @sprite = Sprite.new
    bla bla bla
    ....
  end



  def command_respawn
    #------------------------------------------------------------------------
    respawn_map_id = $game_variables[RESPAWN_MAP_VAR]
    respawn_map_x  = $game_variables[RESPAWN_X_VAR]
    respawn_map_y  = $game_variables[RESPAWN_Y_VAR]
    #------------------------------------------------------------------------
    bla bla bla...
  end
end


That will help for configuring your script
Title: Re: [XP] Revival Point
Post by: brewmeister on March 22, 2011, 09:19:58 am
If the 'respawn' location is fixed throughout the game, the using Constants is neater.

If you want to change the respawn location as you move through the game..  i.e. local respawn locations,
then using game_variables makes it easy to control with events without using "script" commands.
Title: Re: [XP] Revival Point
Post by: G_G on March 22, 2011, 10:46:16 am
RESPAWN_MAP_VAR = 1
  RESPAWN_X_VAR = 2
  RESPAWN_Y_VAR = 3

Thats what Drago is using is variables. Those constants are the id's of the variables to use. That way people don't have to scroll through half the script to configure it.
Title: Re: [XP] Revival Point
Post by: tech williams on March 22, 2011, 12:04:42 pm
I updated it. Thanks LittleDrago.