#===========================================================================
#
# Sky's Quest System Script
# Version 1.0
# April 20, 2010 Started
# May 27, 2010 Completed
#
#===========================================================================
#
# Features :
# Version 1.0 - (May 27)
# - Infinite Amount of Quests
# - 2 Category systems working Simultaneously
# 1. Sorting Quest Type
# 2. Sorting Quest Progresses
# - Can automatically get quest location names
# - Can automatically get quest NPC Name
# - Still need to be complete List
# - Gives Quest Completion
# - Skipping or even going back on a task.
# - retrying a quest
#
#===========================================================================
#
# Credit
# Sky00Valentine :creator and editor
# ShadoweD :for requesting script
# //mitchi.exe : for part of the background
#
#===========================================================================
#
# Terms of Use
# ------------
#
# Crediting Rpgmakervx.net, ShadoweD, and //mitchi.exe is
# the only thing I ask. However feel free to credit
# Sky00Valentine if you see fit.
#
#===========================================================================
#
# Future improvement
# ------------------
#
# - adding in a 100% functioning reward system(sometime soon)
# Including Items, Weapons, Armors, Skills, Class Change/Unlock, Gold,
# Character Unlock.
# (until then event this)
#
#===========================================================================
#
# Instructions & Installation
# ---------------------------
# - Place under Materials
#
# - use this script call to call the script:
# $scene = Scene_Quest.new
#
# - Set Max_Current_Quests to the number you want shown on the
# quest pages to do list.
#
# - Set Return to the Scene you want to go to when you exit
# the Quest_Scene.
#
# - Edit you primary Categories by changing the Categories Hash
# ex.
# category_id => ,
# be carefull to leave in the All Category
#
# - Next you should update the Quests_Categories Hash, by adding in
# Each of your categories
# ex.
# Category => ,
# be sure to add in all of your categories.
#
# - Lastly add in your Quests, this is the most complicated part, only
# until you understand the setup.
# ex.
#
# quest_id => ,
#
# 1. Where quest_id is the quests number,
# 2. Where quest_name is the name of the quest.
# 3. Where status is do you want to start with this quest when
# you start a new game.(true/false)
# 4. Where Category is the Category you want the quest in.
# 5. Where quest_information is basically the information
# about your quest.
# 6. Where task is each task you require before the quest is completed.
#
# ----- ------------ -------------- ---------- ------------- ------
# - Here are the quest commands you can call in game through events.
#
# 1. $quest.begin(quest_id,style = 2)
# will begin your quest
# unless you have already started it. Setting style to
# 2 will include your quest's npc beginning location and
# name. Setting style to 1 will include only the npc's
# name. Setting style to 0 will not include either.
# (if you want both included you only 'need' to use)
# $quest.begin(quest_id)
#
# 2. $quest.fail(quest_id)
# will list the quest as failed now.
#
# 3. $quest.next_task(quest_id)
# will move you onto the next task. This is used
# to progress in quests.
#
# 4. $quest.skip_to_task(quest_id, task)
# will skip to a task if the quest is in progress. Set
# task to the task you want to be skipped to.
#
# 5. $quest.name
# will return the quests name.
#
# 6. $quest.task_complete?(quest_id, task_number)
# will return true if you have completed that task and
# false if not.
# (this works well for conditional branches.)
#
# 7. $quest.quest_complete?(quest_id)
# will return true if you
# have completed the quest and false if you haven't also
# will return false if you failed the mission.
#
# 8. $quest.redo(quest_id,task = 1)
# will let you redo a quest
# or just a task. Set task to the number you want to go
# to.
# (Only works if you failed.)
# (If you want to start all over you only 'need' to have)
# $quest.redo(quest_id)
#
# 9. $quest.delete_quest(quest_id)
# will remove the quest from
# your list all together, and you have the chance to begin
# again.
#
# 10. $quest.current_step(quest_id)
# will give you number of the task you are on.
#
# 11. $quest.started?(quest_id)
# will return true if you are currently doing a quest.
# and false otherwise.
#
#===========================================================================
#
# Compatibility & Bugs
# --------------------
# - Compatibility, should work with all scripts
#
# - Bugs, I don't think so but its totatly possible
# I would actually be suprised if it had none.
#
#===========================================================================

module Sky
module Quest_Info

