Advertisement
Guest User

Script 2

a guest
Feb 6th, 2013
52
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. prime.push (i)
  213. end
  214. end
  215. @prime_objectives = prime
  216. # Initialize non-public arrays
  217. @revealed_objectives = []
  218. @complete_objectives = []
  219. @failed_objectives = []
  220. @reward_given = false
  221. @concealed = false
  222. end
  223. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  224. # * Reveal Objective
  225. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  226. def reveal_objective (index)
  227. return if index >= @objectives.size
  228. # Add to revealed objectives
  229. @revealed_objectives |= [index]
  230. # Sort from lowest index to highest index
  231. @revealed_objectives.sort!
  232. end
  233. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  234. # * Conceal Objective
  235. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  236. def conceal_objective (index)
  237. @revealed_objectives.delete (index)
  238. end
  239. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  240. # * Complete Objective
  241. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  242. def complete_objective (index)
  243. return if index >= @objectives.size
  244. # If the objective is failed, you cannot complete it.
  245. return if @failed_objectives.include? (index)
  246. # Reveal the objective if it was not previously revealed
  247. reveal_objective (index) unless @revealed_objectives.include? (index)
  248. # Add to complete objectives
  249. @complete_objectives |= [index]
  250. # Sort from lowest index to highest index
  251. @complete_objectives.sort!
  252. end
  253. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  254. # * Uncomplete Objective
  255. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  256. def uncomplete_objective (index)
  257. @complete_objectives.delete (index)
  258. end
  259. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  260. # * Fail Objective
  261. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  262. def fail_objective (index)
  263. return if index >= @objectives.size
  264. # Reveal the objective if it has not yet been revealed
  265. reveal_objective (index) unless @revealed_objectives.include? (index)
  266. # Add to revealed objectives
  267. @failed_objectives |= [index]
  268. # Sort from lowest index to highest index
  269. @failed_objectives.sort!
  270. end
  271. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  272. # * Unfail Objective
  273. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  274. def unfail_objective (index)
  275. @failed_objectives.delete (index)
  276. end
  277. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  278. # * Complete?
  279. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  280. def complete?
  281. # Check if all prime objectives have been completed
  282. return (@complete_objectives & @prime_objectives) == @prime_objectives
  283. end
  284. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  285. # * Failed?
  286. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  287. def failed?
  288. # Check if any prime objectives have been failed
  289. return (@failed_objectives & @prime_objectives) != []
  290. end
  291. end
  292. end
  293.  
  294. #==============================================================================
  295. # ** Ellipse
  296. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  297. # Stores an ellipse object.
  298. #==============================================================================
  299.  
  300. class Ellipse
  301. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  302. # * Public Instance Variables
  303. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  304. attr_reader :a # The width of the oval
  305. attr_reader :b # The Height of the oval
  306. attr_reader :x # the top left x position
  307. attr_reader :y # the top left y position
  308. attr_reader :h # The x position of the origin
  309. attr_reader :k # The y position of the origin
  310. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  311. # * Object Initialization
  312. # x : the top left x position
  313. # y : the top left y position
  314. # a : the width of oval from origin to the side
  315. # b : the height of oval from origin. If nil, then a is radius of circle
  316. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  317. def initialize (x, y, a, b = nil)
  318. @x = x
  319. @y = y
  320. @a = a
  321. @b = b.nil? ? a : b
  322. @h = x a
  323. @k = y @b
  324. end
  325. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  326. # * Within?
  327. # x : the x coordinate being tested
  328. # y : the y coordinate being tested
  329. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  330. def within? (x, y)
  331. x_square = ((x - @h)*(x - @h)).to_f / (@a*@a)
  332. y_square = ((y - @k)*(y - @k)).to_f / (@b*@b)
  333. # If "radius" <= 1, then it must be within the ellipse
  334. return (x_square y_square) <= 1
  335. end
  336. end
  337.  
  338. #==============================================================================
  339. # ** Bitmap
  340. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  341. # This adds the methods fill_ellipse, outline_ellipse, and fill_rounded_rect
  342. #==============================================================================
  343.  
  344. class Bitmap
  345. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  346. # * Outline Ellipse
  347. # ellipse : the ellipse being drawn
  348. # width : the width of the bar
  349. # colour : the colour of the outline
  350. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  351. def outline_ellipse (ellipse, colour = font.color, width = 1, steps = 0)
  352. # For neatness, define local variables a and b to the ellipse variables
  353. a, b = ellipse.a, ellipse.b
  354. # Use Ramanujan's approximation of the Circumference of an ellipse
  355. steps = Math::PI*(3*(a b) - Math.sqrt((3*a b)*(a 3*b))) if steps == 0
  356. radian_modifier = (2*Math::PI) / steps
  357. for i in 0...steps
  358. t = (radian_modifier*i) % (2*Math::PI)
  359. # Expressed parametrically:
  360. # x = h acos(t), y = k bsin(t) : where t ranges from 0 to 2pi
  361. x = (ellipse.h (a*Math.cos(t)))
  362. y = (ellipse.k (b*Math.sin(t)))
  363. set_pixel (x, y, colour)
  364. end
  365. # Thicken the line
  366. if width > 1
  367. ellipse = Ellipse.new (ellipse.x 1, ellipse.y 1, ellipse.a - 1, ellipse.b - 1)
  368. outline_ellipse (ellipse, colour, width - 1, steps)
  369. end
  370. end
  371. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  372. # * Fill Ellipse
  373. # ellipse : the ellipse being drawn
  374. # colour : the colour of the outline
  375. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  376. def fill_ellipse (ellipse, colour = font.color, steps = 0)
  377. # For neatness, define local variables a and b to the ellipse variables
  378. a, b = ellipse.a, ellipse.b
  379. # Use Ramanujan's approximation of the Circumference of an ellipse
  380. steps = Math::PI*(3*(a b) - Math.sqrt((3*a b)*(a 3*b))) if steps == 0
  381. radian_modifier = (2*Math::PI) / steps
  382. for i in 0...(steps / 2)
  383. t = (radian_modifier*i) % (2*Math::PI)
  384. # Expressed parametrically:
  385. # x = h acos(t), y = k bsin(t) : where t ranges from 0 to 2pi
  386. x = ellipse.h (a*Math.cos(t))
  387. y = ellipse.k - (b*Math.sin(t))
  388. fill_rect (x, y, 1, 2*(ellipse.k - y), colour)
  389. end
  390. end
  391. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  392. # * Fill Rounded Rectangle
  393. # rect : the rectangle being drawn
  394. # colour : the colour of the outline
  395. # w : the number of pixels to cover by rounding
  396. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  397. # Used to fill a rectangle with rounded corners
  398. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  399. def fill_rounded_rect (rect, colour = font.color, w = 8)
  400. # Draw Body of the rectangle
  401. fill_rect (rect.x w, rect.y, rect.width - 2*w, rect.height, colour)
  402. # Draw Left Vertical Rect
  403. fill_rect (rect.x, rect.y w, w, rect.height - 2*w, colour)
  404. # Draw Right Vertical Rect
  405. x = rect.x rect.width - w
  406. fill_rect (x, rect.y w, w, rect.height - 2*w, colour)
  407. # Make a circle
  408. circle = Ellipse.new (0, 0, w)
  409. for i in 0...w
  410. for j in 0...w
  411. # Upper Left Corner
  412. set_pixel (rect.x i, rect.y j, colour) if circle.within? (i, j)
  413. # Upper Right Corner
  414. set_pixel (rect.x rect.width - w i, rect.y j, colour) if circle.within? (i w, j)
  415. # Bottom Left Corner
  416. set_pixel (rect.x i, rect.y rect.height - w j, colour) if circle.within? (i, j w)
  417. # Bottom Right Corner
  418. set_pixel (rect.x rect.width - w i, rect.y rect.height - w j, colour) if circle.within? (i w, j w)
  419. end
  420. end
  421. end
  422. end
  423.  
  424. #==============================================================================
  425. # ** Window_VarySizeHelp
  426. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  427. # This window is the same as Window_Help, but with variable size
  428. #==============================================================================
  429.  
  430. class Window_VarySizeHelp < Window_Help
  431. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  432. # * Object Initialization
  433. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  434. def initialize (h_x = 0, h_y = 0, h_width = Graphics.width, h_height = WLH 32)
  435. super ()
  436. self.x, self.y, self.width, self.height = h_x, h_y, h_width, h_height
  437. contents.dispose
  438. self.contents = Bitmap.new (h_width - 32, h_height - 32)
  439. end
  440. end
  441.  
  442. #==============================================================================
  443. # ** Game_System
  444. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  445. # Summary of Changes:
  446. # new instance variables - quest_disabled, quest_keyaccess
  447. # aliased method - initialize
  448. #==============================================================================
  449.  
  450. class Game_System
  451. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  452. # * Public Instance Variables
  453. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  454. attr_accessor :quest_disabled # Can you access quest journal at this time
  455. attr_accessor :quest_keyaccess # Is it accessible by key?
  456. attr_accessor :quest_menuaccess # Is it accessible through the menu
  457. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  458. # * Object Initialization
  459. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  460. alias modalg_qst_jrnl_system_init_quests initialize
  461. def initialize
  462. # Run Original Method
  463. modalg_qst_jrnl_system_init_quests
  464. # Initialize new variables
  465. @quest_disabled = false
  466. @quest_keyaccess = ModAlg_QuestData::KEY_ACCESS
  467. @quest_menuaccess = ModAlg_QuestData::MENU_ACCESS
  468. end
  469. end
  470.  
  471. #==============================================================================
  472. # ** Game_Party
  473. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  474. # Summary of Changes:
  475. # new instance variable - quests
  476. # aliased method - initialize
  477. #==============================================================================
  478.  
  479. class Game_Party
  480. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  481. # * Public Instance Variables
  482. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  483. attr_reader :quests
  484. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  485. # * Object Initialization
  486. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  487. alias modalg_qst_jrnl_party_init_quests initialize
  488. def initialize
  489. # Run Original Method
  490. modalg_qst_jrnl_party_init_quests
  491. # Initialize @quests
  492. @quests = Game_Quests.new
  493. end
  494. end
  495.  
  496. #==============================================================================
  497. # ** Game_Quests
  498. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  499. # This class handles Quests. It is a wrapper for the built-in class "Hash".
  500. # The instance of this class is accessed by $game_party.quests
  501. #==============================================================================
  502.  
  503. class Game_Quests
  504. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  505. # * Object Initialization
  506. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  507. def initialize
  508. @data = {}
  509. end
  510. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  511. # * Get Quest
  512. # quest_id : the ID of the quest
  513. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  514. def [] (quest_id)
  515. @data[quest_id] = ModAlg_QuestData::Quest.new (quest_id) if @data[quest_id] == nil
  516. return @data[quest_id]
  517. end
  518. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  519. # * Get Quest List
  520. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  521. def list
  522. quest_list = @data.values
  523. quest_list.each { |i| quest_list.delete (i) if i.concealed }
  524. return quest_list
  525. end
  526. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  527. # * Get Completed Quest List
  528. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  529. def completed_list
  530. complete_quests = []
  531. list.each { |i| complete_quests.push (i) if i.complete? }
  532. return complete_quests
  533. end
  534. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  535. # * Get Failed Quest List
  536. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  537. def failed_list
  538. failed_quests = []
  539. list.each { |i| failed_quests.push (i) if i.failed? }
  540. return failed_quests
  541. end
  542. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  543. # * Get Active Quest List
  544. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  545. def active_list
  546. return list - failed_list - completed_list
  547. end
  548. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  549. # * Revealed?
  550. # quest_id : the ID of a checked quest
  551. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  552. def revealed? (quest_id)
  553. return @data[quest_id] != nil
  554. end
  555. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  556. # * Remove Quest
  557. # quest_id : the ID of a checked quest
  558. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  559. def remove (quest_id)
  560. @data.delete (quest_id)
  561. end
  562. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  563. # * Clear
  564. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  565. def clear
  566. @data.clear
  567. end
  568. end
  569.  
  570. #==============================================================================
  571. # ** Window_Command
  572. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  573. # Summary of Changes:
  574. # new instance variable - disabled_commands
  575. # aliased method - initialize, draw_item
  576. #==============================================================================
  577.  
  578. class Window_Command
  579. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  580. # * Public Instance Variable
  581. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  582. attr_reader :disabled_commands
  583. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  584. # * Initialize
  585. # width : window width
  586. # commands : command string array
  587. # column_max : digit count (if 2 or more, horizontal selection)
  588. # row_max : row count (0: match command count)
  589. # spacing : blank space when items are arrange horizontally
  590. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  591. alias modalg_quest_jrnl_intlz initialize
  592. def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
  593. # Initialize new instance variable
  594. @disabled_commands = []
  595. # Run Original Method
  596. modalg_quest_jrnl_intlz (width, commands, column_max, row_max, spacing)
  597. end
  598. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  599. # * Draw Item
  600. # index : item number
  601. # enabled : enabled flag. When false, draw semi-transparently
  602. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  603. alias modalg_quest_jrnl_itm_drw draw_item
  604. def draw_item (index, enabled = true)
  605. # Run Original Method
  606. modalg_quest_jrnl_itm_drw (index, enabled)
  607. enabled ? @disabled_commands.delete (index) : @disabled_commands.push (index)
  608. end
  609. end
  610.  
  611. #==============================================================================
  612. # ** Window_Message
  613. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  614. # Summary of Changes:
  615. # aliaed method - convert_special_characters
  616. #==============================================================================
  617.  
  618. class Window_Message
  619. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  620. # * Convert Special Characters
  621. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  622. alias modalg_quest_jrnl_spec_char_convert convert_special_characters
  623. def convert_special_characters
  624. @text.gsub! (/NQ[(d )]/i) { $game_party.quests[$1.to_i] } # Name Quest
  625. # Run Original Method
  626. modalg_quest_jrnl_spec_char_convert
  627. end
  628. end
  629.  
  630. #==============================================================================
  631. # ** Window_QuestLabel
  632. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  633. # This window signifies that this is a quest list
  634. #==============================================================================
  635.  
  636. class Window_QuestLabel < Window_Base
  637. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  638. # * Object Initialization
  639. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  640. def initialize
  641. super (0, 0, 160 WLH, 32 WLH)
  642. create_contents
  643. contents.font.color = system_color
  644. contents.draw_text (0, 0, contents.width, WLH, ModAlg_QuestData::QUESTS_LABEL, 1)
  645. end
  646. end
  647.  
  648. #==============================================================================
  649. # ** Window_QuestCategory
  650. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  651. # This window displays which category is being viewed
  652. #==============================================================================
  653.  
  654. class Window_QuestCategory < Window_Base
  655. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  656. # * Object Initialization
  657. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  658. def initialize
  659. super (0, WLH 32, 160 WLH, 64)
  660. create_contents
  661. end
  662. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  663. # * Refresh
  664. # category_index : icon to highlight -
  665. # 0 => All, 1 => Active, 2 => Complete, 3 => Failed
  666. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  667. def refresh (category_index = 0)
  668. contents.clear
  669. # Retrieve Icon Bitmaps
  670. bitmap = Cache.system("Iconset")
  671. icon_index = ModAlg_QuestData::ACTIVE_QUEST_ICON
  672. active_rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  673. icon_index = ModAlg_QuestData::COMPLETE_QUEST_ICON
  674. complete_rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  675. icon_index = ModAlg_QuestData::FAILED_QUEST_ICON
  676. failed_rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  677. # Combine the three icons for the All Icon
  678. all_icon = Bitmap.new (40, 32)
  679. all_icon.blt (0, 0, bitmap, complete_rect)
  680. all_icon.blt (20, 0, bitmap, failed_rect)
  681. all_icon.blt (8, 10, bitmap, active_rect)
  682. distance = (contents.width - 112) / 3
  683. x = 0
  684. # Draw the 'All' Icon onto the window
  685. contents.blt (x, 0, all_icon, all_icon.rect, category_index == 0 ? 255 : 128)
  686. x = 40 distance
  687. # Draw the 'Active' Icon onto the window
  688. contents.blt (x, 4, bitmap, active_rect, category_index == 1 ? 255 : 128)
  689. x = 24 distance
  690. # Draw the 'Complete' Icon onto the window
  691. contents.blt (x, 4, bitmap, complete_rect, category_index == 2 ? 255 : 128)
  692. x = 24 distance
  693. # Draw the 'Failed' Icon onto the window
  694. contents.blt (x, 4, bitmap, failed_rect, category_index == 3 ? 255 : 128)
  695. end
  696. end
  697.  
  698. #==============================================================================
  699. # ** Window_QuestList
  700. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  701. # This window displays the list of quests
  702. #==============================================================================
  703.  
  704. class Window_QuestList < Window_Selectable
  705. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  706. # * Object Initialization
  707. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  708. def initialize (category_index = 0, index = 0)
  709. super (0, 64 (WLH 32), 160 WLH, Graphics.height - 64 - 2*(WLH 32))
  710. @data = []
  711. @column_max = 1
  712. refresh (category_index)
  713. self.index = index
  714. self.active = true
  715. end
  716. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  717. # * Quest
  718. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  719. def quest
  720. return @data[self.index]
  721. end
  722. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  723. # * Refresh
  724. # category_index : List to show -
  725. # 0 => All, 1 => Active, 2 => Complete, 3 => Failed
  726. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  727. def refresh (category_index = 0)
  728. font = Font.new
  729. @data.clear
  730. self.index = 0
  731. # Get the quest list to be drawn
  732. case category_index
  733. when 0
  734. @data = $game_party.quests.list
  735. when 1
  736. @data = $game_party.quests.active_list
  737. font.color = text_color (ModAlg_QuestData::ACTIVE_COLOUR)
  738. when 2
  739. @data = $game_party.quests.completed_list
  740. font.color = text_color (ModAlg_QuestData::COMPLETE_COLOUR)
  741. when 3
  742. @data = $game_party.quests.failed_list
  743. font.color = text_color (ModAlg_QuestData::FAILED_COLOUR)
  744. end
  745. @item_max = @data.size
  746. unless contents == nil
  747. # Clear Contents
  748. contents.clear
  749. return if @data.empty?
  750. contents.dispose
  751. end
  752. # Create Contents
  753. self.contents = Bitmap.new (width - 32, WLH*@data.size)
  754. contents.font = font
  755. # Draw the Quest Names
  756. quest = @data[i]
  757. # If all, distinguish between quest types by colour
  758. if category_index == 0
  759. if quest.complete?
  760. contents.font.color = text_color (ModAlg_QuestData::COMPLETE_COLOUR)
  761. elsif quest.failed?
  762. contents.font.color = text_color (ModAlg_QuestData::FAILED_COLOUR)
  763. else # Active
  764. contents.font.color = text_color (ModAlg_QuestData::ACTIVE_COLOUR)
  765. end
  766. end
  767. draw_icon (quest.icon_index, 0, i*WLH)
  768. # Draw the name of the quest
  769. contents.draw_text (24, i*WLH, contents.width - 24, WLH, quest.name)
  770. end
  771. end
  772. end
  773.  
  774. #==============================================================================
  775. # ** Window_QuestInfo
  776. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  777. # This window displays the information on the quest being viewed
  778. #==============================================================================
  779.  
  780. class Window_QuestInfo < Window_Base
  781. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  782. # * Object Initialization
  783. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  784. def initialize
  785. super (160 WLH, 0, Graphics.width - (160 WLH), Graphics.height - (32 WLH))
  786. create_contents
  787. end
  788. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  789. # * Refresh
  790. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  791. def refresh (quest = nil)
  792. contents.clear
  793. return if quest == nil
  794. # Draw the name of the Quest, centred
  795. contents.font.color = normal_color
  796. contents.draw_text (0, 0, contents.width, WLH, quest.name, 1)
  797. # If the font has set width characters
  798. if contents.text_size ('w').width == contents.text_size ('i').width
  799. formatter = Paragrapher::Formatter_2.new
  800. else
  801. formatter = Paragrapher::Formatter.new
  802. end
  803. # Format the description
  804. desc_bitmap = Bitmap.new (contents.width - 16, (2.4*WLH).to_i)
  805. desc_bitmap.font.size -= 4
  806. formatted_desc = formatter.format (quest.description, desc_bitmap)
  807. # Draw the Description Box
  808. box_height = [WLH*(formatted_desc.lines.size 1), 3*WLH].min
  809. rect = Rect.new (2, (1.5*WLH).to_i, contents.width - 4, box_height)
  810. contents.fill_rounded_rect (rect, system_color, 10)
  811. rect.x, rect.y = rect.x 2, rect.y 2
  812. rect.width, rect.height = rect.width - 4, rect.height - 4
  813. contents.fill_rounded_rect (rect, Color.new (0, 0, 0, 0), 10)
  814. tw = contents.text_size ('Description').width
  815. # Draw the description signifier
  816. contents.fill_rect (32, (1.5*WLH).to_i, tw 2, 2, Color.new (0, 0, 0, 0))
  817. contents.font.color = system_color
  818. contents.draw_text (33, WLH, tw, WLH, 'Description')
  819. # Paragraph Artist
  820. artist = Paragrapher::Artist.new
  821. # If bitmap is too large
  822. if formatted_desc.lines.size < 2
  823. formatted_desc.bitmap = Bitmap.new (contents.width - 16, formatted_desc.lines.size*WLH)
  824. formatted_desc.bitmap.font.size -= 4
  825. end
  826. bmp = artist.draw (formatted_desc)
  827. # Centre within the box
  828. y = rect.y 4 (rect.height - bmp.height) / 2
  829. contents.blt (8, y, bmp, bmp.rect)
  830. bmp.dispose
  831. y = 2*WLH rect.height 4
  832. # Draw Objectives Signifier Text
  833. contents.font.color = system_color
  834. tw = contents.text_size ('Objectives').width
  835. contents.draw_text (32, y, tw, WLH, 'Objectives')
  836. y = WLH
  837. quest.revealed_objectives.each { |i|
  838. # Get the correct color
  839. contents.font.color = quest.complete_objectives.include? (i) ?
  840. text_color (ModAlg_QuestData::COMPLETE_COLOUR) : quest.failed_objectives.include? (i) ?
  841. text_color (ModAlg_QuestData::FAILED_COLOUR) : text_color (ModAlg_QuestData::ACTIVE_COLOUR)
  842. # Get objective
  843. objective = quest.objectives[i]
  844. # Draw Bullet
  845. tw = contents.text_size (ModAlg_QuestData::BULLET_CHARACTER).width
  846. x = 8
  847. contents.draw_text (x, y, tw, WLH, ModAlg_QuestData::BULLET_CHARACTER)
  848. x = tw 4
  849. # Format the objective
  850. obj_bitmap = Bitmap.new (contents.width - x, 2*WLH)
  851. obj_bitmap.font = contents.font
  852. obj_bitmap.font.size -= 4
  853. formatted_obj = formatter.format (objective, obj_bitmap)
  854. # Draw Objective
  855. bmp = artist.draw (formatted_obj)
  856. contents.blt (x, y 4, bmp, bmp.rect)
  857. # Modify the Y accordingly
  858. y = WLH*([formatted_obj.lines.size, 2].min)
  859. }
  860. end
  861. end
  862.  
  863. #==============================================================================
  864. # ** Scene_Map
  865. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  866. # Summary of Changes:
  867. # aliased method - update
  868. #==============================================================================
  869.  
  870. class Scene_Map < Scene_Base
  871. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  872. # * Frame Update
  873. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  874. alias modalg_quest_journal_map_upd_key_access update
  875. def update
  876. modalg_quest_journal_map_upd_key_access
  877. # If the quest log can be accessed by key and is not empty or disabled
  878. if $game_system.quest_keyaccess && !$game_system.quest_disabled && !$game_party.quests.list.empty?
  879. $scene = Scene_Quest.new if Input.trigger? (ModAlg_QuestData::MAPKEY_BUTTON)
  880. end
  881. end
  882. end
  883.  
  884. #==============================================================================
  885. # ** Scene_Menu
  886. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  887. # Summary of Changes:
  888. # aliased methods - initialize, create_command_window, update_command_selection
  889. #==============================================================================
  890.  
  891. class Scene_Menu < Scene_Base
  892. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  893. # * Object Initialization
  894. # menu_index : command cursor's initial position
  895. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  896. alias modalg_quest_jrnl_init initialize
  897. def initialize(menu_index = 0)
  898. modalg_quest_jrnl_init (menu_index)
  899. return unless $game_system.quest_menuaccess
  900. if @menu_index == 'Quest'
  901. @menu_index = ModAlg_QuestData::MENU_INDEX
  902. elsif @menu_index >= ModAlg_QuestData::MENU_INDEX
  903. @menu_index = 1
  904. end
  905. end
  906. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  907. # * Create Command Window
  908. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  909. alias modalg_quest_journal_menu_cmmnd_win_create create_command_window
  910. def create_command_window
  911. modalg_quest_journal_menu_cmmnd_win_create
  912. # If accessed through map, then don't add it to the menu
  913. return unless $game_system.quest_menuaccess
  914. c = @command_window.commands
  915. c.insert (ModAlg_QuestData::MENU_INDEX, ModAlg_QuestData::QUESTS_LABEL)
  916. width = @command_window.width
  917. disabled = @command_window.disabled_commands
  918. @command_window.dispose
  919. @command_window = Window_Command.new(width, c)
  920. @command_window.index = @menu_index
  921. # Disable all of the old commands as well
  922. disabled.each { |i|
  923. i = 1 if i >= ModAlg_QuestData::MENU_INDEX
  924. @command_window.draw_item (i, false)
  925. }
  926. if $game_system.quest_disabled || $game_party.quests.list.empty? # If Quest Journal disabled
  927. @command_window.draw_item (ModAlg_QuestData::MENU_INDEX, false)
  928. end
  929. end
  930. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  931. # * Update Command Selection
  932. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  933. alias modalg_quest_journal_menu_cmmnd_select_upd update_command_selection
  934. def update_command_selection
  935. if $game_system.quest_menuaccess
  936. changed = false
  937. if @command_window.index == ModAlg_QuestData::MENU_INDEX && Input.trigger? (Input::C)
  938. if $game_system.quest_disabled || $game_party.quests.list.empty? # If Quest Journal disabled
  939. Sound.play_buzzer
  940. else
  941. # Open Quest Window
  942. Sound.play_decision
  943. $scene = Scene_Quest.new
  944. end
  945. return
  946. end
  947. # If the command index is greater than it ought to be, make sure
  948. if @command_window.index > ModAlg_QuestData::MENU_INDEX
  949. @command_window.index = (@command_window.index - 1) % @command_window.commands.size
  950. changed = true
  951. end
  952. end
  953. modalg_quest_journal_menu_cmmnd_select_upd
  954. return unless $game_system.quest_menuaccess
  955. @command_window.index = (@command_window.index 1) % @command_window.commands.size if changed
  956. end
  957. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  958. # * Update Actor Selection
  959. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  960. alias modalg_quest_jrnl_actor_selection_upd update_actor_selection
  961. def update_actor_selection
  962. changed = false
  963. if $game_system.quest_menuaccess && @command_window.index > ModAlg_QuestData::MENU_INDEX
  964. @command_window.index = (@command_window.index - 1) % @command_window.commands.size
  965. changed = true
  966. end
  967. modalg_quest_jrnl_actor_selection_upd
  968. return unless $game_system.quest_menuaccess
  969. @command_window.index = (@command_window.index 1) % @command_window.commands.size if changed
  970. end
  971. end
  972.  
  973. #==============================================================================
  974. # ** Scene_Quest
  975. #------------------------------------------------------------------------------
  976. # This class performs the quest screen processing.
  977. #==============================================================================
  978.  
  979. class Scene_Quest < Scene_Base
  980. #--------------------------------------------------------------------------
  981. # * Object Initialization
  982. # menu_index : command cursor's initial position
  983. #--------------------------------------------------------------------------
  984. def initialize(category_index = 0, quest_index = 0)
  985. @category_index = category_index
  986. @quest_index = quest_index
  987. end
  988. #--------------------------------------------------------------------------
  989. # * Start processing
  990. #--------------------------------------------------------------------------
  991. def start
  992. super
  993. create_menu_background
  994. # Create Windows
  995. @label_window = Window_QuestLabel.new
  996. @category_window = Window_QuestCategory.new
  997. @category_window.refresh (@category_index)
  998. @list_window = Window_QuestList.new (@category_index, @quest_index)
  999. @info_window = Window_QuestInfo.new
  1000. @info_window.refresh (@list_window.quest)
  1001. @help_window = Window_VarySizeHelp.new
  1002. @help_window.y = Graphics.height - @help_window.height
  1003. @help_window.set_text ('Use Horizontal Arrow Keys to change categories', 1)
  1004. end
  1005. #--------------------------------------------------------------------------
  1006. # * Termination Processing
  1007. #--------------------------------------------------------------------------
  1008. def terminate
  1009. super
  1010. dispose_menu_background
  1011. @label_window.dispose
  1012. @category_window.dispose
  1013. @list_window.dispose
  1014. @info_window.dispose
  1015. @help_window.dispose
  1016. end
  1017. #--------------------------------------------------------------------------
  1018. # * Frame Update
  1019. #--------------------------------------------------------------------------
  1020. def update
  1021. super
  1022. update_menu_background
  1023. # Since the only possible activity is from @list_window, put it here
  1024. @list_window.update
  1025. if Input.trigger?(Input::B) # If Button B is pressed
  1026. Sound.play_cancel
  1027. # If Returning to Menu
  1028. if $game_system.quest_menuaccess
  1029. $scene = Scene_Menu.new ('Quest')
  1030. else # Returning to Map
  1031. $scene = Scene_Map.new
  1032. end
  1033. elsif Input.trigger? (Input::C) # If C button is pressed
  1034. # Open Journal (eventually)
  1035. elsif Input.trigger? (Input::LEFT) # If Left direction pressed
  1036. # Play Cursor SE
  1037. Sound.play_cursor
  1038. # Refresh Category Window
  1039. @category_index = (@category_index - 1) % 4
  1040. @category_window.refresh (@category_index)
  1041. @list_window.refresh (@category_index)
  1042. @info_window.refresh (@list_window.quest)
  1043. elsif Input.trigger? (Input::RIGHT) # If Right direction pressed
  1044. # Play Cursor SE
  1045. Sound.play_cursor
  1046. # Refresh Category Window
  1047. @category_index = (@category_index 1) % 4
  1048. @category_window.refresh (@category_index)
  1049. @list_window.refresh (@category_index)
  1050. @info_window.refresh (@list_window.quest)
  1051. # If scrolling through quests
  1052. elsif Input.trigger? (Input::DOWN) || Input.trigger? (Input::UP)
  1053. # Refresh Info Window
  1054. @info_window.refresh (@list_window.quest)
  1055. end
  1056. end
  1057. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement