Kain Nobel
Member
I suppose, since I might be asking more questions in the development of this script, I'm going to reserve this thread incase I have further questions.
Once again, I have figured out my own problem... here was my solution, it was simple.
My origional method was...
I simply changed it by doing this, and all 20+ commands displayed!
The Origional Issue
I just barely started this script the other day, and haven't really had time to finish it. When I went to work, it showed all 20+ Mission Categories, but now it only shows 9... anybody know where I went wrong in my last update? Everything looks like it was defined correctly, but its got me stumped.
To test this script, do the standard "install above main" and call it with "$scene = Scene_Mission.new"
While we're on the subject of showing hash data, how would I get the missions show depending on which category is highlighted? I wanted to categorize the mission data like so...
...Something like that anyways. What would be the best way to organize missions depending on category, and get it to show in the right window depending on this data? I've got it organized as an array within a hash... Category ID, Mission ID, Mission Title
Once again, I have figured out my own problem... here was my solution, it was simple.
My origional method was...
Code:
#-----------------------------------------------------------------------------
# * Draw_Item
#-----------------------------------------------------------------------------
def draw_item(index)
# Mission name is determined by data array index
mission = @data[index]
unless mission == nil
# Draw stuff
end
end
I simply changed it by doing this, and all 20+ commands displayed!
Code:
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
The Origional Issue
I just barely started this script the other day, and haven't really had time to finish it. When I went to work, it showed all 20+ Mission Categories, but now it only shows 9... anybody know where I went wrong in my last update? Everything looks like it was defined correctly, but its got me stumped.
To test this script, do the standard "install above main" and call it with "$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 ] *~"
CMS_ShowMap = true
CMS_Opacity = 160
CMS_Index_Mission = 0
#-------------------------------------------------------------------------------
# ** 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"
}
#-------------------------------------------------------------------------------
# ** Mission Selectables
#-------------------------------------------------------------------------------
Mission_Selectables = {
# Category 1
1 => [1, 1, "Spelunking in the Tunnels of Midgar"],
2 => [1, 2, "Pick up the Colonel's Dry Cleaning"],
# Category 2
1 => [2, 1, "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 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 :objectives
#-----------------------------------------------------------------------------
# * Initialize Method
#-----------------------------------------------------------------------------
def initialize
@current_mission = nil
@categories = []
@missions = []
@brefing = []
@objectives = []
@rewards = []
end
#-----------------------------------------------------------------------------
# * Define Categories
#-----------------------------------------------------------------------------
def categories
return Mission_Categories
end
#-----------------------------------------------------------------------------
# * Define Missions
#-----------------------------------------------------------------------------
def missions
return Mission_Selectables
end
#-----------------------------------------------------------------------------
# * Define Description
#-----------------------------------------------------------------------------
def breifing
return Mission_Breifing
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, fail = false)
@current_mission.push(category, mission, fail)
end
#-----------------------------------------------------------------------------
# * Fail Mission
#-----------------------------------------------------------------------------
def mission_failed(category = 1, mission = 1)
# Simply reuses Complete Mission and sets fail to true
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
#===============================================================================
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)
@missions = 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
# 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, @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]
unless mission[index] == 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
################################################################################
#===============================================================================
# ** 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)
@missions = Game_Mission.new
@item_max = Mission_Selectables.size + 1
@commands = []
refresh
self.opacity = CMS_Opacity
self.visible = true
self.active = true
self.index = -1
end
#-----------------------------------------------------------------------------
# * Define Category
#-----------------------------------------------------------------------------
def mission
return @data[self.index]
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
# If Category ID is more than 1
if @missions.missions[i] != nil and
@missions.missions[0] == @category
# Push category into data array
@data.push(@missions.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
################################################################################
#===============================================================================
# ** 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
@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
# Dispose of Map Background
@spriteset.dispose if CMS_ShowMap
end
#-----------------------------------------------------------------------------
# * Update Method
#-----------------------------------------------------------------------------
def update
#@window_header.update
@window_category.update
@window_mission.update
if @window_category.active == true
update_category
return
end
if @window_mission.active = true
update_mission
return
end
end
#-----------------------------------------------------------------------------
# * Update Main Mission Window
#-----------------------------------------------------------------------------
def update_category
# Update based on index
# 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
@window_mission.update_list(@window_category.index)
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
While we're on the subject of showing hash data, how would I get the missions show depending on which category is highlighted? I wanted to categorize the mission data like so...
Code:
#-------------------------------------------------------------------------------
# ** Mission Selectables
#-------------------------------------------------------------------------------
Mission_Selectables = {
# Category 1, Missions 1..2
1 => [1, 1, "Spelunking in the Tunnels of Midgar"],
2 => [1, 2, "Pick up the Colonel's Dry Cleaning"],
# Category 2, Missions 1..1
1 => [2, 1, "Test Tube Terror"]
# Etc, etc, etc...
}
...Something like that anyways. What would be the best way to organize missions depending on category, and get it to show in the right window depending on this data? I've got it organized as an array within a hash... Category ID, Mission ID, Mission Title