New Version Has Arrived!
No more editing at other places. Just put it!
#=============================================================================
# Quest Log Screen
#-----------------------------------------------------------------------------
# ** Version 2.3
# ** Original by Sthrattoff
#=============================================================================
# Description :
# This script enables the ability to show current active quest.
# Features :
# EXTREMELY SIMPLIFIED! Now the script is just about 150 lines length including comments.
# Unlimited amount of quest can be added.
# Use variable to mark quest's progress.
# Limitation :
# Only can store up to 12 progresses per quest.
# History :
# Version 1.0 : Initial release.
# Version 1.2 : Add "Types" features.
# Version 2.0 : Changes in programming style and infinite quest support.
# Version 2.2 : Cut the script length to about 150 lines.
# Version 2.3 : Add "Quest Progress" bar in exchange of "Types" removal.
# Instruction
# Just put this script above main.
# Configuration :
# To add a quest, fill these information by using .push
# $names.push "Name"
# $types.push "Type"
# $description.push (["line1", "line2", ..., "Line5"])
# $objectives.push (["onjective1", ..., "objective12"])
# $var_ID.push ID_NUMBER
# $end_val.push END_VALUE
# Credits
# See the header + Blizzard and Enterbrain
#=============================================================================
class Scene_Quest
# Defines array variables
$names = []
$description = []
$objectives = []
$var_ID = []
$end_val = []
# The main process
def main
@quest_list = Window_Command.new(160, $names)
@quest_window = Window_Quest.new
@quest_window.x = 160
Graphics.transition
loop do
Graphics.update
Input.update
update
break if $scene != self
end
Graphics.freeze
@quest_list.dispose
@quest_window.dispose
end
def update
@quest_list.update
@quest_window.update
if @quest_list.active
update_quest
return
end
end
def update_quest
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(2)
return
end
$id = @quest_list.index
return
end
end
class Window_Quest < Window_Base
def initialize
super(0, 0, 480, 480)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0, self.width - 32, 32, $names[$id.to_i].to_s, 1)
self.contents.draw_text(0, 192, self.width - 32, 32, "Objectives", 1)
self.contents.draw_text(0, 416, self.width - 32, 32, "Quest Progress")
self.contents.font.color = normal_color
for i in 0..4
self.contents.draw_text(0, i * 32 + 32, self.width - 32, 32, $description[$id.to_i][i].to_s)
end
a = b = $game_variables[$var_ID[$id.to_i]]
if a > 5
self.contents.draw_text(240, (a - 6) * 32 + 224, 240, 32, "• " + $objectives[$id.to_i][a].to_s)
else
self.contents.draw_text(0, a * 32 + 224, 240, 32, "• " + $objectives[$id.to_i][a].to_s)
end
self.contents.font.color = disabled_color
if b > 0
for j in 0..(b - 1)
if j > 5
self.contents.draw_text(240, (j - 6) * 32 + 224, 240, 32, "• " + $objectives[$id.to_i][j].to_s)
else
self.contents.draw_text(0, j * 32 + 224, 240, 32, "• " + $objectives[$id.to_i][j].to_s)
end
end
end
draw_quest_progress(96, 428, self.width - 128)
end
def update
refresh
end
end
class Window_Base < Window
def draw_quest_progress(x, y, w = 200)
current = $game_variables[$var_ID[$id.to_i]]
ending = $end_val[$id.to_i]
bordercolor = system_color
outercolor = Color.new(180, 210, 120, 255)
midcolor = Color.new(180, 210, 140, 255)
innercolor = Color.new(180, 210, 160, 255)
emptycolor = Color.new(0, 0, 0, 255)
linewidth = (((current * 1.0) / ending) * (w - 2))
emptywidth = ((w - 1) - linewidth)
emptyx = ((x + 1) + linewidth)
border = Rect.new(x, y, w, 8)
emptyline = Rect.new(x + 1, y + 1, w - 2, 6)
outerline = Rect.new(x + 1, y + 1, linewidth, 6)
midline = Rect.new(x + 2, y + 2, linewidth - 2, 4)
innerline = Rect.new(x + 3, y + 3, linewidth - 4, 2)
self.contents.fill_rect(border, bordercolor)
self.contents.fill_rect(emptyline, emptycolor)
self.contents.fill_rect(outerline, outercolor)
self.contents.fill_rect(midline, midcolor)
self.contents.fill_rect(innerline, innercolor)
end
end
class Scene_Save < Scene_File
alias old_save_data write_save_data
def write_save_data(file)
old_save_data(file)
Marshal.dump($names, file)
Marshal.dump($description, file)
Marshal.dump($objectives, file)
Marshal.dump($var_ID, file)
Marshal.dump($end_val, file)
end
end
class Scene_Load < Scene_File
alias old_load_data read_save_data
def read_save_data(file)
old_load_data(file)
$names = Marshal.load(file)
$description = Marshal.load(file)
$objectives = Marshal.load(file)
$var_ID = Marshal.load(file)
$end_val = Marshal.load(file)
end
end
class Scene_Title
alias old_new_game command_new_game
def command_new_game
old_new_game
$names.clear
$description.clear
$objectives.clear
$var_ID.clear
$end_val.clear
end
end
class Scene_Menu
def initialize(menu_index = 0)
@menu_index = menu_index
size = $names.size
for i in 0..size
var = $var_ID[i]
ending = $end_val[i]
if $game_variables[var.to_i] >= ending.to_i
$names.delete_at i
$description.delete_at i
$objectives.delete_at i
$var_ID.delete_at i
$end_val.delete_at i
end
end
end
end