Advertisement
modern_algebra

Quest Journal 2.0a

May 1st, 2011
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 85.79 KB | None | 0 0
  1. #==============================================================================
  2. #    Quest Journal
  3. #    Version: 2.0a
  4. #    Author: modern algebra (rmrk.net)
  5. #    Date: May 5, 2011
  6. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  7. #  Description:
  8. #
  9. #    This script provides a graphical interface for showing quest progress. It
  10. #   is objective based, meaning that you choose when to reveal objectives and
  11. #   you can set it so that they show up as complete or failed. That said, this
  12. #   script does not build quests for you; it is only a supplementary scene for
  13. #   showing them. As such, you need to event all of the quests yourself and use
  14. #   update quest progress via script call. Therefore, pay close attention to
  15. #   the instructions both here and in the EDITABLE REGIONS.
  16. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  17. #  Instructions:
  18. #
  19. #    As with the previous version, all of the configuration is done in the
  20. #   QuestData module. While it is not necessary, it is recommended that you
  21. #   separate the configuration module from the rest of the script by cutting
  22. #   and pasting it into its own section (as you will see if you have the demo).
  23. #   If you wish to do that, you must cut everything from the first line down to
  24. #   the final end of the module. The first lines of the body script should be
  25. #   the equals bar right above # ** Game_Quest. Again, that is only to make
  26. #   things neater and has no functional relevance; it's up to you.
  27. #
  28. #    That said, you can go to EDITABLE REGION A at line 217 to configure the
  29. #   default settings for the script. This ranges from the functional settings
  30. #   at line 219 (such as whether access is from the menu or the map or which
  31. #   categories are shown in the scene) to the graphical settings at line 242
  32. #   (such as which icons to use for categories and what names should be given
  33. #   to various headings). Even if do not want to configure now, you should
  34. #   familiarize yourself with all the settings so that you can make the best
  35. #   use of the script. A brief description of each setting is included either
  36. #   to the left or directly above each constant.
  37. #
  38. #    EDITABLE REGION B is the real heart of the script however - this is where
  39. #   you fill in all of the details for the quests. Read the instructions at
  40. #   line 328 very carefully!
  41. #
  42. #    You can activate and access a quest with this code in the Script event
  43. #   command:
  44. #
  45. #        quest (quest_id)
  46. #          quest_id : the integer ID of the quest you want to access
  47. #
  48. #   From that, you can access or alter any relevant data stored in the quest,
  49. #   like name, description, objectives, etc... Example:
  50. #         quest (1).name = "Rest in Peace"
  51. #
  52. #    More relevantly, when it comes to controlling the progress of quests the
  53. #   following codes can be used in a Script event command. The arguments are
  54. #   the same for each command so I only explain them once. All of them are
  55. #   pretty self-explanatory and using any of them will activate the quest.
  56. #    
  57. #        reveal_objective (quest_id, objective_id_1, ..., objective_id_n)
  58. #            quest_id : the integer ID of the quest you want to access.
  59. #            objective_id_1, ..., objective_id_n : a list of the IDs of the
  60. #              objectives you want to operate on. It can be as few as one or as
  61. #              many as all of them.
  62. #          Will show the listed objectives in the Quest's information
  63. #        conceal_objective (quest_id, objective_id_1, ..., objective_id_n)
  64. #          Will hide the listed objectives in the Quest's information
  65. #        complete_objective (quest_id, objective_id_1, ..., objective_id_n)
  66. #          Changes the colour of the listed objectives to the completed colour.
  67. #          The quest is completed once all prime objectives are.
  68. #        uncomplete_objective (quest_id, objective_id_1, ..., objective_id_n)
  69. #          Changes the status of the listed complete objectives back to active
  70. #        fail_objective (quest_id, objective_id_1, ..., objective_id_n)
  71. #          Changes the colour of the listed objectives to the failed colour.
  72. #          The quest is failed once one prime objective is.
  73. #        unfail_objective (quest_id, objective_id_1, ..., objective_id_n)
  74. #          Changes the status of the listed failed objectives back to active
  75. #        change_reward_status (quest_id, value)
  76. #            value : either true or false. If excluded, defaults to true.
  77. #          Totally optional, but this is just a personal switch which you can
  78. #          turn on when the reward is given. You can then make it a condition
  79. #          so you don't reward the players more than once. (see line 143)
  80. #
  81. #  EXAMPLES:
  82. #    reveal_objective (1, 0)
  83. #      This would reveal the first objective of the quest with ID 1
  84. #    complete_objective (6, 2, 3)
  85. #      This would complete the third & fourth objectives of the quest with ID 6
  86. #    change_reward_status (8)
  87. #      This would set the reward switch to true for the quest with ID 8.
  88. #
  89. #    Other codes for the Script event command that can be useful are:
  90. #    
  91. #        reset_quest (quest_id)
  92. #            quest_id : the integer ID of the quest you want to access.
  93. #          This will re-initialize the quest, meaning all quest progress to
  94. #          date will be lost
  95. #        remove_quest (quest_id)
  96. #          Deactivates the quest and resets it
  97. #        conceal_quest (quest_id)
  98. #          Deactivates the quest so it won't show up in the scene, but progress
  99. #          is saved
  100. #        reveal_quest (quest_id)
  101. #          Activates or reactivates the quest. This command is NECESSARY if
  102. #          MANUAL_REVEAL at line 238 is true or it has previously been
  103. #          concealed. Otherwise, it is sufficient just to operate on the quest
  104. #        change_quest_access (:symbol)
  105. #          :symbol must be one of six options (include the colon!):
  106. #            :disable - prevents access to the quest scene (greys out in menu)
  107. #            :enable - enables access to the quest scene
  108. #            :disable_menu - this removes the quest option from the menu
  109. #            :enable_menu - this adds the quest option to the menu
  110. #            :disable_map - this prevents access by key from the map
  111. #            :enable_map - this allows access by key to the map
  112. #        change_quest_background ("bg_filename", bg_opacity)
  113. #            bg_filename : the filename of the picture for the background in  
  114. #              the Pictures folder
  115. #            bg_opacity  : the opacity of the background graphic. If excluded,
  116. #              this defaults to the value of the setting at line 244.
  117. #        change_quest_windows ("windowskin_filename", window_opacity)
  118. #            windowskin_filename : the name of the Window graphic in System folder
  119. #            window_opacity : the opacity of the windows. If excluded, this
  120. #              defaults to the value of the setting at line 246.
  121. #
  122. #    Also, there are a few codes that can be used in the Script command of a
  123. #   conditional branch. I note here that all of these are optional. You could
  124. #   use switch and variable checks and monitor quest progress solely through
  125. #   events. However, these commands make it a little easier and they are:
  126. #
  127. #        quest_revealed? (quest_id)
  128. #            quest_id : the integer ID of the quest you want to access.
  129. #          This is satisfied if the quest has been activated.
  130. #        objective_revealed? (quest_id, objective_id_1, ... objective_id_n)
  131. #            objective_id_1, ..., objective_id_n : a list of the IDs of the
  132. #              objectives you want to operate on. It can be as few as one or as
  133. #              many as all of them.
  134. #          This is satisfied if the listed objectives have been revealed
  135. #        quest_complete? (quest_id)
  136. #          This is satisfied if all prime objectives of the quest are complete
  137. #        objective_complete? (quest_id, objective_id_1, ... objective_id_n)
  138. #          This is satisfied if all the listed objectives have been completed
  139. #        quest_failed? (quest_id)
  140. #          This is satisfied if any prime objective of the quest is failed
  141. #        objective_failed? (quest_id, objective_id_1, ... objective_id_n)
  142. #          This is satisfied if all the listed objectives have been failed
  143. #        quest_rewarded? (quest_id)
  144. #          This is satisfied if you have changed the reward status to true.
  145. #
  146. #    If you want to call the Quest scene from an event, you use the following
  147. #   code in a call script:
  148. #
  149. #        call_quest
  150. #        call_quest (quest_id)
  151. #          quest_id : ID of the quest you want to open the scene on
  152. #
  153. #  If you do not specify a quest_id (line 149) then it will simply open the
  154. #  scene as it would normally. If you do specify a quest_id (line 150) then it
  155. #  will open the scene on that quest so long as it has been revealed and it is
  156. #  normally accessible through the quest menu.
  157. #
  158. #   Finally, a new feature in version 2.0 is the ability to have quest shops
  159. #  where the player can pay money to have a quest revealed. Setting it up is a
  160. #  little more complicated as it is all done in the script call and so you need
  161. #  to be careful not to spill over lines. Essentially, to identify the
  162. #  purchable quest you need to create an array like this:
  163. #      [quest_ID, cost, [o1, o2, ..., on], switch_ID]
  164. #          quest_ID      : ID of the quest available for purchase
  165. #          cost          : the price to buy the quest
  166. #          [o1, ..., on] : an array of the objectives revealed when the quest
  167. #            is purchased. If you exclude this, all objectives are revealed.
  168. #          switch_ID     : this is the ID of a switch. When that switch is ON
  169. #            the quest will be available for purchase. Otherwise it won't. If
  170. #            excluded, the quest will always be available for sale at this shop
  171. #   You need one of those for every quest available at the shop and you put
  172. #   them all in another array and you pass it to the following code:
  173. #
  174. #      call_quest_shop (quest_array, "ShopName")
  175. #          quest_array : the array of the above elements
  176. #          "ShopName"  : the name of the shop. Allows you to differentiate
  177. #             quest givers (defaults to the value at line 301 if excluded).
  178. #
  179. #   All of that is further complicated by the line length limit in the script
  180. #   command. In order to avoid this, it is better to create the array before
  181. #   calling the shop. See the example for how this can be done.
  182. #
  183. #  EXAMPLE:
  184. #    a = []
  185. #    a.push ([1, 50, [0]], [4, 80, 1])
  186. #    a.push ([3, 100], [5, 75, [0,1], 1])
  187. #    call_quest_shop (a, "Fighter's Guild")
  188. #
  189. #  The first line creates the array. The second line adds two quests to it: the
  190. #  quest with ID 1 will cost 50 Gold and, if purchased, will reveal the first
  191. #  objective; the quest with ID 4 will cost 80 Gold but will only show up if
  192. #  the switch with ID 1 is ON. It will reveal all objectives when purchased.
  193. #  The third line adds two more quests: the quest with ID 3 will cost 100 Gold
  194. #  and all objectives will be revealed when it is purchased; the quest with ID
  195. #  5 will cost 75 gold but will only show up when switch 1 is ON. If purchased,
  196. #  it will reveal the first two objectives.
  197. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  198. #  Compatibility:
  199. #
  200. #    This script automatically adds itself to the default menu if you turn that
  201. #   feature on. It will also automatically add itself to the menu if you are
  202. #   using Yanfly's YEM Main Menu Melody, my Full Status Custom Menu System, or
  203. #   my Phantasia-esque Custom Menu System. It must be below them though!
  204. #==============================================================================
  205.  
  206. $imported = {} unless $imported
  207. $imported["QuestJournal2"] = true
  208.  
  209. #==============================================================================
  210. # *** Quest Data
  211. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  212. #  This is the configuration module for the Quest Journal
  213. #==============================================================================
  214.  
  215. module QuestData
  216.   #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  217.   #    EDITABLE REGION A
  218.   #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  219.   # Functional Configuration
  220.   # CATEGORIES - this is an array describing which categories are available for
  221.   #   the Quest Journal and the order in which they appear. The options are
  222.   #   :all, :active, :complete, and :failed. You can also create custom
  223.   #   categories which include only quests that are specifically added. To do
  224.   #   so, just make up a symbol name (:name, so like :primary or :secondary or
  225.   #   :companion or etc...) and add it to the array. Then, go to line 248 and
  226.   #   associate an icon with the SAME symbol. Then, when you are setting up the
  227.   #   quests at line 323, all you need to do is add that SAME symbol to the
  228.   #   custom_categories attribute
  229.   CATEGORIES = [:all, :active, :complete, :failed]
  230.   # SORT_TYPE - This is how the quests are sorted. This value can be :id (sort
  231.   #   by ID), :revealed (sort by order they were revealed), :alphabet (sort
  232.   #   alphabetically by name), or :none
  233.   SORT_TYPE = :revealed    
  234.   MENU_ACCESS = true        # Can the script be accessed through the menu?
  235.   MENU_INDEX = 4            # If above is true, where in the command window?
  236.   KEY_ACCESS = false        # Can the quest log be accessed by a key        
  237.   MAPKEY_BUTTON = Input::L  # If above is true, which button?
  238.   # MANUAL_REVEAL - whether you need to manually reveal every quest with the
  239.   #  reveal_quest command or whether they are automatically revealed as soon as
  240.   #  they are operated on (I.e. when you reveal, complete, etc.. objectives)
  241.   MANUAL_REVEAL = false    
  242.   # Graphical Configuration
  243.   BG_PICTURE = ""           # The filename of the background picture
  244.   BG_OPACITY = 255          # The opacity of the background picture, if used
  245.   WINDOWS_SKIN = "Window"   # The skin of the windows in the Quest Scene
  246.   WINDOWS_OPACITY = 200     # The opacity of the windows in the Quest scene
  247.   LIST_WIDTH = 184          # The width, in pixels, of the left-hand windows
  248.   # ICONS - here is where you set up what icons are used for various things in
  249.   #  the script, like categories, gold, exp, or even for the menu option if you
  250.   #  are using one of the supported CMSes. If you have added custom categories
  251.   #  at line 220, then you should also add a line for each of the new categories
  252.   #  under the same format. Don't forget the comma at the end!
  253.   ICONS = {                
  254.     :all => 0,              # If 0, combines :active, :complete, and :failed
  255.     :active => 149,         # Icon representing active quest list
  256.     :complete => 150,       # Icon representing complete quest list
  257.     :failed => 179,         # Icon representing failed quest list
  258.     :menu => 178,           # Quests icon if using one of the supported CMSes
  259.     :gold => 147,           # Icon for gold if used as a reward
  260.     :exp => 133,            # Icon for exp if used as a reward
  261.   }
  262.   # For the following colours, you can use either an integer, in which case it
  263.   # takes its colour from that index of the windowskin palette, or you can use
  264.   # an array in the form [Red, Green, Blue, Alpha] (Alpha can be excluded)
  265.   ACTIVE_COLOUR = 0         # The colour of a quest that is active
  266.   COMPLETE_COLOUR = 3       # The colour of a quest that is complete
  267.   FAILED_COLOUR = 10        # The colour of a quest that is failed
  268.   VOCAB_QUESTS = "Quests"   # What you want Quests to be called (eg. 'Missions')
  269.   # LABEL_FONTNAME - The name of the font used for the label window. If "" or
  270.   #  [], then it just uses the default font.
  271.   LABEL_FONTNAME = ""
  272.   # LABEL_FONTSIZE - The size of the text in the label window. When 0, it will
  273.   #   be automatically fitted to the window size (since it is dynamic)
  274.   LABEL_FONTSIZE = 0        
  275.   LABEL_BOLD = false        # Whether the label should be bold
  276.   INFO_SHOW_NAME = true     # Whether to show the quest's name on info window
  277.   # SUBTITLE FONTNAME - The font used for the subtitles in the info window
  278.   # (The subtitles are: Description, Objectives, Rewards)
  279.   SUBTITLE_FONTNAME = ""  
  280.   SUBTITLE_BOLD = true      # Whether to embolden the subtitles
  281.   SUBTITLE_COLOR = 16       # The color for the subtitles
  282.   VOCAB_DESCRIPTION = "Description" # The word to identify the description text
  283.   DESC_FONTSIZE = 20        # The size of the font used in the description
  284.   VOCAB_OBJECTIVES = "Objectives" # The word to identify the objectives list
  285.   OBJECTIVE_BULLET = "●"    # The character used for listing objectives
  286.   OBJ_FONTSIZE = 20         # The size of the font used for objectives
  287.   VOCAB_REWARDS = "Rewards" # The word to identify the Rewards list
  288.   REWARD_BULLET = ""        # The character used for listing rewards
  289.   REWARD_FONTSIZE = 20      # The size of the font for each reward
  290.   ITEM_NUMBER_PREFACE = "x" # When reward amount > 1, this prefaces it.
  291.   VOCAB_EXP = "EXP"         # The word used for experience, if used in rewards
  292.   DRAW_VOCAB_GOLD = true    # Whether to draw the Gold vocab or only use icon
  293.   # VOCAB_HELP_GENERAL - The phrase in the help window when the list is active
  294.   VOCAB_HELP_GENERAL = "Use the horizontal directional keys to switch categories"
  295.   # VOCAB_HELP_SELECTED - The phrase in the help window when info is active
  296.   VOCAB_HELP_SELECTED = "Use the vertical directional keys to scroll up and down"
  297.   # Alignment of text in the Help Window - 0 => Left; 1 => Centre; 2 => Right
  298.   HELP_ALIGNMENT = 1        
  299.   JUSTIFY_PARAGRAPHS = true # Whether Description/objectives are justified.
  300.   # Quest Shop Configuration
  301.   VOCAB_PURCHASE = "Quest Shop"    # What you want the shop to be called
  302.   PURCHASE_USE_GOLD_ICON = true    # Whether to use gold icon in Quest Shop
  303.   PURCHASE_SHOW_OBJECTIVES = false # Whether to conceal the objectives or not
  304.   PURCHASE_SE = ["Shop", 80]       # The sound played when a quest is bought
  305.   PURCHASE_LIST_WIDTH = 224        # The list width for the purchase scene
  306.   #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  307.   #    END EDITABLE REGION A
  308.   #////////////////////////////////////////////////////////////////////////////
  309.   ICONS.default = 0
  310.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  311.   # * Quest Data
  312.   #````````````````````````````````````````````````````````````````````````````
  313.   #  Returns skeleton data for the quest
  314.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  315.   def self.quest_data (id)
  316.     # Set class variables to corresponding arguments
  317.     banner = ""
  318.     name = "??????"
  319.     description = "??????????"
  320.     objectives = []
  321.     prime = nil
  322.     rewards = []
  323.     common_event = 0
  324.     icon_index = 0
  325.     custom_categories = []
  326.     case id
  327.     #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  328.     #    EDITABLE REGION B
  329.     #````````````````````````````````````````````````````````````````````````
  330.     #  To set up a quest, first identify it with an ID - this can be anything
  331.     #  as long as it is not the same as another quest, but it is important to
  332.     #  remember this ID as it is the only way to access your quest.
  333.     #    In any case, the format for setting up a quest is:
  334.     #
  335.     #      when <quest_id> # Give the quest an ID number
  336.     #        banner = "filename"
  337.     #        name = "quest_name"
  338.     #        description = "quest_description"
  339.     #        objectives[0] = "first_objective"
  340.     #        ...
  341.     #        objectives[n] = "(n - 1)th objective"
  342.     #        prime = [objective_id, ..., objective_id]
  343.     #        rewards = [ [type, id, amount], ..., [type, id], "text" ]
  344.     #        common_event = id
  345.     #        icon_index = quest_icon_index
  346.     #        custom_categories.push (:symbol_1, ..., :symbol_n)
  347.     #
  348.     #    Each of these values have an importance.
  349.     #      banner is the name of a picture that can be shown at the top
  350.     #      name is the name of the quest
  351.     #      description is a small blurb explaining the overall goal of the quest
  352.     #      objective[0..n] are short-term goals that lead to the overall goal
  353.     #      primes are which objectives need to be complete before the quest is
  354.     #        considered to be complete
  355.     #      rewards will list the items you suggest. Note that there is no
  356.     #        automatic gain - it simply lists them in the scene - you will need
  357.     #        to give them out. The format is simple, [type, id, amount] where
  358.     #        type identifies whether it is an item (0), weapon (1), armor (2),
  359.     #        gold (3), or exp (4). id is the item ID (or the amount of gold or
  360.     #        exp). amount only applies if it is an item, weapon or armor and it
  361.     #        is how much of the item is given. If excluded, it won't draw it at
  362.     #        all but if it is included, it will draw even if only 1. You can
  363.     #        also just put a string ("text") and it will write that out.
  364.     #      common_event is the ID of a common event which is immediately called
  365.     #        when the quest is first completed.
  366.     #      icon_index is the icon that represents the quest
  367.     #      custom_categories is a new feature which allows you to define which
  368.     #        quests belong in special categories. All you need to do is add the
  369.     #        appropriate symbol (which corresponds to an included category at
  370.     #        line 229) and it will be added. Then, when the player scrolls over
  371.     #        to that category, this quest, if revealed, will be there.
  372.     #
  373.     #    Note that any of the above values can be omitted without throwing an
  374.     #    error, but for the quest to work properly you should at least set the
  375.     #    name, description, and objectives. If you do omit these, the default
  376.     #    values are:
  377.     #  
  378.     #      banner = ""
  379.     #      name = "??????"
  380.     #      description = "??????????"
  381.     #      objectives = []
  382.     #      prime = [all objectives]
  383.     #      rewards = []
  384.     #      common_event = 0
  385.     #      icon_index = 0
  386.     #      custom_categories = []
  387.     #
  388.     #   If you do want to require that all objectives must be satisfied before
  389.     #   the quest is complete, then do not bother defining it. Otherwise, be
  390.     #   sure to set it. If you are using the Special Codes Formatter, recall
  391.     #   that all codes must be prefaced with \\, not just \.
  392.     #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  393.     when 1 # Quest 1
  394.       name = "Quest 1"
  395.       banner = "" # If using, must be a file from the Pictures folder
  396.       description = "This is the first quest the players receive. It probably involves playing fetch with lazy humans."
  397.       objectives[0] = "The first objective (ID 0)"
  398.       objectives[1] = "Do this next (ID 1)"
  399.       objectives[2] = "Return to collect your reward"
  400.       prime = [0, 1] # You only need to complete the first two objectives.
  401.       rewards = [ [0, 1, 3], [3, 100] ] # A potion and 100 Gold
  402.       common_event = 0
  403.       icon_index = 212
  404.       custom_categories = []
  405.     when 4 # Quest 4 <- Remember: Quest IDs MUST be unique!
  406.       name = "Lovely Lucy"
  407.       description = "Pursue the affections of \\c[6]Lucy\\c[0]"
  408.       objectives[0] = "Buy her a present from the vendor"
  409.       objectives[1] = "Take her out to dinner"
  410.       objectives[2] = "Walk her back to her home"
  411.       rewards = [ [4, 50], "\\icon[137]A kiss from Lucy" ]
  412.       icon_index = 77
  413.       # Note that anything I don't want, like banner, prime, common_event, and
  414.       # custom_categoris, I can exclude and it wll resort to default ("",
  415.       # [0, 1, 2], 0, and [])
  416.     #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  417.     #    END EDITABLE REGION B
  418.     #////////////////////////////////////////////////////////////////////////
  419.     end
  420.     unless prime
  421.       prime = []
  422.       objectives.each_index { |i| prime.push (i) }
  423.     end
  424.     return banner, name, description, objectives, prime, rewards, common_event,
  425.       icon_index, custom_categories
  426.   end
  427. end
  428.  
  429. #==============================================================================
  430. # ** Game_Quest
  431. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  432. #  Holds in-game data for a quest
  433. #==============================================================================
  434.  
  435. class Game_Quest
  436.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  437.   # * Public Instance Variables
  438.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  439.   attr_accessor :id                  # The ID in $game_party.quests
  440.   attr_accessor :banner              # Picture shown at top
  441.   attr_accessor :name                # The name of the quest
  442.   attr_accessor :description         # A blurb explaining the quest
  443.   attr_accessor :objectives          # An array of strings holding objectives
  444.   attr_accessor :prime_objectives    # An array of crucial objectives
  445.   attr_accessor :rewards             # An array of reward components
  446.   attr_accessor :common_event_id     # ID of common event called at completion
  447.   attr_accessor :icon_index          # The Icon associated with this quest
  448.   attr_accessor :revealed_objectives # An array of revealed objectives
  449.   attr_accessor :complete_objectives # An array of completed objectives
  450.   attr_accessor :failed_objectives   # An array of failed objectives
  451.   attr_accessor :custom_categories   # An array of category symbols
  452.   attr_accessor :reward_given        # A switch to ensure only one reward given
  453.   attr_accessor :concealed           # A switch to show or not show the quest
  454.   attr_accessor :cost                # The cost (if in a quest shop)
  455.   # Rewarded?
  456.   alias rewarded? reward_given
  457.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  458.   # * Object Initialization
  459.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  460.   def initialize (id, cost = -1)
  461.     @id = id
  462.     @cost = cost
  463.     reset
  464.   end
  465.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  466.   # * Reset
  467.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  468.   def reset
  469.     # Set variables to corresponding arguments
  470.     @banner, @name, @description, @objectives, @prime_objectives, @rewards,
  471.       @common_event_id, @icon_index, @custom_categories = QuestData.quest_data (id)
  472.     # Initialize non-public arrays
  473.     @revealed_objectives = []
  474.     @complete_objectives = []
  475.     @failed_objectives = []
  476.     @reward_given = false
  477.     @concealed = QuestData::MANUAL_REVEAL
  478.   end
  479.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  480.   # * Reveal Objective
  481.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  482.   def reveal_objective (*obj)
  483.     for i in obj do obj.delete (i) if i >= @objectives.size end
  484.     @revealed_objectives |= obj # Add to revealed objectives
  485.     @revealed_objectives.sort! # Sort from lowest index to highest index
  486.   end
  487.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  488.   # * Complete Objective
  489.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  490.   def complete_objective (*obj)
  491.     for i in obj
  492.       # Can't complete if failed or non-existent
  493.       obj.delete (i) if i >= @objectives.size || @failed_objectives.include? (i)
  494.       # Reveal the objective if it was not previously revealed
  495.       reveal_objective (i) unless @revealed_objectives.include? (i)
  496.     end
  497.     @complete_objectives |= obj # Add to complete objectives
  498.     @complete_objectives.sort! # Sort from lowest index to highest index
  499.     if complete?
  500.       $game_temp.common_event_id = @common_event_id # Call common event
  501.       @common_event_id = 0 # Don't call it again
  502.     end
  503.   end
  504.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  505.   # * Fail Objective
  506.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  507.   def fail_objective (*obj)
  508.     for i in obj
  509.       obj.delete (i) if i >= @objectives.size
  510.       # Reveal the objective if it was not previously revealed
  511.       reveal_objective (i) unless @revealed_objectives.include? (i)
  512.     end
  513.     @failed_objectives |= obj # Add to revealed objectives
  514.     @failed_objectives.sort! # Sort from lowest index to highest index
  515.   end
  516.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  517.   # * Undo Objective operations
  518.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  519.   def conceal_objective (*obj)
  520.     obj.each { |index| @revealed_objectives.delete (index) }
  521.   end
  522.   def uncomplete_objective (*obj)
  523.     for i in obj do @complete_objectives.delete (i) end
  524.   end
  525.   def unfail_objective (*obj)
  526.     for i in obj do @failed_objectives.delete (i) end
  527.   end
  528.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  529.   # * Objective Status Checks
  530.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  531.   def objective_revealed? (*obj)
  532.     return (obj - @revealed_objectives).empty?
  533.   end
  534.   def objective_complete? (*obj)
  535.     return (obj - @complete_objectives).empty?
  536.   end
  537.   def objective_failed? (*obj)
  538.     return (obj - @failed_objectives).empty?
  539.   end
  540.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  541.   # * Complete?
  542.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  543.   def complete?
  544.     # Check if all prime objectives have been completed
  545.     return (@complete_objectives & @prime_objectives) == @prime_objectives
  546.   end
  547.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  548.   # * Failed?
  549.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  550.   def failed?
  551.     # Check if any prime objectives have been failed
  552.     return !(@failed_objectives & @prime_objectives).empty?
  553.   end
  554. end
  555.  
  556. #==============================================================================
  557. # ** Game_Quests
  558. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  559. #  This class handles Quests. It is a wrapper for the built-in class "Hash".
  560. # The instance of this class is accessed by $game_party.quests
  561. #==============================================================================
  562.  
  563. class Game_Quests
  564.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  565.   # * Object Initialization
  566.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  567.   def initialize
  568.     @data = {}
  569.     @id_sort = []
  570.     @revealed_sort = []
  571.     @alphabet_sort = []
  572.   end
  573.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  574.   # * Get Quest
  575.   #    quest_id : the ID of the quest
  576.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  577.   def [] (quest_id)
  578.     return Game_Quest.new (0) unless quest_id.is_a? (Integer)
  579.     if @data[quest_id] == nil
  580.       @data[quest_id] = Game_Quest.new (quest_id)
  581.       $game_system.last_quest_id = quest_id # Open to this quest next time
  582.       # Save sorting order in separate arrays to avoid resorting every time
  583.       @revealed_sort.push (quest_id)
  584.       sorted = false
  585.       for i in 0...@id_sort.size
  586.         if @id_sort[i] > quest_id
  587.           @id_sort.insert (i, quest_id)
  588.           sorted = true
  589.           break
  590.         end
  591.       end
  592.       @id_sort.push (quest_id) unless sorted
  593.       sorted = false
  594.       for i in 0...@alphabet_sort.size
  595.         if @data[@alphabet_sort[i]].name.downcase > @data[quest_id].name.downcase
  596.           @alphabet_sort.insert (i, quest_id)
  597.           sorted = true
  598.           break
  599.         end
  600.       end
  601.       @alphabet_sort.push (quest_id) unless sorted
  602.     end
  603.     return @data[quest_id]
  604.   end
  605.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  606.   # * Get Quest List
  607.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  608.   def list
  609.     quest_list = []
  610.     case QuestData::SORT_TYPE
  611.     when :id
  612.       @id_sort.each { |id| quest_list.push (@data[id]) }
  613.     when :revealed
  614.       @revealed_sort.each { |id| quest_list.push (@data[id]) }
  615.     when :alphabet
  616.       @alphabet_sort.each { |id| quest_list.push (@data[id]) }
  617.     else
  618.       quest_list = @data.values
  619.     end
  620.     quest_list.each { |i| quest_list.delete (i) if i.concealed }
  621.     return quest_list
  622.   end
  623.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  624.   # * Get Completed Quest List
  625.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  626.   def completed_list
  627.     complete_quests = []
  628.     list.each { |i| complete_quests.push (i) if i.complete? }
  629.     return complete_quests
  630.   end
  631.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  632.   # * Get Failed Quest List
  633.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  634.   def failed_list
  635.     failed_quests = []
  636.     list.each { |i| failed_quests.push (i) if i.failed? }
  637.     return failed_quests
  638.   end
  639.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  640.   # * Get Active Quest List
  641.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  642.   def active_list
  643.     return list - failed_list - completed_list
  644.   end
  645.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  646.   # * Category List
  647.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  648.   def category_list (category)
  649.     case category
  650.     when :all then return list
  651.     when :active then return active_list
  652.     when :complete then return completed_list
  653.     when :failed then return failed_list
  654.     else
  655.       quest_list = []
  656.       list.each { |quest| quest_list.push (quest) if quest.custom_categories.include? (category) }
  657.       return quest_list
  658.     end
  659.   end
  660.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  661.   # * Get Location
  662.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  663.   def get_location (quest_id)
  664.     return nil, nil unless @data[quest_id]
  665.     # Check all categories
  666.     for i in 0...QuestData::CATEGORIES.size
  667.       index = category_list (QuestData::CATEGORIES[i]).index (@data[quest_id])
  668.       return i, index if index != nil
  669.     end
  670.   end
  671.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  672.   # * Revealed?
  673.   #    quest_id : the ID of a checked quest
  674.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  675.   def revealed? (quest_id)
  676.     return !@data[quest_id].nil? && !@data[quest_id].concealed
  677.   end
  678.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  679.   # * Remove Quest
  680.   #    quest_id : the ID of the quest to delete
  681.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  682.   def remove (quest_id)
  683.     [@data, @id_sort, @revealed_sort, @alphabet_sort].each { |enum| enum.delete (quest_id) }
  684.   end
  685.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  686.   # * Clear
  687.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  688.   def clear
  689.     @data.clear
  690.   end
  691. end
  692.  
  693. #==============================================================================
  694. # ** Game_Temp
  695. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  696. #  Summary of Changes:
  697. #    new instance variables - quest_shop_array, quest_shop_name
  698. #==============================================================================
  699.  
  700. class Game_Temp
  701.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  702.   # * Public Instance Variables
  703.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  704.   attr_accessor :quest_shop_array
  705.   attr_accessor :quest_shop_name
  706.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  707.   # * Object Initialization
  708.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  709.   alias maba_qjrnl_iniz_5uv1 initialize
  710.   def initialize (*args)
  711.     maba_qjrnl_iniz_5uv1 (*args)
  712.     @quest_shop_array = []
  713.     @quest_shop_name = QuestData::VOCAB_PURCHASE
  714.   end
  715. end
  716.  
  717. #==============================================================================
  718. # ** Game_System
  719. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  720. #  Summary of Changes:
  721. #    new instance variables - quest_disabled; qj_bg_picture; qj_bg_opacity;
  722. #      qj_windowskin; qj_window_opacity; last_quest_id
  723. #    aliased method - initialize
  724. #==============================================================================
  725.  
  726. class Game_System
  727.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  728.   # * Public Instance Variables
  729.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  730.   attr_accessor :quest_disabled    # Can you access quest journal at this time
  731.   attr_accessor :quest_keyaccess   # Is it accessible by key?
  732.   attr_reader   :quest_menuaccess  # Is it accessible through the menu
  733.   attr_accessor :qj_bg_picture     # The filename of the background graphic
  734.   attr_accessor :qj_bg_opacity     # The opacity of the background picture
  735.   attr_accessor :qj_windowskin     # The skin of the windows in the quest scene
  736.   attr_accessor :qj_window_opacity # The opacity of windows in the quest scene
  737.   attr_accessor :last_quest_cat    # The last [category, index] of quest viewed
  738.   attr_accessor :last_quest_id     # The ID of the last quest viewed
  739.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  740.   # * Object Initialization
  741.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  742.   alias modlg_qstjrnl_iniz_4rd2 initialize
  743.   def initialize (*args)
  744.     # Run Original Method
  745.     modlg_qstjrnl_iniz_4rd2 (*args)
  746.     # Initialize new variables
  747.     @quest_disabled = false
  748.     @quest_keyaccess = QuestData::KEY_ACCESS
  749.     @quest_menuaccess = QuestData::MENU_ACCESS
  750.     @qj_bg_picture = QuestData::BG_PICTURE
  751.     @qj_bg_opacity = QuestData::BG_OPACITY
  752.     @qj_windowskin = QuestData::WINDOWS_SKIN
  753.     @qj_window_opacity = QuestData::WINDOWS_OPACITY
  754.     @last_quest_cat = 0
  755.     @last_quest_id = 0
  756.   end
  757.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  758.   # * Set Quest Access
  759.   #    Not simply accessor so I could add in compatibility
  760.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  761.   def quest_menuaccess= (value)
  762.     @quest_menuaccess = value
  763.     @fscms_command_list ? c = @fscms_command_list : (@tpcms_command_list ? c = @tpcms_command_list : return)
  764.     value ? (c.insert (QuestData::MENU_INDEX, :quest2) unless c.include? (:quest2)) :
  765.       c.delete (:quest2)
  766.   end
  767. end
  768.  
  769. #==============================================================================
  770. # ** Game_Party
  771. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  772. #  Summary of Changes:
  773. #    new instance variable - quests
  774. #    aliased method - initialize
  775. #==============================================================================
  776.  
  777. class Game_Party
  778.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  779.   # * Public Instance Variables
  780.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  781.   attr_reader   :quests
  782.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  783.   # * Object Initialization
  784.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  785.   alias modalg_qst_jrnl_party_init_quests initialize
  786.   def initialize
  787.     # Run Original Method
  788.     modalg_qst_jrnl_party_init_quests
  789.     # Initialize @quests
  790.     @quests = Game_Quests.new
  791.   end
  792. end
  793.  
  794. #==============================================================================
  795. # ** Game_Interpreter
  796. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  797. #  Summary of Changes:
  798. #    new method - change_quest_access; change_quest_background; remove_quest;
  799. #      quest; reveal_objective; conceal_objective; complete_objective;
  800. #      uncomplete_objective; fail_objective; unfail_objective; quest_revealed?;
  801. #      quest_complete?; quest_failed?; change_reward_status
  802. #==============================================================================
  803.  
  804. class Game_Interpreter
  805.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  806.   # * Call Quest Scene
  807.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  808.   def call_quest (quest_id = 0)
  809.     Sound.play_decision
  810.     $game_system.last_quest_id = quest_id if quest_id != 0 && quest_revealed? (quest_id)
  811.     $game_temp.next_scene = "quest"
  812.   end
  813.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  814.   # * Call Quest Shop
  815.   #    quest_array : a series of arrays in form [a, b, [c1, c2, ..., cn], d]
  816.   #      a is the Quest ID; b is the Purchase Cost; [c1, ..., cn] is a list
  817.   #      of which objectives are revealed when the quest is bought (it can be
  818.   #      excluded and if so, then it will reveal them all); d is the ID of an
  819.   #      enabling switch, meaning it will only show up if that switch is ON
  820.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  821.   def call_quest_shop (quest_array, shop_name = QuestData::VOCAB_PURCHASE)
  822.     $game_temp.next_scene = "quest shop"
  823.     $game_temp.quest_shop_array = quest_array
  824.     $game_temp.quest_shop_name = shop_name
  825.   end
  826.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  827.   # * Change Quest Access
  828.   #    sym - :enable, :disable, :enable_menu, :disable_menu, :enable_map, or
  829.   #     :disable_map
  830.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  831.   def change_quest_access (sym)
  832.     case sym
  833.     when :enable then $game_system.quest_disabled = false
  834.     when :disable then $game_system.quest_disabled = true
  835.     when :enable_menu then $game_system.quest_menuaccess = true
  836.     when :disable_menu then $game_system.quest_menuaccess = false
  837.     when :enable_map then $game_system.quest_keyaccess = true
  838.     when :disable_map then $game_system.quest_keyaccess = false
  839.     end
  840.   end
  841.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  842.   # * Change Quest Background
  843.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  844.   def change_quest_background (picture, opacity = $game_system.qj_bg_opacity)
  845.     $game_system.qj_bg_picture = picture
  846.     $game_system.qj_bg_opacity = opacity
  847.   end
  848.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  849.   # * Change Quest Windows
  850.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  851.   def change_quest_windows (skin, opacity = $game_system.qj_window_opacity)
  852.     $game_system.qj_windowskin = skin
  853.     $game_system.qj_window_opacity = opacity
  854.   end
  855.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  856.   # * Reset Quest
  857.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  858.   def reset_quest (id)
  859.     quest (id).reset
  860.   end
  861.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  862.   # * Remove Quest
  863.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  864.   def remove_quest (id)
  865.     $game_party.quests.remove (id)
  866.   end
  867.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  868.   # * Reveal/Conceal Quest
  869.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  870.   def conceal_quest (id)
  871.     $game_party.quests[id].concealed = true
  872.   end
  873.   def reveal_quest (id)
  874.     $game_party.quests[id].concealed = false
  875.   end
  876.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  877.   # * Quest
  878.   #    id : Returns the quest object with that ID
  879.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  880.   def quest (id)
  881.     return $game_party.quests[id]
  882.   end
  883.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  884.   # * Quest Revealed?
  885.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  886.   def quest_revealed? (id)
  887.     return $game_party.quests.revealed? (id)
  888.   end
  889.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  890.   # * Facade for Quest methods:
  891.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  892.   [:reveal_objective, :conceal_objective, :complete_objective,
  893.    :uncomplete_objective, :fail_objective, :unfail_objective].each { |method|
  894.     define_method (method) { |id, *obj| quest (id).send (method, *obj) }
  895.   }
  896.   [:objective_revealed?, :objective_complete?, :objective_failed?].each { |method|
  897.     define_method (method) { |id, *obj| quest_revealed? (id) && quest (id).send (method, *obj) }
  898.   }
  899.   [:reset, :complete?, :rewarded?, :failed?].each { |method|
  900.     define_method ("quest_#{method}".to_sym) { |id| quest_revealed? (id) && quest (id).send (method) }
  901.   }
  902.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  903.   # * Change Reward Status
  904.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  905.   def change_reward_status (id, value = true)
  906.     quest (id).reward_given = value
  907.   end
  908. end
  909.  
  910. #==============================================================================
  911. # ** Window_Message
  912. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  913. #  Summary of Changes:
  914. #    aliased method - convert_special_characters
  915. #==============================================================================
  916.  
  917. class Window_Message
  918.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  919.   # * Convert Special Characters
  920.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  921.   alias ma_qstjrnl_cnvrtspecnq_6yh2 convert_special_characters
  922.   def convert_special_characters (*args)
  923.     # Run Original Method
  924.     ma_qstjrnl_cnvrtspecnq_6yh2 (*args)
  925.     @text.gsub! (/\\NQ\[(\d+)\]/i) { $game_party.quests[$1.to_i].name } # Name Quest
  926.   end
  927. end
  928.  
  929. if Object.const_defined? (:Paragrapher) && Paragrapher.const_defined? (:Formatter_SpecialCodes)
  930.   class Paragrapher::Formatter_SpecialCodes
  931.     alias mlg_qstj_prfrmsub_5th2 perform_substitution
  932.     def perform_substitution (*args)
  933.       text = mlg_qstj_prfrmsub_5th2 (*args)
  934.       text.gsub! (/\\NQ\[(\d+)\]/i) { $game_party.quests[$1.to_i].name } # Monster Name
  935.       return text
  936.     end
  937.   end
  938. end
  939.  
  940. #==============================================================================
  941. # ** Window_QuestLabel
  942. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  943. #  This window shows the quest label at the top of the scene
  944. #==============================================================================
  945.  
  946. class Window_QuestLabel < Window_Base
  947.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  948.   # * Object Initialization
  949.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  950.   def initialize (width = QuestData::LIST_WIDTH, height = 32 + WLH, text = QuestData::VOCAB_QUESTS)
  951.     super (0, 0, width, height)
  952.     self.windowskin = Cache.system ($game_system.qj_windowskin)
  953.     self.opacity = $game_system.qj_window_opacity
  954.     # Draw contents
  955.     contents.font.color = system_color
  956.     contents.font.name = QuestData::LABEL_FONTNAME unless QuestData::LABEL_FONTNAME.empty?
  957.     if QuestData::LABEL_FONTSIZE == 0
  958.       contents.font.size = [height - 36, 28].min
  959.       # Fit it by width
  960.       while (contents.text_size (text).width > contents.width) && contents.font.size > Font.default_size
  961.         contents.font.size -= 1
  962.       end
  963.     else
  964.       contents.font.size = QuestData::LABEL_FONTSIZE
  965.     end
  966.     contents.font.bold = QuestData::LABEL_BOLD
  967.     contents.draw_text (contents.rect, text, 1)
  968.   end
  969. end
  970.  
  971. #==============================================================================
  972. # ** Window_QuestPurchaseGold
  973. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  974. #  This is the gold window for the Quest Purchase scene
  975. #==============================================================================
  976.  
  977. class Window_QuestPurchaseGold < Window_Base
  978.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  979.   # * Object Initialization
  980.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  981.   def initialize (y, width = QuestData::PURCHASE_LIST_WIDTH)
  982.     super (0, y, width, 32 + WLH)
  983.     self.windowskin = Cache.system ($game_system.qj_windowskin)
  984.     self.opacity = $game_system.qj_window_opacity
  985.     refresh
  986.   end
  987.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  988.   # * Refresh
  989.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  990.   def refresh
  991.     self.contents.clear
  992.     if QuestData::PURCHASE_USE_GOLD_ICON
  993.       draw_icon (QuestData::ICONS[:gold], 0, 0)
  994.       x = 28
  995.     else
  996.       x = 4
  997.     end
  998.     draw_currency_value ($game_party.gold, x, 0, contents.width - x)
  999.   end
  1000. end
  1001.  
  1002. #==============================================================================
  1003. # ** Window_QuestCategory
  1004. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1005. #  This window allows you to select between which list to show
  1006. #==============================================================================
  1007.  
  1008. class Window_QuestCategory < Window_Base
  1009.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1010.   # * Object Initialization
  1011.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1012.   def initialize (category_index = 0, width = QuestData::LIST_WIDTH)
  1013.     hght = 56
  1014.     @all_index = QuestData::CATEGORIES.index (:all)
  1015.     hght += 8 if @all_index && QuestData::ICONS[:all] == 0
  1016.     super (0, WLH + 32, width, hght)
  1017.     self.windowskin = Cache.system ($game_system.qj_windowskin)
  1018.     self.opacity = $game_system.qj_window_opacity
  1019.     total = 24*QuestData::CATEGORIES.size
  1020.     total += 16 if hght == 64
  1021.     @spacing = (contents.width - total) / (QuestData::CATEGORIES.size - 1)
  1022.     refresh (category_index)
  1023.   end
  1024.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1025.   # * Refresh
  1026.   #    category_index : icon to highlight -
  1027.   #                       0 => All, 1 => Active, 2 => Complete, 3 => Failed
  1028.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1029.   def refresh (category_index = 0)
  1030.     contents.clear
  1031.     for i in 0...QuestData::CATEGORIES.size
  1032.       draw_item (i, i == category_index)
  1033.     end
  1034.   end
  1035.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1036.   # * Draw Category
  1037.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1038.   def draw_item (index, enabled = false)
  1039.     x = index*(24 + @spacing)
  1040.     x += 16 if @all_index && index > @all_index && contents.height == 32
  1041.     category = QuestData::CATEGORIES[index]
  1042.     if @all_index != index || contents.height == 24
  1043.       y = (contents.height == 32 ? 4 : 0)
  1044.       contents.clear_rect (x, y, 24, 24)
  1045.       draw_icon (QuestData::ICONS[category], x, y, enabled)
  1046.     else
  1047.       contents.clear_rect (x, 0, 40, 32)
  1048.       draw_icon (QuestData::ICONS[:complete], x, 0, enabled)
  1049.       draw_icon (QuestData::ICONS[:failed], x + 16, 0, enabled)
  1050.       draw_icon (QuestData::ICONS[:active], x + 8, 8, enabled)
  1051.     end
  1052.   end
  1053. end
  1054.  
  1055. #==============================================================================
  1056. # ** Window_QuestList
  1057. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1058. #  This window shows a list of quests
  1059. #==============================================================================
  1060.  
  1061. class Window_QuestList < Window_Command
  1062.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1063.   # * Object Initialization
  1064.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1065.   def initialize (free, width = QuestData::LIST_WIDTH, category = QuestData::CATEGORIES[0], quest_index = 0)
  1066.     super (width, [], 1, free / WLH)
  1067.     change_list (category)
  1068.     self.windowskin = Cache.system ($game_system.qj_windowskin)
  1069.     self.opacity = $game_system.qj_window_opacity
  1070.     self.index = quest_index
  1071.   end
  1072.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1073.   # * Change List
  1074.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1075.   def change_list (list_type)
  1076.     if list_type.is_a? (Array)
  1077.       @commands = list_type # List passed directly
  1078.     else
  1079.       @commands = $game_party.quests.category_list (list_type)
  1080.       @commands = [] if @commands.nil?
  1081.     end
  1082.     @item_max = @commands.size
  1083.     self.contents = Bitmap.new (contents.width, [self.height - 32, @item_max*WLH].max)
  1084.     self.index = 0
  1085.     refresh
  1086.   end
  1087.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1088.   # * Quest
  1089.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1090.   def quest
  1091.     return @commands[self.index]
  1092.   end
  1093.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1094.   # * Draw Item
  1095.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1096.   def draw_item(index, enabled = true)
  1097.     rect = item_rect(index)
  1098.     self.contents.clear_rect(rect)
  1099.     self.contents.font.color.alpha = (enabled ? 255 : 128)
  1100.     quest = @commands[index]
  1101.     draw_icon (quest.icon_index, rect.x, rect.y, enabled)
  1102.     rect.x += 28
  1103.     rect.width -= 28
  1104.     if quest.cost > -1 # Draw the quest's cost if > -1
  1105.       tw =
  1106.       self.contents.font.color = normal_color
  1107.       self.contents.draw_text (rect, quest.cost.to_s, 2)
  1108.       rect.width -= (self.contents.text_size (quest.cost.to_s).width + 6)
  1109.     else
  1110.       if quest.complete?
  1111.         self.contents.font.color = QuestData::COMPLETE_COLOUR.is_a? (Array) ?
  1112.           Color.new (*QuestData::COMPLETE_COLOUR) : text_color (QuestData::COMPLETE_COLOUR)
  1113.       elsif quest.failed?
  1114.         self.contents.font.color = QuestData::FAILED_COLOUR.is_a? (Array) ?
  1115.           Color.new (*QuestData::FAILED_COLOUR) : text_color (QuestData::FAILED_COLOUR)
  1116.       else # Active
  1117.         self.contents.font.color = QuestData::ACTIVE_COLOUR.is_a? (Array) ?
  1118.          Color.new (*QuestData::ACTIVE_COLOUR) : text_color (QuestData::ACTIVE_COLOUR)
  1119.       end
  1120.     end
  1121.     self.contents.draw_text(rect, quest.name)
  1122.   end
  1123. end
  1124.  
  1125. #==============================================================================
  1126. # ** Window QuestInfo
  1127. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1128. #  This window shows the details of each quest
  1129. #==============================================================================
  1130.  
  1131. class Window_QuestInfo < Window_Base
  1132.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1133.   # * Object Initialization
  1134.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1135.   def initialize (height = Graphics.height - (32 + WLH), x = QuestData::LIST_WIDTH)
  1136.     super (x, 0, Graphics.width - x, height)
  1137.     self.windowskin = Cache.system ($game_system.qj_windowskin)
  1138.     self.opacity = $game_system.qj_window_opacity
  1139.   end
  1140.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1141.   # * Refresh
  1142.   #    quest : the Quest object to show
  1143.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1144.   def refresh (quest)
  1145.     contents.clear
  1146.     if quest.nil?
  1147.       create_contents
  1148.       return
  1149.     end
  1150.     y = 0
  1151.     @quest = quest
  1152.     @font_regular = contents.font.name
  1153.     @dummy = Bitmap.new (self.width - 32, 1000)
  1154.     # Draw Banner
  1155.     y = draw_banner (y) if !@quest.banner.empty?                    # Banner
  1156.     y = draw_name (y) if QuestData::INFO_SHOW_NAME                  # Name
  1157.     # Get the Paragrapher
  1158.     if !Object.const_defined? (:Paragrapher) || !Paragrapher.const_defined? (:Formatter)
  1159.       p "This script requires the Paragraph Formatter 2.0! You can get it at RMRK:",
  1160.       "    http://rmrk.net/index.php/topic,25129.0.html", "The Special Codes Formatter is supported, but you still need the base script."
  1161.     else
  1162.       if Paragrapher.const_defined? (:Formatter_SpecialCodes)
  1163.         @paragrapher = Paragrapher.new (Paragrapher::Formatter_SpecialCodes.new, Paragrapher::Artist_SpecialCodes.new)
  1164.       else
  1165.         @paragrapher = Paragrapher.new (@dummy.paragraph_formatter, @dummy.paragraph_artist)
  1166.       end
  1167.       y = draw_description (y) if !@quest.description.empty?        # Description
  1168.       y = draw_objectives (y) if !@quest.revealed_objectives.empty? # Objectives
  1169.     end
  1170.     total_height = y
  1171.     total_height += WLH*(@quest.rewards.size + 1) if !@quest.rewards.empty? # Calculate for rewards
  1172.     # Draw it all onto the window
  1173.     contents.dispose
  1174.     self.contents = Bitmap.new (self.width - 32, [self.height - 32, total_height - 4].max)
  1175.     contents.blt (0, 0, @dummy, @dummy.rect)
  1176.     @dummy.dispose
  1177.     draw_rewards (y) if !@quest.rewards.empty?                      # Rewards
  1178.   end
  1179.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1180.   # * Draw Banner
  1181.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1182.   def draw_banner (y)
  1183.     banner = Cache.picture (@quest.banner)
  1184.     @dummy.blt ((@dummy.width - banner.width) / 2, y, banner, banner.rect)
  1185.     return y + banner.height
  1186.   end
  1187.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1188.   # * Draw Name
  1189.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1190.   def draw_name (y)
  1191.     @dummy.font.bold = true
  1192.     @dummy.draw_text (0, y, @dummy.width, WLH, @quest.name, 1)
  1193.     @dummy.font.bold = false
  1194.     return y + WLH
  1195.   end
  1196.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1197.   # * Draw Description
  1198.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1199.   def draw_description (y)
  1200.     bmp = Bitmap.new (@dummy.width - 16, WLH)
  1201.     bmp.font = @dummy.font.dup
  1202.     bmp.font.size = QuestData::DESC_FONTSIZE
  1203.     ft = @paragrapher.formatter.format (@quest.description, bmp)
  1204.     hght = ft.lines.size * ft.bitmap.font.size
  1205.     ft.bitmap = Bitmap.new (bmp.width, hght)
  1206.     ft.bitmap.font = bmp.font.dup
  1207.     bmp.dispose
  1208.     rect = Rect.new (2, y + (WLH / 2), @dummy.width - 4, hght + WLH)
  1209.     rect2 = Rect.new (4, y + (WLH / 2) + 2, @dummy.width - 8, hght + WLH - 4)
  1210.     # Make Box
  1211.     if Bitmap.method_defined? (:fill_rounded_rect) # Bitmap Addons
  1212.       @dummy.fill_rounded_rect (rect, system_color)
  1213.       @dummy.fill_rounded_rect (rect2, Color.new (0, 0, 0, 0))
  1214.     else
  1215.       @dummy.fill_rect (rect, system_color)
  1216.       @dummy.clear_rect (rect2)
  1217.     end
  1218.     # Draw Description Label
  1219.     @dummy.font.name = QuestData::SUBTITLE_FONTNAME unless QuestData::SUBTITLE_FONTNAME.empty?
  1220.     @dummy.font.bold = QuestData::SUBTITLE_BOLD
  1221.     tw = @dummy.text_size (QuestData::VOCAB_DESCRIPTION).width
  1222.     @dummy.clear_rect (32, y, tw + 4, WLH)
  1223.     @dummy.font.color = QuestData::SUBTITLE_COLOR.is_a? (Array) ? Color.new (*QuestData::SUBTITLE_COLOR) : text_color (QuestData::SUBTITLE_COLOR)
  1224.     @dummy.draw_text (34, y, tw + 2, WLH, QuestData::VOCAB_DESCRIPTION)
  1225.     @dummy.font.name = @font_regular
  1226.     @dummy.font.bold = false
  1227.     # Draw Description paragraph
  1228.     @paragrapher.artist.draw (ft, QuestData::JUSTIFY_PARAGRAPHS)
  1229.     @dummy.blt (8, y + WLH, ft.bitmap, ft.bitmap.rect)
  1230.     ft.bitmap.dispose
  1231.     return rect.y + rect.height + 4
  1232.   end
  1233.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1234.   # * Draw Objectives
  1235.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1236.   def draw_objectives (y)
  1237.     @dummy.font.color = QuestData::SUBTITLE_COLOR.is_a? (Array) ? Color.new (*QuestData::SUBTITLE_COLOR) : text_color (QuestData::SUBTITLE_COLOR)
  1238.     @dummy.font.name = QuestData::SUBTITLE_FONTNAME unless QuestData::SUBTITLE_FONTNAME.empty?
  1239.     @dummy.font.bold = QuestData::SUBTITLE_BOLD
  1240.     @dummy.draw_text (32, y, contents.width - 32, WLH, QuestData::VOCAB_OBJECTIVES)
  1241.     @dummy.font.name = @font_regular
  1242.     @dummy.font.bold = false
  1243.     # Create second dummy bitmap
  1244.     tw = @dummy.text_size (QuestData::OBJECTIVE_BULLET).width
  1245.     bmp = Bitmap.new (@dummy.width - 12 - tw, WLH)
  1246.     bmp.font = @dummy.font.dup
  1247.     bmp.font.size = QuestData::OBJ_FONTSIZE
  1248.     y += WLH
  1249.     for i in @quest.revealed_objectives
  1250.       # Draw Bullet
  1251.       @dummy.draw_text (8, y, tw, WLH, QuestData::OBJECTIVE_BULLET)
  1252.       # Format & Draw Objective
  1253.       ft = @paragrapher.formatter.format (@quest.objectives[i], bmp)
  1254.       ft.bitmap = Bitmap.new (bmp.width, (bmp.font.size)*ft.lines.size)
  1255.       ft.bitmap.font = bmp.font.dup
  1256.       # Get the correct color
  1257.       if @quest.objective_complete? (i) # Complete?
  1258.         ft.bitmap.font.color = QuestData::COMPLETE_COLOUR.is_a? (Array) ?
  1259.           Color.new (*QuestData::COMPLETE_COLOUR) : text_color (QuestData::COMPLETE_COLOUR)
  1260.       elsif @quest.objective_failed? (i) # Failed?
  1261.         ft.bitmap.font.color = QuestData::FAILED_COLOUR.is_a? (Array) ?
  1262.           Color.new (*QuestData::FAILED_COLOUR) : text_color (QuestData::FAILED_COLOUR)
  1263.       else # Active
  1264.         ft.bitmap.font.color = QuestData::ACTIVE_COLOUR.is_a? (Array) ?
  1265.           Color.new (*QuestData::ACTIVE_COLOUR) : text_color (QuestData::ACTIVE_COLOUR)
  1266.       end
  1267.       @paragrapher.artist.draw (ft, QuestData::JUSTIFY_PARAGRAPHS)
  1268.       @dummy.blt (12 + tw, y + 2, ft.bitmap, ft.bitmap.rect)
  1269.       # Modify the Y accordingly
  1270.       y += 2 + ((ft.bitmap.font.size)*ft.lines.size)
  1271.       ft.bitmap.dispose
  1272.     end
  1273.     bmp.dispose
  1274.     return y + 2
  1275.   end
  1276.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1277.   # * Draw Rewards
  1278.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1279.   def draw_rewards (y)
  1280.     # Rewards done with contents and not @dummy since uses Window_Base methods
  1281.     contents.font.color = QuestData::SUBTITLE_COLOR.is_a? (Array) ? Color.new (*QuestData::SUBTITLE_COLOR) : text_color (QuestData::SUBTITLE_COLOR)
  1282.     contents.font.name = QuestData::SUBTITLE_FONTNAME unless QuestData::SUBTITLE_FONTNAME.empty?
  1283.     contents.font.bold = QuestData::SUBTITLE_BOLD
  1284.     contents.draw_text (32, y, contents.width - 32, WLH, QuestData::VOCAB_REWARDS)
  1285.     contents.font.name = @font_regular
  1286.     contents.font.bold = false
  1287.     x = QuestData::REWARD_BULLET.empty? ? 8 : 12 + (contents.text_size (QuestData::REWARD_BULLET).width)
  1288.     y += WLH
  1289.     contents.font.size = QuestData::REWARD_FONTSIZE
  1290.     for reward in @quest.rewards
  1291.       # Draw Bullet
  1292.       contents.font.color = system_color
  1293.       contents.draw_text (8, y, 100, WLH, QuestData::REWARD_BULLET)
  1294.       contents.font.color = normal_color
  1295.       if reward.is_a? (Array)
  1296.         item = nil
  1297.         case reward[0]
  1298.         when 0 then item = $data_items[reward[1]]
  1299.         when 1 then item = $data_weapons[reward[1]]
  1300.         when 2 then item = $data_armors[reward[1]]
  1301.         when 3 # Gold
  1302.           draw_icon (QuestData::ICONS[:gold], x, y)
  1303.           contents.font.color = normal_color
  1304.           contents.draw_text (x + 24, y, contents.width - x - 24, WLH, reward[1].to_s)
  1305.           if QuestData::DRAW_VOCAB_GOLD
  1306.             tw = contents.text_size(reward[1].to_s).width
  1307.             contents.font.color = system_color
  1308.             contents.draw_text(x + tw + 28, y, contents.width - x - 28 - tw, WLH, Vocab::gold)
  1309.             contents.font.color = normal_color
  1310.           end
  1311.         when 4 # Exp
  1312.           draw_icon (QuestData::ICONS[:exp], x, y)
  1313.           contents.font.color = normal_color
  1314.           contents.draw_text (x + 24, y, contents.width - x - 24, WLH, reward[1].to_s)
  1315.           tw = contents.text_size(reward[1].to_s).width
  1316.           contents.font.color = system_color
  1317.           contents.draw_text(x + tw + 28, y, contents.width - x - 28 - tw, WLH, QuestData::VOCAB_EXP)
  1318.           contents.font.color = normal_color
  1319.         end
  1320.         # Draw Item
  1321.         if item != nil
  1322.           draw_item_name (item, x, y)
  1323.           unless reward[2].nil? # Draw Number
  1324.             contents.font.color = system_color
  1325.             tw = contents.text_size (item.name).width + 28
  1326.             contents.draw_text (x + tw, y, 100, WLH, "#{QuestData::ITEM_NUMBER_PREFACE}#{reward[2]}")
  1327.             contents.font.color = normal_color
  1328.           end
  1329.         end
  1330.       else
  1331.         # Allow use of special codes if Special Codes Formatter available
  1332.         if Object.const_defined? (:Paragrapher) && Paragrapher.const_defined? (:Formatter_SpecialCodes)
  1333.           bmp = Bitmap.new (contents.width - x, WLH)
  1334.           bmp.font = contents.font.dup
  1335.           @paragrapher.paragraph (reward, bmp)
  1336.           contents.blt (x, y, bmp, bmp.rect)
  1337.           bmp.dispose
  1338.         else
  1339.           contents.font.color = normal_color
  1340.           contents.draw_text (x, y, contents.width - x, WLH, reward)
  1341.         end
  1342.       end
  1343.       y += WLH
  1344.     end
  1345.     return y
  1346.   end
  1347.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1348.   # * Frame Update
  1349.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1350.   def update
  1351.     if Input.press? (Input::DOWN)
  1352.       self.oy = [self.oy + 3, contents.height - self.height + 32].min
  1353.     elsif Input.press? (Input::UP)
  1354.       self.oy = [self.oy - 3, 0].max
  1355.     end
  1356.   end
  1357. end
  1358.  
  1359. #==============================================================================
  1360. # ** Scene_Map
  1361. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1362. #  Summary of Changes:
  1363. #    aliased method - update
  1364. #==============================================================================
  1365.  
  1366.   class Scene_Map < Scene_Base
  1367.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1368.   # * Frame Update
  1369.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1370.   alias ma_qj2_keyaces_upd_6yc1 update
  1371.   def update (*args)
  1372.     ma_qj2_keyaces_upd_6yc1 (*args)
  1373.     # If the quest log can be accessed by key and is not empty or disabled
  1374.     if $game_system.quest_keyaccess && Input.trigger? (QuestData::MAPKEY_BUTTON)
  1375.       if $game_system.quest_disabled || $game_party.quests.list.empty?
  1376.         Sound.play_buzzer
  1377.       else
  1378.         Sound.play_decision
  1379.         $game_temp.next_scene = "quest"
  1380.       end
  1381.     end
  1382.   end
  1383.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1384.   # * Execute Screen Switch
  1385.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1386.   alias malb_questj_updscene_5tg2 update_scene_change
  1387.   def update_scene_change (*args)
  1388.     scene_call = $game_temp.next_scene
  1389.     malb_questj_updscene_5tg2 (*args) # Run Original Method
  1390.     # This check first ensures that the scene call was not prevented by external
  1391.     #  factors, like the player moving, then checks to see if it was quest. I
  1392.     #  do it like this to ensure that it doesn't open at weird times (like while
  1393.     #  the message box is open
  1394.     if $game_temp.next_scene.nil? && !scene_call.nil?
  1395.       case scene_call
  1396.       when "quest"
  1397.         $scene = Scene_Quest.new
  1398.       when "quest shop"
  1399.         $scene = Scene_QuestPurchase.new ($game_temp.quest_shop_array, $game_temp.quest_shop_name)
  1400.       end
  1401.     end
  1402.   end
  1403. end
  1404.  
  1405. #==============================================================================
  1406. # ** Scene Quest
  1407. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1408. #  This class handles the quest scene processing
  1409. #==============================================================================
  1410.  
  1411. class Scene_Quest < Scene_Base
  1412.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1413.   # * Object Initialization
  1414.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1415.   def initialize (*args)
  1416.     if args.size == 0 # Last Quest ID
  1417.       cat_ind = $game_system.last_quest_cat
  1418.       cat = QuestData::CATEGORIES[cat_ind]
  1419.       ind = ($game_party.quests.category_list (cat)).index ($game_party.quests[$game_system.last_quest_id])
  1420.       if !ind.nil?
  1421.         @category_index, @quest_index = cat_ind, ind
  1422.       else
  1423.         @category_index, @quest_index = $game_party.quests.get_location ($game_system.last_quest_id)
  1424.       end
  1425.     else
  1426.       @category_index = args[0] < QuestData::CATEGORIES.size ? args[0] : 0
  1427.       @quest_index = args.size < 2 ? 0 : args[1]
  1428.     end
  1429.     @category_index = 0 if @category_index.nil?
  1430.     @quest_index = 0 if @quest_index.nil?
  1431.     @info_window_active = false
  1432.     @from_menu = $scene.is_a? (Scene_Menu)
  1433.   end
  1434.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1435.   # * Start Processing
  1436.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1437.   def start
  1438.     super
  1439.     create_menu_background
  1440.     # Create Background picture
  1441.     unless $game_system.qj_bg_picture.empty?
  1442.       @bg_sprite = Sprite.new
  1443.       @bg_sprite.bitmap = Cache.picture ($game_system.qj_bg_picture)
  1444.       @bg_sprite.opacity = $game_system.qj_bg_opacity
  1445.     end
  1446.     free_space = Graphics.height - 96 - 2*Window_Base::WLH
  1447.     if QuestData::CATEGORIES.size > 1
  1448.       @category_window = Window_QuestCategory.new (@category_index)
  1449.       free_space -= @category_window.height
  1450.     end
  1451.     @label_window = Window_QuestLabel.new (QuestData::LIST_WIDTH, 32 + Window_Base::WLH + (free_space % Window_Base::WLH))
  1452.     y = @label_window.height
  1453.     if @category_window
  1454.       @category_window.y = y
  1455.       y += @category_window.height
  1456.     end
  1457.     @list_window = Window_QuestList.new (free_space, QuestData::LIST_WIDTH, QuestData::CATEGORIES[@category_index], @quest_index)
  1458.     @list_window.y = y
  1459.     @list_window.active = true
  1460.     @info_window = Window_QuestInfo.new
  1461.     @info_window.refresh (@list_window.quest)
  1462.     # Create Help Window
  1463.     @help_window = Window_Help.new
  1464.     @help_window.windowskin = Cache.system ($game_system.qj_windowskin)
  1465.     @help_window.opacity = $game_system.qj_window_opacity
  1466.     @help_window.y = Graphics.height - @help_window.height
  1467.     @help_window.width = Graphics.width
  1468.     @help_window.create_contents
  1469.     @help_window.set_text (QuestData::VOCAB_HELP_GENERAL, QuestData::HELP_ALIGNMENT)
  1470.   end
  1471.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1472.   # * Terminate Process
  1473.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1474.   def terminate
  1475.     super
  1476.     dispose_menu_background
  1477.     if @bg_sprite # Dispose Background Sprite
  1478.       @bg_sprite.bitmap.dispose
  1479.       @bg_sprite.dispose
  1480.     end
  1481.     @label_window.dispose
  1482.     @category_window.dispose if @category_window
  1483.     @list_window.dispose
  1484.     @info_window.dispose
  1485.     @help_window.dispose
  1486.   end
  1487.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1488.   # * Frame Update
  1489.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1490.   def update
  1491.     super
  1492.     update_menu_background
  1493.     if @list_window.active
  1494.       update_list_window
  1495.     elsif @info_window_active
  1496.       update_info_window
  1497.     end
  1498.   end
  1499.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1500.   # * Update List Window
  1501.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1502.   def update_list_window
  1503.     @list_window.update
  1504.     update_category_window if @category_window
  1505.     if Input.trigger?(Input::B) # If Button B is pressed
  1506.       Sound.play_cancel
  1507.       return_scene
  1508.     elsif Input.trigger? (Input::C) # If C button is pressed
  1509.       action_pressed_from_list
  1510.     # If scrolling through quests
  1511.     elsif Input.press? (Input::DOWN) || Input.press? (Input::UP)
  1512.       # Refresh Info Window
  1513.       @info_window.refresh (@list_window.quest)
  1514.     end
  1515.   end
  1516.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1517.   # * Update Category Window
  1518.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1519.   def update_category_window
  1520.     # If category window exists and horizontal arrow triggered
  1521.     if (Input.trigger? (Input::LEFT) || Input.trigger? (Input::RIGHT))
  1522.       add_int = Input.trigger? (Input::LEFT) ? -1 : 1
  1523.       @category_index = (@category_index + add_int) % QuestData::CATEGORIES.size
  1524.       # Play Cursor SE
  1525.       Sound.play_cursor
  1526.       # Refresh Windows
  1527.       @category_window.refresh (@category_index)
  1528.       @list_window.change_list (QuestData::CATEGORIES[@category_index])
  1529.       @info_window.refresh (@list_window.quest)
  1530.     end
  1531.   end
  1532.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1533.   # * Update Info Window
  1534.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1535.   def update_info_window
  1536.     @info_window.update
  1537.     if Input.trigger? (Input::B) || Input.trigger? (Input::C)
  1538.       Sound.play_cancel
  1539.       @info_window_active = false
  1540.       @info_window.oy = 0
  1541.       @list_window.active = true
  1542.       @help_window.set_text (QuestData::VOCAB_HELP_GENERAL, QuestData::HELP_ALIGNMENT)
  1543.     end
  1544.   end
  1545.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1546.   # * C Button Pressed
  1547.   #    I put this as its own method in case I want to write any patches which
  1548.   #   modifies what happens when C is pressed
  1549.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1550.   def action_pressed_from_list
  1551.     if @info_window.contents.height > @info_window.height - 32
  1552.       Sound.play_decision
  1553.       @info_window_active = true
  1554.       @list_window.active = false
  1555.       @help_window.set_text (QuestData::VOCAB_HELP_SELECTED, QuestData::HELP_ALIGNMENT)
  1556.     else
  1557.       Sound.play_buzzer
  1558.     end
  1559.   end
  1560.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1561.   # * Return Scene
  1562.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1563.   def return_scene
  1564.     unless @list_window.quest.nil? # Save Position
  1565.       $game_system.last_quest_id = @list_window.quest.id
  1566.       $game_system.last_quest_cat = @category_index
  1567.     end
  1568.     # Exit Quest Scene
  1569.     $scene = @from_menu ? Scene_Menu.new (QuestData::MENU_INDEX) : Scene_Map.new
  1570.   end
  1571. end
  1572.  
  1573. #==============================================================================
  1574. # ** Scene_QuestPurchase
  1575. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1576. #  This class handles processing for purchasing quests
  1577. #==============================================================================
  1578.  
  1579. class Scene_QuestPurchase < Scene_Quest
  1580.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1581.   # * Object Initialization
  1582.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1583.   def initialize (quest_array = [], shop_name = QuestData::VOCAB_PURCHASE)
  1584.     @quest_list, @quest_reveals = [], []
  1585.     quest_array.each { |quest_a|
  1586.       quest = Game_Quest.new (quest_a[0], (quest_a[1] ? quest_a[1] : 0))
  1587.       # Add if no switch condition or condition met and not already revealed
  1588.       if quest_a[3]
  1589.         reveals = quest_a[2]
  1590.         switch = quest_a[3]
  1591.       else
  1592.         if quest_a[2].is_a? (Array)
  1593.           reveals = quest_a[2]
  1594.           switch = nil
  1595.         else
  1596.           reveals = []
  1597.           quest.objectives.each_index { |i| reveals.push (i) }
  1598.           switch = quest_a[2]
  1599.         end
  1600.       end
  1601.       if (switch.nil? || $game_switches[switch]) && !$game_party.quests.revealed? (quest_a[0])
  1602.         # Reveal all objectives if want to show them
  1603.         quest.reveal_objective (*reveals) if QuestData::PURCHASE_SHOW_OBJECTIVES
  1604.         @quest_list.push (quest)
  1605.         @quest_reveals.push (reveals)
  1606.       end
  1607.     }
  1608.     @shop_name = shop_name
  1609.     @info_window_active = false
  1610.   end
  1611.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1612.   # * Start Processing
  1613.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1614.   def start
  1615.     create_menu_background
  1616.     # Create Background picture
  1617.     unless $game_system.qj_bg_picture.empty?
  1618.       @bg_sprite = Sprite.new
  1619.       @bg_sprite.bitmap = Cache.picture ($game_system.qj_bg_picture)
  1620.       @bg_sprite.opacity = $game_system.qj_bg_opacity
  1621.     end
  1622.     wlh = Window_Base::WLH
  1623.     fs = Graphics.height - (96 + 2*wlh)
  1624.     @label_window = Window_QuestLabel.new (QuestData::PURCHASE_LIST_WIDTH, 32 + wlh + (fs % 24), @shop_name)
  1625.     @list_window = Window_QuestList.new (fs, QuestData::PURCHASE_LIST_WIDTH, @quest_list)
  1626.     @list_window.y = @label_window.height
  1627.     @list_window.active = true
  1628.     for i in 0...@quest_list.size
  1629.       @list_window.draw_item (i, false) if $game_party.gold < @quest_list[i].cost
  1630.     end
  1631.     @info_window = Window_QuestInfo.new (Graphics.height, QuestData::PURCHASE_LIST_WIDTH)
  1632.     @info_window.refresh (@list_window.quest)
  1633.     # Create Gold Window
  1634.     @gold_window = Window_QuestPurchaseGold.new (@list_window.y + @list_window.height)
  1635.   end
  1636.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1637.   # * Terminate Process
  1638.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1639.   def terminate
  1640.     dispose_menu_background
  1641.     if @bg_sprite # Dispose Background Sprite
  1642.       @bg_sprite.bitmap.dispose
  1643.       @bg_sprite.dispose
  1644.     end
  1645.     @label_window.dispose
  1646.     @list_window.dispose
  1647.     @info_window.dispose
  1648.     @gold_window.dispose
  1649.   end
  1650.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1651.   # * Update Info Window
  1652.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1653.   def update_info_window
  1654.     @info_window.update
  1655.     if Input.trigger? (Input::B)
  1656.       Sound.play_cancel
  1657.       @info_window_active = false
  1658.       @info_window.oy = 0
  1659.       @list_window.active = true
  1660.     elsif Input.trigger? (Input::C)
  1661.       purchase_quest
  1662.     end
  1663.   end
  1664.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1665.   # * C Button Pressed
  1666.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1667.   def action_pressed_from_list
  1668.     if @info_window.contents.height > @info_window.height - 32
  1669.       Sound.play_decision
  1670.       @info_window_active = true
  1671.       @list_window.active = false
  1672.     else
  1673.       purchase_quest
  1674.     end
  1675.   end
  1676.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1677.   # * Purchase Quest
  1678.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1679.   def purchase_quest
  1680.     if $game_party.gold < @list_window.quest.cost
  1681.       Sound.play_buzzer
  1682.     else
  1683.       (RPG::SE.new (*QuestData::PURCHASE_SE)).play # Play Purchase SE
  1684.       $game_party.lose_gold (@list_window.quest.cost)
  1685.       quest = $game_party.quests[@list_window.quest.id]
  1686.       quest.reveal_objective (*@quest_reveals[@list_window.index])
  1687.       quest.concealed = false
  1688.       @quest_list.delete_at (@list_window.index)
  1689.       @quest_reveals.delete_at (@list_window.index)
  1690.       @list_window.change_list (@quest_list)
  1691.       for i in 0...@quest_list.size
  1692.         @list_window.draw_item (i, false) if $game_party.gold < @quest_list[i].cost
  1693.       end
  1694.       @info_window.refresh (@list_window.quest)
  1695.       @gold_window.refresh
  1696.     end
  1697.   end
  1698.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1699.   # * Return Scene
  1700.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1701.   def return_scene
  1702.     $scene = Scene_Map.new
  1703.   end
  1704. end
  1705.  
  1706. # YEM Main Menu Melody Compatibility
  1707. if $imported && $imported["MainMenuMelody"]
  1708.   YEM::MENU::MENU_COMMANDS.insert (QuestData::MENU_INDEX, :quest2)
  1709.   YEM::MENU::MENU_ICONS[:quest2] = QuestData::ICONS[:menu]
  1710.   YEM::MENU::IMPORTED_COMMANDS[:quest2] = [:quest_access, :quest_disable, false, QuestData::ICONS[:menu], QuestData::VOCAB_QUESTS, "Scene_Quest"]
  1711.  
  1712.   class Game_Switches
  1713.     alias ma_yemmm_qustjrn_get_6yh1 []
  1714.     def [] (id, *args)
  1715.       return $game_system.quest_disabled || $game_party.quests.list.empty? if id == :quest_disable
  1716.       return !$game_system.quest_menuaccess if id == :quest_access
  1717.       return ma_yemmm_qustjrn_get_6yh1 (id, *args)
  1718.     end
  1719.   end
  1720. # Full Status Menu System Compatibility
  1721. elsif Game_System.method_defined? (:fscms_command_list)
  1722.   ModernAlgebra::FSCMS_CUSTOM_COMMANDS[:quest2] = [QuestData::VOCAB_QUESTS,
  1723.     QuestData::ICONS[:menu], "$game_system.quest_disabled || $game_party.quests.list.empty?",
  1724.     false, Scene_Quest]
  1725.   ModernAlgebra::FSCMS_COMMANDLIST.insert (QuestData::MENU_INDEX, :quest2) if QuestData::MENU_ACCESS
  1726. # If Phantasia Esque Menu
  1727. elsif Game_System.method_defined? (:tpcms_command_list)
  1728.   Phantasia_CMS::CUSTOM_COMMANDS[:quest2] = [QuestData::VOCAB_QUESTS,
  1729.     QuestData::ICONS[:menu], "$game_system.quest_disabled || $game_party.quests.list.empty?",
  1730.     false, Scene_Quest]
  1731.   Phantasia_CMS::COMMANDLIST.insert (QuestData::MENU_INDEX, :quest2) if QuestData::MENU_ACCESS
  1732. else # Default Menu
  1733.   #============================================================================
  1734.   # ** Window_Command (unless already done by other script)
  1735.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1736.   #  Summary of Changes:
  1737.   #    new instance variable - ma_disabled_commands
  1738.   #    aliased method - initialize, draw_item
  1739.   #============================================================================
  1740.   unless Window_Command.method_defined? (:ma_disabled_commands)
  1741.     class Window_Command
  1742.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1743.       # * Public Instance Variable
  1744.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1745.       attr_reader :ma_disabled_commands
  1746.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1747.       # * Initialize
  1748.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1749.       alias malg_quest2_initz_6tg2 initialize
  1750.       def initialize (*args)
  1751.         @ma_disabled_commands = [] # Initialize new instance variable
  1752.         malg_quest2_initz_6tg2 (*args) # Run Original Method
  1753.       end
  1754.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1755.       # * Draw Item
  1756.       #     index   : item number
  1757.       #     enabled : enabled flag. When false, draw semi-transparently
  1758.       #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1759.       alias mab_qstj_itmdraw_8ic4 draw_item
  1760.       def draw_item (index, enabled = true, *args)
  1761.         # Run Original Method
  1762.         mab_qstj_itmdraw_8ic4 (index, enabled, *args)
  1763.         enabled ? @ma_disabled_commands.delete (index) :
  1764.           (@ma_disabled_commands.push (index) if !@ma_disabled_commands.include? (index))
  1765.       end
  1766.     end
  1767.   end
  1768.   #============================================================================
  1769.   # ** Scene Menu
  1770.   #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1771.   #  Summary of Changes:
  1772.   #    aliased methods - initialize; create_command_window;
  1773.   #      update_command_selection; update_actor_selection
  1774.   #============================================================================
  1775.  
  1776.   class Scene_Menu
  1777.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1778.     # * Object Initialization
  1779.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1780.     alias magba_questj_ini_5rc1 initialize
  1781.     def initialize (menu_index = 0, *args)
  1782.       magba_questj_ini_5rc1 (menu_index, *args) # Run Original Method
  1783.       if $game_system.quest_menuaccess
  1784.         # Set menu index if coming from the scene; adjust if not
  1785.         $scene.is_a? (Scene_Quest) ? @menu_index = QuestData::MENU_INDEX : (@menu_index += 1 if @menu_index >= QuestData::MENU_INDEX)
  1786.       end
  1787.     end
  1788.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1789.     # * Create Command Window
  1790.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1791.     alias modrn_qusjrnl2_cmmndwin_5th9 create_command_window
  1792.     def create_command_window (*args)
  1793.       modrn_qusjrnl2_cmmndwin_5th9 (*args) # Run Original Method
  1794.       if $game_system.quest_menuaccess
  1795.         c = @command_window.commands
  1796.         c.insert (QuestData::MENU_INDEX, QuestData::VOCAB_QUESTS)
  1797.         width = @command_window.width
  1798.         disabled = @command_window.ma_disabled_commands
  1799.         @command_window.dispose
  1800.         @command_window = @command_window.class.new (width, c)
  1801.         @command_window.index = @menu_index
  1802.         # Disable all of the old commands as well
  1803.         disabled.each { |i|
  1804.           i += 1 if i >= QuestData::MENU_INDEX
  1805.           @command_window.draw_item (i, false)
  1806.         }
  1807.         @command_window.draw_item (QuestData::MENU_INDEX, false) if $game_system.quest_disabled || $game_party.quests.list.empty?
  1808.       end
  1809.     end
  1810.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1811.     # * Update Command Selection
  1812.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1813.     alias malg_questj_cmmndupd_4rn6 update_command_selection
  1814.     def update_command_selection (*args)
  1815.       if $game_system.quest_menuaccess
  1816.       # If the Quests command selected
  1817.         if @command_window.index == QuestData::MENU_INDEX && Input.trigger? (Input::C)
  1818.           if $game_system.quest_disabled || $game_party.quests.list.empty?
  1819.             Sound.play_buzzer
  1820.           else
  1821.             Sound.play_decision
  1822.             $scene = Scene_Quest.new
  1823.           end
  1824.           return
  1825.         end
  1826.         # Reduce command window index if over the states index
  1827.         change = @command_window.index > QuestData::MENU_INDEX
  1828.         @command_window.index -= 1 if change
  1829.       end
  1830.       malg_questj_cmmndupd_4rn6 (*args) # Run Original Method
  1831.       @command_window.index += 1 if $game_system.quest_menuaccess && change
  1832.     end
  1833.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1834.     # * Update Actor Selection
  1835.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1836.     alias ma_journalqst_actorupd_3gb8 update_actor_selection
  1837.     def update_actor_selection (*args)
  1838.       if $game_system.quest_menuaccess
  1839.         # Reduce command window index if over the states index
  1840.         change = @command_window.index > QuestData::MENU_INDEX
  1841.         @command_window.index -= 1 if change
  1842.       end
  1843.       ma_journalqst_actorupd_3gb8 (*args) # Run Original Method
  1844.       @command_window.index += 1 if $game_system.quest_menuaccess && change
  1845.     end
  1846.   end
  1847. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement