设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 6139|回复: 6
打印 上一主题 下一主题

[已经解决] 【求脚本】VA任务系统改进

[复制链接]

Lv4.逐梦者 (管理员)

砂上描绘的愿想

梦石
15
星屑
4030
在线时间
5071 小时
注册时间
2012-1-15
帖子
4618

开拓者贵宾短篇七成年组亚军剧作品鉴家

跳转到指定楼层
1
发表于 2012-3-8 19:02:23 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
5星屑
本帖最后由 迷糊的安安 于 2012-3-27 10:46 编辑

之前拜读过韩云溪先生和工藤由纪先生的帖子
http://rpg.blue/thread-216707-2-4.html
http://rpg.blue/thread-221055-1-3.html
感觉此任务系统依然不是很适合我的需要
于是我自己画了一个界面……希望有人能做出我理想的任务系统




任务系统区分章节显示
分主线任务和直线任务
未完成主线、已完成主线、未完成支线、已完成支线、已失败或过期支线,分别用不同图标提示
进入任务界面时,界面自动停在当前章节未完成主线上
另外需要一个【删除特定任务】的功能。用在例如主角到了回忆世界或者梦境的场合,醒来以后梦中的任务及相关资料删除,不再显示在列表中。




--------------------------------------------------------------------------------------------------------------------
3.27 任务系统问题已经解决了 虽然不是在这帖解决的 依然还是很感谢两位的热心帮忙。谢谢。

最佳答案

查看完整内容

这个外站的脚本如何? 代码太长,直接上范例吧:http://115.com/file/anjixvgo 使用说明未汉化,不过都是些简单的英语想必没什么问题的
若后退就皆成谎言。

Lv1.梦旅人

梦石
0
星屑
154
在线时间
664 小时
注册时间
2011-9-25
帖子
241
2
发表于 2012-3-8 19:02:24 | 只看该作者
本帖最后由 xuzhengchi 于 2012-3-9 08:25 编辑

这个外站的脚本如何?

代码太长,直接上范例吧:http://115.com/file/anjixvgo
使用说明未汉化,不过都是些简单的英语想必没什么问题的

评分

参与人数 2星屑 +134 收起 理由
杂兵天下 + 14 TEST
迷糊的安安 + 120 另外能不能修改下代码格式 = = 用PHP格式会.

查看全部评分

回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
66
在线时间
140 小时
注册时间
2012-2-6
帖子
384
3
发表于 2012-3-8 19:42:29 | 只看该作者
一个简单思路:
  1. def unfinished_tasks
  2.     n = []
  3.     for i in @tasks.values
  4.       next if i.finished
  5.       n.push(i)
  6.     end
  7.     return n
  8.   end
  9.   def finished_tasks
  10.     n = []
  11.     for i in @tasks.values
  12.       next unless i.finished
  13.       n.push(i)
  14.     end
  15.     return n
  16.   end
复制代码
注意筛选器,可以把它们做成筛选第一章、第二章、第三章的。

  1.   def make_command_list
  2.     add_command("未完成任务",  :unfinished_task)
  3.     add_command("已完成任务", :finished_task)
  4.     add_command("取消", :cancel)
  5.   end
  6. end
复制代码
然后这里把章节罗列出来
  1. def create_task_type_window
  2.     @task_type_window = Window_Task_Type.new
  3.     @task_type_window.set_handler(:unfinished_task,method(:view_unfinished_task))
  4.     @task_type_window.set_handler(:finished_task,method(:view_finished_task))
  5.     @task_type_window.set_handler(:cancel,method(:return_scene))
  6.   end
  7.   def create_left_window
  8.     @left_window = Window_TaskLeft.new
  9.     @left_window.set_finish(false)
  10.     @left_window.refresh
  11.   end
  12.   def create_right_window
  13.     @right_window = Window_TaskRight.new
  14.     @right_window.refresh
  15.   end
  16.   def view_unfinished_task
  17.     @left_window.set_finish(false)
  18.     @left_window.refresh
  19.     @left_window.activate
  20.     @task_type_window.deactivate
  21.     @right_window.set_finish(false)
  22.     @right_window.set_index(@left_window.index)
  23.   end
  24.   def view_finished_task
  25.     @left_window.set_finish(true)
  26.     @left_window.refresh
  27.     @left_window.activate
  28.     @task_type_window.deactivate
  29.     @right_window.set_finish(true)
  30.     @right_window.set_index(@left_window.index)
  31.   end
复制代码
这里也照葫芦画瓢的改
似乎就可以了?
不过需要大量精力且不能在游戏中改动,有极大改进余地。
签名是什么?可以吃么?
回复

使用道具 举报

Lv4.逐梦者 (管理员)

砂上描绘的愿想

梦石
15
星屑
4030
在线时间
5071 小时
注册时间
2012-1-15
帖子
4618

开拓者贵宾短篇七成年组亚军剧作品鉴家

4
 楼主| 发表于 2012-3-10 22:17:46 | 只看该作者
还是想继续求我要的脚本……
若后退就皆成谎言。
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
66
在线时间
140 小时
注册时间
2012-2-6
帖子
384
5
发表于 2012-3-11 10:52:05 | 只看该作者
xuzhengchi 发表于 2012-3-9 00:49
这个外站的脚本如何?

代码太长,直接上范例吧:http://115.com/file/anjixvgo

