Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: tech williams on March 12, 2011, 07:53:47 pm

Title: Respon kills me
Post by: tech williams on March 12, 2011, 07:53:47 pm
Im trying to make my first script by editing scene_gameover so that I can respon to another place if the player chooses, but it seems I made a mistake somewhere and now whenever you die it shows the game over screen over and over. I don't really know why and I thought the script worked, and I couldn't find a similar script here

This is my script:
Spoiler: ShowHide

#==============================================================================
# ** Scene_Gameover
#==============================================================================

class Scene_Gameover
  #--------------------------------------------------------------------------
  # * 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.
  #--------------------------------------------------------------------------
    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)
  #--------------------------------------------------------------------------
  # This command respawns to a location specified by three game variables.
  # You can change which variables it looks at by modifying the numbers in
  # the square brackets below.
  #--------------------------------------------------------------------------
  def command_respawn
    #------------------------------------------------------------------------
    respawn_map_id = $game_variables[1]
    respawn_map_x = $game_variables[2]
    respawn_map_y = $game_variables[3]
    #------------------------------------------------------------------------
    # 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
Title: Re: Respon kills me
Post by: ForeverZer0 on March 12, 2011, 08:09:14 pm
That works fine in an empty project. (I simply hard-coded the respawn variables)
What other scripts are you using?

EDIT:
I found the problem. On my first test I had just made a script call to make it Scene_Gameover, but I thought it may be an Interpreter problem. Sure enough, when I used the "Gameover" event command I got your error.
Title: Re: Respon kills me
Post by: tech williams on March 12, 2011, 11:28:16 pm
So uh, How do I fix it?  :^_^':
Title: Re: Respon kills me
Post by: ForeverZer0 on March 12, 2011, 11:34:47 pm
I can't remember off the top of my head to be quite honest.
You can always just substitute the event command in the editor, with this simple script call:

$scene = Scene_Gameover.new


They both do the exact same thing. I didn't look real close, but it seems like the Interpreter is simply calling the command again. You could try $game_system.map_interpreter.clear

I think that's what it is.... :hm:
Title: Re: Respon kills me
Post by: tech williams on March 13, 2011, 12:09:57 am
I hate being new at things, I have no idea what your talking about  :shy:
Title: Re: Respon kills me
Post by: ForeverZer0 on March 13, 2011, 12:30:32 am
lol, don't worry about it. You'll learn like everyone else who knows had to. It takes time.

For now, just use the script call from my above post instead of the the "Game Over" event command to call the menu.
Title: Re: Respon kills me
Post by: tech williams on March 13, 2011, 12:47:26 am
Hopefully it's just because I'm sick, but replace what with what where?  :???:
Title: Re: Respon kills me
Post by: Wizered67 on March 13, 2011, 12:56:02 am
Instead of using the Game over command in eventing, use a script event that is what ForeverZero said.
Title: Re: Respon kills me
Post by: tech williams on March 13, 2011, 01:03:26 am
I have it set up so that I go to game over after death. I don't have anything evented except for the variables. How do I change it?
Title: Re: Respon kills me
Post by: ForeverZer0 on March 13, 2011, 01:26:08 am
How were you calling the scene to test it?
Were you using an event, or did you keep having your party killed off?
Title: Re: Respon kills me
Post by: tech williams on March 13, 2011, 01:31:21 am
I had them killed off. I tryed figuring it out and changed the game over flag to $scene = Scene_Gameover.new and it worked, but then none of my events worked so thats out the window
Title: Re: Respon kills me
Post by: brewmeister on March 14, 2011, 09:45:27 am
In Command_Respawn, somewhere before $scene = Scene_Map.new, insert

$game_temp.gameover = false
Title: Re: Respon kills me
Post by: tech williams on March 21, 2011, 08:09:39 am
I tried this, but now Im having a problem with the transfer player command. It wont let the game load any other maps. Man, I thought this would be a simple code  :^_^':

EDIT: One thing I just realized. When the game gets the game over command does it tell the game your out of a battle? Like, if I add a command that ends a battle in scene_gameover would that work, because I notice that healing and text work just like they would in a battle, but transfer and other commands that arn't battle friendly wont.

EDIT 2:Nevermind
Title: Re: Respon kills me
Post by: brewmeister on March 21, 2011, 11:53:39 am
Yep, also add...

    $game_temp.in_battle = false

8)
Title: Re: Respon kills me
Post by: tech williams on March 21, 2011, 01:30:46 pm
Yes. I love you now. I was trying to give it an abort battle command, I forgot about this one. Now I can post my first script. Now to work  on making it less laggy, or maybe its just my game. Anyway, thanks alot.