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.

[Anther Resolved!]-Window Scene still not updating correctly

This is the part of the scene that is having me nearly rip my hair out, because I have no idea why its not doing what its supposed to...

Even though I set this window to active true, and the other to active false, it doesn't seem to stick! Also, the Mission Window remains active with the Confirm Window... its really started to get me ticked...

Code:
  #-----------------------------------------------------------------------------
  # * Update Category Window
  #-----------------------------------------------------------------------------
  def update_category
    # 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)
      # Update Windows
      @category.active, @mission.active, @confirm.active = false, true, false
    end
  end
  #-----------------------------------------------------------------------------
  # * Update 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
      @category.active, @mission.active, @confirm.active = true, false, false
    end
    # If C Button Pressed
    if Input.trigger?(Input::C)
      # Play Decision SE
      $game_system.se_play($data_system.decision_se)
      # Update Windows
      @briefing.visible, @confirm.visible = true, true
      @category.active, @mission.active, @confirm.active = false, false, true
    end
  end
  #-----------------------------------------------------------------------------
  # * Update Mission Confirm Window
  #-----------------------------------------------------------------------------
  def update_confirm
    @mission.active = false
    # If B Button Pressed
    if Input.trigger?(Input::B)
      # Play Cancel Se
      $game_system.se_play($data_system.cancel_se)
      # Update Windows
      @briefing.visible, @confirm.visible = false, false
      @category.active, @mission.active, @confirm.active = false, true, false
    end
    # If C Button Pressed
    if Input.trigger?(Input::C)
      # Play Decision SE
      $game_system.se_play($data_system.decision_se)
      # Update Windows
    end
  end

Here's the full script, again just test it by calling $scene = Scene_Mission.new.