Max_Current_Quests = 5 #This is how many quests will be shown for each
#category's information page. The max is 8.

Return = Scene_Map.new #This is the scene you want to return to
#When you exit the Quest Scene.

Categories = {
# category_id =>
0 => , #do not edit this line
1 => ,
2 => ,
3 => ,
}



Quests = {
# quest_id => ,
0 => ,

1 => ,

2 => ,

3 => ,

4 => ,

5 => ,
}


Quests_Categories = {
#Category => ,
"All" => , #Do not edit this line
"Search/Talk" => , #add in each of your categories
"Battle" => ,
"Item" => ,
}
#===============================================================================
#
# Do not edit anything below unless you know what you are doing
# For fear of screwing up your comp or game.
#
#===============================================================================

for i in 0...Quests.size
Quests_Categories.push(i)
Quests_Categories[Quests].push(i)
end

end
end

#===============================================================================
#
# Setup for the Quest command window
#
#===============================================================================

class Window_Sky_Quests < Window_Selectable
attr_reader :commands
WLH = 18

def initialize(commands)
super(32,96,143, page_row_max*WLH+32)
@commands = commands
@item_max = commands.size
@column_max = 1
create_contents
refresh
self.index = 0
end

#===========================================================================
#
# reinitialize(commands)
# ----------------------
# commands : the list of commands that the window will show.
#
# - helps control the category heiarchy.
#
#===========================================================================

def reinitialize(commands)
@commands = commands
@item_max = commands.size
@column_max = 1
create_contents
refresh
end

def refresh
@cat =
for i in 0...Sky::Quest_Info::Categories.size
@cat.push(Sky::Quest_Info::Categories)
end
for i in 0...@item_max
draw_item(i)
end
end

def create_contents
self.contents.dispose
self.contents = Bitmap.new(width - 32, .max)
end

def page_row_max
return 11
end

def top_row
return self.oy / WLH
end

def top_row=(row)
row = 0 if row < 0
row = row_max - 1 if row > row_max - 1
self.oy = row * WLH
end

def item_rect(index)
rect = Rect.new(0, 0, 0, 0)
rect.width = (contents.width + @spacing) / @column_max - @spacing
rect.height = WLH
rect.x = index % @column_max * (rect.width + @spacing)
rect.y = index / @column_max * WLH
return rect
end

def draw_item(index)
rect = item_rect(index)
rect.x += 8
rect.width -= 8
self.contents.clear_rect(rect)
self.contents.font.size = 14
if @cat.include?(@commands)
self.contents.draw_special_case(rect.x,rect.y,rect.width,rect.height,@commands)
else
self.contents.draw_special_case(rect.x + 10,rect.y,(rect.width - 10),rect.height,@commands)
end
if @cat.include?(@commands)
if Sky::Quest_Info::Categories[@cat.index(@commands)]
self.contents.draw_text(rect,"-",2)
else
self.contents.draw_text(rect,"+",2)
end
else
@str = @commands.lstrip
@quest_no = $quest.name.index(@str)
if $quest.quest_progress(@quest_no) == "Complete"
self.contents.blt(rect.x - 4,rect.y+3,Bitmap.new("Graphics/Pictures/mini_comp"),Rect.new(0,0,13,13))
elsif $quest.quest_progress(@quest_no) == "Failed"
self.contents.blt(rect.x - 4,rect.y+3,Bitmap.new("Graphics/Pictures/mini_fail"),Rect.new(0,0,13,13))
elsif $quest.quest_progress(@quest_no) == "In Progress"
self.contents.blt(rect.x - 4,rect.y+3,Bitmap.new("Graphics/Pictures/mini_on"),Rect.new(0,0,13,13))
end
end
end
end

class Game_Event
attr_accessor :event
end

class Game_Interpreter
def get_event_id
events = $game_map.events
@x = events == nil ? nil : events
return @x
end
end

class Scene_Title # Begin Scene_Title

alias quest_object create_game_objects
def create_game_objects
quest_object
$quest = Quest.new # creates the quest object
end

end # End Scene_Title

#===========================================================================
#
# Quest
# -----
# - creates and keeps all the quest information
#
#===========================================================================

class Quest

#===========================================================================
#
# initialize
# ----------
# - begins the class code execution and creates most of the variables.
#
#===========================================================================
def initialize
@step =
@max_steps =
@employer =
@map_name =
initial_step
quest_name_des_setup
end

