SHARE
TWEET

Quest Journal 2.1c

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