Code:
#===============================================================================
# ~** Mission Manager V 0.1 **~
#-------------------------------------------------------------------------------
# Written by  : Kain Nobel
# Version     : 0.1
# Last Update : 06/14/2008
# Created     : 06/11/2008
################################################################################
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
# ~**                 Mission Setup Constants - BEGIN                      **~ #
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
################################################################################
Mission_Title     = "~* [ M I S S I O N   M A N A G E R   V  0 . 1 ] *~"
Mission_FontName  = "Georgia"
Mission_FontSize  = 22
Mission_Italics   = false
CMS_Index_Mission = 0
CMS_Opacity       = 255
#-------------------------------------------------------------------------------
# ** Main Mission Categories
#-------------------------------------------------------------------------------
Mission_Categories = {
  1   => "Mission I",
  2   => "Mission II",
  3   => "Mission III",
  4   => "Mission IV",
  5   => "Mission V",
  6   => "Mission VI",
  7   => "Mission VII",
  8   => "Mission VIII",
  9   => "Mission IX",
  10  => "Mission X",
  11  => "Mission XI",
  12  => "Mission XII",
  13  => "Mission XIII",
  14  => "Mission XIV",
  15  => "Mission XV",
  16  => "Mission XVI",
  17  => "Mission XVII",
  18  => "Mission XVIII",
  19  => "Mission XIX",
  20  => "Mission XX",
  21  => "Mission XXI",
  22  => "Mission XXII",
  23  => "Mission XXIII",
  24  => "Mission XXIV",
  25  => "Mission XXV",
  26  => "Mission XXVI",
  27  => "Mission XXVII",
  28  => "Mission XXVIII",
  29  => "Mission XXIX",
  30  => "Mission XXX",
  31  => "Mission XXXI",
  32  => "Mission XXXII",
  33  => "Mission XXXIII",
  34  => "Mission XXXIV",
  35  => "Mission XXXV",
  36  => "Mission XXXVI",
  37  => "Mission XXXVII",
  38  => "Mission XXXVIII",
  39  => "Mission XXXIX",
  40  => "Mission XXXX"
}
#-------------------------------------------------------------------------------
# ** Mission Selectables    
#-------------------------------------------------------------------------------
Mission_Selectables = {
  # Category 1, Missions 1...5
  1   => "Spelunking in the Tunnels of Midgar",
  2   => "Pick up the Colonel's Dry Cleaning",
  3   => "Secret Meeting in the Alley",
  4   => "Pardon Me, but do you have any Grey Pupon?",
  5   => "The Rise of a New Breed of Chaos!"
  # Etc, etc, etc...
}
#-------------------------------------------------------------------------------
# ** Mission Briefing
#-------------------------------------------------------------------------------
Mission_Briefing = {
  1   => "        When venturing into the tunnels of Midgar, please use",
  2   => "EXTREME caution when approaching the designated drop point,",
  3   => "for there are many traps and mine fields along the way.",
  4   => "        We wouldn't want to lose another agent due to neglect",
  5   => "of your own well being, now would we? Please, come back to us",
  6   => "alive, the casualties in Midgar have been too many lately.",
  7   => "        Also, if you happen to run into a chap named Reno,",
  8   => "please give him my reguards, for I will be leaving the company",
  9   => "shortly... I've worked a long time, I'm ready for my",
  10  => "long awaited retirement.....",
  11  => "",
  12  => "Sincerely,",
  13  => "~Rude"
  # 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 Rewards
#-------------------------------------------------------------------------------
Mission_Rewards = {
  1   => "Reward I",
  2   => "Reward II",
  3   => "Reward III",
  4   => "Reward IV"
}
#===============================================================================
################################################################################
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
# ~**                   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   :briefing
  attr_accessor   :objectives
  attr_accessor   :rewards
  #-----------------------------------------------------------------------------
  # * Initialize Method
  #-----------------------------------------------------------------------------
  def initialize#(c = 1, m = 1, o = 1)
    @current_mission  = nil
    @categories       = []
    @missions         = []
    @briefing         = []
    @objectives       = []
    @rewards          = []
  end
  #-----------------------------------------------------------------------------
  # * Define Categories
  #-----------------------------------------------------------------------------
  def categories
    return Mission_Categories
  end
  #-----------------------------------------------------------------------------
  # * Define Missions
  #-----------------------------------------------------------------------------
  def missions
    return Mission_Selectables
  end
  #-----------------------------------------------------------------------------
  # * Define Description
  #-----------------------------------------------------------------------------
  def briefing
    return Mission_Briefing
  end
  #-----------------------------------------------------------------------------
  # * Define Objectives
  #-----------------------------------------------------------------------------
  def objectives
    return Mission_Objectives
  end
  #-----------------------------------------------------------------------------
  # * Define Rewards
  #-----------------------------------------------------------------------------
  def rewards
    return Mission_Rewards
  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
  #-----------------------------------------------------------------------------
  # * Add Mission
  #-----------------------------------------------------------------------------
  def mission_add(n, boolean = true)
    unless n == nil
      @missions.push(n, boolean)
    end
  end
  #-----------------------------------------------------------------------------
  # * Delete Mission
  #-----------------------------------------------------------------------------
  def mission_delete(n)
    unless n == nil
      @missions.delete(n)
    end
  end
  #-----------------------------------------------------------------------------
  # * Lock Mission
  #-----------------------------------------------------------------------------
  def mission_lock(n)
    unless n == nil
      # Simply reuses mission_add and sets boolean to false
      mission_add(n, false)
    end
  end
  #-----------------------------------------------------------------------------
  # * Add Objective
  #-----------------------------------------------------------------------------
  def objective_add(n, boolean = true)
    unless n == nil
      @objectives.push(n, boolean)
    end
  end
  #-----------------------------------------------------------------------------
  # * Delete Objective
  #-----------------------------------------------------------------------------
  def objective_delete(n)
    unless n == nil
      @objectives.delete(n)
    end
  end
  #-----------------------------------------------------------------------------
  # * Lock Objective
  #-----------------------------------------------------------------------------
  def objective_lock(n)
    unless n == nil
      # Simply reuses objective_add and sets boolean to false
      objective_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, boolean = false)
    @current_mission.push(category, mission, boolean)
  end
  #-----------------------------------------------------------------------------
  # * Fail Mission
  #-----------------------------------------------------------------------------
  def mission_failed(category = 1, mission = 1)
    # Simply reuses Complete Mission and sets 'fail' boolean to true
    complete_mission(category, mission, true)
  end
  #-----------------------------------------------------------------------------
  # * Objective Complete
  #-----------------------------------------------------------------------------
  def complete_objective(n = 1, boolean = false)
    @current_mission.objective(n, boolean)
  end
  #-----------------------------------------------------------------------------
  # * Fail Objective
  #-----------------------------------------------------------------------------
  def fail_objective(n = 1)
    # Simply reuses Complete Objective and sets 'fail' boolean to true
    @current_mission.objective(n, true)
  end
