Advertisement
Guest User

Script 2

a guest
Feb 6th, 2013
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.52 KB | None | 0 0
  1. #==============================================================================
  2. # Quest Journal
  3. # Version: 1.1
  4. # Author: modern algebra (rmrk.net)
  5. # Date: March 24, 2008
  6. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. # Description:
  8. # Basically, this script is an objective based quest log that allows the
  9. # user to make quests and reveal them to the characters through specified
  10. # script calls. It is objective based, meaning that you advance the quest
  11. # by having the player complete objectives and you can choose when to reveal
  12. # these objectives and when to set them as complete or as failed. That being
  13. # said, this script does not build quests, it more or less gives you a
  14. # graphical interface for showing quest progress. It does run by script
  15. # call, and so read the instructions carefully if you want to use this script
  16. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  17. # Instructions:
  18. # Basically, set up all of your quests in the module below. The Constants
  19. # section is annotated, so read the comments near them to determine what you
  20. # should set these constants to. As you can see, they are filled in with
  21. # default values currently, and so that should give you an idea of what to
  22. # do.
  23. #
  24. # Setting up quests can be a little bit harder. You will have to set one
  25. # of these up for every quest that you want represented in the scene. Refer
  26. # to the editable region inside the class Quest for further instructions
  27. #
  28. # Once they are setup, you can activate them at any time in the game by
  29. # this code:
  30. #
  31. # $game_party.quests[quest_id]
  32. #
  33. # There are several methods you can call that are of relevance. Namely:
  34. #
  35. # $game_party.quests[quest_id].reveal_objective (objective_id)
  36. # $game_party.quests[quest_id].conceal_objective (objective_id)
  37. # $game_party.quests[quest_id].complete_objective (objective_id)
  38. # $game_party.quests[quest_id].uncomplete_objective (objective_id)
  39. # $game_party.quests[quest_id].fail_objective (objective_id)
  40. # $game_party.quests[quest_id].unfail_objective (objective_id)
  41. # $game_party.quests[quest_id].complete?
  42. # $game_party.quests[quest_id].failed?
  43. # $game_party.quests[quest_id].reward_given = true/false
  44. # $game_party.quests[quest_id].concealed = true/false
  45. # $game_party.quests.remove (quest_id)
  46. #
  47. # There are other methods that you can access, but they are irrelevant for
  48. # the purposes of controlling quest progress. These are fairly self-
  49. # explanatory methods, but in case they aren't, reveal_objective naturally
  50. # allows the specified objective to appear in the Quest Journal for browsing
  51. # by the user. complete_objective notes when an objective is complete, and
  52. # fail_objective notes when the player has done something that fails this
  53. # objective. complete? returns true if all primary objectives have been
  54. # completed and failed? returns true if any primary objective has been
  55. # failed. reward_given serves the function of a switch. You should
  56. # essentially make the reward event look like this:
  57. #
  58. # @> Conditional Branch: Script: $game_party.quests[quest_id].complete?
  59. # @> Conditional Branch: Script: $game_party.quests[quest_id].reward_given
  60. # @> ...Thank you or whatever you want the event to say once the reward has been given
  61. # @> Else
  62. # @> ...Give Reward
  63. # @> Script: $game_party.quests[quest_id].reward_given = true
  64. # @> Branch End
  65. # @> Branch End
  66. #
  67. # Later versions of this script will have an auto-reward system and also a
  68. # Journal to which the player can write notes.
  69. #
  70. # You can also disable access to the Quest Log at any time with the code:
  71. # $game_system.quest_disabled = true
  72. #
  73. # And you can change how it is accessed with the codes:
  74. #
  75. # $game_system.quest_keyaccess = true / false # ON MAP
  76. # $game_system.quest_menuaccess = true / false # IN MENU
  77. #
  78. # Also, in a message,
  79. q[quest_id] will retrieve the name of a quest and
  80. # print it in a message
  81. #================================================================================
  82. # *** Quest Data
  83. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  84. # This is the configuration class for the Quest Journal
  85. #================================================================================
  86.  
  87. module ModAlg_QuestData
  88. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  89. # * Constants
  90. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  91. # * Editable Region
  92. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  93. QUESTS_LABEL = 'Quests' # What you want Quests to be called (eg. 'Missions')
  94. ACTIVE_QUEST_ICON = 149 # What icon signifies a quest is active
  95. COMPLETE_QUEST_ICON = 150 # What icon signifies a quest is complete
  96. FAILED_QUEST_ICON = 179 # What icon signifies a quest is failed
  97. BULLET_CHARACTER = '●' # The character used for listing objectives
  98. ACTIVE_COLOUR = 0 # The colour of a quest that is active
  99. COMPLETE_COLOUR = 11 # The colour of a quest that is complete
  100. FAILED_COLOUR = 18 # The colour of a quest that is failed
  101. MENU_ACCESS = true # Can the script be accessed through the menu?
  102. MENU_INDEX = 4 # If above is true, where in the command window?
  103. KEY_ACCESS = false # Can the quest log be accessed by a key
  104. MAPKEY_BUTTON = Input::L # If above is true, which button?
  105. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  106. # * Quest Data
  107. #----------------------------------------------------------------------------
  108. # Returns skeleton data for the quesr
  109. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  110. def self.quest_data (id)
  111. # Set class variables to corresponding arguments
  112. objectives = []
  113. name = '??????'
  114. description = '??????????'
  115. icon_index = 0
  116. case id
  117. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  118. # * EDITABLE REGION
  119. #------------------------------------------------------------------------
  120. # To set up a quest, first identify it with an ID - this can be anything
  121. # as long as it is not the same as another quest, but it is important to
  122. # remember this ID as it is the only way to access your quest.
  123. # In any case, the format for setting up a quest is:
  124. #
  125. # when <quest_id> # Give the quest an ID number
  126. # name = '<quest_name>'
  127. # description = '<quest_description>'
  128. # objectives[0] = '<first_objective>'
  129. # ...
  130. # objectives[n] = '<nth objective>'
  131. # prime = [<objective_id>, ..., <objective_id>]
  132. # icon_index = <quest_icon_index>
  133. #
  134. # Each of these values have an importance.
  135. # name is the name of the quest
  136. # description is a small blurb explaining the overall goal of the quest
  137. # objective[0..n] are short-term goals that lead to the overall goal
  138. # primes are which objectives need to be complete before the quest is
  139. # considered to be complete
  140. # icon_index is the icon that represents the quest
  141. #
  142. # Note that any of the above values can be omitted without throwing an
  143. # error, but for the quest to work properly you should at least set the
  144. # name, description, and objectives. If you do omit these, the default
  145. # values are:
  146. #
  147. # name = '??????'
  148. # description = '??????????'
  149. # objectives = []
  150. # prime = [all objectives]
  151. # icon_index = 0
  152. #
  153. # If you do want to require that all objectives must be satisfied before
  154. # the quest is complete, then do not bother defining it. Otherwise, be
  155. # sure to set it.
  156. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  157. when 1 # Fetch
  158. name = 'Fetch'
  159. description = 'Martha needs someone to play with her dog'
  160. objectives[0] = 'Find a stick'
  161. objectives[1] = 'Throw the stick to the dog'
  162. objectives[2] = 'Retrieve the stick from the dog'
  163. icon_index = 79
  164. when 4 # Cat Retrieval
  165. name = 'Cat Retrieval'
  166. description = 'Mrs. Bunderby has lost her cat, and she has employed you to find it.'
  167. objectives[0] = 'Find the lost cat'
  168. objectives[1] = 'Climb the tree and retrieve the cat'
  169. objectives[2] = "Return a cat to Mrs. Bunderby"
  170. # Set prime objectives in an array based on index
  171. prime = [0, 2]
  172. icon_index = 137
  173. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  174. # * END EDITABLE REGION
  175. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  176. end
  177. return name, description, objectives, prime, icon_index
  178. end
  179.  
  180. #============================================================================
  181. # ** Quest
  182. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  183. # Holds in-game data for a quest
  184. #============================================================================
  185.  
  186. class Quest
  187. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  188. # * Public Instance Variables
  189. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  190. attr_reader :name # The name of the quest
  191. attr_reader :id # The ID in $game_party.quests
  192. attr_reader :description # A blurb explaining the quest
  193. attr_reader :objectives # An array of strings holding objectives
  194. attr_reader :prime_objectives # An array of crucial objectives
  195. attr_reader :icon_index # The Icon associated with this quest
  196. attr_reader :revealed_objectives # An array of revealed objectives
  197. attr_reader :complete_objectives # An array of completed objectives
  198. attr_reader :failed_objectives # An array of failed objectives
  199. attr_accessor :reward_given # A switch to ensure only one reward given
  200. attr_accessor :concealed # A switch to show or not show the quest
  201. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  202. # * Object Initialization
  203. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  204. def initialize (id)
  205. @id = id
  206. # Set class variables to corresponding arguments
  207. @name, @description, @objectives, prime, @icon_index = ModAlg_QuestData.quest_data (id)
  208. # If no primary objectives are specified
  209. if prime.nil?
  210. # All objectives become primary
  211. prime = []
  212. for i in 0...@objectives.size
  213. prime.push (i)
  214. end
  215. end
  216. @prime_objectives = prime
  217. # Initialize non-public arrays
  218. @revealed_objectives = []
  219. @complete_objectives = []
  220. @failed_objectives = []
  221. @reward_given = false
  222. @concealed = false
  223. end
  224. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  225. # * Reveal Objective
  226. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  227. def reveal_objective (index)
  228. return if index >= @objectives.size
  229. # Add to revealed objectives
  230. @revealed_objectives |= [index]
  231. # Sort from lowest index to highest index
  232. @revealed_objectives.sort!
  233. end
  234. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  235. # * Conceal Objective
  236. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  237. def conceal_objective (index)
  238. @revealed_objectives.delete (index)
  239. end
  240. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  241. # * Complete Objective
  242. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  243. def complete_objective (index)
  244. return if index >= @objectives.size
  245. # If the objective is failed, you cannot complete it.
  246. return if @failed_objectives.include? (index)
  247. # Reveal the objective if it was not previously revealed
  248. reveal_objective (index) unless @revealed_objectives.include? (index)
  249. # Add to complete objectives
  250. @complete_objectives |= [index]
  251. # Sort from lowest index to highest index
  252. @complete_objectives.sort!
  253. end
  254. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  255. # * Uncomplete Objective
  256. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  257. def uncomplete_objective (index)
  258. @complete_objectives.delete (index)
  259. end
  260. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  261. # * Fail Objective
  262. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  263. def fail_objective (index)
  264. return if index >= @objectives.size
  265. # Reveal the objective if it has not yet been revealed
  266. reveal_objective (index) unless @revealed_objectives.include? (index)
  267. # Add to revealed objectives
  268. @failed_objectives |= [index]
  269. # Sort from lowest index to highest index
  270. @failed_objectives.sort!
  271. end
  272. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  273. # * Unfail Objective
  274. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  275. def unfail_objective (index)
  276. @failed_objectives.delete (index)
  277. end
  278. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  279. # * Complete?
  280. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  281. def complete?
  282. # Check if all prime objectives have been completed
  283. return (@complete_objectives & @prime_objectives) == @prime_objectives
  284. end
  285. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  286. # * Failed?
  287. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  288. def failed?
  289. # Check if any prime objectives have been failed
  290. return (@failed_objectives & @prime_objectives) != []
  291. end
  292. end
  293. end
  294.  
  295. #==============================================================================
  296. # ** Ellipse
  297. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  298. # Stores an ellipse object.
  299. #==============================================================================
  300.  
  301. class Ellipse
  302. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  303. # * Public Instance Variables
  304. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  305. attr_reader :a # The width of the oval
  306. attr_reader :b # The Height of the oval
  307. attr_reader :x # the top left x position
  308. attr_reader :y # the top left y position
  309. attr_reader :h # The x position of the origin
  310. attr_reader :k # The y position of the origin
  311. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  312. # * Object Initialization
  313. # x : the top left x position
  314. # y : the top left y position
  315. # a : the width of oval from origin to the side
  316. # b : the height of oval from origin. If nil, then a is radius of circle
  317. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  318. def initialize (x, y, a, b = nil)
  319. @x = x
  320. @y = y
  321. @a = a
  322. @b = b.nil? ? a : b
  323. @h = x a
  324. @k = y @b
  325. end
  326. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  327. # * Within?
  328. # x : the x coordinate being tested
  329. # y : the y coordinate being tested
  330. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  331. def within? (x, y)
  332. x_square = ((x - @h)*(x - @h)).to_f / (@a*@a)
  333. y_square = ((y - @k)*(y - @k)).to_f / (@b*@b)
  334. # If "radius" <= 1, then it must be within the ellipse
  335. return (x_square y_square) <= 1
  336. end
  337. end
  338.  
  339. #==============================================================================
  340. # ** Bitmap
  341. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  342. # This adds the methods fill_ellipse, outline_ellipse, and fill_rounded_rect
  343. #==============================================================================
  344.  
  345. class Bitmap
  346. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  347. # * Outline Ellipse
  348. # ellipse : the ellipse being drawn
  349. # width : the width of the bar
  350. # colour : the colour of the outline
  351. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  352. def outline_ellipse (ellipse, colour = font.color, width = 1, steps = 0)
  353. # For neatness, define local variables a and b to the ellipse variables
  354. a, b = ellipse.a, ellipse.b
  355. # Use Ramanujan's approximation of the Circumference of an ellipse
  356. steps = Math::PI*(3*(a b) - Math.sqrt((3*a b)*(a 3*b))) if steps == 0
  357. radian_modifier = (2*Math::PI) / steps
  358. for i in 0...steps
  359. t = (radian_modifier*i) % (2*Math::PI)
  360. # Expressed parametrically:
  361. # x = h acos(t), y = k bsin(t) : where t ranges from 0 to 2pi
  362. x = (ellipse.h (a*Math.cos(t)))
  363. y = (ellipse.k (b*Math.sin(t)))
  364. set_pixel (x, y, colour)
  365. end
  366. # Thicken the line
  367. if width > 1
  368. ellipse = Ellipse.new (ellipse.x 1, ellipse.y 1, ellipse.a - 1, ellipse.b - 1)
  369. outline_ellipse (ellipse, colour, width - 1, steps)
  370. end
  371. end
  372. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  373. # * Fill Ellipse
  374. # ellipse : the ellipse being drawn
  375. # colour : the colour of the outline
  376. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  377. def fill_ellipse (ellipse, colour = font.color, steps = 0)
  378. # For neatness, define local variables a and b to the ellipse variables
  379. a, b = ellipse.a, ellipse.b
  380. # Use Ramanujan's approximation of the Circumference of an ellipse
  381. steps = Math::PI*(3*(a b) - Math.sqrt((3*a b)*(a 3*b))) if steps == 0
  382. radian_modifier = (2*Math::PI) / steps
  383. for i in 0...(steps / 2)
  384. t = (radian_modifier*i) % (2*Math::PI)
  385. # Expressed parametrically:
  386. # x = h acos(t), y = k bsin(t) : where t ranges from 0 to 2pi
  387. x = ellipse.h (a*Math.cos(t))
  388. y = ellipse.k - (b*Math.sin(t))
  389. fill_rect (x, y, 1, 2*(ellipse.k - y), colour)
  390. end
  391. end
  392. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  393. # * Fill Rounded Rectangle
  394. # rect : the rectangle being drawn
  395. # colour : the colour of the outline
  396. # w : the number of pixels to cover by rounding
  397. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  398. # Used to fill a rectangle with rounded corners
  399. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  400. def fill_rounded_rect (rect, colour = font.color, w = 8)
  401. # Draw Body of the rectangle
  402. fill_rect (rect.x w, rect.y, rect.width - 2*w, rect.height, colour)
  403. # Draw Left Vertical Rect
  404. fill_rect (rect.x, rect.y w, w, rect.height - 2*w, colour)
  405. # Draw Right Vertical Rect
  406. x = rect.x rect.width - w
  407. fill_rect (x, rect.y w, w, rect.height - 2*w, colour)
  408. # Make a circle
  409. circle = Ellipse.new (0, 0, w)
  410. for i in 0...w
  411. for j in 0...w
  412. # Upper Left Corner
  413. set_pixel (rect.x i, rect.y j, colour) if circle.within? (i, j)
  414. # Upper Right Corner
  415. set_pixel (rect.x rect.width - w i, rect.y j, colour) if circle.within? (i w, j)
  416. # Bottom Left Corner
  417. set_pixel (rect.x i, rect.y rect.height - w j, colour) if circle.within? (i, j w)
  418. # Bottom Right Corner
  419. set_pixel (rect.x rect.width - w i, rect.y rect.height - w j, colour) if circle.within? (i w, j w)
  420. end
  421. end
  422. end
  423. end
  424.  
  425. #==============================================================================
  426. # ** Window_VarySizeHelp
  427. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  428. # This window is the same as Window_Help, but with variable size
  429. #==============================================================================
  430.  
  431. class Window_VarySizeHelp < Window_Help
  432. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  433. # * Object Initialization
  434. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  435. def initialize (h_x = 0, h_y = 0, h_width = Graphics.width, h_height = WLH 32)
  436. super ()
  437. self.x, self.y, self.width, self.height = h_x, h_y, h_width, h_height
  438. contents.dispose
  439. self.contents = Bitmap.new (h_width - 32, h_height - 32)
  440. end
  441. end
  442.  
  443. #==============================================================================
  444. # ** Game_System
  445. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  446. # Summary of Changes:
  447. # new instance variables - quest_disabled, quest_keyaccess
  448. # aliased method - initialize
  449. #==============================================================================
  450.  
  451. class Game_System
  452. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  453. # * Public Instance Variables
  454. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  455. attr_accessor :quest_disabled # Can you access quest journal at this time
  456. attr_accessor :quest_keyaccess # Is it accessible by key?
  457. attr_accessor :quest_menuaccess # Is it accessible through the menu
  458. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  459. # * Object Initialization
  460. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  461. alias modalg_qst_jrnl_system_init_quests initialize
  462. def initialize
  463. # Run Original Method
  464. modalg_qst_jrnl_system_init_quests
  465. # Initialize new variables
  466. @quest_disabled = false
  467. @quest_keyaccess = ModAlg_QuestData::KEY_ACCESS
  468. @quest_menuaccess = ModAlg_QuestData::MENU_ACCESS
  469. end
  470. end
  471.  
  472. #==============================================================================
  473. # ** Game_Party
  474. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  475. # Summary of Changes:
  476. # new instance variable - quests
  477. # aliased method - initialize
  478. #==============================================================================
  479.  
  480. class Game_Party
  481. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  482. # * Public Instance Variables
  483. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  484. attr_reader :quests
  485. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  486. # * Object Initialization
  487. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  488. alias modalg_qst_jrnl_party_init_quests initialize
  489. def initialize
  490. # Run Original Method
  491. modalg_qst_jrnl_party_init_quests
  492. # Initialize @quests
  493. @quests = Game_Quests.new
  494. end
  495. end
  496.  
  497. #==============================================================================
  498. # ** Game_Quests
  499. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  500. # This class handles Quests. It is a wrapper for the built-in class "Hash".
  501. # The instance of this class is accessed by $game_party.quests
  502. #==============================================================================
  503.  
  504. class Game_Quests
  505. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  506. # * Object Initialization
  507. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  508. def initialize
  509. @data = {}
  510. end
  511. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  512. # * Get Quest
  513. # quest_id : the ID of the quest
  514. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  515. def [] (quest_id)
  516. @data[quest_id] = ModAlg_QuestData::Quest.new (quest_id) if @data[quest_id] == nil
  517. return @data[quest_id]
  518. end
  519. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  520. # * Get Quest List
  521. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  522. def list
  523. quest_list = @data.values
  524. quest_list.each { |i| quest_list.delete (i) if i.concealed }
  525. return quest_list
  526. end
  527. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  528. # * Get Completed Quest List
  529. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  530. def completed_list
  531. complete_quests = []
  532. list.each { |i| complete_quests.push (i) if i.complete? }
  533. return complete_quests
  534. end
  535. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  536. # * Get Failed Quest List
  537. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  538. def failed_list
  539. failed_quests = []
  540. list.each { |i| failed_quests.push (i) if i.failed? }
  541. return failed_quests
  542. end
  543. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  544. # * Get Active Quest List
  545. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  546. def active_list
  547. return list - failed_list - completed_list
  548. end
  549. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  550. # * Revealed?
  551. # quest_id : the ID of a checked quest
  552. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  553. def revealed? (quest_id)
  554. return @data[quest_id] != nil
  555. end
  556. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  557. # * Remove Quest
  558. # quest_id : the ID of a checked quest
  559. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  560. def remove (quest_id)
  561. @data.delete (quest_id)
  562. end
  563. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  564. # * Clear
  565. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  566. def clear
  567. @data.clear
  568. end
  569. end
  570.  
  571. #==============================================================================
  572. # ** Window_Command
  573. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  574. # Summary of Changes:
  575. # new instance variable - disabled_commands
  576. # aliased method - initialize, draw_item
  577. #==============================================================================
  578.  
  579. class Window_Command
  580. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  581. # * Public Instance Variable
  582. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  583. attr_reader :disabled_commands
  584. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  585. # * Initialize
  586. # width : window width
  587. # commands : command string array
  588. # column_max : digit count (if 2 or more, horizontal selection)
  589. # row_max : row count (0: match command count)
  590. # spacing : blank space when items are arrange horizontally
  591. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  592. alias modalg_quest_jrnl_intlz initialize
  593. def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
  594. # Initialize new instance variable
  595. @disabled_commands = []
  596. # Run Original Method
  597. modalg_quest_jrnl_intlz (width, commands, column_max, row_max, spacing)
  598. end
  599. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  600. # * Draw Item
  601. # index : item number
  602. # enabled : enabled flag. When false, draw semi-transparently
  603. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  604. alias modalg_quest_jrnl_itm_drw draw_item
  605. def draw_item (index, enabled = true)
  606. # Run Original Method
  607. modalg_quest_jrnl_itm_drw (index, enabled)
  608. enabled ? @disabled_commands.delete (index) : @disabled_commands.push (index)
  609. end
  610. end
  611.  
  612. #==============================================================================
  613. # ** Window_Message
  614. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  615. # Summary of Changes:
  616. # aliaed method - convert_special_characters
  617. #==============================================================================
  618.  
  619. class Window_Message
  620. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  621. # * Convert Special Characters
  622. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  623. alias modalg_quest_jrnl_spec_char_convert convert_special_characters
  624. def convert_special_characters
  625. @text.gsub! (/NQ[(d )]/i) { $game_party.quests[$1.to_i] } # Name Quest
  626. # Run Original Method
  627. modalg_quest_jrnl_spec_char_convert
  628. end
  629. end
  630.  
  631. #==============================================================================
  632. # ** Window_QuestLabel
  633. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  634. # This window signifies that this is a quest list
  635. #==============================================================================
  636.  
  637. class Window_QuestLabel < Window_Base
  638. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  639. # * Object Initialization
  640. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  641. def initialize
  642. super (0, 0, 160 WLH, 32 WLH)
  643. create_contents
  644. contents.font.color = system_color
  645. contents.draw_text (0, 0, contents.width, WLH, ModAlg_QuestData::QUESTS_LABEL, 1)
  646. end
  647. end
  648.  
  649. #==============================================================================
  650. # ** Window_QuestCategory
  651. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  652. # This window displays which category is being viewed
  653. #==============================================================================
  654.  
  655. class Window_QuestCategory < Window_Base
  656. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  657. # * Object Initialization
  658. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  659. def initialize
  660. super (0, WLH 32, 160 WLH, 64)
  661. create_contents
  662. end
  663. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  664. # * Refresh
  665. # category_index : icon to highlight -
  666. # 0 => All, 1 => Active, 2 => Complete, 3 => Failed
  667. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  668. def refresh (category_index = 0)
  669. contents.clear
  670. # Retrieve Icon Bitmaps
  671. bitmap = Cache.system("Iconset")
  672. icon_index = ModAlg_QuestData::ACTIVE_QUEST_ICON
  673. active_rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  674. icon_index = ModAlg_QuestData::COMPLETE_QUEST_ICON
  675. complete_rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  676. icon_index = ModAlg_QuestData::FAILED_QUEST_ICON
  677. failed_rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  678. # Combine the three icons for the All Icon
  679. all_icon = Bitmap.new (40, 32)
  680. all_icon.blt (0, 0, bitmap, complete_rect)
  681. all_icon.blt (20, 0, bitmap, failed_rect)
  682. all_icon.blt (8, 10, bitmap, active_rect)
  683. distance = (contents.width - 112) / 3
  684. x = 0
  685. # Draw the 'All' Icon onto the window
  686. contents.blt (x, 0, all_icon, all_icon.rect, category_index == 0 ? 255 : 128)
  687. x = 40 distance
  688. # Draw the 'Active' Icon onto the window
  689. contents.blt (x, 4, bitmap, active_rect, category_index == 1 ? 255 : 128)
  690. x = 24 distance
  691. # Draw the 'Complete' Icon onto the window
  692. contents.blt (x, 4, bitmap, complete_rect, category_index == 2 ? 255 : 128)
  693. x = 24 distance
  694. # Draw the 'Failed' Icon onto the window
  695. contents.blt (x, 4, bitmap, failed_rect, category_index == 3 ? 255 : 128)
  696. end
  697. end
  698.  
  699. #==============================================================================
  700. # ** Window_QuestList
  701. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  702. # This window displays the list of quests
  703. #==============================================================================
  704.  
  705. class Window_QuestList < Window_Selectable
  706. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  707. # * Object Initialization
  708. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  709. def initialize (category_index = 0, index = 0)
  710. super (0, 64 (WLH 32), 160 WLH, Graphics.height - 64 - 2*(WLH 32))
  711. @data = []
  712. @column_max = 1
  713. refresh (category_index)
  714. self.index = index
  715. self.active = true
  716. end
  717. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  718. # * Quest
  719. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  720. def quest
  721. return @data[self.index]
  722. end
  723. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  724. # * Refresh
  725. # category_index : List to show -
  726. # 0 => All, 1 => Active, 2 => Complete, 3 => Failed
  727. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  728. def refresh (category_index = 0)
  729. font = Font.new
  730. @data.clear
  731. self.index = 0
  732. # Get the quest list to be drawn
  733. case category_index
  734. when 0
  735. @data = $game_party.quests.list
  736. when 1
  737. @data = $game_party.quests.active_list
  738. font.color = text_color (ModAlg_QuestData::ACTIVE_COLOUR)
  739. when 2
  740. @data = $game_party.quests.completed_list
  741. font.color = text_color (ModAlg_QuestData::COMPLETE_COLOUR)
  742. when 3
  743. @data = $game_party.quests.failed_list
  744. font.color = text_color (ModAlg_QuestData::FAILED_COLOUR)
  745. end
  746. @item_max = @data.size
  747. unless contents == nil
  748. # Clear Contents
  749. contents.clear
  750. return if @data.empty?
  751. contents.dispose
  752. end
  753. # Create Contents
  754. self.contents = Bitmap.new (width - 32, WLH*@data.size)
  755. contents.font = font
  756. # Draw the Quest Names
  757. for i in 0...@data.size
  758. quest = @data[i]
  759. # If all, distinguish between quest types by colour
  760. if category_index == 0
  761. if quest.complete?
  762. contents.font.color = text_color (ModAlg_QuestData::COMPLETE_COLOUR)
  763. elsif quest.failed?
  764. contents.font.color = text_color (ModAlg_QuestData::FAILED_COLOUR)
  765. else # Active
  766. contents.font.color = text_color (ModAlg_QuestData::ACTIVE_COLOUR)
  767. end
  768. end
  769. draw_icon (quest.icon_index, 0, i*WLH)
  770. # Draw the name of the quest
  771. contents.draw_text (24, i*WLH, contents.width - 24, WLH, quest.name)
  772. end
  773. end
  774. end
  775.  
  776. #==============================================================================
  777. # ** Window_QuestInfo
  778. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  779. # This window displays the information on the quest being viewed
  780. #==============================================================================
  781.  
  782. class Window_QuestInfo < Window_Base
  783. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  784. # * Object Initialization
  785. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  786. def initialize
  787. super (160 WLH, 0, Graphics.width - (160 WLH), Graphics.height - (32 WLH))
  788. create_contents
  789. end
  790. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  791. # * Refresh
  792. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  793. def refresh (quest = nil)
  794. contents.clear
  795. return if quest == nil
  796. # Draw the name of the Quest, centred
  797. contents.font.color = normal_color
  798. contents.draw_text (0, 0, contents.width, WLH, quest.name, 1)
  799. # If the font has set width characters
  800. if contents.text_size ('w').width == contents.text_size ('i').width
  801. formatter = Paragrapher::Formatter_2.new
  802. else
  803. formatter = Paragrapher::Formatter.new
  804. end
  805. # Format the description
  806. desc_bitmap = Bitmap.new (contents.width - 16, (2.4*WLH).to_i)
  807. desc_bitmap.font.size -= 4
  808. formatted_desc = formatter.format (quest.description, desc_bitmap)
  809. # Draw the Description Box
  810. box_height = [WLH*(formatted_desc.lines.size 1), 3*WLH].min
  811. rect = Rect.new (2, (1.5*WLH).to_i, contents.width - 4, box_height)
  812. contents.fill_rounded_rect (rect, system_color, 10)
  813. rect.x, rect.y = rect.x 2, rect.y 2
  814. rect.width, rect.height = rect.width - 4, rect.height - 4
  815. contents.fill_rounded_rect (rect, Color.new (0, 0, 0, 0), 10)
  816. tw = contents.text_size ('Description').width
  817. # Draw the description signifier
  818. contents.fill_rect (32, (1.5*WLH).to_i, tw 2, 2, Color.new (0, 0, 0, 0))
  819. contents.font.color = system_color
  820. contents.draw_text (33, WLH, tw, WLH, 'Description')
  821. # Paragraph Artist
  822. artist = Paragrapher::Artist.new
  823. # If bitmap is too large
  824. if formatted_desc.lines.size < 2
  825. formatted_desc.bitmap = Bitmap.new (contents.width - 16, formatted_desc.lines.size*WLH)
  826. formatted_desc.bitmap.font.size -= 4
  827. end
  828. bmp = artist.draw (formatted_desc)
  829. # Centre within the box
  830. y = rect.y 4 (rect.height - bmp.height) / 2
  831. contents.blt (8, y, bmp, bmp.rect)
  832. bmp.dispose
  833. y = 2*WLH rect.height 4
  834. # Draw Objectives Signifier Text
  835. contents.font.color = system_color
  836. tw = contents.text_size ('Objectives').width
  837. contents.draw_text (32, y, tw, WLH, 'Objectives')
  838. y = WLH
  839. quest.revealed_objectives.each { |i|
  840. # Get the correct color
  841. contents.font.color = quest.complete_objectives.include? (i) ?
  842. text_color (ModAlg_QuestData::COMPLETE_COLOUR) : quest.failed_objectives.include? (i) ?
  843. text_color (ModAlg_QuestData::FAILED_COLOUR) : text_color (ModAlg_QuestData::ACTIVE_COLOUR)
  844. # Get objective
  845. objective = quest.objectives[i]
  846. # Draw Bullet
  847. tw = contents.text_size (ModAlg_QuestData::BULLET_CHARACTER).width
  848. x = 8
  849. contents.draw_text (x, y, tw, WLH, ModAlg_QuestData::BULLET_CHARACTER)
  850. x = tw 4
  851. # Format the objective
  852. obj_bitmap = Bitmap.new (contents.width - x, 2*WLH)
  853. obj_bitmap.font = contents.font
  854. obj_bitmap.font.size -= 4
  855. formatted_obj = formatter.format (objective, obj_bitmap)
  856. # Draw Objective
  857. bmp = artist.draw (formatted_obj)
  858. contents.blt (x, y 4, bmp, bmp.rect)
  859. # Modify the Y accordingly
  860. y = WLH*([formatted_obj.lines.size, 2].min)
  861. }
  862. end
  863. end
  864.  
  865. #==============================================================================
  866. # ** Scene_Map
  867. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  868. # Summary of Changes:
  869. # aliased method - update
  870. #==============================================================================
  871.  
  872. class Scene_Map < Scene_Base
  873. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  874. # * Frame Update
  875. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  876. alias modalg_quest_journal_map_upd_key_access update
  877. def update
  878. modalg_quest_journal_map_upd_key_access
  879. # If the quest log can be accessed by key and is not empty or disabled
  880. if $game_system.quest_keyaccess && !$game_system.quest_disabled && !$game_party.quests.list.empty?
  881. $scene = Scene_Quest.new if Input.trigger? (ModAlg_QuestData::MAPKEY_BUTTON)
  882. end
  883. end
  884. end
  885.  
  886. #==============================================================================
  887. # ** Scene_Menu
  888. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  889. # Summary of Changes:
  890. # aliased methods - initialize, create_command_window, update_command_selection
  891. #==============================================================================
  892.  
  893. class Scene_Menu < Scene_Base
  894. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  895. # * Object Initialization
  896. # menu_index : command cursor's initial position
  897. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  898. alias modalg_quest_jrnl_init initialize
  899. def initialize(menu_index = 0)
  900. modalg_quest_jrnl_init (menu_index)
  901. return unless $game_system.quest_menuaccess
  902. if @menu_index == 'Quest'
  903. @menu_index = ModAlg_QuestData::MENU_INDEX
  904. elsif @menu_index >= ModAlg_QuestData::MENU_INDEX
  905. @menu_index = 1
  906. end
  907. end
  908. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  909. # * Create Command Window
  910. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  911. alias modalg_quest_journal_menu_cmmnd_win_create create_command_window
  912. def create_command_window
  913. modalg_quest_journal_menu_cmmnd_win_create
  914. # If accessed through map, then don't add it to the menu
  915. return unless $game_system.quest_menuaccess
  916. c = @command_window.commands
  917. c.insert (ModAlg_QuestData::MENU_INDEX, ModAlg_QuestData::QUESTS_LABEL)
  918. width = @command_window.width
  919. disabled = @command_window.disabled_commands
  920. @command_window.dispose
  921. @command_window = Window_Command.new(width, c)
  922. @command_window.index = @menu_index
  923. # Disable all of the old commands as well
  924. disabled.each { |i|
  925. i = 1 if i >= ModAlg_QuestData::MENU_INDEX
  926. @command_window.draw_item (i, false)
  927. }
  928. if $game_system.quest_disabled || $game_party.quests.list.empty? # If Quest Journal disabled
  929. @command_window.draw_item (ModAlg_QuestData::MENU_INDEX, false)
  930. end
  931. end
  932. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  933. # * Update Command Selection
  934. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  935. alias modalg_quest_journal_menu_cmmnd_select_upd update_command_selection
  936. def update_command_selection
  937. if $game_system.quest_menuaccess
  938. changed = false
  939. if @command_window.index == ModAlg_QuestData::MENU_INDEX && Input.trigger? (Input::C)
  940. if $game_system.quest_disabled || $game_party.quests.list.empty? # If Quest Journal disabled
  941. Sound.play_buzzer
  942. else
  943. # Open Quest Window
  944. Sound.play_decision
  945. $scene = Scene_Quest.new
  946. end
  947. return
  948. end
  949. # If the command index is greater than it ought to be, make sure
  950. if @command_window.index > ModAlg_QuestData::MENU_INDEX
  951. @command_window.index = (@command_window.index - 1) % @command_window.commands.size
  952. changed = true
  953. end
  954. end
  955. modalg_quest_journal_menu_cmmnd_select_upd
  956. return unless $game_system.quest_menuaccess
  957. @command_window.index = (@command_window.index 1) % @command_window.commands.size if changed
  958. end
  959. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  960. # * Update Actor Selection
  961. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  962. alias modalg_quest_jrnl_actor_selection_upd update_actor_selection
  963. def update_actor_selection
  964. changed = false
  965. if $game_system.quest_menuaccess && @command_window.index > ModAlg_QuestData::MENU_INDEX
  966. @command_window.index = (@command_window.index - 1) % @command_window.commands.size
  967. changed = true
  968. end
  969. modalg_quest_jrnl_actor_selection_upd
  970. return unless $game_system.quest_menuaccess
  971. @command_window.index = (@command_window.index 1) % @command_window.commands.size if changed
  972. end
  973. end
  974.  
  975. #==============================================================================
  976. # ** Scene_Quest
  977. #------------------------------------------------------------------------------
  978. # This class performs the quest screen processing.
  979. #==============================================================================
  980.  
  981. class Scene_Quest < Scene_Base
  982. #--------------------------------------------------------------------------
  983. # * Object Initialization
  984. # menu_index : command cursor's initial position
  985. #--------------------------------------------------------------------------
  986. def initialize(category_index = 0, quest_index = 0)
  987. @category_index = category_index
  988. @quest_index = quest_index
  989. end
  990. #--------------------------------------------------------------------------
  991. # * Start processing
  992. #--------------------------------------------------------------------------
  993. def start
  994. super
  995. create_menu_background
  996. # Create Windows
  997. @label_window = Window_QuestLabel.new
  998. @category_window = Window_QuestCategory.new
  999. @category_window.refresh (@category_index)
  1000. @list_window = Window_QuestList.new (@category_index, @quest_index)
  1001. @info_window = Window_QuestInfo.new
  1002. @info_window.refresh (@list_window.quest)
  1003. @help_window = Window_VarySizeHelp.new
  1004. @help_window.y = Graphics.height - @help_window.height
  1005. @help_window.set_text ('Use Horizontal Arrow Keys to change categories', 1)
  1006. end
  1007. #--------------------------------------------------------------------------
  1008. # * Termination Processing
  1009. #--------------------------------------------------------------------------
  1010. def terminate
  1011. super
  1012. dispose_menu_background
  1013. @label_window.dispose
  1014. @category_window.dispose
  1015. @list_window.dispose
  1016. @info_window.dispose
  1017. @help_window.dispose
  1018. end
  1019. #--------------------------------------------------------------------------
  1020. # * Frame Update
  1021. #--------------------------------------------------------------------------
  1022. def update
  1023. super
  1024. update_menu_background
  1025. # Since the only possible activity is from @list_window, put it here
  1026. @list_window.update
  1027. if Input.trigger?(Input::B) # If Button B is pressed
  1028. Sound.play_cancel
  1029. # If Returning to Menu
  1030. if $game_system.quest_menuaccess
  1031. $scene = Scene_Menu.new ('Quest')
  1032. else # Returning to Map
  1033. $scene = Scene_Map.new
  1034. end
  1035. elsif Input.trigger? (Input::C) # If C button is pressed
  1036. # Open Journal (eventually)
  1037. elsif Input.trigger? (Input::LEFT) # If Left direction pressed
  1038. # Play Cursor SE
  1039. Sound.play_cursor
  1040. # Refresh Category Window
  1041. @category_index = (@category_index - 1) % 4
  1042. @category_window.refresh (@category_index)
  1043. @list_window.refresh (@category_index)
  1044. @info_window.refresh (@list_window.quest)
  1045. elsif Input.trigger? (Input::RIGHT) # If Right direction pressed
  1046. # Play Cursor SE
  1047. Sound.play_cursor
  1048. # Refresh Category Window
  1049. @category_index = (@category_index 1) % 4
  1050. @category_window.refresh (@category_index)
  1051. @list_window.refresh (@category_index)
  1052. @info_window.refresh (@list_window.quest)
  1053. # If scrolling through quests
  1054. elsif Input.trigger? (Input::DOWN) || Input.trigger? (Input::UP)
  1055. # Refresh Info Window
  1056. @info_window.refresh (@list_window.quest)
  1057. end
  1058. end
  1059. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement