#----------------------------------------#
# â— Quest Manager Revision by Prexus â— #
#----------------------------------------#
# Created on Friday, June 3rd #
# Revised on Sunday, June 5th #
# www.prexus.nearfantasticaonline.com #
# All Rights Reserved #
#----------------------------------------#
# Interferance Scripts: #
# Quest Manager Revision uses these #
# default classes, so make sure no other #
# scripts interfere. If they do, update #
# them accordingly. #
# Game_Party #
# Scene_Title #
# Scene_Save #
# Scene_Load #
#----------------------------------------#
# New in Revision 1: #
# The quests look better visually, using #
# a duallist for requirements and easier #
# access to a quests status in the list. #
# Also, when a quest uses switches or #
# variables, $game_switches/variables is #
# no longer used. This is important to #
# note because now, you must use Call #
# Script to change the values. #
# Like so: #
# $quest_variables[id] (will return the value at id.)
# $quest_variables[id] += value (will add value to the current value of the var)
# $quest_variables[id] -= value (will subtract value from the current var)
# $quest_variables[id] /= value (will divide the current var with value)
# $quest_variables[id] *= value (will mulitple the current var by value)
# $quest_switches[id] (will return true or false based on the id)
# $quest_switches[id] = true (will set switch to true)
# $quest_switches[id] = false (will set switch to false)
# â— Thank you Mr. DJ for the idea =) â— #
#----------------------------------------#
# To use this script, simply paste it #
# above main. It should not interfere #
# with any other scripts unless they use #
# or change scene_load and scene_save and#
# scene_title, as they are the only #
# default scripts that are affected. #
# To add a quest to the database, in #
# Call Script, put the following: #
# â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â— #
# $quest[id] = PRX_Quest.new Change ID to whatever you want. Just never use the same twice.
# $quest[id].name = "Enter Name Here"
# $quest[id].type = 0-3 (explained below)
# $quest[id].description = "Short Explaination of Quest"
# $quest[id].requirements = [] (An array of values, Explained Below)
# $quest[id].values = [] (An array of values, explained below)
# $quest[id].switches = [] (Array of switch IDs, explained below.)
# $quest[id].variables = [] (Array of variable IDs, explained below.)
# $quest[id].completed = Set this to true/false when the quest is done
# $quest[id].disabled = If you want the quest to appear disabled, set this to true
# â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â— #
# Important Notes about Values:
# â— .name
# - A string value that appears in the list.
# â— .type
# - An integer value 0-3.
# When the value is set to 0, make sure to set .requirements to string values.
# These will appear in the quest menu and never change.
#
# If type is set to 1, make sure to set .requirements to string values and
# set .variables accordingly. Also, .values needs to be set
# appropriately as well. For example:
# .requirements = ["Kill Two Goblins", "Find 3 Eggs"]
# .values = [2, 3]
# .variables = [1, 2]
# If variable 1 is 2 or higher, the first requirement will appear green and
# if variable 2 is 3 or higher, the second requirement will appear green.
#
# If it is set to 2, make sure to set .requirements to string values and
# set .switches accordingly. For example:
# .requirements = ["Fight Orc", "Capture Flag"]
# .switches = [1, 2]
# If switch 1 is on, Fight Orc will appear green in the menu and if switch 2
# is on, Capture Flag will also appear green.
#
# If type is set to 3, make sure to set .requirements to IDs of Items from
# the database. Then make sure .values are set appropriately.
# For example:
# .requirements = [1, 2, 3]
# .values = [3, 2, 1]
# You'd need 3 potions, 2 high potions, and 1 full potion.
# â— .description
# - A string value that appears in the description box explaining quest.
# â— .requirements
# - An array which if type is 0 2 or 3, will contain string values, for example
# ["Kill the King", "Save the Princess", "Dance a Jig"]
# If type is 1, be sure to fill it with item ids such as
# [1, 2, 3] will return Potion, High Potion, Full Potion by default
# â— .values
# - An array which holds integer values. If the type is 0, this field can be
# blank as it will have no effect. If type is 1, these values correspond with
# how much of the items in .requirements you need. For example:
# .requirements = [1, 2, 3]
# .values = [3, 2, 1]
# You need 3 Potions, 2 High Potions, and 1 Full Potion.
# If type is 1, this holds how much of each Quest Variable you need.
# â— .switches
# - Holds integer values of the IDs of Quest_Switches. This is used if the .type
# is set to 2.
# â— .variables
# - Holds integer values of the IDs of Quest_Variables. This is used if the .type
# is set to 1.
# â— .completed
# - If true, the name will be green in the quest menu.
# [NEW] This field will automatically update if conditions for quest are met.
# â— .disabled
# - If true, the name will be greyed out in the quest menu.
# Note: If both completed and disabled are true, it will appear completed.
#
# If any further questions are needed refer to the RMXP.net thread.
# â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â—â— #
# Visual Aspects:
# New Class
#-------------------#
# â— Scene Quest â— #
#-------------------#
class Scene_Quest
def main
@quest = Window_Quest.new
@desc = Window_Description.new
@req = Window_Requirements.new
@quest.help_window = @desc
@quest.req_window = @req
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@quest.dispose
@desc.dispose
@req.dispose
end
def update
@quest.update
@desc.update
@req.update
if Input.trigger?(Input::B)
$scene = Scene_Map.new
end
end
end
# End New Class
# New Class
#--------------------#
# â— Window Quest â— #
#--------------------#
class Window_Quest < Window_Selectable
attr_reader :req_window
def initialize
super(0, 0, 640, 192)
@column_max = 2
refresh
self.index = 0
end
def quest
return @data[self.index]
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in 0...$quest.size
if $quest[i] != nil
@data.push($quest[i])
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
quest = @data[index]
text = ""
if quest.type == 0
self.contents.font.color = normal_color
text = quest.name
else
if quest.disabled
self.contents.font.color = disabled_color
text += "(?) " + quest.name.to_s
elsif quest.completed
self.contents.font.color = Color.new(0, 255, 0, 255)
text += "(*) " + quest.name.to_s
else
self.contents.font.color = Color.new(255, 0, 0, 255)
text += "(!) " + quest.name.to_s
end
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
self.contents.draw_text(x, y, 212, 32, text, 0)
end
def update_help
@help_window.set_text(self.quest == nil ? "" : self.quest.description)
if self.quest != nil
if @req_window != nil
@req_window.clear_text
for i in 0...self.quest.requirements.size
quest = self.quest
if quest.type == 0
@req_window.add_text(quest.requirements[i].to_s, -1)
elsif quest.type == 1
quest_variable = $quest_variables[quest.variables[i]]
if quest_variable != nil
@req_window.add_text(quest.requirements[i].to_s, quest_variable.to_i, quest.values[i], quest.type)
else
@req_window.add_text("Not Found?", -1)
end
elsif quest.type == 2
quest_switch = $quest_switches[quest.switches[i]]
if quest_switch != nil
@req_window.add_text(quest.requirements[i].to_s, quest_switch, quest.values[i], quest.type)
else
@req_window.add_text("Not Found?", -1)
end
elsif quest.type == 3
quest_item = $data_items[quest.requirements[i]]
if quest_item != nil
@req_window.add_text(quest_item.name.to_s, $game_party.item_number(quest_item.id), quest.values[i], quest.type)
else
@req_window.add_text("Not Found?", -1)
end
end
end
end
end
end
def help_window=(help_window)
@help_window = help_window
if self.active and @help_window != nil
update_help
end
end
def req_window=(req_window)
@req_window = req_window
if self.active and @req_window != nil
update_help
end
end
end
# End New Class
# New Class
#---------------------------#
# â— Window Requirements â— #
#---------------------------#
class Window_Requirements < Window_Base
def initialize
super(0, 256, 640, 480-256)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
@full_text = []
@amount = []
@amount_needed = []
@type = []
end
def add_text(text, amount, amount_needed = -1, type = 0)
@full_text.push(text)
@amount.push(amount)
@amount_needed.push(amount_needed)
@type.push(type)
show_text
end
def clear_text
@full_text = []
@amount = []
@amount_needed = []
@type = []
end
def show_text
self.contents.clear
self.contents.font.color = normal_color
for i in 0...@full_text.size
x = 4 + i % 2 * (288 + 32)
y = i / 2 * 32
if @type[i] == 0
self.contents.font.color = normal_color
self.contents.draw_text(x, y, (self.width / 2) - 40, 32, @full_text[i], 0)
elsif @type[i] == 1 or @type[i] == 3
if @amount[i] >= @amount_needed[i]
self.contents.font.color = Color.new(0, 255, 0, 255)
else
self.contents.font.color = Color.new(255, 0, 0, 255)
end
self.contents.draw_text(x, y, (self.width / 2) - 40, 32, @full_text[i], 0)
self.contents.draw_text(x, y, (self.width / 2) - 40, 32, @amount[i].to_s + "/" + @amount_needed[i].to_s, 2)
elsif @type[i] == 2
if @amount[i] == true
self.contents.font.color = Color.new(0, 255, 0, 255)
else
self.contents.font.color = Color.new(255, 0, 0, 255)
end
self.contents.draw_text(x, y, (self.width / 2) - 40, 32, @full_text[i], 0)
end
end
self.visible = true
end
end
# End New Class
# New Class
#--------------------------#
# â— Window Description â— #
#--------------------------#
class Window_Description < Window_Base
def initialize
super(0, 192, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
end
def set_text(text, align = 0)
if text != @text or align != @align
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
@text = text
@align = align
end
self.visible = true
end
end
# End New Class
# Programming Aspects:
# New Class
#-----------------#
# â— PRX_Quest â— #
#-----------------#
class PRX_Quest
attr_accessor :name
attr_accessor :type
attr_accessor :description
attr_accessor :requirements
attr_accessor :values
attr_accessor :switches
attr_accessor :variables
attr_accessor :completed
attr_accessor :disabled
def initialize
@name = ""
@type = 0
@description = ""
@requirements = []
@values = []
@switches = []
@switches = Array.new(5000, false)
@variables = []
@variables = Array.new(5000, 0)
@completed = false
@disabled = false
end
end
# End New Class
# Modified Class
#-------------------#
# â— Scene Title â— #
#-------------------#
class Scene_Title
def initialize
$quest_switches = Quest_Switches.new # New
$quest_variables = Quest_Variables.new # New
$quest = [] # New
end
end
# End Modified Class
# Modified Class
#------------------#
# â— Scene Load â— #
#------------------#
class Scene_Load
def read_save_data(file)
characters = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$quest_switches = Marshal.load(file) # New
$game_variables = Marshal.load(file)
$quest_variables = Marshal.load(file) # New
$game_self_switches = Marshal.load(file)
$game_screen = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
$quest = Marshal.load(file) # New
if $game_system.magic_number != $data_system.magic_number
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
$game_party.refresh
end
end
# End Modified Class
# New Class
#----------------------#
# â— Quest Switches â— #
#----------------------#
class Quest_Switches
def initialize
@data = []
@data = Array.new(5000, false)
end
def [](switch_id)
if switch_id <= 5000 and @data[switch_id] != nil
return @data[switch_id]
else
return false
end
end
def []=(switch_id, value)
if switch_id <= 5000
@data[switch_id] = value
comp_count = 0
for i in 0...$quest.size
if $quest[i].type == 2
for k in 0...$quest[i].requirements.size
if @data[$quest[i].switches[k]] == true
comp_count += 1
end
end
if comp_count == $quest[i].requirements.size
$quest[i].completed = true
else
$quest[i].completed = false
end
end
end
end
end
end
# End New Class
# New Class
#-----------------------#
# â— Quest Variables â— #
#-----------------------#
class Quest_Variables
def initialize
@data = []
@data = Array.new(5000, 0)
end
def [](variable_id)
if variable_id <= 5000 and @data[variable_id] != nil
return @data[variable_id]
else
return 0
end
end
def []=(variable_id, value)
if variable_id <= 5000
@data[variable_id] = value
comp_count = 0
for i in 0...$quest.size
if $quest[i].type == 1
for k in 0...$quest[i].requirements.size
if @data[$quest[i].variables[k]] != nil
if @data[$quest[i].variables[k]] >= $quest[i].values[k]
comp_count += 1
end
end
end
if comp_count == $quest[i].requirements.size
$quest[i].completed = true
else
$quest[i].completed = false
end
end
end
end
end
end
# End New Class
# Modified Class
#------------------#
# â— Game Party â— #
#------------------#
class Game_Party
def gain_item(item_id, n)
if item_id > 0
@items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
# New
comp_count = 0
for i in 0...$quest.size
if $quest[i].type == 3
for k in 0...$quest[i].requirements.size
if item_number($quest[i].requirements[k]) >= $quest[i].values[k]
comp_count += 1
end
end
if comp_count == $quest[i].requirements.size
$quest[i].completed = true
else
$quest[i].completed = false
end
end
end
# End New
end
end
end
# End Modified Class