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.

[RESOLVED!] "RGSS player has stopped working" error with new Menu Scene

SOLUTION: Amnesia kicks in sometimes, but it was something simple... since I call "@spriteset = Spriteset_Map.new", I had to add a dispose method at the end of Graphics.transition loop do stuff.

Code:
@spriteset.dispose if CMS_ShowMap == true

Where it says @window_mission.dispose, etc in "Scene_Mission"

I keep encountering an error with one of my scenes... actually I've encountered this error in the past too, with other menu components, but always mysteriously seem to resolve them, so I never knew what caused them in the first place, but I'm having another one that I can't seem to resolve, so I figured now would be the best time to ask about it.

First off, I've been working on a new "Missions and Quests" script, which I know is the cause of the error, because the rest of my menu works fine, I've entered and exited every scene and thats the only scene that has the error.

When I enter the "Scene_Mission", all the selections work fine, but when I exit the Mission scene, back to the menu, then re-enter the Mission scene, that is when the error occurs. Here is a copy of the script in progress, incase anybody needs it. Just call it with $scene = Scene_Mission.new

Code:
CMS_Index_Mission = 0  #<--Exits to this selection in Scene_Menu
################################################################################
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
# ~**                 Mission Setup Constants - BEGIN                      **~ #
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
################################################################################
#-------------------------------------------------------------------------------
# ** Main Mission Categories
#-------------------------------------------------------------------------------
Mission_Categories = {
  1   => "Shinra Electric Power Company",
  2   => "Monster Research Project",
  3   => "Genesis Forces",
  4   => "To End the War With Wutai",
  5   => "Hojo's Laboratory",
  6   => "Seeking Precious Items",
  7   => "Seeking Priceless Items",
  8   => "Zack, The Materia Hunter",
  9   => "The Great Cavern of Wonders",
  10  => "Mysteries of the World"
}
#-------------------------------------------------------------------------------
# ** Mission Selectables    
#-------------------------------------------------------------------------------
Mission_Selectables = {
  # Category 1
  1   => [1, "Spelunking in the Tunnels of Midgar"],
  2   => [1, "Pick up the Colonel's Dry Cleaning"],
  # Category 2
  1   => [2, "Test Tube Terror"]
  # Etc, etc, etc...
}
#-------------------------------------------------------------------------------
# ** Mission Briefing
#-------------------------------------------------------------------------------
Mission_Breifing = {
  # Category 1, Mission 1
  1   => [1, 1, "This is the first mission for Shinra Electric Power Company,"],
  2   => [1, 1, "please use caution entering the premisis, for not only do"],
  3   => [1, 1, "creepoids dwell down here, but also families of live mines"],
  4   => [1, 1, "are present in the tunnel grounds."],
  # Category 1, Mission 2
  1   => [1, 2, "Ah, you've made it to your second mission, now you must pick"],
  2   => [1, 2, "up the colonels laundry from the dry cleaners! Please use"],
  3   => [1, 2, "caution because his clothes are hot off the press! We"],
  4   => [1, 2, "wouldn't want you to burn yourself again, now would we?"],
  # Category 2, Mission 1
  1   => [2, 1, "You've made it to the Monster Research project, please"],
  2   => [2, 1, "use caution when entering the test tube, or you might"],
  3   => [2, 1, "wind up becoming a test tube baby!"]
  # Etc, etc, etc...
}
#-------------------------------------------------------------------------------
# ** Mission Objectives
#-------------------------------------------------------------------------------
Mission_Objectives = {
  # Category 1, Mission 1
  1   => [1, 1, "Obtain 3 orbs of power"],
  2   => [1, 1, "Talk to crackhead in tunnels"],
  3   => [1, 1, "Obtain 3 orbs of speed"],
  4   => [1, 1, "Get back to HQ imediately!"],
  # Category 1, Mission 2
  1   => [1, 2, "Take the train to Sector 6"],
  2   => [1, 2, "Go through the park, to Wall Market"],
  3   => [1, 2, "Enter the Hot Press!"]
}
#===============================================================================
################################################################################
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
# ~**                   Mission Setup Constants - END                      **~ #
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
################################################################################
#===============================================================================
# ** Game_Mission
#-------------------------------------------------------------------------------
#   This class performs generic commands used for the Mission system.
#===============================================================================
class Game_Mission
  # [Attributes]----------------------------------------------------------------
  attr_accessor   :categories
  attr_accessor   :missions
  attr_accessor   :objectives
  #-----------------------------------------------------------------------------
  # * Initialize Method
  #-----------------------------------------------------------------------------
  def initialize(c = 1, m = 1, o = 1)
    @current_mission  = nil
    @categories       = []
    @missions         = []
    @objectives       = []
  end
  #-----------------------------------------------------------------------------
  # * Define Categories
  #-----------------------------------------------------------------------------
  def categories
    return Mission_Categories
  end
  #-----------------------------------------------------------------------------
  # * Define Missions
  #-----------------------------------------------------------------------------
  def missions
    return Mission_Selectables
  end
  #-----------------------------------------------------------------------------
  # * Define Objectives
  #-----------------------------------------------------------------------------
  def objectives
    return Mission_Objectives
  end
  #-----------------------------------------------------------------------------
  # * Add Category
  #-----------------------------------------------------------------------------
  def category_add(n, boolean = true)
    unless n == nil
      @categories.push(n, boolean)
    end
  end
  #-----------------------------------------------------------------------------
  # * Delete Category
  #-----------------------------------------------------------------------------
  def category_delete(n)
    unless n == nil
      @categories.delete(n)
    end
  end
  #-----------------------------------------------------------------------------
  # * Lock Category
  #-----------------------------------------------------------------------------
  def category_lock(n)
    unless n == nil
      # Simply reuses category_add and sets boolean to false
      category_add(n, false)
    end
  end
  #-----------------------------------------------------------------------------
  # * Start Mission
  #-----------------------------------------------------------------------------
  def start_mission(category = 1, mission = 1)
    @current_mission.push(category, mission)
  end
  #-----------------------------------------------------------------------------
  # * Complete Mission
  #-----------------------------------------------------------------------------
  def complete_mission(category = 1, mission = 1, fail = false)
    @current_mission.push(category, mission, fail)
  end
  #-----------------------------------------------------------------------------
  # * Fail Mission
  #-----------------------------------------------------------------------------
  def mission_failed(category = 1, mission = 1)
    complete_mission(category, mission, true)
  end
  #-----------------------------------------------------------------------------
  # * Objective Complete
  #-----------------------------------------------------------------------------
  def complete_objective(mission = 1, category = 1, objective = 1)
    # Complete Objective
  end
  #-----------------------------------------------------------------------------
  # * Fail Objective
  #-----------------------------------------------------------------------------
  def fail_objective(mission = 1, category = 1, objective = 1)
    # Fail Objective
  end
