Jaber's Quest Log v2.1.3

This time I chose to use a book-like format, because it fits better with my new menu-in-the-works than the scroll thing does. The code's a lot cleaner, the quests are easier to manage and organize, and you have -complete- control over the placement of everything in the description.


Features
- Organize your quests into categories!
- Faster loading!
- Less save-bloating!
- Easier quest data organization!
- Multi-page descriptions!
- Quest-specific variables!
- Ability to change font size, color, and name!
- Ability to use icons and pictures in descriptions!
- Greater control over objectives!
- Message codes for displaying various data in your description!
- HOLY CRAP MORE CUSTOMIZATION THAN YOU'LL EVER NEED FOR ANYTHING EVER
- Probably some other stuff that I forgot!
- wakka wakka wakka
- I am a SALAD BOAT
- VROOM VROOOM
- pinecone

Changelog
v.2.1.3
Woops.
Bugfixes:
-Fixed a bug causing the quest display to refresh itself more than neccessary.
-Fixed a bug where the category title would be drawn based on all categories in the list instead of based on only active categories.
-Fixed several other bugs caused by the above problem.

v.2.1.2
Bugfixes:
-Fixed a bug where the draw text instruction types would default to the window's default font/size/color instead of the category list's default font/size/color

New stuff:
-Added support for spaces in quest variable names and in the \\s message code
-Confirm button now closes quest window when called directly to a quest (So books and stuff will behave more like a message box)
-Updated demo


Scripts
Quest Data Spoiler
  1. class Game_System
  2.  
  3.   def load_quest_data
  4.     $data_quests = {}
  5.     #$data_quests["hash key"] = Quest_Data.new(
  6.     # "name", [description code], [objective code], {initial quest variables(optional)})
  7.     $data_quests["fishtalk"] = Quest_Data.new("Talk with Fish",
  8.     [[0, [0, [4, 4], "Cat wants me to ask Fish if"]], [0, [0, [4, 24], "it's ok to eat him."]]],
  9.     [[0, 1, [0, [4, 44], ["I need to get Fish's response.", "Fish said no."]]]])
  10.     $data_quests["cat quest 2"] = Quest_Data.new("Cat's Query",
  11.     [[0, [0, [4, 4], "Cat wants to know how Fish is"]], [0, [0, [4, 24], "breathing outside of water."]],
  12.     [0, [0, [4, 60], "Being a cat, Cat is too damn lazy"]], [0, [0, [4, 80], "to ask Fish himself."]]],
  13.     [])
  14.     $data_quests["cat quest done"] = Quest_Data.new("Lazy Cat",
  15.     [[0, [0, [4, 4], "Cat can ask his own stupid"]], [0, [0, [4, 24], "questions from now on."]]],
  16.     [])
  17.     $data_quests["trees"] = Quest_Data.new("Oh, nuts",
  18.     [[0, [0, [4, 4], "This tree wants me to find"]], [0, [0, [4, 24], "its missing acorns."]],
  19.     [2, [0, [290, 4], [1, 1]]], [0, [0, [310, 260], "A nice enough sort.", nil, 15]],
  20.     [0, [0, [4, 100], "I have found \\qv[nuts found]/5 acorns."]]],
  21.     [[0, 0, [0, [4, 120], ["I should return these to that tree."]]]], {"nuts found" => 0})
  22.     $data_quests["trees done"] = Quest_Data.new("Oh, nuts",
  23.     [[1, [0, [-80, 4], [1, "hat2"]]], [0, [0, [4, 232], "That tree gave me its"]],
  24.     [0, [0, [4, 252], "old 'brocap'."]], [0, [0, [4, 270], "I think I look smashing in it."]]],
  25.     [])
  26.     $data_quests["sign1"] = Quest_Data.new("",
  27.     [[0, [0, [4, 4], "You can call the script directly to a quest,"]],
  28.     [0, [0, [4, 24], "like this sign does. This lets you create"]],
  29.     [0, [0, [4, 44], "books and other media for your game..."]],
  30.     [0, [0, [4, 74], "...such as this sign."]], [0, [0, [4, 120], "You can also skip the category list and"]],
  31.     [0, [0, [4, 140], "jump directly to a category, if you wanted to."]]], [])
  32.   end
  33.  
  34. end
Expand to see the code.
Quest Handling Spoiler
  1. class Quest_Data
  2.  
  3.   attr_accessor :description
  4.   attr_accessor :objectives
  5.   attr_accessor :name
  6.   attr_accessor :data
  7.  
  8.   def initialize(name, description, objectives, data = {})
  9.     @name = name
  10.     @description = description
  11.     @objectives = objectives
  12.     @data = data
  13.   end
  14.  
  15. end
  16.  
  17. class Quest_List_Data
  18.  
  19.   attr_accessor :data
  20.   attr_accessor :stages
  21.   attr_reader   :id
  22.  
  23.   def initialize(quest_id)
  24.     @data = $data_quests[quest_id].data
  25.     @stages = []
  26.     for obj in $data_quests[quest_id].objectives
  27.       @stages.push(obj[1])
  28.     end
  29.     @id = quest_id
  30.   end
  31.  
  32.   def name
  33.     return $data_quests[@id].name
  34.   end
  35.  
  36.   def description
  37.     return $data_quests[@id].description
  38.   end
  39.  
  40.   def objectives
  41.     return $data_quests[@id].objectives
  42.   end
  43.  
  44. end
  45.  
  46. class Quest_List
  47.  
  48.   attr_accessor :quests
  49.   attr_accessor :lists
  50.   attr_accessor :order
  51.   attr_accessor :settings
  52.  
  53.   def initialize
  54.     @quests = {}
  55.     @order = {}
  56.     @lists = {}
  57.     @settings = [1, 2] # Default inventory, default battlers
  58.     @lists['wat'] = Category_List.new
  59.     @lists['wat'].windowskin = "001-Blue01"
  60.     @lists['wat'].categories = [["Not Finished", "list1"], ["Not Not Finished", "Finished"]]
  61.     @lists["signboard"] = Category_List.new
  62.     @lists["signboard"].windowskin = "001-Blue01"
  63.     @lists["signboard"].background = ["terriblesign", -16, -24] # Remember that there's a 16x16 buffer on windows
  64.   end
  65.  
  66.   def has_quest?(quest_id)
  67.     return @quests.include?(quest_id)
  68.   end
  69.  
  70.   def add(quest_id, list_name)
  71.     return if $data_quests[quest_id].nil?
  72.     if @order[list_name].nil?
  73.       @order[list_name] = []
  74.     end
  75.     return if @order[list_name].include?(quest_id)
  76.     @order[list_name].push(quest_id)
  77.     add_quest(quest_id)
  78.   end
  79.  
  80.   def remove(quest_id, list_name)
  81.     return if $data_quests[quest_id].nil?
  82.     return if @order[list_name].nil?
  83.     return if @order[list_name].empty?
  84.     return unless @order[list_name].include?(quest_id)
  85.     @order[list_name].delete(quest_id)
  86.   end
  87.  
  88.   def add_quest(quest_id)
  89.     return if $data_quests[quest_id].nil?
  90.     return if @quests.include?(quest_id)
  91.     @quests[quest_id] = Quest_List_Data.new(quest_id)
  92.   end
  93.  
  94.   def remove_quest(quest_id, erase = false)
  95.     @quests.delete(quest_id) if erase
  96.     for list in @order.keys
  97.       @order[list].delete(quest_id)
  98.     end
  99.   end
  100.  
  101.   def reset_quest(quest_id, create = true)
  102.     return unless @quests.include?(quest_id) if create == false
  103.     @quests.delete(quest_id)
  104.     add_quest(quest_id)
  105.   end
  106.  
  107.   def replace(new_quest, rep_quest, list_name)
  108.     return if new_quest == rep_quest # EASIEST REPLACEMENT EVER
  109.     return if $data_quests[new_quest].nil? or $data_quests[rep_quest].nil?
  110.     return if @order[list_name].nil?
  111.     return if @order[list_name].empty?
  112.     return if @order[list_name].include?(new_quest)
  113.     return unless @order[list_name].include?(rep_quest)
  114.     @order[list_name][@order[list_name].index(rep_quest)] = new_quest
  115.     add_quest(new_quest)
  116.   end
  117.  
  118.   def erase_list(list_name)
  119.     @order.delete(list_name)
  120.   end
  121.  
  122.   def create_list(list_name)
  123.     return unless @order[list_name].nil?
  124.     @order[list_name] = []
  125.   end
  126.  
  127. end
  128.  
  129. class Category_List
  130.  
  131.   attr_accessor :categories
  132.   attr_accessor :title
  133.   attr_accessor :font
  134.   attr_accessor :background
  135.   attr_accessor :windowskin
  136.   attr_accessor :ipp
  137.   attr_accessor :animation
  138.   attr_accessor :empty_text
  139.   attr_accessor :audio
  140.   attr_accessor :formatting
  141.   attr_accessor :page_graphics
  142.  
  143.   def initialize
  144.     # These are the defaults. You have to set them for the category list itself
  145.     # if you want it to be different.
  146.     @title = "Table of Contents"
  147.     # Font [[Title Font, Size, Color], [Category Font, Size, Color]]
  148.     @font = [[Font.default_name, 24, Color.new(0, 0, 0)], [Font.default_name, 20, Color.new(0, 0, 0)]]
  149.     # Background [filename, x offset, y offset]
  150.     @background = ["BookBack2.png", 5, 8]
  151.     @windowskin = "Pengu Speech 1.png"
  152.     # Items per page. Will require adjusting of @formatting if you change it.
  153.     @ipp = 11
  154.     # Animation ID (defined in script)
  155.     @animation = -1
  156.     # Text to display when there are no valid categories
  157.     @empty_text = ""
  158.     # Audio
  159.     @audio = [["Audio/SE/046-Book01", 100, 100], ["Audio/SE/046-Book01", 100, 100],
  160.               ["Audio/SE/046-Book01", 100, 90], ["Audio/SE/046-Book01", 100, 90],
  161.               ["Audio/SE/" + $data_system.cursor_se.name, $data_system.cursor_se.volume, $data_system.cursor_se.pitch],
  162.               ["Audio/SE/046-Book01", 100, 100]]
  163.     # Formatting: [Distance from one page to the next, distance between list items, width of page, offset from top, cursor margin]
  164.     @formatting = [261, 26, 235, 12, 8]
  165.     # Page Graphics: [prevpage, nextpage]
  166.     @page_graphics = ["prevpage.png", "nextpage.png"]
  167.     # Same as before
  168.     @categories = []
  169.   end
  170.  
  171. end