end
#===============================================================================
# ** Window_MissionHeader
#===============================================================================
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.draw_text(-16, -10, 640, 48, Mission_Title, 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
    super(0, 64, 192, 416)
    self.contents = Bitmap.new(width - 32, height - 32)
    @game = Game_Mission.new
    @item_max = Mission_Categories.size
    @commands = []
    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 * 2
      # If Category ID is more than 1
      if @game.categories[i] != nil
        # Push category into data array
        @data.push(@game.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, @item_max * 64)
      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]
    for i in 0...mission.size + 1
      unless i == nil
        # 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, 192, 32, mission)
      end
    end
  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 = 0)
    super(192, 64, 448, 416)
    self.contents = Bitmap.new(width - 32, height - 32)
    @game = Game_Mission.new
    @item_max = Mission_Selectables.size - 3
    @commands = []
    refresh
    self.opacity = CMS_Opacity
    self.visible = true
    self.active = false
    self.index = 0
  end
  #-----------------------------------------------------------------------------
  #  * Define Category
  #-----------------------------------------------------------------------------
  def mission(category)
    unless category == nil
      return @data[self.index][category]
    end
  end
  #-----------------------------------------------------------------------------
  # * Update Mission List
  #-----------------------------------------------------------------------------
  def update_list(category)
    @category = category
    refresh
  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_Selectables.size + 1
      # If Category ID is more than 1
      if @game.missions[i] != nil and
        @game.missions[0] == @category
        # Push category into data array
        @data.push(@game.missions[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
    selectable = @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, 448, 32, selectable.to_s)
  end
end
#===============================================================================
# ** Window_MissionBriefing
#-------------------------------------------------------------------------------
#   This window shows breifing information for Kain Nobel's Mission Manager.
#===============================================================================
class Window_MissionBriefing < Window_Base
  #-----------------------------------------------------------------------------
  # * Initialize Method
  #-----------------------------------------------------------------------------
  def initialize
    super(16, 16, 608, 448)
    self.contents = Bitmap.new(width - 32, height - 32)
    @game = Game_Mission.new
    self.visible = false
    self.z = 1000
    self.opacity = CMS_Opacity * 1.25
    refresh
  end
  #-----------------------------------------------------------------------------
  # * Refresh Method
  #-----------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...Mission_Briefing.size + 1
      y = (i * 32) - 32
      self.contents.font.name   = Mission_FontName
      self.contents.font.size   = Mission_FontSize
      self.contents.font.italic = Mission_Italics
      self.contents.draw_text(16, y, 640, 32, @game.briefing[i].to_s)
    end
  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
    # Setup easy Game_Mission variable
    @game = Game_Mission.new
    # Create Window_MissionHeader
    @header = Window_MissionHeader.new
    # Create Window_MissionCategory
    @category = Window_MissionCategory.new
    #@category.active = true
    # Create Window_MissionSelect
    @mission = Window_MissionSelect.new
    # Create Window_MissionBriefing
    @briefing = Window_MissionBriefing.new
    # Create Window_MissionConfirm
    #@confirm = Window_MissionConfirm.new
    @confirm = Window_Command.new(180, ["Accept Mission", "Forget it!"])
    @confirm.x = 448
    @confirm.y = 372
    @confirm.z = 1100
    @confirm.opacity = CMS_Opacity * 1.25
    @confirm.visible = false
    @confirm.active = false
    # 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
    @header.dispose
    @category.dispose
    @mission.dispose
    @briefing.dispose
    @confirm.dispose
    # Dispose of Map Background
    @spriteset.dispose if CMS_ShowMap
  end
  #-----------------------------------------------------------------------------
  # * Update Method
  #-----------------------------------------------------------------------------
  def update
    #@header.update
    @category.update
    @mission.update
    @briefing.update
    @confirm.update
    # Check Activity
    if Input.trigger?(Input::A)
      print("Category :", @category.active,
            "  Mission  :", @mission.active,
            "  Confirm  :", @confirm.active)
    end
    # Window Category Update
    if @category.active == true
      update_category
      return
    end
    # Window Mission Update
    if @mission.active = true
      update_mission
      return
    end
    # Window Confirm Update
    if @confirm.active = true
      update_confirm
      #return
    end
  end
  #-----------------------------------------------------------------------------
  # * Update Category Window
  #-----------------------------------------------------------------------------
  def update_category
    # 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)
      # Update Windows
      @category.active, @mission.active, @confirm.active = false, true, false
    end
  end
  #-----------------------------------------------------------------------------
  # * Update 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
      @category.active, @mission.active, @confirm.active = true, false, false
    end
    # If C Button Pressed
    if Input.trigger?(Input::C)
      # Play Decision SE
      $game_system.se_play($data_system.decision_se)
      # Update Windows
      @briefing.visible, @confirm.visible = true, true
      @category.active, @mission.active, @confirm.active = false, false, true
    end
  end
  #-----------------------------------------------------------------------------
  # * Update Mission Confirm Window
  #-----------------------------------------------------------------------------
  def update_confirm
    @mission.active = false
    # If B Button Pressed
    if Input.trigger?(Input::B)
      # Play Cancel Se
      $game_system.se_play($data_system.cancel_se)
      # Update Windows
      @briefing.visible, @confirm.visible = false, false
      @category.active, @mission.active, @confirm.active = false, true, false
    end
    # If C Button Pressed
    if Input.trigger?(Input::C)
      # Play Decision SE
      $game_system.se_play($data_system.decision_se)
      # Update Windows
    end
  end
end
 

khmp

Sponsor

In your update method you are using a single equals in a test for comparison. This equates to assignment and will always be considered true.

Code:
  #-----------------------------------------------------------------------------
  # * Update Method
  #-----------------------------------------------------------------------------
  def update
    #@header.update
    @category.update
    @mission.update
    @briefing.update
    @confirm.update
    # Check Activity
    if Input.trigger?(Input::A)
      print("Category :", @category.active,
            "  Mission  :", @mission.active,
            "  Confirm  :", @confirm.active)
    end
    # Window Category Update
    if @category.active
      update_category
      return
    end
    # Window Mission Update
    if @mission.active
      update_mission
      return
    end
    # Window Confirm Update
    if @confirm.active
      update_confirm
      #return
    end
  end

Good luck with it Kain Nobel! :thumb:

[edit]
Sorry Gando :down: I didn't see anyone in the thread when I first clicked on it.
 
The problem isn't in the update_category, update_mission or update_confirm methods. If you look at the update method of the scene, there is your problem!
If you look at this:

Code:
    # Window Category Update
    if @category.active == true
      update_category
      return
    end
    # Window Mission Update
    if @mission.active = true
      update_mission
      return
    end
    # Window Confirm Update
    if @confirm.active = true
      update_confirm
      #return
    end

Do you see something that is different between the different if statements? That's right, you forgot that extra " = " in the if @mission.active statement and in the if @confirm.active statenent. Here is how your update method should look like:

Code:
  #-----------------------------------------------------------------------------
  # * Update Method
  #-----------------------------------------------------------------------------
  def update
    #@header.update
    @category.update
    @mission.update
    @briefing.update
    @confirm.update
    # Check Activity
    if Input.trigger?(Input::A)
      print("Category :", @category.active,
            "  Mission  :", @mission.active,
            "  Confirm  :", @confirm.active)
    end
    # Window Category Update
    if @category.active == true
      update_category
      return
    end
    # Window Mission Update
    if @mission.active == true
      update_mission
      return
    end
    # Window Confirm Update
    if @confirm.active == true
      update_confirm
      #return
    end
  end

Anyways, good luck with your script Kain Nobel :thumb:

Over and out - Gando

Edit: Damn khmp, you're too fast!  :lol:
 

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