此脚本的汉化版:
  1. #==============================================================================
  2. #    Quest Journal [VXA]
  3. #    Version: 1.0d
  4. #    Author: modern algebra (rmrk.net)
  5. #    Date: February 27, 2012
  6. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  7. #  Description:
  8. #
  9. #    This script provides a graphical interface for showing quest progress. It
  10. #   is objective-based, meaning that you choose when to reveal objectives and
  11. #   you can set it so that they show up as complete or failed. That said, this
  12. #   script does not build quests for you; it is only a supplementary scene for
  13. #   showing them. As such, you need to event all of the quests yourself and
  14. #   update quest progress via script call. Therefore, pay close attention to
  15. #   the instructions here and in the Editable Regions at lines 232 and 612.
  16. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  17. #  Instructions:
  18. #
  19. #    Paste this script into its own slot or slots, above Main and below
  20. #   Materials. If you are using the menu access feature, you should put any
  21. #   other menu scripts above this one.
  22. #
  23. #    All of the configuration is done in the QuestData module. While it is not
  24. #   necessary, it is recommended that you separate the configuration module
  25. #   from the rest of the script by cutting and pasting it into its own slot in
  26. #   the Script Editor (as you will see if you have the demo). The reason for
  27. #   this is that, if and when this script gets updated, you can preserve the
  28. #   configuration section and only replace the other parts of the script. If
  29. #   you wish to do that, you must cut everything from the first line down to
  30. #   the final end of the module. The first lines of the body script should be
  31. #   the equals bar right above # ** Game_Quest. Again, it's up to you whether
  32. #   you do it.
  33. #
  34. #    You can go to EDITABLE REGION A at line 232 to configure the default
  35. #   settings for the script. All of these will work fine without modification,
  36. #   of course, but even if do not want to configure now, you should familiarize
  37. #   yourself with all the settings so that you can make the best use of your
  38. #   script. I have included tons of settings so that you can make the Quest
  39. #   Journal unique for your game, even down to the order in which each section
  40. #   of the info window is drawn. A brief description of each setting is
  41. #   included either to the right or directly above each constant.
  42. #
  43. #    EDITABLE REGION B is the real heart of the script however - this is where
  44. #   you fill in all of the details for the quests. Read the instructions at
  45. #   line 612 very carefully!
  46. #
  47. #    You can activate and access a quest with this code in the Script event
  48. #   command:
  49. #
  50. #        quest(quest_id)
  51. #          quest_id : the integer ID of the quest you want to access
  52. #
  53. #   From that, you can access or alter any relevant data stored in the quest,
  54. #   like name, description, objectives, etc... Example:
  55. #         quest(1).name = "Rest in Pieces"
  56. #
  57. #    More relevantly, when it comes to controlling the progress of quests the
  58. #   following codes can be used in a Script event command. The arguments are
  59. #   the same for each command so I only explain them once. All of them are
  60. #   pretty self-explanatory and using any of them will activate the quest
  61. #   (unless you are using the MANUAL REVEAL setting at line 267).
  62. #   
  63. #        reveal_objective(quest_id, objective_id_1, ..., objective_id_n)
  64. #            quest_id : the integer ID of the quest you want to access.
  65. #            objective_id_1, ..., objective_id_n : a list of the IDs of the
  66. #              objectives you want to operate on. It can be as few as one or as
  67. #              many as all of them.
  68. #          Will show the listed objectives in the Quest's information
  69. #
  70. #        conceal_objective(quest_id, objective_id_1, ..., objective_id_n)
  71. #          Will hide the listed objectives in the Quest's information
  72. #
  73. #        complete_objective(quest_id, objective_id_1, ..., objective_id_n)
  74. #          Changes the colour of the listed objectives to the completed colour.
  75. #          The quest is completed once all prime objectives are.
  76. #
  77. #        uncomplete_objective (quest_id, objective_id_1, ..., objective_id_n)
  78. #          Changes the status of the listed complete objectives back to active
  79. #
  80. #        fail_objective(quest_id, objective_id_1, ..., objective_id_n)
  81. #          Changes the colour of the listed objectives to the failed colour.
  82. #          The quest is failed once one prime objective is.
  83. #
  84. #        unfail_objective(quest_id, objective_id_1, ..., objective_id_n)
  85. #          Changes the status of the listed failed objectives back to active
  86. #
  87. #        change_reward_status(quest_id, value)
  88. #            value : either true or false. If excluded, defaults to true.
  89. #          Totally optional, but this is just a personal switch which you can
  90. #          turn on when the reward is given. You can then make it a condition
  91. #          so you don't reward the players more than once. (see line 180)
  92. #
  93. #  EXAMPLES:
  94. #    reveal_objective(1, 0)
  95. #      This would reveal the first objective of the quest with ID 1
  96. #    complete_objective(6, 2, 3)
  97. #      This would complete the third & fourth objectives of the quest with ID 6
  98. #    change_reward_status(8)
  99. #      This would set the reward switch to true for the quest with ID 8.
  100. #
  101. #   Another new feature is the ability to set rewards that will show up in the
  102. #  menu (see EDITABLE REGION B). In addition to that, you can use the following
  103. #  code to automatically distribute the specified rewards for a quest if the
  104. #  quest is complete and no reward has yet been given:
  105. #
  106. #        distribute_quest_rewards(quest_id)
  107. #          quest_id : the ID of the quest whose rewards you want to distribute
  108. #
  109. #   Of course, it can only distribute the material rewards (items, weapons,
  110. #   armors, gold, or exp). It won't distribute rewards you specify by string.
  111. #   To that end though, you can also use this code in a conditional branch and
  112. #   it will be satisfied only if it distributes the rewards. Thus, if you
  113. #   wanted to add some special rewards or do things like that, you can just put
  114. #   that in the branch for when it is true. This feature is not really
  115. #   recommended, since I think it is better to do it by events.
  116. #
  117. #    Other codes for the Script event command that can be useful are:
  118. #   
  119. #        reset_quest(quest_id)
  120. #            quest_id : the integer ID of the quest you want to access.
  121. #          This will re-initialize the quest, meaning all quest progress to
  122. #          date will be lost
  123. #
  124. #        remove_quest(quest_id)
  125. #          Deactivates the quest and resets it
  126. #
  127. #        conceal_quest(quest_id)
  128. #          Deactivates the quest so it won't show up in the scene, but progress
  129. #          is saved
  130. #
  131. #        reveal_quest(quest_id)
  132. #          Activates or reactivates the quest. This command is NECESSARY if
  133. #          MANUAL_REVEAL at line 284 is true or it has previously been
  134. #          concealed. Otherwise, it is sufficient just to operate on the quest
  135. #
  136. #        change_quest_access(:symbol)
  137. #          :symbol must be one of six options (include the colon!):
  138. #            :disable - prevents access to the quest scene (greys out in menu)
  139. #            :enable - enables access to the quest scene
  140. #            :disable_menu - this removes the quest option from the menu
  141. #            :enable_menu - this adds the quest option to the menu
  142. #            :disable_map - this prevents access by key from the map
  143. #            :enable_map - this allows access by key to the map
  144. #
  145. #        change_quest_background("bg_filename", bg_opacity, bg_blend_type)
  146. #            bg_filename   : the filename of the picture for the background in  
  147. #              the Pictures folder
  148. #            bg_opacity    : the opacity of the background graphic. If
  149. #              excluded, this defaults to the value of the setting at line 434.
  150. #            bg_blend_type : the blend type of the background graphic. If
  151. #              excluded, this defaults to the value of the setting at line 437.
  152. #
  153. #        change_quest_windows ("windowskin_filename", tone, opacity)
  154. #            windowskin_filename : the name of the Window graphic in the
  155. #              System folder of Graphics
  156. #            opacity             : the opacity of the windows. If excluded,
  157. #              this defaults to the value of the setting at line 423.
  158. #            blend_type          : the blend_type of the windows. If excluded,
  159. #              this defaults to the value of the setting at line 426.
  160. #
  161. #    Also, there are a few codes that can be used in the Script command of a
  162. #   conditional branch. I note here that all of these are optional. You could
  163. #   use switch and variable checks and monitor quest progress solely through
  164. #   events. However, these commands make it a little easier and they are:
  165. #
  166. #        quest_revealed?(quest_id)
  167. #            quest_id : the integer ID of the quest you want to access.
  168. #          This is satisfied if the quest has been activated.
  169. #
  170. #        quest_complete?(quest_id)
  171. #          This is satisfied if all prime objectives of the quest are complete
  172. #
  173. #        quest_failed?(quest_id)
  174. #          This is satisfied if any prime objective of the quest is failed
  175. #
  176. #        quest_rewarded?(quest_id)
  177. #          This is satisfied if you have changed the reward status to true.
  178. #
  179. #        objective_revealed?(quest_id, objective_id_1, ... objective_id_n)
  180. #            objective_id_1, ..., objective_id_n : a list of the IDs of the
  181. #              objectives you want to operate on. It can be as few as one or as
  182. #              many as all of them.
  183. #          This is satisfied if the listed objectives have been revealed
  184. #
  185. #        objective_active?(quest_id, objective_id_1, ... objective_id_n)
  186. #          This is satisfied if all the listed objectives are revealed and
  187. #          neither complete nor failed.
  188. #
  189. #        objective_complete?(quest_id, objective_id_1, ... objective_id_n)
  190. #          This is satisfied if all the listed objectives have been completed
  191. #
  192. #        objective_failed?(quest_id, objective_id_1, ... objective_id_n)
  193. #          This is satisfied if all the listed objectives have been failed
  194. #
  195. #    If you want to call the Quest scene from an event, you use the following
  196. #   code in a call script:
  197. #
  198. #        call_quest_journal
  199. #        call_quest_journal(quest_id)
  200. #          quest_id : ID of the quest you want to open the scene on
  201. #
  202. #  If you do not specify a quest_id (line 198) then it will simply open the
  203. #  scene as it would normally. If you do specify a quest_id (line 199) then it
  204. #  will open the scene on that quest so long as it has been revealed and it is
  205. #  normally accessible through the quest menu.
  206. #
  207. #   Finally, the default way this script operates is that quests automatically
  208. #  complete or fail based on the status of the prime objectives. However, you
  209. #  can set it so that there are no prime objectives, in which case you can only
  210. #  complete, fail, or (re)activate a quest manually through the following code
  211. #  in a script call:
  212. #
  213. #        manually_complete_quest(quest_id)
  214. #          quest_id : ID of the quest you want to manually complete
  215. #        manually_fail_quest(quest_id)
  216. #          quest_id : ID of the quest you want to manually fail
  217. #        manually_activate_quest(quest_id)
  218. #          quest_id : ID of the quest you want to manually activate
  219. #==============================================================================

  220. $imported ||= {}
  221. $imported[:"MA_QuestJournal_1.0"] = true

  222. #==============================================================================
  223. # *** QuestData
  224. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  225. #  This module contains all the configuration data for the quest journal
  226. #==============================================================================

  227. module QuestData
  228.   #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  229.   #  BEGIN Editable Region A
  230.   #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  231.   #  MENU_ACCESS - If true, you can access the quest journal through a command
  232.   # in the menu. If false, there will be no such command.
  233.   MENU_ACCESS = false
  234.   #  MENU_INDEX - If MENU_ACCESS is true, this determines where it appears
  235.   MENU_INDEX = 4
  236.   #  MAP_ACCESS - If true, this allows you to access the quest journal by
  237.   # pressing a key on the map.
  238.   MAP_ACCESS = true
  239.   #  MAP_BUTTON - If MAP_ACCESS is true, this determines which button calls the
  240.   # Quest Journal
  241.   MAP_BUTTON = :L
  242.   #  OPEN_TO_LAST_REVEALED_QUEST - If true, then the first time you open the
  243.   # quest journal after revealing a new quest, it will open to the new quest.
  244.   OPEN_TO_LAST_REVEALED_QUEST = true
  245.   #  OPEN_TO_LAST_CHANGED_QUEST - If true, then the Quest Journal will open to
  246.   # the last quest whose objective status has changed.
  247.   OPEN_TO_LAST_CHANGED_QUEST = false
  248.   #  LIST_WINDOW_WIDTH - The width, in pixels, of the List Window
  249.   LIST_WINDOW_WIDTH = 192
  250.   #  BASIC_DATA_TYPES  - This lets you set up additional types of data. Just
  251.   # include an identifying signal in the Array. Then, you will need to give
  252.   # each signal an icon (in the ICONS hash at line 322) and a signal text (in
  253.   # the VOCAB array at line 333, though it can be an empty string). Then, you
  254.   # can set the data itself when setting up quests by simply adding a:
  255.   #    q[:symbol] = ""
  256.   # line to the quest. You will also need to include the data type somewhere in
  257.   # the DATA_LAYOUT at line 306. As an example of this, I have included :client
  258.   # and :location by default. You can CTRL+F for anything in this section with
  259.   # one of those symbols (excluding :) and you will there need to add something
  260.   # for any new data types you add.
  261.   BASIC_DATA_TYPES = [:client, :location]
  262.   #  BASIC_DATA_WIDTH - This determines how much room, in pixels, is given to  
  263.   # any basic data types you set up in the data window.
  264.   BASIC_DATA_WIDTH = 240
  265.   #  CONCURRENT_ACTIVITY - If true, then when in the Quest Journal scene, you
  266.   # can switch categories or scroll down the quest list at the same time. If
  267.   # false, you will first need to select a category before you can start
  268.   # scrolling through the quest list.
  269.   CONCURRENT_ACTIVITY = true
  270.   #  HIDE_CATEGORY_CURSOR - If true, then the Category Window will not have a
  271.   # cursor and will instead just highlight the currently selected category.
  272.   # This is best when CONCURRENT_ACTIVITY is true.
  273.   HIDE_CATEGORY_CURSOR = true
  274.   #  SHOW_QUEST_ICONS - If true, then the icon you choose for each quest will
  275.   # be displayed to the left of its name in the Quest List window
  276.   SHOW_QUEST_ICONS = true
  277.   #  MANUAL_REVEAL - If false, then quests will be revealed the moment you
  278.   # first reveal, complete, or fail an objective. If this is true, you will
  279.   # need to specifically reveal each quest via a separate script call:
  280.   #    reveal_quest(quest_id)
  281.   MANUAL_REVEAL = false
  282.   #  DATA_LAYOUT - This controls the way that the quest window lays out all of
  283.   # the relevant data. If you set one of the entries to be an array, then any
  284.   # of the commands there will be drawn at the same y. With exception to :line,
  285.   # none of the commands will be drawn if the quest is not set to have that
  286.   # particular data. The symbols are:
  287.   #    :line        - Draws a horizontal line across the window.
  288.   #    :name        - Draws the name of the quest
  289.   #    :level       - Draws the level of the quest
  290.   #    :banner      - Draws the banner for the quest
  291.   #    :client      - Draws the client set in the quest   (basic data)
  292.   #    :location    - Draws the location set in the quest (basic data)
  293.   #    :description - Draws the quest's description
  294.   #    :objectives  - Draws all the quest's objectives that have been revealed
  295.   #    :rewards     - Draws whatever rewards have been set
  296.   #
  297.   # You will also need to add an entry for any new BASIC_DATA that you place
  298.   # in BASIC_DATA_TYPES at line 264.
  299.   #
  300.   # Remember to place a comma after each entry. Also note that this is only the
  301.   # default layout. You can set a different layout for any quest, and when
  302.   # viewing that quest, it will be the custom layout that is shown.
  303.   DATA_LAYOUT = [
  304.     [:line, :name, :level],
  305.     :banner,
  306.     :client,
  307.     :location,
  308.     :description,
  309.     :objectives,
  310.     [:line, :rewards],
  311.     :line,
  312.   ] # <= Do not touch.
  313.   #  ICONS - This is where you setup many of the icons used in the script. The
  314.   # purpose of each is listed next to it. Also, if you make any custom
  315.   # categories, you NEED to give them an icon by placing a line like the
  316.   # others. So, if the new custom category is :romance then you would need to
  317.   # set it like this:
  318.   #    romance:     107,
  319.   ICONS = {
  320.     all:         226, # The icon for the All Quests category
  321.     active:      236, # The icon for the Active Quests category
  322.     complete:    238, # The icon for the Complete Quests category
  323.     failed:      227, # The icon for the Failed Quests category
  324.     client:      121, # The icon for client data. If none wanted, set to 0
  325.     location:    231, # The icon for location data. If none wanted, set to 0
  326.     reward_gold: 262, # The icon for gold rewards. If none wanted, set to 0
  327.     reward_exp:  117, # The icon for exp rewards. If none wanted, set to 0
  328.   } # <= Do not touch.
  329.   #  VOCAB - This lets you choose some of the words used in the quest scene
  330.   VOCAB = {
  331.     # menu_label:  The command name in the menu if MENU_ACCESS is true
  332.     menu_label:       "任务",
  333.     # scene_label: The label at the top of the scene. If empty, no window
  334.     scene_label:      "任务选单",
  335.     # description: The heading to identify the description
  336.     description:      "任务介绍",
  337.     # objectives: The heading to identify the objectives
  338.     objectives:       "任务目标",
  339.     # objective_bullet: The bullet which shows up to the left of every
  340.     #  objective. If %d is included, it shows the objective's ID.
  341.     objective_bullet: "?",
  342.     # rewards: The heading to identify the rewards.
  343.     rewards:          "奖励",
  344.     # reward_amount: For item rewards, this is the text to show the amount.
  345.     #  It should include %d to show the amount.
  346.     reward_amount:    "x%d",
  347.     # reward_gold: Text to identify gold rewards
  348.     reward_gold:      "",
  349.     # reward_exp: Text to identify exp rewards
  350.     reward_exp:       "",
  351.     # level: If LEVEL_ICON is 0, this is the text which precedes the level
  352.     level:            "",#级别:",
  353.     # location: The text label for quest location
  354.     location:         "",
  355.     # location: The text label for quest client
  356.     client:           "",
  357.   } # <= Do not touch.
  358.   #  CATEGORIES - This array allows you to set which categories are available
  359.   # in the Quest scene. The default categories are :all, :active, :complete,
  360.   # and :failed, and their names are self-explanatory. You can add custom
  361.   # categories as well, but note that you will need to make sure that each new
  362.   # category has an icon set in the ICONS hash, as well as a label set in the
  363.   # CATEGORY_VOCAB hash (if you are using SHOW_CATEGORY_LABEL). It is also
  364.   # advisable to give it a sort type, unless you are fine with it being sorted
  365.   # by ID, as is default.
  366.   CATEGORIES = [:all, :active, :complete, :failed]
  367.   #  SHOW_CATEGORY_LABEL - This allows you to choose whether to show the name
  368.   # of the currently selected category. If true, it will choose the name out
  369.   # of the CATEGORY_VOCAB hash.
  370.   SHOW_CATEGORY_LABEL = true
  371.   #  CATEGORY_LABEL_IN_SAME_WINDOW - If SHOW_CATEGORY_LABEL is true, then this
  372.   # options lets you choose whether the label is shown in the same window as
  373.   # the category icons or in a separate window below. true = same window.
  374.   CATEGORY_LABEL_IN_SAME_WINDOW = true
  375.   #  CATEGORY_VOCAB - If SHOW_CATEGORY_LABEL is true, this hash lets you set the
  376.   # label for each category. For any custom categories you create, you will
  377.   # need to add a line for each below and in the same format:
  378.   #    :category => "Label",
  379.   # Don't forget to add the comma at the end of each line.
  380.   CATEGORY_VOCAB = {
  381.     :all =>      "所有任务",      # The label for the :all category
  382.     :active =>   "当前任务",   # The label for the :active category
  383.     :complete => "已完成任务", # The label for the :complete category
  384.     :failed =>   "失败的任务",   # The label for the :failed category
  385.   } # <= Do not touch.
  386.   #  SORT_TYPE - This hash allows you to choose how each category is sorted.
  387.   # For each category, default or custom, you can set a different sort method
  388.   # There are seven options to choose from:
  389.   #    :id - The quests are sorted from lowest to highest ID
  390.   #    :alphabet - The quests are sorted in alphabetical order
  391.   #    :level - The quests are sorted from the lowest to highest level
  392.   #    :reveal - The quests are sorted from most recently revealed on.
  393.   #            Every time a new quest is revealed, it will be at the top.
  394.   #    :change - The quests are sorted from the one whose status most recently
  395.   #            changed on. So, every time an objective is modified, that quest
  396.   #            will be thrown to the top.
  397.   #    :complete - The quests are sorted from the most recently completed on.
  398.   #            Every time a quest is completed, it will be thrown to the top.
  399.   #    :failed - The quests are sorted from the most recently failed on.
  400.   #            Every time a quest is failed, it will be thrown to the top.
  401.   #
  402.   # Additionally, you can put _r at the end of any of the sort options and it
  403.   # will reverse the order. So, for instance, if the sort method for a category
  404.   # is :alphabet_r, then the quests will show up from Z-A
  405.   SORT_TYPE = {
  406.     :all =>      :id,       # Sort type for the All Quests category
  407.     :active =>   :change,   # Sort type for the Active Quests category
  408.     :complete => :complete, # Sort type for the Complete Quests category
  409.     :failed =>   :failed,   # Sort type for the Failed Quests category
  410.   } # <= Do not touch.
  411.   #  WINDOWSKIN - The windowskin for each window in the Quest scene. It must
  412.   # refer to a graphic in the System folder of Graphics. If set to false, then
  413.   # it will use whatever windowskin is default. If you are using a script which
  414.   # lets the player choose the windowskin, false is the recommended value.
  415.   WINDOWSKIN = false
  416.   #  WINDOW_TONE - The tone for each window. It must be an array in the form:
  417.   #      WINDOW_TONE = [red, green, blue, gray]
  418.   # gray can be excluded, but the other three must be present. If you set this
  419.   # value to false, then the windows will have whatever tone is default.
  420.   WINDOW_TONE = false
  421.   #  WINDOW_OPACITY - The opacity of the windows in the Quest scene. If set to
  422.   # false, it will use the default opacity for windows.
  423.   WINDOW_OPACITY = false
  424.   #  BG_PICTURE - This is a string referring to a picture in the Picture folder
  425.   # of Graphics. If set to "", then there will be no picture. Otherwise, it
  426.   # will display the selected picture below the windows but above the map in
  427.   # the Quest scene.
  428.   BG_PICTURE = ""
  429.   #  BG_OPACITY - This allows you to set the opacity of the background picture,
  430.   # if you have selected one.
  431.   BG_OPACITY = 255
  432.   #  BG_BLEND_TYPE - This allows you to set the blend type of the background
  433.   # picture, if you have selected one.
  434.   BG_BLEND_TYPE = 0
  435.   #  DESCRIPTION_IN_BOX - This is a graphical option, and it allows you to
  436.   # choose whether the description should be shown in a box.
  437.   DESCRIPTION_IN_BOX = true
  438.   #  LEVEL_ICON - This sets how levels are shown. If set to an integer, then it
  439.   # will draw the same icon numerous times up to the level of the quest. Ie. If
  440.   # the level's quest is 1, then the icon will only be drawn once, but if the
  441.   # level's quest is 4, it will be drawn 4 times. LEVEL_ICONS_SPACE determines
  442.   # the space between them. If you set LEVEL_ICON to 0, however, then it will
  443.   # instead draw a signal for the level, corresponding to that index in the
  444.   # LEVEL_SIGNALS array. If the LEVEL_SIGNALS array is empty, then it will just
  445.   # draw the integer for the level. Finally, LEVEL_ICON can also be an array of
  446.   # integers, in which case the level will be represented only by the icon set
  447.   # which corresponds to it in the array.
  448.   LEVEL_ICON = 0
  449.   #  LEVEL_ICONS_SPACE - If LEVEL_ICON is an integer, this is the amount of
  450.   # space between each time the icon is drawn.
  451.   LEVEL_ICONS_SPACE = 12
  452.   #  LEVEL_SIGNALS - If LEVEL_ICON is 0, this allows you to set what string
  453.   # should be the signal for each level. If this array is empty, then it will
  454.   # just draw the level integer. Ie. if the Quest is Level 4, it will draw 4.
  455.   LEVEL_SIGNALS = ["傻逼", "普通", "智者", "疯子", "国战", "种族", "天道"]
  456.   #  COLOURS - This lets you change the colour for various aspects of the
  457.   # quest scene. Each can be set in one of three ways:
  458.   #    :symbol - If you use a symbol, the colour will be the result of calling
  459.   #      the method of the same name. For instance, if you set something to
  460.   #      :system_color, it will set the colour to the result of the Window_Base
  461.   #      system_color method.
  462.   #    Integer - If you set the colour to an integer, then it will take its
  463.   #      colour from the windowskin palette, just like using \c[x] in messages.
  464.   #    Array - You can also set the rgba values directly with an array in the
  465.   #      format: [red, green, blue, alpha]. alpha can be excluded, but you must
  466.   #      have values for red, green, and blue.
  467.   COLOURS = {
  468.     # active: This sets the colour for active quests in the list and the name
  469.     #  of the active quest when shown in the data window.
  470.     active:           :normal_color,
  471.     # complete: This sets the colour for complete quests in the list and the
  472.     #  name of the complete quest when shown in the data window.
  473.     complete:         3,
  474.     # failed: This sets the colour for failed quests in the list and the name
  475.     #  of the failed quest when shown in the data window.
  476.     failed:           10,
  477.     # line:  This sets the colour for lines or boxes drawn in the quest scene
  478.     line:             :system_color,
  479.     # line_shadow:  This sets the colour of the shadow for lines or boxes drawn
  480.     #  in the quest scene
  481.     line_shadow: [0, 0, 0, 128],
  482.     # scene_label: This sets the colour for the scene label, if shown
  483.     scene_label:      :system_color,
  484.     # category_label: This sets the colour for the category label, if shown
  485.     category_label:   :normal_color,
  486.     # level_signal: This sets the colour for the level signal, if shown
  487.     level_signal:     :normal_color,
  488.     # objective_bullet: This sets the colour for objectives; if set to
  489.     #  :maqj_objective_color, it will reflect the completion status of the
  490.     #  objective, but you can change it to something else if you prefer
  491.     objective_bullet: :maqj_objective_color,
  492.     # reward_amount: The colour of the item amount, when shown
  493.     reward_amount:    :normal_color,
  494.     # heading: The colour of any headings in the script, like "Description"
  495.     heading:          :system_color,
  496.     # basic_label: For basic data, like client, the colour of the label
  497.     basic_label:      :system_color,
  498.     # basic_value: For basic data, like client, the colour of the value
  499.     basic_value:      :normal_color,
  500.   } # <= Do not touch.
  501.   #  HEADING_ALIGN - This sets the alignment for the aspects listed. 0 is Left;
  502.   # 1 is Centre; 2 is Right
  503.   HEADING_ALIGN = {
  504.     description: 0, # Alignment for the Description heading
  505.     objectives:  0, # Alignment for the Objectives heading
  506.     rewards:     1, # Alignment for the Rewards heading
  507.     level:       2  # Alignment when showing the level
  508.   } # <= Do not touch.
  509.   #````````````````````````````````````````````````````````````````````````````
  510.   #    Font Aspects
  511.   #
  512.   #  All of the following options (FONTNAMES, FONTSIZES, FONTBOLDS, and
  513.   # FONTITALICS) allow you to alter the fonts used for various aspects of the
  514.   # scene. The only one listed there by default is normal:, which is the
  515.   # font used by default for the entire scene. However, you can change the  
  516.   # fonts for almost any aspect - all you need to do is add a line like so:
  517.   #
  518.   #    description: value,
  519.   #
  520.   # and that will change that font aspect when drawing the description. The
  521.   # following symbols are available for changing:
  522.   #
  523.   #   normal:         The default font used for every part of the scene
  524.   #   list:           The font used in the List Window
  525.   #   scene_label:    The font used when drawing the Scene Label, if shown
  526.   #   category_label: The font used when drawing the Category Label, if shown
  527.   #   heading:        The font used when drawing any headings, like "Description"
  528.   #   name:           The font used when drawing the quest name in data window
  529.   #   description:    The font used when drawing the Description
  530.   #   objectives:     The font used when drawing the objectives
  531.   #   rewards:        The font used when drawing the rewards
  532.   #   client:         The font used when drawing the client
  533.   #   location:       The font used when drawing the location
  534.   #
  535.   # For any of them, you need to set a value. What the value can be depends
  536.   # on which font aspect you are changing and is described below, but for any
  537.   # of them setting it to the false will mean it will simply use the default
  538.   #
  539.   # For any that you add, remember that you must put a comma after the value.
  540.   #````````````````````````````````````````````````````````````````````````````
  541.   #  FONTNAMES - Here you can change the font used for any of the various
  542.   # options. It can take any of the following types of values:
  543.   #     false    - The default font will be used
  544.   #     "String" - The font with the name "String" will be used.
  545.   #     [Array]  - The array must be in the form: ["String1", "String2", ...]
  546.   #               The font used will be the first one in the array that the
  547.   #               player has installed.
  548.   #
  549.   #  EXAMPLES:
  550.   #
  551.   #    normal:      false,
  552.   #      The font used for unaltered aspects of the scene is the default font
  553.   #    scene_label: "Algerian",
  554.   #      The font used for the Scene Label will be Algerian.
  555.   #    description: ["Cambria", "Times New Roman"],
  556.   #      The font used when drawing the description will be Cambria if the
  557.   #      player has Cambria installed. If the player does not have Cambria
  558.   #      installed, then the font used will be Times New Roman
  559.   FONTNAMES = {
  560.     normal: false, # normal: the default font name
  561.   } # <= Do not touch.
  562.   #  FONTSIZES - Here you can change the size of the font. There are two types
  563.   # of values you can set:
  564.   #    false   - The default fontsize will be used
  565.   #    Integer - The fontsize will be equal to the value of the Integer.
  566.   #  
  567.   # For everything but the label windows, this shouldn't exceed 24, since that
  568.   # is the line_height. However, for scene_label: and category_label:, the size
  569.   # of the window will be adjusted to whatever size you set the font.
  570.   FONTSIZES = {
  571.     normal:         false, # normal: default font size
  572.     scene_label:    28,    # scene_label: fontsize for the Scene Label window
  573.     category_label: 24,    # category_label: fontsize for Category Label window
  574.   } # <= Do not touch.
  575.   #  FONTBOLDS - Here you can set whether the font will be bolded. You can set
  576.   # it to either false, in which case it will not be bolded, or true, in which
  577.   # case it will be bolded.
  578.   FONTBOLDS = {
  579.     scene_label:  true, # scene_label: whether font is bold for Scene Label
  580.     heading:      true, # heading: whether font is bold for the headings
  581.     level_signal: true, # level_signal: whether font is bold for level
  582.   } # <= Do not touch.
  583.   #  FONTITALICS - Here you can set whether the font will be italicized. You
  584.   # can set it to either false, in which case it will not be italicized, or
  585.   # true, in which case it will be italicized.
  586.   FONTITALICS = {
  587.   }
  588.   #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  589.   #  END Editable Region A
  590.   #//////////////////////////////////////////////////////////////////////////
  591.   CATEGORIES = [:all] if !CATEGORIES || CATEGORIES.empty?
  592.   VOCAB.default = ""
  593.   ICONS.default = 0
  594.   CATEGORY_VOCAB.default = ""
  595.   SORT_TYPE.default = :id
  596.   COLOURS.default = :normal_color
  597.   HEADING_ALIGN.default = 0
  598.   FONTNAMES.default = false
  599.   FONTSIZES.default = false
  600.   FONTBOLDS.default = false
  601.   FONTITALICS.default = false
  602.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  603.   # * Setup Quest
  604.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  605.   def self.setup_quest(quest_id)
  606.     q = { objectives: [] }
  607.     case quest_id
  608.     #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  609.     #  BEGIN Editable Region B
  610.     #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  611.     #    Quest Setup
  612.     #
  613.     #  This is where you set up the data for every quest in the game. While
  614.     # it may seem complicated, I urge you to pay attention and, once you get
  615.     # the hang of it, I am sure it will quickly become second nature.
  616.     #
  617.     #  Every single quest should be set up in the following format, but note
  618.     # that if you are not setting anything for a particular aspect, you can
  619.     # delete that line. Anyway, this is what each quest should look like, with
  620.     # the values on the left being the default values if you don't set them:
  621.     #
  622.     #  when quest_id
  623.     #   q[:name]              = "??????"
  624.     #   q[:icon_index]        = 0
  625.     #   q[:level]             = 0
  626.     #   q[:description]       = ""
  627.     #   q[:banner]            = ""
  628.     #   q[:banner_hue]        = 0
  629.     #   q[:objectives][0]     = ""
  630.     #   q[:objectives][1]     = ""
  631.     #   q[:objectives][2]     = ""
  632.     #   q[:objectives][n]     = ""
  633.     #   q[:prime_objectives]  = [0, 1, 2, n]
  634.     #   q[:custom_categories] = []
  635.     #   q[:client]            = ""
  636.     #   q[:location]          = ""
  637.     #   q[:rewards]           = []
  638.     #   q[:common_event_id]   = 0
  639.     #   q[:layout]            = false
  640.     #
  641.     #  For each line, with the exception of objectives, it is only the value on
  642.     # the right of the equals sign that you will need to change. Now I will
  643.     # explain each line:
  644.     #
  645.     # when quest_id
  646.     #    quest_id - is an integer of your choosing, and this is how you
  647.     #        reference a quest in order to advance and do anything else. It
  648.     #        must be unique for every quest; if you use 1 for the first quest,
  649.     #        you cannot use 1 for any other quest.
  650.     #
  651.     #   q[:name]              = ""
  652.     #     "" - This line sets the name of the quest which shows in the Quest
  653.     #        List.
  654.     #   
  655.     #   q[:icon_index]        = 0
  656.     #     0  - This line sets the icon to be used for this quest. It will show
  657.     #        to the left of the quest's name in the Quest List.
  658.     #
  659.     #   q[:level]             = 0
  660.     #     0  - This line sets the level of the quest. If 0, no level will be
  661.     #        shown. See the level options at lines 441-458 for more detail.
  662.     #   
  663.     #   q[:description]       = ""
  664.     #     "" - This line sets the description of the quest. You can use message
  665.     #        codes in this string, but if you are using "" then you need to use
  666.     #        \\ to identify codes and not just \. Ie. It's \\v[x], not \v[x]
  667.     #
  668.     #   q[:objectives][0]     = ""
  669.     #   q[:objectives][1]     = ""
  670.     #   q[:objectives][2]     = ""
  671.     #   q[:objectives][n]     = ""
  672.     #  Objectives are slightly different. Notice that after q[:objectives] on
  673.     # each line there is an integer enclosed in square brackets:
  674.     #    [n] - This is the ID of the objective, and n MUST be an integer. No
  675.     #       quest can have more than one objective with the same ID. This is
  676.     #       how you identify which objective you want to reveal, complete or
  677.     #       fail. That said, you can make as many objectives as you want, as
  678.     #       long as you give them all distinct IDs. The IDs should be in
  679.     #       sequence as well, so there shouldn't be a q[:objectives][5] if
  680.     #       there is no q[:objectives][4].
  681.     #     "" - This is the text of the objective. You can use message codes in
  682.     #        this string, but if you are using "" then you will need to use
  683.     #        \\ to identify codes and not just \. Ie: It's \\v[x], not \v[x]
  684.     #
  685.     #   q[:prime_objectives]  = [0, 1, 2, n]
  686.     #     [0, 1, 2, n] - This array determines what objectives need to be
  687.     #        completed in order for the quest to be complete. In other words,
  688.     #        all of the objectives with the IDs in this array need to be
  689.     #        complete for the quest to be complete. If any one of them is
  690.     #        failed, the quest will be failed. If you remove this line
  691.     #        altogether, then all objectives are prime. If you set this to [],
  692.     #        then the quest will never be automatically completed or failed and
  693.     #        you need to use the manual options described at lines 207-218.
  694.     #
  695.     #   q[:custom_categories] = []
  696.     #     [] - This allows you to set an array of custom categories for this
  697.     #        quest, whiich means this quest will show up in each of those
  698.     #        categories if you add it to the CATEGORIES array at line 369.
  699.     #        Note that each category you make must be identified by a unique
  700.     #        :symbol, and you must set up all the category details for that
  701.     #        :symbol.
  702.     #
  703.     #   q[:banner]            = ""
  704.     #     "" - This line sets the banner to be used for a quest. It must be the
  705.     #        filename of an image in the Pictures folder of Graphics.
  706.     #
  707.     #   q[:banner_hue]        = 0
  708.     #     0 - The hue of the banner graphic, if used
  709.     #
  710.     #   q[:client]            = ""
  711.     #     "" - This line sets the client name for this quest. (basic data)
  712.     #
  713.     #   q[:location]          = ""
  714.     #     "" - This line sets the location of the quest. (basic data)
  715.     #
  716.     #   q[:rewards]           = []
  717.     #    [] - In this array, you can identify particular rewards that will
  718.     #       show up
  719.     #
  720.     #   q[:common_event_id]   = 0
  721.     #     0  - This allows you to call the identified common event immediately
  722.     #        and automatically once the quest is completed. It is generally
  723.     #        not recommended, as for most quests you should be controlling it
  724.     #        enough not to need this feature.
  725.     #
  726.     #   q[:layout]            = false
  727.     #     false - The default value for this is false, and when it is false the
  728.     #        layout for the quest will be inherited from the default you set at
  729.     #        302. However, you can also give the quest its own layout - the
  730.     #        format would be the same as you set for the default at line 306.
  731.     #  
  732.     # Template:
  733.     #
  734.     #  When making a new quest, I recommend that you copy and paste the
  735.     # following template, removing whichever lines you don't want to alter.
  736.     # Naturally, you need to remove the #~. You can do so by highlighting
  737.     # the entire thing and pressing CTRL+Q:
  738. #~     when 2 # <= REMINDER: The Quest ID MUST be unique
  739. #~       q[:name]              = "??????"
  740. #~       q[:icon_index]        = 0
  741. #~       q[:level]             = 0
  742. #~       q[:description]       = ""
  743. #~       # REMINDER: You can make as many objectives as you like, but each must
  744. #~       # have a unique ID.
  745. #~       q[:objectives][0]     = ""
  746. #~       q[:objectives][1]     = ""
  747. #~       q[:objectives][2]     = ""
  748. #~       q[:prime_objectives]  = [0, 1, 2]
  749. #~       q[:custom_categories] = []
  750. #~       q[:banner]            = ""
  751. #~       q[:banner_hue]        = 0
  752. #~       q[:client]            = ""
  753. #~       q[:location]          = ""
  754. #~       q[:rewards]           = []
  755. #~       q[:common_event_id]   = 0
  756.     when 1 # Quest 1 - SAMPLE QUEST
  757.       q[:name]              = "黑暗的苏醒"
  758.       q[:level]             = 7
  759.       q[:icon_index]        = 7
  760.       q[:description]       = "圣骑士长的膝盖中了一箭,投靠了黑
  761. 暗势力。请联络大天使加百列讨论天
  762. 人联盟的问题。"
  763.       q[:objectives][0]     = "与大天使加百列对话"
  764.       q[:objectives][1]     = "组建天人联盟"
  765.       q[:objectives][2]     = "帮助重建天国"
  766.       q[:objectives][3]     = "与黑暗圣骑士战斗并取得胜利"
  767.       q[:prime_objectives]  = [0, 1]
  768.       q[:custom_categories] = []
  769.       q[:banner]            = ""
  770.       q[:banner_hue]        = 0
  771.       q[:client]            = "加百列"
  772.       q[:location]          = "天堂遗迹"
  773.       q[:common_event_id]   = 0
  774.       q[:rewards]           = [
  775.         [:item, 1, 3],
  776.         [:gold, 500],
  777.       ]
  778.       q[:layout]            = false
  779.     #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  780.     #  END Editable Region B
  781.     #//////////////////////////////////////////////////////////////////////
  782.     end
  783.     q
  784.   end
  785. end

  786. #==============================================================================
  787. # *** DataManager
  788. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  789. #  Summary of Changes:
  790. #    aliased method - self.extract_save_contents
  791. #==============================================================================

  792. class << DataManager
  793.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  794.   # * Extract Save Contents
  795.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  796.   alias maqj_extractsavecons_2kw5 extract_save_contents
  797.   def extract_save_contents(*args, &block)
  798.     maqj_extractsavecons_2kw5(*args, &block) # Call Original Method
  799.     if $game_party.quests.nil?
  800.       $game_party.init_maqj_data
  801.       $game_system.init_maqj_data
  802.     end
  803.   end
  804. end

  805. #==============================================================================
  806. # ** MAQJ_SortedArray
  807. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  808. #  This module mixes in to an array to maintain the sorted order when inserting
  809. #==============================================================================

  810. module MAQJ_SortedArray
  811.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  812.   # * Insert to Array
  813.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  814.   def maqj_insert_sort(el, &block)
  815.     index = bsearch_index(el, 0, size, &block)
  816.     index ? insert(index, el) : push(el)
  817.   end
  818.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  819.   # * Retrieve Index from Binary Search
  820.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  821.   def bsearch_index(el, b = 0, e = size, &block)
  822.     return bsearch_index(el, b, e) { |a,b| a <=> b } if block.nil?
  823.     return b if b == e # Return the discovered insertion index
  824.     return if b > e
  825.     m = (b + e) / 2    # Get Middle
  826.     block.call(el, self[m]) > 0 ? b = m + 1 : e = m
  827.     bsearch_index(el, b, e, &block)
  828.   end
  829. end

  830. #==============================================================================
  831. # ** Game_Quest
  832. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  833. #  This class holds all instance data for a quest
  834. #==============================================================================

  835. class Game_Quest
  836.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  837.   # * Public Instance Variables
  838.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  839.   attr_reader   :id                  # Unique identifier for this quest
  840.   attr_reader   :name                # The name to be shown for the quest
  841.   attr_reader   :level               # The level of difficulty of the quest
  842.   attr_reader   :objectives          # An array of objective strings
  843.   attr_reader   :prime_objectives    # An array of crucial objective IDs
  844.   attr_reader   :revealed_objectives # An array of revealed objective IDs
  845.   attr_reader   :complete_objectives # An array of completed objective IDs
  846.   attr_reader   :failed_objectives   # An array of failed objective IDs
  847.   attr_reader   :custom_categories   # An array of category symbols
  848.   attr_accessor :icon_index          # Icon associated with this quest
  849.   attr_accessor :common_event_id     # ID of common event to call upon complete
  850.   attr_accessor :description         # The description for the quest
  851.   attr_accessor :banner              # Picture shown to represent the quest
  852.   attr_accessor :banner_hue          # The hue of the banner
  853.   attr_accessor :layout              # The layout of this quest in scene
  854.   attr_accessor :rewards             # An array of rewards to show
  855.   attr_accessor :reward_given        # Boolean tracking if quest was rewarded
  856.   attr_accessor :concealed           # Whether or not the quest is visible
  857.   attr_accessor :manual_status       # Quest status if not using prime objectives
  858.   QuestData::BASIC_DATA_TYPES.each { |data_type| attr_accessor(data_type) }
  859.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  860.   # * Object Initialization
  861.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  862.   def initialize(quest_id)
  863.     @id = quest_id
  864.     @concealed = default_value_for(:concealed)
  865.     @reward_given = default_value_for(:reward_given)
  866.     reset
  867.   end
  868.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  869.   # * Reset
  870.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  871.   def reset
  872.     data = QuestData.setup_quest(@id)
  873.     data_symbol_array.each { |meth| instance_variable_set(:"@#{meth}",
  874.       data[meth] ? data[meth] : default_value_for(meth)) }
  875.     @revealed_objectives = [].send(:extend, MAQJ_SortedArray)
  876.     @complete_objectives = [].send(:extend, MAQJ_SortedArray)
  877.     @failed_objectives =   [].send(:extend, MAQJ_SortedArray)
  878.     @manual_status = default_value_for(:manual_status)
  879.   end
  880.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  881.   # * Data Symbol Array
  882.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  883.   def data_symbol_array
  884.     [:name, :level, :objectives, :prime_objectives, :custom_categories,
  885.       :icon_index, :description, :banner, :banner_hue, :common_event_id,
  886.       :layout, :rewards] + QuestData::BASIC_DATA_TYPES
  887.   end
  888.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  889.   # * Default Value
  890.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  891.   def default_value_for(method)
  892.     case method
  893.     when :name then "??????"
  894.     when :description, :banner then ""
  895.     when :level, :banner_hue, :icon_index, :common_event_id then 0
  896.     when :objectives, :rewards, :custom_categories then []
  897.     when :prime_objectives then Array.new(objectives.size) { |x| x }
  898.     when :concealed then QuestData::MANUAL_REVEAL
  899.     when :manual_status then :active
  900.     when :layout, :reward_given then false
  901.     else ""
  902.     end
  903.   end
  904.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  905.   # * Reveal/Conceal Objective
  906.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  907.   def reveal_objective(*obj)
  908.     valid_obj = obj.select {|x| x < objectives.size && !@revealed_objectives.include?(x) }
  909.     valid_obj.each {|i| @revealed_objectives.maqj_insert_sort(i) }
  910.     quest_status_changed unless valid_obj.empty?
  911.   end
  912.   def conceal_objective(*obj)
  913.     quest_status_changed unless (obj & @revealed_objectives).empty?
  914.     obj.each { |obj_id| @revealed_objectives.delete(obj_id) }
  915.   end
  916.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  917.   # * Complete/Uncomplete Objective
  918.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  919.   def complete_objective(*obj)
  920.     valid_obj = obj.select {|x| x < objectives.size && !@complete_objectives.include?(x) }
  921.     reveal_objective(*valid_obj)
  922.     unfail_objective(*valid_obj)
  923.     was_complete = status?(:complete)
  924.     valid_obj.each {|i| @complete_objectives.maqj_insert_sort(i) }
  925.     quest_status_changed unless valid_obj.empty?
  926.     # If just completed
  927.     if status?(:complete) && !was_complete
  928.       $game_temp.reserve_common_event(common_event_id)
  929.       $game_party.quests.add_to_sort_array(:complete, @id)
  930.     end
  931.   end
  932.   def uncomplete_objective(*obj)
  933.     quest_status_changed unless (obj & @complete_objectives).empty?
  934.     obj.each { |obj_id| @complete_objectives.delete(obj_id) }
  935.   end
  936.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  937.   # * Fail/Unfail Objective
  938.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  939.   def fail_objective(*obj)
  940.     valid_obj = obj.select {|x| x < objectives.size && !@failed_objectives.include?(x) }
  941.     reveal_objective(*valid_obj)
  942.     uncomplete_objective(*valid_obj)
  943.     was_failed = status?(:failed)
  944.     valid_obj.each {|i| @failed_objectives.maqj_insert_sort(i) }
  945.     quest_status_changed unless valid_obj.empty?
  946.     $game_party.quests.add_to_sort_array(:failed, @id) if status?(:failed) && !was_failed
  947.   end
  948.   def unfail_objective(*obj)
  949.     quest_status_changed unless (obj & @failed_objectives).empty?
  950.     obj.each { |obj_id| @failed_objectives.delete(obj_id) }
  951.   end
  952.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  953.   # * Updates when the quest status has been changed
  954.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  955.   def quest_status_changed
  956.     $game_party.quests.add_to_sort_array(:change, @id)
  957.     $game_system.last_quest_id = @id if QuestData::OPEN_TO_LAST_CHANGED_QUEST
  958.   end
  959.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  960.   # * Objective Status?
  961.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  962.   def objective_status?(status_check, *obj)
  963.     return false if obj.empty?
  964.     case status_check
  965.     when :failed   then !(obj & @failed_objectives).empty?
  966.     when :complete then obj.size == (obj & @complete_objectives).size
  967.     when :revealed then obj.size == (obj & @revealed_objectives).size
  968.     when :active then objective_status?(:revealed, *obj) &&
  969.       !objective_status?(:complete, *obj) && !objective_status?(:failed, *obj)
  970.     end
  971.   end
  972.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  973.   # * Status?
  974.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  975.   def status?(status_check)
  976.     case status_check
  977.     when :failed  
  978.       @prime_objectives.empty? ? @manual_status == :failed :
  979.         !(@failed_objectives & @prime_objectives).empty?
  980.     when :complete
  981.       @prime_objectives.empty? ? @manual_status == :complete : !status?(:failed) &&
  982.         ((@prime_objectives & @complete_objectives) == @prime_objectives)
  983.     when :active then !concealed && !status?(:complete) && !status?(:failed)
  984.     when :reward then @reward_given
  985.     end
  986.   end
  987.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  988.   # * Set Name
  989.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  990.   def name=(new_name)
  991.     @name = new_name
  992.     $game_party.quests.add_to_sort_array(:alphabet, @id) if $game_party &&
  993.       $game_party.quests
  994.   end
  995.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  996.   # * Set Level
  997.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  998.   def level=(new_lvl)
  999.     @level = new_lvl
  1000.     $game_party.quests.add_to_sort_array(:level, @id) if $game_party &&
  1001.       $game_party.quests
  1002.   end
  1003. end

  1004. #==============================================================================
  1005. # ** Game_Quests
  1006. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1007. #  This is a wrapper for an array holding Game_Quest objects
  1008. #==============================================================================

  1009. class Game_Quests
  1010.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1011.   # * Object Initialization
  1012.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1013.   def initialize
  1014.     @data = {}
  1015.     @sort_arrays = {
  1016.       reveal: [], change: [], complete: [], failed: [],
  1017.       id:       [].send(:extend, MAQJ_SortedArray),
  1018.       alphabet: [].send(:extend, MAQJ_SortedArray),
  1019.       level:    [].send(:extend, MAQJ_SortedArray)
  1020.     }
  1021.   end
  1022.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1023.   # * Get Quest
  1024.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1025.   def [](quest_id)
  1026.     reset_quest(quest_id) if !@data[quest_id]
  1027.     @data[quest_id]
  1028.   end
  1029.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1030.   # * Set Quest <- Not sure when this would ever be useful.
  1031.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1032.   def []=(quest_id, value)
  1033.     @data[quest_id] = value
  1034.   end
  1035.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1036.   # * List
  1037.   #    list_type : the type of list to return
  1038.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1039.   def list(list_type = :all, sort_type = $game_system.quest_sort_type[list_type])
  1040.     sort_type_s = sort_type.to_s
  1041.     reverse = !(sort_type_s.sub!(/_r$/, "")).nil?
  1042.     sort_type = sort_type_s.to_sym
  1043.     list = @sort_arrays[sort_type].select { |quest_id| include?(quest_id, list_type) }
  1044.     list.reverse! if reverse
  1045.     list.collect { |quest_id| @data[quest_id] }
  1046.   end
  1047.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1048.   # * Include?
  1049.   #    determines whether to include a particular quest depending on list type
  1050.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1051.   def include?(quest_id, list_type = :all)
  1052.     return false if !revealed?(quest_id)
  1053.     case list_type
  1054.     when :all then true
  1055.     when :complete, :failed, :active then @data[quest_id].status?(list_type)
  1056.     else
  1057.       @data[quest_id].custom_categories.include?(list_type)
  1058.     end
  1059.   end
  1060.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1061.   # * Revealed?
  1062.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1063.   def revealed?(quest_id)
  1064.     (!@data[quest_id].nil? && !@data[quest_id].concealed)
  1065.   end
  1066.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1067.   # * Setup Quest
  1068.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1069.   def setup_quest(quest_id)
  1070.     return if @data[quest_id]
  1071.     @data[quest_id] = Game_Quest.new(quest_id)
  1072.     # Open to this quest next time the QJ is opened
  1073.     $game_system.last_quest_id = quest_id if QuestData::OPEN_TO_LAST_REVEALED_QUEST
  1074.     # Save sorting order in separate arrays to avoid re-sorting every time
  1075.     @sort_arrays.keys.each { |sym| add_to_sort_array(sym, quest_id) }
  1076.   end
  1077.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1078.   # * Delete Quest
  1079.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1080.   def delete_quest(quest_id)
  1081.     @data.delete(quest_id)
  1082.     @sort_arrays.values.each { |ary| ary.delete(quest_id) }
  1083.   end
  1084.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1085.   # * Reset Quest
  1086.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1087.   def reset_quest(quest_id)
  1088.     delete_quest(quest_id)
  1089.     setup_quest(quest_id)
  1090.   end
  1091.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1092.   # * Add to Sorted Array
  1093.   #    sort_type : array to alter
  1094.   #    quest_id  : ID of the quest to add.
  1095.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1096.   def add_to_sort_array(sort_type, quest_id)
  1097.     @sort_arrays[sort_type].delete(quest_id) # Make sure always unique
  1098.     case sort_type
  1099.     when :reveal, :change, :complete, :failed
  1100.       @sort_arrays[sort_type].unshift(quest_id)
  1101.     when :id
  1102.       @sort_arrays[sort_type].maqj_insert_sort(quest_id)
  1103.     when :alphabet
  1104.       @sort_arrays[sort_type].maqj_insert_sort(quest_id) { |a, b| @data[a].name.downcase <=> @data[b].name.downcase }
  1105.     when :level
  1106.       @sort_arrays[sort_type].maqj_insert_sort(quest_id) { |a, b| @data[a].level <=> self[b].level }
  1107.     end
  1108.   end
  1109.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1110.   # * Find Location
  1111.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1112.   def find_location(quest_id, cat = nil)
  1113.     if revealed?(quest_id)
  1114.       categories = $game_system.quest_categories.dup
  1115.       # If cat specified, check in that category first.
  1116.       if cat && categories.include?(cat)
  1117.         categories.delete(cat)
  1118.         categories.unshift(cat)
  1119.       end
  1120.       for category in categories # Check all categories
  1121.         index = list(category).index(@data[quest_id])
  1122.         return category, index if index != nil
  1123.       end
  1124.     end
  1125.     return nil, nil
  1126.   end
  1127.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1128.   # * Clear
  1129.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1130.   def clear
  1131.     @data.clear
  1132.   end
  1133. end

  1134. #==============================================================================
  1135. # ** Game System
  1136. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1137. #  Summary of Changes:
  1138. #    new attr_accessor - quest_menu_access; quest_map_access; quest_sort_type;
  1139. #      quest_bg_picture; quest_bg_opacity; quest_windowskin;
  1140. #      quest_window_opacity; quest_access_disabled; last_quest_cat;
  1141. #      last_quest_id
  1142. #    aliased methods - initialize
  1143. #    new methods - init_maqj_data
  1144. #==============================================================================

  1145. class Game_System
  1146.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1147.   # * Public Instance Variables
  1148.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1149.   attr_reader   :quest_menu_access     # Whether the scene is called from menu
  1150.   attr_accessor :quest_map_access      # Whether the scene is called from map
  1151.   attr_accessor :quest_sort_type       # The sort types for each category
  1152.   attr_accessor :quest_bg_picture      # The filename of the background picture
  1153.   attr_accessor :quest_bg_opacity      # The opacity of the background picture
  1154.   attr_accessor :quest_bg_blend_type   # The blend type of the background pic
  1155.   attr_accessor :quest_windowskin      # The windowskin used for the scene
  1156.   attr_accessor :quest_window_tone     # The tone of windows in the scene
  1157.   attr_accessor :quest_window_opacity  # The opacity of windows in the scene
  1158.   attr_accessor :quest_access_disabled # Whether access to Quests is disabled
  1159.   attr_accessor :quest_categories      # The categories to show in the scene
  1160.   attr_accessor :quest_scene_label     # The label to show in the scene
  1161.   attr_accessor :last_quest_cat        # The category to open to
  1162.   attr_accessor :last_quest_id         # The ID to open to
  1163.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1164.   # * Object Initialization
  1165.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1166.   alias maqj_initialze_2cy9 initialize
  1167.   def initialize(*args, &block)
  1168.     maqj_initialze_2cy9(*args, &block)
  1169.     init_maqj_data
  1170.   end
  1171.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1172.   # * Initialize Quest Data
  1173.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1174.   def init_maqj_data
  1175.     # Initialize new variables
  1176.     self.quest_menu_access = QuestData::MENU_ACCESS
  1177.     @quest_map_access = QuestData::MAP_ACCESS
  1178.     @quest_sort_type = QuestData::SORT_TYPE
  1179.     @quest_bg_picture = QuestData::BG_PICTURE
  1180.     @quest_bg_opacity = QuestData::BG_OPACITY
  1181.     @quest_bg_blend_type = QuestData::BG_BLEND_TYPE
  1182.     @quest_windowskin = QuestData::WINDOWSKIN
  1183.     @quest_window_tone = QuestData::WINDOW_TONE
  1184.     @quest_window_opacity = QuestData::WINDOW_OPACITY
  1185.     @quest_access_disabled = false
  1186.     @quest_categories = QuestData::CATEGORIES
  1187.     @quest_scene_label = QuestData::VOCAB[:scene_label]
  1188.     @last_quest_cat = @quest_categories[0]
  1189.     @last_quest_id = 0
  1190.   end
  1191.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1192.   # * Set Quest Menu Access
  1193.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1194.   def quest_menu_access=(boolean)
  1195.     @quest_menu_access = boolean
  1196.     maic_inserted_menu_commands.delete(:quest_journal)
  1197.     maic_inserted_menu_commands.push(:quest_journal) if @quest_menu_access
  1198.     maic_inserted_menu_commands.sort!
  1199.   end
  1200. end

  1201. #==============================================================================
  1202. # ** Game_Party
  1203. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1204. #  Summary of Changes:
  1205. #    new attr_reader - quests
  1206. #    aliased method - initialize
  1207. #    new method - init_maqj_data
  1208. #==============================================================================

  1209. class Game_Party
  1210.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1211.   # * Public Instance Variables
  1212.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1213.   attr_reader :quests
  1214.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1215.   # * Object Initialization
  1216.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1217.   alias maqj_intiaze_2si9 initialize
  1218.   def initialize(*args, &block)
  1219.     maqj_intiaze_2si9(*args, &block) # Call Original Method
  1220.     init_maqj_data
  1221.   end
  1222.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1223.   # * Initialize Quests
  1224.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1225.   def init_maqj_data
  1226.     @quests = Game_Quests.new # Initialize @quests
  1227.   end
  1228. end

  1229. #==============================================================================
  1230. # ** Game_Interpreter
  1231. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1232. #  Summary of Changes:
  1233. #    new methods - change_quest_access; change_quest_background;
  1234. #      change_quest_windows; setup_quest; delete_quest; reset_quest; quest;
  1235. #      reveal_quest; conceal_quest; manually_complete_quest;
  1236. #      manually_fail_quest; reveal_objective; conceal_objective;
  1237. #      complete_objective; uncomplete_objective; fail_objective;
  1238. #      unfail_objective; quest_revealed?; quest_complete?; quest_active?;
  1239. #      quest_failed?; objective_complete?; objective_active?;
  1240. #      objective_failed?; distribute_quest_rewards; distribute_quest_reward;
  1241. #      call_quest_journal
  1242. #==============================================================================

  1243. class Game_Interpreter
  1244.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1245.   # * Change Quest Access
  1246.   #    sym : symbol representing what aspect of access is being changed
  1247.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1248.   def change_quest_access(sym)
  1249.     case sym
  1250.     when :enable then $game_system.quest_access_disabled = false
  1251.     when :disable then $game_system.quest_access_disabled = true
  1252.     when :enable_menu then $game_system.quest_menu_access = true
  1253.     when :disable_menu then $game_system.quest_menu_access = false
  1254.     when :enable_map then $game_system.quest_map_access = true
  1255.     when :disable_map then $game_system.quest_map_access = false
  1256.     end
  1257.   end
  1258.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1259.   # * Change Quest Background
  1260.   #    picture : picture to show in the scene's background
  1261.   #    opacity : opacity of the picture shown in the scene's background
  1262.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1263.   def change_quest_background(picture, opacity = $game_system.quest_bg_opacity,
  1264.       blend_type = $game_system.quest_bg_blend_type)
  1265.     $game_system.quest_bg_picture = picture
  1266.     $game_system.quest_bg_opacity = opacity
  1267.     $game_system.quest_bg_blend_type = blend_type
  1268.   end
  1269.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1270.   # * Change Quest Windows
  1271.   #    skin    : windowskin name to use in the scene
  1272.   #    tone    : tone for the windowskin
  1273.   #    opacity : opacity of windows in the scene
  1274.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1275.   def change_quest_windows(skin, tone = $game_system.quest_window_tone,
  1276.       opacity = $game_system.quest_window_opacity)
  1277.     $game_system.quest_windowskin = skin
  1278.     $game_system.quest_window_tone = tone
  1279.     $game_system.quest_window_opacity = opacity
  1280.   end
  1281.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1282.   # * Setup/Delete/Reset Quest
  1283.   #    quest_id : ID of the quest to be setup or deleted or reset
  1284.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1285.   [:setup_quest, :delete_quest, :reset_quest].each { |method|
  1286.     define_method(:"quest_#{method}") do |quest_id|
  1287.       $game_party.quests.send(method, quest_id)
  1288.     end
  1289.   }
  1290.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1291.   # * Retrieve Quest
  1292.   #    quest_id : ID of the quest to retrieve
  1293.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1294.   def quest(quest_id);         $game_party.quests[quest_id];      end
  1295.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1296.   # * Reveal/Conceal Quest
  1297.   #    quest_id : ID of the quest to be revealed or concealed
  1298.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1299.   def reveal_quest(quest_id);  quest(quest_id).concealed = false; end
  1300.   def conceal_quest(quest_id); quest(quest_id).concealed = true;  end
  1301.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1302.   # * Manually Complete/Fail Quest
  1303.   #    quest_id : ID of the quest to be revealed or concealed
  1304.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1305.   def manually_complete_quest(quest_id)
  1306.     quest(quest_id).prime_objectives.clear
  1307.     quest(quest_id).manual_status = :complete
  1308.   end
  1309.   def manually_fail_quest(quest_id)
  1310.     quest(quest_id).prime_objectives.clear
  1311.     quest(quest_id).manual_status = :failed
  1312.   end
  1313.   def manually_activate_quest(quest_id)
  1314.     quest(quest_id).manual_status = :active
  1315.   end
  1316.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1317.   # * Reveal/Complete/Fail/Conceal/Uncomplete/Unfail Objective
  1318.   #    quest_id : ID of the quest whose objectives will be modified
  1319.   #    *obj     : IDs of objectives to reveal or complete or fail (or opposite)
  1320.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1321.   [:reveal_objective, :complete_objective, :fail_objective, :conceal_objective,
  1322.   :uncomplete_objective, :unfail_objective].each { |method|
  1323.     define_method(method) do |quest_id, *obj|
  1324.       quest(quest_id).send(method, *obj)
  1325.     end
  1326.   }
  1327.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1328.   # * Quest Revealed?
  1329.   #    quest_id : ID of the quest you are checking is revealed
  1330.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1331.   def quest_revealed?(quest_id)
  1332.     $game_party.quests.revealed?(quest_id)
  1333.   end
  1334.   [:complete, :failed, :active].each { |method|
  1335.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1336.     # * Quest Complete/Failed/Active?
  1337.     #    quest_id : ID of the quest whose completion status is being checked
  1338.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1339.     define_method(:"quest_#{method}?") do |quest_id|
  1340.       quest_revealed?(quest_id) && quest(quest_id).status?(method)
  1341.     end
  1342.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1343.     # * Objective Complete/Failed/Active?
  1344.     #    quest_id : ID of the quest whose objectives are being checked
  1345.     #    *obj     : IDs of objectives to check completion status
  1346.     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1347.     define_method(:"objective_#{method}?") do |quest_id, *obj|
  1348.       quest_revealed?(quest_id) && quest(quest_id).objective_status?(method, *obj)
  1349.     end
  1350.   }
  1351.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1352.   # * Objective Revealed?
  1353.   #    quest_id : ID of the quest you are checking is revealed
  1354.   #    *obj     : IDs of objectives to check completion status
  1355.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1356.   def objective_revealed?(quest_id, *obj)
  1357.     quest_revealed?(quest_id) && quest(quest_id).objective_status?(:revealed, *obj)
  1358.   end
  1359.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1360.   # * Quest Rewarded?
  1361.   #    quest_id : ID of the quest you are checking is revealed
  1362.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1363.   def quest_rewarded?(quest_id)
  1364.     quest_revealed?(quest_id) && quest(quest_id).status?(:reward)
  1365.   end
  1366.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1367.   # * Change Reward Status
  1368.   #    quest_id : ID of the quest you are checking is revealed
  1369.   #    value    : true or false
  1370.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1371.   def change_reward_status(quest_id, value = true)
  1372.     quest(quest_id).reward_given = value
  1373.   end
  1374.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1375.   # * Distribute Rewards
  1376.   #    quest_id : ID of the quest whose rewards are to be distributed
  1377.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1378.   def distribute_quest_rewards(quest_id)
  1379.     if quest_revealed?(quest_id) && !quest_rewarded?(quest_id)
  1380.       params = @params.dup
  1381.       change_reward_status(quest_id, true)
  1382.       quest(quest_id).rewards.each { |reward| distribute_quest_reward(reward) }
  1383.       @params = params
  1384.       true
  1385.     else
  1386.       false
  1387.     end
  1388.   end
  1389.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1390.   # * Distribute Reward
  1391.   #    reward : an array identifying the reward
  1392.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1393.   def distribute_quest_reward(reward)
  1394.     @params = [reward[1], 0, 0, (reward[2] ? reward[2] : 1)]
  1395.     case reward[0]
  1396.     when :item, 0 then   command_126 # Item
  1397.     when :weapon, 1 then command_127 # Weapon
  1398.     when :armor, 2 then  command_128 # Armor
  1399.     when :gold, 3   # Gold
  1400.       @params = [0, 0, reward[1] ? reward[1] : 0]
  1401.       command_125
  1402.     when :exp, 4    # Exp
  1403.       @params = [0, 0, 0, 0, reward[1] ? reward[1] : 0, true]
  1404.       command_315
  1405.     end
  1406.   end
  1407.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1408.   # * Call Quest Journal
  1409.   #    quest_id : ID of the quest to open the journal to
  1410.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1411.   def call_quest_journal(quest_id = nil)
  1412.     return if $game_party.in_battle
  1413.     $game_system.last_quest_id = quest_id if quest_id
  1414.     SceneManager.call(Scene_Quest)
  1415.     Fiber.yield
  1416.   end
  1417. end

  1418. unless $imported[:"MA_ParagraphFormat_1.0"]
  1419. #==============================================================================
  1420. # ** MA_Window_ParagraphFormat
  1421. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1422. #  This module inserts into Window_Base and provides a method to format the
  1423. # strings so as to go to the next line if it exceeds a set limit. This is
  1424. # designed to work with draw_text_ex, and a string formatted by this method
  1425. # should go through that, not draw_text.
  1426. #==============================================================================

  1427. module MA_Window_ParagraphFormat
  1428.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1429.   # * Calc Line Width
  1430.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1431.   def mapf_calc_line_width(line, tw = 0, contents_dummy = false)
  1432.     return tw if line.nil?
  1433.     line = line.clone
  1434.     unless contents_dummy
  1435.       real_contents = contents # Preserve Real Contents
  1436.       # Create a dummy contents
  1437.       self.contents = Bitmap.new(contents_width, 24)
  1438.       reset_font_settings
  1439.     end
  1440.     pos = {x: 0, y: 0, new_x: 0, height: calc_line_height(line)}
  1441.     while line[/^(.*?)\e(.*)/]
  1442.       tw += text_size($1).width
  1443.       line = $2
  1444.       # Remove all ancillaries to the code, like parameters
  1445.       code = obtain_escape_code(line)
  1446.       # If direct setting of x, reset tw.
  1447.       tw = 0 if ($imported[:ATS_SpecialMessageCodes] && code.upcase == 'X') ||
  1448.         ($imported["YEA-MessageSystem"] && code.upcase == 'PX')
  1449.       #  If I need to do something special on the basis that it is testing,
  1450.       # alias process_escape_character and differentiate using @atsf_testing
  1451.       process_escape_character(code, line, pos)
  1452.     end
  1453.     #  Add width of remaining text, as well as the value of pos[:x] under the
  1454.     # assumption that any additions to it are because the special code is
  1455.     # replaced by something which requires space (like icons)
  1456.     tw += text_size(line).width + pos[:x]
  1457.     unless contents_dummy
  1458.       contents.dispose # Dispose dummy contents
  1459.       self.contents = real_contents # Restore real contents
  1460.     end
  1461.     return tw
  1462.   end
  1463.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1464.   # * Format Paragraph
  1465.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1466.   def mapf_format_paragraph(text, max_width = contents_width)
  1467.     text = text.clone
  1468.     #  Create a Dummy Contents - I wanted to boost compatibility by using the
  1469.     # default process method for escape codes. It may have the opposite effect,
  1470.     # for some :(
  1471.     real_contents = contents # Preserve Real Contents
  1472.     self.contents = Bitmap.new(contents_width, 24)
  1473.     reset_font_settings
  1474.     paragraph = ""
  1475.     while !text.empty?
  1476.       text.lstrip!
  1477.       oline, nline, tw = mapf_format_by_line(text.clone, max_width)
  1478.       # Replace old line with the new one
  1479.       text.sub!(/#{Regexp.escape(oline)}/m, nline)
  1480.       paragraph += text.slice!(/.*?(\n|$)/)
  1481.     end
  1482.     contents.dispose # Dispose dummy contents
  1483.     self.contents = real_contents # Restore real contents
  1484.     return paragraph
  1485.   end
  1486.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1487.   # * Format By Line
  1488.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1489.   def mapf_format_by_line(text, max_width = contents_width)
  1490.     oline, nline, tw = "", "", 0
  1491.     loop do
  1492.       #  Format each word until reach the width limit
  1493.       oline, nline, tw, done = mapf_format_by_word(text, nline, tw, max_width)
  1494.       return oline, nline, tw if done
  1495.     end
  1496.   end
  1497.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1498.   # * Format By Word
  1499.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1500.   def mapf_format_by_word(text, line, tw, max_width)
  1501.     return line, line, tw, true if text.nil? || text.empty?
  1502.     # Extract next word
  1503.     if text.sub!(/(\s*)([^\s\n\f]*)([\n\f]?)/, "") != nil
  1504.       prespace, word, line_end = $1, $2, $3
  1505.       ntw = mapf_calc_line_width(word, tw, true)
  1506.       pw = contents.text_size(prespace).width
  1507.       if (pw + ntw >= max_width)
  1508.         # Insert
  1509.         if line.empty?
  1510.           # If one word takes entire line
  1511.           return prespace + word, word + "\n", ntw, true
  1512.         else
  1513.           return line + prespace + word, line + "\n" + word, tw, true
  1514.         end
  1515.       else
  1516.         line += prespace + word
  1517.         tw = pw + ntw
  1518.         # If the line is force ended, then end
  1519.         return line, line, tw, true if !line_end.empty?
  1520.       end
  1521.     else
  1522.       return line, line, tw, true
  1523.     end
  1524.     return line, line, tw, false
  1525.   end
  1526. end

  1527. class Window_Base
  1528.   include MA_Window_ParagraphFormat
  1529. end

  1530. $imported[:"MA_ParagraphFormat_1.0"] = true
  1531. end

  1532. #==============================================================================
  1533. # *** MAQJ Window_QuestBase
  1534. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1535. #  This module mixes in with all quest windows
  1536. #==============================================================================

  1537. module MAQJ_Window_QuestBase
  1538.   attr_reader :maqj_objective_color
  1539.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1540.   # * Object Initialization
  1541.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1542.   def initialize(*args, &block)
  1543.     super(*args, &block)
  1544.     reset_font_settings
  1545.     set_data_font(:normal)
  1546.     @maqj_default_font = contents.font.dup
  1547.     # Change the windowskin, tone if they are set to be changed
  1548.     self.windowskin = Cache.system($game_system.quest_windowskin) if $game_system.quest_windowskin
  1549.     self.opacity = $game_system.quest_window_opacity if $game_system.quest_window_opacity
  1550.   end
  1551.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1552.   # * Reset Font Settings
  1553.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1554.   def reset_font_settings(*args, &block)
  1555.     super(*args, &block)
  1556.     set_data_font(@maqj_font_data_type) if @maqj_font_data_type
  1557.   end
  1558.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1559.   # * Set Data Font
  1560.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1561.   def set_data_font(data_type)
  1562.     @maqj_default_font = contents.font.dup unless @maqj_default_font
  1563.     contents.font.name = QuestData::FONTNAMES[data_type] ?
  1564.       QuestData::FONTNAMES[data_type] : @maqj_default_font.name
  1565.     contents.font.size = QuestData::FONTSIZES[data_type] ?
  1566.       QuestData::FONTSIZES[data_type] : @maqj_default_font.size
  1567.     contents.font.bold = QuestData::FONTBOLDS.keys.include?(data_type) ?
  1568.       QuestData::FONTBOLDS[data_type] : @maqj_default_font.bold
  1569.     contents.font.italic = QuestData::FONTITALICS.keys.include?(data_type) ?
  1570.       QuestData::FONTITALICS[data_type] : @maqj_default_font.italic
  1571.     case data_type
  1572.     when :objectives then change_color(@maqj_objective_color) if @maqj_objective_color
  1573.     when :name then change_color(quest_name_colour(@quest)) if @quest
  1574.     else
  1575.       change_color(text_color(QuestData::COLOURS[data_type])) if QuestData::COLOURS.keys.include?(data_type)
  1576.     end
  1577.   end
  1578.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1579.   # * Draw Horizontal Line
  1580.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1581.   def draw_horizontal_line(y, h = 2)
  1582.     contents.fill_rect(0, y, contents_width, h, text_color(QuestData::COLOURS[:line]))
  1583.     contents.fill_rect(0, y + h, contents_width, [h / 2, 1].max, text_color(QuestData::COLOURS[:line_shadow]))
  1584.   end
  1585.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1586.   # * MA Text Color
  1587.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1588.   def text_color(param)
  1589.     begin
  1590.       colour = case param
  1591.       when Integer then super(param) rescue normal_color
  1592.       when Symbol then send(param) rescue normal_color
  1593.       when Array then Color.new(*param) rescue normal_color
  1594.       else
  1595.         normal_color
  1596.       end
  1597.     end
  1598.     colour.is_a?(Color) ? colour : normal_color
  1599.   end
  1600.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1601.   # * Quest Name Colour
  1602.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1603.   def quest_name_colour(quest = @quest)
  1604.     return if !quest
  1605.     quest = $game_party.quests[quest] if quest.is_a?(Integer)
  1606.     s = [:failed, :complete, :active].find { |status| quest.status?(status) }
  1607.     text_color(QuestData::COLOURS[s])
  1608.   end
  1609.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1610.   # * Quest Objective Colour
  1611.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1612.   def quest_objective_colour(quest, obj_id)
  1613.     return if !quest
  1614.     quest = $game_party.quests[quest] if quest.is_a?(Integer)
  1615.     s = [:failed, :complete, :active].find { |status| quest.objective_status?(status, obj_id) }
  1616.     text_color(QuestData::COLOURS[s])
  1617.   end
  1618.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1619.   # * Update Tone
  1620.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1621.   def update_tone
  1622.     $game_system.quest_window_tone ?
  1623.       self.tone.set(*$game_system.quest_window_tone) : super
  1624.   end
  1625. end

  1626. unless $imported[:"MA_IconHorzCommand_1.0"]
  1627. #==============================================================================
  1628. # ** Window_MA_IconHorzCommand
  1629. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1630. #  This window is a base window to show a horizontal command window populated
  1631. # with icons.
  1632. #==============================================================================

  1633. class Window_MA_IconHorzCommand < Window_HorzCommand
  1634.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1635.   # * Public Instance Variable
  1636.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1637.   attr_reader   :observing_procs
  1638.   attr_accessor :cursor_hide
  1639.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1640.   # * Object Initialization
  1641.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1642.   def initialize(*args, &block)
  1643.     @observing_procs = {}
  1644.     super(*args, &block)
  1645.   end
  1646.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1647.   # * Column Max
  1648.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1649.   def col_max; [(width - standard_padding) / (24 + spacing), item_max].min; end
  1650.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1651.   # * Item
  1652.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1653.   def item
  1654.     @list[index] ? @list[index][:symbol] : nil
  1655.   end
  1656.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1657.   # * Enabled? / Current Item Enabled?
  1658.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1659.   def enable?(index); self.index == index; end
  1660.   def current_item_enabled?; !current_data.nil?; end
  1661.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1662.   # * Draw Item
  1663.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1664.   def draw_item(index)
  1665.     rect = item_rect(index)
  1666.     contents.clear_rect(rect)
  1667.     draw_icon(@list[index][:ext], rect.x + ((rect.width - 24) / 2), rect.y, enable?(index))
  1668.   end
  1669.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1670.   # * Set Index
  1671.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1672.   def index=(index)
  1673.     old_index = self.index
  1674.     super(index)
  1675.     draw_item(old_index)
  1676.     draw_item(self.index)
  1677.   end
  1678.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1679.   # * Frame Update
  1680.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1681.   def update
  1682.     super
  1683.     @observing_procs.values.each { |block| block.call(item) }
  1684.   end
  1685.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1686.   # * Add/Remove Observing Window
  1687.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1688.   def add_observing_proc(id, &block)
  1689.     @observing_procs[id] = block
  1690.     update
  1691.   end
  1692.   def remove_observing_proc(id)     ; @observing_procs.delete(id) ; end
  1693.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1694.   # * Update Cursor
  1695.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1696.   def update_cursor
  1697.     super
  1698.     cursor_rect.empty if @cursor_hide
  1699.   end
  1700. end
  1701. $imported[:"MA_IconHorzCommand_1.0"] = true
  1702. end

  1703. #==============================================================================
  1704. # ** Window_QuestCategory
  1705. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1706. #  This window allows the player to switch between quest categories.
  1707. #==============================================================================

  1708. class Window_QuestCategory < Window_MA_IconHorzCommand
  1709.   include MAQJ_Window_QuestBase
  1710.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1711.   # * Object Initialization
  1712.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1713.   def initialize(x, y, categories = $game_system.quest_categories)
  1714.     @cursor_hide = QuestData::HIDE_CATEGORY_CURSOR
  1715.     @categories = categories
  1716.     super(x, y)
  1717.   end
  1718.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1719.   # * Window Width
  1720.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1721.   def window_width; QuestData::LIST_WINDOW_WIDTH; end
  1722.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1723.   # * Category=
  1724.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1725.   def category=(category)
  1726.     self.index = @categories.index(category) if @categories.include?(category)
  1727.   end
  1728.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1729.   # * Make Command List
  1730.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1731.   def make_command_list
  1732.     @categories.each { |cat|
  1733.       add_command("", cat, false, QuestData::ICONS[cat]) }
  1734.   end
  1735. end

  1736. #==============================================================================
  1737. # ** Window QuestLabel
  1738. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1739. #  This window simply shows a label for the Quests scene
  1740. #==============================================================================

  1741. class Window_QuestLabel < Window_Base
  1742.   include MAQJ_Window_QuestBase
  1743.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1744.   # * Object Initialization
  1745.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1746.   def initialize(x, y, label = "")
  1747.     super(x, y, window_width, window_height)
  1748.     refresh(label)
  1749.   end
  1750.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1751.   # * Reset Font Settings
  1752.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1753.   def reset_font_settings; set_data_font(:scene_label); end
  1754.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1755.   # * Window Attributes
  1756.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1757.   def window_width
  1758.     w = ($game_system.quest_categories.size > 1 || QuestData::SHOW_CATEGORY_LABEL) ?
  1759.       Graphics.width - QuestData::LIST_WINDOW_WIDTH : QuestData::LIST_WINDOW_WIDTH
  1760.   end
  1761.   def window_height; line_height + (standard_padding*2); end
  1762.   def line_height(*args)
  1763.     line_h = super(*args)
  1764.     QuestData::FONTSIZES[:scene_label] ?
  1765.       [QuestData::FONTSIZES[:scene_label], line_h].max : line_h
  1766.   end
  1767.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1768.   # * Refresh
  1769.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1770.   def refresh(label = @label)
  1771.     @label = label.is_a?(String) ? convert_escape_characters(label) : ""
  1772.     contents.clear
  1773.     reset_font_settings
  1774.     tw = mapf_calc_line_width(@label)
  1775.     draw_text_ex((contents_width - tw) / 2, 0, @label)
  1776.   end
  1777. end

  1778. #==============================================================================
  1779. # ** Window QuestLabel
  1780. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1781. #  This window simply shows a label for category currently selected
  1782. #==============================================================================

  1783. class Window_QuestCategoryLabel < Window_QuestLabel
  1784.   include MAQJ_Window_QuestBase
  1785.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1786.   # * Reset Font Settings
  1787.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1788.   def reset_font_settings; set_data_font(:category_label); end
  1789.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1790.   # * Window Attributes
  1791.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1792.   def window_width; QuestData::LIST_WINDOW_WIDTH; end
  1793.   def line_height(*args)
  1794.     line_h = super(*args)
  1795.     QuestData::FONTSIZES[:category_label] ?
  1796.       [QuestData::FONTSIZES[:category_label], line_h].max : line_h
  1797.   end
  1798.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1799.   # * Set Category
  1800.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1801.   def category=(category)
  1802.     return if @category == category
  1803.     @category = category
  1804.     refresh(QuestData::CATEGORY_VOCAB[category])
  1805.   end
  1806. end

  1807. #==============================================================================
  1808. # ** Window_QuestCategoryDummy
  1809. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1810. #  This window shows up behind the category and category label window
  1811. #==============================================================================

  1812. class Window_QuestCategoryDummy < Window_Base
  1813.   include MAQJ_Window_QuestBase
  1814. end

  1815. #==============================================================================
  1816. # ** Window_QuestList
  1817. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1818. #  This window shows all quests in a selected category.
  1819. #==============================================================================

  1820. class Window_QuestList < Window_Selectable
  1821.   include MAQJ_Window_QuestBase
  1822.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1823.   # * Object Initialization
  1824.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1825.   def initialize(x, y, width, height)
  1826.     super
  1827.     @data = []
  1828.     self.index = 0
  1829.     activate
  1830.   end
  1831.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1832.   # * Set Category
  1833.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1834.   def category=(category)
  1835.     return if @category == category
  1836.     @category = category
  1837.     refresh
  1838.     self.index = 0
  1839.     update_help if @help_window
  1840.   end
  1841.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1842.   # * Get Quest
  1843.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1844.   def item; @data && index >= 0 ? @data[index] : nil; end
  1845.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1846.   # * Column/Item Max
  1847.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1848.   def col_max; 1; end
  1849.   def item_max; @data ? @data.size : 1; end
  1850.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1851.   # * Whether it should be drawn enabled
  1852.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1853.   def enable?(item); true; end
  1854.   def current_item_enabled?
  1855.     (@help_window && @help_window.maqj_visible_height < @help_window.contents_height)
  1856.   end
  1857.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1858.   # * Make Item List
  1859.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1860.   def make_item_list
  1861.     @data = @category ? $game_party.quests.list(@category) : []
  1862.   end
  1863.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1864.   # * Draw Item
  1865.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1866.   def draw_item(index)
  1867.     quest = @data[index]
  1868.     if quest
  1869.       rect = item_rect_for_text(index)
  1870.       if QuestData::SHOW_QUEST_ICONS
  1871.         draw_icon(quest.icon_index, rect.x, rect.y, enable?(quest))
  1872.         rect.x += 24
  1873.         rect.width -= 24
  1874.       end
  1875.       change_color(quest_name_colour(quest), enable?(quest))
  1876.       draw_text(rect, quest.name)
  1877.     end
  1878.   end
  1879.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1880.   # * Refresh
  1881.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1882.   def refresh
  1883.     make_item_list
  1884.     create_contents
  1885.     set_data_font(:list)
  1886.     draw_all_items
  1887.   end
  1888.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1889.   # * Update Help
  1890.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1891.   def update_help
  1892.     @help_window.quest = item
  1893.   end
  1894. end

  1895. #==============================================================================
  1896. # ** Window_QuestData
  1897. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1898. #  This window shows all quest data
  1899. #==============================================================================

  1900. class Window_QuestData < Window_Selectable
  1901.   include MAQJ_Window_QuestBase
  1902.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1903.   # * Object Initialization
  1904.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1905.   def initialize(x, y, w, h, layout = QuestData::DATA_LAYOUT)
  1906.     @dest_scroll_oy = 0
  1907.     super(x, y, w, h)
  1908.     @dest_scroll_oy = self.oy
  1909.     self.layout = layout
  1910.   end
  1911.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1912.   # * Contents Height
  1913.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1914.   alias maqj_visible_height contents_height
  1915.   def contents_height
  1916.     @q_contents_height ? [@q_contents_height, maqj_visible_height].max : maqj_visible_height
  1917.   end
  1918.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1919.   # * Calculate Contents Height
  1920.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1921.   def calc_contents_height
  1922.     @q_contents_height = 0
  1923.     @layout.each { |dt| @q_contents_height += data_height(dt) } if @quest
  1924.   end
  1925.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1926.   # * Draw Data?
  1927.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1928.   def draw_data?(data_type)
  1929.     case data_type
  1930.     when :line then true
  1931.     when :level then @quest.level > 0
  1932.     when :objectives then [email protected]_objectives.empty?
  1933.     when Array then (data_type - [:line]).any? { |dt| draw_data?(dt) }
  1934.     else [email protected](data_type).empty? # :description, :name, etc...
  1935.     end
  1936.   end
  1937.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1938.   # * Get Data Height
  1939.   #    This method calculates the height required for a specified element of
  1940.   #   the current quest. This is to calculate the needed space in contents,
  1941.   #   as well as advance the @draw_y variable.
  1942.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1943.   def data_height(data_type)
  1944.     return 0 unless draw_data?(data_type)
  1945.     return line_height if QuestData::BASIC_DATA_TYPES.include?(data_type)
  1946.     @maqj_font_data_type = data_type
  1947.     reset_font_settings
  1948.     return case data_type
  1949.     when :line, :level, :name then line_height
  1950.     when :banner
  1951.       bmp = Cache.picture(@quest.banner)
  1952.       hght = bmp.rect.height
  1953.       bmp.dispose
  1954.       hght
  1955.     when :description
  1956.       buff = description_x*2
  1957.       paragraph = mapf_format_paragraph(@quest.description, contents_width - buff)
  1958.       line_num = paragraph.scan(/\n/).size + 1
  1959.       line_num += (QuestData::DESCRIPTION_IN_BOX ? 2 :
  1960.         !QuestData::VOCAB[:description].empty? ? 1 : 0)
  1961.       line_num*line_height
  1962.     when :objectives
  1963.       objectives = @quest.revealed_objectives.collect { |obj_id|
  1964.         @quest.objectives[obj_id] }
  1965.       line_num = QuestData::VOCAB[:objectives].empty? ? 0 : 1
  1966.       buff = (objective_x*2) + text_size(QuestData::VOCAB[:objective_bullet]).width
  1967.       objectives.each { |obj|
  1968.         paragraph = mapf_format_paragraph(obj, contents_width - buff)
  1969.         line_num += paragraph.scan(/\n/).size + 1 }
  1970.       line_num*line_height
  1971.     when :rewards
  1972.       line_num = QuestData::VOCAB[:rewards].empty? ? 0 : 1
  1973.       (line_num + @quest.rewards.size)*line_height
  1974.     when Array then data_height(data_type.max_by { |dt| data_height(dt) })
  1975.     else 0
  1976.     end
  1977.   end
  1978.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1979.   # * Set Quest
  1980.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1981.   def quest=(value)
  1982.     return if @quest == value
  1983.     @quest = value
  1984.     @layout = (@quest && @quest.layout) ? @quest.layout : @default_layout
  1985.     refresh
  1986.   end
  1987.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1988.   # * Set Layout
  1989.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1990.   def layout=(value)
  1991.     return if @default_layout == value && @layout == value
  1992.     @default_layout = value
  1993.     @layout = value
  1994.     refresh
  1995.   end
  1996.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1997.   # * Refresh
  1998.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1999.   def refresh
  2000.     contents.clear
  2001.     calc_contents_height
  2002.     create_contents
  2003.     return unless @quest && @layout
  2004.     self.oy = 0
  2005.     @dest_scroll_oy = 0
  2006.     #  The basic idea here is that each draw_ method will rely on and advance
  2007.     # the @draw_y variable. Where they are an array, the elements will be
  2008.     # drawn at the same @draw_y.
  2009.     @draw_y = 0
  2010.     @layout.each {|dt|
  2011.       next unless draw_data?(dt)
  2012.       dt.is_a?(Array) ? draw_data_array(dt) : draw_data(dt)
  2013.     }
  2014.   end
  2015.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2016.   # * Draw Data
  2017.   #    data_type : the data block to draw next
  2018.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2019.   def draw_data(data_type)
  2020.     @maqj_font_data_type = data_type
  2021.     reset_font_settings
  2022.     send(:"draw_#{data_type}") if self.class.method_defined?(:"draw_#{data_type}")
  2023.     @draw_y += data_height(data_type)
  2024.   end
  2025.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2026.   # * Draw Data Array
  2027.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2028.   def draw_data_array(layout_array)
  2029.     y, max_y = @draw_y, @draw_y
  2030.     # Draw each data aspect at the same starting @draw_y
  2031.     layout_array.each { |dt|
  2032.       @draw_y = y
  2033.       draw_data(dt)
  2034.       max_y = @draw_y if @draw_y > max_y
  2035.     }
  2036.     @draw_y = max_y
  2037.   end
  2038.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2039.   # * Draw Line
  2040.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2041.   def draw_line; draw_horizontal_line(@draw_y + (line_height / 2) - 1, 2); end
  2042.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2043.   # * Draw Name
  2044.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2045.   def draw_name
  2046.     set_data_font(:name)
  2047.     clear_and_draw_text(0, @draw_y, contents_width, line_height, @quest.name, 1)
  2048.   end
  2049.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2050.   # * Draw Level
  2051.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2052.   def draw_level
  2053.     case QuestData::LEVEL_ICON
  2054.     when Array then QuestData::LEVEL_ICON.empty? ? draw_level_text : draw_level_array
  2055.     when 0 then draw_level_text
  2056.     else
  2057.       draw_level_stacked
  2058.     end
  2059.   end
  2060.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2061.   # * Draw Stacked Level
  2062.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2063.   def draw_level_stacked(icon_index = QuestData::LEVEL_ICON)
  2064.     align = QuestData::HEADING_ALIGN[:level]
  2065.     es = QuestData::LEVEL_ICONS_SPACE*(@quest.level - 1)
  2066.     x = align == 2 ? contents_width - 24 : align == 1 ?
  2067.       (contents_width - 24 - (es)) / 2 : es
  2068.     @quest.level.times do
  2069.       draw_icon(icon_index, x, @draw_y)
  2070.       x -= QuestData::LEVEL_ICONS_SPACE
  2071.     end
  2072.   end
  2073.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2074.   # * Draw Array Level
  2075.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2076.   def draw_level_array(icon_index = QuestData::LEVEL_ICON)
  2077.     return if icon_index.empty?
  2078.     icon_index = icon_index[@quest.level - 1] ? icon_index[@quest.level - 1] : icon_index[-1]
  2079.     align = QuestData::HEADING_ALIGN[:level]
  2080.     x = align == 2 ? contents_width - 24 : align == 1 ? (contents_width-24)/2 : 0
  2081.     draw_icon(icon_index, x, @draw_y)
  2082.   end
  2083.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2084.   # * Draw Text Level
  2085.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2086.   def draw_level_text
  2087.     reset_font_settings
  2088.     level = QuestData::LEVEL_SIGNALS && QuestData::LEVEL_SIGNALS[@quest.level - 1] ?
  2089.       QuestData::LEVEL_SIGNALS[@quest.level - 1] : @quest.level.to_s
  2090.     align = QuestData::HEADING_ALIGN[:level]
  2091.     tw = text_size(QuestData::VOCAB[:level]).width + 4
  2092.     tw2 = text_size(level).width + 2
  2093.     space = contents_width - tw - tw2
  2094.     x = align == 2 ? space : align == 1 ? space / 2 : 0
  2095.     clear_and_draw_text(x, @draw_y, tw, line_height, QuestData::VOCAB[:level])
  2096.     set_data_font(:level_signal)
  2097.     clear_and_draw_text(x + tw, @draw_y, tw2, line_height, level, 2)
  2098.   end
  2099.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2100.   # * Draw Banner
  2101.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2102.   def draw_banner
  2103.     bmp = Cache.picture(@quest.banner) # Get Picture
  2104.     # Shift the hue if requested
  2105.     bmp.hue_change(@quest.banner_hue) unless @quest.banner_hue == 0
  2106.     x = (contents_width - bmp.rect.width) / 2
  2107.     if x < 0 # Stretch horizontally if the banner is too wide
  2108.       dest_rect = bmp.rect.dup
  2109.       dest_rect.width = contents_width
  2110.       contents.stretch_blt(dest_rect, bmp, bmp.rect)
  2111.     else
  2112.       contents.blt(x, @draw_y, bmp, bmp.rect)
  2113.     end
  2114.     bmp.dispose
  2115.   end
  2116.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2117.   # * Draw Description
  2118.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2119.   def draw_description
  2120.     buff = description_x*2
  2121.     paragraph = mapf_format_paragraph(@quest.description, contents_width - buff)
  2122.     y = @draw_y
  2123.     # Draw Rect
  2124.     draw_box(paragraph.scan(/\n/).size + 1) if QuestData::DESCRIPTION_IN_BOX
  2125.     # Draw Description Label
  2126.     draw_heading(:description, y) unless QuestData::VOCAB[:description].empty?
  2127.     # Draw Description
  2128.     y += line_height if !QuestData::VOCAB[:description].empty? || QuestData::DESCRIPTION_IN_BOX
  2129.     draw_text_ex(description_x, y, paragraph)
  2130.   end
  2131.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2132.   # * Draw Objectives
  2133.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2134.   def draw_objectives
  2135.     y = @draw_y
  2136.     unless QuestData::VOCAB[:objectives].empty?
  2137.       draw_heading(:objectives, y)
  2138.       y += line_height
  2139.     end
  2140.     @quest.revealed_objectives.each { |obj_id| y = draw_objective(obj_id, y) }
  2141.   end
  2142.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2143.   # * Draw Objective
  2144.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2145.   def draw_objective(obj_id, y)
  2146.     bullet = QuestData::VOCAB[:objective_bullet]
  2147.     bullet_tw = text_size(bullet).width + 2
  2148.     buff = (objective_x*2) + bullet_tw
  2149.     paragraph = mapf_format_paragraph(@quest.objectives[obj_id], contents_width - buff)
  2150.     line_num = 1 + paragraph.scan(/\n/).size
  2151.     # Since draw_text_ex resets the font, set colour here
  2152.     @maqj_objective_color = quest_objective_colour(@quest, obj_id)
  2153.     change_color(text_color(QuestData::COLOURS[:objective_bullet]))
  2154.     draw_text(objective_x, y, bullet_tw, line_height, sprintf(bullet, obj_id + 1))
  2155.     draw_text_ex(objective_x + bullet_tw, y, paragraph)
  2156.     @maqj_objective_color = false
  2157.     y += (line_num*line_height)
  2158.   end
  2159.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2160.   # * Draw Rewards
  2161.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2162.   def draw_rewards
  2163.     y = @draw_y
  2164.     unless QuestData::VOCAB[:rewards].empty?
  2165.       draw_heading(:rewards, y)
  2166.       y += line_height
  2167.     end
  2168.     for i in [email protected] do draw_reward(i, y + i*line_height) end
  2169.   end
  2170.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2171.   # * Draw Reward
  2172.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2173.   def draw_reward(r_id, y)
  2174.     reward = @quest.rewards[r_id]
  2175.     case reward[0]
  2176.     when :item, 0   # Item
  2177.       draw_item_reward(y, $data_items[reward[1]], reward[2] ? reward[2] : 1)
  2178.     when :weapon, 1 # Weapon
  2179.       draw_item_reward(y, $data_weapons[reward[1]], reward[2] ? reward[2] : 1)
  2180.     when :armor, 2  # Armor
  2181.       draw_item_reward(y, $data_armors[reward[1]], reward[2] ? reward[2] : 1)
  2182.     when :gold, 3   # Gold
  2183.       draw_basic_data(y, QuestData::ICONS[:reward_gold],
  2184.         QuestData::VOCAB[:reward_gold], (reward[1] ? reward[1] : 0).to_s)
  2185.     when :exp, 4    # Exp
  2186.       draw_basic_data(y, QuestData::ICONS[:reward_exp],
  2187.         QuestData::VOCAB[:reward_exp], (reward[1] ? reward[1] : 0).to_s)
  2188.     when :string, 5 # String
  2189.       draw_basic_data(y, reward[1] ? reward[1] : 0, reward[3] ? reward[3] : "",
  2190.         reward[2] ? reward[2] : "")
  2191.     end
  2192.   end
  2193.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2194.   # * Draw Item Reward
  2195.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2196.   def draw_item_reward(y, item, amount = 1)
  2197.     w = contents_width
  2198.     w = QuestData::BASIC_DATA_WIDTH if QuestData::BASIC_DATA_WIDTH.between?(1, w)
  2199.     x = (contents_width - w) / 2
  2200.     draw_item_name(item, x, y, true, w - 40)
  2201.     if amount > 1
  2202.       change_color(text_color(QuestData::COLOURS[:reward_amount]))
  2203.       draw_text(x + w - 40, y, 40, line_height, sprintf(QuestData::VOCAB[:reward_amount], amount), 2)
  2204.     end
  2205.   end
  2206.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2207.   # * Draw Basic Data Methods
  2208.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2209.   QuestData::BASIC_DATA_TYPES.each { |data_type|
  2210.     define_method(:"draw_#{data_type}") {
  2211.       draw_basic_data(@draw_y, QuestData::ICONS[data_type],
  2212.         QuestData::VOCAB[data_type], @quest.send(data_type))
  2213.     }
  2214.   }
  2215.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2216.   # * Draw Basic Data
  2217.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2218.   def draw_basic_data(y, icon_index, vocab, value)
  2219.     w = contents_width
  2220.     w = QuestData::BASIC_DATA_WIDTH if QuestData::BASIC_DATA_WIDTH.between?(1, w)
  2221.     x = (contents_width - w) / 2
  2222.     unless icon_index == 0
  2223.       draw_icon(icon_index, x, y)
  2224.       x += 24
  2225.       w -= 24
  2226.     end
  2227.     tw = text_size(vocab).width
  2228.     change_color(text_color(QuestData::COLOURS[:basic_label]))
  2229.     draw_text(x, y, tw, line_height, vocab)
  2230.     change_color(text_color(QuestData::COLOURS[:basic_value]))
  2231.     draw_text(x + tw, y, w - tw, line_height, value, 2)
  2232.   end
  2233.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2234.   # * Draw Heading
  2235.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2236.   def draw_heading(data_type, y)
  2237.     set_data_font(:heading)
  2238.     clear_and_draw_text(40, y, contents_width - 80, line_height,
  2239.       QuestData::VOCAB[data_type], QuestData::HEADING_ALIGN[data_type])
  2240.     reset_font_settings
  2241.   end
  2242.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2243.   # * Clear and Draw Text
  2244.   #    Clear the field before drawing the text
  2245.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2246.   def clear_and_draw_text(*args)
  2247.     rect = []
  2248.     while !args[0].is_a?(String) do rect.push(args.shift) end
  2249.     rect[0].is_a?(Rect) ? rect = rect[0] : rect = Rect.new(*rect)
  2250.     align = args[1] ? args[1] : 0
  2251.     ts = text_size(args[0])
  2252.     ts.width = [ts.width + 4, rect.width].min
  2253.     align == 1 ? ts.x = rect.x + ((rect.width - ts.width) / 2) :
  2254.       align == 2 ? ts.x = rect.x + rect.width - ts.width : ts.x = rect.x
  2255.     ts.y = rect.y
  2256.     contents.clear_rect(ts)
  2257.     ts.x += 2
  2258.     draw_text(ts, args[0], align)
  2259.   end
  2260.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2261.   # * Draw Description Box
  2262.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2263.   def draw_box(line_num)
  2264.     return if line_num < 1
  2265.     x = (line_height / 2) - 1
  2266.     y = @draw_y + (line_height / 2) - 1
  2267.     w = contents_width - 2*x
  2268.     h = (1 + line_num)*line_height
  2269.     draw_rect_outline_with_shadow(x, y, w, h)
  2270.   end
  2271.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2272.   # * Draw Rect Outline
  2273.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2274.   def draw_rect_outline(x, y, w, h, colour)
  2275.     # Horizontal Lines
  2276.     contents.fill_rect(x, y, w, 2, colour)
  2277.     contents.fill_rect(x, y + h - 2, w, 2, colour)
  2278.     # Vertical Lines
  2279.     contents.fill_rect(x, y, 2, h, colour)
  2280.     contents.fill_rect(x + w - 2, y, 2, h, colour)
  2281.   end
  2282.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2283.   # * Draw Rect Outline with Shadow
  2284.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2285.   def draw_rect_outline_with_shadow(x, y, w, h)
  2286.     draw_rect_outline(x + 1, y + 1, w, h, text_color(QuestData::COLOURS[:line_shadow]))
  2287.     draw_rect_outline(x, y, w, h, text_color(QuestData::COLOURS[:line]))
  2288.   end
  2289.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2290.   # * Objective/Description X
  2291.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2292.   def objective_x; line_height / 2; end
  2293.   def description_x; QuestData::DESCRIPTION_IN_BOX ? line_height : (line_height/2); end
  2294.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2295.   # * Update
  2296.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2297.   def update(*args, &block)
  2298.     super(*args, &block)
  2299.     if open? && active && @dest_scroll_oy == self.oy
  2300.       scroll_down if Input.press?(:DOWN)
  2301.       scroll_up if Input.press?(:UP)
  2302.     end
  2303.     if self.oy != @dest_scroll_oy
  2304.       mod = (@dest_scroll_oy <=> self.oy)
  2305.       self.oy += 3*mod
  2306.       self.oy = @dest_scroll_oy if (@dest_scroll_oy <=> self.oy) != mod
  2307.     end
  2308.   end
  2309.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2310.   # * Scroll Down
  2311.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2312.   def scroll_down(*args, &block)
  2313.     max_oy = contents_height - maqj_visible_height
  2314.     dest = ((@dest_scroll_oy / line_height) + 1)*line_height
  2315.     @dest_scroll_oy = [dest, max_oy].min
  2316.   end
  2317.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2318.   # * Scroll Up
  2319.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2320.   def scroll_up(*args, &block)
  2321.     dest = ((@dest_scroll_oy / line_height) - 1)*line_height
  2322.     @dest_scroll_oy = [dest, 0].max
  2323.   end
  2324. end

  2325. #==============================================================================
  2326. # ** Scene_Quest
  2327. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2328. #  This class handles processing for the Quest scene
  2329. #==============================================================================

  2330. class Scene_Quest < Scene_MenuBase
  2331.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2332.   # * Start Scene Processing
  2333.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2334.   def start
  2335.     super
  2336.     @init_category, @init_quest_index = $game_party.quests.find_location($game_system.last_quest_id, $game_system.last_quest_cat)
  2337.     create_maqj_picture unless $game_system.quest_bg_picture.empty?
  2338.     create_all_windows
  2339.     adjust_window_positions
  2340.   end
  2341.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2342.   # * Terminate Scene
  2343.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2344.   def terminate
  2345.     $game_system.quest_categories = QuestData::CATEGORIES
  2346.     $game_system.quest_scene_label = QuestData::VOCAB[:scene_label]
  2347.     $game_system.last_quest_id = @quest_list_window.item ? @quest_list_window.item.id : 0
  2348.     $game_system.last_quest_cat = @quest_category_window.item
  2349.     super
  2350.     dispose_maqj_picture
  2351.   end
  2352.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2353.   # * Create Background Picture
  2354.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2355.   def create_maqj_picture
  2356.     @maqj_picture_sprite = Sprite.new
  2357.     @maqj_picture_sprite.bitmap = Cache.picture($game_system.quest_bg_picture)
  2358.     @maqj_picture_sprite.opacity = $game_system.quest_bg_opacity
  2359.     @maqj_picture_sprite.blend_type = $game_system.quest_bg_blend_type
  2360.     @maqj_picture_sprite.z = @background_sprite.z + 1 if @background_sprite
  2361.   end
  2362.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2363.   # * Create All Windows
  2364.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2365.   def create_all_windows
  2366.     create_quest_label_window unless $game_system.quest_scene_label.empty?
  2367.     create_quest_category_window if $game_system.quest_categories.size > 1
  2368.     create_quest_category_label_window if QuestData::SHOW_CATEGORY_LABEL
  2369.     create_dummy_category_window if QuestData::CATEGORY_LABEL_IN_SAME_WINDOW &&
  2370.       @quest_category_window && @quest_category_label_window
  2371.     create_quest_list_window
  2372.     create_quest_data_window
  2373.   end
  2374.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2375.   # * Create QuestLabel Window
  2376.   #    This window shows the name of the scene
  2377.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2378.   def create_quest_label_window
  2379.     @quest_label_window = Window_QuestLabel.new(0, 0, $game_system.quest_scene_label)
  2380.   end
  2381.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2382.   # * Create QuestCategory Window
  2383.   #    This window allows the player to switch categories.
  2384.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2385.   def create_quest_category_window
  2386.     @quest_category_window = Window_QuestCategory.new(0, 0, $game_system.quest_categories)
  2387.     @quest_category_window.category = @init_category if @init_category
  2388.     @quest_category_window.set_handler(:cancel, method(:on_category_cancel))
  2389.     @quest_category_window.set_handler(:ok, method(:on_category_ok))
  2390.   end
  2391.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2392.   # * Create QuestCategoryLabel Window
  2393.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2394.   def create_quest_category_label_window
  2395.     if @quest_category_window
  2396.       @quest_category_label_window = Window_QuestCategoryLabel.new(0, @quest_category_window.height)
  2397.       @quest_category_window.add_observing_proc(:label) { |category|
  2398.         @quest_category_label_window.category = category }
  2399.     else
  2400.       @quest_category_label_window = Window_QuestCategoryLabel.new(0, 0)
  2401.       @quest_category_label_window.category = $game_system.quest_categories ? $game_system.quest_categories[0] : :all
  2402.     end
  2403.   end
  2404.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2405.   # * Create Dummy Category Label Window
  2406.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2407.   def create_dummy_category_window
  2408.     @quest_category_label_window.y -= 12
  2409.     @quest_category_label_window.opacity = 0
  2410.     @quest_category_window.opacity = 0
  2411.     w = [@quest_category_window.width, @quest_category_label_window.width].max
  2412.     h = @quest_category_window.height + @quest_category_label_window.height - 12
  2413.     @category_dummy_window = Window_QuestCategoryDummy.new(0, 0, w, h)
  2414.     @category_dummy_window.z = [@quest_category_window.z, @quest_category_label_window.z].min - 1
  2415.     # Draw Horz Line
  2416.     @category_dummy_window.draw_horizontal_line(@quest_category_window.height - @quest_category_window.padding - 7, 2)
  2417.   end
  2418.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2419.   # * Create QuestList Window
  2420.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2421.   def create_quest_list_window
  2422.     if @category_dummy_window
  2423.       y = @category_dummy_window.height
  2424.     else
  2425.       y = @quest_category_window ? @quest_category_window.height : 0
  2426.       y += @quest_category_label_window ? @quest_category_label_window.height : 0
  2427.       y = @quest_label_window.height if y == 0
  2428.     end
  2429.     @quest_list_window = Window_QuestList.new(0, y, QuestData::LIST_WINDOW_WIDTH,
  2430.       Graphics.height - y)
  2431.     @quest_list_window.set_handler(:ok, method(:on_list_ok))
  2432.     if !QuestData::CONCURRENT_ACTIVITY
  2433.       @quest_list_window.deactivate
  2434.       @quest_list_window.set_handler(:cancel, method(:on_list_cancel))
  2435.     end
  2436.     if @quest_category_window
  2437.       @quest_category_window.add_observing_proc(:list) { |category|
  2438.         @quest_list_window.category = category }
  2439.     else
  2440.       @quest_list_window.category = $game_system.quest_categories[0]
  2441.     end
  2442.     @quest_list_window.index = @init_quest_index if @init_quest_index
  2443.   end
  2444.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2445.   # * Create QuestData Window
  2446.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2447.   def create_quest_data_window
  2448.     x = @quest_list_window.width
  2449.     y = (@quest_label_window && (@quest_category_window ||
  2450.       @quest_category_label_window)) ? @quest_label_window.height : 0
  2451.     @quest_data_window = Window_QuestData.new(x, y, Graphics.width - x,
  2452.       Graphics.height - y)
  2453.     @quest_list_window.help_window = @quest_data_window
  2454.     @quest_data_window.quest = @quest_list_window.item
  2455.     @quest_data_window.set_handler(:ok, method(:on_data_ok))
  2456.     @quest_data_window.set_handler(:cancel, method(:on_data_cancel))
  2457.   end
  2458.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2459.   # * Dispose Background Picture
  2460.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2461.   def dispose_maqj_picture
  2462.     @maqj_picture_sprite.dispose if @maqj_picture_sprite
  2463.   end
  2464.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2465.   # * Adjust Window Positions
  2466.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2467.   def adjust_window_positions
  2468.     if @quest_label_window && (@quest_category_window || @quest_category_label_window)
  2469.       @quest_label_window.x = QuestData::LIST_WINDOW_WIDTH
  2470.     end
  2471.   end
  2472.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2473.   # * Category OK
  2474.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2475.   def on_category_ok; @quest_list_window.activate; end
  2476.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2477.   # * Category Cancel
  2478.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2479.   def on_category_cancel; return_scene; end
  2480.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2481.   # * List OK
  2482.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2483.   def on_list_ok
  2484.     @quest_category_window.deactivate
  2485.     @quest_data_window.activate
  2486.   end
  2487.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2488.   # * List Cancel
  2489.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2490.   def on_list_cancel; @quest_category_window.activate; end
  2491.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2492.   # * Data OK
  2493.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2494.   def on_data_ok; on_data_cancel; end
  2495.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2496.   # * Data Cancel
  2497.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2498.   def on_data_cancel
  2499.     @quest_list_window.activate
  2500.     @quest_category_window.activate if QuestData::CONCURRENT_ACTIVITY
  2501.   end
  2502.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2503.   # * Update All Windows
  2504.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2505.   def update_all_windows(*args, &block)
  2506.     # To accomodate for concurrent activity, must deactivate category
  2507.     @quest_category_window.deactivate if QuestData::CONCURRENT_ACTIVITY &&
  2508.       @quest_list_window.active && Input.trigger?(:C)
  2509.     super(*args, &block)
  2510.     @quest_category_window.activate if QuestData::CONCURRENT_ACTIVITY &&
  2511.       @quest_list_window.active
  2512.   end
  2513. end

  2514. #==============================================================================
  2515. # ** Scene_Map
  2516. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2517. #  Summary of Changes:
  2518. #    aliased method - update_scene
  2519. #    new methods - update_call_quest_journal; call_quest_journal
  2520. #==============================================================================

  2521. class Scene_Map
  2522.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2523.   # * Update Scene
  2524.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2525.   alias maqj_updascne_9kh4 update_scene
  2526.   def update_scene(*args, &block)
  2527.     maqj_updascne_9kh4(*args, &block)
  2528.     update_call_quest_journal if $game_system.quest_map_access && !scene_changing?
  2529.   end
  2530.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2531.   # * Update Call Quest Journal
  2532.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2533.   def update_call_quest_journal
  2534.     if $game_map.interpreter.running?
  2535.       @quest_journal_calling = false
  2536.     else
  2537.       if Input.trigger?(QuestData::MAP_BUTTON)
  2538.         $game_system.quest_access_disabled || $game_party.quests.list.empty? ?
  2539.           Sound.play_buzzer : @quest_journal_calling = true
  2540.       end
  2541.       call_quest_journal if @quest_journal_calling && !$game_player.moving?
  2542.     end
  2543.   end
  2544.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2545.   # * Call Quest Journal
  2546.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2547.   def call_quest_journal
  2548.     @quest_journal_calling = false
  2549.     Sound.play_ok
  2550.     SceneManager.call(Scene_Quest)
  2551.   end
  2552. end

  2553. # Menu Access
  2554. if !$imported[:MA_InsertCommand]
  2555. # Initialize the Insertion Hash
  2556. MA_COMMAND_INSERTS = {}
  2557. MA_InsertableMenuCommand = Struct.new(:name, :index, :enable, :scene, :other)

  2558. #==============================================================================
  2559. # ** Game_System
  2560. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2561. #  Summary of Changes:
  2562. #    new public instance variable - maic_menu_commands
  2563. #    aliased method - initialize
  2564. #==============================================================================

  2565. class Game_System
  2566.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2567.   # * Inserted Menu Commands
  2568.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2569.   def maic_inserted_menu_commands
  2570.     # Lazy Instantiation so that old save files are not corrupted
  2571.     if !@maic_inserted_menu_commands
  2572.       @maic_inserted_menu_commands = MA_COMMAND_INSERTS.keys
  2573.       # Sort by index
  2574.       @maic_inserted_menu_commands.sort! { |a, b| MA_COMMAND_INSERTS[a].index <=> MA_COMMAND_INSERTS[b].index }
  2575.     end
  2576.     @maic_inserted_menu_commands
  2577.   end
  2578. end

  2579. #==============================================================================
  2580. # ** Window_MenuCommand
  2581. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2582. #  Summary of Changes:
  2583. #    aliased method - make_command_list; maic_insert_command
  2584. #==============================================================================

  2585. class Window_MenuCommand
  2586.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2587.   # * Make Command List
  2588.   #``````````````````````````````````````````````````````````````````````````
  2589.   #  I alias this method instead of add_original_commands because I need to
  2590.   # have all commands created before I can insert at the correct index
  2591.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2592.   alias maic_mkcmmndl_6yd2 make_command_list
  2593.   def make_command_list(*args, &block)
  2594.     maic_mkcmmndl_6yd2(*args, &block) # Run Original Method
  2595.     # Insert new commands
  2596.     $game_system.maic_inserted_menu_commands.each { |sym| maic_insert_command(sym) }
  2597.   end
  2598.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2599.   # * Insert Command
  2600.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2601.   def maic_insert_command(symbol)
  2602.     command = MA_COMMAND_INSERTS[symbol]
  2603.     # Get the command name
  2604.     name = command.name.is_a?(Symbol) ? eval(command.name.to_s) : command.name
  2605.     # Check whether enabled
  2606.     enabled = case command.enable
  2607.     when Integer then command.enable == 0 ? true : $game_switches[command.enable]
  2608.     when String then eval(command.enable)
  2609.     when Symbol then self.send(command.enable)
  2610.     else
  2611.       enabled = true
  2612.     end
  2613.     # Add the command to the list
  2614.     add_command(name, symbol, enabled)
  2615.     added = @list.pop
  2616.     @list.insert([command.index, @list.size].min, added) # Insert at specific index
  2617.   end
  2618. end

  2619. #==============================================================================
  2620. # ** Scene_Menu
  2621. #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2622. #  Summary of Changes:
  2623. #    aliased method - create_command_window; on_personal_ok
  2624. #    new methods - maic_set_insert_handler; maic_command_insert
  2625. #==============================================================================

  2626. class Scene_Menu
  2627.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2628.   # * Create Command Window
  2629.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2630.   alias maic_createcndwin_3ey7 create_command_window
  2631.   def create_command_window(*args, &block)
  2632.     maic_createcndwin_3ey7(*args, &block) # Run Original Method
  2633.     # Add handlers for all custom commands
  2634.     $game_system.maic_inserted_menu_commands.each { |symbol| maic_set_insert_handler(symbol) }
  2635.   end
  2636.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2637.   # * Set Inserted Handler
  2638.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2639.   def maic_set_insert_handler(symbol)
  2640.     other = MA_COMMAND_INSERTS[symbol].other
  2641.     handler = case other
  2642.     when Symbol then method(other)
  2643.     when String then lambda { eval(other) }
  2644.     when TrueClass then method(:command_personal)
  2645.     else
  2646.       handler = method(:maic_command_insert)
  2647.     end
  2648.     @command_window.set_handler(symbol, handler)
  2649.   end
  2650.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2651.   # * Custom Command
  2652.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2653.   def maic_command_insert
  2654.     SceneManager.call(Kernel.const_get(MA_COMMAND_INSERTS[@command_window.current_symbol].scene))
  2655.   end
  2656.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2657.   # * Personal OK
  2658.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2659.   alias maic_onpok_3ek9 on_personal_ok
  2660.   def on_personal_ok(*args, &block)
  2661.     if $game_system.maic_inserted_menu_commands.include?(@command_window.current_symbol)
  2662.       maic_command_insert
  2663.     else
  2664.       maic_onpok_3ek9(*args, &block) # Run Original Method
  2665.     end
  2666.   end
  2667. end

  2668. $imported[:MA_InsertCommand] = true
  2669. end

  2670. MA_COMMAND_INSERTS[:quest_journal] =
  2671.   MA_InsertableMenuCommand.new(QuestData::VOCAB[:menu_label], QuestData::MENU_INDEX,
  2672.   "!$game_system.quest_access_disabled && !$game_party.quests.list.empty?",
  2673.   :Scene_Quest, false)
复制代码

评分

参与人数 1星屑 +200 梦石 +2 收起 理由
迷糊的安安 + 200 + 2 感谢帮忙

查看全部评分

签名是什么?可以吃么?
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
165
在线时间
9 小时
注册时间
2012-3-15
帖子
1
6
发表于 2012-3-15 20:01:41 | 只看该作者
本帖最后由 OAK 于 2012-3-16 10:23 编辑

试试,看能不能用
为什么我用了没效果呢,按了X键后,没任务选项。。。。{:1_4:}@
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
599 小时
注册时间
2012-8-19
帖子
131
7
发表于 2012-10-2 18:56:03 | 只看该作者
xuzhengchi 发表于 2012-3-8 19:02
这个外站的脚本如何?

代码太长,直接上范例吧:http://115.com/file/anjixvgo

115g挂了=-= 能给个新地址么=-=
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-14 02:21

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表