end
################################################################################
#===============================================================================
# ** Window_MissionHeader
#-------------------------------------------------------------------------------
#                 "~** [ M I S S I O N    S E L E C T ] **~"
#===============================================================================
class Window_MissionHeader < Window_Base
  #-----------------------------------------------------------------------------
  # * Initialize Method
  #-----------------------------------------------------------------------------
  def initialize
    super(0, 0, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.visible = true
    self.opacity = CMS_Opacity
    refresh
  end
  #-----------------------------------------------------------------------------
  # * Refresh Method
  #-----------------------------------------------------------------------------
  def refresh
    self.contents.clear
    #self.contents.font.bold = true
    @header = "~* [ M I S S I O N   M A N A G E R   V  2 . 0 ] *~"
    self.contents.draw_text(-16, -10, 640, 48, @header, 1)
  end
end
################################################################################
#===============================================================================
# ** Window_MissionCategory
#-------------------------------------------------------------------------------
#   This is the list of main mission categories, which will take you to the list
# of sub missions that fall into the respective category.
#===============================================================================
class Window_MissionCategory < Window_Selectable
  #-----------------------------------------------------------------------------
  # * Initialize Method
  #-----------------------------------------------------------------------------
  def initialize(mission)
    super(0, 64, 192, 416)
    self.contents = Bitmap.new(width - 32, height - 32)
    @missions = Game_Mission.new
    @item_max = Mission_Categories.size
    @commands = []
    $game_mission = Game_Mission.new(mission)
    refresh
    self.opacity = CMS_Opacity
    self.visible = true
    self.active = true
    self.index = 0
  end
  #-----------------------------------------------------------------------------
  #  * Define Category
  #-----------------------------------------------------------------------------
  def category
    return @data[self.index]
  end
  #-----------------------------------------------------------------------------
  #  * Refresh
  #-----------------------------------------------------------------------------
  def refresh
    # If contents doesn't equal nil
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    # Create Data array
    @data = []
    # For information within the Mission Categories
    for i in 0...Mission_Categories.size
      # If Category ID is more than 1
      if @missions.categories[i] != nil
        # Push category into data array
        @data.push(@missions.categories[i])
      end
    end
    # Item max is reset to size of data array
    @item_max = @data.size
    # If Item Max is more than 0
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      # For information in Item Max
      for i in 0...@item_max
        # Draw Mission Category
        draw_item(i)
      end
    end
  end
  #-----------------------------------------------------------------------------
  #  * Draw_Item
  #-----------------------------------------------------------------------------
  def draw_item(index)
    # Mission name is determined by data array index
    mission = @data[index]
    # Set Y coordinate of Mission Category command
    y = index * 32
    # Create new Rect
    rect = Rect.new(0, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.font.color = normal_color
    self.contents.draw_text(0, y, 228, 32, mission)
  end
end
################################################################################
#===============================================================================
# ** Window_MissionSelect
#-------------------------------------------------------------------------------
#   This is the list of main mission categories, which will take you to the list
# of sub missions that fall into the respective category.
#===============================================================================
class Window_MissionSelect < Window_Selectable
  #-----------------------------------------------------------------------------
  # * Initialize Method
  #-----------------------------------------------------------------------------
  def initialize(mission_list)
    super(192, 64, 448, 416)
    self.contents = Bitmap.new(width - 32, height - 32)
    @missions = mission_list != nil ? mission_list : []
    refresh
    self.opacity = CMS_Opacity
    self.visible = true
    self.active = false
    self.index = 0
  end
  #-----------------------------------------------------------------------------
  # * Update
  #-----------------------------------------------------------------------------
  def refresh
    self.contents.clear
  end
end
################################################################################
#===============================================================================
# ** Scene_Mission
#-------------------------------------------------------------------------------
#   This plays out the mission select scene, and allows you to pick which
# mission you need to complete.
#===============================================================================
class Scene_Mission
  #-----------------------------------------------------------------------------
  # * Main Method
  #-----------------------------------------------------------------------------
  def main
    # View Map behind windows.
    if CMS_ShowMap == true
      @spriteset = Spriteset_Map.new
    end
    # Execute Mission Setup
    @window_header = Window_MissionHeader.new
    @window_header.visible = true
    # Create Window_Mission
    @window_category = Window_MissionCategory.new(0)
    @window_category.visible = true
    # Create Window_MissionList
    @window_mission = Window_MissionSelect.new(0)
    @window_mission.visible = true
    # Create Window_MissionStatus
    # Execute transition
    Graphics.transition
    # 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 Windows
    @window_header.dispose
    @window_category.dispose
    @window_mission.dispose
  end
  #-----------------------------------------------------------------------------
  # * Update Method
  #-----------------------------------------------------------------------------
  def update
    @window_header.update
    @window_category.update
    @window_mission.update
    if @window_category.active == true
      update_main
      return
    end
    if @window_mission.active = true
      update_mission
      return
    end
  end
  #-----------------------------------------------------------------------------
  # * Update Main Mission Window
  #-----------------------------------------------------------------------------
  def update_main
    # If B Button Pressed
    if Input.trigger?(Input::B)
      # Play Cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Go back to Menu
      $scene = Scene_Menu.new(CMS_Index_Mission)
    end
    # If C Button Pressed
    if Input.trigger?(Input::C)
      # Play Decision SE
      $game_system.se_play($data_system.decision_se)
      # Switch to Mission Selection
      @window_category.active = false
      @window_mission.active = true
      @window_mission.index = 0
    end
  end
  #-----------------------------------------------------------------------------
  # * Update Sub Mission Window
  #-----------------------------------------------------------------------------
  def update_mission
    # If B Button Pressed
    if Input.trigger?(Input::B)
      # Play Cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Update Windows
      @window_category.active = true
      @window_mission.active = false
      @window_mission.index = -1
    end
    # If C Button Pressed
    if Input.trigger?(Input::C)
      # Play Decision SE
      $game_system.se_play($data_system.decision_se)
      # Switch to Category Selection
      @window_category.active = false
      @window_mission.active = false
    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