Expand to see the code.
Quest Window Spoiler
  1. class Quest_Window < Window_Base
  2.  
  3.   attr_reader :close_book
  4.  
  5.   def initialize(x, y, z, list_index, auto = false, mode = [0])
  6.     super(x-16, y-16, 535, 386)
  7.     self.contents = Bitmap.new(width-32, height-32)
  8.     self.contents.font.color = normal_color
  9.     self.z = z
  10.     @list = $game_party.quests.lists[list_index]
  11.     @background = Sprite.new
  12.     @background.bitmap = RPG::Cache.picture(@list.background[0])
  13.     @background.x = self.x + @list.background[1]
  14.     @background.y = self.y + @list.background[2]
  15.     @background.z = self.z - 10
  16.     self.opacity = 0
  17.     @cursor_coord = []
  18.     @index = [0, 0, ""]
  19.     @last_index = -2
  20.     @last_page = 0
  21.     @page = [0,0,0]
  22.     @close_book = false
  23.     @phase = 0
  24.     @mode = mode
  25.     setup_toc
  26.     setup_toc_cursor
  27.     check_mode
  28.     refresh
  29.     update_loop if auto
  30.   end
  31.  
  32.   def update_loop
  33.     loop do
  34.       Graphics.update
  35.       Input.update
  36.       update
  37.       break if @close_book
  38.     end
  39.     dispose
  40.     Input.update
  41.   end
  42.  
  43.   def check_mode
  44.     se = @list.audio[2]
  45.     Audio.se_play(se[0], se[1], se[2])
  46.     case @mode[0]
  47.     when 1 # Directly to category [1, category key, header text]
  48.       @phase = 1
  49.       setup_category_cursor
  50.     when 2 # Directly to quest [2, quest key]
  51.       @phase = 2
  52.     end
  53.   end
  54.  
  55.   def dispose
  56.     @background.dispose
  57.     super
  58.   end
  59.  
  60.   def setup_toc
  61.     @toc = [[]]
  62.     @pagemax = []
  63.     @indexmax = [-1, 0]
  64.     i = 0
  65.     count = 1
  66.     val = -1
  67.     for catg in @list.categories
  68.       val += 1
  69.       next if $game_party.quests.order[catg[1]].nil?
  70.       next if $game_party.quests.order[catg[1]].empty?
  71.       if count > @list.ipp * 2
  72.         count = 0
  73.         i += 1
  74.         @toc.push([])
  75.       end
  76.       @toc[i].push(catg)
  77.       count += 1
  78.       @indexmax[0] += 1
  79.     end
  80.     if @indexmax[0] == -1
  81.       @phase = -1
  82.       @toc[0].push([@list.empty_text])
  83.     end
  84.     @pagemax[0] = i
  85.   end
  86.  
  87.   def setup_questlist
  88.     @indexmax[1] = $game_party.quests.order[@toc[@page[1]][@index[0]][1]].size - 1
  89.     @pagemax[1] = $game_party.quests.order[@toc[@page[1]][@index[0]][1]].size / (@list.ipp * 2)
  90.   end
  91.  
  92.   def update
  93.     if [-1, 0].include?(@phase)
  94.       indexnum = 0
  95.     elsif @phase == 1
  96.       indexnum = 1
  97.     elsif @phase == 2
  98.       indexnum = 2
  99.     end
  100.     if Input.repeat?(Input::DOWN)
  101.       if [0, 1].include?(@phase)
  102.         temp = @index[indexnum] / @list.ipp
  103.         @index[indexnum] += 1
  104.         if @index[indexnum] > @indexmax[indexnum]
  105.           @index[indexnum] -= (@indexmax[indexnum] + 1) % @list.ipp
  106.         elsif @index[indexnum] / @list.ipp != temp
  107.           @index[indexnum] -= @list.ipp
  108.         end
  109.       end
  110.     end
  111.     if Input.repeat?(Input::UP)
  112.       if [0, 1].include?(@phase)
  113.         temp = @index[indexnum] / @list.ipp
  114.         @index[indexnum] -= 1
  115.         if @index[indexnum] < 0 or @index[indexnum] / @list.ipp != temp
  116.           @index[indexnum] = [(@index[indexnum] + @list.ipp), @indexmax[indexnum]].min
  117.         end
  118.       end
  119.     end
  120.     if Input.repeat?(Input::RIGHT)
  121.       if [0, 1].include?(@phase)
  122.         if @index[indexnum] == @indexmax[indexnum]
  123.           @index[indexnum] = 0
  124.         else
  125.           @index[indexnum] += @list.ipp
  126.           @index[indexnum] = @indexmax[indexnum] if @index[indexnum] > @indexmax[indexnum]
  127.         end
  128.       elsif @phase == 2
  129.         @page[2] += 1
  130.         @page[2] = 0 if @page[2] > @pagemax[2]
  131.       end
  132.     end
  133.     if Input.repeat?(Input::LEFT)
  134.       if [0, 1].include?(@phase)
  135.         if @index[indexnum] == 0
  136.           @index[indexnum] = @indexmax[indexnum]
  137.         else
  138.           @index[indexnum] -= @list.ipp
  139.           @index[indexnum] = 0 if @index[indexnum] < 0
  140.         end
  141.       elsif @phase == 2
  142.         @page[2] -= 1
  143.         @page[2] = @pagemax[2] if @page[2] < 0
  144.       end
  145.     end
  146.     if [-1, 0, 1].include?(@phase)
  147.       @page[indexnum] = (@index[indexnum] / (@list.ipp * 2))
  148.     end
  149.     if Input.trigger?(Input::C)
  150.       if @phase == 0
  151.         @phase = 1
  152.         setup_questlist
  153.         setup_category_cursor
  154.         @last_index = -1
  155.         @last_page = - 1
  156.         se = @list.audio[0]
  157.         Audio.se_play(se[0], se[1], se[2])
  158.         return
  159.       elsif @phase == 1
  160.         @phase = 2
  161.         @last_index = -1
  162.         @last_page = - 1
  163.         se = @list.audio[1]
  164.         Audio.se_play(se[0], se[1], se[2])
  165.         return
  166.       elsif @phase == 2 and @mode[0] == 2
  167.         @close_book = true
  168.         se = @list.audio[2]
  169.         Audio.se_play(se[0], se[1], se[2])
  170.         return
  171.       end
  172.     end
  173.     if Input.trigger?(Input::B)
  174.       if [-1, 0].include?(@phase) or (@phase == 1 and @mode[0] == 1) or
  175.                 (@phase == 2 and @mode[0] == 2)
  176.         @close_book = true
  177.         se = @list.audio[2]
  178.         Audio.se_play(se[0], se[1], se[2])
  179.         return
  180.       elsif [1, 2].include?(@phase)
  181.         @index[1] = 0 if @phase == 1
  182.         @phase -= 1
  183.         @last_index = -1
  184.         @last_page = - 1
  185.         @page[2] = 0
  186.         se = @list.audio[3]
  187.         Audio.se_play(se[0], se[1], se[2])
  188.         return
  189.       end
  190.     end
  191.     if [0, 1].include?(@phase)
  192.       if @index[indexnum] != @last_index
  193.         unless @page[indexnum] != @last_page or @last_index == -2
  194.           se = @list.audio[4]
  195.           Audio.se_play(se[0], se[1], se[2])
  196.         end
  197.         @last_index = @index[indexnum]
  198.         self.cursor_rect.set(@cursor_coord[indexnum][@index[indexnum]][0], @cursor_coord[indexnum][@index[indexnum]][1], @cursor_coord[indexnum][@index[indexnum]][2],30)
  199.       end
  200.     end
  201.     if @page[indexnum] != @last_page
  202.       unless @last_page == - 1
  203.         se = @list.audio[5]
  204.         Audio.se_play(se[0], se[1], se[2])
  205.         if @page[indexnum] < @last_page
  206.           if @page[indexnum] + 1 < @last_page
  207.             page_left_many
  208.           else
  209.             page_left
  210.           end
  211.         else
  212.           if @page[indexnum] - 1 > @last_page
  213.             page_right_many
  214.           else
  215.             page_right
  216.           end
  217.         end
  218.       end
  219.       @last_page = @page[indexnum]
  220.       refresh
  221.     end
  222.   end
  223.  
  224.   def refresh
  225.     self.contents.clear
  226.     if [-1, 0, 1].include?(@phase)
  227.       if [-1, 0].include?(@phase)
  228.         pagenum = 0
  229.         pagemaxnum = 0
  230.         headertext = @list.title
  231.         loopvals = @toc[@page[0]]
  232.       else
  233.         pagenum = 1
  234.         @pagemax[1] = 0
  235.         pagemaxnum = 1
  236.         if @mode[0] == 1
  237.           headertext = @mode[2]
  238.           loopvals = $game_party.quests.order[@mode[1]]
  239.         else
  240.           headertext = @toc[@page[1]][@index[0]][0]
  241.           loopvals = $game_party.quests.order[@toc[@page[1]][@index[0]][1]]
  242.         end
  243.       end
  244.       offset = @list.formatting[3]
  245.       if @page[pagenum] == 0
  246.         self.contents.font.name = @list.font[0][0]
  247.         self.contents.font.size = @list.font[0][1]
  248.         self.contents.font.color = @list.font[0][2]
  249.         text = headertext.dup
  250.         fontcheck = check_title_codes(text)
  251.         self.contents.font.name = fontcheck[0] unless fontcheck[0].nil?
  252.         self.contents.font.size = fontcheck[1] + 5 unless fontcheck[1].nil?
  253.         self.contents.font.color = fontcheck[2] unless fontcheck[2].nil?
  254.         self.contents.draw_text(0, 0, @list.formatting[2], 32, text, 1)
  255.       end
  256.       y = 0
  257.       x = 0
  258.       for asdf in loopvals
  259.         self.contents.font.name = @list.font[1][0]
  260.         self.contents.font.size = @list.font[1][1]
  261.         self.contents.font.color = @list.font[1][2]
  262.         if @phase == 1
  263.           name = $game_party.quests.quests[asdf].name.dup
  264.         else
  265.           name = asdf[0].dup
  266.         end
  267.         fontcheck = check_title_codes(name)
  268.         self.contents.font.name = fontcheck[0] unless fontcheck[0].nil?
  269.         self.contents.font.size = fontcheck[1] unless fontcheck[1].nil?
  270.         self.contents.font.color = fontcheck[2] unless fontcheck[2].nil?
  271.         y += 1
  272.         if y > @list.ipp
  273.           y = 1
  274.           x += 1
  275.         end
  276.         break if x >= 2
  277.         self.contents.draw_text(x * @list.formatting[0], offset + (y * @list.formatting[1]), @list.formatting[2], 32, name, 1)
  278.       end
  279.       if @page[pagenum] + 1 <= @pagemax[pagemaxnum]
  280.         bitmap = RPG::Cache.picture(@list.page_graphics[1])
  281.         self.contents.blt(self.contents.width - bitmap.width, self.contents.height - bitmap.height, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
  282.       end
  283.       if @page[pagenum] > 0
  284.         bitmap = RPG::Cache.picture(@list.page_graphics[0])
  285.         self.contents.blt(0, self.contents.height - bitmap.height, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
  286.       end
  287.     elsif @phase == 2
  288.       self.cursor_rect.empty
  289.       draw_description
  290.     end
  291.   end
  292.  
  293.   def setup_toc_cursor
  294.     duck = 0
  295.     @cursor_coord[0] = []
  296.     for cat in @toc
  297.       x = 0
  298.       y = 0
  299.       for dog in cat
  300.         y += 1
  301.         if y > @list.ipp
  302.           y = 1
  303.           x += 1
  304.         end
  305.         if x >= 2
  306.           x = 0
  307.         end
  308.         self.contents.font.name = @list.font[1][0]
  309.         self.contents.font.size = @list.font[1][1]
  310.         self.contents.font.color = @list.font[1][2]
  311.         zebra = dog[0].dup
  312.         fontcheck = check_title_codes(zebra)
  313.         self.contents.font.name = fontcheck[0] unless fontcheck[0].nil?
  314.         self.contents.font.size = fontcheck[1] unless fontcheck[1].nil?
  315.         self.contents.font.color = fontcheck[2] unless fontcheck[2].nil?
  316.         @cursor_coord[0][duck] = [x * @list.formatting[0] + (@list.formatting[2] / 2) - @list.formatting[4] - (self.contents.text_size(zebra).width / 2), @list.formatting[3] + (y * @list.formatting[1]), self.contents.text_size(zebra).width + (@list.formatting[4] * 2)]
  317.         duck += 1
  318.       end
  319.     end
  320.   end
  321.  
  322.   def setup_category_cursor
  323.     x = 0
  324.     y = 0
  325.     moose = 0
  326.     @cursor_coord[1] = []
  327.     if @mode[0] == 1
  328.       loopvals = $game_party.quests.order[@mode[1]]
  329.     else
  330.       loopvals = $game_party.quests.order[@toc[@page[0]][@index[0]][1]]
  331.     end
  332.     for cow in loopvals
  333.       badger = $game_party.quests.quests[cow].name
  334.       y += 1
  335.       if y > @list.ipp
  336.         y = 1
  337.         x += 1
  338.       end
  339.       if x >= 2
  340.         x = 0
  341.       end
  342.       self.contents.font.name = @list.font[1][0]
  343.       self.contents.font.size = @list.font[1][1]
  344.       self.contents.font.color = @list.font[1][2]
  345.       mushroom = badger.dup
  346.       fontcheck = check_title_codes(mushroom)
  347.       self.contents.font.name = fontcheck[0] unless fontcheck[0].nil?
  348.       self.contents.font.size = fontcheck[1] unless fontcheck[1].nil?
  349.       self.contents.font.color = fontcheck[2] unless fontcheck[2].nil?
  350.       @cursor_coord[1][moose] = [x * @list.formatting[0] + (@list.formatting[2] / 2) - @list.formatting[4] - (self.contents.text_size(mushroom).width / 2), @list.formatting[3] + (y * @list.formatting[1]), self.contents.text_size(mushroom).width + (@list.formatting[4] * 2)]
  351.       moose += 1
  352.     end
  353.   end
  354.  
  355.   def check_title_codes(text)
  356.     fn = nil
  357.     fs = nil
  358.     fc = nil
  359.     text.gsub!(/\\[Ff][Nn]\[([0-9]+)\]/) do
  360.       fn = title_fonts($1.to_i)
  361.       ""
  362.     end
  363.     text.gsub!(/\\[Ff][Ss]\[([0-9]+)\]/) do
  364.       fs = $1.to_i
  365.       ""
  366.     end
  367.     text.gsub!(/\\[Ff][Cc]\[([0-9]+),([0-9]+),([0-9]+)\]/) do
  368.       fc = Color.new($1.to_i, $2.to_i, $3.to_i)
  369.       ""
  370.     end
  371.     return [fn, fs, fc]
  372.   end
  373.  
  374.  
  375.  
  376.   def page_left
  377.    
  378.   end
  379.  
  380.   def page_right
  381.    
  382.   end
  383.  
  384.   def page_left_many
  385.    
  386.   end
  387.  
  388.   def page_right_many
  389.    
  390.   end
  391.  
  392.   def title_fonts(type)
  393.     case type
  394.     when 0
  395.       return Font.default_name
  396.     when 1
  397.       return "Verdana"
  398.     end
  399.   end
  400.  
  401. end
Expand to see the code.
Message Codes and Instruction Types Spoiler
  1. class Quest_Window < Window_Base
  2.  
  3.   def draw_description
  4.     case @mode[0]
  5.     when 0
  6.       @index[2] = $game_party.quests.order[@list.categories[@indexvals[@index[0]]][1]][@index[1]]
  7.     when 1
  8.       @index[2] = $game_party.quests.order[@mode[1]][@index[1]]
  9.     when 2
  10.       @index[2] = @mode[1]
  11.     end
  12.     quest = $game_party.quests.quests[@index[2]]
  13.     pages = []
  14.     page_graphics = @list.page_graphics.dup
  15.     for line in quest.description
  16.       pages.push(line[1][0])
  17.       next unless @page[2] == line[1][0]
  18.       case line[0]
  19.       when 0 # Draw Text
  20.         x = line[1][1][0]
  21.         y = line[1][1][1]
  22.         t1 = line[1][2].dup
  23.         fc = line[1][3]
  24.         fs = line[1][4]
  25.         ft = line[1][5]
  26.         fc = @list.font[1][2] if fc.nil?
  27.         fs = @list.font[1][1] if fs.nil?
  28.         ft = @list.font[1][0] if ft.nil?
  29.         self.contents.font.color = fc
  30.         self.contents.font.size = fs
  31.         self.contents.font.name = ft
  32.         t = check_codes(t1)
  33.         h = self.contents.text_size(t).height
  34.         self.contents.draw_text(x, y, 1000, h, t)
  35.       when 1 # Draw Graphic
  36.         x = line[1][1][0]
  37.         y = line[1][1][1]
  38.         w = line[1][1][2]
  39.         h = line[1][1][3]
  40.         o = line[1][1][4]
  41.         w = 1.0 if w.nil?
  42.         h = 1.0 if h.nil?
  43.         o = 255 if o.nil?
  44.         gt = line[1][2][0]
  45.         gn = line[1][2][1]
  46.         if gt == 0
  47.           bitmap = RPG::Cache.icon(gn)
  48.         elsif gt == 1
  49.           bitmap = RPG::Cache.picture(gn)
  50.         end
  51.         self.contents.stretch_blt(Rect.new(x, y, bitmap.width * w, bitmap.height * h), bitmap, Rect.new(0, 0, bitmap.width, bitmap.height), o)
  52.       when 2 # Draw battler
  53.         x = line[1][1][0]
  54.         y = line[1][1][1]
  55.         o = line[1][1][2]
  56.         o = 255 if o.nil?
  57.         if line[1][2][0] == 0
  58.           actor = $game_actors[line[1][2][1]]
  59.         elsif line[1][2][0] == 1
  60.           actor = $data_enemies[line[1][2][1]]
  61.         end
  62.         case $game_party.quests.settings[1]
  63.         when 0 # Jaber's animation system [page, [x, y, opacity], [actor/enemy, id], pose, frame]
  64.           graphic = actor.battle_graphic + actor.stance + line[1][3]
  65.           bitmap = RPG::Cache.battler(graphic, 0)
  66.           self.contents.blt(x - ((bitmap.width / $game_temp.pose_frames(graphic)) / 2), y - bitmap.height, bitmap,
  67.                   Rect.new(((bitmap.width / $game_temp.pose_frames(graphic)) * line[1][4]), 0, bitmap.width / $game_temp.pose_frames(graphic), bitmap.height), o)
  68.           if line[1][2][0] == 0
  69.             equip_graphics = []
  70.             eqind = -1
  71.             for equip in actor.slot_data
  72.               eqind += 1
  73.               equip_data = $game_temp.get_data(actor.equipment[eqind])
  74.               next if equip_data == nil or equip_data.battle_graphic == nil
  75.               hand = eqind == 0 ? "_R" : eqind == 1 ? "_L" : "_"
  76.               equip_pic = actor.battle_graphic + actor.stance + hand + equip_data.battle_graphic + line[1][3]
  77.               equip_graphics.push([equip_data.priority, equip_pic])
  78.             end
  79.             equip_graphics.sort!
  80.             for equip in equip_graphics
  81.               bitmap = RPG::Cache.battler(equip[1], 0)
  82.               if bitmap.nil?
  83.                 p equip[1]
  84.                 next
  85.               end
  86.               self.contents.blt(x - ((bitmap.width / $game_temp.pose_frames(graphic)) / 2), y - bitmap.height, bitmap,
  87.                   Rect.new(((bitmap.width / $game_temp.pose_frames(graphic)) * line[1][4]), 0, bitmap.width / $game_temp.pose_frames(graphic), bitmap.height), o)
  88.             end
  89.           end
  90.         when 1 # Minkoff's animation system [page, [x, y], [actor/enemy, id], pose#, frame#]
  91.           if line[1][2][0] == 0
  92.             bitmap = RPG::Cache.battlers(actor.battler_name, actor.battler_hue)
  93.             o = MNK_TRANSLUCENCY if MNK_TRANSLUCENT_ACTOR.include?(actor.id)
  94.             if DEFAULT_ACTOR or DEFAULT_ACTOR_ID.include?(actor.id)
  95.               x_div = 1
  96.               y_div = 1
  97.               pose = 0
  98.               frame = 0
  99.             else
  100.               x_div = MNK_FRAMES
  101.               y_div = MNK_POSES
  102.               if MNK_FRAMES_ACTOR != nil and MNK_FRAMES_ACTOR[actor.id] != nil
  103.                 x_div = MNK_FRAMES_ACTOR[actor.id]
  104.               end
  105.               if MNK_POSES_ACTOR != nil and MNK_POSES_ACTOR[actor.id] != nil
  106.                 y_div = MNK_POSES_ACTOR[actor.id]
  107.               end
  108.               # WHY COULDN'T YOU MAKE THE POSE CRAP EASIER DVV D:
  109.               pose = line[1][3]
  110.               frame = line[1][4]
  111.               case line[1][3]
  112.               when 0
  113.                 pose = MNK_APOSE1[actor.id] if MNK_APOSE1[actor.id] != nil
  114.               when 1
  115.                 pose = MNK_APOSE2[actor.id] if MNK_APOSE2[actor.id] != nil
  116.               when 2
  117.                 pose = MNK_APOSE3[actor.id] if MNK_APOSE3[actor.id] != nil
  118.               when 3
  119.                 pose = MNK_APOSE4[actor.id] if MNK_APOSE4[actor.id] != nil
  120.               when 4
  121.                 pose = MNK_APOSE5[actor.id] if MNK_APOSE5[actor.id] != nil
  122.               when 5
  123.                 pose = MNK_APOSE6[actor.id] if MNK_APOSE6[actor.id] != nil
  124.               when 6
  125.                 pose = MNK_APOSE7[actor.id] if MNK_APOSE7[actor.id] != nil
  126.               when 7
  127.                 pose = MNK_APOSE8[actor.id] if MNK_APOSE8[actor.id] != nil
  128.               when 8
  129.                 pose = MNK_APOSE9[actor.id] if MNK_APOSE9[actor.id] != nil
  130.               when 9
  131.                 pose = MNK_APOSE10[actor.id] if MNK_APOSE10[actor.id] != nil
  132.               when 10
  133.                 pose = MNK_APOSE11[actor.id] if MNK_APOSE11[actor.id] != nil
  134.               end
  135.               if MNK_FRAMES_PER_POSE[pose] != nil
  136.                 x_div = MNK_FRAMES_PER_POSE[pose]
  137.               end
  138.               # I DON'T KNOW HOW THE MNK_POSES_FR_ THING WORKS SORRY
  139.             end
  140.           elsif line[1][2][0] == 1
  141.             bitmap = RPG::Cache.battlers(actor.battler_name, actor.battler_hue)
  142.             o = MNK_TRANSLUCENCY if MNK_TRANSLUCENT_ENEMY.include?(actor.id)
  143.             if DEFAULT_ENEMY or DEFAULT_ENEMY_ID.include?(actor.id)
  144.               x_div = 1
  145.               y_div = 1
  146.               pose = 0
  147.               frame = 0
  148.             else
  149.               x_div = MNK_FRAMES
  150.               y_div = MNK_POSES
  151.               if MNK_FRAMES_ENEMY != nil and MNK_FRAMES_ENEMY[actor.id] != nil
  152.                 x_div = MNK_FRAMES_ENEMY[actor.id]
  153.               end
  154.               if MNK_POSES_ENEMY != nil and MNK_POSES_ENEMY[actor.id] != nil
  155.                 y_div = MNK_POSES_ENEMY[actor.id]
  156.               end
  157.               pose = line[1][3]
  158.               frame = line[1][4]
  159.               case line[1][3]
  160.               when 0
  161.                 pose = MNK_EPOSE1[actor.id] if MNK_EPOSE1[actor.id] != nil
  162.               when 1
  163.                 pose = MNK_EPOSE2[actor.id] if MNK_EPOSE2[actor.id] != nil
  164.               when 2
  165.                 pose = MNK_EPOSE3[actor.id] if MNK_EPOSE3[actor.id] != nil
  166.               when 3
  167.                 pose = MNK_EPOSE4[actor.id] if MNK_EPOSE4[actor.id] != nil
  168.               when 4
  169.                 pose = MNK_EPOSE5[actor.id] if MNK_EPOSE5[actor.id] != nil
  170.               when 5
  171.                 pose = MNK_EPOSE6[actor.id] if MNK_EPOSE6[actor.id] != nil
  172.               when 6
  173.                 pose = MNK_EPOSE7[actor.id] if MNK_EPOSE7[actor.id] != nil
  174.               when 7
  175.                 pose = MNK_EPOSE8[actor.id] if MNK_EPOSE8[actor.id] != nil
  176.               when 8
  177.                 pose = MNK_EPOSE9[actor.id] if MNK_EPOSE9[actor.id] != nil
  178.               when 9
  179.                 pose = MNK_EPOSE10[actor.id] if MNK_EPOSE10[actor.id] != nil
  180.               when 10
  181.                 pose = MNK_EPOSE11[actor.id] if MNK_EPOSE11[actor.id] != nil
  182.               end
  183.             end
  184.           end
  185.           self.contents.blt(x, y, bitmap, Rect.new((bitmap.width / x_div) * frame, (bitmap.height / y_div) * pose, bitmap.width / x_div, bitmap.height / y_div), o)
  186.         when 2 # Default battlers [page, [x, y, opacity], [actor/enemy, id]]
  187.           bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
  188.           self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height), o)
  189.         end
  190.       when 3 # Draw Characterset [page, [x, y, opacity], [type, data], [#frames, #directions, facing, frame]]
  191.         case line[1][2][0] # For type:
  192.         when 0 # Use actor ID, [0, actor id]
  193.           cn = $game_actors[line[1][2][1]].character_name
  194.           ch = $game_actors[line[1][2][1]].character_hue
  195.         when 1 # Use filename, [1, filename, hue number]
  196.           cn = line[1][2][1]
  197.           ch = line[1][2][2]
  198.         end
  199.         x = line[1][1][0]
  200.         y = line[1][1][1]
  201.         o = line[1][1][2]
  202.         o = 255 if o.nil?
  203.         w = line[3][0]
  204.         h = line[3][1]
  205.         d = line[3][2]
  206.         f = line[3][3]
  207.         bitmap = RPG::Cache.character(cn, ch)
  208.         self.contents.blt(x, y, bitmap, Rect.new(x + ((bitmap.width / w) * f), y + ((bitmap.height / h) * d),
  209.                                                   bitmap.width / w, bitmap.height / h), o)
  210.       #
  211.       end
  212.     end
  213.     count = -1
  214.     for line in quest.objectives
  215.       count += 1
  216.       obj = quest.stages[count]
  217.       next if obj == 0
  218.       pages.push(line[2][0])
  219.       next unless @page[2] == line[2][0]
  220.       case line[0]
  221.       when 0 # Draw Text
  222.         x = line[2][1][0]
  223.         y = line[2][1][1]
  224.         t1 = line[2][2][obj-1].dup
  225.         fc = line[2][3]
  226.         fs = line[2][4]
  227.         ft = line[2][5]
  228.         fc = @list.font[1][2] if fc.nil?
  229.         fs = @list.font[1][1] if fs.nil?
  230.         ft = @list.font[1][0] if ft.nil?
  231.         self.contents.font.color = fc
  232.         self.contents.font.size = fs
  233.         self.contents.font.name = ft
  234.         t = check_codes(t1)
  235.         h = self.contents.text_size(t).height
  236.         self.contents.draw_text(x, y, 1000, h, t)
  237.       when 1 # Draw Graphic
  238.         x = line[2][1][0]
  239.         y = line[2][1][1]
  240.         w = line[2][1][2]
  241.         h = line[2][1][3]
  242.         o = line[2][1][4]
  243.         w = 1.0 if w.nil?
  244.         h = 1.0 if h.nil?
  245.         o = 255 if o.nil?
  246.         gt = line[2][2][obj-1][0]
  247.         gn = line[2][2][obj-1][1]
  248.         if gt == 0
  249.           bitmap = RPG::Cache.icon(gn)
  250.         elsif gt == 1
  251.           bitmap = RPG::Cache.picture(gn)
  252.         end
  253.         self.contents.stretch_blt(Rect.new(x, y, bitmap.width * w, bitmap.height * h), bitmap, Rect.new(0, 0, bitmap.width, bitmap.height), o)
  254.       when 2 # Draw battler
  255.         x = line[2][1][0]
  256.         y = line[2][1][1]
  257.         o = line[1][1][2]
  258.         o = 255 if o.nil?
  259.         if line[2][2][obj-1][0] == 0
  260.           actor = $game_actors[line[2][2][obj-1][1]]
  261.         elsif line[2][2][obj-1][0] == 1
  262.           actor = $data_enemies[line[2][2][obj-1][1]]
  263.         end
  264.         case $game_party.quests.settings[1]
  265.         when 0 # Jaber's animation system
  266.           graphic = actor.battle_graphic + actor.stance + line[2][3][obj-1]
  267.           bitmap = RPG::Cache.battler(graphic, 0)
  268.           self.contents.blt(x - ((bitmap.width / $game_temp.pose_frames(graphic)) / 2), y - bitmap.height, bitmap,
  269.                 Rect.new(((bitmap.width / $game_temp.pose_frames(graphic)) * line[2][4][obj-1]), 0, bitmap.width / $game_temp.pose_frames(graphic), bitmap.height), o)
  270.           if line[1][1][obj-1][0] == 0
  271.             equip_graphics = []
  272.             eqind = -1
  273.             for equip in actor.slot_data
  274.               eqind += 1
  275.               equip_data = $game_temp.get_data(actor.equipment[eqind])
  276.               next if equip_data == nil or equip_data.battle_graphic == nil
  277.               hand = eqind == 0 ? "_R" : eqind == 1 ? "_L" : "_"
  278.               equip_pic = actor.battle_graphic + actor.stance + hand + equip_data.battle_graphic + line[2][3][obj-1]
  279.               equip_graphics.push([equip_data.priority, equip_pic])
  280.             end
  281.             equip_graphics.sort!
  282.             for equip in equip_graphics
  283.               bitmap = RPG::Cache.battler(equip[1], 0)
  284.               if bitmap.nil?
  285.                 p equip[1]
  286.                 next
  287.               end
  288.               self.contents.blt(x - ((bitmap.width / $game_temp.pose_frames(graphic)) / 2), y - bitmap.height, bitmap,
  289.                   Rect.new(((bitmap.width / $game_temp.pose_frames(graphic)) * line[2][4][obj-1]), 0, bitmap.width / $game_temp.pose_frames(graphic), bitmap.height), o)
  290.             end
  291.           end
  292.         when 1 # Minkoff's animation system [page, [x, y], [actor/enemy, id], pose#, frame#]
  293.           if line[1][2][obj-1][0] == 0
  294.             bitmap = RPG::Cache.battlers(actor.battler_name, actor.battler_hue)
  295.             o = MNK_TRANSLUCENCY if MNK_TRANSLUCENT_ACTOR.include?(actor.id)
  296.             if DEFAULT_ACTOR or DEFAULT_ACTOR_ID.include?(actor.id)
  297.               x_div = 1
  298.               y_div = 1
  299.               pose = 0
  300.               frame = 0
  301.             else
  302.               x_div = MNK_FRAMES
  303.               y_div = MNK_POSES
  304.               if MNK_FRAMES_ACTOR != nil and MNK_FRAMES_ACTOR[actor.id] != nil
  305.                 x_div = MNK_FRAMES_ACTOR[actor.id]
  306.               end
  307.               if MNK_POSES_ACTOR != nil and MNK_POSES_ACTOR[actor.id] != nil
  308.                 y_div = MNK_POSES_ACTOR[actor.id]
  309.               end
  310.               pose = line[1][3][obj-1]
  311.               frame = line[1][4][obj-1]
  312.               case line[1][3]
  313.               when 0
  314.                 pose = MNK_APOSE1[actor.id] if MNK_APOSE1[actor.id] != nil
  315.               when 1
  316.                 pose = MNK_APOSE2[actor.id] if MNK_APOSE2[actor.id] != nil
  317.               when 2
  318.                 pose = MNK_APOSE3[actor.id] if MNK_APOSE3[actor.id] != nil
  319.               when 3
  320.                 pose = MNK_APOSE4[actor.id] if MNK_APOSE4[actor.id] != nil
  321.               when 4
  322.                 pose = MNK_APOSE5[actor.id] if MNK_APOSE5[actor.id] != nil
  323.               when 5
  324.                 pose = MNK_APOSE6[actor.id] if MNK_APOSE6[actor.id] != nil
  325.               when 6
  326.                 pose = MNK_APOSE7[actor.id] if MNK_APOSE7[actor.id] != nil
  327.               when 7
  328.                 pose = MNK_APOSE8[actor.id] if MNK_APOSE8[actor.id] != nil
  329.               when 8
  330.                 pose = MNK_APOSE9[actor.id] if MNK_APOSE9[actor.id] != nil
  331.               when 9
  332.                 pose = MNK_APOSE10[actor.id] if MNK_APOSE10[actor.id] != nil
  333.               when 10
  334.                 pose = MNK_APOSE11[actor.id] if MNK_APOSE11[actor.id] != nil
  335.               end
  336.               if MNK_FRAMES_PER_POSE[pose] != nil
  337.                 x_div = MNK_FRAMES_PER_POSE[pose]
  338.               end
  339.             end
  340.           elsif line[1][2][obj-1][0] == 1
  341.             bitmap = RPG::Cache.battlers(actor.battler_name, actor.battler_hue)
  342.             o = MNK_TRANSLUCENCY if MNK_TRANSLUCENT_ENEMY.include?(actor.id)
  343.             if DEFAULT_ENEMY or DEFAULT_ENEMY_ID.include?(actor.id)
  344.               x_div = 1
  345.               y_div = 1
  346.               pose = 0
  347.               frame = 0
  348.             else
  349.               x_div = MNK_FRAMES
  350.               y_div = MNK_POSES
  351.               if MNK_FRAMES_ENEMY != nil and MNK_FRAMES_ENEMY[actor.id] != nil
  352.                 x_div = MNK_FRAMES_ENEMY[actor.id]
  353.               end
  354.               if MNK_POSES_ENEMY != nil and MNK_POSES_ENEMY[actor.id] != nil
  355.                 y_div = MNK_POSES_ENEMY[actor.id]
  356.               end
  357.               pose = line[1][3][obj-1]
  358.               frame = line[1][4][obj-1]
  359.               case line[1][3][obj-1]
  360.               when 0
  361.                 pose = MNK_EPOSE1[actor.id] if MNK_EPOSE1[actor.id] != nil
  362.               when 1
  363.                 pose = MNK_EPOSE2[actor.id] if MNK_EPOSE2[actor.id] != nil
  364.               when 2
  365.                 pose = MNK_EPOSE3[actor.id] if MNK_EPOSE3[actor.id] != nil
  366.               when 3
  367.                 pose = MNK_EPOSE4[actor.id] if MNK_EPOSE4[actor.id] != nil
  368.               when 4
  369.                 pose = MNK_EPOSE5[actor.id] if MNK_EPOSE5[actor.id] != nil
  370.               when 5
  371.                 pose = MNK_EPOSE6[actor.id] if MNK_EPOSE6[actor.id] != nil
  372.               when 6
  373.                 pose = MNK_EPOSE7[actor.id] if MNK_EPOSE7[actor.id] != nil
  374.               when 7
  375.                 pose = MNK_EPOSE8[actor.id] if MNK_EPOSE8[actor.id] != nil
  376.               when 8
  377.                 pose = MNK_EPOSE9[actor.id] if MNK_EPOSE9[actor.id] != nil
  378.               when 9
  379.                 pose = MNK_EPOSE10[actor.id] if MNK_EPOSE10[actor.id] != nil
  380.               when 10
  381.                 pose = MNK_EPOSE11[actor.id] if MNK_EPOSE11[actor.id] != nil
  382.               end
  383.             end
  384.           end
  385.           self.contents.blt(x, y, bitmap, Rect.new((bitmap.width / x_div) * frame, (bitmap.height / y_div) * pose, bitmap.width / x_div, bitmap.height / y_div), o)          
  386.         when 2 # Default battlers
  387.           bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
  388.           self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height), o)
  389.         end
  390.       when 3 # Draw Characterset
  391.         case line[1][2][obj-1][0]
  392.         when 0 # Use actor ID
  393.           cn = $game_actors[line[1][2][obj-1][1]].character_name
  394.           ch = $game_actors[line[1][2][obj-1][1]].character_hue
  395.         when 1 # Use filename
  396.           cn = line[1][2][obj-1][1]
  397.           ch = line[1][2][obj-1][2]
  398.         end
  399.         x = line[1][1][0]
  400.         y = line[1][1][1]
  401.         o = line[1][1][2]
  402.         o = 255 if o.nil?
  403.         w = line[3][0][obj-1]
  404.         h = line[3][1][obj-1]
  405.         d = line[3][2][obj-1]
  406.         f = line[3][3][obj-1]
  407.         bitmap = RPG::Cache.character(cn, ch)
  408.         self.contents.blt(x, y, bitmap, Rect.new(x + ((bitmap.width / w) * f), y + ((bitmap.height / h) * d),
  409.                                                   bitmap.width / w, bitmap.height / h), o)
  410.       #
  411.       end
  412.     end
  413.     @pagemax[2] = pages.max
  414.     if @page[2] + 1 <= @pagemax[2]
  415.       bitmap = RPG::Cache.picture(page_graphics[1])
  416.       self.contents.blt(self.contents.width - bitmap.width, self.contents.height - bitmap.height, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
  417.     end
  418.     if @page[2] > 0
  419.       bitmap = RPG::Cache.picture(page_graphics[0])
  420.       self.contents.blt(0, self.contents.height - bitmap.height, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
  421.     end
  422.   end
  423.  
  424.   def check_codes(text)
  425.     text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  426.     text.gsub!(/\\[Ss]\[([0-9]+),([\w\s]*),([\w\s]*)\]/) { $game_switches[$1.to_i] == true ? $2 : $3 }
  427.     text.gsub!(/\\[Gg]/) { $game_party.gold }
  428.     text.gsub!(/\\[Qq][Vv]\[([\w\s]*)\]/) { $game_party.quests.quests[@index[2]].data[$1] }
  429.     text.gsub!(/\\[Ii][Tt][Ee][Mm]\[([0-9]+)\]/) { $data_items[$1.to_i].name }
  430.     text.gsub!(/\\[Ww][Ee][Aa][Pp][Oo][Nn]\[([0-9]+)\]/) { $data_weapons[$1.to_i].name }
  431.     text.gsub!(/\\[Aa][Rr][Mm][Oo][Rr]\[([0-9]+)\]/) { $data_armors[$1.to_i].name }
  432.     text.gsub!(/\\[Ss][Kk][Ii][Ll][Ll]\[([0-9]+)\]/) { $data_skills[$1.to_i].name }
  433.     text.gsub!(/\\[Aa][Cc][Tt][Oo][Rr]\[([0-9]+)\]/) { $data_actors[$1.to_i].name }
  434.     text.gsub!(/\\[Ee][Nn][Ee][Mm][Yy]\[([0-9]+)\]/) { $data_enemies[$1.to_i].name }
  435.     text.gsub!(/\\[Cc][Ll][Aa][Ss][Ss]\[([0-9]+)\]/) { $data_classes[$1.to_i].name }
  436.     text.gsub!(/\\[Aa][Cc][Ll][Aa][Ss][Ss]\[([0-9]+)\]/) { $data_classes[$game_actors[$1.to_i].class_id].name }
  437.     case $game_party.quests.settings[0]
  438.     when 0 # For my inventory grid [mode, bag index, type, id]
  439.       text.gsub!(/\\[Hh][Ee][Ll][Dd]\[([01]),([0-9]+),([0-9]+),([0-9]+)\]/) do
  440.         if $1.to_i == 0 # Use $game_party
  441.           case $2.to_i
  442.           when 0 # Party item bag
  443.             $game_party.item_bag.item_amount([$3.to_i, $4.to_i]).to_s
  444.           else
  445.             $game_party.actors[$2.to_i].item_bag.item_amount([$3.to_i, $4.to_i]).to_s
  446.           end
  447.         elsif $1.to_i == 1 # Use $game_actors
  448.           $game_actors[$2.to_i].item_bag.item_amount([$3.to_i, $4.to_i]).to_s
  449.         end
  450.       end
  451.     when 1 # For everyone else's less insane inventory systems [type, id]
  452.       text.gsub!(/\\[Ii][Hh][Ee][Ll][Dd]\[([012]),([0-9]+)\]/) do
  453.         case $1.to_i
  454.         when 0 # Items
  455.           $game_party.item_number($2.to_i).to_s
  456.         when 1 # Weapons
  457.           $game_party.weapon_number($2.to_i).to_s
  458.         when 2 # Armor
  459.           $game_party.armor_number($2.to_i).to_s
  460.         end
  461.       end
  462.     end
  463.     text.gsub!(/\\[Ss][Tt][Aa][Tt]\[([012]),([0-9]+),(\w*)\]/) do
  464.       case $1.to_i
  465.       when 0
  466.         chara = $game_party.actors[$2.to_i]
  467.       when 1
  468.         chara = $game_actors[$2.to_i]
  469.       when 2
  470.         chara = $data_enemies[$2.to_i]
  471.       end
  472.       case $3
  473.       when "hp"
  474.         chara.hp.to_s
  475.       when "maxhp"
  476.         chara.maxhp.to_s
  477.       when "sp"
  478.         chara.sp.to_s
  479.       when "maxsp"
  480.         chara.maxsp.to_s
  481.       when "bmaxhp"
  482.         chara.base_maxhp.to_s
  483.       when "bmaxsp"
  484.         chara.base_maxsp.to_s
  485.       when "atk"
  486.         chara.base_atk.to_s
  487.       when "str"
  488.         chara.base_str.to_s
  489.       when "int"
  490.         chara.base_int.to_s
  491.       when "dex"
  492.         chara.base_dex.to_s
  493.       when "agi"
  494.         chara.base_agi.to_s
  495.       when "pdef"
  496.         chara.base_pdef.to_s
  497.       when "mdef"
  498.         chara.base_mdef.to_s
  499.       when "eva"
  500.         chara.base_eva.to_s
  501.       # Don't use any of the following or your game will asplode.
  502.       when "tp"
  503.         chara.tp.to_s
  504.       when "atk0"
  505.         chara.base_atk(0).to_s
  506.       when "atk1"
  507.         chara.base_atk(1).to_s
  508.       when "dmg0"
  509.         chara.basedmg(0).to_s
  510.       when "dmg1"
  511.         chara.basedmg(1).to_s
  512.       when "mdmg0"
  513.         chara.magdmg(0).to_s
  514.       when "mdmg1"
  515.         chara.magdmg(1).to_s
  516.       when "acc"
  517.         chara.base_acc.to_s
  518.       when "altdmg0"
  519.         chara.altbasedmg(0).to_s
  520.       when "altdmg1"
  521.         chara.altbasedmg(1).to_s
  522.       when "delay"
  523.         chara.delay.to_s
  524.       when "matk0"
  525.         chara.base_matk(0).to_s
  526.       when "matk1"
  527.         chara.base_matk(1).to_s
  528.       when "macc"
  529.         chara.base_macc.to_s
  530.       else
  531.         ""
  532.       end
  533.     end
  534.    
  535.     return text
  536.   end
  537.  
  538. end
Expand to see the code.


Setup
Here's a few pictures for you to use for the background:
Book graphic
First version of the book graphic in blinding white (Size is off by like 1 pixel)

And here's some crappy next/previous page pictures:
Image Image

Alright, onto the setup.
In Scene_Title, locate the following line:
$game_system = Game_System.new
In the default title, it should be on line 32.
Add this line right below it:
$game_system.load_quest_data

Next, stick the following anywhere below Game_Party:
  1. class Game_Party
  2.  
  3.   attr_accessor :quests
  4.  
  5.   alias eveningguvnr initialize
  6.   def initialize
  7.     eveningguvnr
  8.     @quests = Quest_List.new
  9.   end
  10.  
  11. end
Expand to see the code.


To call the quest window, simply use
Quest_Window.new(x, y, z, list key, selfupdate, mode)
x, y, and z are the coordinates, obviously.
Don't know what a list key is? Read the instructions below.
selfupdate and mode are optional.
If selfupdate is set to true, the window will function as it's own scene of sorts, meaning you could, say, call it from an event on the map without interrupting Scene_Map. If you don't know what that means, you'll probably want to have this set to true all the time.
mode is an array that lets you... 'skip' sections of the quest window.
Here's the various settings for it:
[0]
This is the default setting for the mode. It'll open up to the specified list.

[1, category key, headertext]
This will skip the category list and open up a category directly. 'headertext' is what will be displayed at the top of the first page. You still need to specify a list key, as it'll use that for formatting. Useful if you, say... don't want to use the category seperation feature. You'd be able to use a category as the entire quest log, if you wanted.

[2, quest key]
This will skip everything and jump right to a quest. Usefor for things like books or notes laying around.

Instructions
And this is the part where your head explodes. There's a whole crapload of stuff you can do with this, so I'll just go over the features and how to use them.
Creating Quests Spoiler
This is done in the Quest Data script. You can see an example of what the data for a quest will look like. You have complete control over everything displayed on the page when the quest is opened. It doesn't even need to be a quest, you could make some text for books, or put together a wanted poster on a wall, or really anything you can think of.
First, to create your quest, you need to pick out a unique key for it. The example quest uses "test quest". No other quest can have the same key, and you can name it whatever you want so it's more intuitive than just giving them numbers. For this example, let's use "wumpus" as the quest key. You'd start by adding the following line to the load_quest_data method:
$data_quests["wumpus"] = Quest_Data.new()

Now you can begin entering the data for your quest. The first thing to enter is the quest's name. This is what will be displayed ingame. We'll call this quest "Hunt the Wumpus":
$data_quests["wumpus"] = Quest_Data.new("Hunt the Wumpus",

The next two things to enter will be instructions for how the quest will look. See the "Instruction Types" section for detailed info.
The first of the two is the description section. The second of the two is the objective section. You don't need to put description only in the description section, and the objective section doesn't need to be used for objectives. Essentially, the two sections are identical, with one difference: The objective section has a 'stage' variable that you can change in-game to hide the objective or change what it does.
For our wumpus quest, we'll keep it simple and just use the first instruction type to write some text, and leave the objectives section blank:
$data_quests["wumpus"] = Quest_Data.new("Hunt the Wumpus", [[0, [0, [4, 4], "YOU MUST KILL THE WUMPUS"]]], []

The next part is for the quest variables. They don't need to be set up here, and you don't even need add this part. This section exists only to set what variables will start at when the quest is started. We'll leave it blank:
$data_quests["wumpus"] = Quest_Data.new("Hunt the Wumpus", [[0, [0, [4, 4], "YOU MUST KILL THE WUMPUS"]]], [])

And there you go, you've got the data for a simple wumpus-hunting quest set up. Or maybe it's just a note, or a flyer, who knows? You can use this for pretty much any kind of visual media in your game, whether you use the quest log functions or not.
Category Lists Spoiler
Quests are added to categories, and categories are added to category lists. You call the quest window and tell it what list to use, and it will display any categories in that list that have quests in them.
Even if you decide not to use the quest log functions, you'll still need to set up a list. They contain all the formatting information required by the script.
Here's how to set one up:

First, go to the quest handling script, and scroll down to the Quest_List class. See the '@lists[0] = Category_List.new' line? That's how you make a category list. There's more to it than that, though. That 0 is the list key. Like the quest key, it's a unique identifier for this particular list.
Now you have a number of different things you can customize for the list, the first of which being the categories it contains.
@lists[0].categories.push(["Category Name", category key])
Will add a category to the list. Category name would, of course, be the name of the category. Category key, just like the quest and list keys, is a unique identifier for a category. However, the categories themselves are not created just by adding them to a list. The list.categories just points towards the categories themselves. Don't worry too much about it, though, because the categories themselves are created automatically when quests are added to them. Any categories without quests in them won't show up, so add whatever categories you'll want to use in the future.

Onto the actual customization portion:
All of the following are accessed the same way, with @lists[key].xxxxxxx, where xxxxx would be the name of the option. So if you wanted to change the title of the list '0' above, you'd use @lists[0].title = ______. Let's begin.
title
This is what shows up at the top of the page where "Table of Contents" is in the screenshots. It's just a string.

font
This contains the default fonts, sizes, and colors for the list. It's set up as
[[Title Font, Size, Color], [List Font, Size, Color]]

background
An array holding the filename of the picture to use, and the x/y offsets for positioning it relative to the text. It's set up as
[filename, x offset, y offset]

windowskin
This is what windowskin the list will use. This pretty much just affects what the cursor will look like. It's just a string.

ipp
This is how many items will appear on each page of the list. If you muck with this, you'll likely have to change the formatting part below. It's an integer.

animation
This will control the page turning animations whenever I get around to making them. Currently it does nothing.

empty_text
This is what will be displayed if you have no categories with quests on the list. It's just a string.

audio
This is an array containing arrays containing the data on what sound effects to play for various things like flipping pages and moving the cursor. I forget how it's set up, but each element of the array is set up as ["Audio/SE/Filename", volume, pitch].
I know audio[2] is for the opening and closing of the list, but I forget the rest. Experiment with it a bit, you'll figure it out.

formatting
This controls the positioning and spacing of the items on the list. It's set up as
[distance between pages, distance between list items, width of one page, offset from top of page, cursor margin]

page_graphics
This is an array holding the filenames of the little arrows in the corner. It's set up as [filename for left arrow, filename for right arrow]



You can check the Category_List class if you need help with how it should be set up. Changing the settings in the actual class will change them for all lists that don't have the options set individually. In other words, they're the defaults.
Basic Use Spoiler
Alright, you've got some quests set up and a category list set up. So how do you start adding quests and all that stuff?
It's really rather easy once you get the hang of it.
First, I'll explain how the data is handled.
The entries in $data_quests don't contain the actual quest data, they're basically just cookie cutters that display the quest. When you add a quest to a category, it creates an actual data entry for the quest in $game_party.quests.quests. This is where the objective stages and quest variables are stored. You can access them any time in-game by using $game_party.quests.quests[quest key].stages[objective index]
and
$game_party.quests.quests[quest key].data[variable key]

You're probably confused at this point, but it's important to understand that before a quest has an entry in $game_party.quests.quests, it essentially does not exist in your saved data, which means you can't do anything with its objective stages or quest variables until it's been added. There's two ways to do this: You can use the 'add' method to add it to a category, or the 'add_quest' function to create just the quest data. More on that later.

Other than objectives and variables, you won't be able to view any quest that doesn't have an entry in $game_party.quests.quests. If you try to open the quest window directly to such a quest, it will explode.

While you're here, there is one more thing you need to do. See that '@settings = [0, 0]' line? That controls the settings for the message codes and instruction types. Specifically, for the drawing of battlers and the displaying of item quantities.
The first number is for item quantities. 0 is for my item grid system. You'll need to set this to 1 so it'll use the default inventory system. Otherwise, youre game will explode.
The second number is for the type of battlers you're using. 0 is for my animation system, and will make your game explode. Set this to 1 for minkoff's animated battlers, or 2 for the default battlers. Currently there is no code for the display of minkoff battlers, so don't be alarmed if it doesn't do anything yet. It'll be added in the next update.

Back to objectives and variables...
The 'objective index' above points to an objective. 0 would be the first objective, 1 would be the second, and so on.
The variable key is, like all the other keys, an identifier for a variable of the quest. You can only use alphanumeric characters for variable keys. If you use anything else, you won't be able to show the variable in the quest description using the message codes. These variables can be whatever you want, you could have say... a "cats ridden" variable that tracks how many cats you've ridden, for example.

It's really simple once you get the hang of it. Not so simple to explain. You'll get the hang of it. Probably.

Anyways, with that out of the way, let's go back to the basics: how to control the quests. There's a number of commands I've made to make it easier, and they handle a lot of the checks and data creation for you.
All are accessed with $game_party.quests._________
Let's begin:
has_quest(quest key)
This will return true if the quest has a data entry. You can use this to check if a quest has been accepted, or to prevent the aforementioned explosion from trying to view a quest with no data entry.

add(quest key, category key)
This will add a quest to a category. It will also create a data entry for the quest if it doesn't already have one. The quest will be viewable from any lists that have the category key in their categories setting.

add_quest(quest key)
This will create a data entry for a quest if it doesn't already have one.

remove(quest key, category key)
This will remove a quest from a category. It will not remove the quest's data entry.

remove_quest(quest key, erase)
This will remove a quest from ALL categories. It will not remove the quest's data entry unless 'erase' is set to true. 'erase' is entirely optional, and not including it is the same as setting it to false.

reset_quest(quest key, create)
This will blank out a quest's variables and objectives, returning them to the default values. It will not remove it from any categories. If 'create' is set to true, this command will create a data entry if called on a quest that doesn't have one. 'create' is optional, and not including it is the same as calling it as true.

replace(new quest, old quest, category key)
This will replace one quest with another on a category. It will take the old quest's spot on the list, so the order will stay the same. It does not touch the quest data at all. Useful for when a quest requires a large update, and you want it to look like the same quest.

erase_list(category key)
This will erase a category. It will not erase any quest data for the quests within. Almost entirely useless, you can use this to veeeeery slightly lower the size of your savefiles by erasing lists that are no longer needed.

create_list(category key)
This will create a category. Entirely useless since this is done automatically whenever it's needed.

Instruction Types Spoiler
For quest layout, that is. Descriptions and objectives use a list of these to put together the quest. For the most part, they're pretty much the same for descriptions and objectives. Objectives just have an added stage variable and a some parts are turned into arrays.
The basic layout for an instruction is as follows:
[type, [data]]
For objectives, there's an added stage variable:
[type, stage, [data]]
'stage' would be whatever you want the stage to start at. 0 is hidden, 1 displays the first entry, 2 displays the second, and so on. Objectives can have as many stages as you want.

And with that, here's the type numbers and data format:
Any options marked with a * are optional.
'page' refers to the pair of pages it will appear on, i.e. 1 would refer to page 3 and 4. This means you can have thigns spanning multiple pages, so you could use it for books and whatnot.
Type 0 - Draw Text
This draws text, obviously.
Descriptions:
[0, [page, [x, y], text, alignment*, color*, size*, font*]]
Objectives:
[0, stage, [page, [x, y], [stage1 text, stage2 text, etc.], alignment*, color*, size*, font*]]
Pretty self-explanatory. The text can make use of message codes, detailed in the 'message codes' section.

Type 1 - Graphic
This displays either an icon or a picture.
Descriptions:
[1, [page, [x, y, zoom_x*, zoom_y*, opacity*], [type, filename]]]
Objectives:
[1, stage, [page, [x, y, zoom_x*, zoom_y*, opacity*], [[stage1 type, stage1 filename], [stage2 type, stage2 filename], [etc., etc.]]]]
'type' is either 0 or 1. 0 will load an icon, 1 will load a picture. zoom_x and zoom_y are multipliers, i.e. a zoom_x of 1.2 will make the image 20% wider.

Type 2 - Draw Battler
This will draw an actor's battler.
For default battlers:
Descriptions:
[2, [page, [x, y, opacity*], [type, id]]]
Objectives:
[2, stage, [page, [x, y, opacity*], [[stage1 type, stage1 id], [stage2 type, stage2 id], etc.]]]
'type' is either 0 or 1. 0 will load actors, 1 will load enemies. ID is the database id.

For Minkoff battlers:
Descriptions:
[2, [page, [x, y, opacity*], [type, id], pose#, frame]]
Objectives:
[2, stage, [page, [x, y, opacity*], [[stage1 type, stage1 id], [stage2 type, stage2 id], etc.], [stage1 pose#, stage2 pose#, etc.], [stage1 frame, stage2 frame, etc.]]]
'type' is either 0 or 1. 0 will load actors, 1 will load enemies. ID is the database id.
If the battler is set up to use a default battler, pose and frame can be skipped.
You can enter an opacity to use, but if the battler is added to MNK_TRANSLUCENT_WHATEVER, then it'll use the MNK_TRANSLUCENCY thingy setting.

Type 3 - Draw Characterset
This will draw a specified character, or an actor's characterset.
Descriptions:
[3, [page, [x, y, opacity*], [type, data], [frames, directions, facing, frame#]]]
Objectives:
[3, stage, [page, [x, y, opacity*], [[stage1 type, stage1 data], [stage2 type, stage2 data], [etc., etc.]], [[stage1 frames, directions, facing, frame#], [stage 2 frames, directions, facing, frame#], etc.]]]
'type' is either 0 or 1. 'data' depends on which type you use:
For type 0, it will use an actor's characterset, formatted like so: [0, actor id]
For type 1, it will use the specified characterset, formatted like so: [1, "filename", hue number]
frames is how many animation frames the characterset has (typically 4)
directions is how many directions the characterset has (typically 4 or 8)
facing is which direction will be displayed. It does not correspond to the actual directions, but to how far down the characterset it is, i.e. on a default 4dir characterset (dirs = [2, 4, 6, 8]), you'd enter 0 for down, 1 for left, 2 for right, and 3 for up.
frame# is what frame of the walking animation will be displayed.
Message Codes Spoiler
There's three codes for use in quest and category names, and a bunch others for description and objective text. All you do is include the code in the text, and it'll replace it with various things or change various settings.

Quest/Category Name Codes
These control the font for quest and category names. They'll be used in place of the list's default settings. You can use this to, say, use a handwriting-ish font to make it look like a note was scrawled in, or something.
\\fn[number]
This will change the font. You'll have to set up what number goes with what font in the 'title_fonts' method at the very bottom of the Quest Window script.

\\fs[number]
This will change the size of the font.

\\fc[r,g,b]
This will change the color of the font. r, g, b corresponds to red, green, and blue levels.

Description/Objective Codes
These can be used to display a wide variety of data.
\\v[n]
This will display $game_variables[n]

\\s[n,on,off]
This will display the state of $game_switches[n].
If the switch is true, it will display the 'on' text. Otherwise, it will display the 'off' text.
Example: "The gate is \\s[3,open,closed]."
Alphanumerics only, by the way.

\\g
This will display the amount of gold the party has.

\\qv[key]
This will display one of the quest's variables. 'key' would be the variable key, obviously. This is why I suggested only using alphanumerics in the variable keys, as you won't be able to display any that use other characters.

\\item[n]
\\weapon[n]
\\armor[n]
\\skill[n]
\\actor[n]
\\enemy[n]
\\class[n]
These will display the item/skill/class/etc. names. n would be the id.

\\aclass[id]
This will display the name of $game_actor[id]'s class.

\\held[type,id]
This will display the quantity of an item/weapon/armor.
type is 0 for items, 1 for weapons, and 2 for armors. id is, of course, the id.

\\stat[type,id,stat]
This will display an actor/enemy's stats.
For type, enter one of the following:
0: Will use $game_party.actors[id]
1: Will use $game_actors[id]
2: Will use $data_enemies[id]
For id, enter the party index (if you're using type 0), or the database ID.
For stat, you can use any of the following:
hp, maxhp, sp, maxsp, bmaxhp, bmaxsp, atk, str, int, dex, agi, pdef, mdef, eva
It's typed in exactly like that.
For example, \\stat[1,2,bmaxhp] would display Basil's base max hp.
If you look at the code, you'll notice a whole bunch more stats listed. Don't use them or your game will explode.
Also, hp, maxhp, sp, and maxsp will likely not work with enemies.

WELL THAT ONLY TOOK THREE HOURS TO WRITE
...
It's really easy to use, but really hard to understand at first.

If anyone feels like writing a better set of instructions, go for it.

Screenshots
Category List Spoiler
Image

Quest List Spoiler
Yeah, with 1 quest.
Image

Quest Description Spoiler
I was testing various things, okay?
Image

v2.1.0 New Features Spoiler
Battlers, item quantities, and ability to be called from any scene.
Image



Demo
Now with several examples of the various things you can do!
(And it still doesn't cover everything possible!)
http://www.mediafire.com/download.php?zj0lm3nj3fk


Terms of Use
You can use it or repost it wherever you want, just make sure to credit me.
If you complain about the images, I will punch you in the face.
If you refuse to try it because you don't like the images and don't feel like making your own, I will punch you again, only harder.
Lastly, I would love to see the kinds of ideas people come up with for this.

Special thanks to DerVVulfman for support, suggestions, and encouraging me to make something that runs outside of Ninja Penguin.
I love the look and implentation of this. It's a lot nicer than other quest scripts I've seen (although there aren't that many out there). If I still used RMXP and other people's scripts I'd probably use this.
Miss Jaber, this Quest Log of yours can also be converted into a "bestiary"-type or [[Resident Evil-ish File stuff]]. Of course, a few tweaks will make conversion easier ^_^

Good job by the way!

About your old Quest System, I also liked it, almost perfect if the game you're working is on modern to futuristic setting such that instead of books, we have blogs!
Thanks o_o/
I mostly rewrote it because my old quest log was this horrible massive array thing full of loops and stuff ._.;
Wait, I'm actually referring to your old one when the quest background is still a scroll. I wonder if you can still refine it, so that it can be perfectly suitable for games set in modern times.

:boo:
You could just change the background with a computer screen instead of a book/scroll, couldn't you?
Oh yeah, I did, that's when I was still working on my old game during its Gamma test:

Image
That looks pretty neat, actually o_o
Maybe I'll make a verson that uses the new quest formatting with the old layout.
A bestiary is also a pretty neat idea o_o Guess I'll have to go add in an option to display an enemy's battler, too.
Or even the book-thing that Resident Evil does...

I think it was an old script that went away in the typhoon or something...
Demo with changeable windowskin, please!
...what?
The only part of the windowskin it uses is the cursor, and it already supports different windowskins for different category lists >.>

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=68769