Pikachu8329

I need help i dont know what i did wrong

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