can someone help me with this, cant figure how to end the quest,
its sky's quest script
#===========================================================================
#
# 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 => [Category Name, false],
# 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 => [quest_name, status, Category,
# quest_information
# task 1
# task 2
# task 3
# (task etc.) <=== this just means you can make as many
# tasks as you want
# last task],
#
# 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 => [category,(false) leave all false]
0 => ["All", false], #do not edit this line
1 => ["Search/Talk", false],
2 => ["Battle", false],
3 => ["Item", false],
}
Quests = {
# quest_id => [quest_name, status, Category
# Quest_Information
# Tasks
# (end of tasks)],
0 => ["Talk to Mr.Fred", false,"Search/Talk",
"Go to Mr.Freds House",
"Talk to Mr.Fred"],
1 => ["Valia Forest", false,"Search/Talk",
"Go To Valia Forest,South East Of The World Map",
"Go to Valia Forest"],
2 => ["Find potion", false,"Item",
"Ylva wants me to look at those 3 boxes and find a potion.",
"Find a potion in one of the 3 boxes",
"Return to Ylva and get next mission"],
3 => ["Elmer", false, "Search/Talk",
"Ylva told me to find Elmer I guess he is gonna be teaching me more.",
"Find and talk to Elmer"],
4 => ["Eww Slimes", false, "Battle",
"Well I don't know what this proves but Elmer asked me to defeat a few monsters and retrieve his magic water.",
"Fight and defeat a slime.",
"Fight the Demon Lord.",
"Obtain the Spirit Water.",
"Return to Elmer"],
5 => ["Alden", false, "Search/Talk",
"Alden",
"Go talk to Alden"],
}
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["All"].push(i)
Quests_Categories[Quests[i][2]].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[i][0])
end
for i in 0...@item_max
draw_item(i)
end
end
def create_contents
self.contents.dispose
self.contents = Bitmap.new(width - 32, [height - 32, row_max * 18].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[index])
self.contents.draw_special_case(rect.x,rect.y,rect.width,rect.height,@commands[index])
else
self.contents.draw_special_case(rect.x + 10,rect.y,(rect.width - 10),rect.height,@commands[index])
end
if @cat.include?(@commands[index])
if Sky::Quest_Info::Categories[@cat.index(@commands[index])][1]
self.contents.draw_text(rect,"-",2)
else
self.contents.draw_text(rect,"+",2)
end
else
@str = @commands[index].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[@event_id]
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[i] = 0
@max_steps[i] = Sky::Quest_Info::Quests[i].size - 4
if @max_steps[i] <= 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[i][0])
@des.push(Sky::Quest_Info::Quests[i][3])
@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[quest_id]
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[quest_id].to_f / @max_steps[quest_id].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[quest_id] == @max_steps[quest_id]
return "Complete"
elsif @step[quest_id] > @max_steps[quest_id]
raise Exception.new("Quest Progress Error")
elsif @step[quest_id] < 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[i][1]
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[quest_id][1]
Sky::Quest_Info::Quests[quest_id][1] = true
if set_info == 2
@event_id = ($game_map.interpreter.get_event_id).id
@employer[quest_id] = $game_map.events[@event_id].event.name
@var = load_data("Data/MapInfos.rvdata")
@map_name[quest_id] = @var[$game_map.map_id].name
elsif set_info == 1
@event_id = ($game_map.interpreter.get_event_id)
@employer[quest_id] = $game_map.events[@event_id].event.name
elsif set_info == 0
end
@step[quest_id] = 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[quest_id][1]
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[quest_id][1] = false
@step[quest_id] = 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[i][1]
@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[quest_id]
end
def next_task(quest_id)
@step[quest_id] += 1 unless @step[quest_id] == @max_steps[quest_id] or @step[quest_id] < 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[quest_id] = 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[quest_id] = task_num - 1 unless @step[quest_id] < 0 or @step[quest_id] == @max_stemps[quest_id]
end
#===========================================================================
#
# fail(quest_id)
# --------------
# quest_id : the quest number
#
# - fails the quest
#
#===========================================================================
def fail(quest_id)
@step[quest_id] = -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[quest_id] + 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[i][0])
@all_commands.push(Sky::Quest_Info::Categories[i][0])
@held = i
if Sky::Quest_Info::Categories[i][1]
for i in 0...Sky::Quest_Info::Quests_Categories["#{Sky::Quest_Info::Categories[@held][0]}"].size
if Sky::Quest_Info::Quests[Sky::Quest_Info::Quests_Categories["#{Sky::Quest_Info::Categories[@held][0]}"][i]][1]
if @try.index == 0
@all_commands.push(" #{Sky::Quest_Info::Quests[Sky::Quest_Info::Quests_Categories["#{Sky::Quest_Info::Categories[@held][0]}"][i]][0]}")
elsif @try.index == 1
@str = Sky::Quest_Info::Quests[Sky::Quest_Info::Quests_Categories["#{Sky::Quest_Info::Categories[@held][0]}"][i]][0]
@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[@held][0]}"][i]][0]}")
end
elsif @try.index == 2
@str = Sky::Quest_Info::Quests[Sky::Quest_Info::Quests_Categories["#{Sky::Quest_Info::Categories[@held][0]}"][i]][0]
@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[@held][0]}"][i]][0]}")
end
elsif @try.index == 3
@str = Sky::Quest_Info::Quests[Sky::Quest_Info::Quests_Categories["#{Sky::Quest_Info::Categories[@held][0]}"][i]][0]
@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[@held][0]}"][i]][0]}")
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[@quest_command.index].lstrip
@quest_no = $quest.name.index(@str)
@y = @quest_info.contents.wrap_text_height(270,18,$quest.des[@quest_no]) + 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[@quest_no][i + 4]}") + 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, [@quest_info.height - 32, @y + 18].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_command.index]
@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[@str].size
if Sky::Quest_Info::Quests[Sky::Quest_Info::Quests_Categories[@str][i]][1]
if @quest_amount < @max_amount and $quest.quest_progress(Sky::Quest_Info::Quests_Categories[@str][i]) == "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[@str][i])}%)#{$quest.name[Sky::Quest_Info::Quests_Categories[@str][i]]}")
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[@quest_command.index].lstrip
@quest_no = $quest.name.index(@str)
@quest_info.contents.draw_wrap_text(0,0,270,18,$quest.des[@quest_no])
@y = @quest_info.contents.wrap_text_height(270,18,$quest.des[@quest_no])
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[@quest_no][i + 3]) + 18
end
@quest_info.contents.draw_wrap_text(0,(@y + 18) + @other_y,270,18,"#{i + 1}. #{Sky::Quest_Info::Quests[@quest_no][i + 4]}") 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[@quest_no])
@employer.contents.draw_special_case(0,0,168,18,$quest.employer[@quest_no])
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_command.index]
@quest_name.contents.draw_text(0,0,172,24,"Category: " + @str,1)
else
@str = @quest_command.commands[@quest_command.index].lstrip
@reference_width = @quest_name.contents.text_size(@str).width
@quest_name.contents.dispose
@quest_name.contents = Bitmap.new([@quest_name.width - 32, @reference_width + 5].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[@quest_command.index]
@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::B) and (not Input.press?(Input::A))
if @quest_command.active
for i in 0...Sky::Quest_Info::Categories.size
Sky::Quest_Info::Categories[i][1] = 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[@quest_command.index])
Sky::Quest_Info::Categories[@commands.index(@quest_command.commands[@quest_command.index])][1] = true
end
get_commands
@hold = @quest_command.commands[@quest_command.index]
@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[@quest_command.index])
Sky::Quest_Info::Categories[@commands.index(@quest_command.commands[@quest_command.index])][1] = false
@hold = @quest_command.commands[@quest_command.index]
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[@quest_command.index])
if Sky::Quest_Info::Categories[@commands.index(@quest_command.commands[@quest_command.index])][1]
Sky::Quest_Info::Categories[@commands.index(@quest_command.commands[@quest_command.index])][1] = false
else
Sky::Quest_Info::Categories[@commands.index(@quest_command.commands[@quest_command.index])][1] = true
end
@hold = @quest_command.commands[@quest_command.index]
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[@quest_command.index]
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[@quest_command.index]) # 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[@quest_command.index])
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