Basic Quest System

Might as well necro-post instead of making a new thread again. The quest system does not keep progress when the player closes the game. An objective might be at 1/1 upon saving and closing the game, but when the player opens it up again, it's at 0/1.

It's confusing my players a lot, and causing me headaches every time when I explain that what the quest log shows and the actual quest progress (done through conditional branches) are unrelated.

Anyone else has this problem?
necro-post instead of making a new thread again
You can go either way. You can't necro post a script thread. It's made to always have new info.
Script support is under the 30 day limit.
Let me check this out.

Remove Vlue module DataManager in the script. Line 420-433 or further down if you have a lot of quests.
Add this in to the same spot or below vlue basic quest
Ruby:
module DataManager
  class << self
    alias r2_vlue_quest_extract extract_save_contents
    alias r2_save_vlue_quest make_save_contents
    alias quest_sng setup_new_game
  end

  def self.make_save_contents
    r2vluequestdata = r2_save_vlue_quest
    r2vluequestdata[:quest_data] = $game_quests
    r2vluequestdata
  end
 
  def self.extract_save_contents(contents)
    r2_vlue_quest_extract(contents)
    $game_quests = contents[:quest_data]
  end
 
  def self.setup_new_game
    $game_quests = Game_Quests.new
    quest_sng
  end
end
Awesome, it worked, thanks.
@Roninator can I ask for one more change? What must I do to have custom text as a reward description? For example if finishing a quest improves reputation with a faction or something like that.
@Roninator can I ask for one more change? What must I do to have custom text as a reward description? For example if finishing a quest improves reputation with a faction or something like that.
I don't quite understand. there is an option to have a description.
what is it not doing that you need?
I want the custom text option in the reward part as well, not just the quest description.
I want the custom text option in the reward part as well
Ruby:
class Quest
  def initialize(id,quest_hash)
    @id = id
    @level = 0
    @difficulty = 0
    @name = "No Quest Name"
    @desc = ""
    @qgiver_name = 0
    @location = 0
    @auto_complete = false
    @abandonable = true
    @need_popup = false
    @force_turnin = false
    @force_accept = false
    @name = quest_hash[:name] if quest_hash[:name]
    @level = quest_hash[:level] if quest_hash[:level]
    @force_accept = quest_hash[:force_accept] if quest_hash[:force_accept]
    @force_turnin = quest_hash[:force_turnin] if quest_hash[:force_turnin]
    @difficulty = quest_hash[:difficulty] if quest_hash[:difficulty]
    @auto_complete = quest_hash[:auto_complete] if quest_hash[:auto_complete]
    @abandonable = quest_hash[:abandonable] if !quest_hash[:abandonable].nil?
    @desc = QUEST::DESCRIPTIONS[id][:desc] if QUEST::DESCRIPTIONS[id][:desc]
    @qgiver_name = QUEST::DESCRIPTIONS[id][:qgiver_name] if QUEST::DESCRIPTIONS[id][:qgiver_name]
    @location = QUEST::DESCRIPTIONS[id][:location] if QUEST::DESCRIPTIONS[id][:location]
    @objectives = {}
    if QUEST::OBJECTIVES[id]
      QUEST::OBJECTIVES[id].each do |id, obj|
        @objectives[id] = Objective.new(id, obj)
      end
    else
      msgbox("Quest " + id.to_s + " has no objectives.")
    end
    @reward_gold = 0
    @reward_exp = 0
    @scale_exp = 0
    @reward_items = []
    @reward_text = ""
    begin
      if QUEST::REWARDS[id][:gold]
        @reward_gold = QUEST::REWARDS[id][:gold]
      end
      if QUEST::REWARDS[id][:exp]
        @reward_exp = QUEST::REWARDS[id][:exp]
        @scale_exp = QUEST::REWARDS[id][:scale_exp] if QUEST::REWARDS[id][:scale_exp]
      end
      if QUEST::REWARDS[id][:items]
        @reward_items = QUEST::REWARDS[id][:items]
      end
      if QUEST::REWARDS[id][:text]
        @reward_text = QUEST::REWARDS[id][:text]
      end
    rescue
      msgbox(id.to_s + " has no defined REWARDS. This is not optional.")
    end
  end
  def reward_text
    @reward_text
  end
end
class Window_SceneDetail < Window_Base
  def refresh
    contents.clear
    return unless @quest
    contents.font.size = 18
    change_color(system_color)
    draw_text(0,0,contents.width,line_height,@quest.qgiver_name) if @quest.qgiver_name != 0
    draw_text(0,0,contents.width,line_height,@quest.location,2) if @quest.location != 0
    change_color(normal_color)
    @quest.qgiver_name != 0 || @quest.location != 0 ? yy = line_height : yy = 0
    draw_text_ex(0,yy,@quest.desc)
    change_color(system_color)
    draw_text(0,line_height*7,contents.width,24,"Objectives:")
    change_color(normal_color)
    yy = line_height * 8
    @quest.objectives.each do |id, obj|
      next if obj.hidden
      draw_objective(yy, obj)
      yy += 24
    end
    change_color(system_color)
    draw_text(0,yy,contents.width,line_height,"Rewards:")
    yy += line_height
    if @quest.reward_exp > 0
      draw_text(6,yy,contents.width/2,line_height,"XP: ")
      change_color(normal_color)
      draw_text(36,yy,contents.width/2,line_height,@quest.reward_exp)
      yy += line_height
    end
    if @quest.reward_gold > 0
      change_color(normal_color)
      draw_text(6,yy,contents.width/2,line_height,@quest.reward_gold.to_s)
      cx = text_size(@quest.reward_gold).width
      change_color(system_color)
      draw_text(6+cx,yy,contents.width/2,line_height,Vocab::currency_unit)
    end
    yy += line_height
    change_color(normal_color)
    @quest.reward_items.each do |array|
      item = $data_items[array[1]] if array[0] == :item
      item = $data_weapons[array[1]] if array[0] == :weapon
      item = $data_armors[array[1]] if array[0] == :armor
      draw_item_name(item, 6, yy, true, contents.width)
      if array[2] > 1
        draw_text(6+text_size(item.name).width+36,yy,48,24,"x"+array[2].to_s)
      end
      yy += line_height
    end
    if @quest.difficulty != 0
      text = "Difficulty: " + @quest.difficulty
      draw_text(0,contents.height-line_height,contents.width,line_height,text,2)
    end
    if @quest.reward_text != ""
      yy += line_height
      change_color(normal_color)
      draw_text(0,yy,contents.width,line_height,@quest.reward_text.to_s)
    end
  end
end
class Window_QuestApply < Window_Base
  def refresh
    return unless @quest
    contents.clear
    change_color(system_color)
    yy = 0
    if @quest.qgiver_name != 0
      draw_text(0,0,contents.width/2,line_height,@quest.qgiver_name)
      yy = line_height
    end
    if @quest.location != 0
      draw_text(contents.width/2,0,contents.width/2,line_height,@quest.location,2)
      yy = line_height
    end
    change_color(crisis_color)
    draw_text(0,yy,contents.width,line_height,"Lvl: " + @quest.level.to_s) if @quest.level > 0
    draw_text(0,yy,contents.width,line_height,@quest.name,1)
    draw_text(0,yy,contents.width,line_height,@quest.difficulty,2) if @quest.difficulty != 0
    change_color(normal_color)
    draw_text_ex(0,line_height+yy,@quest.desc)
    change_color(system_color)
    draw_text(0,line_height*8,contents.width,line_height,"Objectives:")
    change_color(normal_color)
    yy = line_height * 9
    @quest.objectives.each do |obj_id, obj|
      next if obj.hidden
      draw_objective(yy, $game_party.quests[@quest.id][obj_id])
      yy += line_height
    end
    change_color(system_color)
    draw_text(0,yy,contents.width,line_height,"Rewards:")
    yy += line_height
    if @quest.reward_exp > 0
      draw_text(6,yy,contents.width/2,line_height,"XP: ")
      change_color(normal_color)
      draw_text(36,yy,contents.width/2,line_height,@quest.reward_exp)
      yy += line_height
    end
    if @quest.reward_gold > 0
      change_color(normal_color)
      draw_text(6,yy,contents.width/2,line_height,@quest.reward_gold.to_s)
      cx = text_size(@quest.reward_gold).width
      change_color(system_color)
      draw_text(6+cx,yy,contents.width/2,line_height,Vocab::currency_unit)
    end
    yy += line_height
    change_color(normal_color)
    @quest.reward_items.each do |array|
      item = $data_items[array[1]] if array[0] == :item
      item = $data_weapons[array[1]] if array[0] == :weapon
      item = $data_armors[array[1]] if array[0] == :armor
      draw_item_name(item, 6, yy, true, contents.width)
      if array[2] > 1
        draw_text(6+text_size(item.name).width+36,yy,48,24,"x"+array[2].to_s)
      end
      yy += line_height
    end
    if @quest.reward_text != ""
      change_color(normal_color)
      draw_text(0,yy,contents.width,line_height,@quest.reward_text.to_s)
    end
  end
