Guest User

Problem with quest journal

a guest
Sep 16th, 2014
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 130.81 KB | None | 0 0
  1. #==============================================================================
  2. #    Quest Journal [VXA]
  3. #    Version: 1.0.3
  4. #    Author: modern algebra (rmrk.net)
  5. #    Date: 24 September 2012
  6. #    Support: http://rmrk.net/index.php/topic,45127.0.html
  7. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  8. #  Description:
  9. #
  10. #    This script provides a graphical interface for showing quest progress. It
  11. #   is objective-based, meaning that you choose when to reveal objectives and
  12. #   you can set it so that they show up as complete or failed. That said, this
  13. #   script does not build quests for you; it is only a supplementary scene for
  14. #   showing them. As such, you need to event all of the quests yourself and
  15. #   update quest progress via script call. Therefore, pay close attention to
  16. #   the instructions here and in the Editable Regions at lines 232 and 612.
  17. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  18. #  Instructions:
  19. #
  20. #    Paste this script into its own slot or slots, above Main and below
  21. #   Materials. If you are using the menu access feature, you should put any
  22. #   other menu scripts above this one.
  23. #
  24. #    All of the configuration is done in the QuestData module. While it is not
  25. #   necessary, it is recommended that you separate the configuration module
  26. #   from the rest of the script by cutting and pasting it into its own slot in
  27. #   the Script Editor (as you will see if you have the demo). The reason for
  28. #   this is that, if and when this script gets updated, you can preserve the
  29. #   configuration section and only replace the other parts of the script. If
  30. #   you wish to do that, you must cut everything from the first line down to
  31. #   the final end of the module. The first lines of the body script should be
  32. #   the equals bar right above # ** Game_Quest. Again, it's up to you whether
  33. #   you do it.
  34. #
  35. #    You can go to EDITABLE REGION A at line 232 to configure the default
  36. #   settings for the script. All of these will work fine without modification,
  37. #   of course, but even if do not want to configure now, you should familiarize
  38. #   yourself with all the settings so that you can make the best use of your
  39. #   script. I have included tons of settings so that you can make the Quest
  40. #   Journal unique for your game, even down to the order in which each section
  41. #   of the info window is drawn. A brief description of each setting is
  42. #   included either to the right or directly above each constant.
  43. #
  44. #    EDITABLE REGION B is the real heart of the script however - this is where
  45. #   you fill in all of the details for the quests. Read the instructions at
  46. #   line 612 very carefully!
  47. #
  48. #    You can activate and access a quest with this code in the Script event
  49. #   command:
  50. #
  51. #        quest(quest_id)
  52. #          quest_id : the integer ID of the quest you want to access
  53. #
  54. #   From that, you can access or alter any relevant data stored in the quest,
  55. #   like name, description, objectives, etc... Example:
  56. #         quest(1).name = "Rest in Pieces"
  57. #
  58. #    More relevantly, when it comes to controlling the progress of quests the
  59. #   following codes can be used in a Script event command. The arguments are
  60. #   the same for each command so I only explain them once. All of them are
  61. #   pretty self-explanatory and using any of them will activate the quest
  62. #   (unless you are using the MANUAL REVEAL setting at line 267).
  63. #    
  64. #        reveal_objective(quest_id, objective_id_1, ..., objective_id_n)
  65. #            quest_id : the integer ID of the quest you want to access.
  66. #            objective_id_1, ..., objective_id_n : a list of the IDs of the
  67. #              objectives you want to operate on. It can be as few as one or as
  68. #              many as all of them.
  69. #          Will show the listed objectives in the Quest's information
  70. #
  71. #        conceal_objective(quest_id, objective_id_1, ..., objective_id_n)
  72. #          Will hide the listed objectives in the Quest's information
  73. #
  74. #        complete_objective(quest_id, objective_id_1, ..., objective_id_n)
  75. #          Changes the colour of the listed objectives to the completed colour.
  76. #          The quest is completed once all prime objectives are.
  77. #
  78. #        uncomplete_objective (quest_id, objective_id_1, ..., objective_id_n)
  79. #          Changes the status of the listed complete objectives back to active
  80. #
  81. #        fail_objective(quest_id, objective_id_1, ..., objective_id_n)
  82. #          Changes the colour of the listed objectives to the failed colour.
  83. #          The quest is failed once one prime objective is.
  84. #
  85. #        unfail_objective(quest_id, objective_id_1, ..., objective_id_n)
  86. #          Changes the status of the listed failed objectives back to active
  87. #
  88. #        change_reward_status(quest_id, value)
  89. #            value : either true or false. If excluded, defaults to true.
  90. #          Totally optional, but this is just a personal switch which you can
  91. #          turn on when the reward is given. You can then make it a condition
  92. #          so you don't reward the players more than once. (see line 180)
  93. #
  94. #  EXAMPLES:
  95. #    reveal_objective(1, 0)
  96. #      This would reveal the first objective of the quest with ID 1
  97. #    complete_objective(6, 2, 3)
  98. #      This would complete the third & fourth objectives of the quest with ID 6
  99. #    change_reward_status(8)
  100. #      This would set the reward switch to true for the quest with ID 8.
  101. #
  102. #   Another new feature is the ability to set rewards that will show up in the
  103. #  menu (see EDITABLE REGION B). In addition to that, you can use the following
  104. #  code to automatically distribute the specified rewards for a quest if the
  105. #  quest is complete and no reward has yet been given:
  106. #
  107. #        distribute_quest_rewards(quest_id)
  108. #          quest_id : the ID of the quest whose rewards you want to distribute
  109. #
  110. #   Of course, it can only distribute the material rewards (items, weapons,
  111. #   armors, gold, or exp). It won't distribute rewards you specify by string.
  112. #   To that end though, you can also use this code in a conditional branch and
  113. #   it will be satisfied only if it distributes the rewards. Thus, if you
  114. #   wanted to add some special rewards or do things like that, you can just put
  115. #   that in the branch for when it is true. This feature is not really
  116. #   recommended, since I think it is better to do it by events.
  117. #
  118. #    Other codes for the Script event command that can be useful are:
  119. #    
  120. #        reset_quest(quest_id)
  121. #            quest_id : the integer ID of the quest you want to access.
  122. #          This will re-initialize the quest, meaning all quest progress to
  123. #          date will be lost
  124. #
  125. #        delete_quest(quest_id)
  126. #          Deactivates the quest and resets it
  127. #
  128. #        conceal_quest(quest_id)
  129. #          Deactivates the quest so it won't show up in the scene, but progress
  130. #          is saved
  131. #
  132. #        reveal_quest(quest_id)
  133. #          Activates or reactivates the quest. This command is NECESSARY if
  134. #          MANUAL_REVEAL at line 284 is true or it has previously been
  135. #          concealed. Otherwise, it is sufficient just to operate on the quest
  136. #
  137. #        change_quest_access(:symbol)
  138. #          :symbol must be one of six options (include the colon!):
  139. #            :disable - prevents access to the quest scene (greys out in menu)
  140. #            :enable - enables access to the quest scene
  141. #            :disable_menu - this removes the quest option from the menu
  142. #            :enable_menu - this adds the quest option to the menu
  143. #            :disable_map - this prevents access by key from the map
  144. #            :enable_map - this allows access by key to the map
  145. #
  146. #        change_quest_background("bg_filename", bg_opacity, bg_blend_type)
  147. #            bg_filename   : the filename of the picture for the background in  
  148. #              the Pictures folder
  149. #            bg_opacity    : the opacity of the background graphic. If
  150. #              excluded, this defaults to the value of the setting at line 434.
  151. #            bg_blend_type : the blend type of the background graphic. If
  152. #              excluded, this defaults to the value of the setting at line 437.
  153. #
  154. #        change_quest_windows ("windowskin_filename", tone, opacity)
  155. #            windowskin_filename : the name of the Window graphic in the
  156. #              System folder of Graphics
  157. #            opacity             : the opacity of the windows. If excluded,
  158. #              this defaults to the value of the setting at line 423.
  159. #            blend_type          : the blend_type of the windows. If excluded,
  160. #              this defaults to the value of the setting at line 426.
  161. #
  162. #    Also, there are a few codes that can be used in the Script command of a
  163. #   conditional branch. I note here that all of these are optional. You could
  164. #   use switch and variable checks and monitor quest progress solely through
  165. #   events. However, these commands make it a little easier and they are:
  166. #
  167. #        quest_revealed?(quest_id)
  168. #            quest_id : the integer ID of the quest you want to access.
  169. #          This is satisfied if the quest has been activated.
  170. #
  171. #        quest_complete?(quest_id)
  172. #          This is satisfied if all prime objectives of the quest are complete
  173. #
  174. #        quest_failed?(quest_id)
  175. #          This is satisfied if any prime objective of the quest is failed
  176. #
  177. #        quest_rewarded?(quest_id)
  178. #          This is satisfied if you have changed the reward status to true.
  179. #
  180. #        objective_revealed?(quest_id, objective_id_1, ... objective_id_n)
  181. #            objective_id_1, ..., objective_id_n : a list of the IDs of the
  182. #              objectives you want to operate on. It can be as few as one or as
  183. #              many as all of them.
  184. #          This is satisfied if the listed objectives have been revealed
  185. #
  186. #        objective_active?(quest_id, objective_id_1, ... objective_id_n)
  187. #          This is satisfied if all the listed objectives are revealed and
  188. #          neither complete nor failed.
  189. #
  190. #        objective_complete?(quest_id, objective_id_1, ... objective_id_n)
  191. #          This is satisfied if all the listed objectives have been completed
  192. #
  193. #        objective_failed?(quest_id, objective_id_1, ... objective_id_n)
  194. #          This is satisfied if all the listed objectives have been failed
  195. #
  196. #    If you want to call the Quest scene from an event, you use the following
  197. #   code in a call script:
  198. #
  199. #        call_quest_journal
  200. #        call_quest_journal(quest_id)
  201. #          quest_id : ID of the quest you want to open the scene on
  202. #
  203. #  If you do not specify a quest_id (line 198) then it will simply open the
  204. #  scene as it would normally. If you do specify a quest_id (line 199) then it
  205. #  will open the scene on that quest so long as it has been revealed and it is
  206. #  normally accessible through the quest menu.
  207. #
  208. #   Finally, the default way this script operates is that quests automatically
  209. #  complete or fail based on the status of the prime objectives. However, you
  210. #  can set it so that there are no prime objectives, in which case you can only
  211. #  complete, fail, or (re)activate a quest manually through the following code
  212. #  in a script call:
  213. #
  214. #        manually_complete_quest(quest_id)
  215. #          quest_id : ID of the quest you want to manually complete
  216. #        manually_fail_quest(quest_id)
  217. #          quest_id : ID of the quest you want to manually fail
  218. #        manually_activate_quest(quest_id)
  219. #          quest_id : ID of the quest you want to manually activate
  220. #==============================================================================
  221.  
  222. $imported ||= {}
  223. $imported[:"MA_QuestJournal_1.0"] = true
  224. $imported[:"MA_QuestJournal_1.0.1"] = true
  225.  
  226. #==============================================================================
  227. # *** QuestData
  228. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  229. #  This module contains all the configuration data for the quest journal
  230. #==============================================================================
  231.  
  232. module QuestData
  233.   #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  234.   #  BEGIN Editable Region A
  235.   #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  236.   #  MENU_ACCESS - If true, you can access the quest journal through a command
  237.   # in the menu. If false, there will be no such command.
  238.   MENU_ACCESS = true
  239.  
  240.   #  MENU_INDEX - If MENU_ACCESS is true, this determines where it appears
  241.   MENU_INDEX = 4
  242.   #  MAP_ACCESS - If true, this allows you to access the quest journal by
  243.   # pressing a key on the map.
  244.   MAP_ACCESS = true
  245.   #  MAP_BUTTON - If MAP_ACCESS is true, this determines which button calls the
  246.   # Quest Journal
  247.   MAP_BUTTON = :L
  248.   #  OPEN_TO_LAST_REVEALED_QUEST - If true, then the first time you open the
  249.   # quest journal after revealing a new quest, it will open to the new quest.
  250.   OPEN_TO_LAST_REVEALED_QUEST = true
  251.   #  OPEN_TO_LAST_CHANGED_QUEST - If true, then the Quest Journal will open to
  252.   # the last quest whose objective status has changed.
  253.   OPEN_TO_LAST_CHANGED_QUEST = true
  254.   #  LIST_WINDOW_WIDTH - The width, in pixels, of the List Window
  255.   LIST_WINDOW_WIDTH = 192
  256.   #  BASIC_DATA_TYPES  - This lets you set up additional types of data. Just
  257.   # include an identifying signal in the Array. Then, you will need to give
  258.   # each signal an icon (in the ICONS hash at line 322) and a signal text (in
  259.   # the VOCAB array at line 333, though it can be an empty string). Then, you
  260.   # can set the data itself when setting up quests by simply adding a:
  261.   #    q[:symbol] = ""
  262.   # line to the quest. You will also need to include the data type somewhere in
  263.   # the DATA_LAYOUT at line 306. As an example of this, I have included :client
  264.   # and :location by default. You can CTRL+F for anything in this section with
  265.   # one of those symbols (excluding :) and you will there need to add something
  266.   # for any new data types you add.
  267.   BASIC_DATA_TYPES = [:client, :location]
  268.   #  BASIC_DATA_WIDTH - This determines how much room, in pixels, is given to  
  269.   # any basic data types you set up in the data window.
  270.   BASIC_DATA_WIDTH = 240
  271.   #  CONCURRENT_ACTIVITY - If true, then when in the Quest Journal scene, you
  272.   # can switch categories or scroll down the quest list at the same time. If
  273.   # false, you will first need to select a category before you can start
  274.   # scrolling through the quest list.
  275.   CONCURRENT_ACTIVITY = true
  276.   #  HIDE_CATEGORY_CURSOR - If true, then the Category Window will not have a
  277.   # cursor and will instead just highlight the currently selected category.
  278.   # This is best when CONCURRENT_ACTIVITY is true.
  279.   HIDE_CATEGORY_CURSOR = true
  280.   #  SHOW_QUEST_ICONS - If true, then the icon you choose for each quest will
  281.   # be displayed to the left of its name in the Quest List window
  282.   SHOW_QUEST_ICONS = true
  283.   #  MANUAL_REVEAL - If false, then quests will be revealed the moment you
  284.   # first reveal, complete, or fail an objective. If this is true, you will
  285.   # need to specifically reveal each quest via a separate script call:
  286.   #    reveal_quest(quest_id)
  287.   MANUAL_REVEAL = false
  288.   #  DATA_LAYOUT - This controls the way that the quest window lays out all of
  289.   # the relevant data. If you set one of the entries to be an array, then any
  290.   # of the commands there will be drawn at the same y. With exception to :line,
  291.   # none of the commands will be drawn if the quest is not set to have that
  292.   # particular data. The symbols are:
  293.   #    :line        - Draws a horizontal line across the window.
  294.   #    :name        - Draws the name of the quest
  295.   #    :level       - Draws the level of the quest
  296.   #    :banner      - Draws the banner for the quest
  297.   #    :client      - Draws the client set in the quest   (basic data)
  298.   #    :location    - Draws the location set in the quest (basic data)
  299.   #    :description - Draws the quest's description
  300.   #    :objectives  - Draws all the quest's objectives that have been revealed
  301.   #    :rewards     - Draws whatever rewards have been set
  302.   #
  303.   # You will also need to add an entry for any new BASIC_DATA that you place
  304.   # in BASIC_DATA_TYPES at line 264.
  305.   #
  306.   # Remember to place a comma after each entry. Also note that this is only the
  307.   # default layout. You can set a different layout for any quest, and when
  308.   # viewing that quest, it will be the custom layout that is shown.
  309.   DATA_LAYOUT = [
  310.     [:line, :name, :level],
  311.     :banner,
  312.     :client,
  313.     :location,
  314.     :description,
  315.     :objectives,
  316.     [:line, :rewards],
  317.     :line,
  318.   ] # <= Do not touch.
  319.   #  ICONS - This is where you setup many of the icons used in the script. The
  320.   # purpose of each is listed next to it. Also, if you make any custom
  321.   # categories, you NEED to give them an icon by placing a line like the
  322.   # others. So, if the new custom category is :romance then you would need to
  323.   # set it like this:
  324.   #    romance:     107,
  325.   ICONS = {
  326.     all:         226, # The icon for the All Quests category
  327.     active:      236, # The icon for the Active Quests category
  328.     complete:    238, # The icon for the Complete Quests category
  329.     failed:      227, # The icon for the Failed Quests category
  330.     client:      121, # The icon for client data. If none wanted, set to 0
  331.     location:    231, # The icon for location data. If none wanted, set to 0
  332.     reward_gold: 262, # The icon for gold rewards. If none wanted, set to 0
  333.     reward_exp:  117, # The icon for exp rewards. If none wanted, set to 0
  334.   } # <= Do not touch.
  335.   #  VOCAB - This lets you choose some of the words used in the quest scene
  336.   VOCAB = {
  337.     # menu_label:  The command name in the menu if MENU_ACCESS is true
  338.     menu_label:       "Quests",
  339.     # scene_label: The label at the top of the scene. If empty, no window
  340.     scene_label:      "Quest Journal",
  341.     # description: The heading to identify the description
  342.     description:      "Description",
  343.     # objectives: The heading to identify the objectives
  344.     objectives:       "Objectives",
  345.     # objective_bullet: The bullet which shows up to the left of every
  346.     #  objective. If %d is included, it shows the objective's ID.
  347.     objective_bullet: "♦",
  348.     # rewards: The heading to identify the rewards.
  349.     rewards:          "Rewards",
  350.     # reward_amount: For item rewards, this is the text to show the amount.
  351.     #  It should include %d to show the amount.
  352.     reward_amount:    "x%d",
  353.     # reward_gold: Text to identify gold rewards
  354.     reward_gold:      "",
  355.     # reward_exp: Text to identify exp rewards
  356.     reward_exp:       "",
  357.     # level: If LEVEL_ICON is 0, this is the text which precedes the level
  358.     level:            "Rank: ",
  359.     # location: The text label for quest location
  360.     location:         "",
  361.     # location: The text label for quest client
  362.     client:           "",
  363.   } # <= Do not touch.
  364.   #  CATEGORIES - This array allows you to set which categories are available
  365.   # in the Quest scene. The default categories are :all, :active, :complete,
  366.   # and :failed, and their names are self-explanatory. You can add custom
  367.   # categories as well, but note that you will need to make sure that each new
  368.   # category has an icon set in the ICONS hash, as well as a label set in the
  369.   # CATEGORY_VOCAB hash (if you are using SHOW_CATEGORY_LABEL). It is also
  370.   # advisable to give it a sort type, unless you are fine with it being sorted
  371.   # by ID, as is default.
  372.   CATEGORIES = [:all, :active, :complete, :failed]
  373.   #  SHOW_CATEGORY_LABEL - This allows you to choose whether to show the name
  374.   # of the currently selected category. If true, it will choose the name out
  375.   # of the CATEGORY_VOCAB hash.
  376.   SHOW_CATEGORY_LABEL = true
  377.   #  CATEGORY_LABEL_IN_SAME_WINDOW - If SHOW_CATEGORY_LABEL is true, then this
  378.   # options lets you choose whether the label is shown in the same window as
  379.   # the category icons or in a separate window below. true = same window.
  380.   CATEGORY_LABEL_IN_SAME_WINDOW = true
  381.   #  CATEGORY_VOCAB - If SHOW_CATEGORY_LABEL is true, this hash lets you set the
  382.   # label for each category. For any custom categories you create, you will
  383.   # need to add a line for each below and in the same format:
  384.   #    :category => "Label",
  385.   # Don't forget to add the comma at the end of each line.
  386.   CATEGORY_VOCAB = {
  387.     :all =>      "All Quests",      # The label for the :all category
  388.     :active =>   "Active Quests",   # The label for the :active category
  389.     :complete => "Complete Quests", # The label for the :complete category
  390.     :failed =>   "Failed Quests",   # The label for the :failed category
  391.   } # <= Do not touch.
  392.   #  SORT_TYPE - This hash allows you to choose how each category is sorted.
  393.   # For each category, default or custom, you can set a different sort method
  394.   # There are seven options to choose from:
  395.   #    :id - The quests are sorted from lowest to highest ID
  396.   #    :alphabet - The quests are sorted in alphabetical order
  397.   #    :level - The quests are sorted from the lowest to highest level
  398.   #    :reveal - The quests are sorted from most recently revealed on.
  399.   #            Every time a new quest is revealed, it will be at the top.
  400.   #    :change - The quests are sorted from the one whose status most recently
  401.   #            changed on. So, every time an objective is modified, that quest
  402.   #            will be thrown to the top.
  403.   #    :complete - The quests are sorted from the most recently completed on.
  404.   #            Every time a quest is completed, it will be thrown to the top.
  405.   #    :failed - The quests are sorted from the most recently failed on.
  406.   #            Every time a quest is failed, it will be thrown to the top.
  407.   #
  408.   # Additionally, you can put _r at the end of any of the sort options and it
  409.   # will reverse the order. So, for instance, if the sort method for a category
  410.   # is :alphabet_r, then the quests will show up from Z-A
  411.   SORT_TYPE = {
  412.     :all =>      :id,       # Sort type for the All Quests category
  413.     :active =>   :change,   # Sort type for the Active Quests category
  414.     :complete => :complete, # Sort type for the Complete Quests category
  415.     :failed =>   :failed,   # Sort type for the Failed Quests category
  416.   } # <= Do not touch.
  417.   #  WINDOWSKIN - The windowskin for each window in the Quest scene. It must
  418.   # refer to a graphic in the System folder of Graphics. If set to false, then
  419.   # it will use whatever windowskin is default. If you are using a script which
  420.   # lets the player choose the windowskin, false is the recommended value.
  421.   WINDOWSKIN = false
  422.   #  WINDOW_TONE - The tone for each window. It must be an array in the form:
  423.   #      WINDOW_TONE = [red, green, blue, gray]
  424.   # gray can be excluded, but the other three must be present. If you set this
  425.   # value to false, then the windows will have whatever tone is default.
  426.   WINDOW_TONE = false
  427.   #  WINDOW_OPACITY - The opacity of the windows in the Quest scene. If set to
  428.   # false, it will use the default opacity for windows.
  429.   WINDOW_OPACITY = false
  430.   #  BG_PICTURE - This is a string referring to a picture in the Picture folder
  431.   # of Graphics. If set to "", then there will be no picture. Otherwise, it
  432.   # will display the selected picture below the windows but above the map in
  433.   # the Quest scene.
  434.   BG_PICTURE = ""
  435.   #  BG_OPACITY - This allows you to set the opacity of the background picture,
  436.   # if you have selected one.
  437.   BG_OPACITY = 255
  438.   #  BG_BLEND_TYPE - This allows you to set the blend type of the background
  439.   # picture, if you have selected one.
  440.   BG_BLEND_TYPE = 0
  441.   #  DESCRIPTION_IN_BOX - This is a graphical option, and it allows you to
  442.   # choose whether the description should be shown in a box.
  443.   DESCRIPTION_IN_BOX = true
  444.   #  LEVEL_ICON - This sets how levels are shown. If set to an integer, then it
  445.   # will draw the same icon numerous times up to the level of the quest. Ie. If
  446.   # the level's quest is 1, then the icon will only be drawn once, but if the
  447.   # level's quest is 4, it will be drawn 4 times. LEVEL_ICONS_SPACE determines
  448.   # the space between them. If you set LEVEL_ICON to 0, however, then it will
  449.   # instead draw a signal for the level, corresponding to that index in the
  450.   # LEVEL_SIGNALS array. If the LEVEL_SIGNALS array is empty, then it will just
  451.   # draw the integer for the level. Finally, LEVEL_ICON can also be an array of
  452.   # integers, in which case the level will be represented only by the icon set
  453.   # which corresponds to it in the array.
  454.   LEVEL_ICON = 125
  455.   #  LEVEL_ICONS_SPACE - If LEVEL_ICON is an integer, this is the amount of
  456.   # space between each time the icon is drawn.
  457.   LEVEL_ICONS_SPACE = 16
  458.   #  LEVEL_SIGNALS - If LEVEL_ICON is 0, this allows you to set what string
  459.   # should be the signal for each level. If this array is empty, then it will
  460.   # just draw the level integer. Ie. if the Quest is Level 4, it will draw 4.
  461.   LEVEL_SIGNALS = ["F", "E", "D", "C", "B", "A", "S"]
  462.   #  COLOURS - This lets you change the colour for various aspects of the
  463.   # quest scene. Each can be set in one of three ways:
  464.   #    :symbol - If you use a symbol, the colour will be the result of calling
  465.   #      the method of the same name. For instance, if you set something to
  466.   #      :system_color, it will set the colour to the result of the Window_Base
  467.   #      system_color method.
  468.   #    Integer - If you set the colour to an integer, then it will take its
  469.   #      colour from the windowskin palette, just like using \c[x] in messages.
  470.   #    Array - You can also set the rgba values directly with an array in the
  471.   #      format: [red, green, blue, alpha]. alpha can be excluded, but you must
  472.   #      have values for red, green, and blue.
  473.   COLOURS = {
  474.     # active: This sets the colour for active quests in the list and the name
  475.     #  of the active quest when shown in the data window.
  476.     active:           :normal_color,
  477.     # complete: This sets the colour for complete quests in the list and the
  478.     #  name of the complete quest when shown in the data window.
  479.     complete:         3,
  480.     # failed: This sets the colour for failed quests in the list and the name
  481.     #  of the failed quest when shown in the data window.
  482.     failed:           10,
  483.     # line:  This sets the colour for lines or boxes drawn in the quest scene
  484.     line:             :system_color,
  485.     # line_shadow:  This sets the colour of the shadow for lines or boxes drawn
  486.     #  in the quest scene
  487.     line_shadow: [0, 0, 0, 128],
  488.     # scene_label: This sets the colour for the scene label, if shown
  489.     scene_label:      :system_color,
  490.     # category_label: This sets the colour for the category label, if shown
  491.     category_label:   :normal_color,
  492.     # level_signal: This sets the colour for the level signal, if shown
  493.     level_signal:     :normal_color,
  494.     # objective_bullet: This sets the colour for objectives; if set to
  495.     #  :maqj_objective_color, it will reflect the completion status of the
  496.     #  objective, but you can change it to something else if you prefer
  497.     objective_bullet: :maqj_objective_color,
  498.     # reward_amount: The colour of the item amount, when shown
  499.     reward_amount:    :normal_color,
  500.     # heading: The colour of any headings in the script, like "Description"
  501.     heading:          :system_color,
  502.     # basic_label: For basic data, like client, the colour of the label
  503.     basic_label:      :system_color,
  504.     # basic_value: For basic data, like client, the colour of the value
  505.     basic_value:      :normal_color,
  506.   } # <= Do not touch.
  507.   #  HEADING_ALIGN - This sets the alignment for the aspects listed. 0 is Left;
  508.   # 1 is Centre; 2 is Right
  509.   HEADING_ALIGN = {
  510.     description: 0, # Alignment for the Description heading
  511.     objectives:  0, # Alignment for the Objectives heading
  512.     rewards:     1, # Alignment for the Rewards heading
  513.     level:       2  # Alignment when showing the level
  514.   } # <= Do not touch.
  515.   #````````````````````````````````````````````````````````````````````````````
  516.   #    Font Aspects
  517.   #
  518.   #  All of the following options (FONTNAMES, FONTSIZES, FONTBOLDS, and
  519.   # FONTITALICS) allow you to alter the fonts used for various aspects of the
  520.   # scene. The only one listed there by default is normal:, which is the
  521.   # font used by default for the entire scene. However, you can change the  
  522.   # fonts for almost any aspect - all you need to do is add a line like so:
  523.   #
  524.   #    description: value,
  525.   #
  526.   # and that will change that font aspect when drawing the description. The
  527.   # following symbols are available for changing:
  528.   #
  529.   #   normal:         The default font used for every part of the scene
  530.   #   list:           The font used in the List Window
  531.   #   scene_label:    The font used when drawing the Scene Label, if shown
  532.   #   category_label: The font used when drawing the Category Label, if shown
  533.   #   heading:        The font used when drawing any headings, like "Description"
  534.   #   name:           The font used when drawing the quest name in data window
  535.   #   description:    The font used when drawing the Description
  536.   #   objectives:     The font used when drawing the objectives
  537.   #   rewards:        The font used when drawing the rewards
  538.   #   client:         The font used when drawing the client
  539.   #   location:       The font used when drawing the location
  540.   #
  541.   # For any of them, you need to set a value. What the value can be depends
  542.   # on which font aspect you are changing and is described below, but for any
  543.   # of them setting it to the false will mean it will simply use the default
  544.   #
  545.   # For any that you add, remember that you must put a comma after the value.
  546.   #````````````````````````````````````````````````````````````````````````````
  547.   #  FONTNAMES - Here you can change the font used for any of the various
  548.   # options. It can take any of the following types of values:
  549.   #     false    - The default font will be used
  550.   #     "String" - The font with the name "String" will be used.
  551.   #     [Array]  - The array must be in the form: ["String1", "String2", ...]
  552.   #               The font used will be the first one in the array that the
  553.   #               player has installed.
  554.   #
  555.   #  EXAMPLES:
  556.   #
  557.   #    normal:      false,
  558.   #      The font used for unaltered aspects of the scene is the default font
  559.   #    scene_label: "Algerian",
  560.   #      The font used for the Scene Label will be Algerian.
  561.   #    description: ["Cambria", "Times New Roman"],
  562.   #      The font used when drawing the description will be Cambria if the
  563.   #      player has Cambria installed. If the player does not have Cambria
  564.   #      installed, then the font used will be Times New Roman
  565.   FONTNAMES = {
  566.     normal: false, # normal: the default font name
  567.   } # <= Do not touch.
  568.   #  FONTSIZES - Here you can change the size of the font. There are two types
  569.   # of values you can set:
  570.   #    false   - The default fontsize will be used
  571.   #    Integer - The fontsize will be equal to the value of the Integer.
  572.   #  
  573.   # For everything but the label windows, this shouldn't exceed 24, since that
  574.   # is the line_height. However, for scene_label: and category_label:, the size
  575.   # of the window will be adjusted to whatever size you set the font.
  576.   FONTSIZES = {
  577.     normal:         false, # normal: default font size
  578.     scene_label:    28,    # scene_label: fontsize for the Scene Label window
  579.     category_label: 24,    # category_label: fontsize for Category Label window
  580.   } # <= Do not touch.
  581.   #  FONTBOLDS - Here you can set whether the font will be bolded. You can set
  582.   # it to either false, in which case it will not be bolded, or true, in which
  583.   # case it will be bolded.
  584.   FONTBOLDS = {
  585.     scene_label:  true, # scene_label: whether font is bold for Scene Label
  586.     heading:      true, # heading: whether font is bold for the headings
  587.     level_signal: true, # level_signal: whether font is bold for level
  588.   } # <= Do not touch.
  589.   #  FONTITALICS - Here you can set whether the font will be italicized. You
  590.   # can set it to either false, in which case it will not be italicized, or
  591.   # true, in which case it will be italicized.
  592.   FONTITALICS = {
  593.   }
  594.   #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  595.   #  END Editable Region A
  596.   #//////////////////////////////////////////////////////////////////////////
  597.   CATEGORIES = [:all] if !CATEGORIES || CATEGORIES.empty?
  598.   VOCAB.default = ""
  599.   ICONS.default = 0
  600.   CATEGORY_VOCAB.default = ""
  601.   SORT_TYPE.default = :id
  602.   COLOURS.default = :normal_color
  603.   HEADING_ALIGN.default = 0
  604.   FONTNAMES.default = false
  605.   FONTSIZES.default = false
  606.   FONTBOLDS.default = false
  607.   FONTITALICS.default = false
  608.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  609.   # * Setup Quest
  610.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  611.   def self.setup_quest(quest_id)
  612.     q = { objectives: [] }
  613.     case quest_id
  614.     #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  615.     #  BEGIN Editable Region B
  616.     #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  617.     #    Quest Setup
  618.     #
  619.     #  This is where you set up the data for every quest in the game. While
  620.     # it may seem complicated, I urge you to pay attention and, once you get
  621.     # the hang of it, I am sure it will quickly become second nature.
  622.     #
  623.     #  Every single quest should be set up in the following format, but note
  624.     # that if you are not setting anything for a particular aspect, you can
  625.     # delete that line. Anyway, this is what each quest should look like, with
  626.     # the values on the left being the default values if you don't set them:
  627.     #
  628.     #  when quest_id
  629.     #   q[:name]              = "??????"
  630.     #   q[:icon_index]        = 0
  631.     #   q[:level]             = 0
  632.     #   q[:description]       = ""
  633.     #   q[:banner]            = ""
  634.     #   q[:banner_hue]        = 0
  635.     #   q[:objectives][0]     = ""
  636.     #   q[:objectives][1]     = ""
  637.     #   q[:objectives][2]     = ""
  638.     #   q[:objectives][n]     = ""
  639.     #   q[:prime_objectives]  = [0, 1, 2, n]
  640.     #   q[:custom_categories] = []
  641.     #   q[:client]            = ""
  642.     #   q[:location]          = ""
  643.     #   q[:rewards]           = []
  644.     #   q[:common_event_id]   = 0
  645.     #   q[:layout]            = false
  646.     #
  647.     #  For each line, with the exception of objectives, it is only the value on
  648.     # the right of the equals sign that you will need to change. Now I will
  649.     # explain each line:
  650.     #
  651.     # when quest_id
  652.     #    quest_id - is an integer of your choosing, and this is how you
  653.     #        reference a quest in order to advance and do anything else. It
  654.     #        must be unique for every quest; if you use 1 for the first quest,
  655.     #        you cannot use 1 for any other quest.
  656.     #
  657.     #   q[:name]              = ""
  658.     #     "" - This line sets the name of the quest which shows in the Quest
  659.     #        List.
  660.     #  
  661.     #   q[:icon_index]        = 0
  662.     #     0  - This line sets the icon to be used for this quest. It will show
  663.     #        to the left of the quest's name in the Quest List.
  664.     #
  665.     #   q[:level]             = 0
  666.     #     0  - This line sets the level of the quest. If 0, no level will be
  667.     #        shown. See the level options at lines 441-458 for more detail.
  668.     #  
  669.     #   q[:description]       = ""
  670.     #     "" - This line sets the description of the quest. You can use message
  671.     #        codes in this string, but if you are using "" then you need to use
  672.     #        \\ to identify codes and not just \. Ie. It's \\v[x], not \v[x]
  673.     #
  674.     #   q[:objectives][0]     = ""
  675.     #   q[:objectives][1]     = ""
  676.     #   q[:objectives][2]     = ""
  677.     #   q[:objectives][n]     = ""
  678.     #  Objectives are slightly different. Notice that after q[:objectives] on
  679.     # each line there is an integer enclosed in square brackets:
  680.     #    [n] - This is the ID of the objective, and n MUST be an integer. No
  681.     #       quest can have more than one objective with the same ID. This is
  682.     #       how you identify which objective you want to reveal, complete or
  683.     #       fail. That said, you can make as many objectives as you want, as
  684.     #       long as you give them all distinct IDs. The IDs should be in
  685.     #       sequence as well, so there shouldn't be a q[:objectives][5] if
  686.     #       there is no q[:objectives][4].
  687.     #     "" - This is the text of the objective. You can use message codes in
  688.     #        this string, but if you are using "" then you will need to use
  689.     #        \\ to identify codes and not just \. Ie: It's \\v[x], not \v[x]
  690.     #
  691.     #   q[:prime_objectives]  = [0, 1, 2, n]
  692.     #     [0, 1, 2, n] - This array determines what objectives need to be
  693.     #        completed in order for the quest to be complete. In other words,
  694.     #        all of the objectives with the IDs in this array need to be
  695.     #        complete for the quest to be complete. If any one of them is
  696.     #        failed, the quest will be failed. If you remove this line
  697.     #        altogether, then all objectives are prime. If you set this to [],
  698.     #        then the quest will never be automatically completed or failed and
  699.     #        you need to use the manual options described at lines 208-219.
  700.     #
  701.     #   q[:custom_categories] = []
  702.     #     [] - This allows you to set an array of custom categories for this
  703.     #        quest, whiich means this quest will show up in each of those
  704.     #        categories if you add it to the CATEGORIES array at line 370.
  705.     #        Note that each category you make must be identified by a unique
  706.     #        :symbol, and you must set up all the category details for that
  707.     #        :symbol.
  708.     #
  709.     #   q[:banner]            = ""
  710.     #     "" - This line sets the banner to be used for a quest. It must be the
  711.     #        filename of an image in the Pictures folder of Graphics.
  712.     #
  713.     #   q[:banner_hue]        = 0
  714.     #     0 - The hue of the banner graphic, if used
  715.     #
  716.     #   q[:client]            = ""
  717.     #     "" - This line sets the client name for this quest. (basic data)
  718.     #
  719.     #   q[:location]          = ""
  720.     #     "" - This line sets the location of the quest. (basic data)
  721.     #
  722.     #   q[:rewards]           = []
  723.     #    [] - In this array, you can identify particular rewards that will
  724.     #       show up. Each reward should be in its own array and can be any of
  725.     #       the following:
  726.     #          [:item, ID, n],
  727.     #          [:weapon, ID, n],
  728.     #          [:armor, ID, n],
  729.     #          [:gold, n],
  730.     #          [:exp, n],
  731.     #       where ID is the ID of the item, weapon or armour you want
  732.     #       distributed and n is the amount of the item, weapon, armor, gold,
  733.     #       or experience you want distributed. Additionally, you can also set
  734.     #       some text to show up in the rewards format but which wouldn't be
  735.     #       automatically distributed. You would need to specify that type of
  736.     #       reward text in the following format:
  737.     #          [:string, icon_index, "string", "vocab"],
  738.     #       where icon_index is the icon to be shown, "string" is what you
  739.     #       would show up as the amount, and "vocab" is what would show up as a
  740.     #       label between the icon and the amount.
  741.     #      
  742.     #
  743.     #   q[:common_event_id]   = 0
  744.     #     0  - This allows you to call the identified common event immediately
  745.     #        and automatically once the quest is completed. It is generally
  746.     #        not recommended, as for most quests you should be controlling it
  747.     #        enough not to need this feature.
  748.     #
  749.     #   q[:layout]            = false
  750.     #     false - The default value for this is false, and when it is false the
  751.     #        layout for the quest will be inherited from the default you set at
  752.     #        302. However, you can also give the quest its own layout - the
  753.     #        format would be the same as you set for the default at line 307.
  754.     #  
  755.     # Template:
  756.     #
  757.     #  When making a new quest, I recommend that you copy and paste the
  758.     # following template, removing whichever lines you don't want to alter.
  759.     # Naturally, you need to remove the #~. You can do so by highlighting
  760.     # the entire thing and pressing CTRL+Q:
  761. #~     when 2 # <= REMINDER: The Quest ID MUST be unique
  762. #~       q[:name]              = "??????"
  763. #~       q[:icon_index]        = 0
  764. #~       q[:level]             = 0
  765. #~       q[:description]       = ""
  766. #~       # REMINDER: You can make as many objectives as you like, but each must
  767. #~       # have a unique ID.
  768. #~       q[:objectives][0]     = ""
  769. #~       q[:objectives][1]     = ""
  770. #~       q[:objectives][2]     = ""
  771. #~       q[:prime_objectives]  = [0, 1, 2]
  772. #~       q[:custom_categories] = []
  773. #~       q[:banner]            = ""
  774. #~       q[:banner_hue]        = 0
  775. #~       q[:client]            = ""
  776. #~       q[:location]          = ""
  777. #~       q[:rewards]           = []
  778. #~       q[:common_event_id]   = 0
  779.     when 1 # Quest 1 - SAMPLE QUEST
  780.       q[:name]              = "New beginning"
  781.       q[:level]             = 1
  782.       q[:icon_index]        = 125
  783.       q[:description]       = "You need a place to sleep"
  784.       q[:objectives][0]     = "Go to the campsite"
  785.       q[:objectives][1]     = "Find and talk to the camp leader"
  786.       q[:objectives][2]     = "Find the sleeping tent"
  787.       q[:objectives][3]     = "Find Bryant in Bridgeworth Inn"
  788.       q[:prime_objectives]  = [0, 1, 2, 3]
  789.       q[:custom_categories] = [ ]
  790.       q[:banner]            = ""
  791.       q[:banner_hue]        = 0
  792.       q[:client]            = "Story Quest"
  793.       q[:location]          = "Campsite"
  794.       q[:common_event_id]   = 0
  795.       q[:rewards]           = [
  796.         [:exp, 20],
  797.     ]when 2
  798.       q[:name]              = "Tomato Run!"
  799.       q[:level]             = 1
  800.       q[:icon_index]        = 126
  801.       q[:description]       = "A local woman needs 50 tomatoes"
  802.       q[:objectives][0]     = "Go to the campsite"
  803.       q[:objectives][1]     = "Get a box of tomatoes"
  804.       q[:objectives][2]     = "Go back to the Bridgeworth Groceries"
  805.       q[:objectives][3]     = "Talk to Lyn"
  806.       q[:prime_objectives]  = [0, 1, 2, 3]
  807.       q[:custom_categories] = []
  808.       q[:banner]            = ""
  809.       q[:banner_hue]        = 0
  810.       q[:client]            = "Side Quest"
  811.       q[:location]          = "Brians Groceries"
  812.       q[:common_event_id]   = 0
  813.       q[:rewards]           = [
  814.         [:exp, 20],
  815.         [:gold, 20],
  816.     ]when 3
  817.       q[:name]              = "Gain power!"
  818.       q[:level]             = 1
  819.       q[:icon_index]        = 125
  820.       q[:description]       = "We need to get stronger"
  821.       q[:objectives][0]     = "Find the trainer in Bridgeworth South"
  822.       q[:objectives][1]     = "Talk to the trainer"
  823.       q[:objectives][2]     = "Train!"
  824.       q[:prime_objectives]  = [0, 1, 2]
  825.       q[:custom_categories] = []
  826.       q[:banner]            = ""
  827.       q[:banner_hue]        = 0
  828.       q[:client]            = "Story Quest"
  829.       q[:location]          = "Bridgeworth South"
  830.       q[:common_event_id]   = 0
  831.       q[:rewards]           = [
  832.         [:exp, 20],
  833.     ]when 4
  834.       q[:name]              = "New Equipment"
  835.       q[:level]             = 1
  836.       q[:icon_index]        = 125
  837.       q[:description]       = "We need better protection"
  838.       q[:objectives][0]     = "Find the armory in Bridgeworth North"
  839.       q[:objectives][1]     = "Talk to Raymond"
  840.       q[:objectives][2]     = "Receive new equipment"
  841.       q[:prime_objectives]  = [0, 1, 2]
  842.       q[:custom_categories] = []
  843.       q[:banner]            = ""
  844.       q[:banner_hue]        = 0
  845.       q[:client]            = "Story Quest"
  846.       q[:location]          = "Bridgeworth North"
  847.       q[:common_event_id]   = 0
  848.       q[:rewards]           = [
  849.         [:exp, 50],
  850.         [:gold, 150],
  851.     ]when 5
  852.       q[:name]              = "Potions"
  853.       q[:level]             = 3
  854.       q[:icon_index]        = 125
  855.       q[:description]       = "Daniella will help you get potions"
  856.       q[:objectives][0]     = "Find her house"
  857.       q[:objectives][1]     = "Talk to Daniella"
  858.       q[:objectives][2]     = "Collect 5 Skeleton Heads and 5 Eger"
  859.       q[:objectives][3]     = "Talk to Daniella again"
  860.       q[:prime_objectives]  = [0, 1, 2, 3]
  861.       q[:custom_categories] = []
  862.       q[:banner]            = ""
  863.       q[:banner_hue]        = 0
  864.       q[:client]            = "Story Quest"
  865.       q[:location]          = "Bridgeworth North"
  866.       q[:common_event_id]   = 0
  867.       q[:rewards]           = [
  868.         [:exp, 30],
  869.         [:gold, 50],
  870.       q[:layout]            = false
  871.     ]
  872.     #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  873.     #  END Editable Region B
  874.     #//////////////////////////////////////////////////////////////////////
  875.     end
  876.     q
  877.   end
  878. end
  879.  
  880. #==============================================================================
  881. # *** DataManager
  882. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  883. #  Summary of Changes:
  884. #    aliased method - self.extract_save_contents
  885. #==============================================================================
  886.  
  887. class << DataManager
  888.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  889.   # * Extract Save Contents
  890.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  891.   alias maqj_extractsavecons_2kw5 extract_save_contents
  892.   def extract_save_contents(*args, &block)
  893.     maqj_extractsavecons_2kw5(*args, &block) # Call Original Method
  894.     if $game_party.quests.nil?
  895.       $game_party.init_maqj_data
  896.       $game_system.init_maqj_data
  897.     end
  898.   end
  899. end
  900.  
  901. #==============================================================================
  902. # ** MAQJ_SortedArray
  903. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  904. #  This module mixes in to an array to maintain the sorted order when inserting
  905. #==============================================================================
  906.  
  907. module MAQJ_SortedArray
  908.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  909.   # * Insert to Array
  910.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  911.   def maqj_insert_sort(el, &block)
  912.     index = bsearch_index(el, 0, size, &block)
  913.     index ? insert(index, el) : push(el)
  914.   end
  915.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  916.   # * Retrieve Index from Binary Search
  917.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  918.   def bsearch_index(el, b = 0, e = size, &block)
  919.     return bsearch_index(el, b, e) { |a,b| a <=> b } if block.nil?
  920.     return b if b == e # Return the discovered insertion index
  921.     return if b > e
  922.     m = (b + e) / 2    # Get Middle
  923.     block.call(el, self[m]) > 0 ? b = m + 1 : e = m
  924.     bsearch_index(el, b, e, &block)
  925.   end
  926. end
  927.  
  928. #==============================================================================
  929. # ** Game_Quest
  930. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  931. #  This class holds all instance data for a quest
  932. #==============================================================================
  933.  
  934. class Game_Quest
  935.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  936.   # * Public Instance Variables
  937.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  938.   attr_reader   :id                  # Unique identifier for this quest
  939.   attr_reader   :name                # The name to be shown for the quest
  940.   attr_reader   :level               # The level of difficulty of the quest
  941.   attr_reader   :objectives          # An array of objective strings
  942.   attr_reader   :prime_objectives    # An array of crucial objective IDs
  943.   attr_reader   :revealed_objectives # An array of revealed objective IDs
  944.   attr_reader   :complete_objectives # An array of completed objective IDs
  945.   attr_reader   :failed_objectives   # An array of failed objective IDs
  946.   attr_reader   :custom_categories   # An array of category symbols
  947.   attr_accessor :icon_index          # Icon associated with this quest
  948.   attr_accessor :common_event_id     # ID of common event to call upon complete
  949.   attr_accessor :description         # The description for the quest
  950.   attr_accessor :banner              # Picture shown to represent the quest
  951.   attr_accessor :banner_hue          # The hue of the banner
  952.   attr_accessor :layout              # The layout of this quest in scene
  953.   attr_accessor :rewards             # An array of rewards to show
  954.   attr_accessor :reward_given        # Boolean tracking if quest was rewarded
  955.   attr_accessor :concealed           # Whether or not the quest is visible
  956.   attr_accessor :manual_status       # Quest status if not using prime objectives
  957.   QuestData::BASIC_DATA_TYPES.each { |data_type| attr_accessor(data_type) }
  958.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  959.   # * Object Initialization
  960.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  961.   def initialize(quest_id)
  962.     @id = quest_id
  963.     @concealed = default_value_for(:concealed)
  964.     @reward_given = default_value_for(:reward_given)
  965.     reset
  966.   end
  967.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  968.   # * Reset
  969.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  970.   def reset
  971.     data = QuestData.setup_quest(@id)
  972.     data_symbol_array.each { |meth| instance_variable_set(:"@#{meth}",
  973.       data[meth] ? data[meth] : default_value_for(meth)) }
  974.     @revealed_objectives = [].send(:extend, MAQJ_SortedArray)
  975.     @complete_objectives = [].send(:extend, MAQJ_SortedArray)
  976.     @failed_objectives =   [].send(:extend, MAQJ_SortedArray)
  977.     @manual_status = default_value_for(:manual_status)
  978.   end
  979.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  980.   # * Data Symbol Array
  981.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  982.   def data_symbol_array
  983.     [:name, :level, :objectives, :prime_objectives, :custom_categories,
  984.       :icon_index, :description, :banner, :banner_hue, :common_event_id,
  985.       :layout, :rewards] + QuestData::BASIC_DATA_TYPES
  986.   end
  987.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  988.   # * Default Value
  989.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  990.   def default_value_for(method)
  991.     case method
  992.     when :name then "??????"
  993.     when :description, :banner then ""
  994.     when :level, :banner_hue, :icon_index, :common_event_id then 0
  995.     when :objectives, :rewards, :custom_categories then []
  996.     when :prime_objectives then Array.new(objectives.size) { |x| x }
  997.     when :concealed then QuestData::MANUAL_REVEAL
  998.     when :manual_status then :active
  999.     when :layout, :reward_given then false
  1000.     else ""
  1001.     end
  1002.   end
  1003.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1004.   # * Reveal/Conceal Objective
  1005.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1006.   def reveal_objective(*obj)
  1007.     valid_obj = obj.select {|x| x < objectives.size && !@revealed_objectives.include?(x) }
  1008.     valid_obj.each {|i| @revealed_objectives.maqj_insert_sort(i) }
  1009.     quest_status_changed unless valid_obj.empty?
  1010.   end
  1011.   def conceal_objective(*obj)
  1012.     quest_status_changed unless (obj & @revealed_objectives).empty?
  1013.     obj.each { |obj_id| @revealed_objectives.delete(obj_id) }
  1014.   end
  1015.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1016.   # * Complete/Uncomplete Objective
  1017.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1018.   def complete_objective(*obj)
  1019.     valid_obj = obj.select {|x| x < objectives.size && !@complete_objectives.include?(x) }
  1020.     reveal_objective(*valid_obj)
  1021.     unfail_objective(*valid_obj)
  1022.     was_complete = status?(:complete)
  1023.     valid_obj.each {|i| @complete_objectives.maqj_insert_sort(i) }
  1024.     quest_status_changed unless valid_obj.empty?
  1025.     # If just completed
  1026.     if status?(:complete) && !was_complete
  1027.       $game_temp.reserve_common_event(common_event_id)
  1028.       $game_party.quests.add_to_sort_array(:complete, @id)
  1029.     end
  1030.   end
  1031.   def uncomplete_objective(*obj)
  1032.     quest_status_changed unless (obj & @complete_objectives).empty?
  1033.     obj.each { |obj_id| @complete_objectives.delete(obj_id) }
  1034.   end
  1035.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1036.   # * Fail/Unfail Objective
  1037.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1038.   def fail_objective(*obj)
  1039.     valid_obj = obj.select {|x| x < objectives.size && !@failed_objectives.include?(x) }
  1040.     reveal_objective(*valid_obj)
  1041.     uncomplete_objective(*valid_obj)
  1042.     was_failed = status?(:failed)
  1043.     valid_obj.each {|i| @failed_objectives.maqj_insert_sort(i) }
  1044.     quest_status_changed unless valid_obj.empty?
  1045.     $game_party.quests.add_to_sort_array(:failed, @id) if status?(:failed) && !was_failed
  1046.   end
  1047.   def unfail_objective(*obj)
  1048.     quest_status_changed unless (obj & @failed_objectives).empty?
  1049.     obj.each { |obj_id| @failed_objectives.delete(obj_id) }
  1050.   end
  1051.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1052.   # * Updates when the quest status has been changed
  1053.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1054.   def quest_status_changed
  1055.     $game_party.quests.add_to_sort_array(:change, @id)
  1056.     $game_system.last_quest_id = @id if QuestData::OPEN_TO_LAST_CHANGED_QUEST
  1057.   end
  1058.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1059.   # * Objective Status?
  1060.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1061.   def objective_status?(status_check, *obj)
  1062.     return false if obj.empty?
  1063.     case status_check
  1064.     when :failed   then !(obj & @failed_objectives).empty?
  1065.     when :complete then obj.size == (obj & @complete_objectives).size
  1066.     when :revealed then obj.size == (obj & @revealed_objectives).size
  1067.     when :active then objective_status?(:revealed, *obj) &&
  1068.       !objective_status?(:complete, *obj) && !objective_status?(:failed, *obj)
  1069.     end
  1070.   end
  1071.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1072.   # * Status?
  1073.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1074.   def status?(status_check)
  1075.     case status_check
  1076.     when :failed  
  1077.       @prime_objectives.empty? ? @manual_status == :failed :
  1078.         !(@failed_objectives & @prime_objectives).empty?
  1079.     when :complete
  1080.       @prime_objectives.empty? ? @manual_status == :complete : !status?(:failed) &&
  1081.         ((@prime_objectives & @complete_objectives) == @prime_objectives)
  1082.     when :active then !concealed && !status?(:complete) && !status?(:failed)
  1083.     when :reward then @reward_given
  1084.     end
  1085.   end
  1086.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1087.   # * Set Name
  1088.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1089.   def name=(new_name)
  1090.     @name = new_name
  1091.     $game_party.quests.add_to_sort_array(:alphabet, @id) if $game_party &&
  1092.       $game_party.quests
  1093.   end
  1094.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1095.   # * Set Level
  1096.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1097.   def level=(new_lvl)
  1098.     @level = new_lvl
  1099.     $game_party.quests.add_to_sort_array(:level, @id) if $game_party &&
  1100.       $game_party.quests
  1101.   end
  1102. end
  1103.  
  1104. #==============================================================================
  1105. # ** Game_Quests
  1106. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1107. #  This is a wrapper for an array holding Game_Quest objects
  1108. #==============================================================================
  1109.  
  1110. class Game_Quests
  1111.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1112.   # * Object Initialization
  1113.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1114.   def initialize
  1115.     @data = {}
  1116.     @sort_arrays = {
  1117.       reveal: [], change: [], complete: [], failed: [],
  1118.       id:       [].send(:extend, MAQJ_SortedArray),
  1119.       alphabet: [].send(:extend, MAQJ_SortedArray),
  1120.       level:    [].send(:extend, MAQJ_SortedArray)
  1121.     }
  1122.   end
  1123.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1124.   # * Get Quest
  1125.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1126.   def [](quest_id)
  1127.     reset_quest(quest_id) if !@data[quest_id]
  1128.     @data[quest_id]
  1129.   end
  1130.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1131.   # * Set Quest <- Not sure when this would ever be useful.
  1132.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1133.   def []=(quest_id, value)
  1134.     @data[quest_id] = value
  1135.   end
  1136.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1137.   # * List
  1138.   #    list_type : the type of list to return
  1139.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1140.   def list(list_type = :all, sort_type = $game_system.quest_sort_type[list_type])
  1141.     sort_type_s = sort_type.to_s
  1142.     reverse = !(sort_type_s.sub!(/_r$/, "")).nil?
  1143.     sort_type = sort_type_s.to_sym
  1144.     list = @sort_arrays[sort_type].select { |quest_id| include?(quest_id, list_type) }
  1145.     list.reverse! if reverse
  1146.     list.collect { |quest_id| @data[quest_id] }
  1147.   end
  1148.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1149.   # * Include?
  1150.   #    determines whether to include a particular quest depending on list type
  1151.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1152.   def include?(quest_id, list_type = :all)
  1153.     return false if !revealed?(quest_id)
  1154.     case list_type
  1155.     when :all then true
  1156.     when :complete, :failed, :active then @data[quest_id].status?(list_type)
  1157.     else
  1158.       @data[quest_id].custom_categories.include?(list_type)
  1159.     end
  1160.   end
  1161.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1162.   # * Revealed?
  1163.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1164.   def revealed?(quest_id)
  1165.     (!@data[quest_id].nil? && !@data[quest_id].concealed)
  1166.   end
  1167.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1168.   # * Setup Quest
  1169.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1170.   def setup_quest(quest_id)
  1171.     return if @data[quest_id]
  1172.     @data[quest_id] = Game_Quest.new(quest_id)
  1173.     # Open to this quest next time the QJ is opened
  1174.     $game_system.last_quest_id = quest_id if QuestData::OPEN_TO_LAST_REVEALED_QUEST
  1175.     # Save sorting order in separate arrays to avoid re-sorting every time
  1176.     @sort_arrays.keys.each { |sym| add_to_sort_array(sym, quest_id) }
  1177.   end
  1178.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1179.   # * Delete Quest
  1180.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1181.   def delete_quest(quest_id)
  1182.     @data.delete(quest_id)
  1183.     @sort_arrays.values.each { |ary| ary.delete(quest_id) }
  1184.   end
  1185.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1186.   # * Reset Quest
  1187.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1188.   def reset_quest(quest_id)
  1189.     delete_quest(quest_id)
  1190.     setup_quest(quest_id)
  1191.   end
  1192.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1193.   # * Add to Sorted Array
  1194.   #    sort_type : array to alter
  1195.   #    quest_id  : ID of the quest to add.
  1196.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1197.   def add_to_sort_array(sort_type, quest_id)
  1198.     @sort_arrays[sort_type].delete(quest_id) # Make sure always unique
  1199.     case sort_type
  1200.     when :reveal, :change, :complete, :failed
  1201.       @sort_arrays[sort_type].unshift(quest_id)
  1202.     when :id
  1203.       @sort_arrays[sort_type].maqj_insert_sort(quest_id)
  1204.     when :alphabet
  1205.       @sort_arrays[sort_type].maqj_insert_sort(quest_id) { |a, b| @data[a].name.downcase <=> @data[b].name.downcase }
  1206.     when :level
  1207.       @sort_arrays[sort_type].maqj_insert_sort(quest_id) { |a, b| @data[a].level <=> self[b].level }
  1208.     end
  1209.   end
  1210.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1211.   # * Find Location
  1212.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1213.   def find_location(quest_id, cat = nil)
  1214.     if revealed?(quest_id)
  1215.       categories = $game_system.quest_categories.dup
  1216.       # If cat specified, check in that category first.
  1217.       if cat && categories.include?(cat)
  1218.         categories.delete(cat)
  1219.         categories.unshift(cat)
  1220.       end
  1221.       for category in categories # Check all categories
  1222.         index = list(category).index(@data[quest_id])
  1223.         return category, index if index != nil
  1224.       end
  1225.     end
  1226.     return nil, nil
  1227.   end
  1228.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1229.   # * Clear
  1230.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1231.   def clear
  1232.     @data.clear
  1233.   end
  1234. end
  1235.  
  1236. #==============================================================================
  1237. # ** Game System
  1238. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1239. #  Summary of Changes:
  1240. #    new attr_accessor - quest_menu_access; quest_map_access; quest_sort_type;
  1241. #      quest_bg_picture; quest_bg_opacity; quest_windowskin;
  1242. #      quest_window_opacity; quest_access_disabled; last_quest_cat;
  1243. #      last_quest_id
  1244. #    aliased methods - initialize
  1245. #    new methods - init_maqj_data
  1246. #==============================================================================
  1247.  
  1248. class Game_System
  1249.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1250.   # * Public Instance Variables
  1251.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1252.   attr_reader   :quest_menu_access     # Whether the scene is called from menu
  1253.   attr_accessor :quest_map_access      # Whether the scene is called from map
  1254.   attr_accessor :quest_sort_type       # The sort types for each category
  1255.   attr_accessor :quest_bg_picture      # The filename of the background picture
  1256.   attr_accessor :quest_bg_opacity      # The opacity of the background picture
  1257.   attr_accessor :quest_bg_blend_type   # The blend type of the background pic
  1258.   attr_accessor :quest_windowskin      # The windowskin used for the scene
  1259.   attr_accessor :quest_window_tone     # The tone of windows in the scene
  1260.   attr_accessor :quest_window_opacity  # The opacity of windows in the scene
  1261.   attr_accessor :quest_access_disabled # Whether access to Quests is disabled
  1262.   attr_accessor :quest_categories      # The categories to show in the scene
  1263.   attr_accessor :quest_scene_label     # The label to show in the scene
  1264.   attr_accessor :last_quest_cat        # The category to open to
  1265.   attr_accessor :last_quest_id         # The ID to open to
  1266.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1267.   # * Object Initialization
  1268.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1269.   alias maqj_initialze_2cy9 initialize
  1270.   def initialize(*args, &block)
  1271.     maqj_initialze_2cy9(*args, &block)
  1272.     init_maqj_data
  1273.   end
  1274.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1275.   # * Initialize Quest Data
  1276.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1277.   def init_maqj_data
  1278.     # Initialize new variables
  1279.     self.quest_menu_access = QuestData::MENU_ACCESS
  1280.     @quest_map_access = QuestData::MAP_ACCESS
  1281.     @quest_sort_type = QuestData::SORT_TYPE
  1282.     @quest_bg_picture = QuestData::BG_PICTURE
  1283.     @quest_bg_opacity = QuestData::BG_OPACITY
  1284.     @quest_bg_blend_type = QuestData::BG_BLEND_TYPE
  1285.     @quest_windowskin = QuestData::WINDOWSKIN
  1286.     @quest_window_tone = QuestData::WINDOW_TONE
  1287.     @quest_window_opacity = QuestData::WINDOW_OPACITY
  1288.     @quest_access_disabled = false
  1289.     @quest_categories = QuestData::CATEGORIES
  1290.     @quest_scene_label = QuestData::VOCAB[:scene_label]
  1291.     @last_quest_cat = @quest_categories[0]
  1292.     @last_quest_id = 0
  1293.   end
  1294.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1295.   # * Set Quest Menu Access
  1296.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1297.   def quest_menu_access=(boolean)
  1298.     @quest_menu_access = boolean
  1299.     maic_inserted_menu_commands.delete(:quest_journal)
  1300.     maic_inserted_menu_commands.push(:quest_journal) if @quest_menu_access
  1301.     maic_inserted_menu_commands.sort!
  1302.   end
  1303. end
  1304.  
  1305. #==============================================================================
  1306. # ** Game_Party
  1307. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1308. #  Summary of Changes:
  1309. #    new attr_reader - quests
  1310. #    aliased method - initialize
  1311. #    new method - init_maqj_data
  1312. #==============================================================================
  1313.  
  1314. class Game_Party
  1315.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1316.   # * Public Instance Variables
  1317.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1318.   attr_reader :quests
  1319.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1320.   # * Object Initialization
  1321.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1322.   alias maqj_intiaze_2si9 initialize
  1323.   def initialize(*args, &block)
  1324.     maqj_intiaze_2si9(*args, &block) # Call Original Method
  1325.     init_maqj_data
  1326.   end
  1327.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1328.   # * Initialize Quests
  1329.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1330.   def init_maqj_data
  1331.     @quests = Game_Quests.new # Initialize @quests
  1332.   end
  1333. end
  1334.  
  1335. #==============================================================================
  1336. # ** Game_Interpreter
  1337. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1338. #  Summary of Changes:
  1339. #    new methods - change_quest_access; change_quest_background;
  1340. #      change_quest_windows; setup_quest; delete_quest; reset_quest; quest;
  1341. #      reveal_quest; conceal_quest; manually_complete_quest;
  1342. #      manually_fail_quest; reveal_objective; conceal_objective;
  1343. #      complete_objective; uncomplete_objective; fail_objective;
  1344. #      unfail_objective; quest_revealed?; quest_complete?; quest_active?;
  1345. #      quest_failed?; objective_complete?; objective_active?;
  1346. #      objective_failed?; distribute_quest_rewards; distribute_quest_reward;
  1347. #      call_quest_journal
  1348. #==============================================================================
  1349.  
  1350. class Game_Interpreter
  1351.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1352.   # * Change Quest Access
  1353.   #    sym : symbol representing what aspect of access is being changed
  1354.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1355.   def change_quest_access(sym)
  1356.     case sym
  1357.     when :enable then $game_system.quest_access_disabled = false
  1358.     when :disable then $game_system.quest_access_disabled = true
  1359.     when :enable_menu then $game_system.quest_menu_access = true
  1360.     when :disable_menu then $game_system.quest_menu_access = false
  1361.     when :enable_map then $game_system.quest_map_access = true
  1362.     when :disable_map then $game_system.quest_map_access = false
  1363.     end
  1364.   end
  1365.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1366.   # * Change Quest Background
  1367.   #    picture : picture to show in the scene's background
  1368.   #    opacity : opacity of the picture shown in the scene's background
  1369.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1370.   def change_quest_background(picture, opacity = $game_system.quest_bg_opacity,
  1371.       blend_type = $game_system.quest_bg_blend_type)
  1372.     $game_system.quest_bg_picture = picture
  1373.     $game_system.quest_bg_opacity = opacity
  1374.     $game_system.quest_bg_blend_type = blend_type
  1375.   end
  1376.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1377.   # * Change Quest Windows
  1378.   #    skin    : windowskin name to use in the scene
  1379.   #    tone    : tone for the windowskin
  1380.   #    opacity : opacity of windows in the scene
  1381.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1382.   def change_quest_windows(skin, tone = $game_system.quest_window_tone,
  1383.       opacity = $game_system.quest_window_opacity)
  1384.     $game_system.quest_windowskin = skin
  1385.     $game_system.quest_window_tone = tone
  1386.     $game_system.quest_window_opacity = opacity
  1387.   end
  1388.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1389.   # * Setup/Delete/Reset Quest
  1390.   #    quest_id : ID of the quest to be setup or deleted or reset
  1391.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1392.   [:setup_quest, :delete_quest, :reset_quest].each { |method|
  1393.     define_method(method) do |quest_id|
  1394.       $game_party.quests.send(method, quest_id)
  1395.     end
  1396.   }
  1397.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1398.   # * Retrieve Quest
  1399.   #    quest_id : ID of the quest to retrieve
  1400.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1401.   def quest(quest_id);         $game_party.quests[quest_id];      end
  1402.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1403.   # * Reveal/Conceal Quest
  1404.   #    quest_id : ID of the quest to be revealed or concealed
  1405.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1406.   def reveal_quest(quest_id);  quest(quest_id).concealed = false; end
  1407.   def conceal_quest(quest_id); quest(quest_id).concealed = true;  end
  1408.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1409.   # * Manually Complete/Fail Quest
  1410.   #    quest_id : ID of the quest to be revealed or concealed
  1411.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1412.   def manually_complete_quest(quest_id)
  1413.     quest(quest_id).prime_objectives.clear
  1414.     quest(quest_id).manual_status = :complete
  1415.   end
  1416.   def manually_fail_quest(quest_id)
  1417.     quest(quest_id).prime_objectives.clear
  1418.     quest(quest_id).manual_status = :failed
  1419.   end
  1420.   def manually_activate_quest(quest_id)
  1421.     quest(quest_id).manual_status = :active
  1422.   end
  1423.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1424.   # * Reveal/Complete/Fail/Conceal/Uncomplete/Unfail Objective
  1425.   #    quest_id : ID of the quest whose objectives will be modified
  1426.   #    *obj     : IDs of objectives to reveal or complete or fail (or opposite)
  1427.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1428.   [:reveal_objective, :complete_objective, :fail_objective, :conceal_objective,
  1429.   :uncomplete_objective, :unfail_objective].each { |method|
  1430.     define_method(method) do |quest_id, *obj|
  1431.       quest(quest_id).send(method, *obj)
  1432.     end
  1433.   }
  1434.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1435.   # * Quest Revealed?
  1436.   #    quest_id : ID of the quest you are checking is revealed
  1437.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1438.   def quest_revealed?(quest_id)
  1439.     $game_party.quests.revealed?(quest_id)
  1440.   end
  1441.   [:complete, :failed, :active].each { |method|
  1442.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1443.     # * Quest Complete/Failed/Active?
  1444.     #    quest_id : ID of the quest whose completion status is being checked
  1445.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1446.     define_method(:"quest_#{method}?") do |quest_id|
  1447.       quest_revealed?(quest_id) && quest(quest_id).status?(method)
  1448.     end
  1449.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1450.     # * Objective Complete/Failed/Active?
  1451.     #    quest_id : ID of the quest whose objectives are being checked
  1452.     #    *obj     : IDs of objectives to check completion status
  1453.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1454.     define_method(:"objective_#{method}?") do |quest_id, *obj|
  1455.       quest_revealed?(quest_id) && quest(quest_id).objective_status?(method, *obj)
  1456.     end
  1457.   }
  1458.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1459.   # * Objective Revealed?
  1460.   #    quest_id : ID of the quest you are checking is revealed
  1461.   #    *obj     : IDs of objectives to check completion status
  1462.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1463.   def objective_revealed?(quest_id, *obj)
  1464.     quest_revealed?(quest_id) && quest(quest_id).objective_status?(:revealed, *obj)
  1465.   end
  1466.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1467.   # * Quest Rewarded?
  1468.   #    quest_id : ID of the quest you are checking is revealed
  1469.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1470.   def quest_rewarded?(quest_id)
  1471.     quest_revealed?(quest_id) && quest(quest_id).status?(:reward)
  1472.   end
  1473.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1474.   # * Change Reward Status
  1475.   #    quest_id : ID of the quest you are checking is revealed
  1476.   #    value    : true or false
  1477.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1478.   def change_reward_status(quest_id, value = true)
  1479.     quest(quest_id).reward_given = value
  1480.   end
  1481.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1482.   # * Distribute Rewards
  1483.   #    quest_id : ID of the quest whose rewards are to be distributed
  1484.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1485.   def distribute_quest_rewards(quest_id)
  1486.     if quest_revealed?(quest_id) && !quest_rewarded?(quest_id)
  1487.       params = @params.dup
  1488.       change_reward_status(quest_id, true)
  1489.       quest(quest_id).rewards.each { |reward| distribute_quest_reward(reward) }
  1490.       @params = params
  1491.       true
  1492.     else
  1493.       false
  1494.     end
  1495.   end
  1496.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1497.   # * Distribute Reward
  1498.   #    reward : an array identifying the reward
  1499.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1500.   def distribute_quest_reward(reward)
  1501.     @params = [reward[1], 0, 0, (reward[2] ? reward[2] : 1)]
  1502.     case reward[0]
  1503.     when :item, 0 then   command_126 # Item
  1504.     when :weapon, 1 then command_127 # Weapon
  1505.     when :armor, 2 then  command_128 # Armor
  1506.     when :gold, 3   # Gold
  1507.       @params = [0, 0, reward[1] ? reward[1] : 0]
  1508.       command_125
  1509.     when :exp, 4    # Exp
  1510.       @params = [0, 0, 0, 0, reward[1] ? reward[1] : 0, true]
  1511.       command_315
  1512.     end
  1513.   end
  1514.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1515.   # * Call Quest Journal
  1516.   #    quest_id : ID of the quest to open the journal to
  1517.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1518.   def call_quest_journal(quest_id = nil)
  1519.     return if $game_party.in_battle
  1520.     $game_system.last_quest_id = quest_id if quest_id
  1521.     SceneManager.call(Scene_Quest)
  1522.     Fiber.yield
  1523.   end
  1524. end
  1525.  
  1526. unless $imported[:"MA_ParagraphFormat_1.0"]
  1527. #==============================================================================
  1528. # ** MA_Window_ParagraphFormat
  1529. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1530. #  This module inserts into Window_Base and provides a method to format the
  1531. # strings so as to go to the next line if it exceeds a set limit. This is
  1532. # designed to work with draw_text_ex, and a string formatted by this method
  1533. # should go through that, not draw_text.
  1534. #==============================================================================
  1535.  
  1536. module MA_Window_ParagraphFormat
  1537.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1538.   # * Calc Line Width
  1539.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1540.   def mapf_calc_line_width(line, tw = 0, contents_dummy = false)
  1541.     return tw if line.nil?
  1542.     line = line.clone
  1543.     unless contents_dummy
  1544.       real_contents = contents # Preserve Real Contents
  1545.       # Create a dummy contents
  1546.       self.contents = Bitmap.new(contents_width, 24)
  1547.       reset_font_settings
  1548.     end
  1549.     pos = {x: 0, y: 0, new_x: 0, height: calc_line_height(line)}
  1550.     while line[/^(.*?)\e(.*)/]
  1551.       tw += text_size($1).width
  1552.       line = $2
  1553.       # Remove all ancillaries to the code, like parameters
  1554.       code = obtain_escape_code(line)
  1555.       # If direct setting of x, reset tw.
  1556.       tw = 0 if ($imported[:ATS_SpecialMessageCodes] && code.upcase == 'X') ||
  1557.         ($imported["YEA-MessageSystem"] && code.upcase == 'PX')
  1558.       #  If I need to do something special on the basis that it is testing,
  1559.       # alias process_escape_character and differentiate using @atsf_testing
  1560.       process_escape_character(code, line, pos)
  1561.     end
  1562.     #  Add width of remaining text, as well as the value of pos[:x] under the
  1563.     # assumption that any additions to it are because the special code is
  1564.     # replaced by something which requires space (like icons)
  1565.     tw += text_size(line).width + pos[:x]
  1566.     unless contents_dummy
  1567.       contents.dispose # Dispose dummy contents
  1568.       self.contents = real_contents # Restore real contents
  1569.     end
  1570.     return tw
  1571.   end
  1572.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1573.   # * Format Paragraph
  1574.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1575.   def mapf_format_paragraph(text, max_width = contents_width)
  1576.     text = text.clone
  1577.     #  Create a Dummy Contents - I wanted to boost compatibility by using the
  1578.     # default process method for escape codes. It may have the opposite effect,
  1579.     # for some :(
  1580.     real_contents = contents # Preserve Real Contents
  1581.     self.contents = Bitmap.new(contents_width, 24)
  1582.     reset_font_settings
  1583.     paragraph = ""
  1584.     while !text.empty?
  1585.       text.lstrip!
  1586.       oline, nline, tw = mapf_format_by_line(text.clone, max_width)
  1587.       # Replace old line with the new one
  1588.       text.sub!(/#{Regexp.escape(oline)}/m, nline)
  1589.       paragraph += text.slice!(/.*?(\n|$)/)
  1590.     end
  1591.     contents.dispose # Dispose dummy contents
  1592.     self.contents = real_contents # Restore real contents
  1593.     return paragraph
  1594.   end
  1595.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1596.   # * Format By Line
  1597.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1598.   def mapf_format_by_line(text, max_width = contents_width)
  1599.     oline, nline, tw = "", "", 0
  1600.     loop do
  1601.       #  Format each word until reach the width limit
  1602.       oline, nline, tw, done = mapf_format_by_word(text, nline, tw, max_width)
  1603.       return oline, nline, tw if done
  1604.     end
  1605.   end
  1606.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1607.   # * Format By Word
  1608.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1609.   def mapf_format_by_word(text, line, tw, max_width)
  1610.     return line, line, tw, true if text.nil? || text.empty?
  1611.     # Extract next word
  1612.     if text.sub!(/([ \t\r\f]*)(\S*)([\n\f]?)/, "") != nil
  1613.       prespace, word, line_end = $1, $2, $3
  1614.       ntw = mapf_calc_line_width(word, tw, true)
  1615.       pw = contents.text_size(prespace).width
  1616.       if (pw + ntw >= max_width)
  1617.         # Insert
  1618.         if line.empty?
  1619.           # If one word takes entire line
  1620.           return prespace + word, word + "\n", ntw, true
  1621.         else
  1622.           return line + prespace + word, line + "\n" + word, tw, true
  1623.         end
  1624.       else
  1625.         line += prespace + word
  1626.         tw = pw + ntw
  1627.         # If the line is force ended, then end
  1628.         return line, line, tw, true if !line_end.empty?
  1629.       end
  1630.     else
  1631.       return line, line, tw, true
  1632.     end
  1633.     return line, line, tw, false
  1634.   end
  1635. end
  1636.  
  1637. class Window_Base
  1638.   include MA_Window_ParagraphFormat
  1639. end
  1640.  
  1641. $imported[:"MA_ParagraphFormat_1.0"] = true
  1642. end
  1643.  
  1644. #==============================================================================
  1645. # *** MAQJ Window_QuestBase
  1646. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1647. #  This module mixes in with all quest windows
  1648. #==============================================================================
  1649.  
  1650. module MAQJ_Window_QuestBase
  1651.   attr_reader :maqj_objective_color
  1652.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1653.   # * Object Initialization
  1654.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1655.   def initialize(*args, &block)
  1656.     super(*args, &block)
  1657.     reset_font_settings
  1658.     set_data_font(:normal)
  1659.     @maqj_default_font = contents.font.dup
  1660.     # Change the windowskin, tone if they are set to be changed
  1661.     self.windowskin = Cache.system($game_system.quest_windowskin) if $game_system.quest_windowskin
  1662.     self.opacity = $game_system.quest_window_opacity if $game_system.quest_window_opacity
  1663.   end
  1664.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1665.   # * Reset Font Settings
  1666.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1667.   def reset_font_settings(*args, &block)
  1668.     super(*args, &block)
  1669.     set_data_font(@maqj_font_data_type) if @maqj_font_data_type
  1670.   end
  1671.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1672.   # * Set Data Font
  1673.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1674.   def set_data_font(data_type)
  1675.     @maqj_default_font = contents.font.dup unless @maqj_default_font
  1676.     contents.font.name = QuestData::FONTNAMES[data_type] ?
  1677.       QuestData::FONTNAMES[data_type] : @maqj_default_font.name
  1678.     contents.font.size = QuestData::FONTSIZES[data_type] ?
  1679.       QuestData::FONTSIZES[data_type] : @maqj_default_font.size
  1680.     contents.font.bold = QuestData::FONTBOLDS.keys.include?(data_type) ?
  1681.       QuestData::FONTBOLDS[data_type] : @maqj_default_font.bold
  1682.     contents.font.italic = QuestData::FONTITALICS.keys.include?(data_type) ?
  1683.       QuestData::FONTITALICS[data_type] : @maqj_default_font.italic
  1684.     case data_type
  1685.     when :objectives then change_color(@maqj_objective_color) if @maqj_objective_color
  1686.     when :name then change_color(quest_name_colour(@quest)) if @quest
  1687.     else
  1688.       change_color(text_color(QuestData::COLOURS[data_type])) if QuestData::COLOURS.keys.include?(data_type)
  1689.     end
  1690.   end
  1691.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1692.   # * Draw Horizontal Line
  1693.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1694.   def draw_horizontal_line(y, h = 2)
  1695.     contents.fill_rect(0, y, contents_width, h, text_color(QuestData::COLOURS[:line]))
  1696.     contents.fill_rect(0, y + h, contents_width, [h / 2, 1].max, text_color(QuestData::COLOURS[:line_shadow]))
  1697.   end
  1698.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1699.   # * MA Text Color
  1700.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1701.   def text_color(param)
  1702.     begin
  1703.       colour = case param
  1704.       when Integer then super(param) rescue normal_color
  1705.       when Symbol then send(param) rescue normal_color
  1706.       when Array then Color.new(*param) rescue normal_color
  1707.       else
  1708.         normal_color
  1709.       end
  1710.     end
  1711.     colour.is_a?(Color) ? colour : normal_color
  1712.   end
  1713.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1714.   # * Quest Name Colour
  1715.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1716.   def quest_name_colour(quest = @quest)
  1717.     return if !quest
  1718.     quest = $game_party.quests[quest] if quest.is_a?(Integer)
  1719.     s = [:failed, :complete, :active].find { |status| quest.status?(status) }
  1720.     text_color(QuestData::COLOURS[s])
  1721.   end
  1722.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1723.   # * Quest Objective Colour
  1724.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1725.   def quest_objective_colour(quest, obj_id)
  1726.     return if !quest
  1727.     quest = $game_party.quests[quest] if quest.is_a?(Integer)
  1728.     s = [:failed, :complete, :active].find { |status| quest.objective_status?(status, obj_id) }
  1729.     text_color(QuestData::COLOURS[s])
  1730.   end
  1731.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1732.   # * Update Tone
  1733.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1734.   def update_tone
  1735.     $game_system.quest_window_tone ?
  1736.       self.tone.set(*$game_system.quest_window_tone) : super
  1737.   end
  1738. end
  1739.  
  1740. unless $imported[:"MA_IconHorzCommand_1.0"]
  1741. #==============================================================================
  1742. # ** Window_MA_IconHorzCommand
  1743. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1744. #  This window is a base window to show a horizontal command window populated
  1745. # with icons.
  1746. #==============================================================================
  1747.  
  1748. class Window_MA_IconHorzCommand < Window_HorzCommand
  1749.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1750.   # * Public Instance Variable
  1751.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1752.   attr_reader   :observing_procs
  1753.   attr_accessor :cursor_hide
  1754.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1755.   # * Object Initialization
  1756.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1757.   def initialize(*args, &block)
  1758.     @observing_procs = {}
  1759.     super(*args, &block)
  1760.   end
  1761.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1762.   # * Column Max
  1763.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1764.   def col_max; [(width - standard_padding) / (24 + spacing), item_max].min; end
  1765.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1766.   # * Item
  1767.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1768.   def item
  1769.     @list[index] ? @list[index][:symbol] : nil
  1770.   end
  1771.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1772.   # * Enabled? / Current Item Enabled?
  1773.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1774.   def enable?(index); self.index == index; end
  1775.   def current_item_enabled?; !current_data.nil?; end
  1776.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1777.   # * Draw Item
  1778.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1779.   def draw_item(index)
  1780.     rect = item_rect(index)
  1781.     contents.clear_rect(rect)
  1782.     draw_icon(@list[index][:ext], rect.x + ((rect.width - 24) / 2), rect.y, enable?(index))
  1783.   end
  1784.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1785.   # * Set Index
  1786.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1787.   def index=(index)
  1788.     old_index = self.index
  1789.     super(index)
  1790.     draw_item(old_index)
  1791.     draw_item(self.index)
  1792.   end
  1793.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1794.   # * Frame Update
  1795.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1796.   def update
  1797.     super
  1798.     @observing_procs.values.each { |block| block.call(item) }
  1799.   end
  1800.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1801.   # * Add/Remove Observing Window
  1802.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1803.   def add_observing_proc(id, &block)
  1804.     @observing_procs[id] = block
  1805.     update
  1806.   end
  1807.   def remove_observing_proc(id)     ; @observing_procs.delete(id) ; end
  1808.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1809.   # * Update Cursor
  1810.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1811.   def update_cursor
  1812.     super
  1813.     cursor_rect.empty if @cursor_hide
  1814.   end
  1815. end
  1816. $imported[:"MA_IconHorzCommand_1.0"] = true
  1817. end
  1818.  
  1819. #==============================================================================
  1820. # ** Window_QuestCategory
  1821. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1822. #  This window allows the player to switch between quest categories.
  1823. #==============================================================================
  1824.  
  1825. class Window_QuestCategory < Window_MA_IconHorzCommand
  1826.   include MAQJ_Window_QuestBase
  1827.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1828.   # * Object Initialization
  1829.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1830.   def initialize(x, y, categories = $game_system.quest_categories)
  1831.     @cursor_hide = QuestData::HIDE_CATEGORY_CURSOR
  1832.     @categories = categories
  1833.     super(x, y)
  1834.   end
  1835.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1836.   # * Window Width
  1837.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1838.   def window_width; QuestData::LIST_WINDOW_WIDTH; end
  1839.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1840.   # * Category=
  1841.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1842.   def category=(category)
  1843.     self.index = @categories.index(category) if @categories.include?(category)
  1844.   end
  1845.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1846.   # * Make Command List
  1847.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1848.   def make_command_list
  1849.     @categories.each { |cat|
  1850.       add_command("", cat, false, QuestData::ICONS[cat]) }
  1851.   end
  1852. end
  1853.  
  1854. #==============================================================================
  1855. # ** Window QuestLabel
  1856. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1857. #  This window simply shows a label for the Quests scene
  1858. #==============================================================================
  1859.  
  1860. class Window_QuestLabel < Window_Base
  1861.   include MAQJ_Window_QuestBase
  1862.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1863.   # * Object Initialization
  1864.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1865.   def initialize(x, y, label = "")
  1866.     super(x, y, window_width, window_height)
  1867.     refresh(label)
  1868.   end
  1869.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1870.   # * Reset Font Settings
  1871.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1872.   def reset_font_settings; set_data_font(:scene_label); end
  1873.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1874.   # * Window Attributes
  1875.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1876.   def window_width
  1877.     w = ($game_system.quest_categories.size > 1 || QuestData::SHOW_CATEGORY_LABEL) ?
  1878.       Graphics.width - QuestData::LIST_WINDOW_WIDTH : QuestData::LIST_WINDOW_WIDTH
  1879.   end
  1880.   def window_height; line_height + (standard_padding*2); end
  1881.   def line_height(*args)
  1882.     line_h = super(*args)
  1883.     QuestData::FONTSIZES[:scene_label] ?
  1884.       [QuestData::FONTSIZES[:scene_label], line_h].max : line_h
  1885.   end
  1886.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1887.   # * Refresh
  1888.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1889.   def refresh(label = @label)
  1890.     @label = label.is_a?(String) ? convert_escape_characters(label) : ""
  1891.     contents.clear
  1892.     reset_font_settings
  1893.     tw = mapf_calc_line_width(@label)
  1894.     draw_text_ex((contents_width - tw) / 2, 0, @label)
  1895.   end
  1896. end
  1897.  
  1898. #==============================================================================
  1899. # ** Window QuestLabel
  1900. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1901. #  This window simply shows a label for category currently selected
  1902. #==============================================================================
  1903.  
  1904. class Window_QuestCategoryLabel < Window_QuestLabel
  1905.   include MAQJ_Window_QuestBase
  1906.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1907.   # * Reset Font Settings
  1908.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1909.   def reset_font_settings; set_data_font(:category_label); end
  1910.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1911.   # * Window Attributes
  1912.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1913.   def window_width; QuestData::LIST_WINDOW_WIDTH; end
  1914.   def line_height(*args)
  1915.     line_h = super(*args)
  1916.     QuestData::FONTSIZES[:category_label] ?
  1917.       [QuestData::FONTSIZES[:category_label], line_h].max : line_h
  1918.   end
  1919.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1920.   # * Set Category
  1921.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1922.   def category=(category)
  1923.     return if @category == category
  1924.     @category = category
  1925.     refresh(QuestData::CATEGORY_VOCAB[category])
  1926.   end
  1927. end
  1928.  
  1929. #==============================================================================
  1930. # ** Window_QuestCategoryDummy
  1931. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1932. #  This window shows up behind the category and category label window
  1933. #==============================================================================
  1934.  
  1935. class Window_QuestCategoryDummy < Window_Base
  1936.   include MAQJ_Window_QuestBase
  1937. end
  1938.  
  1939. #==============================================================================
  1940. # ** Window_QuestList
  1941. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1942. #  This window shows all quests in a selected category.
  1943. #==============================================================================
  1944.  
  1945. class Window_QuestList < Window_Selectable
  1946.   include MAQJ_Window_QuestBase
  1947.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1948.   # * Object Initialization
  1949.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1950.   def initialize(x, y, width, height)
  1951.     super
  1952.     @data = []
  1953.     self.index = 0
  1954.     activate
  1955.   end
  1956.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1957.   # * Set Category
  1958.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1959.   def category=(category)
  1960.     return if @category == category
  1961.     @category = category
  1962.     refresh
  1963.     self.index = 0
  1964.     update_help if @help_window
  1965.   end
  1966.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1967.   # * Get Quest
  1968.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1969.   def item; @data && index >= 0 ? @data[index] : nil; end
  1970.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1971.   # * Column/Item Max
  1972.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1973.   def col_max; 1; end
  1974.   def item_max; @data ? @data.size : 1; end
  1975.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1976.   # * Whether it should be drawn enabled
  1977.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1978.   def enable?(item); true; end
  1979.   def current_item_enabled?
  1980.     (@help_window && @help_window.maqj_visible_height < @help_window.contents_height)
  1981.   end
  1982.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1983.   # * Make Item List
  1984.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1985.   def make_item_list
  1986.     @data = @category ? $game_party.quests.list(@category) : []
  1987.   end
  1988.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1989.   # * Draw Item
  1990.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1991.   def draw_item(index)
  1992.     quest = @data[index]
  1993.     if quest
  1994.       rect = item_rect_for_text(index)
  1995.       if QuestData::SHOW_QUEST_ICONS
  1996.         draw_icon(quest.icon_index, rect.x, rect.y, enable?(quest))
  1997.         rect.x += 24
  1998.         rect.width -= 24
  1999.       end
  2000.       change_color(quest_name_colour(quest), enable?(quest))
  2001.       draw_text(rect, quest.name)
  2002.     end
  2003.   end
  2004.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2005.   # * Refresh
  2006.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2007.   def refresh
  2008.     make_item_list
  2009.     create_contents
  2010.     set_data_font(:list)
  2011.     draw_all_items
  2012.   end
  2013.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2014.   # * Update Help
  2015.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2016.   def update_help
  2017.     @help_window.quest = item
  2018.   end
  2019. end
  2020.  
  2021. #==============================================================================
  2022. # ** Window_QuestData
  2023. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2024. #  This window shows all quest data
  2025. #==============================================================================
  2026.  
  2027. class Window_QuestData < Window_Selectable
  2028.   include MAQJ_Window_QuestBase
  2029.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2030.   # * Object Initialization
  2031.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2032.   def initialize(x, y, w, h, layout = QuestData::DATA_LAYOUT)
  2033.     @dest_scroll_oy = 0
  2034.     super(x, y, w, h)
  2035.     @dest_scroll_oy = self.oy
  2036.     self.layout = layout
  2037.   end
  2038.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2039.   # * Contents Height
  2040.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2041.   alias maqj_visible_height contents_height
  2042.   def contents_height
  2043.     @q_contents_height ? [@q_contents_height, maqj_visible_height].max : maqj_visible_height
  2044.   end
  2045.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2046.   # * Calculate Contents Height
  2047.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2048.   def calc_contents_height
  2049.     @q_contents_height = 0
  2050.     @layout.each { |dt| @q_contents_height += data_height(dt) } if @quest
  2051.   end
  2052.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2053.   # * Draw Data?
  2054.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2055.   def draw_data?(data_type)
  2056.     case data_type
  2057.     when :line then true
  2058.     when :level then @quest.level > 0
  2059.     when :objectives then !@quest.revealed_objectives.empty?
  2060.     when Array then (data_type - [:line]).any? { |dt| draw_data?(dt) }
  2061.     else !@quest.send(data_type).empty? # :description, :name, etc...
  2062.     end
  2063.   end
  2064.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2065.   # * Get Data Height
  2066.   #    This method calculates the height required for a specified element of
  2067.   #   the current quest. This is to calculate the needed space in contents,
  2068.   #   as well as advance the @draw_y variable.
  2069.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2070.   def data_height(data_type)
  2071.     return 0 unless draw_data?(data_type)
  2072.     return line_height if QuestData::BASIC_DATA_TYPES.include?(data_type)
  2073.     @maqj_font_data_type = data_type
  2074.     reset_font_settings
  2075.     return case data_type
  2076.     when :line, :level, :name then line_height
  2077.     when :banner
  2078.       bmp = Cache.picture(@quest.banner)
  2079.       hght = bmp.rect.height
  2080.       bmp.dispose
  2081.       hght
  2082.     when :description
  2083.       buff = description_x*2
  2084.       paragraph = mapf_format_paragraph(@quest.description, contents_width - buff)
  2085.       line_num = paragraph.scan(/\n/).size + 1
  2086.       line_num += (QuestData::DESCRIPTION_IN_BOX ? 2 :
  2087.         !QuestData::VOCAB[:description].empty? ? 1 : 0)
  2088.       line_num*line_height
  2089.     when :objectives
  2090.       objectives = @quest.revealed_objectives.collect { |obj_id|
  2091.         @quest.objectives[obj_id] }
  2092.       line_num = QuestData::VOCAB[:objectives].empty? ? 0 : 1
  2093.       buff = (objective_x*2) + text_size(QuestData::VOCAB[:objective_bullet]).width
  2094.       objectives.each { |obj|
  2095.         paragraph = mapf_format_paragraph(obj, contents_width - buff)
  2096.         line_num += paragraph.scan(/\n/).size + 1 }
  2097.       line_num*line_height
  2098.     when :rewards
  2099.       line_num = QuestData::VOCAB[:rewards].empty? ? 0 : 1
  2100.       (line_num + @quest.rewards.size)*line_height
  2101.     when Array then data_height(data_type.max_by { |dt| data_height(dt) })
  2102.     else 0
  2103.     end
  2104.   end
  2105.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2106.   # * Set Quest
  2107.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2108.   def quest=(value)
  2109.     return if @quest == value
  2110.     @quest = value
  2111.     @layout = (@quest && @quest.layout) ? @quest.layout : @default_layout
  2112.     refresh
  2113.   end
  2114.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2115.   # * Set Layout
  2116.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2117.   def layout=(value)
  2118.     return if @default_layout == value && @layout == value
  2119.     @default_layout = value
  2120.     @layout = value
  2121.     refresh
  2122.   end
  2123.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2124.   # * Refresh
  2125.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2126.   def refresh
  2127.     contents.clear
  2128.     calc_contents_height
  2129.     create_contents
  2130.     return unless @quest && @layout
  2131.     self.oy = 0
  2132.     @dest_scroll_oy = 0
  2133.     #  The basic idea here is that each draw_ method will rely on and advance
  2134.     # the @draw_y variable. Where they are an array, the elements will be
  2135.     # drawn at the same @draw_y.
  2136.     @draw_y = 0
  2137.     @layout.each {|dt|
  2138.       next unless draw_data?(dt)
  2139.       dt.is_a?(Array) ? draw_data_array(dt) : draw_data(dt)
  2140.     }
  2141.   end
  2142.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2143.   # * Draw Data
  2144.   #    data_type : the data block to draw next
  2145.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2146.   def draw_data(data_type)
  2147.     @maqj_font_data_type = data_type
  2148.     reset_font_settings
  2149.     send(:"draw_#{data_type}") if self.class.method_defined?(:"draw_#{data_type}")
  2150.     @draw_y += data_height(data_type)
  2151.   end
  2152.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2153.   # * Draw Data Array
  2154.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2155.   def draw_data_array(layout_array)
  2156.     y, max_y = @draw_y, @draw_y
  2157.     # Draw each data aspect at the same starting @draw_y
  2158.     layout_array.each { |dt|
  2159.       @draw_y = y
  2160.       draw_data(dt)
  2161.       max_y = @draw_y if @draw_y > max_y
  2162.     }
  2163.     @draw_y = max_y
  2164.   end
  2165.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2166.   # * Draw Line
  2167.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2168.   def draw_line; draw_horizontal_line(@draw_y + (line_height / 2) - 1, 2); end
  2169.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2170.   # * Draw Name
  2171.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2172.   def draw_name
  2173.     set_data_font(:name)
  2174.     clear_and_draw_text(0, @draw_y, contents_width, line_height, @quest.name, 1)
  2175.   end
  2176.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2177.   # * Draw Level
  2178.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2179.   def draw_level
  2180.     case QuestData::LEVEL_ICON
  2181.     when Array then QuestData::LEVEL_ICON.empty? ? draw_level_text : draw_level_array
  2182.     when 0 then draw_level_text
  2183.     else
  2184.       draw_level_stacked
  2185.     end
  2186.   end
  2187.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2188.   # * Draw Stacked Level
  2189.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2190.   def draw_level_stacked(icon_index = QuestData::LEVEL_ICON)
  2191.     align = QuestData::HEADING_ALIGN[:level]
  2192.     es = QuestData::LEVEL_ICONS_SPACE*(@quest.level - 1)
  2193.     x = align == 2 ? contents_width - 24 : align == 1 ?
  2194.       (contents_width - 24 - (es)) / 2 : es
  2195.     @quest.level.times do
  2196.       draw_icon(icon_index, x, @draw_y)
  2197.       x -= QuestData::LEVEL_ICONS_SPACE
  2198.     end
  2199.   end
  2200.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2201.   # * Draw Array Level
  2202.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2203.   def draw_level_array(icon_index = QuestData::LEVEL_ICON)
  2204.     return if icon_index.empty?
  2205.     icon_index = icon_index[@quest.level - 1] ? icon_index[@quest.level - 1] : icon_index[-1]
  2206.     align = QuestData::HEADING_ALIGN[:level]
  2207.     x = align == 2 ? contents_width - 24 : align == 1 ? (contents_width-24)/2 : 0
  2208.     draw_icon(icon_index, x, @draw_y)
  2209.   end
  2210.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2211.   # * Draw Text Level
  2212.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2213.   def draw_level_text
  2214.     reset_font_settings
  2215.     level = QuestData::LEVEL_SIGNALS && QuestData::LEVEL_SIGNALS[@quest.level - 1] ?
  2216.       QuestData::LEVEL_SIGNALS[@quest.level - 1] : @quest.level.to_s
  2217.     align = QuestData::HEADING_ALIGN[:level]
  2218.     tw = text_size(QuestData::VOCAB[:level]).width + 4
  2219.     tw2 = text_size(level).width + 2
  2220.     space = contents_width - tw - tw2
  2221.     x = align == 2 ? space : align == 1 ? space / 2 : 0
  2222.     clear_and_draw_text(x, @draw_y, tw, line_height, QuestData::VOCAB[:level])
  2223.     set_data_font(:level_signal)
  2224.     clear_and_draw_text(x + tw, @draw_y, tw2, line_height, level, 2)
  2225.   end
  2226.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2227.   # * Draw Banner
  2228.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2229.   def draw_banner
  2230.     bmp = Cache.picture(@quest.banner) # Get Picture
  2231.     # Shift the hue if requested
  2232.     bmp.hue_change(@quest.banner_hue) unless @quest.banner_hue == 0
  2233.     x = (contents_width - bmp.rect.width) / 2
  2234.     if x < 0 # Stretch horizontally if the banner is too wide
  2235.       dest_rect = bmp.rect.dup
  2236.       dest_rect.width = contents_width
  2237.       contents.stretch_blt(dest_rect, bmp, bmp.rect)
  2238.     else
  2239.       contents.blt(x, @draw_y, bmp, bmp.rect)
  2240.     end
  2241.     bmp.dispose
  2242.   end
  2243.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2244.   # * Draw Description
  2245.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2246.   def draw_description
  2247.     buff = description_x*2
  2248.     paragraph = mapf_format_paragraph(@quest.description, contents_width - buff)
  2249.     y = @draw_y
  2250.     # Draw Rect
  2251.     draw_box(paragraph.scan(/\n/).size + 1) if QuestData::DESCRIPTION_IN_BOX
  2252.     # Draw Description Label
  2253.     draw_heading(:description, y) unless QuestData::VOCAB[:description].empty?
  2254.     # Draw Description
  2255.     y += line_height if !QuestData::VOCAB[:description].empty? || QuestData::DESCRIPTION_IN_BOX
  2256.     draw_text_ex(description_x, y, paragraph)
  2257.   end
  2258.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2259.   # * Draw Objectives
  2260.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2261.   def draw_objectives
  2262.     y = @draw_y
  2263.     unless QuestData::VOCAB[:objectives].empty?
  2264.       draw_heading(:objectives, y)
  2265.       y += line_height
  2266.     end
  2267.     @quest.revealed_objectives.each { |obj_id| y = draw_objective(obj_id, y) }
  2268.   end
  2269.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2270.   # * Draw Objective
  2271.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2272.   def draw_objective(obj_id, y)
  2273.     bullet = QuestData::VOCAB[:objective_bullet]
  2274.     bullet_tw = text_size(bullet).width + 2
  2275.     buff = (objective_x*2) + bullet_tw
  2276.     paragraph = mapf_format_paragraph(@quest.objectives[obj_id], contents_width - buff)
  2277.     line_num = 1 + paragraph.scan(/\n/).size
  2278.     # Since draw_text_ex resets the font, set colour here
  2279.     @maqj_objective_color = quest_objective_colour(@quest, obj_id)
  2280.     change_color(text_color(QuestData::COLOURS[:objective_bullet]))
  2281.     draw_text(objective_x, y, bullet_tw, line_height, sprintf(bullet, obj_id + 1))
  2282.     draw_text_ex(objective_x + bullet_tw, y, paragraph)
  2283.     @maqj_objective_color = false
  2284.     y += (line_num*line_height)
  2285.   end
  2286.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2287.   # * Draw Rewards
  2288.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2289.   def draw_rewards
  2290.     y = @draw_y
  2291.     unless QuestData::VOCAB[:rewards].empty?
  2292.       draw_heading(:rewards, y)
  2293.       y += line_height
  2294.     end
  2295.     for i in 0...@quest.rewards.size do draw_reward(i, y + i*line_height) end
  2296.   end
  2297.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2298.   # * Draw Reward
  2299.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2300.   def draw_reward(r_id, y)
  2301.     reward = @quest.rewards[r_id]
  2302.     case reward[0]
  2303.     when :item, 0   # Item
  2304.       draw_item_reward(y, $data_items[reward[1]], reward[2] ? reward[2] : 1)
  2305.     when :weapon, 1 # Weapon
  2306.       draw_item_reward(y, $data_weapons[reward[1]], reward[2] ? reward[2] : 1)
  2307.     when :armor, 2  # Armor
  2308.       draw_item_reward(y, $data_armors[reward[1]], reward[2] ? reward[2] : 1)
  2309.     when :gold, 3   # Gold
  2310.       draw_basic_data(y, QuestData::ICONS[:reward_gold],
  2311.         QuestData::VOCAB[:reward_gold], (reward[1] ? reward[1] : 0).to_s)
  2312.     when :exp, 4    # Exp
  2313.       draw_basic_data(y, QuestData::ICONS[:reward_exp],
  2314.         QuestData::VOCAB[:reward_exp], (reward[1] ? reward[1] : 0).to_s)
  2315.     when :string, 5 # String
  2316.       draw_basic_data(y, reward[1] ? reward[1] : 0, reward[3] ? reward[3].to_s : "",
  2317.         reward[2] ? reward[2].to_s : "")
  2318.     end
  2319.   end
  2320.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2321.   # * Draw Item Reward
  2322.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2323.   def draw_item_reward(y, item, amount = 1)
  2324.     w = contents_width
  2325.     w = QuestData::BASIC_DATA_WIDTH if QuestData::BASIC_DATA_WIDTH.between?(1, w)
  2326.     x = (contents_width - w) / 2
  2327.     draw_item_name(item, x, y, true, w - 40)
  2328.     if amount > 1
  2329.       change_color(text_color(QuestData::COLOURS[:reward_amount]))
  2330.       draw_text(x + w - 40, y, 40, line_height, sprintf(QuestData::VOCAB[:reward_amount], amount), 2)
  2331.     end
  2332.   end
  2333.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2334.   # * Draw Basic Data Methods
  2335.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2336.   QuestData::BASIC_DATA_TYPES.each { |data_type|
  2337.     define_method(:"draw_#{data_type}") {
  2338.       draw_basic_data(@draw_y, QuestData::ICONS[data_type],
  2339.         QuestData::VOCAB[data_type], @quest.send(data_type))
  2340.     }
  2341.   }
  2342.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2343.   # * Draw Basic Data
  2344.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2345.   def draw_basic_data(y, icon_index, vocab, value)
  2346.     w = contents_width
  2347.     w = QuestData::BASIC_DATA_WIDTH if QuestData::BASIC_DATA_WIDTH.between?(1, w)
  2348.     x = (contents_width - w) / 2
  2349.     unless icon_index == 0
  2350.       draw_icon(icon_index, x, y)
  2351.       x += 24
  2352.       w -= 24
  2353.     end
  2354.     tw = text_size(vocab).width
  2355.     change_color(text_color(QuestData::COLOURS[:basic_label]))
  2356.     draw_text(x, y, tw, line_height, vocab)
  2357.     change_color(text_color(QuestData::COLOURS[:basic_value]))
  2358.     draw_text(x + tw, y, w - tw, line_height, value, 2)
  2359.   end
  2360.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2361.   # * Draw Heading
  2362.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2363.   def draw_heading(data_type, y)
  2364.     set_data_font(:heading)
  2365.     clear_and_draw_text(40, y, contents_width - 80, line_height,
  2366.       QuestData::VOCAB[data_type], QuestData::HEADING_ALIGN[data_type])
  2367.     reset_font_settings
  2368.   end
  2369.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2370.   # * Clear and Draw Text
  2371.   #    Clear the field before drawing the text
  2372.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2373.   def clear_and_draw_text(*args)
  2374.     rect = []
  2375.     while !args[0].is_a?(String) do rect.push(args.shift) end
  2376.     rect[0].is_a?(Rect) ? rect = rect[0] : rect = Rect.new(*rect)
  2377.     align = args[1] ? args[1] : 0
  2378.     ts = text_size(args[0])
  2379.     ts.width = [ts.width + 4, rect.width].min
  2380.     align == 1 ? ts.x = rect.x + ((rect.width - ts.width) / 2) :
  2381.       align == 2 ? ts.x = rect.x + rect.width - ts.width : ts.x = rect.x
  2382.     ts.y = rect.y
  2383.     contents.clear_rect(ts)
  2384.     ts.x += 2
  2385.     draw_text(ts, args[0], align)
  2386.   end
  2387.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2388.   # * Draw Description Box
  2389.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2390.   def draw_box(line_num)
  2391.     return if line_num < 1
  2392.     x = (line_height / 2) - 1
  2393.     y = @draw_y + (line_height / 2) - 1
  2394.     w = contents_width - 2*x
  2395.     h = (1 + line_num)*line_height
  2396.     draw_rect_outline_with_shadow(x, y, w, h)
  2397.   end
  2398.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2399.   # * Draw Rect Outline
  2400.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2401.   def draw_rect_outline(x, y, w, h, colour)
  2402.     # Horizontal Lines
  2403.     contents.fill_rect(x, y, w, 2, colour)
  2404.     contents.fill_rect(x, y + h - 2, w, 2, colour)
  2405.     # Vertical Lines
  2406.     contents.fill_rect(x, y, 2, h, colour)
  2407.     contents.fill_rect(x + w - 2, y, 2, h, colour)
  2408.   end
  2409.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2410.   # * Draw Rect Outline with Shadow
  2411.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2412.   def draw_rect_outline_with_shadow(x, y, w, h)
  2413.     draw_rect_outline(x + 1, y + 1, w, h, text_color(QuestData::COLOURS[:line_shadow]))
  2414.     draw_rect_outline(x, y, w, h, text_color(QuestData::COLOURS[:line]))
  2415.   end
  2416.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2417.   # * Objective/Description X
  2418.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2419.   def objective_x; line_height / 2; end
  2420.   def description_x; QuestData::DESCRIPTION_IN_BOX ? line_height : (line_height/2); end
  2421.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2422.   # * Update
  2423.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2424.   def update(*args, &block)
  2425.     super(*args, &block)
  2426.     if open? && active && @dest_scroll_oy == self.oy
  2427.       scroll_down if Input.press?(:DOWN)
  2428.       scroll_up if Input.press?(:UP)
  2429.     end
  2430.     if self.oy != @dest_scroll_oy
  2431.       mod = (@dest_scroll_oy <=> self.oy)
  2432.       self.oy += 3*mod
  2433.       self.oy = @dest_scroll_oy if (@dest_scroll_oy <=> self.oy) != mod
  2434.     end
  2435.   end
  2436.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2437.   # * Scroll Down
  2438.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2439.   def scroll_down(*args, &block)
  2440.     max_oy = contents_height - maqj_visible_height
  2441.     dest = ((@dest_scroll_oy / line_height) + 1)*line_height
  2442.     @dest_scroll_oy = [dest, max_oy].min
  2443.   end
  2444.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2445.   # * Scroll Up
  2446.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2447.   def scroll_up(*args, &block)
  2448.     dest = ((@dest_scroll_oy / line_height) - 1)*line_height
  2449.     @dest_scroll_oy = [dest, 0].max
  2450.   end
  2451. end
  2452.  
  2453. #==============================================================================
  2454. # ** Scene_Quest
  2455. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2456. #  This class handles processing for the Quest scene
  2457. #==============================================================================
  2458.  
  2459. class Scene_Quest < Scene_MenuBase
  2460.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2461.   # * Start Scene Processing
  2462.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2463.   def start
  2464.     super
  2465.     @init_category, @init_quest_index = $game_party.quests.find_location($game_system.last_quest_id, $game_system.last_quest_cat)
  2466.     create_maqj_picture unless $game_system.quest_bg_picture.empty?
  2467.     create_all_windows
  2468.     adjust_window_positions
  2469.   end
  2470.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2471.   # * Terminate Scene
  2472.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2473.   def terminate
  2474.     $game_system.quest_categories = QuestData::CATEGORIES
  2475.     $game_system.quest_scene_label = QuestData::VOCAB[:scene_label]
  2476.     $game_system.last_quest_id = @quest_list_window.item ? @quest_list_window.item.id : 0
  2477.     $game_system.last_quest_cat = @quest_category_window ?
  2478.       @quest_category_window.item : $game_system.quest_categories[0]
  2479.     super
  2480.     dispose_maqj_picture
  2481.   end
  2482.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2483.   # * Create Background Picture
  2484.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2485.   def create_maqj_picture
  2486.     @maqj_picture_sprite = Sprite.new
  2487.     @maqj_picture_sprite.bitmap = Cache.picture($game_system.quest_bg_picture)
  2488.     @maqj_picture_sprite.opacity = $game_system.quest_bg_opacity
  2489.     @maqj_picture_sprite.blend_type = $game_system.quest_bg_blend_type
  2490.     @maqj_picture_sprite.z = @background_sprite.z + 1 if @background_sprite
  2491.   end
  2492.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2493.   # * Create All Windows
  2494.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2495.   def create_all_windows
  2496.     create_quest_label_window unless $game_system.quest_scene_label.empty?
  2497.     create_quest_category_window if $game_system.quest_categories.size > 1
  2498.     create_quest_category_label_window if QuestData::SHOW_CATEGORY_LABEL
  2499.     create_dummy_category_window if QuestData::CATEGORY_LABEL_IN_SAME_WINDOW &&
  2500.       @quest_category_window && @quest_category_label_window
  2501.     create_quest_list_window
  2502.     create_quest_data_window
  2503.   end
  2504.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2505.   # * Create QuestLabel Window
  2506.   #    This window shows the name of the scene
  2507.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2508.   def create_quest_label_window
  2509.     @quest_label_window = Window_QuestLabel.new(0, 0, $game_system.quest_scene_label)
  2510.   end
  2511.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2512.   # * Create QuestCategory Window
  2513.   #    This window allows the player to switch categories.
  2514.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2515.   def create_quest_category_window
  2516.     @quest_category_window = Window_QuestCategory.new(0, 0, $game_system.quest_categories)
  2517.     @quest_category_window.category = @init_category if @init_category
  2518.     @quest_category_window.set_handler(:cancel, method(:on_category_cancel))
  2519.     @quest_category_window.set_handler(:ok, method(:on_category_ok))
  2520.   end
  2521.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2522.   # * Create QuestCategoryLabel Window
  2523.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2524.   def create_quest_category_label_window
  2525.     if @quest_category_window
  2526.       @quest_category_label_window = Window_QuestCategoryLabel.new(0, @quest_category_window.height)
  2527.       @quest_category_window.add_observing_proc(:label) { |category|
  2528.         @quest_category_label_window.category = category }
  2529.     else
  2530.       @quest_category_label_window = Window_QuestCategoryLabel.new(0, 0)
  2531.       @quest_category_label_window.category = $game_system.quest_categories ? $game_system.quest_categories[0] : :all
  2532.     end
  2533.   end
  2534.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2535.   # * Create Dummy Category Label Window
  2536.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2537.   def create_dummy_category_window
  2538.     @quest_category_label_window.y -= 12
  2539.     @quest_category_label_window.opacity = 0
  2540.     @quest_category_window.opacity = 0
  2541.     w = [@quest_category_window.width, @quest_category_label_window.width].max
  2542.     h = @quest_category_window.height + @quest_category_label_window.height - 12
  2543.     @category_dummy_window = Window_QuestCategoryDummy.new(0, 0, w, h)
  2544.     @category_dummy_window.z = [@quest_category_window.z, @quest_category_label_window.z].min - 1
  2545.     # Draw Horz Line
  2546.     @category_dummy_window.draw_horizontal_line(@quest_category_window.height - @quest_category_window.padding - 7, 2)
  2547.   end
  2548.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2549.   # * Create QuestList Window
  2550.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2551.   def create_quest_list_window
  2552.     if @category_dummy_window
  2553.       y = @category_dummy_window.height
  2554.     else
  2555.       y = @quest_category_window ? @quest_category_window.height : 0
  2556.       y += @quest_category_label_window ? @quest_category_label_window.height : 0
  2557.       y = @quest_label_window.height if y == 0
  2558.     end
  2559.     @quest_list_window = Window_QuestList.new(0, y, QuestData::LIST_WINDOW_WIDTH,
  2560.       Graphics.height - y)
  2561.     @quest_list_window.set_handler(:ok, method(:on_list_ok))
  2562.     @quest_list_window.deactivate if !QuestData::CONCURRENT_ACTIVITY
  2563.     if !QuestData::CONCURRENT_ACTIVITY || !@quest_category_window
  2564.       @quest_list_window.set_handler(:cancel, method(:on_list_cancel))
  2565.     end
  2566.     if @quest_category_window
  2567.       @quest_category_window.add_observing_proc(:list) { |category|
  2568.         @quest_list_window.category = category }
  2569.     else
  2570.       @quest_list_window.category = $game_system.quest_categories[0]
  2571.     end
  2572.     @quest_list_window.index = @init_quest_index if @init_quest_index
  2573.   end
  2574.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2575.   # * Create QuestData Window
  2576.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2577.   def create_quest_data_window
  2578.     x = @quest_list_window.width
  2579.     y = (@quest_label_window && (@quest_category_window ||
  2580.       @quest_category_label_window)) ? @quest_label_window.height : 0
  2581.     @quest_data_window = Window_QuestData.new(x, y, Graphics.width - x,
  2582.       Graphics.height - y)
  2583.     @quest_list_window.help_window = @quest_data_window
  2584.     @quest_data_window.quest = @quest_list_window.item
  2585.     @quest_data_window.set_handler(:ok, method(:on_data_ok))
  2586.     @quest_data_window.set_handler(:cancel, method(:on_data_cancel))
  2587.   end
  2588.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2589.   # * Dispose Background Picture
  2590.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2591.   def dispose_maqj_picture
  2592.     @maqj_picture_sprite.dispose if @maqj_picture_sprite
  2593.   end
  2594.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2595.   # * Adjust Window Positions
  2596.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2597.   def adjust_window_positions
  2598.     if @quest_label_window && (@quest_category_window || @quest_category_label_window)
  2599.       @quest_label_window.x = QuestData::LIST_WINDOW_WIDTH
  2600.     end
  2601.   end
  2602.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2603.   # * Category OK
  2604.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2605.   def on_category_ok; @quest_list_window.activate; end
  2606.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2607.   # * Category Cancel
  2608.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2609.   def on_category_cancel; return_scene; end
  2610.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2611.   # * List OK
  2612.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2613.   def on_list_ok
  2614.     @quest_category_window.deactivate if @quest_category_window
  2615.     @quest_data_window.activate
  2616.   end
  2617.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2618.   # * List Cancel
  2619.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2620.   def on_list_cancel
  2621.     @quest_category_window ? @quest_category_window.activate : return_scene
  2622.   end
  2623.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2624.   # * Data OK
  2625.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2626.   def on_data_ok; on_data_cancel; end
  2627.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2628.   # * Data Cancel
  2629.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2630.   def on_data_cancel
  2631.     @quest_list_window.activate
  2632.     @quest_category_window.activate if @quest_category_window && QuestData::CONCURRENT_ACTIVITY
  2633.   end
  2634.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2635.   # * Update All Windows
  2636.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2637.   def update_all_windows(*args, &block)
  2638.     # To accomodate for concurrent activity, must deactivate category
  2639.     @quest_category_window.deactivate if @quest_category_window &&
  2640.       QuestData::CONCURRENT_ACTIVITY && @quest_list_window.active &&
  2641.       Input.trigger?(:C)
  2642.     super(*args, &block)
  2643.     @quest_category_window.activate if @quest_category_window &&
  2644.       QuestData::CONCURRENT_ACTIVITY && @quest_list_window.active
  2645.   end
  2646. end
  2647.  
  2648. #==============================================================================
  2649. # ** Scene_Map
  2650. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2651. #  Summary of Changes:
  2652. #    aliased method - update_scene
  2653. #    new methods - update_call_quest_journal; call_quest_journal
  2654. #==============================================================================
  2655.  
  2656. class Scene_Map
  2657.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2658.   # * Update Scene
  2659.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2660.   alias maqj_updascne_9kh4 update_scene
  2661.   def update_scene(*args, &block)
  2662.     maqj_updascne_9kh4(*args, &block)
  2663.     update_call_quest_journal if $game_system.quest_map_access && !scene_changing?
  2664.   end
  2665.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2666.   # * Update Call Quest Journal
  2667.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2668.   def update_call_quest_journal
  2669.     if $game_map.interpreter.running?
  2670.       @quest_journal_calling = false
  2671.     else
  2672.       if Input.trigger?(QuestData::MAP_BUTTON)
  2673.         $game_system.quest_access_disabled || $game_party.quests.list.empty? ?
  2674.           Sound.play_buzzer : @quest_journal_calling = true
  2675.       end
  2676.       call_quest_journal if @quest_journal_calling && !$game_player.moving?
  2677.     end
  2678.   end
  2679.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2680.   # * Call Quest Journal
  2681.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2682.   def call_quest_journal
  2683.     @quest_journal_calling = false
  2684.     Sound.play_ok
  2685.     SceneManager.call(Scene_Quest)
  2686.   end
  2687. end
  2688.  
  2689. # Menu Access
  2690. if !$imported[:MA_InsertCommand]
  2691. # Initialize the Insertion Hash
  2692. MA_COMMAND_INSERTS = {}
  2693. MA_InsertableMenuCommand = Struct.new(:name, :index, :enable, :scene, :other)
  2694.  
  2695. #==============================================================================
  2696. # ** Game_System
  2697. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2698. #  Summary of Changes:
  2699. #    new public instance variable - maic_menu_commands
  2700. #    aliased method - initialize
  2701. #==============================================================================
  2702.  
  2703. class Game_System
  2704.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2705.   # * Inserted Menu Commands
  2706.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2707.   def maic_inserted_menu_commands
  2708.     # Lazy Instantiation so that old save files are not corrupted
  2709.     if !@maic_inserted_menu_commands
  2710.       @maic_inserted_menu_commands = MA_COMMAND_INSERTS.keys
  2711.       # Sort by index
  2712.       @maic_inserted_menu_commands.sort! { |a, b| MA_COMMAND_INSERTS[a].index <=> MA_COMMAND_INSERTS[b].index }
  2713.     end
  2714.     @maic_inserted_menu_commands
  2715.   end
  2716. end
  2717.  
  2718. #==============================================================================
  2719. # ** Window_MenuCommand
  2720. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2721. #  Summary of Changes:
  2722. #    aliased method - make_command_list; maic_insert_command
  2723. #==============================================================================
  2724.  
  2725. class Window_MenuCommand
  2726.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2727.   # * Make Command List
  2728.   #``````````````````````````````````````````````````````````````````````````
  2729.   #  I alias this method instead of add_original_commands because I need to
  2730.   # have all commands created before I can insert at the correct index
  2731.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2732.   alias maic_mkcmmndl_6yd2 make_command_list
  2733.   def make_command_list(*args, &block)
  2734.     maic_mkcmmndl_6yd2(*args, &block) # Run Original Method
  2735.     # Insert new commands
  2736.     $game_system.maic_inserted_menu_commands.each { |sym| maic_insert_command(sym) }
  2737.   end
  2738.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2739.   # * Insert Command
  2740.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2741.   def maic_insert_command(symbol)
  2742.     command = MA_COMMAND_INSERTS[symbol]
  2743.     # Get the command name
  2744.     name = command.name.is_a?(Symbol) ? eval(command.name.to_s) : command.name
  2745.     # Check whether enabled
  2746.     enabled = case command.enable
  2747.     when Integer then command.enable == 0 ? true : $game_switches[command.enable]
  2748.     when String then eval(command.enable)
  2749.     when Symbol then self.send(command.enable)
  2750.     else
  2751.       enabled = true
  2752.     end
  2753.     # Add the command to the list
  2754.     add_command(name, symbol, enabled)
  2755.     added = @list.pop
  2756.     @list.insert([command.index, @list.size].min, added) # Insert at specific index
  2757.   end
  2758. end
  2759.  
  2760. #==============================================================================
  2761. # ** Scene_Menu
  2762. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2763. #  Summary of Changes:
  2764. #    aliased method - create_command_window; on_personal_ok
  2765. #    new methods - maic_set_insert_handler; maic_command_insert
  2766. #==============================================================================
  2767.  
  2768. class Scene_Menu
  2769.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2770.   # * Create Command Window
  2771.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2772.   alias maic_createcndwin_3ey7 create_command_window
  2773.   def create_command_window(*args, &block)
  2774.     maic_createcndwin_3ey7(*args, &block) # Run Original Method
  2775.     # Add handlers for all custom commands
  2776.     $game_system.maic_inserted_menu_commands.each { |symbol| maic_set_insert_handler(symbol) }
  2777.   end
  2778.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2779.   # * Set Inserted Handler
  2780.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2781.   def maic_set_insert_handler(symbol)
  2782.     other = MA_COMMAND_INSERTS[symbol].other
  2783.     handler = case other
  2784.     when Symbol then method(other)
  2785.     when String then lambda { eval(other) }
  2786.     when TrueClass then method(:command_personal)
  2787.     else
  2788.       handler = method(:maic_command_insert)
  2789.     end
  2790.     @command_window.set_handler(symbol, handler)
  2791.   end
  2792.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2793.   # * Custom Command
  2794.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2795.   def maic_command_insert
  2796.     SceneManager.call(Kernel.const_get(MA_COMMAND_INSERTS[@command_window.current_symbol].scene))
  2797.   end
  2798.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2799.   # * Personal OK
  2800.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2801.   alias maic_onpok_3ek9 on_personal_ok
  2802.   def on_personal_ok(*args, &block)
  2803.     if $game_system.maic_inserted_menu_commands.include?(@command_window.current_symbol)
  2804.       maic_command_insert
  2805.     else
  2806.       maic_onpok_3ek9(*args, &block) # Run Original Method
  2807.     end
  2808.   end
  2809. end
  2810.  
  2811. $imported[:MA_InsertCommand] = true
  2812. end
  2813.  
  2814. MA_COMMAND_INSERTS[:quest_journal] =
  2815.   MA_InsertableMenuCommand.new(QuestData::VOCAB[:menu_label], QuestData::MENU_INDEX,
  2816.   "!$game_system.quest_access_disabled && !$game_party.quests.list.empty?",
  2817.   :Scene_Quest, false)
Add Comment
Please, Sign In to add comment