#===========================================================================
#
# initial_step
# ------------
# - sets up the quests tasks. How many tasks and the beginning task.
#
#===========================================================================

def initial_step
for i in 0...Sky::Quest_Info::Quests.size
@step = 0
@max_steps = Sky::Quest_Info::Quests.size - 4
if @max_steps <= 0
print i
raise Exception.new("Sky::Quest_Info::Quests Error")
end
end
end

#===========================================================================
#
# quest_name_des_setup
# --------------------
# - gets the name of the quest and the description
#
#===========================================================================

def quest_name_des_setup
@name =
@des =
for i in 0...Sky::Quest_Info::Quests.size
@name.push(Sky::Quest_Info::Quests)
@des.push(Sky::Quest_Info::Quests)
@map_name.push("")
@employer.push("")
end
end

#===========================================================================
#
# self
# ----
# quest_id : the quest number
#
# - returns the name of the quest number
#
#===========================================================================

def self(quest_id)
return @name
end

#===========================================================================
#
# des
# ---
# - returns the description array, which contains all quest descriptions
#
#===========================================================================

def des
return @des
end

#===========================================================================
#
# name
# ----
# - returns the name array, which contains all quest names.
#
#===========================================================================

def name
return @name
end

#===========================================================================
#
# map
# -----
# - returns the map_name array, which contains all quests initial map if
# they have one.
#
#===========================================================================

def map
return @map_name
end

#===========================================================================
#
# employer
# --------
# - returns the employer array, which contains all quests beginning event
# names.
#
#===========================================================================

def employer
return @employer
end

#===========================================================================
#
# percent(quest_id)
# -----------------
# :quest_id : the quest number
#
# - returns the quests percentage of completion
#
#===========================================================================

def percent(quest_id)
@max = sprintf( "%10.1f", (@step.to_f / @max_steps.to_f) * 100)
return @max
end

#===========================================================================
#
# task_complete?(quest_id,task_num)
# --------------------------------
# quest_id : the quest number
# task_num : the tasks number
#
# - returns whether or not you have completed a quests task
#
#===========================================================================

def task_complete?(quest_id,task_num)
unless quest_progress(quest_id) == "Failed"
if current_step(quest_id) <= task_num
return false
else
return true
end
else
return false
end
end

#===========================================================================
#
# quest_complete?(quest_id)
# -------------------------
# quest_id : the quest number
#
# - returns whether or not you have completed a quest.
#
#===========================================================================

def quest_complete?(quest_id)
if quest_progress(quest_id) == "Complete"
return true
else
return false
end
end

#===========================================================================
#
# quest_progress(quest_id)
# ------------------------
# quest_id : the quest number
#
# - return the quests progress
#
#===========================================================================

def quest_progress(quest_id)
if @step == @max_steps
return "Complete"
elsif @step > @max_steps
raise Exception.new("Quest Progress Error")
elsif @step < 0
return "Failed"
else
return "In Progress"
end
end

#===========================================================================
#
# total_complete
# --------------
# - returns the amount of completed quests
#
#===========================================================================

def total_complete
@total_complete = 0
for i in 0...@name.size
if quest_progress(i) == "Complete"
@total_complete += 1
end
end
return @total_complete
end

#===========================================================================
#
# all_quest_percent
# -----------------
# - returns the completed quest percentage.
#
#===========================================================================

def all_quest_percent
@all_quest = @name.size
@c = sprintf( "%10.1f", (total_complete.to_f / @all_quest.to_f) * 100)
return @c
end

#===========================================================================
#
# found_quest_percent
# -------------------
# - returns the percentage of how many quests you have found out of
# the entire game's quests.
#
#===========================================================================

def found_quest_percent
@complete = 0
for i in 0...name.size
if Sky::Quest_Info::Quests
if quest_progress(i) == "Complete"
@complete += 1
end
end
end
@qp = sprintf("%10.1f",(@complete.to_f / found.to_f) * 100)
return @qp
end

#===========================================================================
#
# begin(quest_id,set_info)
# -----------------------
# quest_id : the quest number
# set_info : the amount of information saved for the quest.
#
# - lets you begin a new quest, and depending on set_info sets the
# beginning location and NPC.
#
#===========================================================================