end

write the quest like this
Ruby:
    REWARDS[:quest001] = {
    :exp => 50000,
    :text => "look at this now",
    }
Ruby:
    p(@quest.reward_text)

You forgot to delete it, @Roninator2 .

By the way, whenever you have to initialize boolean variables and it is possible for them to be false or simply not true, you can look for the given hash key to get its return value. It won't matter if the result is nil because it will disable that feature by default. That means there's no need to add any if modifier statement at the end of the line.
You forgot to delete it, @Roninator2 .
thanks

By the way, whenever you have to initialize boolean variables and it is possible for them to be false or simply not true, you can look for the given hash key to get its return value. It won't matter if the result is nil because it will disable that feature by default. That means there's no need to add any if modifier statement at the end of the line.
I'm not sure what part that is in reference to.
Except for the reward_text basically everthing else is a copy of the original script.
So I assume you are referring to something that is in the original script.
Thanks, I finally managed to fix it.
Hey, Ronin. In that same test file (https://drive.google.com/drive/folders/10ODj0Vq5pkzmFinWwC_xKCjeNdAMYScP) can you take a look at the quest system's log display (test it with a quest or two)? The heights are all messed-up. I've been trying to fix it on my own, but it's giving me a headache.

Edit: Also, it might be because of all the edits I've done, but when I set 2 texts as rewards, it only displays the bottom one.
there were a few mistakes in there. Mainly you were not adding on the text you were overwriting it.
I didn't evaluate everything, but this is the fixed code for what you were doing.
Changed the text to be in an array
moved the def rewards outside the def initialize method.
removed the second reward method
modified the first one to iterate through the array.
all text rewards are now arrays
Spoiler: quest
Ruby:
#Basic Quest System v1.3f
#By Vlue
#----------#
#Features: Quests! What more can you say.
#
#Usage:   Set up your quests and away you go!
#        Script calls:
#         accept_quest(:questid)     - force quest accept
#         ask_accept(:questid)       - open quest acceptance window
#         abandon_quest(:questid)    - force quest abandon
#         turnin_quest(:questid)     - force quest turnin
#         fail_quest(:questid)       - force abandon with ME
#         ask_turnin(:questid)       - open quest complete window
#
#       adv_obj(:questid, :objectiveid, value)   - changes obj by value
#       set_obj(:questid, :objectiveid, value)   - sets obj to value
#       obj(:questid, :objectiveid)              - gets obj value
#       hide_obj(:questid, :objectiveid)         - hides objective
#       show_obj(:questid, :objectiveid)         - shows objective
#
#     $game_quests[:questid].accepted?     - true if quest is accepted
#     $game_quests[:questid].completed?    - true if quest is completed
#     $game_quests[:questid].turned_in?     - true if quest is turned in
#
# Examples:
#  The obj function can be used in conditional branches to check progress
#   of certain objectives. Example.
#    #Checking if :obj3 of :quest89 is greater than 3:
#     obj(:quest89, :obj3) > 3
#
#~ #----------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
#    given by email: [email hidden]
#    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
#   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
#
#--- Free to use in any project, commercial or non-commercial, with credit given
# - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
 
#Visibility of quest log on map
$questlogvisibility = false
#Maximum # of quests displayed on the quest log overlay
$questlogmaxdisplay = 2
#Quest log position, 1 - top-left, 2 - top-right
QUEST_LOG_POSITION = 2
#Quest log offsets
QUEST_LOG_OFFSET_X = 0
QUEST_LOG_OFFSET_Y = 0
 
# Quest Format and set up!
 
# DETAILS[:quest_id] = {
#   :name => "quest name"     #Quest name
#   :level => value           #Arbitrary value (Optional)
#   :difficulty => "string"   #Arbitrary string (Optional)
#   :auto_complete => true    #Recieve rewards on the spot (Optional)
#   :abandonable => false     #Set's whether quest can be abandoned (Optional)
#   :force_accept => true     #ask_accept only allows accepting (Optional)
#   :force_turnin => true     #ask_turnin only allows completing (Optional)
#  }
# DESCRIPTIONS[:quest_id] = {
#   :qgiver_name => "string"  #Quest giver name (shows in log) (Optional)
#   :location => "string"     #Quest giver location (shows in log) (Optional)
#   :desc => "string"         #Description of quest displayed in log (Optional)
#  }
# OBJECTIVES[:quest_id] = {   #Quest objectives, "string" is name, id is max value
#                             #   boolean is hidden objective (true for hidden)
#   :obj_id1 => ["string", id]
#   :obj_id2 => ["string", id, boolean],
#   etc...
#  }
# REWARDS[:quest_id] = {
#   :gold => value            #Gold recieved from quest (Optional)
#   :exp => value             #Exp recieved from quest (Optional)
#         #Items recieved from quest, :type is :item, :weapon, or :armor
#   :scale_exp => value       #Percent value to scale exp based on level vs party
#   :items => [[:type,id,value], ...]],    (Optional)
#  }
 
module QUEST
  DETAILS= {}
  DESCRIPTIONS = {}
  OBJECTIVES = {}
  REWARDS = {}
 
  #Broken Reality
  DETAILS[:quest1] = {
    :name => "Broken Reality",}
  DESCRIPTIONS[:quest1] = {
    :desc => "A deity known as 'Mother' wants me to find some 'Truth' about the world of Psema. The 'Regulators', also known as 'The Trinity', Gods of Psema, want me to stay put. Both claim to have my best interests in mind, and say that the other is lying. I fear I am the unluckiest person in Psema." }
  OBJECTIVES[:quest1] = {
    :obj1 => ["Explore Psema",0],
    :obj2 => ["I found Hana, Mother's chosen.",1,true],
    :obj3 => ["We recruited a werewolf, Gouki.",1,true],
    :obj4 => ["Visit Theodoxa.",1,true],
    :obj5 => ["We recruited a magus, Hachi.",1,true] }
    REWARDS[:quest1] = {
    :text => "Freedom of Choice" }
    
  #Mother's Will
  DETAILS[:quest2] = {
    :name => "Mother's Will",}
  DESCRIPTIONS[:quest2] = {
    :desc => "Mother has told Hana that we need to travel to a city called 'Theodoxa'. There, the next part of her plan will be revealed. I will lead Hana there, but..." }
  OBJECTIVES[:quest2] = {
    :obj1 => ["Travel to Hioni from Woodsedge Docks and recruit a man there",1]}
    REWARDS[:quest2] = {
    :text => "The Truth" }
 
  #Floor 3 Church Side Quest
  DETAILS[:sidequest001] = {
    :name => "Abandoned Faith",
    :difficulty => "where is this going?" }
  DESCRIPTIONS[:sidequest001] = {
    :qgiver_name => "Trinity Priest",
    :location => "Blackcry",
    :desc => "The Trinity priest of Blackcry was chased out of his church by the lotic, leaving behind his Trinity cross of the Trinity. He wants it back." }
  OBJECTIVES[:sidequest001] = {
    :obj1 => ["Trinity Cross", 1] }
  REWARDS[:sidequest001] = {
    :text => ["30% Wave", "150 Col"] }
    
  #Floor 1 Wolf Perk Side Quest
  DETAILS[:sidequest002] = {
    :name => "Howl of the Wolf"}
  DESCRIPTIONS[:sidequest002] = {
    :qgiver_name => "Tibian",
    :location => "Illfang's Forest",
    :desc => "A group of ruffians hunt wolves for sport. Tibian wants me to stop them. I can find them in Mermaid's Song, in ToB." }
  OBJECTIVES[:sidequest002] = {
    :obj1 => ["Hunters dispatched", 3],
    :obj2 => ["Report back to Tibian",1,true]}
  REWARDS[:sidequest002] = {
    :text => ["60% Wave","Overworld Pacified Wolves"]}
    
  #Floor 1 Kobold Cousins
  DETAILS[:sidequest003] = {
    :name => "The Kobold Cousins"}
  DESCRIPTIONS[:sidequest003] = {
    :qgiver_name => "Kobold Guard",
    :location => "Town of Beginnings",
    :desc => "The kobold guarding the entrance to Illfang's Tower wants me to find out what happened to his cousin, Vagabond. He should be in Illfang's Forest, in some cave." }
  OBJECTIVES[:sidequest003] = {
    :obj1 => ["Find Vagabond", 1],
    :obj2 => ["Learn cousin's name", 1],
    :obj3 => ["Report back to cousin", 1]}
  REWARDS[:sidequest003] = {
    :text => ["25% Wave","No Alarm in Kobold Lands"]}
    
    #Floor 1 Docks Scorpion Skin
  DETAILS[:sidequest004] = {
    :name => "Missing Ingredient"}
  DESCRIPTIONS[:sidequest004] = {
    :qgiver_name => "Magus at docks",
    :location => "Town of Beginnings Docks",
    :desc => "A masked man in the docks is looking for his lost ingredient for alchemy, scorpion skin. It is located somewhere in the docks." }
  OBJECTIVES[:sidequest004] = {
    :obj1 => ["Find the scorpion skin", 1],
    :obj2 => ["Return to the magus", 0, true]}
  REWARDS[:sidequest004] = {
    :text => ["5% Wave", "Healing Potion X2" ]}
    
  #Floor 1 Hiding Grandson
  DETAILS[:sidequest005] = {
    :name => "Brat Trackdown"}
  DESCRIPTIONS[:sidequest005] = {
    :qgiver_name => "Elderly Man",
    :location => "Palace Plaza, ToB",
    :desc => "An old man's grandson has ran off. I should ask the children where to find him." }
  OBJECTIVES[:sidequest005] = {
    :obj1 => ["Locate the brat", 1],
    :obj2 => ["Return to the elder", 0, true]}
  REWARDS[:sidequest005] = {
    :text => ["7% Wave", "Cooking Recipes"]}
    
  #Floor 1 Wine Cellar Rats
  DETAILS[:sidequest006] = {
    :name => "Rat Infestation"}
  DESCRIPTIONS[:sidequest006] = {
    :qgiver_name => "Liquor Store Owner",
    :location => "Southeast Sector, ToB",
    :desc => "The basement of the liquor store is infested with rats. I need to kill them all." }
  OBJECTIVES[:sidequest006] = {
    :obj1 => ["Rats killed", 4]}
  REWARDS[:sidequest006] = {
    :text => ["18% Wave", "Wine Shop Discounts"]}
 
  #Floor 1 Hunter 1 - Doug
  DETAILS[:sidequest007] = {
    :name => "A Punchable Offense"}
  DESCRIPTIONS[:sidequest007] = {
    :qgiver_name => "Doug",
    :location => "Mermaid's Song, ToB",
    :desc => "Doug Ironsword is one of the three hunter ruffians in Mermaid's Song." }
  OBJECTIVES[:sidequest007] = {
    :obj1 => ["Dig some dirt on Doug", 1],
    :obj2 => ["Find mr. Ironsword", 1, true],
    :obj3 => ["Go back to Doug", 1, true]}
  REWARDS[:sidequest007] = {
    :text => ["20% Wave"] }
    
  #Floor 1 Hunter 1 - Doug Alternative
  DETAILS[:sidequest008] = {
    :name => "A Highly Punchable Offense"}
  DESCRIPTIONS[:sidequest008] = {
    :qgiver_name => "Vickie",
    :location => "Ironsword Mansion",
    :desc => "Vickie wants me to ambush Doug near the Drunk Dragon and mug him. This is an alternative way to stop the hunter." }
  OBJECTIVES[:sidequest008] = {
    :obj1 => ["Beat up Doug", 1]}
  REWARDS[:sidequest008] = {
    :text => ["17% Wave"] }
 
  #Floor 2 Baby Wyrms
  DETAILS[:sidequest009] = {
    :name => "Sheep Snap"}
  DESCRIPTIONS[:sidequest009] = {
    :qgiver_name => "Farmer Timberson",
    :location => "Urbus Provinces",
    :desc => "Farmer Timberson wants me to find and eradicate the baby wyrms that plague his sheep." }
  OBJECTIVES[:sidequest009] = {
    :obj1 => ["Baby wyrms killed", 6]}
  REWARDS[:sidequest009] = {
    :text => ["70% Wave"] }
    
  #Floor 1 Hunter 3 - Music option
  DETAILS[:sidequest010] = {
    :name => "The Aspiring Musician"}
  DESCRIPTIONS[:sidequest010] = {
    :qgiver_name => "Hunter",
    :location => "Mermaid's Song, ToB",
    :desc => "The sophisticated hunter wants to learn music. Perhaps if I could find a bard near the ToB..." }
  OBJECTIVES[:sidequest010] = {
    :obj1 => ["Find a bard", 1],
    :obj2 => ["Report back to the hunter", 1, true]}
  REWARDS[:sidequest010] = {
    :text => ["15% Wave"] }
    
  #Floor 1 Hunter 3 - Rude Hunter
  DETAILS[:sidequest011] = {
    :name => "Enemy of my Enemy"}
  DESCRIPTIONS[:sidequest011] = {
    :qgiver_name => "Hunter",
    :location => "Mermaid's Song, ToB",
    :desc => "Rhys is the rudest amongst the group of thug-hunters, despite being the most cowardly.
    A worm like that is bound to have an enemy or two..." }
  OBJECTIVES[:sidequest011] = {
    :obj1 => ["Ask the wench", 1],
    :obj2 => ["Find Sally", 1, true],
    :obj3 => ["Visit the Drunk Dragon", 1, true],
    :obj4 => ["Return to Rhys", 1, true]}
  REWARDS[:sidequest011] = {
    :text => ["15% Wave"] }
    
  #Floor 1 Church Side Quest
  DETAILS[:sidequest012] = {
    :name => "Mother's Necklace"}
  DESCRIPTIONS[:sidequest012] = {
    :qgiver_name => "Nancy",
    :location => "Church Grounds, ToB",
    :desc => "One of the orphanage girls south of the Town of Beginnings is missing her mother's memento. She suspects someone has stolen it from her." }
  OBJECTIVES[:sidequest012] = {
    :obj1 => ["Talk with Enver", 1],
    :obj2 => ["Talk with Flare", 1, true],
    :obj3 => ["Return to Nancy", 1, true]}
  REWARDS[:sidequest012] = {
    :text => ["10% Wave"] }
    
  #Floor 1 Church Side Quest #2
  DETAILS[:sidequest013] = {
    :name => "Enlightment in a Bottle"}
  DESCRIPTIONS[:sidequest013] = {
    :qgiver_name => "Sister Rafa",
    :location => "Orphanage",
    :desc => "Sister Rafa, one of the orphans' caretakers is wasted. She accidentally drank the sacramental wine and now needs to replace it." }
  OBJECTIVES[:sidequest013] = {
    :obj1 => ["Give her red wine", 1],
    :obj2 => ["Give her more red wine", 1, true],
    :obj3 => ["Give her sake", 1, true]}
  REWARDS[:sidequest013] = {
    :text => ["17% Wave"]}
    
  #Floor 3 Repairer of Reputations
  DETAILS[:sidequest014] = {
    :name => "Songs which Break Reality"}
  DESCRIPTIONS[:sidequest014] = {
    :qgiver_name => "Servants of the Artist",
    :location => "Forests of Shilai, near Blackcry",
    :desc => "Servants of the Artist have given me a strange coin, as a reward for helping them. I have been told to bring it to a small lake in the forests of Shilai, near Blackcry." }
  OBJECTIVES[:sidequest014] = {
    :obj1 => ["Find the clearing", 1]}
  REWARDS[:sidequest014] = {
    :text => ["10% Wave"]}
    
  #Floor 1 Tomb Permit
  DETAILS[:sidequest015] = {
    :name => "Hikari's Permit"}
  DESCRIPTIONS[:sidequest015] = {
    :qgiver_name => "Guard",
    :location => "Town of Beginnings",
    :desc => "South of the Town of Beginnings lies the great dragon Hikari's tomb. The guard there won't let me get close without an official permit. I will have to find someone with authority in the Town of Beginnings to grant it to me." }
  OBJECTIVES[:sidequest015] = {
    :obj1 => ["Find someone who can give a permit", 1],
    :obj2 => ["Get the permit", 1, true],
    :obj3 => ["Return to the soldier", 1, true]}
  REWARDS[:sidequest015] = {
    :text => ["15% Wave", "Entry to Hikari's Tomb"]}
    
  #Free Quest 16 Toolbox Delivery
    DETAILS[:sidequest016] = {
    :name => "Hikari's Permit"}
  DESCRIPTIONS[:sidequest016] = {
    :qgiver_name => "Guard",
    :location => "Ironsword Blacksmith, ToB",
    :desc => "The blacksmith of Urbus has handed me a toolbox to deliver to the blacksmith in the Town of Beginnings." }
  OBJECTIVES[:sidequest016] = {
    :obj1 => ["Give the toolbox to ToB blacksmith", 1],
    :obj2 => ["Return to Urbus blacksmith", 1, true]}
  REWARDS[:sidequest016] = {
    :text => ["150 Col", "Copper bar", "10% Wave"]}
    
  #Floor 2 Healer Cave
  DETAILS[:sidequest017] = {
    :name => "Bone Studies"}
  DESCRIPTIONS[:sidequest017] = {
    :qgiver_name => "Blonde Healer",
    :location => "Cave in Urbus South Valley",
    :desc => "A Yudah Healers' Union member wants me to clear the way and the pests in the cave she is in, so she can study ancient skeletons in peace." }
  OBJECTIVES[:sidequest017] = {
    :obj1 => ["Clear the Cave/10", 0]}
  REWARDS[:sidequest017] = {
    :text => ["200 Col", "15% Wave"]}
    
  #Floor 1 Grandma Brother
  DETAILS[:sidequest018] = {
    :name => "Horunka Village"}
  DESCRIPTIONS[:sidequest018] = {
    :qgiver_name => "Farmer's Wife",
    :location => "Illfang's Forest",
    :desc => "A middle-aged woman at the edges of Illfang's Forest wants me to find her brother and see if he is alright. According to her, he should be working on his little farm in Horunka Village, in Illfang's Forest." }
  OBJECTIVES[:sidequest018] = {
    :obj1 => ["Find the Brother", 1],
    :obj2 => ["Return to the Farmer's Wife", 1, true]}
  REWARDS[:sidequest018] = {
    :text => ["18% Wave"] }
    
   #Floor 5 Cult of the Damned
  DETAILS[:sidequest019] = {
    :name => "Trapped Spirits"}
  DESCRIPTIONS[:sidequest019] = {
    :qgiver_name => "Spectre of Jafaan Abdallah",
    :location => "Nameless Tomb, East of Asari",
    :desc => "I met the ghost of a Trinity priest, cursed by the ancient Cult of the Damned which they defeated to die, and then have the spirit bound to the corpse. He wants me to find two orb artifacts, so that he may break the curse and let himself and his followers go to the afterlife." }
  OBJECTIVES[:sidequest019] = {
    :obj1 => ["Visit the Asari Temple archives", 1],
    :obj2 => ["Orb of Igbagbo in the north tomb", 1, true],
    :obj3 => ["Orb of Ina in Jafaan's House in East Asari", 1, true],
    :obj4 => ["Obtain the key from the barracks", 1, true],
    :obj5 => ["Return to the spectre", 1, true]}
  REWARDS[:sidequest019] = {
    :exp => 1500 }   
    
  #Floor 1 House Maid
  DETAILS[:sidequest020] = {
    :name => "Maid in Order"}
  DESCRIPTIONS[:sidequest020] = {
    :qgiver_name => "ToB Home",
    :location => "Town of Beginnings",
    :desc => "You've got yourself a nice, large house, now if only you had someone to look after it while you're out adventuring... There should be some poor lass in the city looking for work." }
  OBJECTIVES[:sidequest020] = {
    :obj1 => ["Find a maid for your ToB house", 1]}
  REWARDS[:sidequest020] = {
    :text => ["65% Wave"] }   
    
  #Floor 1 Spectre Quest
  DETAILS[:sidequest021] = {
    :name => "Nothing but Silence"}
  DESCRIPTIONS[:sidequest021] = {
    :qgiver_name => "River Spectre",
    :location => "Southern Paths",
    :desc => "The spectre by the river south of the Town of Beginnings is dissatisfied with the insistent barkings of the nearby dog when a bear comes to steal the crops. It wants its silence from before the bear showed up to return." }
  OBJECTIVES[:sidequest021] = {
    :obj1 => ["Keep the dog from barking", 1],
    :obj2 => ["Return to the spectre", 1, true]}
  REWARDS[:sidequest021] = {
    :text => ["20% Wave"] }   
    
  #Floor 1 Illfang
  DETAILS[:sidequest022] = {
    :name => "Kobold Invasion"}
  DESCRIPTIONS[:sidequest022] = {
    :qgiver_name => "Personal",
    :location => "Tolbana",
    :desc => "The kobolds near Tolbana are setting up ambushes for weary travellers and ganging up on adventurers, under the commands of a mysterious master. Dealing with them will make travelling safe, and give me some Yudah recognition." }
  OBJECTIVES[:sidequest022] = {
    :obj1 => ["Deal with the kobold problem", 1]}
  REWARDS[:sidequest022] = {
    :text => ["1 Wave"] }   
    
  #Floor 2 N'Gombe
  DETAILS[:sidequest023] = {
    :name => "Minotaur Raiders"}
  DESCRIPTIONS[:sidequest023] = {
    :qgiver_name => "Personal",
    :location => "Urbus Mountains",
    :desc => "Minotaurs attack travellers near Urbus indiscriminately. The beasts are strong, but not too bright, and rarely work on their own. They must have a leader somewhere near Urbus. Dealing with him will give me more Yudah recognition." }
  OBJECTIVES[:sidequest023] = {
    :obj1 => ["Deal with the minotaurs", 1]}
  REWARDS[:sidequest023] = {
    :text => ["1 Wave"] }   
    
  #Floor 1-2 Mute Soldier
  DETAILS[:sidequest024] = {
    :name => "Oath of Silence"}
  DESCRIPTIONS[:sidequest024] = {
    :qgiver_name => "Silent Soldier",
    :location => "Tolbana to Urbus Path",
    :desc => "In the outpost on the road from Tolbana to Urbus, I found a soldier who seems incapable of speech for some reason. Perhaps if I helped him, my reputation with Yudah's military would improve." }
  OBJECTIVES[:sidequest024] = {
    :obj1 => ["Ask the other soldier for details.", 1],
    :obj2 => ["Ask around in a Yudah Barracks", 1, true],
    :obj3 => ["Ask about Irvin at the Urbus Inn", 1, true],
    :obj4 => ["Find Irvin's on the road to Urbus", 1, true],
    :obj5 => ["Return to Reuel", 1, true],}
  REWARDS[:sidequest024] = {
    :text => ["1 Wave"]  }   
    
  #Floor 1-2 Mute Soldier
  DETAILS[:sidequest025] = {
    :name => "Signet Ring"}
  DESCRIPTIONS[:sidequest025] = {
    :qgiver_name => "Kobold's Lavatory Patron",
    :location => "ToB East Sewers",
    :desc => "A wealthy figure in Kobold's Lavatory sent an adventurer named Howard on a quest to find a signet ring, in an easter section of the Town of Beginnings' sewers. I am to find him and report back." }
  OBJECTIVES[:sidequest025] = {
    :obj1 => ["Find Howard or the Signet Ring.", 1],
    :obj2 => ["Return to Kobold's Lavatory", 1, true]}
  REWARDS[:sidequest025] = {
    :text => ["200 Col", "35% Wave"] } 
    
 #Floor 2 Testosterone Drug
  DETAILS[:sidequest026] = {
    :name => "Testosterone in a Bottle"}
  DESCRIPTIONS[:sidequest026] = {
    :qgiver_name => "Lucy",
    :location => "Imperia Academia",
    :desc => "Three lasses in Imperia Academia requested ingredients from me to create a new kind of strength potion. I will need: A regular strength potion, hornet honey and Minotaur Horn Dust." }
  OBJECTIVES[:sidequest026] = {
    :obj1 => ["Deliver the items to Lucy", 1]}
  REWARDS[:sidequest026] = {
    :text => ["30% Wave" ]} 
    
  #Floor 3 Corpses Missing
  DETAILS[:sidequest027] = {
    :name => "No Eternal Rest in Yudah"}
  DESCRIPTIONS[:sidequest027] = {
    :qgiver_name => "Widow",
    :location => "Dragontooth",
    :desc => "A man in Dragontooth sold his corpse to Yudah's Healers' Union. His grieving wife wants it back, but the Union refuses to resell it. Can bureaucracy really be so cruel, or are there sinister purposes here?" }
  OBJECTIVES[:sidequest027] = {
    :obj1 => ["Speak with the Corpse Buyer", 1],
    :obj2 => ["Speak with Dragontooth's Gravekeeper", 1],
    :obj3 => ["Ask denizens of Yudah's underworld.", 1],
    :obj4 => ["Return to the widow in Dragontooth", 1, true]}
  REWARDS[:sidequest027] = {
    :text => ["2 Waves", "30% Wave"]} 
    
  #Floor 3 Hana Outfit
  DETAILS[:sidequest028] = {
    :name => "Lady Wendigo"}
  DESCRIPTIONS[:sidequest028] = {
    :qgiver_name => "Raggs",
    :location => "Raggs'es Camp",
    :desc => "The vile kobold boneworker, who you met in Illfang's mines, has promised to make a new outfit for Hana, for free. He just needs the materials to do it." }
  OBJECTIVES[:sidequest028] = {
    :obj1 => ["Kill the 'demon bat'", 1],
    :obj2 => ["Find the mistweaver diagrams", 1]}
  REWARDS[:sidequest028] = {
    :text => ["Hana new Outfit", "35% Wave"]} 
    
  #Floor 4 Troll Toll
  DETAILS[:sidequest029] = {
    :name => "Troll Toll"}
  DESCRIPTIONS[:sidequest029] = {
    :qgiver_name => "Rhetor",
    :location => "Beach Southwest of Kronos",
    :desc => "The magus owning the beach worries about the future of his schemes due to the presence of the troll. He wants it cease its tolls on the passangers, and will pay handsomely for it." }
  OBJECTIVES[:sidequest029] = {
    :obj1 => ["Rid the beach of the troll", 1]}
  REWARDS[:sidequest029] = {
    :text => ["free passage in Hioni west beach", "2000 Col", "45% Wave" ]} 
    
  #Azar Babysitter
  DETAILS[:sidequest030] = {
    :name => "Babysitter"}
  DESCRIPTIONS[:sidequest030] = {
    :qgiver_name => "Azar",
    :location => "Imperia Academia",
    :desc => "There is no scenario in which Azar can take care of herself, especially now that her diapers need daily washing. You need to find a babysitter for your little blonde. Someone who lives near her." }
  OBJECTIVES[:sidequest030] = {
    :obj1 => ["Find a babysitter for Azar", 1]}
  REWARDS[:sidequest030] = {
    :text => ["15% Wave"] } 
    
  #Advertisment quest
  DETAILS[:sidequest031] = {
    :name => "Invasive Consumerism"}
  DESCRIPTIONS[:sidequest031] = {
    :qgiver_name => "Eliot Brandson",
    :location => "Weissberg",
    :desc => "Eliot Brandson in northeastern Weissberg has asked you to help advertise his logistics business." }
  OBJECTIVES[:sidequest031] = {
    :obj1 => ["Hire a kid as a crier.", 1],
    :obj2 => ["Return to Brandson.", 1, true],
    :obj3 => ["Hang the posters around Weissberg.", 4, true],
    :obj4 => ["Return to Brandson.", 1, true],
    :obj5 => ["Deliver the personalized ads.", 3, true],
    :obj6 => ["Return to Brandson.", 1, true]}
  REWARDS[:sidequest031] = {
    :text => ["250 Col", "70% Wave" ]} 
    
  #Recorder Quest
  DETAILS[:sidequest032] = {
    :name => "Quiet Days"}
  DESCRIPTIONS[:sidequest032] = {
    :qgiver_name => "Village Grandma",
    :location => "Woodsedge",
    :desc => "An elderly woman in the happy community of Woodsedge told a tail of an old horror by the Others, repurposed to serve as a keeper of history by a magus, more than thirty years ago." }
  OBJECTIVES[:sidequest032] = {
    :obj1 => ["Investigate the forest near Woodsedge.", 1],
    :obj2 => ["Investigate the underground of Woodsedge.", 1, true]}
  REWARDS[:sidequest032] = {
    :text => ["50% Wave"] } 
    
  #Axe Delivery Docks
  DETAILS[:sidequest033] = {
    :name => "Axeleration"}
  DESCRIPTIONS[:sidequest033] = {
    :qgiver_name => "Docks Worker",
    :location => "Woodsedge",
    :desc => "An old man at the docks gave me an axe, to be delivered to a lumberjack at Woodsedge, directly west of the docks, on the road to the Town of Beginnings." }
  OBJECTIVES[:sidequest033] = {
    :obj1 => ["Give Handaxe to Dragontooth lumberjack.", 1]}
  REWARDS[:sidequest033] = {
    :text => ["5% Wave"]} 
    
  #Floor 2 Letter Delivery
  DETAILS[:sidequest034] = {
    :name => "Urbus Valley Courier"}
  DESCRIPTIONS[:sidequest034] = {
    :qgiver_name => "Robin",
    :location => "Ash Inn, Urbus",
    :desc => "The sick courier in Urbus' Ash Inn has asked me to deliver mail around the Urbus Valley for him, and then return for my reward. Maybe I can be a bit naughty with the job too..." }
  OBJECTIVES[:sidequest034] = {
    :obj1 => ["Deliver mail around Urbus valley.", 5]}
  REWARDS[:sidequest034] = {
    :text => ["100 Col", "35% Wave"]} 

  #Floor 4 Weissberg Skeletons
  DETAILS[:sidequest035] = {
    :name => "Spooky Scary Skeletons"}
  DESCRIPTIONS[:sidequest035] = {
    :qgiver_name => "yourself",
    :location => "Weissberg, Hioni",
    :desc => "The town of Weissberg in Hioni has been taken over by animated skeletons, who patrol the streets. Someone should put them back to the ground, and deal with their leader, Frederich the necromancer." }
  OBJECTIVES[:sidequest035] = {
    :obj1 => ["Liberate Weissberg", 1]}
  REWARDS[:sidequest035] = {
    :text => [ "1 Wave", "50% Wave"]} 
    
 #Party Noblelady Flowers
  DETAILS[:sidequest036] = {
    :name => "Fashion Statement"}
  DESCRIPTIONS[:sidequest036] = {
    :qgiver_name => "Noblelady-Stripper",
    :location => "Celebratory Party",
    :desc => "One of the noble ladies in king Rune's celebratory feast wants me to get a flower that will fit her hairstyle and color. Surely noone will notice if a few of the cosmetic plants lose a flowerhead or two." }
  OBJECTIVES[:sidequest036] = {
    :obj1 => ["Find a fitting flower in the party.", 1]}
  REWARDS[:sidequest036] = {
    :text => ["2% Wave"],
    :gold => 60,} 
    
  #Party Asari Girl Romance
  DETAILS[:sidequest037] = {
    :name => "Pick-Up Poetry"}
  DESCRIPTIONS[:sidequest037] = {
    :qgiver_name => "Nobleman at balcony",
    :location => "Celebratory Party",
    :desc => "A nobleman with self-esteem issues has tasked me with crafting a poem for him, to charm the newfound love of his life. Unfortunately, with your writing skills you couldn't woo a female ape, let alone a noblelady." }
  OBJECTIVES[:sidequest037] = {
    :obj1 => ["Synthesize a poetic masterpiece", 1],
    :obj2 => ["Get the clerk a tart", 1, true],
    :obj3 => ["Return to the nobleman", 1, true]}
  REWARDS[:sidequest037] = {
    :text => ["11% Wave"] } 
    
  #Ruins Kobold Slaying
  DETAILS[:sidequest038] = {
    :name => "Kobold Slaying"}
  DESCRIPTIONS[:sidequest038] = {
    :qgiver_name => "Yudah",
    :location => "Ruins East of Tolbana",
    :desc => "Kobolds are rumored to be ambushing adventurers in the ruins east of Tolbana. Their concentration in the area is strange, given that there is nothing worth looting there." }
  OBJECTIVES[:sidequest038] = {
    :obj1 => ["Engage 5 kobolds in the Ruins", 5]}
  REWARDS[:sidequest038] = {
    :text => ["35% Wave" ]} 
    
  #South Valley Minotaur Slaying
  DETAILS[:sidequest039] = {
    :name => "Minotaur Slaying"}
  DESCRIPTIONS[:sidequest039] = {
    :qgiver_name => "Yudah",
    :location => "Ruins East of Tolbana",
    :desc => "Minotaur raiders have invaded the mountains of Urbus, killing men and capturing women. Better thin out their numbers, especially near Imperia Academia." }
  OBJECTIVES[:sidequest039] = {
    :obj1 => ["Kill 6 minotaurs in the southern Urbus Valley and its caves.", 5]}
  REWARDS[:sidequest039] = {
    :text => ["40% Wave"] } 
    
end
 
class Game_Quests
  attr_accessor :reset_hash
  def initialize
    @quests = {}
    QUEST::DETAILS.each do |id, quest|
      @quests[id] = Quest.new(id,quest)
    end
    @reset_hash = {}
    @quests.each_value do |quest|
      @reset_hash[quest.id] = {}
      @reset_hash[quest.id][:accepted] = true
      @reset_hash[quest.id][:turnedin] = true
      quest.objectives.each do |id, obj|
        @reset_hash[quest.id][id] = obj
      end
    end
  end
  def check_quests
    @quests.each do |id, quest|
      if !$game_party.quests[id]
        $game_party.quests[id] = {}
        quest.reset
      end
    end
  end
  def [](quest_id)
    return msgbox("No Quest with id " + quest_id.to_s) if @quests[quest_id].nil?
    @quests[quest_id]
  end
  def []=(quest_id, val)
    @quests[quest_id] = val
  end
  def quests
    @quests
  end
  def no_quests?
    @quests.each do |id, quest|
      return false if quest.accepted? && !quest.turned_in
    end
    return true
  end
  def tracking?
    $game_party.tracking
  end
  def track_quest(id)
    return if $game_party.tracking.include?(id)
    $game_party.tracking.push(id)
    if $game_party.tracking.size > $questlogmaxdisplay = 5
      $game_party.tracking.reverse!.pop
      $game_party.tracking.reverse!
    end
  end
  def untrack_quest(id)
    return unless $game_party.tracking.include?(id)
    $game_party.tracking.delete(id)
    $game_party.tracking.compact!
  end
end
 
class Quest
  attr_accessor :name
  attr_accessor :level
  attr_accessor :id
  attr_accessor :desc
  attr_accessor :objectives
  attr_accessor :turned_in
  attr_accessor :difficulty
  attr_accessor :qgiver_name
  attr_accessor :location
  attr_accessor :auto_complete
  attr_accessor :abandonable
  attr_accessor :force_accept
  attr_accessor :force_turnin
  def initialize(id,quest_hash)
    @id = id
    @level = 0
    @difficulty = 0
    @name = "No Quest Name"
    @desc = ""
    @qgiver_name = 0
    @location = 0
    @auto_complete = false
    @abandonable = true
    @need_popup = false
    @force_turnin = false
    @force_accept = false
    @name = quest_hash[:name] if quest_hash[:name]
    @level = quest_hash[:level] if quest_hash[:level]
    @force_accept = quest_hash[:force_accept] if quest_hash[:force_accept]
    @force_turnin = quest_hash[:force_turnin] if quest_hash[:force_turnin]
    @difficulty = quest_hash[:difficulty] if quest_hash[:difficulty]
    @auto_complete = quest_hash[:auto_complete] if quest_hash[:auto_complete]
    @abandonable = quest_hash[:abandonable] if !quest_hash[:abandonable].nil?
    @desc = QUEST::DESCRIPTIONS[id][:desc] if QUEST::DESCRIPTIONS[id][:desc]
    @qgiver_name = QUEST::DESCRIPTIONS[id][:qgiver_name] if QUEST::DESCRIPTIONS[id][:qgiver_name]
    @location = QUEST::DESCRIPTIONS[id][:location] if QUEST::DESCRIPTIONS[id][:location]
    @objectives = {}
    if QUEST::OBJECTIVES[id]
      QUEST::OBJECTIVES[id].each do |id, obj|
        @objectives[id] = Objective.new(id, obj)
      end
    else
      msgbox("Quest " + id.to_s + " has no objectives.")
    end
    @reward_gold = 0
    @reward_exp = 0
    @scale_exp = 0
    @reward_items = []
    @reward_text = []
    begin
      if QUEST::REWARDS[id][:gold]
        @reward_gold = QUEST::REWARDS[id][:gold]
      end
      if QUEST::REWARDS[id][:exp]
        @reward_exp = QUEST::REWARDS[id][:exp]
        @scale_exp = QUEST::REWARDS[id][:scale_exp] if QUEST::REWARDS[id][:scale_exp]
      end
      if QUEST::REWARDS[id][:items]
        @reward_items = QUEST::REWARDS[id][:items]
      end
      if QUEST::REWARDS[id][:text]
        @reward_text = QUEST::REWARDS[id][:text]
      end
    rescue
      msgbox(id.to_s + " has no defined REWARDS. This is not optional.")
    end
  end
  def reward_text
    @reward_text
  end
  def accept
    reset
    $game_party.quests[id][:accepted] = true
    track_quest
    $game_map.need_refresh = true
    Audio.se_play("Audio/SE/Book2")
  end
  def abandon
    reset
    $game_party.quests[id][:accepted] = false
  end
  def fail
    Audio.me_play("Audio/SE/Pen")
    abandon
  end
  def accepted?
    $game_party.quests[id][:accepted]
  end
  def accepted
    accepted?
  end
  def completed?
    @objectives.each do |id, obj|
      return false if !$game_party.quests[@id][id].completed?
    end
    return true
  end
  def force_done
    $game_party.quests[id][:accepted] = true
    @objectives.each do |id, obj|
      $game_party.quests[@id][id].current = obj.max
    end
    turnin
  end
  def reset
    $game_party.quests[id][:accepted] = false
    @objectives.each do |id, obj|
      $game_party.quests[@id][id] = obj
      $game_party.quests[@id][id].current = 0
    end
    $game_party.quests[id][:turnedin] = false
  end
  def objective(id)
    return Objective.new(id, ["No Objective Found",0]) if @objectives[id].nil?
    $game_party.quests[@id][id]
  end
  def set_obj(id, value)
    objective(id).current = value
    @need_popup = false if !completed?
    popup if completed? && !@need_popup
    turnin if completed? && @auto_complete
    $game_map.need_refresh = true
  end
  def adv_obj(id, value)
    objective(id).current += value
    @need_popup = false if !completed?
    popup if completed? && !@need_popup
    turnin if completed? && @auto_complete
    $game_map.need_refresh = true
  end
  def reward_gold
    @reward_gold
  end
  def reward_exp
    get_mod_exp.to_i
  end
  def reward_items
    @reward_items
  end
  def turnin
    $game_party.quests[id][:turnedin] = true
    untrack_quest
    $game_map.need_refresh = true
    $game_party.gain_gold(@reward_gold)
    $game_party.members.each do |actor|
      actor.gain_exp(@reward_exp)
    end
    @reward_items.each do |array|
      item = $data_items[array[1]] if array[0] == :item
      item = $data_weapons[array[1]] if array[0] == :weapon
      item = $data_armors[array[1]] if array[0] == :armor
      $game_party.gain_item(item, array[2])
    end
  end
  def track_quest
    $game_quests.track_quest(@id)
  end
  def untrack_quest
    $game_quests.untrack_quest(@id)
  end
  def can_abandon?
    @abandonable
  end
  def popup
    @need_popup = true
    Audio.me_play("Audio/SE/Magic1")
    if Module.const_defined?(:Popup)
      Popup.add([@name + ' complete!'])
    end
  end
  def turned_in?
    $game_party.quests[id][:turnedin]
  end
  def turned_in
    turned_in?
  end
  def active?
    accepted? && !completed?
  end
  def get_mod_exp
    pval = @scale_exp * (@level - $game_party.highest_level).to_f / 100 + 1
    @reward_exp * pval
  end
end
 
class Objective
  attr_accessor :id
  attr_accessor :name
  attr_accessor :current
  attr_accessor :max
  attr_accessor :hidden
  def initialize(id, obj)
    @name = obj[0]
    @current = 0
    @max = obj[1]
    @hidden = obj[2] ? obj[2] : false
  end
  def completed?
    @current >= @max
  end
end
 
module DataManager
  class << self
    alias quest_cgo load_database
    alias quest_sng setup_new_game
  end
  def self.load_database
    quest_cgo
    $game_quests = Game_Quests.new
  end
  def self.setup_new_game
    $game_quests = Game_Quests.new
    quest_sng
  end
end
 
class Scene_Quest < Scene_MenuBase
  def start
    super
    @help_window = Window_Help.new(1)
    @help_window.set_text("Quest Log")
    @list_window = Window_SceneList.new
    @list_window.set_handler(:cancel, method(:list_cancel))
    #@list_window.set_handler(:ok, method(:list_ok))
    @list_window.refresh
    @list_window.activate
    @list_window.select(0)
    @detail_window = Window_SceneDetail.new
    @command_window = Window_QuestTrack.new
    @command_window.x = Graphics.width / 2 - @command_window.width / 2
    @command_window.y = Graphics.height / 2 - @command_window.height / 2
    @command_window.set_handler(:track, method(:track))
    @command_window.set_handler(:untrack, method(:untrack))
    @command_window.set_handler(:abandon, method(:abandon))
    @command_window.set_handler(:cancel, method(:command_cancel))
  end
  def update
    super
    @detail_window.quest = @list_window.current_item
  end
  def list_cancel
    SceneManager.return
  end
  def list_ok
    @command_window.quest(@list_window.current_item)
    @command_window.refresh
    @command_window.select(0)
    @command_window.activate
    @command_window.open
  end
  def track
    $game_quests.track_quest(@list_window.current_item.id)
    command_cancel
  end
  def untrack
    $game_quests.untrack_quest(@list_window.current_item.id)
    command_cancel
  end
  def abandon
    @list_window.current_item.abandon
    command_cancel
  end
  def command_cancel
    @command_window.close
    @list_window.refresh
    @list_window.activate
    list_cancel if $game_quests.no_quests?
  end
end
 
class Window_SceneList < Window_Selectable
  def initialize
    super(0,48,Graphics.width/5*2,Graphics.height-48)
    refresh
  end
  def make_item_list
    @data = []
    $game_quests.quests.each do |id, quest|
      @data.push(quest) if quest.accepted? && !quest.turned_in?
    end
    @data.push(nil) if @data.empty?
  end
  def draw_item(index)
    contents.font.size = 18
    item = @data[index]
    if item
      rect = item_rect(index)
      rect.width -= 4
      if $game_quests.tracking?.include?(item.id)
        text = "*" + item.name
      else
        text = item.name
      end
      draw_text(rect, text)
      draw_text(rect, "Lv" + item.level.to_s,2) if item.level > 0
    end
  end
  def col_max; 1; end
  def current_item
    @data[@index]
  end
  def current_item_enabled?
    true
  end
  def refresh
    make_item_list
    create_contents
    draw_all_items
  end
  def item_max
    @data ? @data.size : 0
  end
end
 
class Window_SceneDetail < Window_Base
  def initialize
    super(Graphics.width/5*2,48,Graphics.width-Graphics.width/5*2,Graphics.height-48)
  end
  def quest=(quest)
    return if @quest == quest
    @quest = quest
    refresh
  end
  def draw_text_ex(x, y, text)
    reset_font_settings
    @new_y = 0
    text = convert_escape_characters(text)
    pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
    process_character(text.slice!(0, 1), text, pos) until text.empty?
  end
  def process_new_line(text, pos)
    pos[:x] = pos[:new_x]
    pos[:y] += pos[:height]
    @new_y += 1
    pos[:height] = calc_line_height(text)
  end
  def refresh
    contents.clear
    return unless @quest
    contents.font.size = 18
    change_color(system_color)
    draw_text(0,0,contents.width,line_height,@quest.qgiver_name) if @quest.qgiver_name != 0
    draw_text(0,0,contents.width,line_height,@quest.location,2) if @quest.location != 0
    change_color(normal_color)
    @quest.qgiver_name != 0 || @quest.location != 0 ? yy = line_height : yy = 0
    draw_text_ex(0,yy,@quest.desc)
    yy += (@new_y + 1) * line_height
    change_color(system_color)
    draw_text(0,yy,contents.width,24,"Objectives:")
    change_color(normal_color)
    yy += line_height
    @quest.objectives.each do |id, obj|
      next if obj.hidden
      draw_objective(yy, obj)
      yy += line_height
    end
    change_color(system_color)
    draw_text(0,yy,contents.width,line_height,"Rewards:")
    yy += line_height
    if @quest.reward_exp > 0
      draw_text(6,yy,contents.width/2,line_height,"XP: ")
      change_color(normal_color)
      draw_text(36,yy,contents.width/2,line_height,@quest.reward_exp)
      yy += line_height
    end
    if @quest.reward_gold > 0
      change_color(normal_color)
      draw_text(6,yy,contents.width/2,line_height,@quest.reward_gold.to_s)
      cx = text_size(@quest.reward_gold).width
      change_color(system_color)
      draw_text(6+cx,yy,contents.width/2,line_height,Vocab::currency_unit)
      yy += line_height
    end
    change_color(normal_color)
    @quest.reward_items.each do |array|
      item = $data_items[array[1]] if array[0] == :item
      item = $data_weapons[array[1]] if array[0] == :weapon
      item = $data_armors[array[1]] if array[0] == :armor
      draw_item_name(item, 6, yy, true, contents.width)
      if array[2] > 1
        draw_text(6+text_size(item.name).width+36,yy,48,24,"x"+array[2].to_s)
      end
      yy += line_height
    end
    if @quest.reward_text != []
      change_color(normal_color)
      @quest.reward_text.each do |txt|
        draw_text(0,yy,contents.width,line_height,txt.to_s)
        yy += line_height
      end
    end
    if @quest.difficulty != 0
      text = "Difficulty: " + @quest.difficulty
      draw_text(0,contents.height-line_height,contents.width,line_height,text,2)
    end
  end
  def draw_objective(yy, obj)
    draw_text(6,yy,contents.width,24,obj.name)
    draw_text(0,yy,contents.width,24,obj.current.to_s+"/"+obj.max.to_s,2)
  end
  def reset_font_settings
    change_color(normal_color)
    contents.font.bold = Font.default_bold
    contents.font.italic = Font.default_italic
  end
end
 
class Window_QuestTrack < Window_Command
  def initialize
    super(0,0)
    self.openness = 0
  end
  def quest(quest)
    @quest = quest
  end
  def make_command_list
    return unless @quest
    if !$game_quests.tracking?.include?(@quest.id)
      #add_command("Track Quest", :track)
    else
      #add_command("Untrack Quest", :untrack)
    end
    #add_command("Abandon Quest", :abandon, @quest.can_abandon?)
  end
  def window_height
    fitting_height(2)
  end
end
 
class Window_MenuCommand
  alias quest_aoc add_original_commands
  def add_original_commands
    quest_aoc
    add_command("Quest Log", :quest, !$game_quests.no_quests?)
  end
end
 
class Scene_Menu
  alias quest_ccw create_command_window
  def create_command_window
    quest_ccw
    @command_window.set_handler(:quest,    method(:scene_quest))
  end
  def scene_quest
    SceneManager.call(Scene_Quest)
  end
end
 
class Scene_Map
  alias quest_start start
  alias quest_update update
  def start
    quest_start
    @quest_log = Window_QuestLog.new
    @quest_confirm = Window_QuestConfirm.new
    @quest_confirm.set_handler(:accept, method(:confirm_accept))
    @quest_confirm.set_handler(:decline, method(:confirm_cancel))
    @quest_confirm.set_handler(:cancel, method(:confirm_cancel))
    @quest_turnin = Window_QuestTurnin.new
    @quest_turnin.set_handler(:accept, method(:turnin_accept))
    @quest_turnin.set_handler(:decline, method(:confirm_cancel))
    @quest_turnin.set_handler(:cancel, method(:confirm_cancel))
    @quest_apply = Window_QuestApply.new(@quest_confirm,@quest_turnin)
  end
  def update(*args)
    @quest_log = Window_QuestLog.new if @quest_log.disposed?
    quest_update(*args)
  end
  def show_quest(id, turnin = false)
    @quest_apply.show($game_quests[id],turnin)
  end
  def accepting?
    @quest_confirm.active || @quest_turnin.active
  end
  def confirm_accept
    @quest_apply.accept
    @quest_apply.hide
  end
  def confirm_cancel
    @quest_apply.hide
  end
  def turnin_accept
    @quest_apply.turnin
    @quest_apply.hide
  end
  def update_call_menu
    if $game_system.menu_disabled || $game_map.interpreter.running? || accepting?
      @menu_calling = false
    else
      @menu_calling ||= Input.trigger?(:B)
      call_menu if @menu_calling && !$game_player.moving?
    end
  end
end
 
class Scene_Base
  def accepting?
    false
  end
end
 
class Window_QuestLog < Window_Base
  def initialize
    super(Graphics.width/5*3,0,Graphics.width/5*2,Graphics.height)
    self.x = 0 if QUEST_LOG_POSITION == 1
    self.x += QUEST_LOG_OFFSET_X
    self.y += QUEST_LOG_OFFSET_Y
    self.opacity = 0
    self.contents.font.size = 18
  end
  def update
    super
    return unless Graphics.frame_count % 20 == 0
    self.visible = $questlogvisibility
    return unless self.visible
    self.visible = !$game_quests.no_quests?
    self.visible = $game_quests.tracking?.size > 0
    return unless self.visible
    contents.clear
    change_color(crisis_color)
    draw_text(0,0,contents.width,18,"Quest Log:",1)
    yy = 18;iter = 0
    $game_quests.tracking?.each do |id|
      quest = $game_quests[id]
      next unless quest.accepted? && !quest.turned_in
      change_color(system_color)
      draw_text(6,yy,contents.width-6,18,quest.name)
      change_color(normal_color)
      yy += 18
      quest.objectives.each do |obj_id, obj|
        next if obj.hidden
        draw_objective(yy, $game_party.quests[id][obj_id])
        yy += 18
      end
      iter += 1
    end
  end
  def draw_objective(yy, obj)
    draw_text(0,yy,contents.width-24,18,obj.name)
    draw_text(0,yy,contents.width,18,obj.current.to_s+"/"+obj.max.to_s,2)
  end
end
   
class Window_QuestApply < Window_Base
  def initialize(confirm_window, turnin_window)
    super(Graphics.width/8,Graphics.width/8,Graphics.width/5*3,Graphics.height-Graphics.width/8*2)
    self.openness = 0
    @confirm_window = confirm_window
    @turnin_window = turnin_window
    self.contents.font.size = 18
  end
  def refresh
    return unless @quest
    contents.clear
    change_color(system_color)
    yy = 0
    if @quest.qgiver_name != 0
      draw_text(0,0,contents.width/2,line_height,@quest.qgiver_name)
      yy = line_height
    end
    if @quest.location != 0
      draw_text(contents.width/2,0,contents.width/2,line_height,@quest.location,2)
      yy = line_height
    end
    change_color(crisis_color)
    draw_text(0,yy,contents.width,line_height,"Lvl: " + @quest.level.to_s) if @quest.level > 0
    draw_text(0,yy,contents.width,line_height,@quest.name,1)
    draw_text(0,yy,contents.width,line_height,@quest.difficulty,2) if @quest.difficulty != 0
    change_color(normal_color)
    draw_text_ex(0,line_height+yy,@quest.desc)
    change_color(system_color)
    draw_text(0,line_height*8,contents.width,line_height,"Objectives:")
    change_color(normal_color)
    yy = line_height * 9
    @quest.objectives.each do |obj_id, obj|
      next if obj.hidden
      draw_objective(yy, $game_party.quests[@quest.id][obj_id])
      yy += line_height
    end
    change_color(system_color)
    draw_text(0,yy,contents.width,line_height,"Rewards:")
    yy += line_height
    if @quest.reward_exp > 0
      draw_text(6,yy,contents.width/2,line_height,"XP: ")
      change_color(normal_color)
      draw_text(36,yy,contents.width/2,line_height,@quest.reward_exp)
      yy += line_height
    end
    if @quest.reward_gold > 0
      change_color(normal_color)
      draw_text(6,yy,contents.width/2,line_height,@quest.reward_gold.to_s)
      cx = text_size(@quest.reward_gold).width
      change_color(system_color)
      draw_text(6+cx,yy,contents.width/2,line_height,Vocab::currency_unit)
    end
    yy += line_height
    change_color(normal_color)
    @quest.reward_items.each do |array|
      item = $data_items[array[1]] if array[0] == :item
      item = $data_weapons[array[1]] if array[0] == :weapon
      item = $data_armors[array[1]] if array[0] == :armor
      draw_item_name(item, 6, yy, true, contents.width)
      if array[2] > 1
        draw_text(6+text_size(item.name).width+36,yy,48,24,"x"+array[2].to_s)
      end
      yy += line_height
    end
  end
  def reset_font_settings
    change_color(normal_color)
    contents.font.bold = Font.default_bold
    contents.font.italic = Font.default_italic
  end
  def line_height
    18
  end
  def draw_objective(yy, obj)
    draw_text(6,yy,contents.width,24,obj.name)
    draw_text(0,yy,contents.width,24,obj.current.to_s+"/"+obj.max.to_s,2)
  end
  def show(quest,turnin)
    @quest = quest
    return if @quest.turned_in
    refresh
    open
    @confirm_window.quest(@quest)
    @confirm_window.open if !turnin
    if turnin
      @turnin_window.quest(@quest)
      @turnin_window.open
    end
  end
  def hide
    close
    @confirm_window.close
    @turnin_window.close
  end
  def accept
    @quest.accept
  end
  def turnin
    @quest.turnin
  end
end
 
class Window_QuestConfirm < Window_HorzCommand
  def initialize
    super(Graphics.width/8,Graphics.width/8+Graphics.height-Graphics.width/8*2)
    self.openness = 0
    self.active = false
    @enabled = true
    refresh
  end
  def window_width
    Graphics.width/5*2
  end
  def window_height
    48
  end
  def make_command_list
    add_command("Accept",:accept)
    add_command("Decline",:decline, @enabled)
  end
  def item_width
    width / 2 - padding * 2
  end
  def open
    super
    activate
    select(0)
  end
  def quest(quest)
    @quest = quest
    @enabled = [email protected]_accept
    refresh
  end
  def cancel_enabled?
    super && @enabled
  end
end
 
class Window_QuestTurnin < Window_QuestConfirm
  def quest(quest)
    @quest = quest
    @enabled = true
    @enabled = [email protected]? if @quest.force_turnin
    refresh
  end
  def make_command_list
    return unless @quest
    add_command("Complete",:accept,@quest.completed? && [email protected]_in)
    add_command("Cancel",:decline, @enabled)
  end
end
 
class Game_Party
  attr_accessor :quests
  attr_accessor :tracking
  alias quests_init initialize
  def initialize(*args)
    quests_init(*args)
    @quests = $game_quests.reset_hash unless $game_quests.nil?
    @tracking = []
  end
end
 
class Game_Player
  alias quest_update update
  def update
    return if SceneManager.scene.accepting?
    quest_update
  end
end
 
class Game_Event
  def obj(quest, objective)
    $game_quests[quest].objective(objective).current
  end
end
 
class Game_Interpreter
  def accept_quest(quest)
    $game_quests[quest].accept
  end
  def ask_accept(quest)
    return unless SceneManager.scene.is_a?(Scene_Map)
    SceneManager.scene.show_quest(quest)
    Fiber.yield while SceneManager.scene.accepting?
  end
  def abandon_quest(quest)
    $game_quests[quest].abandon
  end
  def fail_quest(quest)
    $game_quests[quest].fail
  end
  def turnin_quest(quest)
    $game_quests[quest].turnin
  end
  def ask_turnin(quest)
    return unless SceneManager.scene.is_a?(Scene_Map)
    SceneManager.scene.show_quest(quest,true)
    Fiber.yield while SceneManager.scene.accepting?
  end
  def adv_obj(quest, objective, value)
    $game_quests[quest].adv_obj(objective, value)
  end
  def set_obj(quest, objective, value)
    $game_quests[quest].set_obj(objective, value)
  end
  def obj(quest, objective)
    $game_quests[quest].objective(objective).current
  end
  def hide_obj(quest, objective)
    $game_quests[quest].objective(objective).hidden = true
  end
  def show_obj(quest, objective)
    $game_quests[quest].objective(objective).hidden = false
  end
end

module DataManager
  class << self
    alias quest_load_game load_game
  end
  def self.load_game(index)
    quest_load_game(index)
    $game_quests.check_quests
  end
end
Ok, the displaying part of the rewards now works, thanks. Any idea what to do about the display heights?
Any idea what to do about the display heights?
fixed. code above updated
by the way, thanks for helping to improve the script
fixed. code above updated
by the way, thanks for helping to improve the script
I'm the one that should be thanking you. Thanks to you the game has been in a proper running state instead of being a buggy mess. (I mean, it's still a buggy mess, but the other bugs I can fix).
hi, I got some bugs when I executed the script, can anyone help me to take a look?😅
1690995301997.png
hi, I got some bugs when I executed the script, can anyone help me to take a look?😅
Did you start from a new game or a saved one?
Did you start from a new game or a saved one?
The saved one, I tried to start a new game and it worked! Thanks a lot!!!!
For the abandonable quest, if I abandon the quest, it has still remained at an incomplete stage and I cannot retake it. In other words, it cannot be initialized. Can anyone help me?
Does anyone have a demo project for this script? So I could see how quests work. Thanks!

Original thread: https://forums.rpgmakerweb.com/threads/basic-quest-system.27446/