pigu_6

MR.Bubble|Tactics ogre craft system 1.3

Nov 23rd, 2012
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 118.63 KB | None | 0 0
  1. # ╔══════════════════════════════════════════════════════╤═══════╤═══════════╗
  2. # ║ Tactics Ogre PSP Crafting System │ v1.13 │ (3/26/13) ║
  3. # ╚══════════════════════════════════════════════════════╧═══════╧═══════════╝
  4. # Script by:
  5. # Mr. Bubble ( http://mrbubblewand.wordpress.com/ )
  6. # Thanks:
  7. # Mithran, regexp references
  8. #--------------------------------------------------------------------------
  9. # This item crafting script is modeled after the crafting system implemented
  10. # in the PSP remake of Tactics Ogre: Let Us Cling Together. It's a very
  11. # simple crafting system with a very simple GUI which I also used as
  12. # a model.
  13. #
  14. # Players must have recipe books in their inventory when entering the
  15. # crafting scene. Any recipe books owned by the player will be displayed
  16. # in a list. When a recipe book is selected, all possible items, armors,
  17. # and weapons in the recipe book will be listed and you will be able to
  18. # craft them provided that the player has the necessary ingredients.
  19. #
  20. # The script "Reader Functions for Features/Effects" v1.2 or above is
  21. # required to display item info with this script, but is optional in
  22. # terms of this script's ability to function.
  23. #
  24. # Feel free to reguest custom information to be added to item info pages
  25. # in the crafting scene.
  26. #--------------------------------------------------------------------------
  27. # ++ Changelog ++
  28. #--------------------------------------------------------------------------
  29. # v1.13 : Bugfix: Custom craft result sound effects should no longer
  30. # : crash the game.
  31. # : Equippable members info page added.
  32. # : Cleaned up some code. (3/26/13)
  33. # v1.12 : Quick compatibility update with Tsukihime's TO Crafting Shop
  34. # : script. (3/13/13)
  35. # v1.11 : You can now require specific actors in the party as a crafting
  36. # : requirement.
  37. # : New ingredient notetag added.
  38. # : New options in the customization module added.
  39. # : Slight code efficiency update. (2/06/2013)
  40. # v1.10 : TP Recovery now displays the correct value.
  41. # : Recipebook images are now centered by default. (9/04/2012)
  42. # v1.9 : State resistance item info is now viewable.
  43. # : Footer text is now properly aligned. (8/28/2012)
  44. # v1.8 : Compatibility: "YEA-AceMenuEngine" support added.
  45. # : You can now view item details in the crafting scene if the
  46. # : script "Reader Functions for Features/Effects" is installed.
  47. # : Info window style has changed.
  48. # : Any amount of ingredients can now be displayed, not just 6.
  49. # : Configuration module has many new settings.
  50. # : Some method names have changed.
  51. # : Removed a chunk of redundant code.
  52. # : Efficiency update. (8/25/2012)
  53. # v1.7 : Fixed issue where you can still craft from a recipebook even if
  54. # : you have zero left as a result of using it in a crafting recipe.
  55. # : Script call for the crafting scene has changed. The old one can
  56. # : still be used though.
  57. # : New Notetag for recipebooks added.
  58. # : You can now choose which recipebooks can be included in the
  59. # : crafting scene by category.
  60. # : Efficiency update. (8/18/2012)
  61. # v1.6 : Compatibility: "XAS VX Ace" support added. (8/08/2012)
  62. # v1.5 : You can now change the recipebook pictures directory.
  63. # : You can now assign sound effects for crafted items.
  64. # : Slight code efficiency update. (7/29/2012)
  65. # v1.4 : Added the option to use images as recipebook covers.
  66. # : New Notetag for recipebooks added.
  67. # : New option in customization module for book images. (7/27/2012)
  68. # v1.3 : Colon between type and ID no longer needed.
  69. # : Updated comments to reflect changes.
  70. # : Tool regexp updated. (7/27/2012)
  71. # v1.2 : You can now change the Gold icon in the customization module.
  72. # : You can now change the name of Gold in windows. (7/27/2012)
  73. # v1.1 : Fixed issue with long item names getting cut off in windows.
  74. # : Confirm window removed.
  75. # : Quantity selection window implemented.
  76. # : Crafting Gold fee implemented.
  77. # : Crafting tool requirement implemented.
  78. # : New options added in customization module. (7/26/2012)
  79. # v1.0 : Initial release. (7/25/2012)
  80. #--------------------------------------------------------------------------
  81. # ++ Installation ++
  82. #--------------------------------------------------------------------------
  83. # Install this script in the Materials section in your project's
  84. # script editor.
  85. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  86. # ++ Notetags ++
  87. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  88. # Note: Some tags are given shorter tags for typing convenience. You only
  89. # need to use one <tag> from a given group for a notebox.
  90. # Use common sense.
  91. #
  92. # The following Notetags are for Items, Weapons, and Armors only:
  93. #
  94. # <recipebook>
  95. # setting
  96. # setting
  97. # </recipebook>
  98. # This tag allows you define a recipe book. You can add as many
  99. # settings between the <recipebook> tags as you like. Only items with
  100. # this tag will appear in the recipes window in the crafting scene.
  101. # The following settings are available:
  102. #
  103. # item: id
  104. # item: id, id, id ...
  105. # i: id
  106. # i: id, id, id ...
  107. # This setting defines the items that can be crafted from the
  108. # recipe book where id is the Item ID number found in your database.
  109. # You can list multiple id numbers on the same line separated by commas.
  110. # This setting can be used multiple times within the <recipebook> tags.
  111. #
  112. # weapon: id
  113. # weapon: id, id, id ...
  114. # w: id
  115. # w: id, id, id ...
  116. # This setting defines the weapons that can be crafted from the
  117. # recipe book where id is the Weapon ID number found in your database.
  118. # You can list multiple id numbers on the same line separated by commas.
  119. # This setting can be used multiple times within the <recipebook> tags.
  120. #
  121. # armor: id
  122. # armor: id, id, id ...
  123. # armour: id
  124. # armour: id, id, id ...
  125. # a: id
  126. # a: id, id, id ...
  127. # This setting defines the armors that can be crafted from the
  128. # recipe book where id is the Armor ID number found in your database.
  129. # You can list multiple id numbers on the same line separated by commas.
  130. # This setting can be used multiple times within the <recipebook> tags.
  131. #
  132. # picture: filename
  133. # pic: filename
  134. # cover: filename
  135. # This setting defines the image used to represent the recipe book
  136. # in the crafting scene where filename is the name of a picture
  137. # located in the Graphics/Pictures/ folder of your project. Do
  138. # not include the filename's extension. Recommended picture
  139. # resolutions are [width: 248, height: 320] for default resolutions
  140. # and [width: 296, height: 384] for 480x640 resolutions.
  141. #
  142. # category: name
  143. # This setting defines the recipebook's category label. Category
  144. # labels are used by developers to determine which recipebooks
  145. # they want included in the crafting scene. If a category label is
  146. # not defined, the default category is "none". This is a completely
  147. # optional setting.
  148. #
  149. # <ingredients>
  150. # setting
  151. # setting
  152. # </ingredients>
  153. # This tag allows you define the ingredients required to craft an item.
  154. # You can add as many settings between the <ingredients> tags as you like.
  155. # If an item, weapon, or armor has no ingredients, you can still craft it.
  156. # The following settings are available:
  157. #
  158. # item: id
  159. # item: id xN
  160. # i: id
  161. # i: id xN
  162. # This setting defines the item ingredients required to craft the
  163. # item, weapon, or armor where id is the Item ID number found in
  164. # your database. xN is total number of that ingredient required if
  165. # it is included after the id number where N is a whole number
  166. # (ex. x2, x3, x4, etc.). If xN is not included, the script will
  167. # automatically assume x1. You can list multiple id numbers on the
  168. # same line separated by commas. This setting can be used multiple
  169. # times within the <ingredients> tags.
  170. #
  171. # weapon: id
  172. # weapon: id xN
  173. # w: id
  174. # w: id xN
  175. # This setting defines the weapon ingredients required to craft the
  176. # item, weapon, or armor where id is the Weapon ID number found in
  177. # your database. xN is total number of that ingredient required if
  178. # it is included after the id number where N is a whole number
  179. # (ex. x2, x3, x4, etc.). If xN is not included, the script will
  180. # automatically assume x1. You can list multiple id numbers on the
  181. # same line separated by commas. This setting can be used multiple
  182. # times within the <ingredients> tags.
  183. #
  184. # armor: id
  185. # armor: id xN
  186. # armour: id
  187. # armour: id xN
  188. # a: id
  189. # a: id xN
  190. # This setting defines the armor ingredients required to craft the
  191. # item, weapon, or armor where id is the Weapon ID number found in
  192. # your database. xN is total number of that ingredient required if
  193. # it is included after the id number where N is a whole number
  194. # (ex. x2, x3, x4, etc.). If xN is not included, the script will
  195. # automatically assume x1. You can list multiple id numbers on the
  196. # same line separated by commas. This setting can be used multiple
  197. # times within the <ingredients> tags.
  198. #
  199. # gold: amount
  200. # This setting defines the amount of Gold required to craft
  201. # the item, armor, or weapon where amount is any amount of gold.
  202. # If this setting is omitted, it will use the default fee defined
  203. # in the customization module.
  204. #
  205. # tool: item id
  206. # tool: i id
  207. # tool: weapon id
  208. # tool: w id
  209. # tool: armor id
  210. # tool: armour id
  211. # tool: a id
  212. # This setting defines the tools required to craft the item, weapon,
  213. # or armor where id is the item, weapon, or armor ID number found in
  214. # your database. Tools are not consumed in the crafting process.
  215. # This setting can be used multiple times within the <ingredients>
  216. # tags.
  217. #
  218. # actor: actor_id
  219. # This setting defines the actor required to craft the item, weapon,
  220. # or armor where actor_id is the actor ID number from your database.
  221. # Currently, nothing happens to the actor after crafting an item
  222. # that requires one. This setting can be used multiple times within
  223. # the <ingredients> tags.
  224. #
  225. # se: filename, volume, pitch
  226. # This setting defines the custom sound effect played when the
  227. # item is crafted. filename is a sound effect filename found in
  228. # the Audio/SE/ folder. volume is a value between 0~100. pitch is
  229. # a value between 50~150. If this setting is omitted, the default
  230. # crafting sound effect defined in the customization module will
  231. # play instead.
  232. #
  233. # Here are some examples of proper <recipebook> tags and <ingredients> tags:
  234. #
  235. # <recipebook>
  236. # weapon: 1, 2, 7, 8, 13, 14, 19, 20
  237. # weapon: 25, 37, 38
  238. # armor: 1, 2, 3, 4, 5
  239. # item: 40
  240. # </recipebook>
  241. #
  242. # It is important to know that Note boxes have iffy word wrap distinction.
  243. # If a line is too long and overflows into the next line, that next line
  244. # might be treated as a new line in the Note box. To stay on the safe side,
  245. # if you have a long list of ids for a single item type setting, you
  246. # should start the next line with the similar type setting. See the
  247. # "weapon:" settings in this example tag.
  248. #
  249. # <ingredients>
  250. # item: 29 x3
  251. # item: 30 x2
  252. # item: 31
  253. # </ingredients>
  254. #
  255. # Each ingredient id must be on its own line, unlike the recipebook tag.
  256. # More than 6 ingredients are possible, but the Required Ingredients
  257. # window will not display more than 6. The last setting tag "item: 31" does
  258. # not have an "xN" multiplier which means the script will automatically
  259. # assume "x1".
  260. #
  261. # <ingredients>
  262. # fee: 30
  263. # se: Bell3, 80, 100
  264. # tool: item 40
  265. # item: 21
  266. # item: 22 x2
  267. # </ingredients>
  268. #
  269. # This tag is an example of how to use the "fee" and "tool" setting tags.
  270. # Item ID 40 is required to craft the item, but it will not be consumed.
  271. # Each item crafted costs 30 gold. The sound effect Bell3 will play
  272. # when the item is crafted.
  273. #
  274. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  275. # ++ Script Calls ++
  276. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  277. # The following Script Calls are meant to be used in "Script..." event
  278. # commands found under Tab 3 when creating a new event.
  279. #
  280. # call_tocrafting_scene
  281. # This script call opens up a Tactics Ogre Crafting scene with all
  282. # recipebooks the player has in their inventory.
  283. #
  284. # call_tocrafting_scene( :category, :category, ...)
  285. # This script call opens up the Tactics Ogre Crafting scene with
  286. # only recipebooks that have the category included in one of the
  287. # script call's arguments. You can list as many categories in the
  288. # script call's arguments separated by commas as you like. Category
  289. # names must always be preceeded by a colon (:).
  290. #
  291. # Here is an example of a script call using call_tocrafting_scene with
  292. # category arguments:
  293. #
  294. # call_tocrafting_scene( :smithing )
  295. #
  296. # This script call will open up the crafting scene with only recipebooks
  297. # that have the category of "smithing".
  298. #
  299. #--------------------------------------------------------------------------
  300. # ++ FAQ ++
  301. #--------------------------------------------------------------------------
  302. # --Why am I allowed to craft items that have no required ingredients?
  303. #
  304. # This was done on purpose to ease game development. I assumed that
  305. # when people finalize a game, they will have an appropriate list of
  306. # ingredients for each craftable item defined by then.
  307. #
  308. # --Can an item/armor/weapon have a <recipebook> tag AND an <ingredients>
  309. # tag?
  310. #
  311. # Yes.
  312. #
  313. # --Why isn't "Success Rate" also implemented in this script from
  314. # Tactics Ogre PSP?
  315. #
  316. # Because I think Success Rate on crafting in single-player games
  317. # is annoying and pointless due to save and load. But if there is
  318. # demand for it, I can implement it.
  319. #--------------------------------------------------------------------------
  320. # ++ Compatibility ++
  321. #--------------------------------------------------------------------------
  322. # This script aliases the following default VXA methods:
  323. #
  324. # DataManager#load_database
  325. #
  326. # There are no default method overwrites.
  327. #
  328. # This script has built-in compatibility with the following scripts:
  329. #
  330. # -Xiderwong Action System (XAS) VX Ace
  331. # -Yanfly Engine Ace - Ace Menu Engine
  332. #
  333. # Requests for compatibility with other scripts are welcome.
  334. #--------------------------------------------------------------------------
  335. # ++ Terms and Conditions ++
  336. #--------------------------------------------------------------------------
  337. # Please do not repost this script elsewhere without permission.
  338. # Free for non-commercial use. For commercial use, contact me first.
  339. #
  340. # Newest versions of this script can be found at
  341. # http://mrbubblewand.wordpress.com/
  342. #=============================================================================
  343.  
  344. $imported ||= {}
  345. $imported["BubsTOCrafting"] = true
  346.  
  347. #==========================================================================
  348. # ++ START OF USER CUSTOMIZATION MODULE ++
  349. #==========================================================================
  350. module Bubs
  351. #==========================================================================
  352. # ++ TO Crafting Settings
  353. #==========================================================================
  354. module TOCrafting
  355. #--------------------------------------------------------------------------
  356. # Ingredients List Display Settings
  357. #--------------------------------------------------------------------------
  358. INGREDIENTS_HEADER_TEXT = "Ingredients" # Header text
  359. INGREDIENTS_PAGE_SIZE = 5 # 6 is recommended for 640x480 resolutions
  360. NOT_ENOUGH_INGREDIENTS_COLOR = 10 # Windowskin color index, default 10 (red)
  361.  
  362. #--------------------------------------------------------------------------
  363. # Info Page Footer Text
  364. #--------------------------------------------------------------------------
  365. # Recommended length: 22 characters " "
  366. NORMAL_FOOTER_TEXT = "← →"
  367. INGREDIENTS_VIEW_MORE_FOOTER_TEXT = "← Shift: More... →"
  368.  
  369. #--------------------------------------------------------------------------
  370. # Tools Display Settings
  371. #--------------------------------------------------------------------------
  372. TOOL_AVAILABLE_TEXT = "Available"
  373. TOOL_AVAILABLE_TEXT_COLOR = 3 # Windowskin color index, default 3 (green)
  374. TOOL_UNAVAILABLE_TEXT = "Unavailable"
  375. TOOL_UNAVAILABLE_TEXT_COLOR = 10 # Windowskin color index, default 10 (red)
  376.  
  377. #--------------------------------------------------------------------------
  378. # Faded Requirement Not Met Display Settings
  379. #--------------------------------------------------------------------------
  380. # true : Ingredient quantity and Tool requirement text will be faded
  381. # out like the item name if the requirement isn't met
  382. # false : Ingredient quantity and Tool requirement text will not be faded
  383. FADED_REQUIREMENT_QUANTITY = false
  384.  
  385. #--------------------------------------------------------------------------
  386. # Crafting Gold Fee Default Markdown/Markup Rate
  387. #--------------------------------------------------------------------------
  388. # If a "gold: amount" setting is not included in an <ingredients> tag,
  389. # it will use the item's Price in the database by default. This setting
  390. # allows you to automatically increase or decrease that item, armor
  391. # or weapon price by a specified rate where 100.0 is normal price and
  392. # 0.0 is free.
  393. CRAFTING_FEE_PRICE_RATE = 0.0
  394. #--------------------------------------------------------------------------
  395. # Gold Window Settings
  396. #--------------------------------------------------------------------------
  397. # true : Gold window appears in crafting scene
  398. # false : Gold crafting fees appear in ingredients list, no gold window
  399. USE_GOLD_WINDOW = true
  400. GOLD_WINDOW_ICON_INDEX = 361 # Icon Index number
  401. GOLD_WINDOW_TEXT = "Gold"
  402.  
  403. #--------------------------------------------------------------------------
  404. # Crafting Result Header Text
  405. #--------------------------------------------------------------------------
  406. RESULT_WINDOW_HEADER_TEXT = "You Received"
  407.  
  408. #--------------------------------------------------------------------------
  409. # Stretch Recipebook Pictures Setting
  410. #--------------------------------------------------------------------------
  411. # Recommended width and height for book covers images:
  412. #
  413. # width: 248, height: 320 (default resolutions)
  414. # width: 296, height: 384 (480x640 resolutions)
  415. #
  416. # true : Book cover pics are stretched to fit the contents of the window.
  417. # false : Book cover pics are drawn normally.
  418. STRETCH_RECIPEBOOK_PICTURES = false
  419. #--------------------------------------------------------------------------
  420. # Recipebook Images Folder Directory
  421. #--------------------------------------------------------------------------
  422. # Project folder where recipebook pictures are located.
  423. #
  424. # Default: "Graphics/Pictures/"
  425. RECIPEBOOK_PICTURES_DIRECTORY = "Graphics/Pictures/"
  426.  
  427. #--------------------------------------------------------------------------
  428. # Default Crafting Result Sound Effect
  429. #--------------------------------------------------------------------------
  430. # Filename : SE filename in Audio/SE/ folder
  431. # Volume : Between 0~100
  432. # Pitch : Between 50~150
  433. #
  434. # Filename, Volume, Pitch
  435. CRAFTING_RESULT_SE = [ "Bell2", 80, 100]
  436.  
  437. #--------------------------------------------------------------------------
  438. # Actor Icon Index Numbers
  439. #--------------------------------------------------------------------------
  440. # This setting lets you define the icon index number that represents
  441. # an actor in info windows.
  442. ACTOR_ICONS = {
  443. :default => 16,
  444. # actor_id => icon_index,
  445. 1 => 16,
  446. } # <- Do not delete.
  447.  
  448. #--------------------------------------------------------------------------
  449. # Actor Requirement Display Settings
  450. #--------------------------------------------------------------------------
  451. ACTOR_AVAILABLE_TEXT = "Available"
  452. ACTOR_AVAILABLE_TEXT_COLOR = 3 # Windowskin color index, default 3 (green)
  453. ACTOR_UNAVAILABLE_TEXT = "Unavailable"
  454. ACTOR_UNAVAILABLE_TEXT_COLOR = 10 # Windowskin color index, default 10 (red)
  455.  
  456.  
  457. #--------------------------------------------------------------------------
  458. # Item Info Pages
  459. #--------------------------------------------------------------------------
  460. # This setting determines the order of info pages for usable items.
  461. # Each kind of info page is represented by a symbol. Possible symbols
  462. # include:
  463. #
  464. # :item_info # Requires "Reader Functions for Features/Effects"
  465. ITEM_INFO_PAGES = [:ingredients, # Page 1 (Required as 1st page)
  466. :item_info, # Page 2
  467. ] # <- Do not delete.
  468.  
  469. #--------------------------------------------------------------------------
  470. # Equip Info Page List
  471. #--------------------------------------------------------------------------
  472. # This setting determines the order of info pages for equippable items.
  473. # Each kind of info page is represented by a symbol. Possible symbols
  474. # include:
  475. #
  476. # :equippable_info
  477. # :param_info # Requires "Reader Functions for Features/Effects"
  478. # :attack_info # Requires "Reader Functions for Features/Effects"
  479. # :element_info # Requires "Reader Functions for Features/Effects"
  480. # :state_info # Requires "Reader Functions for Features/Effects"
  481. EQUIP_INFO_PAGES = [:ingredients, # Page 1 (Required as 1st page)
  482. :param_info, # Page 2
  483. :attack_info, # Page 3
  484. :element_info, # Page 4
  485. :state_info, # Page 5
  486. :equippable_info, # Page 6
  487. ] # <- Do not delete.
  488.  
  489. #--------------------------------------------------------------------------
  490. # Info Page Header Text
  491. #--------------------------------------------------------------------------
  492. INFO_PAGE_HEADER_TEXT = {
  493. # General
  494. :main_header => "Information",
  495. # Weapons and Armor
  496. :atk_elements => "Attack Elements",
  497. :atk_speed => "Attack Speed",
  498. :atk_times_add => "Number of Attacks",
  499. :atk_states => "Attack States",
  500. :element_rate => "Element Resistances",
  501. :state_rate => "State Resistances",
  502. :state_resist_set => "State Immunity",
  503. :equippable => "Equippable Members",
  504. # Items
  505. :hp_recovery => "HP Recovery",
  506. :mp_recovery => "MP Recovery",
  507. :tp_recovery => "TP Recovery",
  508. :add_states => "Adds",
  509. :remove_states => "Removes",
  510. } # <- Do not delete.
  511.  
  512. #--------------------------------------------------------------------------
  513. # Element Icon Index Numbers
  514. #--------------------------------------------------------------------------
  515. # This setting lets you define the icon index number that represents
  516. # an element in info pages
  517. #
  518. # Requires "Reader Functions for Features/Effects" to see effects.
  519. ELEMENT_ICONS = {
  520. 1 => 116, # Physical
  521. 2 => 113, # Absorb
  522. 3 => 96, # Fire
  523. 4 => 97, # Ice
  524. 5 => 98, # Thunder
  525. 6 => 99, # Water
  526. 7 => 100, # Earth
  527. 8 => 101, # Wind
  528. 9 => 102, # Light
  529. 10 => 103, # Dark
  530. } # <- Do not delete.
  531.  
  532. #--------------------------------------------------------------------------
  533. # Element ID List for Info Page
  534. #--------------------------------------------------------------------------
  535. # This setting determines which elements are seen in an item's element
  536. # info page where each number in the array is an Element ID number from
  537. # your database.
  538. #
  539. # Requires "Reader Functions for Features/Effects" to see effects.
  540. DISPLAYED_ELEMENT_RESISTS = [1,2,3,4,5,6,7,8,9,10]
  541.  
  542. #--------------------------------------------------------------------------
  543. # State ID List for Info Page
  544. #--------------------------------------------------------------------------
  545. # This setting determines which states are seen in an item's state
  546. # info page where each number in the array is a State ID number from
  547. # your database.
  548. #
  549. # Requires "Reader Functions for Features/Effects" to see effects.
  550. DISPLAYED_STATE_RESISTS = [1,2,3,4,5,6,7,8]
  551.  
  552. #--------------------------------------------------------------------------
  553. # Change Info Page Buttons
  554. #--------------------------------------------------------------------------
  555. # These settings determine which gamepad buttons change the info
  556. # window page. Possible buttons include :LEFT, :RIGHT, :UP, :DOWN,
  557. # :A, :B, :C, :X, :Y, :Z, :L, :R
  558. PREV_PAGE_BUTTON = :LEFT
  559. NEXT_PAGE_BUTTON = :RIGHT
  560.  
  561. #--------------------------------------------------------------------------
  562. # Change Ingredident Page Button
  563. #--------------------------------------------------------------------------
  564. # This setting determine which gamepad button changes the ingredient
  565. # window page. Possible buttons include :LEFT, :RIGHT, :UP, :DOWN,
  566. # :A, :B, :C, :X, :Y, :Z, :L, :R
  567. NEXT_INGREDIENT_PAGE_BUTTON = :A
  568.  
  569. #--------------------------------------------------------------------------
  570. # Page Change Sound Effect
  571. #--------------------------------------------------------------------------
  572. # Filename : SE filename in Audio/SE/ folder
  573. # Volume : Between 0~100
  574. # Pitch : Between 50~150
  575. #
  576. # Filename, Volume, Pitch
  577. PAGE_CHANGE_SE = ["Cursor1", 80, 100]
  578.  
  579. #--------------------------------------------------------------------------
  580. # YEA Ace Menu Engine - Custom Menu Command Setting
  581. #--------------------------------------------------------------------------
  582. # This setting only takes effect when YEA - Ace Menu Engine is installed
  583. # in the same project.
  584. #
  585. # To add the TOCrafting scene to Ace Menu Engine, look for a
  586. # configuration setting called "- Main Menu Settings -". There is a
  587. # variable called COMMANDS that has an array of orange symbols. Add
  588. # the symbol :tocrafting to the COMMANDS array to add the crafting
  589. # command to your menu.
  590. #
  591. # The setting here working exactly the same as the CUSTOM_COMMAND
  592. # setting in Ace Menu Engine. For more information, please refer to
  593. # the Ace Menu Engine script.
  594. TOCRAFTING_CUSTOM_COMMAND = {
  595. # ["Display Name", EnableSwitch, ShowSwitch, Handler Method],
  596. :tocrafting => [ "Crafting", 0, 0, :command_tocrafting],
  597. } # <- Do not delete.
  598.  
  599. end # module TOCrafting
  600. end # module Bubs
  601.  
  602. #==========================================================================
  603. # ++ END OF USER CUSTOMIZATION MODULE ++
  604. #==========================================================================
  605.  
  606.  
  607. #==============================================================================
  608. # ++ Sound
  609. #==============================================================================
  610. module Sound
  611. #--------------------------------------------------------------------------
  612. # new method : play_tocrafting_result
  613. #--------------------------------------------------------------------------
  614. def self.play_tocrafting_result
  615. filename = Bubs::TOCrafting::CRAFTING_RESULT_SE[0]
  616. volume = Bubs::TOCrafting::CRAFTING_RESULT_SE[1]
  617. pitch = Bubs::TOCrafting::CRAFTING_RESULT_SE[2]
  618. Audio.se_play("Audio/SE/" + filename, volume, pitch)
  619. end
  620.  
  621. #--------------------------------------------------------------------------
  622. # new method : play_custom_tocrafting_result
  623. #--------------------------------------------------------------------------
  624. def self.play_custom_tocrafting_result(filename, volume, pitch)
  625. Audio.se_play("Audio/SE/" + filename, volume, pitch)
  626. end
  627.  
  628. #--------------------------------------------------------------------------
  629. # new method : play_page_change
  630. #--------------------------------------------------------------------------
  631. def self.play_page_change
  632. filename = Bubs::TOCrafting::PAGE_CHANGE_SE[0]
  633. volume = Bubs::TOCrafting::PAGE_CHANGE_SE[1]
  634. pitch = Bubs::TOCrafting::PAGE_CHANGE_SE[2]
  635. Audio.se_play("Audio/SE/" + filename, volume, pitch)
  636. end
  637. end # module Sound
  638.  
  639.  
  640. #==============================================================================
  641. # ++ Cache
  642. #==============================================================================
  643. module Cache
  644. #--------------------------------------------------------------------------
  645. # new method : recipebook_cover
  646. #--------------------------------------------------------------------------
  647. def self.recipebook_cover(filename)
  648. load_bitmap(Bubs::TOCrafting::RECIPEBOOK_PICTURES_DIRECTORY, filename)
  649. end
  650. end # module Cache
  651.  
  652.  
  653. #==========================================================================
  654. # ++ Bubs::Regexp
  655. #==========================================================================
  656. module Bubs
  657. module Regexp
  658. RECIPEBOOK_START_TAG = /<RECIPE[_\s]?BOOK>/i
  659. RECIPEBOOK_END_TAG = /<\/RECIPE[_\s]?BOOK>/i
  660. RECIPEBOOK_OBJ_TAG = /(\w+):\s*(\d+(?:\s*,\s*\d+)*)/i
  661. RECIPEBOOK_COVER_TAG = /(?:PICTURE|PIC|COVER):\s*(\w+)/i
  662. RECIPEBOOK_CATEGORY_TAG = /category?:\s*(\w+)/i
  663.  
  664. INGREDIENT_START_TAG = /<INGREDIENTS?>/i
  665. INGREDIENT_END_TAG = /<\/INGREDIENTS?>/i
  666. INGREDIENT_OBJ_TAG = /(\w+):\s*[×x]?(\d+)\s*[×x]?(\d+)?/i
  667.  
  668. REQUIRED_TOOLS_TAG = /TOOLS?:\s*(\w+)\s*(\d+)/i
  669.  
  670. CRAFTING_CUSTOM_SE_TAG = /SE:\s*(\w+)\s*,\s*(\d+)\s*,\s*(\d+)/i
  671. CRAFTING_AMOUNT_TAG = /<CRAFT[_\s]*(?:AMOUNT|amt):\s*[x]*(\d+)\s*>/i
  672. end # module Regexp
  673. end # module Bubs
  674.  
  675.  
  676. #==========================================================================
  677. # ++ DataManager
  678. #==========================================================================
  679. module DataManager
  680. #--------------------------------------------------------------------------
  681. # alias : load_database
  682. #--------------------------------------------------------------------------
  683. class << self; alias load_database_bubs_tocrafting load_database; end
  684. def self.load_database
  685. load_database_bubs_tocrafting # alias
  686. load_notetags_bubs_tocrafting
  687. end
  688.  
  689. #--------------------------------------------------------------------------
  690. # new method : load_notetags_bubs_tocrafting
  691. #--------------------------------------------------------------------------
  692. def self.load_notetags_bubs_tocrafting
  693. groups = [$data_items, $data_weapons, $data_armors]
  694. for group in groups
  695. for obj in group
  696. next if obj.nil?
  697. obj.load_notetags_bubs_tocrafting
  698. end # for obj
  699. end # for group
  700. end # def
  701.  
  702. end # module DataManager
  703.  
  704.  
  705. #==========================================================================
  706. # ++ RPG::BaseItem
  707. #==========================================================================
  708. class RPG::BaseItem
  709. #--------------------------------------------------------------------------
  710. # public instance variables
  711. #--------------------------------------------------------------------------
  712. attr_accessor :recipe_list
  713. attr_accessor :ingredient_list
  714. attr_accessor :tocrafting_tools
  715. attr_accessor :tocrafting_actors
  716. attr_accessor :tocrafting_skills
  717. attr_accessor :tocrafting_gold_fee
  718. attr_accessor :tocrafting_bookcover
  719. attr_accessor :tocrafting_se
  720. attr_accessor :tocrafting_category
  721. attr_accessor :tocrafting_amount
  722. #--------------------------------------------------------------------------
  723. # common cache : load_notetags_bubs_tocrafting
  724. #--------------------------------------------------------------------------
  725. def load_notetags_bubs_tocrafting
  726. @recipe_list = []
  727. @ingredient_list = []
  728. @tocrafting_tools = []
  729. @tocrafting_actors = []
  730. @tocrafting_skills = []
  731. @tocrafting_gold_fee = self.price
  732. @tocrafting_bookcover = ""
  733. @tocrafting_se = []
  734. @tocrafting_category = :none
  735. @tocrafting_amount = 1
  736.  
  737. load_notetags_default_fee_bubs_tocrafting
  738.  
  739. recipe_tag = false
  740. ingredient_tag = false
  741.  
  742. self.note.split(/[\r\n]+/).each { |line|
  743. case line
  744. when Bubs::Regexp::RECIPEBOOK_START_TAG
  745. recipe_tag = true
  746. when Bubs::Regexp::RECIPEBOOK_END_TAG
  747. recipe_tag = false
  748.  
  749. when Bubs::Regexp::INGREDIENT_START_TAG
  750. ingredient_tag = true
  751. when Bubs::Regexp::INGREDIENT_END_TAG
  752. ingredient_tag = false
  753.  
  754. when Bubs::Regexp::CRAFTING_AMOUNT_TAG
  755. @tocrafting_amount = $1.to_i
  756.  
  757. when Bubs::Regexp::RECIPEBOOK_COVER_TAG
  758. next unless recipe_tag
  759. @tocrafting_bookcover = $1
  760.  
  761. when Bubs::Regexp::RECIPEBOOK_CATEGORY_TAG
  762. next unless recipe_tag
  763. @tocrafting_category = $1.to_sym
  764.  
  765. when Bubs::Regexp::REQUIRED_TOOLS_TAG
  766. next unless ingredient_tag
  767. load_notetags_tools_bubs_tocrafting(line)
  768.  
  769. when Bubs::Regexp::CRAFTING_CUSTOM_SE_TAG
  770. next unless ingredient_tag
  771. @tocrafting_se = [$1, $2.to_i, $3.to_i]
  772.  
  773. else
  774. load_notetags_recipelist_bubs_tocrafting(line) if recipe_tag
  775. load_notetags_ingredients_bubs_tocrafting(line) if ingredient_tag
  776. end # case
  777. } # self.note.split
  778. @recipe_list.compact!
  779. @ingredient_list.compact!
  780. @tocrafting_tools.compact!
  781. @tocrafting_actors.compact!
  782. @tocrafting_skills.compact!
  783. end # load_notetags_bubs_tocrafting
  784.  
  785. #--------------------------------------------------------------------------
  786. # common cache : load_notetags_default_fee_bubs_tocrafting
  787. #--------------------------------------------------------------------------
  788. def load_notetags_default_fee_bubs_tocrafting
  789. rate = Bubs::TOCrafting::CRAFTING_FEE_PRICE_RATE
  790. @tocrafting_gold_fee = (@tocrafting_gold_fee * (rate * 0.01)).to_i
  791. end
  792.  
  793. #--------------------------------------------------------------------------
  794. # common cache : load_notetags_recipelist_bubs_tocrafting
  795. #--------------------------------------------------------------------------
  796. def load_notetags_recipelist_bubs_tocrafting(line)
  797. return unless line =~ Bubs::Regexp::RECIPEBOOK_OBJ_TAG ? true : false
  798. match = $~.clone
  799. id_array = match[2].scan(/\d+/)
  800.  
  801. case match[1].upcase
  802. when "I", "ITEM"
  803. for id in id_array
  804. @recipe_list.push( $data_items[id.to_i] )
  805. end
  806.  
  807. when "W", "WEAPON", "WEP"
  808. for id in id_array
  809. @recipe_list.push( $data_weapons[id.to_i] )
  810. end
  811.  
  812. when "A", "ARMOR", "ARMOUR", "ARM"
  813. for id in id_array
  814. @recipe_list.push( $data_armors[id.to_i] )
  815. end # for
  816.  
  817. end # case
  818. end # def load_notetags_recipelist_bubs_tocrafting
  819.  
  820. #--------------------------------------------------------------------------
  821. # common cache : load_notetags_ingredients_bubs_tocrafting
  822. #--------------------------------------------------------------------------
  823. def load_notetags_ingredients_bubs_tocrafting(line)
  824. return unless line =~ Bubs::Regexp::INGREDIENT_OBJ_TAG ? true : false
  825. amount = $3 ? $3.to_i : 1
  826.  
  827. case $1.upcase
  828. when "I", "ITEM"
  829. amount.times do @ingredient_list.push( $data_items[$2.to_i] ) end
  830.  
  831. when "W", "WEAPON", "WEP"
  832. amount.times do @ingredient_list.push( $data_weapons[$2.to_i] ) end
  833.  
  834. when "A", "ARMOR", "ARMOUR", "ARM"
  835. amount.times do @ingredient_list.push( $data_armors[$2.to_i] ) end
  836.  
  837. when "FEE", "GOLD"
  838. @tocrafting_gold_fee = $2.to_i
  839.  
  840. when "SKILL"
  841. @tocrafting_skills.push( $2.to_i )
  842.  
  843. when "ACTOR"
  844. @tocrafting_actors.push( $2.to_i )
  845.  
  846. end # case $1.upcase
  847. end # def load_notetags_ingredients_bubs_tocrafting
  848.  
  849. #--------------------------------------------------------------------------
  850. # common cache : load_notetags_tools_bubs_tocrafting
  851. #--------------------------------------------------------------------------
  852. def load_notetags_tools_bubs_tocrafting(line)
  853. line =~ Bubs::Regexp::REQUIRED_TOOLS_TAG
  854.  
  855. case $1.upcase
  856. when "I", "ITEM"
  857. @tocrafting_tools.push( $data_items[$2.to_i] )
  858.  
  859. when "W", "WEAPON", "WEP"
  860. @tocrafting_tools.push( $data_weapons[$2.to_i] )
  861.  
  862. when "A", "ARMOR", "ARMOUR", "ARM"
  863. @tocrafting_tools.push( $data_armors[$2.to_i] )
  864.  
  865. end # case
  866. end # def load_notetags_tools_bubs_tocrafting
  867.  
  868. #--------------------------------------------------------------------------
  869. # new method : recipebook?
  870. #--------------------------------------------------------------------------
  871. def recipebook?
  872. return false unless self.is_a?(RPG::UsableItem) || self.is_a?(RPG::EquipItem)
  873. return !@recipe_list.empty?
  874. end
  875. end # class RPG::BaseItem
  876.  
  877.  
  878. #==============================================================================
  879. # ++ Window_TOCraftingRecipeList
  880. #==============================================================================
  881. class Window_TOCraftingRecipeList < Window_ItemList
  882. #--------------------------------------------------------------------------
  883. # public instance variables
  884. #--------------------------------------------------------------------------
  885. attr_reader :info_window
  886. attr_reader :header_window
  887. attr_reader :cover_window
  888. #--------------------------------------------------------------------------
  889. # initialize
  890. #--------------------------------------------------------------------------
  891. def initialize(x, y, height)
  892. super(x, y, window_width, height)
  893. end
  894.  
  895. #--------------------------------------------------------------------------
  896. # categories=
  897. #--------------------------------------------------------------------------
  898. def categories=(categories)
  899. @categories = categories
  900. end
  901.  
  902. #--------------------------------------------------------------------------
  903. # window_width
  904. #--------------------------------------------------------------------------
  905. def window_width
  906. Graphics.width / 2
  907. end
  908.  
  909. #--------------------------------------------------------------------------
  910. # current_item_enabled? # Get Activation State of Selection Item
  911. #--------------------------------------------------------------------------
  912. def current_item_enabled?
  913. enable?(@data[index])
  914. end
  915.  
  916. #--------------------------------------------------------------------------
  917. # enable? # Display in Enabled State?
  918. #--------------------------------------------------------------------------
  919. def enable?(item)
  920. return false if item.nil?
  921. return true
  922. end
  923.  
  924. #--------------------------------------------------------------------------
  925. # col_max
  926. #--------------------------------------------------------------------------
  927. def col_max
  928. return 1
  929. end
  930.  
  931. #--------------------------------------------------------------------------
  932. # include? # Include in Item List?
  933. #--------------------------------------------------------------------------
  934. def include?(item)
  935. return false if item.nil?
  936. return include_recipebook?(item) if item.recipebook?
  937. return false
  938. end
  939.  
  940. #--------------------------------------------------------------------------
  941. # include_recipebook?
  942. #--------------------------------------------------------------------------
  943. def include_recipebook?(item)
  944. return true if @categories.empty?
  945. return true if @categories.include?(item.tocrafting_category)
  946. return false
  947. end
  948.  
  949. #--------------------------------------------------------------------------
  950. # draw_item
  951. #--------------------------------------------------------------------------
  952. def draw_item(index)
  953. item = @data[index]
  954. if item
  955. rect = item_rect(index)
  956. rect.width -= 4
  957. draw_item_name(item, rect.x, rect.y, enable?(item), rect.width - 24)
  958. end
  959. end
  960.  
  961. #--------------------------------------------------------------------------
  962. # info_window=
  963. #--------------------------------------------------------------------------
  964. def info_window=(info_window)
  965. @info_window = info_window
  966. call_update_help
  967. end
  968.  
  969. #--------------------------------------------------------------------------
  970. # header_window=
  971. #--------------------------------------------------------------------------
  972. def header_window=(header_window)
  973. @header_window = header_window
  974. end
  975.  
  976. #--------------------------------------------------------------------------
  977. # cover_window=
  978. #--------------------------------------------------------------------------
  979. def cover_window=(cover_window)
  980. @cover_window = cover_window
  981. end
  982.  
  983. #--------------------------------------------------------------------------
  984. # update_help
  985. #--------------------------------------------------------------------------
  986. def update_help
  987. @help_window.set_item(item) if @help_window
  988. @info_window.item = item if @info_window
  989. @header_window.item = item if @header_window
  990. @cover_window.item = item if @cover_window
  991. end
  992.  
  993. end # Window_TOCraftingRecipeList
  994.  
  995.  
  996. #==============================================================================
  997. # ++ Window_TOCraftingItemListHeader
  998. #==============================================================================
  999. class Window_TOCraftingItemListHeader < Window_Base
  1000. #--------------------------------------------------------------------------
  1001. # initialize
  1002. #--------------------------------------------------------------------------
  1003. def initialize(x, y)
  1004. super(x, y, window_width, window_height)
  1005. @item = nil
  1006. end
  1007.  
  1008. #--------------------------------------------------------------------------
  1009. # window_width
  1010. #--------------------------------------------------------------------------
  1011. def window_width
  1012. Graphics.width / 2
  1013. end
  1014.  
  1015. #--------------------------------------------------------------------------
  1016. # window_height
  1017. #--------------------------------------------------------------------------
  1018. def window_height
  1019. fitting_height(1)
  1020. end
  1021.  
  1022. #--------------------------------------------------------------------------
  1023. # item= # Set window header item
  1024. #--------------------------------------------------------------------------
  1025. def item=(item)
  1026. @item = item
  1027. end
  1028.  
  1029. #--------------------------------------------------------------------------
  1030. # refresh
  1031. #--------------------------------------------------------------------------
  1032. def refresh
  1033. contents.clear
  1034. draw_itemlist_header_item(0, 0)
  1035. end
  1036.  
  1037. #--------------------------------------------------------------------------
  1038. # draw_itemlist_header_item
  1039. #--------------------------------------------------------------------------
  1040. def draw_itemlist_header_item(x, y)
  1041. return unless @item
  1042. draw_item_name(@item, x, y, true, contents.width - 28)
  1043. end
  1044.  
  1045. end # class Window_TOCraftingItemListHeader
  1046.  
  1047.  
  1048. #==============================================================================
  1049. # ++ Window_TOCraftingItemList
  1050. #==============================================================================
  1051.  
  1052. class Window_TOCraftingItemList < Window_ItemList
  1053. #--------------------------------------------------------------------------
  1054. # initialize
  1055. #--------------------------------------------------------------------------
  1056. def initialize(x, y, height)
  1057. super(x, y, window_width, height)
  1058. @item = nil
  1059. end
  1060.  
  1061. #--------------------------------------------------------------------------
  1062. # window_width
  1063. #--------------------------------------------------------------------------
  1064. def window_width
  1065. Graphics.width / 2
  1066. end
  1067.  
  1068. #--------------------------------------------------------------------------
  1069. # col_max
  1070. #--------------------------------------------------------------------------
  1071. def col_max
  1072. return 1
  1073. end
  1074.  
  1075. #--------------------------------------------------------------------------
  1076. # item=
  1077. #--------------------------------------------------------------------------
  1078. def item=(item)
  1079. @item = item
  1080. refresh
  1081. end
  1082.  
  1083. #--------------------------------------------------------------------------
  1084. # info_window=
  1085. #--------------------------------------------------------------------------
  1086. def info_window=(info_window)
  1087. @info_window = info_window
  1088. call_update_help
  1089. end
  1090.  
  1091. #--------------------------------------------------------------------------
  1092. # gold_window=
  1093. #--------------------------------------------------------------------------
  1094. def gold_window=(gold_window)
  1095. @gold_window = gold_window
  1096. call_update_help
  1097. end
  1098.  
  1099. #--------------------------------------------------------------------------
  1100. # current_item_enabled? # Get Activation State of Selection Item
  1101. #--------------------------------------------------------------------------
  1102. def current_item_enabled?
  1103. enable?(@data[index])
  1104. end
  1105.  
  1106. #--------------------------------------------------------------------------
  1107. # enable? # Display in Enabled State?
  1108. #--------------------------------------------------------------------------
  1109. def enable?(item)
  1110. return false if item.nil?
  1111. return false unless has_recipebook?
  1112. return false if item.tocrafting_gold_fee > $game_party.gold
  1113. return false if $game_party.item_max?(item)
  1114. return false unless have_tools?(item)
  1115. return false unless have_actors?(item)
  1116. return true if item.ingredient_list.empty?
  1117. return have_ingredients?(item)
  1118. end
  1119.  
  1120. #--------------------------------------------------------------------------
  1121. # has_recipebook?
  1122. #--------------------------------------------------------------------------
  1123. def has_recipebook?
  1124. return true if $imported["TH_TOCraftingShop"]
  1125. return true if $game_party.item_number(@item) > 0
  1126. return false
  1127. end
  1128.  
  1129. #--------------------------------------------------------------------------
  1130. # have_ingredients?
  1131. #--------------------------------------------------------------------------
  1132. def have_ingredients?(item)
  1133. item.ingredient_list.uniq.each do |ingredient|
  1134. party_amount = $game_party.item_number(ingredient)
  1135. required_amount = item.ingredient_list.count(ingredient)
  1136. return false if party_amount < required_amount
  1137. end # do
  1138. return true
  1139. end
  1140.  
  1141. #--------------------------------------------------------------------------
  1142. # have_tools?
  1143. #--------------------------------------------------------------------------
  1144. def have_tools?(item)
  1145. item.tocrafting_tools.each do |tool|
  1146. return false if !$game_party.has_item?(tool)
  1147. end
  1148. return true
  1149. end
  1150.  
  1151. #--------------------------------------------------------------------------
  1152. # have_actors?
  1153. #--------------------------------------------------------------------------
  1154. def have_actors?(item)
  1155. item.tocrafting_actors.each do |id|
  1156. return false unless $game_party.members.include?($game_actors[id])
  1157. end
  1158. return true
  1159. end
  1160.  
  1161. #--------------------------------------------------------------------------
  1162. # include? # Include in Item List?
  1163. #--------------------------------------------------------------------------
  1164. def include?(item)
  1165. return false if item.nil?
  1166. return true
  1167. end
  1168.  
  1169. #--------------------------------------------------------------------------
  1170. # make_item_list
  1171. #--------------------------------------------------------------------------
  1172. def make_item_list
  1173. @data = @item.recipe_list.each { |item| include?(item) } if @item
  1174. end
  1175.  
  1176. #--------------------------------------------------------------------------
  1177. # update_help
  1178. #--------------------------------------------------------------------------
  1179. def update_help
  1180. @help_window.set_item(item) if @help_window
  1181. @info_window.item = item if @info_window
  1182. @gold_window.item = item if @gold_window
  1183. end
  1184.  
  1185. #--------------------------------------------------------------------------
  1186. # update_open
  1187. #--------------------------------------------------------------------------
  1188. def update_open
  1189. self.openness += 24
  1190. @opening = false if open?
  1191. end
  1192.  
  1193. end # class Window_TOCraftingItemList
  1194.  
  1195.  
  1196. #==============================================================================
  1197. # ++ Window_TOCraftingInfo
  1198. #==============================================================================
  1199. class Window_TOCraftingInfo < Window_Base
  1200. #--------------------------------------------------------------------------
  1201. # Constants (Starting Number of Buff/Debuff Icons)
  1202. #--------------------------------------------------------------------------
  1203. ICON_BUFF_START = 64 # buff (16 icons)
  1204. ICON_DEBUFF_START = 80 # debuff (16 icons)
  1205. #--------------------------------------------------------------------------
  1206. # public instance variables
  1207. #--------------------------------------------------------------------------
  1208. attr_accessor :number
  1209. attr_accessor :page_change
  1210. attr_accessor :page_index
  1211. attr_reader :ingredients
  1212. #--------------------------------------------------------------------------
  1213. # initialize
  1214. #--------------------------------------------------------------------------
  1215. def initialize(x, y, width, height)
  1216. super(x, y, width, height)
  1217. @item = nil
  1218. @number = 1
  1219. @page_change = true
  1220. @page_index = 0
  1221. @ingredients = []
  1222. set_page_keys
  1223. end
  1224.  
  1225. #--------------------------------------------------------------------------
  1226. # set_page_keys
  1227. #--------------------------------------------------------------------------
  1228. def set_page_keys
  1229. @usableitem_pages = Bubs::TOCrafting::ITEM_INFO_PAGES.clone
  1230. @equipitem_pages = Bubs::TOCrafting::EQUIP_INFO_PAGES.clone
  1231. refresh
  1232. end
  1233.  
  1234. #--------------------------------------------------------------------------
  1235. # refresh
  1236. #--------------------------------------------------------------------------
  1237. def refresh
  1238. contents.clear
  1239. return unless @item
  1240. draw_page_contents(@item)
  1241. end
  1242.  
  1243. #--------------------------------------------------------------------------
  1244. # update
  1245. #--------------------------------------------------------------------------
  1246. def update
  1247. super
  1248. update_page
  1249. end
  1250.  
  1251. #--------------------------------------------------------------------------
  1252. # draw_page_contents
  1253. #--------------------------------------------------------------------------
  1254. def draw_page_contents(item)
  1255. if item.is_a?(RPG::Item)
  1256. case @usableitem_pages[0]
  1257. when :ingredients
  1258. draw_ingredients(4, line_height * 2)
  1259. standard_page_doodads(4, 0)
  1260.  
  1261. when :item_info
  1262. return feature_reader_text(4, 0) unless $imported["BubsFeaturesReader"]
  1263. draw_usableitem_info(item, 4, line_height * 2)
  1264. standard_page_doodads(4, 0)
  1265.  
  1266. end
  1267. elsif item.is_a?(RPG::EquipItem)
  1268. case @equipitem_pages[0]
  1269. when :ingredients
  1270. draw_ingredients(4, line_height * 2)
  1271. standard_page_doodads(4, 0)
  1272.  
  1273. when :param_info
  1274. return feature_reader_text(4, 0) unless $imported["BubsFeaturesReader"]
  1275. draw_param_info(item, 4, line_height * 2)
  1276. standard_page_doodads(4, 0)
  1277.  
  1278. when :xparam_info
  1279. return feature_reader_text(4, 0) unless $imported["BubsFeaturesReader"]
  1280. #draw_xparam_info(item, 4, line_height * 2)
  1281.  
  1282. when :sparam_info
  1283. return feature_reader_text(4, 0) unless $imported["BubsFeaturesReader"]
  1284. #draw_sparam_info(item, 4, line_height * 2)
  1285. standard_page_doodads(4, 0)
  1286.  
  1287. when :attack_info
  1288. return feature_reader_text(4, 0) unless $imported["BubsFeaturesReader"]
  1289. draw_attack_info(item, 4, line_height * 2)
  1290. standard_page_doodads(4, 0)
  1291.  
  1292. when :element_info
  1293. return feature_reader_text(4, 0) unless $imported["BubsFeaturesReader"]
  1294. draw_element_resists_info(item, 4, line_height * 2)
  1295. standard_page_doodads(4, 0)
  1296.  
  1297. when :state_info
  1298. return feature_reader_text(4, 0) unless $imported["BubsFeaturesReader"]
  1299. draw_state_resists_info(item, 4, line_height * 2)
  1300. standard_page_doodads(4, 0)
  1301.  
  1302. when :equippable_info
  1303. draw_equippable_info(item, 4, line_height * 2)
  1304. standard_page_doodads(4, 0)
  1305.  
  1306. end # case
  1307. end # if
  1308. end # def
  1309.  
  1310. #--------------------------------------------------------------------------
  1311. # standard_page_doodads
  1312. #--------------------------------------------------------------------------
  1313. def standard_page_doodads(x, y)
  1314. draw_info_header_text(x, y)
  1315. draw_info_footer_text(x, y)
  1316. draw_horz_line(line_height * 1)
  1317. end
  1318.  
  1319. #--------------------------------------------------------------------------
  1320. # feature_reader_text
  1321. #--------------------------------------------------------------------------
  1322. def feature_reader_text(x, y)
  1323. change_color(normal_color)
  1324. rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  1325. text = "This page requires"
  1326. rect.y = line_height * 3
  1327. draw_text(rect, text, 1)
  1328. text = "the script"
  1329. rect.y = line_height * 4
  1330. draw_text(rect, text, 1)
  1331. text = "\"Reader Functions for "
  1332. rect.y = line_height * 5
  1333. draw_text(rect, text, 1)
  1334. text = "Features\/Effects\""
  1335. rect.y = line_height * 6
  1336. draw_text(rect, text, 1)
  1337. text = "to be properly viewed."
  1338. rect.y = line_height * 7
  1339. draw_text(rect, text, 1)
  1340. end
  1341.  
  1342. #--------------------------------------------------------------------------
  1343. # update_page
  1344. #--------------------------------------------------------------------------
  1345. def update_page
  1346. if visible
  1347. next_info_page if Input.trigger?(next_page_button) && @page_change
  1348. prev_info_page if Input.trigger?(prev_page_button) && @page_change
  1349. if Input.trigger?(next_ingredient_page_button) && page_max > 1
  1350. next_ingredient_page if current_symbol == :ingredients
  1351. end
  1352. end
  1353. end
  1354.  
  1355. #--------------------------------------------------------------------------
  1356. # current_symbol
  1357. #--------------------------------------------------------------------------
  1358. def current_symbol
  1359. return :none unless @item
  1360. return @usableitem_pages[0] if @item.is_a?(RPG::UsableItem)
  1361. return @equipitem_pages[0] if @item.is_a?(RPG::EquipItem)
  1362. end
  1363.  
  1364. #--------------------------------------------------------------------------
  1365. # prev_page_button
  1366. #--------------------------------------------------------------------------
  1367. def prev_page_button
  1368. Bubs::TOCrafting::PREV_PAGE_BUTTON
  1369. end
  1370.  
  1371. #--------------------------------------------------------------------------
  1372. # next_page_button
  1373. #--------------------------------------------------------------------------
  1374. def next_page_button
  1375. Bubs::TOCrafting::NEXT_PAGE_BUTTON
  1376. end
  1377.  
  1378. #--------------------------------------------------------------------------
  1379. # next_ingredient_page_button
  1380. #--------------------------------------------------------------------------
  1381. def next_ingredient_page_button
  1382. Bubs::TOCrafting::NEXT_INGREDIENT_PAGE_BUTTON
  1383. end
  1384.  
  1385. #--------------------------------------------------------------------------
  1386. # normal_footer_text
  1387. #--------------------------------------------------------------------------
  1388. def normal_footer_text
  1389. Bubs::TOCrafting::NORMAL_FOOTER_TEXT
  1390. end
  1391.  
  1392. #--------------------------------------------------------------------------
  1393. # ingredients_view_more_footer_text
  1394. #--------------------------------------------------------------------------
  1395. def ingredients_view_more_footer_text
  1396. Bubs::TOCrafting::INGREDIENTS_VIEW_MORE_FOOTER_TEXT
  1397. end
  1398.  
  1399. #--------------------------------------------------------------------------
  1400. # draw_ingredients_footer_text
  1401. #--------------------------------------------------------------------------
  1402. def draw_ingredients_footer_text(x, y)
  1403. y = y + line_height * (contents.height / line_height - 1)
  1404. rect = standard_rect(x, y)
  1405. change_color(normal_color)
  1406. if page_max > 1
  1407. draw_text(rect, ingredients_view_more_footer_text, 1)
  1408. else
  1409. draw_text(rect, normal_footer_text, 1)
  1410. end
  1411. end
  1412.  
  1413. #--------------------------------------------------------------------------
  1414. # draw_info_footer_text(4, 0)
  1415. #--------------------------------------------------------------------------
  1416. def draw_info_footer_text(x, y)
  1417. y = y + line_height * (contents.height / line_height - 1)
  1418. rect = standard_rect(x, y)
  1419. change_color(normal_color)
  1420. draw_text(rect, normal_footer_text, 1)
  1421. end
  1422.  
  1423. #--------------------------------------------------------------------------
  1424. # next_ingredient_page
  1425. #--------------------------------------------------------------------------
  1426. def next_ingredient_page
  1427. @page_index = (@page_index + 1) % page_max
  1428. refresh
  1429. end
  1430.  
  1431. #--------------------------------------------------------------------------
  1432. # next_info_page
  1433. #--------------------------------------------------------------------------
  1434. def next_info_page
  1435. Sound.play_page_change
  1436. @equipitem_pages.rotate! if @item.is_a?(RPG::EquipItem)
  1437. @usableitem_pages.rotate! if @item.is_a?(RPG::UsableItem)
  1438. refresh
  1439. end
  1440.  
  1441. #--------------------------------------------------------------------------
  1442. # prev_info_page
  1443. #--------------------------------------------------------------------------
  1444. def prev_info_page
  1445. Sound.play_page_change
  1446. @equipitem_pages.rotate!(-1) if @item.is_a?(RPG::EquipItem)
  1447. @usableitem_pages.rotate!(-1) if @item.is_a?(RPG::UsableItem)
  1448. refresh
  1449. end
  1450.  
  1451. #--------------------------------------------------------------------------
  1452. # draw_horz_line
  1453. #--------------------------------------------------------------------------
  1454. def draw_horz_line(y)
  1455. line_y = y + line_height / 2 - 1
  1456. contents.fill_rect(0, line_y, contents_width, 2, line_color)
  1457. end
  1458.  
  1459. #--------------------------------------------------------------------------
  1460. # line_color # Get Color of Horizontal Line
  1461. #--------------------------------------------------------------------------
  1462. def line_color
  1463. color = normal_color
  1464. color.alpha = 48
  1465. color
  1466. end
  1467.  
  1468. #--------------------------------------------------------------------------
  1469. # info_header_text
  1470. #--------------------------------------------------------------------------
  1471. def info_header_text(key)
  1472. Bubs::TOCrafting::INFO_PAGE_HEADER_TEXT[key]
  1473. end
  1474.  
  1475. #--------------------------------------------------------------------------
  1476. # standard_rect
  1477. #--------------------------------------------------------------------------
  1478. def standard_rect(x, y)
  1479. Rect.new(x, y, contents.width - 4 - x, line_height)
  1480. end
  1481.  
  1482. #--------------------------------------------------------------------------
  1483. # draw_equippable_info
  1484. #--------------------------------------------------------------------------
  1485. def draw_equippable_info(item, x, y)
  1486. draw_equippable_text(item, x, y)
  1487. draw_equippable_members_info(item, x, y + line_height)
  1488. end
  1489.  
  1490. #--------------------------------------------------------------------------
  1491. # draw_equippable_members_info
  1492. #--------------------------------------------------------------------------
  1493. def draw_equippable_members_info(item, x, y)
  1494. change_color(normal_color)
  1495. temp = $game_party.members.select { |member| member.equippable?(item) }
  1496. temp.each_with_index do |member, index|
  1497. y_plus = line_height * (index / col_max)
  1498. x_plus = index % col_max * item_width
  1499. icon_index = actor_icons[member.id] ? member.id : :default
  1500. draw_icon(actor_icons[icon_index], x + x_plus, y + y_plus)
  1501. rect = Rect.new(x, y, contents.width / col_max - 4 - x, line_height)
  1502. rect.x += x_plus
  1503. rect.y += y_plus
  1504. text = sprintf("%s", member.name)
  1505. draw_text(rect, text, 2)
  1506. end
  1507. end
  1508.  
  1509. #--------------------------------------------------------------------------
  1510. # draw_equippable_text
  1511. #--------------------------------------------------------------------------
  1512. def draw_equippable_text(item, x, y)
  1513. change_color(system_color)
  1514. rect = standard_rect(x, y)
  1515. text = info_header_text(:equippable) # "Equippable Members"
  1516. draw_text(rect, text)
  1517. end
  1518.  
  1519. #--------------------------------------------------------------------------
  1520. # draw_param_info
  1521. #--------------------------------------------------------------------------
  1522. def draw_param_info(item, x, y)
  1523. 8.times do |i|
  1524. y_plus = line_height * i
  1525. x_plus = 0 #i % col_max * item_width
  1526. draw_param_name(x + x_plus, y + y_plus, i)
  1527. draw_param_value(item, x + x_plus, y + y_plus, i)
  1528. end
  1529. end
  1530.  
  1531. #--------------------------------------------------------------------------
  1532. # draw_attack_info
  1533. #--------------------------------------------------------------------------
  1534. def draw_attack_info(item, x, y)
  1535. draw_attack_elements(item, x, y + line_height * 0)
  1536. draw_attack_speed(item, x, y + line_height * 1)
  1537. draw_number_of_attacks(item, x, y + line_height * 2)
  1538. draw_attack_states_text(item, x, y + line_height * 4)
  1539. draw_attack_states(item, x, y + line_height * 5)
  1540. end
  1541.  
  1542. #--------------------------------------------------------------------------
  1543. # draw_attack_elements
  1544. #--------------------------------------------------------------------------
  1545. def draw_attack_elements(item, x, y)
  1546. draw_attack_elements_text(item, x, y)
  1547. draw_attack_elements_icons(item, x, y)
  1548. end
  1549.  
  1550. #--------------------------------------------------------------------------
  1551. # draw_attack_elements_text
  1552. #--------------------------------------------------------------------------
  1553. def draw_attack_elements_text(item, x, y)
  1554. change_color(system_color)
  1555. rect = standard_rect(x, y)
  1556. text = info_header_text(:atk_elements) # "Attack Element"
  1557. draw_text(rect, text)
  1558. end
  1559.  
  1560. #--------------------------------------------------------------------------
  1561. # draw_attack_elements_icons
  1562. #--------------------------------------------------------------------------
  1563. def draw_attack_elements_icons(item, x, y)
  1564. icons = item.atk_elements
  1565. icons.reverse.each_with_index do |id, i|
  1566. n = element_icon_id(id) ? element_icon_id(id) : 0
  1567. draw_icon(n, contents.width - 4 - x - (24 * (i + 1)), y)
  1568. end
  1569. end
  1570.  
  1571. #--------------------------------------------------------------------------
  1572. # draw_attack_speed
  1573. #--------------------------------------------------------------------------
  1574. def draw_attack_speed(item, x, y)
  1575. change_color(system_color)
  1576. rect = standard_rect(x, y)
  1577. text = info_header_text(:atk_speed) # "Attack Speed"
  1578. draw_text(rect, text)
  1579. value = item.atk_speed
  1580. change_color(param_change_color(value))
  1581. draw_text(rect, sprintf("%+d", value), 2)
  1582. end
  1583.  
  1584. #--------------------------------------------------------------------------
  1585. # draw_number_of_attacks
  1586. #--------------------------------------------------------------------------
  1587. def draw_number_of_attacks(item, x, y)
  1588. change_color(system_color)
  1589. rect = standard_rect(x, y)
  1590. text = info_header_text(:atk_times_add) # "Number of Attacks"
  1591. draw_text(rect, text)
  1592. value = item.atk_times_add
  1593. change_color(param_change_color(value))
  1594. draw_text(rect, sprintf("%+d", value), 2)
  1595. end
  1596.  
  1597. #--------------------------------------------------------------------------
  1598. # draw_attack_states
  1599. #--------------------------------------------------------------------------
  1600. def draw_attack_states(item, x, y)
  1601. change_color(normal_color)
  1602. item.atk_states.each_with_index do |state_id, index|
  1603. y_plus = line_height * (index / col_max)
  1604. x_plus = index % col_max * item_width
  1605. icon_index = $data_states[state_id].icon_index
  1606. draw_icon(icon_index, x + x_plus, y + y_plus)
  1607. rect = Rect.new(x, y, contents.width / col_max - 4 - x, line_height)
  1608. rect.x += x_plus
  1609. rect.y += y_plus
  1610. rate = item.atk_states_rate(state_id) * 100
  1611. text = sprintf("%d%%", rate)
  1612. draw_text(rect, text, 2)
  1613. end
  1614. end
  1615.  
  1616. #--------------------------------------------------------------------------
  1617. # draw_attack_states_text
  1618. #--------------------------------------------------------------------------
  1619. def draw_attack_states_text(item, x, y)
  1620. change_color(system_color)
  1621. rect = standard_rect(x, y)
  1622. text = info_header_text(:atk_states) # "Attack States"
  1623. draw_text(rect, text)
  1624. end
  1625.  
  1626. #--------------------------------------------------------------------------
  1627. # element_icon_id
  1628. #--------------------------------------------------------------------------
  1629. def element_icon_id(element_id)
  1630. Bubs::TOCrafting::ELEMENT_ICONS[element_id]
  1631. end
  1632.  
  1633. #--------------------------------------------------------------------------
  1634. # draw_element_resists_info
  1635. #--------------------------------------------------------------------------
  1636. def draw_element_resists_info(item, x, y)
  1637. draw_element_resists_text(item, x, y + line_height * 0)
  1638. draw_element_resists(item, x, y + line_height * 1)
  1639. end
  1640.  
  1641. #--------------------------------------------------------------------------
  1642. # draw_state_resists_info
  1643. #--------------------------------------------------------------------------
  1644. def draw_state_resists_info(item, x, y)
  1645. draw_state_resists_text(item, x, y + line_height * 0)
  1646. draw_state_resists(item, x, y + line_height * 1)
  1647. draw_state_immunity_text(item, x, y + line_height * 8)
  1648. draw_state_immunity(item, x, y + + line_height * 9)
  1649. end
  1650.  
  1651. #--------------------------------------------------------------------------
  1652. # draw_state_resists_text
  1653. #--------------------------------------------------------------------------
  1654. def draw_state_resists_text(item, x, y)
  1655. change_color(system_color)
  1656. rect = standard_rect(x, y)
  1657. text = info_header_text(:state_rate) # "State Resistance"
  1658. draw_text(rect, text)
  1659. end
  1660.  
  1661. #--------------------------------------------------------------------------
  1662. # draw_state_resists
  1663. #--------------------------------------------------------------------------
  1664. def draw_state_resists(item, x, y)
  1665. listed_states.each_with_index do |state_id, index|
  1666. y_plus = line_height * (index / col_max)
  1667. x_plus = index % col_max * item_width
  1668. icon_index = $data_states[state_id].icon_index
  1669. draw_icon(icon_index, x + x_plus, y + y_plus)
  1670. rect = Rect.new(x, y, contents.width / col_max - 4 - x, line_height)
  1671. rect.x += x_plus
  1672. rect.y += y_plus
  1673. rate = item.state_rate(state_id) * 100 - 100
  1674. change_color(param_change_color(-rate))
  1675. text = sprintf("%+d%%", -rate)
  1676. draw_text(rect, text, 2)
  1677. end
  1678. end
  1679.  
  1680. #--------------------------------------------------------------------------
  1681. # draw_state_immunity_text
  1682. #--------------------------------------------------------------------------
  1683. def draw_state_immunity_text(item, x, y)
  1684. change_color(system_color)
  1685. rect = standard_rect(x, y)
  1686. text = info_header_text(:state_resist_set) # "State Immunity"
  1687. draw_text(rect, text)
  1688. end
  1689.  
  1690. #--------------------------------------------------------------------------
  1691. # draw_state_immunity
  1692. #--------------------------------------------------------------------------
  1693. def draw_state_immunity(item, x, y)
  1694. item.state_resist_set.each_with_index do |state_id, index|
  1695. icon_row_max = (contents.width - 4 - x) / 24
  1696. y_plus = (index / icon_row_max) * line_height
  1697. x_plus = (index % icon_row_max) * 24
  1698. icon_index = $data_states[state_id].icon_index
  1699. draw_icon(icon_index, x + x_plus, y + y_plus)
  1700. end
  1701. end
  1702.  
  1703. #--------------------------------------------------------------------------
  1704. # draw_element_resists
  1705. #--------------------------------------------------------------------------
  1706. def draw_element_resists(item, x, y)
  1707. change_color(normal_color)
  1708. listed_elements.each_with_index do |element_id, index|
  1709. y_plus = line_height * (index / col_max)
  1710. x_plus = index % col_max * item_width
  1711. icon_index = element_icon_id(element_id) ? element_icon_id(element_id) : 0
  1712. draw_icon(icon_index, x + x_plus, y + y_plus)
  1713. rect = Rect.new(x + x_plus, y + y_plus, contents.width / col_max - 4 - x, line_height)
  1714. rate = item.element_rate(element_id) * 100 - 100
  1715. change_color(param_change_color(-rate))
  1716. text = sprintf("%+d%%", -rate)
  1717. draw_text(rect, text, 2)
  1718. end
  1719. end
  1720.  
  1721. #--------------------------------------------------------------------------
  1722. # draw_element_resists_text
  1723. #--------------------------------------------------------------------------
  1724. def draw_element_resists_text(item, x, y)
  1725. change_color(system_color)
  1726. rect = standard_rect(x, y)
  1727. text = info_header_text(:element_rate) # "Element Resists"
  1728. draw_text(rect, text)
  1729. end
  1730.  
  1731. #--------------------------------------------------------------------------
  1732. # listed_elements
  1733. #--------------------------------------------------------------------------
  1734. def listed_elements
  1735. Bubs::TOCrafting::DISPLAYED_ELEMENT_RESISTS
  1736. end
  1737.  
  1738. #--------------------------------------------------------------------------
  1739. # listed_states
  1740. #--------------------------------------------------------------------------
  1741. def listed_states
  1742. Bubs::TOCrafting::DISPLAYED_STATE_RESISTS
  1743. end
  1744.  
  1745. #--------------------------------------------------------------------------
  1746. # draw_usableitem_info
  1747. #--------------------------------------------------------------------------
  1748. def draw_usableitem_info(item, x, y)
  1749. draw_hp_recovery(item, x, y + line_height * 0)
  1750. draw_mp_recovery(item, x, y + line_height * 1)
  1751. draw_tp_recovery(item, x, y + line_height * 2)
  1752. draw_add_state_text(item, x, y + line_height * 4)
  1753. draw_add_state_icons(item, x, y + line_height * 5)
  1754. draw_remove_state_text(item, x, y + line_height * 7)
  1755. draw_remove_state_icons(item, x, y + line_height * 8)
  1756. end
  1757.  
  1758. #--------------------------------------------------------------------------
  1759. # draw_add_state_icons
  1760. #--------------------------------------------------------------------------
  1761. def draw_add_state_icons(item, x, y)
  1762. icons = get_add_state_icons(item)
  1763. icons.each_with_index do |n, i|
  1764. icon_row_max = (contents.width - 4 - x) / 24
  1765. y_plus = (i / icon_row_max) * line_height
  1766. x_plus = (i % icon_row_max) * 24
  1767. draw_icon(n, x + x_plus, y + y_plus)
  1768. end
  1769. end
  1770.  
  1771. #--------------------------------------------------------------------------
  1772. # get_add_state_icons
  1773. #--------------------------------------------------------------------------
  1774. def get_add_state_icons(item)
  1775. icons = item.add_states.collect { |id| $data_states[id].icon_index }
  1776. icons += item.add_buffs.collect { |param| buff_icon_index( 1, param) }
  1777. icons += item.add_debuffs.collect { |param| buff_icon_index(-1, param) }
  1778. icons.delete(0)
  1779. icons
  1780. end
  1781.  
  1782. #--------------------------------------------------------------------------
  1783. # draw_remove_state_icons
  1784. #--------------------------------------------------------------------------
  1785. def draw_remove_state_icons(item, x, y)
  1786. icons = get_remove_state_icons(item)
  1787. icons.each_with_index do |n, i|
  1788. icon_row_max = (contents.width - 4 - x) / 24
  1789. y_plus = (i / icon_row_max) * line_height
  1790. x_plus = (i % icon_row_max) * 24
  1791. draw_icon(n, x + x_plus, y + y_plus)
  1792. end
  1793. end
  1794.  
  1795. #--------------------------------------------------------------------------
  1796. # get_remove_state_icons
  1797. #--------------------------------------------------------------------------
  1798. def get_remove_state_icons(item)
  1799. icons = item.remove_states.collect { |id| $data_states[id].icon_index }
  1800. icons += item.remove_buffs.collect { |param| buff_icon_index( 1, param) }
  1801. icons += item.remove_debuffs.collect { |param| buff_icon_index(-1, param) }
  1802. icons.delete(0)
  1803. icons
  1804. end
  1805.  
  1806. #--------------------------------------------------------------------------
  1807. # buff_icon_index # Get Icon Number Corresponding to Buff/Debuff
  1808. #--------------------------------------------------------------------------
  1809. def buff_icon_index(buff_level, param_id)
  1810. if buff_level > 0
  1811. return ICON_BUFF_START + (buff_level - 1) * 8 + param_id
  1812. elsif buff_level < 0
  1813. return ICON_DEBUFF_START + (-buff_level - 1) * 8 + param_id
  1814. else
  1815. return 0
  1816. end
  1817. end
  1818.  
  1819. #--------------------------------------------------------------------------
  1820. # draw_add_state_text
  1821. #--------------------------------------------------------------------------
  1822. def draw_add_state_text(item, x, y)
  1823. change_color(system_color)
  1824. rect = standard_rect(x, y)
  1825. text = info_header_text(:add_states) # "Add States"
  1826. draw_text(rect, text)
  1827. end
  1828.  
  1829. #--------------------------------------------------------------------------
  1830. # draw_remove_state_text
  1831. #--------------------------------------------------------------------------
  1832. def draw_remove_state_text(item, x, y)
  1833. change_color(system_color)
  1834. rect = standard_rect(x, y)
  1835. text = info_header_text(:remove_states) # "Remove States"
  1836. draw_text(rect, text)
  1837. end
  1838.  
  1839. #--------------------------------------------------------------------------
  1840. # draw_hp_recovery
  1841. #--------------------------------------------------------------------------
  1842. def draw_hp_recovery(item, x, y)
  1843. change_color(system_color)
  1844. rect = standard_rect(x, y)
  1845. text = info_header_text(:hp_recovery) # "HP Recovery"
  1846. draw_text(rect, text)
  1847. value = item.hp_recovery
  1848. rate = item.hp_recovery_rate
  1849. text = get_recovery_text(value, rate)
  1850. draw_text(rect, text, 2)
  1851. end
  1852.  
  1853. #--------------------------------------------------------------------------
  1854. # draw_mp_recovery
  1855. #--------------------------------------------------------------------------
  1856. def draw_mp_recovery(item, x, y)
  1857. change_color(system_color)
  1858. rect = standard_rect(x, y)
  1859. text = info_header_text(:mp_recovery) # "MP Recovery"
  1860. draw_text(rect, text)
  1861. value = item.mp_recovery
  1862. rate = item.mp_recovery_rate
  1863. text = get_recovery_text(value, rate)
  1864. draw_text(rect, text, 2)
  1865. end
  1866.  
  1867. #--------------------------------------------------------------------------
  1868. # draw_tp_recovery
  1869. #--------------------------------------------------------------------------
  1870. def draw_tp_recovery(item, x, y)
  1871. change_color(system_color)
  1872. rect = standard_rect(x, y)
  1873. text = info_header_text(:tp_recovery) # "TP Recovery"
  1874. draw_text(rect, text)
  1875. # If you get an error on this line, it means you are using an old
  1876. # version of "Reader Functions for Features/Effects". Get v1.2 or above.
  1877. value = item.tp_recovery
  1878. text = get_recovery_text(value)
  1879. draw_text(rect, text, 2)
  1880. end
  1881.  
  1882. #--------------------------------------------------------------------------
  1883. # get_recovery_text
  1884. #--------------------------------------------------------------------------
  1885. def get_recovery_text(value, rate = 0)
  1886. rate = rate * 100
  1887. if value != 0 && rate != 0
  1888. change_color(param_change_color(value))
  1889. text = sprintf("%+d%%%+d", rate, value)
  1890. elsif rate != 0
  1891. change_color(param_change_color(rate))
  1892. text = sprintf("%+d%%", rate)
  1893. else
  1894. change_color(param_change_color(value))
  1895. text = sprintf("%+d", value)
  1896. end
  1897. return text
  1898. end
  1899.  
  1900. #--------------------------------------------------------------------------
  1901. # draw_param_name
  1902. #--------------------------------------------------------------------------
  1903. def draw_param_name(x, y, param_id)
  1904. change_color(system_color)
  1905. text = Vocab::param(param_id)
  1906. draw_text(x, y, contents.width - 4 - x, line_height, text)
  1907. end
  1908.  
  1909. #--------------------------------------------------------------------------
  1910. # draw_param_value
  1911. #--------------------------------------------------------------------------
  1912. def draw_param_value(item, x, y, param_id)
  1913. rect = standard_rect(x, y)
  1914. value = item.param(param_id)
  1915. rate = item.param_rate(param_id)
  1916. text = get_param_text(value, rate)
  1917. draw_text(rect, text, 2)
  1918. end
  1919.  
  1920. #--------------------------------------------------------------------------
  1921. # get_param_text
  1922. #--------------------------------------------------------------------------
  1923. def get_param_text(value, rate = 0)
  1924. rate = (rate * 100).to_i - 100
  1925. if value != 0 && rate != 0
  1926. change_color(param_change_color(value))
  1927. text = sprintf("%+d%%%+d", rate, value)
  1928. elsif rate != 0
  1929. change_color(param_change_color(rate))
  1930. text = sprintf("%+d%%", rate)
  1931. else
  1932. change_color(param_change_color(value))
  1933. text = sprintf("%+d", value)
  1934. end
  1935. return text
  1936. end
  1937.  
  1938. #--------------------------------------------------------------------------
  1939. # col_max
  1940. #--------------------------------------------------------------------------
  1941. def col_max
  1942. return 2
  1943. end
  1944.  
  1945. #--------------------------------------------------------------------------
  1946. # item_width
  1947. #--------------------------------------------------------------------------
  1948. def item_width
  1949. (width - standard_padding * 2 + 4) / col_max - 4
  1950. end
  1951.  
  1952. #--------------------------------------------------------------------------
  1953. # draw_item
  1954. #--------------------------------------------------------------------------
  1955. def draw_item(index)
  1956. item = @data[index]
  1957. if item
  1958. rect = item_rect(index)
  1959. rect.width -= 4
  1960. draw_item_name(item, rect.x, rect.y, enable?(item))
  1961. draw_item_number(rect, item)
  1962. end
  1963. end
  1964.  
  1965. #--------------------------------------------------------------------------
  1966. # draw_item_number
  1967. #--------------------------------------------------------------------------
  1968. def draw_item_number(rect, item)
  1969. draw_text(rect, sprintf(":%2d", $game_party.item_number(item)), 2)
  1970. end
  1971.  
  1972. #--------------------------------------------------------------------------
  1973. # draw_info_header_text
  1974. #--------------------------------------------------------------------------
  1975. def draw_info_header_text(x, y)
  1976. rect = standard_rect(x, y)
  1977. change_color(system_color)
  1978. draw_text(rect, info_header_text(:main_header))
  1979. draw_icon(@item.icon_index, rect.width - 24, y) if @item
  1980. end
  1981.  
  1982. #--------------------------------------------------------------------------
  1983. # item= # Set Item
  1984. #--------------------------------------------------------------------------
  1985. def item=(item)
  1986. @item = item
  1987. @page_index = 0
  1988. refresh
  1989. end
  1990.  
  1991. #--------------------------------------------------------------------------
  1992. # ingredients
  1993. #--------------------------------------------------------------------------
  1994. def ingredients
  1995. @item.ingredient_list
  1996. end
  1997.  
  1998. #--------------------------------------------------------------------------
  1999. # tools
  2000. #--------------------------------------------------------------------------
  2001. def tools
  2002. @item.tocrafting_tools
  2003. end
  2004.  
  2005. #--------------------------------------------------------------------------
  2006. # actor_requirements
  2007. #--------------------------------------------------------------------------
  2008. def actor_requirements
  2009. @item.tocrafting_actors
  2010. end
  2011.  
  2012. #--------------------------------------------------------------------------
  2013. # ingredients_header_text
  2014. #--------------------------------------------------------------------------
  2015. def ingredients_header_text
  2016. Bubs::TOCrafting::INGREDIENTS_HEADER_TEXT
  2017. end
  2018.  
  2019. #--------------------------------------------------------------------------
  2020. # draw_ingredients_header_text
  2021. #--------------------------------------------------------------------------
  2022. def draw_ingredients_header_text(x, y)
  2023. rect = standard_rect(x, y)
  2024. change_color(system_color)
  2025. draw_text(rect, ingredients_header_text)
  2026. draw_icon(@item.icon_index, rect.width - 24, y) if @item
  2027. end
  2028.  
  2029. #--------------------------------------------------------------------------
  2030. # use_gold_window?
  2031. #--------------------------------------------------------------------------
  2032. def use_gold_window?
  2033. Bubs::TOCrafting::USE_GOLD_WINDOW
  2034. end
  2035.  
  2036. #--------------------------------------------------------------------------
  2037. # create_ingredient_array
  2038. #--------------------------------------------------------------------------
  2039. def create_ingredients_array(item)
  2040. @ingredients = []
  2041. if !use_gold_window? && @item.tocrafting_gold_fee > 0
  2042. @ingredients.push([:gold, @item.tocrafting_gold_fee])
  2043. end
  2044.  
  2045. actor_requirements.uniq.each do |id|
  2046. @ingredients.push([:actor, $game_actors[id]])
  2047. end
  2048.  
  2049. tools.uniq.each do |tool|
  2050. @ingredients.push([:tool, tool])
  2051. end
  2052.  
  2053. ingredients.uniq.each do |ingredient|
  2054. @ingredients.push([:ingredient, ingredient])
  2055. end
  2056. end
  2057.  
  2058. #--------------------------------------------------------------------------
  2059. # draw_ingredients
  2060. #--------------------------------------------------------------------------
  2061. def draw_ingredients(x, y)
  2062. return unless @item
  2063. i = 0
  2064. create_ingredients_array(@item)
  2065. @page_index = 0 if viewable_ingredients.nil?
  2066. for pair in viewable_ingredients
  2067.  
  2068. case pair[0]
  2069. when :gold
  2070. draw_gold_info(pair[1], x, y)
  2071. i += 1
  2072. when :actor
  2073. draw_actor_req_info(pair[1], x, y + line_height * (i * 2))
  2074. i += 1
  2075. when :tool
  2076. draw_tools_info(pair[1], x, y + line_height * (i * 2))
  2077. i += 1
  2078. when :ingredient
  2079. draw_ingredient_info(pair[1], x, y + line_height * (i * 2))
  2080. i += 1
  2081. end
  2082. end
  2083. end
  2084.  
  2085. #--------------------------------------------------------------------------
  2086. # * Array of Actors for Which to Draw Equipment Information
  2087. #--------------------------------------------------------------------------
  2088. def viewable_ingredients
  2089. @ingredients[@page_index * page_size, page_size]
  2090. end
  2091.  
  2092. #--------------------------------------------------------------------------
  2093. # page_size # Number of Ingredients Displayable at Once
  2094. #--------------------------------------------------------------------------
  2095. def page_size
  2096. Bubs::TOCrafting::INGREDIENTS_PAGE_SIZE
  2097. end
  2098.  
  2099. #--------------------------------------------------------------------------
  2100. # page_max # Get Maximum Number of Pages
  2101. #--------------------------------------------------------------------------
  2102. def page_max
  2103. (@ingredients.size + page_size - 1) / page_size
  2104. end
  2105.  
  2106. #--------------------------------------------------------------------------
  2107. # required_amount
  2108. #--------------------------------------------------------------------------
  2109. def required_amount(item)
  2110. ingredients.count(item) * @number
  2111. end
  2112.  
  2113. #--------------------------------------------------------------------------
  2114. # party_amount
  2115. #--------------------------------------------------------------------------
  2116. def party_amount(item)
  2117. $game_party.item_number(item)
  2118. end
  2119.  
  2120. #--------------------------------------------------------------------------
  2121. # crafting_fee
  2122. #--------------------------------------------------------------------------
  2123. def crafting_fee
  2124. @item.tocrafting_gold_fee
  2125. end
  2126.  
  2127. #--------------------------------------------------------------------------
  2128. # party_gold
  2129. #--------------------------------------------------------------------------
  2130. def party_gold
  2131. $game_party.gold
  2132. end
  2133.  
  2134. #--------------------------------------------------------------------------
  2135. # currency_unit
  2136. #--------------------------------------------------------------------------
  2137. def currency_unit
  2138. Vocab::currency_unit
  2139. end
  2140.  
  2141. #--------------------------------------------------------------------------
  2142. # actor_icons
  2143. #--------------------------------------------------------------------------
  2144. def actor_icons
  2145. Bubs::TOCrafting::ACTOR_ICONS
  2146. end
  2147.  
  2148. #--------------------------------------------------------------------------
  2149. # draw_tools_info
  2150. #--------------------------------------------------------------------------
  2151. def draw_tools_info(item, x, y)
  2152. enabled = $game_party.has_item?(item)
  2153. width = contents.width - 4 - x
  2154.  
  2155. draw_item_name(item, x, y, enabled, width)
  2156. draw_tool_availability_text(item, x, y, enabled)
  2157. end
  2158.  
  2159. #--------------------------------------------------------------------------
  2160. # draw_actor_req_info
  2161. #--------------------------------------------------------------------------
  2162. def draw_actor_req_info(actor, x, y)
  2163. enabled = $game_party.members.include?(actor)
  2164. width = contents.width - 4 - x
  2165. icon_index = actor_icons[actor.id] ? actor_id : :default
  2166. draw_icon(actor_icons[icon_index], x, y, enabled)
  2167. draw_actor_availability_text(actor.id, x, y, enabled)
  2168. change_color(normal_color, enabled)
  2169. draw_text(x + 24, y, width, line_height, actor.name)
  2170. end
  2171.  
  2172. #--------------------------------------------------------------------------
  2173. # draw_tool_availability_text
  2174. #--------------------------------------------------------------------------
  2175. def draw_tool_availability_text(item, x, y, enabled)
  2176. rect = Rect.new(x, y + line_height, contents.width - 4 - x, line_height)
  2177. if enabled
  2178. change_color(text_color(Bubs::TOCrafting::TOOL_AVAILABLE_TEXT_COLOR))
  2179. draw_text(rect, Bubs::TOCrafting::TOOL_AVAILABLE_TEXT, 2)
  2180. else
  2181. change_color(text_color(Bubs::TOCrafting::TOOL_UNAVAILABLE_TEXT_COLOR))
  2182. draw_text(rect, Bubs::TOCrafting::TOOL_UNAVAILABLE_TEXT, 2)
  2183. end
  2184. end
  2185.  
  2186. #--------------------------------------------------------------------------
  2187. # draw_actor_availability_text
  2188. #--------------------------------------------------------------------------
  2189. def draw_actor_availability_text(item, x, y, enabled)
  2190. rect = Rect.new(x, y + line_height, contents.width - 4 - x, line_height)
  2191. if enabled
  2192. change_color(text_color(Bubs::TOCrafting::ACTOR_AVAILABLE_TEXT_COLOR))
  2193. draw_text(rect, Bubs::TOCrafting::ACTOR_AVAILABLE_TEXT, 2)
  2194. else
  2195. change_color(text_color(Bubs::TOCrafting::ACTOR_UNAVAILABLE_TEXT_COLOR))
  2196. draw_text(rect, Bubs::TOCrafting::ACTOR_UNAVAILABLE_TEXT, 2)
  2197. end
  2198. end
  2199.  
  2200. #--------------------------------------------------------------------------
  2201. # draw_ingredient_info
  2202. #--------------------------------------------------------------------------
  2203. def draw_ingredient_info(item, x, y)
  2204. enabled = party_amount(item) >= required_amount(item)
  2205. width = contents.width - 4 - x
  2206.  
  2207. draw_item_name(item, x, y, enabled, width)
  2208. not_enough_ingredients_color unless enabled
  2209. rect = Rect.new(x, y + line_height, contents.width - 4 - x, line_height)
  2210. draw_text(rect, sprintf("×%2d/%2d", required_amount(item), party_amount(item)), 2)
  2211. end
  2212.  
  2213. #--------------------------------------------------------------------------
  2214. # draw_gold_info
  2215. #--------------------------------------------------------------------------
  2216. def draw_gold_info(item, x, y)
  2217. return if item.nil?
  2218. enabled = party_gold >= crafting_fee
  2219. cx = text_size(currency_unit).width
  2220. width = contents.width - 4 - x
  2221.  
  2222. draw_gold_name(x, y, enabled)
  2223.  
  2224. change_color(system_color)
  2225. draw_text(x, y + line_height, width, line_height, currency_unit, 2)
  2226. change_color(normal_color)
  2227.  
  2228. not_enough_ingredients_color unless enabled
  2229. text = sprintf("%8d/%8d", crafting_fee * @number, party_gold)
  2230. draw_text(x, y + line_height, width - cx - 2, line_height, text, 2)
  2231. end
  2232.  
  2233. #--------------------------------------------------------------------------
  2234. # draw_gold_name
  2235. #--------------------------------------------------------------------------
  2236. def draw_gold_name(x, y, enabled = true)
  2237. draw_icon(Bubs::TOCrafting::GOLD_WINDOW_ICON_INDEX, x, y, enabled)
  2238. change_color(normal_color, enabled)
  2239. draw_text(x + 24, y, width, line_height, Bubs::TOCrafting::GOLD_WINDOW_TEXT)
  2240. end
  2241.  
  2242. #--------------------------------------------------------------------------
  2243. # not_enough_ingredients_color
  2244. #--------------------------------------------------------------------------
  2245. def not_enough_ingredients_color
  2246. enabled = !Bubs::TOCrafting::FADED_REQUIREMENT_QUANTITY
  2247. color_index = Bubs::TOCrafting::NOT_ENOUGH_INGREDIENTS_COLOR
  2248. change_color(text_color(color_index), enabled)
  2249. end
  2250.  
  2251.  
  2252.  
  2253. end # class Window_TOCraftingInfo
  2254.  
  2255.  
  2256. #==============================================================================
  2257. # ++ Window_TOCraftingResult
  2258. #==============================================================================
  2259. class Window_TOCraftingResult < Window_Selectable
  2260. #--------------------------------------------------------------------------
  2261. # initialize
  2262. #--------------------------------------------------------------------------
  2263. def initialize(x, y)
  2264. @item = nil
  2265. @number = 0
  2266. super(x, y, window_width,window_height)
  2267. end
  2268.  
  2269. #--------------------------------------------------------------------------
  2270. # window_width
  2271. #--------------------------------------------------------------------------
  2272. def window_width
  2273. Graphics.width / 2
  2274. end
  2275.  
  2276. #--------------------------------------------------------------------------
  2277. # window_height
  2278. #--------------------------------------------------------------------------
  2279. def window_height
  2280. fitting_height(2)
  2281. end
  2282.  
  2283. #--------------------------------------------------------------------------
  2284. # set
  2285. #--------------------------------------------------------------------------
  2286. def set(item, number)
  2287. @item = item
  2288. @number = number
  2289. end
  2290.  
  2291. #--------------------------------------------------------------------------
  2292. # refresh
  2293. #--------------------------------------------------------------------------
  2294. def refresh
  2295. contents.clear
  2296. draw_result_header_text(4, 0)
  2297. draw_result_item(4, line_height)
  2298. end
  2299.  
  2300. #--------------------------------------------------------------------------
  2301. # draw_result_header_text
  2302. #--------------------------------------------------------------------------
  2303. def draw_result_header_text(x, y)
  2304. return unless @item
  2305. rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  2306. change_color(system_color)
  2307. draw_text(rect, Bubs::TOCrafting::RESULT_WINDOW_HEADER_TEXT, 1)
  2308. end
  2309.  
  2310. #--------------------------------------------------------------------------
  2311. # draw_result_item
  2312. #--------------------------------------------------------------------------
  2313. def draw_result_item(x, y)
  2314. return unless @item
  2315. draw_item_name(@item, x, y, true)
  2316. draw_item_amount(x, y, @number)
  2317. end
  2318.  
  2319. #--------------------------------------------------------------------------
  2320. # draw_item_amount
  2321. #--------------------------------------------------------------------------
  2322. def draw_item_amount(x, y, number)
  2323. rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  2324. draw_text(rect, sprintf("×%2d", number), 2)
  2325. end
  2326.  
  2327. end # class Window_TOCraftingResult
  2328.  
  2329.  
  2330. #==============================================================================
  2331. # ++ Window_TOCraftingGold
  2332. #==============================================================================
  2333. class Window_TOCraftingGold < Window_Base
  2334. #--------------------------------------------------------------------------
  2335. # public instance variables
  2336. #--------------------------------------------------------------------------
  2337. attr_accessor :number
  2338. #--------------------------------------------------------------------------
  2339. # initialize
  2340. #--------------------------------------------------------------------------
  2341. def initialize
  2342. super(0, 0, window_width, fitting_height(2))
  2343. @item = nil
  2344. @number = 1
  2345. refresh
  2346. end
  2347.  
  2348. #--------------------------------------------------------------------------
  2349. # window_width
  2350. #--------------------------------------------------------------------------
  2351. def window_width
  2352. return Graphics.width / 2
  2353. end
  2354.  
  2355. #--------------------------------------------------------------------------
  2356. # item=
  2357. #--------------------------------------------------------------------------
  2358. def item=(item)
  2359. @item = item
  2360. refresh
  2361. end
  2362.  
  2363. #--------------------------------------------------------------------------
  2364. # refresh
  2365. #--------------------------------------------------------------------------
  2366. def refresh
  2367. contents.clear
  2368. draw_gold_info(4, 0)
  2369. end
  2370.  
  2371. #--------------------------------------------------------------------------
  2372. # currency_unit
  2373. #--------------------------------------------------------------------------
  2374. def currency_unit
  2375. Vocab::currency_unit
  2376. end
  2377.  
  2378. #--------------------------------------------------------------------------
  2379. # open
  2380. #--------------------------------------------------------------------------
  2381. def open
  2382. refresh
  2383. super
  2384. end
  2385.  
  2386. #--------------------------------------------------------------------------
  2387. # crafting_fee
  2388. #--------------------------------------------------------------------------
  2389. def crafting_fee
  2390. @item.tocrafting_gold_fee
  2391. end
  2392.  
  2393. #--------------------------------------------------------------------------
  2394. # party_gold
  2395. #--------------------------------------------------------------------------
  2396. def party_gold
  2397. $game_party.gold
  2398. end
  2399.  
  2400. #--------------------------------------------------------------------------
  2401. # draw_gold_info
  2402. #--------------------------------------------------------------------------
  2403. def draw_gold_info(x, y)
  2404. return if @item.nil?
  2405. enabled = party_gold >= crafting_fee
  2406. cx = text_size(currency_unit).width
  2407. width = contents.width - 4 - x
  2408.  
  2409. draw_gold_name(x, y, enabled)
  2410.  
  2411. change_color(system_color)
  2412. draw_text(x, y + line_height, width, line_height, currency_unit, 2)
  2413. change_color(normal_color)
  2414.  
  2415. not_enough_ingredients_color unless enabled
  2416. text = sprintf("%8d/%8d", crafting_fee * @number, party_gold)
  2417. draw_text(x, y + line_height, width - cx - 2, line_height, text, 2)
  2418. end
  2419.  
  2420. #--------------------------------------------------------------------------
  2421. # draw_gold_name
  2422. #--------------------------------------------------------------------------
  2423. def draw_gold_name(x, y, enabled = true)
  2424. draw_icon(Bubs::TOCrafting::GOLD_WINDOW_ICON_INDEX, x, y, enabled)
  2425. change_color(normal_color, enabled)
  2426. draw_text(x + 24, y, width, line_height, Bubs::TOCrafting::GOLD_WINDOW_TEXT)
  2427. end
  2428.  
  2429. #--------------------------------------------------------------------------
  2430. # not_enough_ingredients_color
  2431. #--------------------------------------------------------------------------
  2432. def not_enough_ingredients_color
  2433. enabled = !Bubs::TOCrafting::FADED_REQUIREMENT_QUANTITY
  2434. color_index = Bubs::TOCrafting::NOT_ENOUGH_INGREDIENTS_COLOR
  2435. change_color(text_color(color_index), enabled)
  2436. end
  2437. end # class Window_TOCraftingGold
  2438.  
  2439.  
  2440. #==============================================================================
  2441. # ++ Window_TOCraftingNumber
  2442. #==============================================================================
  2443. class Window_TOCraftingNumber < Window_Selectable
  2444. #--------------------------------------------------------------------------
  2445. # public instance variables
  2446. #--------------------------------------------------------------------------
  2447. attr_accessor :number # quantity entered
  2448. attr_reader :item
  2449. #--------------------------------------------------------------------------
  2450. # initialize
  2451. #--------------------------------------------------------------------------
  2452. def initialize(x, y, height)
  2453. super(x, y, window_width, height)
  2454. @item = nil
  2455. @info_window = nil
  2456. @max = 1
  2457. @price = 0
  2458. @number = 1
  2459. @currency_unit = Vocab::currency_unit
  2460. end
  2461.  
  2462. #--------------------------------------------------------------------------
  2463. # window_width
  2464. #--------------------------------------------------------------------------
  2465. def window_width
  2466. return Graphics.width / 2
  2467. end
  2468.  
  2469. #--------------------------------------------------------------------------
  2470. # info_window=
  2471. #--------------------------------------------------------------------------
  2472. def info_window=(info_window)
  2473. @info_window = info_window
  2474. end
  2475.  
  2476. #--------------------------------------------------------------------------
  2477. # gold_window=
  2478. #--------------------------------------------------------------------------
  2479. def gold_window=(gold_window)
  2480. @gold_window = gold_window
  2481. end
  2482.  
  2483. #--------------------------------------------------------------------------
  2484. # set
  2485. #--------------------------------------------------------------------------
  2486. def set(item, max, price, currency_unit = nil)
  2487. @item = item
  2488. @max = max
  2489. @price = price
  2490. @currency_unit = currency_unit if currency_unit
  2491. @number = 1
  2492. refresh
  2493. end
  2494.  
  2495. #--------------------------------------------------------------------------
  2496. # currency_unit
  2497. #--------------------------------------------------------------------------
  2498. def currency_unit=(currency_unit)
  2499. @currency_unit = currency_unit
  2500. refresh
  2501. end
  2502.  
  2503. #--------------------------------------------------------------------------
  2504. # refresh
  2505. #--------------------------------------------------------------------------
  2506. def refresh
  2507. contents.clear
  2508. draw_item_name(@item, 0, item_y)
  2509. draw_number
  2510. update_info_window
  2511. update_gold_window
  2512. end
  2513.  
  2514. #--------------------------------------------------------------------------
  2515. # draw_number
  2516. #--------------------------------------------------------------------------
  2517. def draw_number
  2518. change_color(normal_color)
  2519. draw_text(cursor_x - 28, item_y, 22, line_height, "×")
  2520. draw_text(cursor_x, item_y, cursor_width - 4, line_height, @number, 2)
  2521. end
  2522.  
  2523. #--------------------------------------------------------------------------
  2524. # draw_total_price
  2525. #--------------------------------------------------------------------------
  2526. def draw_total_price
  2527. return if @item.nil?
  2528. return if @item.tocrafting_gold_fee == 0
  2529. width = contents_width - 8
  2530. draw_currency_value(@price * @number, @currency_unit, 4, price_y, width)
  2531. end
  2532.  
  2533. #--------------------------------------------------------------------------
  2534. # item_y # Y Coordinate of Item Name Display Line
  2535. #--------------------------------------------------------------------------
  2536. def item_y
  2537. contents_height / 2 - line_height * 3 / 2
  2538. end
  2539.  
  2540. #--------------------------------------------------------------------------
  2541. # price_y # Y Coordinate of Price Display Line
  2542. #--------------------------------------------------------------------------
  2543. def price_y
  2544. contents_height / 2 + line_height / 2
  2545. end
  2546.  
  2547. #--------------------------------------------------------------------------
  2548. # cursor_width
  2549. #--------------------------------------------------------------------------
  2550. def cursor_width
  2551. figures * 10 + 12
  2552. end
  2553.  
  2554. #--------------------------------------------------------------------------
  2555. # cursor_x # Get X Coordinate of Cursor
  2556. #--------------------------------------------------------------------------
  2557. def cursor_x
  2558. contents_width - cursor_width - 4
  2559. end
  2560.  
  2561. #--------------------------------------------------------------------------
  2562. # figures # Get Maximum Number of Digits for Quantity Display
  2563. #--------------------------------------------------------------------------
  2564. def figures
  2565. return 2
  2566. end
  2567.  
  2568. #--------------------------------------------------------------------------
  2569. # update # Frame Update
  2570. #--------------------------------------------------------------------------
  2571. def update
  2572. super
  2573. if active
  2574. last_number = @number
  2575. update_number
  2576. if @number != last_number
  2577. Sound.play_cursor
  2578. refresh
  2579. end
  2580. end
  2581. end
  2582.  
  2583. #--------------------------------------------------------------------------
  2584. # update_number # Update Quantity
  2585. #--------------------------------------------------------------------------
  2586. def update_number
  2587. change_number(1) if Input.repeat?(:RIGHT)
  2588. change_number(-1) if Input.repeat?(:LEFT)
  2589. change_number(10) if Input.repeat?(:UP)
  2590. change_number(-10) if Input.repeat?(:DOWN)
  2591. end
  2592.  
  2593. #--------------------------------------------------------------------------
  2594. # change_number
  2595. #--------------------------------------------------------------------------
  2596. def change_number(amount)
  2597. @number = [[@number + amount, @max].min, 1].max
  2598. end
  2599.  
  2600. #--------------------------------------------------------------------------
  2601. # update_cursor
  2602. #--------------------------------------------------------------------------
  2603. def update_cursor
  2604. cursor_rect.set(cursor_x, item_y, cursor_width, line_height)
  2605. end
  2606.  
  2607. #--------------------------------------------------------------------------
  2608. # update_info_window
  2609. #--------------------------------------------------------------------------
  2610. def update_info_window
  2611. @info_window.number = @number
  2612. @info_window.refresh
  2613. end
  2614.  
  2615. #--------------------------------------------------------------------------
  2616. # update_gold_window
  2617. #--------------------------------------------------------------------------
  2618. def update_gold_window
  2619. @gold_window.number = @number
  2620. @gold_window.refresh
  2621. end
  2622.  
  2623. end # class Window_TOCraftingNumber
  2624.  
  2625.  
  2626. #==============================================================================
  2627. # ++ Window_TOCraftingCover
  2628. #==============================================================================
  2629. class Window_TOCraftingCover < Window_Base
  2630. #--------------------------------------------------------------------------
  2631. # refresh
  2632. #--------------------------------------------------------------------------
  2633. def refresh
  2634. contents.clear
  2635. draw_bookcover(0, 0)
  2636. end
  2637.  
  2638. #--------------------------------------------------------------------------
  2639. # item=
  2640. #--------------------------------------------------------------------------
  2641. def item=(item)
  2642. @item = item
  2643. refresh
  2644. end
  2645.  
  2646. #--------------------------------------------------------------------------
  2647. # stretch_pictures?
  2648. #--------------------------------------------------------------------------
  2649. def stretch_pictures?
  2650. Bubs::TOCrafting::STRETCH_RECIPEBOOK_PICTURES
  2651. end
  2652.  
  2653. #--------------------------------------------------------------------------
  2654. # draw_bookcover
  2655. #--------------------------------------------------------------------------
  2656. def draw_bookcover(x, y)
  2657. return unless @item
  2658. bitmap = Cache.recipebook_cover(@item.tocrafting_bookcover)
  2659. rect = Rect.new(0, 0, contents.width, contents.height)
  2660. if stretch_pictures?
  2661. contents.stretch_blt(rect, bitmap, bitmap.rect)
  2662. else
  2663. x = (contents.width - bitmap.width) / 2
  2664. y = (contents.height - bitmap.height) / 2
  2665. contents.blt(x, y, bitmap, rect)
  2666. end
  2667. bitmap.dispose
  2668. end
  2669.  
  2670. end # class Window_TOCraftingCover
  2671.  
  2672.  
  2673. #==============================================================================
  2674. # ++ Game_Interpreter
  2675. #==============================================================================
  2676. class Game_Interpreter
  2677. #--------------------------------------------------------------------------
  2678. # new method : call_tocrafting_scene
  2679. #--------------------------------------------------------------------------
  2680. def call_tocrafting_scene(*args)
  2681. SceneManager.call(Scene_TOCrafting)
  2682. SceneManager.scene.prepare(args)
  2683. end
  2684. alias open_tocrafting_shop call_tocrafting_scene
  2685. end
  2686.  
  2687.  
  2688. #==============================================================================
  2689. # ++ Scene_TOCrafting
  2690. #==============================================================================
  2691. class Scene_TOCrafting < Scene_MenuBase
  2692. #--------------------------------------------------------------------------
  2693. # prepare
  2694. #--------------------------------------------------------------------------
  2695. def prepare(categories)
  2696. @categories = categories
  2697. end
  2698.  
  2699. #--------------------------------------------------------------------------
  2700. # start
  2701. #--------------------------------------------------------------------------
  2702. def start
  2703. super
  2704. create_help_window
  2705. create_gold_window
  2706. create_cover_window
  2707. create_info_window
  2708. create_itemlist_header_window
  2709. create_itemlist_window
  2710. create_recipelist_window
  2711. create_number_window
  2712. create_result_window
  2713. end
  2714.  
  2715. #--------------------------------------------------------------------------
  2716. # create_gold_window
  2717. #--------------------------------------------------------------------------
  2718. def create_gold_window
  2719. @gold_window = Window_TOCraftingGold.new
  2720. @gold_window.viewport = @viewport
  2721. @gold_window.hide.close
  2722. @gold_window.x = 0
  2723. @gold_window.y = Graphics.height - @gold_window.height
  2724. end
  2725.  
  2726. #--------------------------------------------------------------------------
  2727. # create_recipelist_window
  2728. #--------------------------------------------------------------------------
  2729. def create_recipelist_window
  2730. wx = 0
  2731. wy = @help_window.height
  2732. wh = Graphics.height - wy
  2733. @recipelist_window = Window_TOCraftingRecipeList.new(wx, wy, wh)
  2734. @recipelist_window.viewport = @viewport
  2735. @recipelist_window.help_window = @help_window
  2736. @recipelist_window.info_window = @info_window
  2737. @recipelist_window.header_window = @itemlist_header_window
  2738. @recipelist_window.cover_window = @cover_window
  2739. @recipelist_window.categories = @categories
  2740. @recipelist_window.set_handler(:ok, method(:on_recipelist_ok))
  2741. @recipelist_window.set_handler(:cancel, method(:on_recipelist_cancel))
  2742. @recipelist_window.refresh
  2743. @recipelist_window.show.activate.select(0)
  2744. end
  2745.  
  2746. #--------------------------------------------------------------------------
  2747. # on_recipelist_ok
  2748. #--------------------------------------------------------------------------
  2749. def on_recipelist_ok
  2750. @recipelist_window.close
  2751. @itemlist_window.item = @recipelist_window.item
  2752. @gold_window.show.open if gold_window?
  2753. @cover_window.hide
  2754. @info_window.show
  2755. @info_window.set_page_keys
  2756. activate_itemlist_window
  2757. end
  2758.  
  2759. #--------------------------------------------------------------------------
  2760. # on_recipelist_cancel
  2761. #--------------------------------------------------------------------------
  2762. def on_recipelist_cancel
  2763. refresh
  2764. return_scene
  2765. end
  2766.  
  2767. #--------------------------------------------------------------------------
  2768. # activate_recipelist_window
  2769. #--------------------------------------------------------------------------
  2770. def activate_recipelist_window
  2771. refresh
  2772. @recipelist_window.show.open.activate
  2773. end
  2774.  
  2775. #--------------------------------------------------------------------------
  2776. # create_itemlist_window
  2777. #--------------------------------------------------------------------------
  2778. def create_itemlist_window
  2779. wx = 0
  2780. wy = @help_window.height + @itemlist_header_window.height
  2781. wh = Graphics.height - wy
  2782. wh = wh - @gold_window.height if gold_window?
  2783. @itemlist_window = Window_TOCraftingItemList.new(wx, wy, wh)
  2784. @itemlist_window.viewport = @viewport
  2785. @itemlist_window.help_window = @help_window
  2786. @itemlist_window.info_window = @info_window
  2787. @itemlist_window.gold_window = @gold_window
  2788. @itemlist_window.hide
  2789. @itemlist_window.close
  2790. @itemlist_window.set_handler(:ok, method(:on_itemlist_ok))
  2791. @itemlist_window.set_handler(:cancel, method(:on_itemlist_cancel))
  2792. @itemlist_window.refresh
  2793. end
  2794.  
  2795. #--------------------------------------------------------------------------
  2796. # on_itemlist_ok
  2797. #--------------------------------------------------------------------------
  2798. def on_itemlist_ok
  2799. @item = @itemlist_window.item
  2800. @itemlist_window.close.hide
  2801. @number_window.set(@item, max_craft, crafting_fee)
  2802. @info_window.page_change = false
  2803. @info_window.set_page_keys
  2804. @number_window.show.open.activate
  2805. end
  2806.  
  2807. #--------------------------------------------------------------------------
  2808. # on_itemlist_cancel
  2809. #--------------------------------------------------------------------------
  2810. def on_itemlist_cancel
  2811. @itemlist_window.close
  2812. @itemlist_header_window.close
  2813. @gold_window.close.hide if gold_window?
  2814. @info_window.hide
  2815. @cover_window.show
  2816. activate_recipelist_window
  2817. end
  2818.  
  2819. #--------------------------------------------------------------------------
  2820. # activate_itemlist_window
  2821. #--------------------------------------------------------------------------
  2822. def activate_itemlist_window
  2823. refresh
  2824. @itemlist_header_window.show.open
  2825. @itemlist_window.show.open.activate.select(0)
  2826. end
  2827.  
  2828. #--------------------------------------------------------------------------
  2829. # create_number_window
  2830. #--------------------------------------------------------------------------
  2831. def create_number_window
  2832. wx = 0
  2833. wy = @itemlist_header_window.y + @itemlist_header_window.height
  2834. wh = Graphics.height - wy
  2835. wh = wh - @gold_window.height if gold_window?
  2836. @number_window = Window_TOCraftingNumber.new(wx, wy, wh)
  2837. @number_window.viewport = @viewport
  2838. @number_window.info_window = @info_window
  2839. @number_window.gold_window = @gold_window
  2840. @number_window.hide.close
  2841. @number_window.set_handler(:ok, method(:on_number_ok))
  2842. @number_window.set_handler(:cancel, method(:on_number_cancel))
  2843. end
  2844.  
  2845. #--------------------------------------------------------------------------
  2846. # on_number_ok
  2847. #--------------------------------------------------------------------------
  2848. def on_number_ok
  2849. @number_window.close.hide
  2850. @number_window.number
  2851. do_crafting(@item, @number_window.number)
  2852. @result_window.set(@item, @number_window.number)
  2853. @result_window.show.open.activate
  2854. @itemlist_window.show.open
  2855. @info_window.page_change = true
  2856.  
  2857. @gold_window.number = @info_window.number = 1
  2858. refresh
  2859. @result_window.show.open.activate
  2860. end
  2861.  
  2862. #--------------------------------------------------------------------------
  2863. # on_number_cancel
  2864. #--------------------------------------------------------------------------
  2865. def on_number_cancel
  2866. @number_window.close.hide
  2867. @gold_window.number = @info_window.number = 1
  2868. @info_window.page_change = true
  2869. @itemlist_window.show.open.activate
  2870. end
  2871.  
  2872. #--------------------------------------------------------------------------
  2873. # create_result_window
  2874. #--------------------------------------------------------------------------
  2875. def create_result_window
  2876. wx = Graphics.width / 4
  2877. wy = 0
  2878. @result_window = Window_TOCraftingResult.new(wx, wy)
  2879. @result_window.y = (Graphics.height / 2) - (@result_window.height / 2)
  2880. @result_window.viewport = @viewport
  2881. @result_window.hide.close
  2882. @result_window.set_handler(:ok, method(:on_result_ok))
  2883. @result_window.refresh
  2884. end
  2885.  
  2886. #--------------------------------------------------------------------------
  2887. # on_result_ok
  2888. #--------------------------------------------------------------------------
  2889. def on_result_ok
  2890. @result_window.close.hide
  2891. @itemlist_window.activate
  2892. end
  2893.  
  2894. #--------------------------------------------------------------------------
  2895. # create_itemlist_header_window
  2896. #--------------------------------------------------------------------------
  2897. def create_itemlist_header_window
  2898. wx = 0
  2899. wy = @help_window.height
  2900. @itemlist_header_window = Window_TOCraftingItemListHeader.new(wx, wy)
  2901. @itemlist_header_window.viewport = @viewport
  2902. @itemlist_header_window.hide
  2903. @itemlist_header_window.close
  2904. @itemlist_header_window.refresh
  2905. end
  2906.  
  2907. #--------------------------------------------------------------------------
  2908. # create_cover_window
  2909. #--------------------------------------------------------------------------
  2910. def create_cover_window
  2911. wx = Graphics.width / 2
  2912. wy = @help_window.height
  2913. wh = Graphics.height - @help_window.height
  2914. ww = Graphics.width - wx
  2915. @cover_window = Window_TOCraftingCover.new(wx, wy, ww, wh)
  2916. @cover_window.viewport = @viewport
  2917. @cover_window.refresh
  2918. @cover_window.show
  2919. end
  2920.  
  2921. #--------------------------------------------------------------------------
  2922. # create_info_window
  2923. #--------------------------------------------------------------------------
  2924. def create_info_window
  2925. wx = Graphics.width / 2
  2926. wy = @help_window.height
  2927. ww = Graphics.width - wx
  2928. wh = Graphics.height - @help_window.height
  2929. @info_window = Window_TOCraftingInfo.new(wx, wy, ww, wh)
  2930. @info_window.viewport = @viewport
  2931. @info_window.hide
  2932. @info_window.refresh
  2933. end
  2934.  
  2935. #--------------------------------------------------------------------------
  2936. # refresh
  2937. #--------------------------------------------------------------------------
  2938. def refresh
  2939. @info_window.refresh
  2940. @help_window.refresh
  2941. @itemlist_window.refresh
  2942. @recipelist_window.refresh
  2943. @result_window.refresh
  2944. @itemlist_header_window.refresh
  2945. @gold_window.refresh
  2946. end
  2947.  
  2948. #--------------------------------------------------------------------------
  2949. # do_crafting
  2950. #--------------------------------------------------------------------------
  2951. def do_crafting(item, number)
  2952. return unless item
  2953. play_crafting_se(item)
  2954. lose_ingredients(item, number)
  2955. pay_crafting_fee(item, number)
  2956. gain_crafted_item(item, number)
  2957. end
  2958.  
  2959. #--------------------------------------------------------------------------
  2960. # play_crafting_se
  2961. #--------------------------------------------------------------------------
  2962. def play_crafting_se(item)
  2963. if item.tocrafting_se.empty?
  2964. Sound.play_tocrafting_result
  2965. else
  2966. se = item.tocrafting_se
  2967. Sound.play_custom_tocrafting_result(se[0], se[1], se[2])
  2968. end
  2969. end
  2970.  
  2971. #--------------------------------------------------------------------------
  2972. # lose_ingredients
  2973. #--------------------------------------------------------------------------
  2974. def lose_ingredients(item, number)
  2975. item.ingredient_list.each do |ingredient|
  2976. $game_party.lose_item(ingredient, number)
  2977. end
  2978. end
  2979.  
  2980. #--------------------------------------------------------------------------
  2981. # pay_crafting_fee
  2982. #--------------------------------------------------------------------------
  2983. def pay_crafting_fee(item, number)
  2984. $game_party.lose_gold(item.tocrafting_gold_fee * number)
  2985. end
  2986.  
  2987. #--------------------------------------------------------------------------
  2988. # gain_crafted_item
  2989. #--------------------------------------------------------------------------
  2990. def gain_crafted_item(item, number)
  2991. $game_party.gain_item(item, number)
  2992. end
  2993.  
  2994. #--------------------------------------------------------------------------
  2995. # crafting_fee
  2996. #--------------------------------------------------------------------------
  2997. def crafting_fee
  2998. @item.tocrafting_gold_fee
  2999. end
  3000.  
  3001. #--------------------------------------------------------------------------
  3002. # gold_window?
  3003. #--------------------------------------------------------------------------
  3004. def gold_window?
  3005. Bubs::TOCrafting::USE_GOLD_WINDOW
  3006. end
  3007.  
  3008. #--------------------------------------------------------------------------
  3009. # party_gold
  3010. #--------------------------------------------------------------------------
  3011. def party_gold
  3012. $game_party.gold
  3013. end
  3014.  
  3015. #--------------------------------------------------------------------------
  3016. # max_craft
  3017. #--------------------------------------------------------------------------
  3018. def max_craft
  3019. max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
  3020. max = crafting_fee == 0 ? max : [max, party_gold / crafting_fee].min
  3021. for ingredient in @item.ingredient_list.uniq.each
  3022. break if max == 0
  3023. count = @item.ingredient_list.count(ingredient)
  3024. temp_max = 0
  3025. for i in 1..max
  3026. break if (i * count) > $game_party.item_number(ingredient)
  3027. temp_max += 1
  3028. end # for
  3029. max = temp_max if max > temp_max
  3030. end # for
  3031. return max
  3032. end
  3033.  
  3034. end # class Scene_TOCrafting
  3035.  
  3036.  
  3037.  
  3038. if defined?(XAS_SYSTEM)
  3039. #==============================================================================
  3040. # ++ Window_ItemList
  3041. #==============================================================================
  3042. class Window_ItemList < Window_Selectable
  3043. #--------------------------------------------------------------------------
  3044. # compatibility alias : can_equip_item_action?
  3045. #--------------------------------------------------------------------------
  3046. alias can_equip_item_action_bubs_tocrafting can_equip_item_action?
  3047. def can_equip_item_action?
  3048. return false if SceneManager.scene_is?(Scene_TOCrafting)
  3049. return can_equip_item_action_bubs_tocrafting # alias
  3050. end
  3051. end # class Window_ItemList
  3052.  
  3053. end # if defined?(XAS_SYSTEM)
  3054.  
  3055.  
  3056. if $imported["YEA-AceMenuEngine"]
  3057. YEA::MENU::CUSTOM_COMMANDS.merge!(Bubs::TOCrafting::TOCRAFTING_CUSTOM_COMMAND)
  3058. #==============================================================================
  3059. # ++ Scene_Menu
  3060. #==============================================================================
  3061. class Scene_Menu < Scene_MenuBase
  3062. #--------------------------------------------------------------------------
  3063. # compatibility method : command_tocrafting
  3064. #--------------------------------------------------------------------------
  3065. def command_tocrafting(*args)
  3066. SceneManager.call(Scene_TOCrafting)
  3067. SceneManager.scene.prepare(args)
  3068. end
  3069. end # class Scene_Menu
  3070.  
  3071. end # if $imported["YEA-AceMenuEngine"]
Add Comment
Please, Sign In to add comment