def begin(quest_id,set_info = 2)
if not Sky::Quest_Info::Quests
Sky::Quest_Info::Quests = true
if set_info == 2
@event_id = ($game_map.interpreter.get_event_id).id
@employer = $game_map.events.event.name
@var = load_data("Data/MapInfos.rvdata")
@map_name = @var.name
elsif set_info == 1
@event_id = ($game_map.interpreter.get_event_id)
@employer = $game_map.events.event.name
elsif set_info == 0
end
@step = 0
end
end

#===========================================================================
#
# started?(quest_id)
# ------------------
# quest_id : the quest number
#
# - returns true if the quest is active
#===========================================================================

def started?(quest_id)
return false if quest_complete?(quest_id)
return Sky::Quest_Info::Quests
end

#===========================================================================
#
# delete_quest(quest_id)
# ----------------------
# quest_id : the quest number
#
# - deletes the quest from your in game records.
#
#===========================================================================

def delete_quest(quest_id)
Sky::Quest_Info::Quests = false
@step = 0
end

#===========================================================================
#
# found
# -----
# - returns the total amount of quests you have began
#
#===========================================================================

def found
@quest_amount = 0
for i in 0...name.size
if Sky::Quest_Info::Quests
@quest_amount += 1
end
end
return @quest_amount
end

#===========================================================================
#
# task_amount(quest_id)
# ---------------------
# quest_id : the quest number
#
# - returns the amount of tasks a quest has.
#
#===========================================================================

def task_amount(quest_id)
return @max_steps
end

def next_task(quest_id)
@step += 1 unless @step == @max_steps or @step < 0
end

#===========================================================================
#
# redo(quest_id,task)
# -------------------
# quest_id : the quest number
# task : the task of the quest
#
# - will reset you quest to the given task.
#
#===========================================================================

def redo(quest_id, task = 1)
if quest_progress(quest_id) == "Failed"
@step = task - 1
end
end

#===========================================================================
#
# skip_to_task(quest_id,task_num)
# -------------------------------
# quest_id : the quest number
# task_num : the task of the quest
#
# will set your quest to the given task
#
#===========================================================================

def skip_to_task(quest_id, task_num)
@step = task_num - 1 unless @step < 0 or @step == @max_stemps
end

#===========================================================================
#
# fail(quest_id)
# --------------
# quest_id : the quest number
#
# - fails the quest
#
#===========================================================================

def fail(quest_id)
@step = -1
end

#===========================================================================
#
# current_step(quest_id)
# ----------------------
# quest_id : the quest number
#
# - returns the number of the current task you are on of a quest.
#
#===========================================================================

def current_step(quest_id)
return @step + 1
end
end

#===========================================================================
#
# Progress_Window
# ---------------
# - The Progress Category Window
#
#===========================================================================

class Progress_Window < Window_Selectable
def initialize
super(0,0,230,90)
@item_max = 4
@column_max = 4
@spacing = 9
refresh
self.index = 0
end

def refresh
for i in 0...@item_max
draw_item(i)
end
end

def item_rect(index)
rect = Rect.new(0, 0, 0, 0)
rect.width = 44
rect.height = 21
rect.x = index % @column_max * (rect.width + @spacing)
rect.y = 32
return rect
end

def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
self.contents.font.size = 11
if index == 0
bitmap = Cache.picture("blank")
text = "All"
self.contents.draw_text(rect.x,rect.y+3,rect.width,15,text,1)
elsif index == 1
bitmap = Cache.picture("ongoing")
text = "In"
self.contents.draw_text(rect.x,rect.y+1,rect.width,15,text,1)
self.contents.draw_text(rect.x,rect.y+7,rect.width,15,"Progress",1)
elsif index == 2
bitmap = Cache.picture("finished")
text = "Complete"
self.contents.draw_text(rect.x,rect.y+3,rect.width,15,text,1)
elsif index == 3
bitmap = Cache.picture("failed")
text = "Failed"
self.contents.draw_text(rect.x,rect.y+3,rect.width,15,text,1)
end
cw = bitmap.width
@ch = bitmap.height
src_rect = Rect.new(0, 0, cw, @ch)
self.contents.blt(rect.x+10,3,bitmap,src_rect,255)
end

end


#===============================================================================
#
# The actual Quest Scene
#
#===============================================================================

class Scene_Quest < Scene_Base # Begin Scene_Quest

#===========================================================================
#
# start
# -----
# - begins the Scene by creating almost everything and creating
# the initial setup.
#
#===========================================================================

def start
@status = Sprite.new
@definitions = Window_Base.new(172,133,200,150)
@definitions.z = 110
create_background
def_fill
get_commands
@quest_command = Window_Sky_Quests.new(@commands)
@quest_command.opacity = 0
@quest_name = Window_Base.new(242,24,200,56)
@quest_info = Window_Base.new(194,79,302,229)
@employer = Window_Base.new(40,340,200,56)
@location = Window_Base.new(260,340,200,56)
@employer.contents.font.size = 14
@location.contents.font.size = 14
@employer.opacity = 0
@location.opacity = 0
@quest_name.contents.font.size = 14
@quest_name.opacity = 0
@quest_info.opacity = 0
@try = Progress_Window.new
@try.opacity = 0
@try.contents_opacity = 0
@try.active = false
update_name_window(0)
update_quest_info
@counter = 0
@count = 0
@page_index = 15
@up = false
end

#===========================================================================
#
# get_commands
# ------------
# - creates the category and quest list or quest_command window
#
#===========================================================================

def get_commands
@all_commands =
@commands =
for i in 0...Sky::Quest_Info::Categories.size
@commands.push(Sky::Quest_Info::Categories)
@all_commands.push(Sky::Quest_Info::Categories)
@held = i
if Sky::Quest_Info::Categories
for i in 0...Sky::Quest_Info::Quests_Categories["#{Sky::Quest_Info::Categories}"].size
if Sky::Quest_Info::Quests[Sky::Quest_Info::Quests_Categories["#{Sky::Quest_Info::Categories}"]]
if @try.index == 0
@all_commands.push(" #{Sky::Quest_Info::Quests[Sky::Quest_Info::Quests_Categories["#{Sky::Quest_Info::Categories}"]]}")
elsif @try.index == 1
@str = Sky::Quest_Info::Quests[Sky::Quest_Info::Quests_Categories["#{Sky::Quest_Info::Categories}"]]
@quest_no = $quest.name.index(@str)
if $quest.quest_progress(@quest_no) == "In Progress"
@all_commands.push(" #{Sky::Quest_Info::Quests[Sky::Quest_Info::Quests_Categories["#{Sky::Quest_Info::Categories}"]]}")
end
elsif @try.index == 2
@str = Sky::Quest_Info::Quests[Sky::Quest_Info::Quests_Categories["#{Sky::Quest_Info::Categories}"]]
@quest_no = $quest.name.index(@str)
if $quest.quest_progress(@quest_no) == "Complete"
@all_commands.push(" #{Sky::Quest_Info::Quests[Sky::Quest_Info::Quests_Categories["#{Sky::Quest_Info::Categories}"]]}")
end
elsif @try.index == 3
@str = Sky::Quest_Info::Quests[Sky::Quest_Info::Quests_Categories["#{Sky::Quest_Info::Categories}"]]
@quest_no = $quest.name.index(@str)
if $quest.quest_progress(@quest_no) == "Failed"
@all_commands.push(" #{Sky::Quest_Info::Quests[Sky::Quest_Info::Quests_Categories["#{Sky::Quest_Info::Categories}"]]}")
end
end
end
end
end
end
end

#===========================================================================
#
# def_fill
# --------
# - fills the definitions window
#
#===========================================================================

def def_fill
@definitions.opacity = 0
@definitions.contents_opacity = 0
@definitions.contents.font.size = 16
@definitions.contents.draw_text(5,0,200,24,"In Progress")
@definitions.contents.draw_text(32,41,200,24,"Passed")
@definitions.contents.draw_text(38,82,200,24,"Failed")
@ongoing_def = Cache.picture("ongoing")
@passed_def = Cache.picture("finished")
@failed_def = Cache.picture("failed")
ch = @ongoing_def.height
cw = @ongoing_def.width
src_rect = Rect.new(0,0,cw,ch)
@definitions.contents.blt(110,0,@ongoing_def,src_rect)
@definitions.contents.blt(110,41,@passed_def,src_rect)
@definitions.contents.blt(110,82,@failed_def,src_rect)
end

#===========================================================================
#
# create_background
# -----------------
# - sets up all sprites shown
#
#===========================================================================
def create_background
default =
@sprite = Sprite.new
@sprite.bitmap = located?("Quest Background") if located?("Quest Background") != false
@sprite2 = Sprite.new
@sprite2.bitmap = located?("Quest Borders") if located?("Quest Borders") != false
@spritetext = Sprite.new
@spritetext.viewport = Viewport.new(0,0,544,416)
@spritetext.y = 416
@spritetext.bitmap = Bitmap.new(512,384)
@spritetext.bitmap.font.name = @definitions.contents.font.name
@spritetext.bitmap.font.size = 14
@spritetext.angle = 90
@spritetext.bitmap.draw_text(0,0,416,18,"A Button: Progress Chart Y Button: Categorize",1)
end

def located?(pic)
return Cache.picture(pic) rescue return false
end
#===========================================================================
#
# free_back
# ---------
# - disposes of the sprites
#
#===========================================================================

def free_back
@sprite.bitmap.dispose unless @sprite.bitmap == nil
@sprite.dispose
@sprite2.bitmap.dispose unless @sprite2.bitmap == nil
@sprite2.dispose
@spritetext.bitmap.dispose
@spritetext.dispose
end

#===========================================================================
#
# get_contents_height
# -------------------
# - gets the total height of all text shown in the quest_info screen
#
#===========================================================================
def get_contents_height
@str = @quest_command.commands.lstrip
@quest_no = $quest.name.index(@str)
@y = @quest_info.contents.wrap_text_height(270,18,$quest.des) + 18
for i in 0...$quest.current_step(@quest_no)
@y += @quest_info.contents.wrap_text_height(270,18,"#{i + 1}. #{Sky::Quest_Info::Quests}") + 18
end
return @y
end

#===========================================================================
#
# info_create_contents
# --------------------
# - sets the contents bitmap's new specifications
#
#===========================================================================

def info_create_contents
get_contents_height
@quest_info.contents.dispose
@quest_info.contents = Bitmap.new(@quest_info.width - 32, .max)
@quest_info.contents.font.size = 14
end

#===========================================================================
#
# update_quest_info(style = 0)
# ----------------------------
# style : how the quest_info window should be filled
#
# - controls the information shown for quest_info, location,
# and employer windows.
#
#===========================================================================
def update_quest_info(style = 0)
@quest_info.contents.clear
@quest_info.oy = 0
@location.contents.clear
@employer.contents.clear
if style == 0
if @try.index == 0 or @try.index == 1
@str = @quest_command.commands
@quest_amount = 0
@max_amount = Sky::Quest_Info::Max_Current_Quests
if @max_amount > 8
@max_amount = 8
end
@quest_info.contents.font.size = 24
@quest_info.contents.draw_text(0,0,270,28,"Current Quests",1)
@quest_info.contents.draw_text(0,0,270,28,"____________",1)
@quest_info.contents.font.size = 14
for i in 0...Sky::Quest_Info::Quests_Categories.size
if Sky::Quest_Info::Quests[Sky::Quest_Info::Quests_Categories]
if @quest_amount < @max_amount and $quest.quest_progress(Sky::Quest_Info::Quests_Categories) == "In Progress"
@quest_amount += 1
@quest_info.contents.draw_text(0,(@quest_amount * 16) + 30,270,18,"#{@quest_amount}. (#{$quest.percent(Sky::Quest_Info::Quests_Categories)}%)#{$quest.name[Sky::Quest_Info::Quests_Categories]}")
end
end
end
if @quest_amount == 0
@quest_info.contents.draw_text(0,@quest_info.height/2 - 40,270,18,"No Quests Available",1)
end
else
@quest_info.contents.font.size = 24
@quest_info.contents.draw_text(0,0,270,28,"Completion",1)
@quest_info.contents.draw_text(0,0,270,28,"_________",1)
@quest_info.contents.font.size = 14
@quest_info.contents.draw_text(0,34,270,28,"Total Quests : #{$quest.found}")
@quest_info.contents.draw_text(0,54,270,28,"Quests Complete : #{$quest.found_quest_percent}%")
@quest_info.contents.draw_text(0,94,270,28,"All Complete : #{$quest.all_quest_percent}%")
end
else
info_create_contents
@str = @quest_command.commands.lstrip
@quest_no = $quest.name.index(@str)
@quest_info.contents.draw_wrap_text(0,0,270,18,$quest.des)
@y = @quest_info.contents.wrap_text_height(270,18,$quest.des)
for i in 0...$quest.current_step(@quest_no)
if i == 0
@other_y = 0
else
@other_y += @quest_info.contents.wrap_text_height(270,18,Sky::Quest_Info::Quests) + 18
end
@quest_info.contents.draw_wrap_text(0,(@y + 18) + @other_y,270,18,"#{i + 1}. #{Sky::Quest_Info::Quests}") unless i == $quest.task_amount(@quest_no)
end
if $quest.quest_progress(@quest_no) == "Complete"
bitmap = Cache.picture("Quest Complete") rescue ""
ch = bitmap.height unless bitmap == ""
cw = bitmap.width unless bitmap == ""
src_rect = Rect.new(0,0,cw,ch) unless bitmap == ""
@quest_info.contents.blt(30,60,bitmap,src_rect) unless bitmap == ""
end
@location.contents.draw_special_case(0,0,168,18,$quest.map)
@employer.contents.draw_special_case(0,0,168,18,$quest.employer)
end
end

#===========================================================================
#
# update_name_window(style = 0)
# -----------------------------
# style : whether the window should show the Category or the Quest name.
#
# - controls the quest_name window
#===========================================================================

def update_name_window(style = 0)
@quest_name.contents.clear
if style == 0
@quest_name.create_contents
@quest_name.contents.font.size = 14
@str = @quest_command.commands
@quest_name.contents.draw_text(0,0,172,24,"Category: " + @str,1)
else
@str = @quest_command.commands.lstrip
@reference_width = @quest_name.contents.text_size(@str).width
@quest_name.contents.dispose
@quest_name.contents = Bitmap.new(.max, @quest_name.height - 32)
@quest_name.contents.font.size = 14
@quest_name.contents.draw_text(0,0,190,24,@str)#,1)
end
end

#===========================================================================
#
# Instructions & Installation
# ---------------------------
# - updates the entire Scene
#
#===========================================================================

def update
@quest_command.update
@try.update
if Input.press?(Input::A)
@try.contents_opacity = 0
@try.index = @category unless @category == nil
@try.active = false
@definitions.contents_opacity = 255
@quest_command.contents_opacity = 100
@quest_name.contents_opacity = 100
@quest_info.contents_opacity = 100
if @quest_command.active
@quest_command.active = false
@num = 1
end
else
@definitions.contents_opacity = 0
@quest_command.contents_opacity = 255
@quest_name.contents_opacity = 255
@quest_info.contents_opacity = 255
if @num == 1
@quest_command.active = true
@num = 0
end
if @quest_command.active
for i in 0..4
if @spritetext.opacity == 0
@up = true
elsif @spritetext.opacity == 255
@up = false
end
if @spritetext.opacity <= 255 and not @up
@spritetext.opacity -= 1
elsif @spritetext.opacity >= 0 and @up
@spritetext.opacity += 1
end
end
end
end
unless @quest_command.active or @try.active or Input.press?(Input::A)
@str = @quest_command.commands
@reference_width = @quest_name.contents.text_size(@str).width
if @quest_name.contents.width > @quest_name.width - 32
unless @quest_name.ox == @reference_width + 12
@counter += 1
@quest_name.ox += 1 if @counter >= 360
else
@quest_name.ox = 0
@counter = 0
end
end
end
if Input.trigger?(Input:: and (not Input.press?(Input::A))
if @quest_command.active
for i in 0...Sky::Quest_Info::Categories.size
Sky::Quest_Info::Categories = false
end
@quest_command.dispose
@definitions.dispose
@quest_info.dispose
@quest_name.dispose
@employer.dispose
@location.dispose
@try.dispose
free_back
$scene = Sky::Quest_Info::Return
elsif @try.active
@try.contents_opacity = 0
@try.index = @category
@try.active = false
@quest_command.active = true
@counter = 0
@quest_name.ox = 0
else
@quest_command.active = true
@counter = 0
@quest_name.ox = 0
end
elsif Input.trigger?(Input::Y) and (not Input.press?(Input::A)) and @quest_command.active
@try.contents_opacity = 255
@try.active = true
@category = @try.index
@quest_command.active = false
elsif Input.trigger?(Input::RIGHT) and (not Input.press?(Input::A)) and @quest_command.active
if @commands.include?(@quest_command.commands)
Sky::Quest_Info::Categories[@commands.index(@quest_command.commands)] = true
end
get_commands
@hold = @quest_command.commands
@quest_command.reinitialize(@all_commands)
@quest_command.index = @quest_command.commands.index(@hold)
elsif Input.trigger?(Input::LEFT) and (not Input.press?(Input::A)) and @quest_command.active
if @commands.include?(@quest_command.commands)
Sky::Quest_Info::Categories[@commands.index(@quest_command.commands)] = false
@hold = @quest_command.commands
get_commands
@quest_command.reinitialize(@all_commands)
@quest_command.index = @quest_command.commands.index(@hold)
end
elsif Input.trigger?(Input::C) and (not Input.press?(Input::A)) and @quest_command.active
if @commands.include?(@quest_command.commands)
if Sky::Quest_Info::Categories[@commands.index(@quest_command.commands)]
Sky::Quest_Info::Categories[@commands.index(@quest_command.commands)] = false
else
Sky::Quest_Info::Categories[@commands.index(@quest_command.commands)] = true
end
@hold = @quest_command.commands
get_commands
@quest_command.reinitialize(@all_commands)
@quest_command.index = @quest_command.commands.index(@hold)
else
@quest_command.active = false
end
elsif Input.trigger?(Input::C) and @try.active
@try.active = false
@hold = @quest_command.commands
get_commands
@quest_command.reinitialize(@all_commands)
@quest_command.index = 0
@quest_command.index = @quest_command.commands.index(@hold) if @quest_command.commands.index(@hold) != nil
@quest_command.active = true
@try.contents_opacity = 0
if @commands.include?(@quest_command.commands) # if on a category
update_name_window(0)
update_quest_info(0)
else # if inside a category
update_name_window(1)
update_quest_info(1)
end
elsif (Input.trigger?(Input::DOWN) or Input.press?(Input::DOWN) or Input.press?(Input::UP) or Input.trigger?(Input::UP)) and @quest_command.active
if @commands.include?(@quest_command.commands)
update_name_window(0)
update_quest_info(0)
else
update_name_window(1)
update_quest_info(1)
end
elsif not(@quest_command.active or @try.active) and (not Input.press?(Input::A)) and (Input.press?(Input::DOWN) and @count < 23)
if @count == 0
if @quest_info.oy % 18 != 0
@quest_info.oy -= 18 - (@quest_info.oy % 18)
end
@quest_info.oy += 18 unless @quest_info.oy >= get_contents_height - 198
@quest_info.oy = get_contents_height - 198 if (@quest_info.oy > get_contents_height - 198 and @quest_info.contents.height > 198)
end
@count += 1
elsif not(@quest_command.active or @try.active) and (not Input.press?(Input::A)) and (Input.press?(Input::DOWN) and @count >= 23)
@quest_info.oy += 2 unless @quest_info.oy >= get_contents_height - 198
elsif not(@quest_command.active or @try.active) and (not Input.press?(Input::A)) and (Input.press?(Input::UP) and @count < 23)
if @count == 0
if @quest_info.oy % 18 != 0
@quest_info.oy += 18 - (@quest_info.oy % 18)
end
@quest_info.oy -= 18 unless @quest_info.oy <= 0
@quest_info.oy = 0 if @quest_info.oy < 0
end
@count += 1
elsif not(@quest_command.active or @try.active) and (not Input.press?(Input::A)) and (Input.press?(Input::UP) and @count >= 23)
@quest_info.oy -= 2 unless @quest_info.oy <= 0
@quest_info.oy = 0 if @quest_info.oy < 0
end
unless Input.press?(Input::DOWN) or Input.press?(Input::UP) or (Input.press?(Input::DOWN) and Input.press?(Input::UP))
@count = 0
end
end
end # End Scene_Quest

class Scene_File # Begin Scene_File

alias quest_save write_save_data
def write_save_data(file)
quest_save(file)
Marshal.dump($quest, file)
end

alias quest_load read_save_data
def read_save_data(file)
quest_load(file)
$quest = Marshal.load(file)
end
end # End Scene_File