mrbubble

Tactics Ogre PSP Crafting System header

May 18th, 2013
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 23.87 KB | None | 0 0
  1. # ╔══════════════════════════════════════════════════════╤═══════╤═══════════╗
  2. # ║ Tactics Ogre PSP Crafting System                     │ v2.03 │ (5/11/13) ║
  3. # ╚══════════════════════════════════════════════════════╧═══════╧═══════════╝
  4. # Script by:
  5. #     Mr. Bubble ( http://mrbubblewand.wordpress.com/ )
  6. # Thanks:
  7. #     Mithran, regexp references
  8. #     estriole, assistance with scene interpreter
  9. #--------------------------------------------------------------------------
  10. # This item crafting script is modeled after the crafting system implemented
  11. # in the PSP remake of Tactics Ogre: Let Us Cling Together. It's a very
  12. # simple crafting system with a very simple GUI which I also used as
  13. # a model.
  14. #
  15. # Players must have recipe books in their inventory when entering the
  16. # crafting scene. Any recipe books owned by the player will be displayed
  17. # in a list. When a recipe book is selected, all possible items, armors,
  18. # and weapons in the recipe book will be listed and you will be able to
  19. # craft them provided that the player has the necessary ingredients.
  20. #
  21. # The script "Info Pages Window" is required.
  22. #
  23. # Feel free to reguest custom information to be added to item info pages
  24. # in the crafting scene.
  25. #--------------------------------------------------------------------------
  26. #      Changelog  
  27. #--------------------------------------------------------------------------
  28. # v2.03 : Compatibility Update: "TH_SceneInterpreter"
  29. #       : Bugfix: Fixed bug where selecting the number to craft
  30. #       : ignores the amount of ingredients available. (5/11/2013)
  31. # v2.02 : Bugfix: Fixed categories nil error.
  32. # v2.01 : Bugfix: Fixed ingredient numbers in info window.
  33. #       : New tag: <craft result>. See comments for more info.
  34. #       : You can now run a common event after crafting an item.
  35. #       : You can now change how many of an item you gain per
  36. #       : set of ingredients. (5/02/2013)
  37. # v2.00 : Now requires script: "Info Pages Window".
  38. #       : This script will now check if any required scripts are
  39. #       : missing. If any are missing, the game will be exited.
  40. #       : Many crafting customization options related to the info
  41. #       : pages window have been removed.
  42. #       : Changed version number format.
  43. #       : $imported variable now uses version number.
  44. #       : Changed some methods, add-ons/patches may not work anymore.
  45. #       : Removed about 700+ lines of code. (5/02/2013)
  46. # v1.14 : Calling the crafting scene directly with SceneManager will
  47. #       : no longer crash the game. (4/28/2013)
  48. # v1.13 : Bugfix: Custom craft result sound effects should no longer
  49. #       : crash the game.
  50. #       : Equippable members info page added.
  51. #       : Cleaned up some code. (3/26/13)
  52. # v1.12 : Quick compatibility update with Tsukihime's TO Crafting Shop
  53. #       : script. (3/13/13)
  54. # v1.11 : You can now require specific actors in the party as a crafting
  55. #       : requirement.
  56. #       : New ingredient notetag added.
  57. #       : New options in the customization module added.
  58. #       : Slight code efficiency update. (2/06/2013)
  59. # v1.10 : TP Recovery now displays the correct value.
  60. #       : Recipebook images are now centered by default. (9/04/2012)
  61. # v1.09 : State resistance item info is now viewable.
  62. #       : Footer text is now properly aligned. (8/28/2012)
  63. # v1.08 : Compatibility: "YEA-AceMenuEngine" support added.
  64. #       : You can now view item details in the crafting scene if the
  65. #       : script "Reader Functions for Features/Effects" is installed.
  66. #       : Info window style has changed.
  67. #       : Any amount of ingredients can now be displayed, not just 6.
  68. #       : Configuration module has many new settings.
  69. #       : Some method names have changed.
  70. #       : Removed a chunk of redundant code.
  71. #       : Efficiency update. (8/25/2012)
  72. # v1.07 : Fixed issue where you can still craft from a recipebook even if
  73. #       : you have zero left as a result of using it in a crafting recipe.
  74. #       : Script call for the crafting scene has changed. The old one can
  75. #       : still be used though.
  76. #       : New Notetag for recipebooks added.
  77. #       : You can now choose which recipebooks can be included in the
  78. #       : crafting scene by category.
  79. #       : Efficiency update. (8/18/2012)
  80. # v1.06 : Compatibility: "XAS VX Ace" support added. (8/08/2012)
  81. # v1.05 : You can now change the recipebook pictures directory.
  82. #       : You can now assign sound effects for crafted items.
  83. #       : Slight code efficiency update. (7/29/2012)
  84. # v1.04 : Added the option to use images as recipebook covers.
  85. #       : New Notetag for recipebooks added.
  86. #       : New option in customization module for book images. (7/27/2012)
  87. # v1.03 : Colon between type and ID no longer needed.
  88. #       : Updated comments to reflect changes.
  89. #       : Tool regexp updated. (7/27/2012)
  90. # v1.02 : You can now change the Gold icon in the customization module.
  91. #       : You can now change the name of Gold in windows. (7/27/2012)
  92. # v1.01 : Fixed issue with long item names getting cut off in windows.
  93. #       : Confirm window removed.
  94. #       : Quantity selection window implemented.
  95. #       : Crafting Gold fee implemented.
  96. #       : Crafting tool requirement implemented.
  97. #       : New options added in customization module. (7/26/2012)
  98. # v1.00 : Initial release. (7/25/2012)
  99. #--------------------------------------------------------------------------
  100. #      Installation & Requirements
  101. #--------------------------------------------------------------------------
  102. # Install this script in the Materials section in your project's
  103. # script editor BELOW the script "Info Pages Window".
  104. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  105. #      Notetags  
  106. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  107. # Note: Some tags are given shorter tags for typing convenience. You only
  108. #       need to use one <tag> from a given group for a notebox.
  109. #       Use common sense.
  110. #
  111. # The following Notetags are for Items, Weapons, and Armors only:
  112. #
  113. # <recipebook>
  114. # setting
  115. # setting
  116. # </recipebook>
  117. #   This tag allows you define a recipe book. You can add as many
  118. #   settings between the <recipebook> tags as you like. Only items with
  119. #   this tag will appear in the recipes window in the crafting scene.
  120. #   The following settings are available:
  121. #
  122. #     item: id
  123. #     item: id, id, id ...
  124. #     i: id
  125. #     i: id, id, id ...
  126. #       This setting defines the items that can be crafted from the
  127. #       recipe book where id is the Item ID number found in your database.
  128. #       You can list multiple id numbers on the same line separated by commas.
  129. #       This setting can be used multiple times within the <recipebook> tags.
  130. #
  131. #     weapon: id
  132. #     weapon: id, id, id ...
  133. #     w: id
  134. #     w: id, id, id ...
  135. #       This setting defines the weapons that can be crafted from the
  136. #       recipe book where id is the Weapon ID number found in your database.
  137. #       You can list multiple id numbers on the same line separated by commas.
  138. #       This setting can be used multiple times within the <recipebook> tags.
  139. #      
  140. #     armor: id
  141. #     armor: id, id, id ...
  142. #     armour: id
  143. #     armour: id, id, id ...
  144. #     a: id
  145. #     a: id, id, id ...
  146. #       This setting defines the armors that can be crafted from the
  147. #       recipe book where id is the Armor ID number found in your database.
  148. #       You can list multiple id numbers on the same line separated by commas.
  149. #       This setting can be used multiple times within the <recipebook> tags.
  150. #
  151. #     picture: filename
  152. #     pic: filename
  153. #     cover: filename
  154. #       This setting defines the image used to represent the recipe book
  155. #       in the crafting scene where filename is the name of a picture
  156. #       located in the Graphics/Pictures/ folder of your project. Do
  157. #       not include the filename's extension. Recommended picture
  158. #       resolutions are [width: 248, height: 320] for default resolutions
  159. #       and [width: 296, height: 384] for 480x640 resolutions.
  160. #
  161. #     category: name
  162. #       This setting defines the recipebook's category label. Category
  163. #       labels are used by developers to determine which recipebooks
  164. #       they want included in the crafting scene. If a category label is
  165. #       not defined, the default category is "none". This is a completely
  166. #       optional setting.
  167. #  
  168. # <ingredients>
  169. # setting
  170. # setting
  171. # </ingredients>
  172. #   This tag allows you define the ingredients required to craft an item.
  173. #   You can add as many settings between the <ingredients> tags as you like.
  174. #   If an item, weapon, or armor has no ingredients, you can still craft it.
  175. #   The following settings are available:
  176. #
  177. #     item: id
  178. #     item: id xN
  179. #     i: id
  180. #     i: id xN
  181. #       This setting defines the item ingredients required to craft the
  182. #       item, weapon, or armor where id is the Item ID number found in
  183. #       your database. xN is total number of that ingredient required if
  184. #       it is included after the id number where N is a whole number
  185. #       (ex. x2, x3, x4, etc.). If xN is not included, the script will
  186. #       automatically assume x1. You can list multiple id numbers on the
  187. #       same line separated by commas. This setting can be used multiple
  188. #       times within the <ingredients> tags.
  189. #
  190. #     weapon: id
  191. #     weapon: id xN
  192. #     w: id
  193. #     w: id xN
  194. #       This setting defines the weapon ingredients required to craft the
  195. #       item, weapon, or armor where id is the Weapon ID number found in
  196. #       your database. xN is total number of that ingredient required if
  197. #       it is included after the id number where N is a whole number
  198. #       (ex. x2, x3, x4, etc.). If xN is not included, the script will
  199. #       automatically assume x1. You can list multiple id numbers on the
  200. #       same line separated by commas. This setting can be used multiple
  201. #       times within the <ingredients> tags.
  202. #
  203. #     armor: id
  204. #     armor: id xN
  205. #     armour: id
  206. #     armour: id xN
  207. #     a: id
  208. #     a: id xN
  209. #       This setting defines the armor ingredients required to craft the
  210. #       item, weapon, or armor where id is the Weapon ID number found in
  211. #       your database. xN is total number of that ingredient required if
  212. #       it is included after the id number where N is a whole number
  213. #       (ex. x2, x3, x4, etc.). If xN is not included, the script will
  214. #       automatically assume x1. You can list multiple id numbers on the
  215. #       same line separated by commas. This setting can be used multiple
  216. #       times within the <ingredients> tags.
  217. #
  218. #     gold: amount
  219. #       This setting defines the amount of Gold required to craft
  220. #       the item, armor, or weapon where amount is any amount of gold.
  221. #       If this setting is omitted, it will use the default fee defined
  222. #       in the customization module.
  223. #
  224. #     tool: item id
  225. #     tool: i id
  226. #     tool: weapon id
  227. #     tool: w id
  228. #     tool: armor id
  229. #     tool: armour id
  230. #     tool: a id
  231. #       This setting defines the tools required to craft the item, weapon,
  232. #       or armor where id is the item, weapon, or armor ID number found in
  233. #       your database. Tools are not consumed in the crafting process.
  234. #       This setting can be used multiple times within the <ingredients>
  235. #       tags.
  236. #
  237. #     actor: actor_id
  238. #       This setting defines the actor required to craft the item, weapon,
  239. #       or armor where actor_id is the actor ID number from your database.
  240. #       Currently, nothing happens to the actor after crafting an item
  241. #       that requires one. This setting can be used multiple times within
  242. #       the <ingredients> tags.
  243. #
  244. # <craft result>
  245. # setting
  246. # setting
  247. # </craft result>
  248. #   This tag allows you to define what happens after an item is
  249. #   crafted. You can add as many settings between the <craft result>
  250. #   tags as you like.
  251. #   The following settings are available:
  252. #
  253. #     se: filename, volume, pitch
  254. #       This setting defines the custom sound effect played when the
  255. #       item is crafted. filename is a sound effect filename found in
  256. #       the Audio/SE/ folder. volume is a value between 0~100. pitch is
  257. #       a value between 50~150. If this setting is omitted, the default
  258. #       crafting sound effect defined in the customization module will
  259. #       play instead.
  260. #
  261. #     amount: n
  262. #       This setting defines the amount that is produced from one
  263. #       set of ingredients, where n is a number. By default, the
  264. #       amount produced from one set of ingredients is 1.
  265. #
  266. #     common event: id
  267. #     cev: id
  268. #       This setting defines a common event that runs right after an
  269. #       item is crafted where id is a common event ID number
  270. #       from your database.
  271. #
  272. # Here are some examples of proper <recipebook> tags and <ingredients> tags:
  273. #
  274. #     <recipebook>
  275. #     weapon: 1, 2, 7, 8, 13, 14, 19, 20
  276. #     weapon: 25, 37, 38
  277. #     armor: 1, 2, 3, 4, 5
  278. #     item: 40
  279. #     </recipebook>
  280. #
  281. # It is important to know that Note boxes have iffy word wrap distinction.
  282. # If a line is too long and overflows into the next line, that next line
  283. # might be treated as a new line in the Note box. To stay on the safe side,
  284. # if you have a long list of ids for a single item type setting, you
  285. # should start the next line with the similar type setting. See the
  286. # "weapon:" settings in this example tag.
  287. #
  288. #     <ingredients>
  289. #     item: 29 x3
  290. #     item: 30 x2
  291. #     item: 31
  292. #     </ingredients>
  293. #
  294. # Each ingredient id must be on its own line, unlike the recipebook tag.
  295. # More than 6 ingredients are possible, but the Required Ingredients
  296. # window will not display more than 6. The last setting tag "item: 31" does
  297. # not have an "xN" multiplier which means the script will automatically
  298. # assume "x1".
  299. #
  300. #     <ingredients>
  301. #     fee: 30
  302. #     se: Bell3, 80, 100
  303. #     tool: item 40
  304. #     item: 21
  305. #     item: 22 x2
  306. #     </ingredients>
  307. #
  308. # This tag is an example of how to use the "fee" and "tool" setting tags.
  309. # Item ID 40 is required to craft the item, but it will not be consumed.
  310. # Each item crafted costs 30 gold. The sound effect Bell3 will play
  311. # when the item is crafted.
  312. #
  313. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  314. #      Script Calls  
  315. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  316. # The following Script Calls are meant to be used in "Script..." event
  317. # commands found under Tab 3 when creating a new event.
  318. #
  319. # call_tocrafting_scene
  320. #   This script call opens up a Tactics Ogre Crafting scene with all
  321. #   recipebooks the player has in their inventory.
  322. #
  323. # call_tocrafting_scene( :category, :category, ...)
  324. #   This script call opens up the Tactics Ogre Crafting scene with
  325. #   only recipebooks that have the category included in one of the
  326. #   script call's arguments. You can list as many categories in the
  327. #   script call's arguments separated by commas as you like. Category
  328. #   names must always be preceeded by a colon (:).
  329. #
  330. # Here is an example of a script call using call_tocrafting_scene with
  331. # category arguments:
  332. #
  333. #   call_tocrafting_scene( :smithing )
  334. #  
  335. # This script call will open up the crafting scene with only recipebooks
  336. # that have the category of "smithing".
  337. #
  338. #--------------------------------------------------------------------------
  339. #      FAQ  
  340. #--------------------------------------------------------------------------
  341. # --Why am I allowed to craft items that have no required ingredients?
  342. #
  343. #     This was done on purpose to ease game development. I assumed that
  344. #     when people finalize a game, they will have an appropriate list of
  345. #     ingredients for each craftable item defined by then.
  346. #
  347. # --Can an item/armor/weapon have a <recipebook> tag AND an <ingredients>
  348. #   tag?
  349. #  
  350. #     Yes.
  351. #
  352. # --Why isn't "Success Rate" also implemented in this script from
  353. #   Tactics Ogre PSP?
  354. #
  355. #     Because I think Success Rate on crafting in single-player games
  356. #     is annoying and pointless due to save and load. But if there is
  357. #     demand for it, I can implement it.
  358. #--------------------------------------------------------------------------
  359. #      Compatibility  
  360. #--------------------------------------------------------------------------
  361. # This script aliases the following default VXA methods:
  362. #
  363. #     DataManager#load_database
  364. #    
  365. # There are no default method overwrites.
  366. #
  367. # This script has built-in compatibility with the following scripts:
  368. #
  369. #     -Xiderwong Action System (XAS) VX Ace
  370. #     -Yanfly Engine Ace - Ace Menu Engine by YF
  371. #     -Scene Interpreter by Tsukihime
  372. #
  373. # Requests for compatibility with other scripts are welcome.
  374. #--------------------------------------------------------------------------
  375. #      Terms and Conditions  
  376. #--------------------------------------------------------------------------
  377. # Please do not repost this script elsewhere without permission.
  378. # Free for non-commercial use. For commercial use, contact me first.
  379. #
  380. # Newest versions of this script can be found at
  381. #                                           http://mrbubblewand.wordpress.com/
  382. #=============================================================================
  383.  
  384. $imported ||= {}
  385. $imported["BubsTOCrafting"] = 2.03
  386.  
  387. #==========================================================================
  388. # ++ START OF USER CUSTOMIZATION MODULE ++
  389. #==========================================================================
  390. module Bubs
  391.   #==========================================================================
  392.   # ++ TO Crafting Settings
  393.   #==========================================================================
  394.   module TOCrafting
  395.   #--------------------------------------------------------------------------
  396.   #   Ingredients List Display Settings
  397.   #--------------------------------------------------------------------------
  398.   INGREDIENTS_HEADER_TEXT = "Ingredients" # Header text
  399.   INGREDIENTS_PAGE_SIZE = 5 # 6 is recommended for 640x480 resolutions
  400.   NOT_ENOUGH_INGREDIENTS_COLOR = 10 # Windowskin color index, default 10 (red)
  401.  
  402.   #--------------------------------------------------------------------------
  403.   #   Ingredients Info Page Footer Text
  404.   #--------------------------------------------------------------------------
  405.   # Recommended length: 22 characters "                      "
  406.   INGREDIENTS_VIEW_MORE_FOOTER_TEXT = "←A  Shift: More...  S→"
  407.  
  408.   #--------------------------------------------------------------------------
  409.   #   Tools Display Settings
  410.   #--------------------------------------------------------------------------
  411.   TOOL_AVAILABLE_TEXT = "Available"
  412.   TOOL_AVAILABLE_TEXT_COLOR = 3 # Windowskin color index, default 3 (green)
  413.   TOOL_UNAVAILABLE_TEXT = "Unavailable"
  414.   TOOL_UNAVAILABLE_TEXT_COLOR = 10 # Windowskin color index, default 10 (red)
  415.  
  416.   #--------------------------------------------------------------------------
  417.   #   Faded Requirement Not Met Display Settings
  418.   #--------------------------------------------------------------------------
  419.   # true  : Ingredient quantity and Tool requirement text will be faded
  420.   #         out like the item name if the requirement isn't met
  421.   # false : Ingredient quantity and Tool requirement text will not be faded
  422.   FADED_REQUIREMENT_QUANTITY = false
  423.    
  424.   #--------------------------------------------------------------------------
  425.   #   Crafting Gold Fee Default Markdown/Markup Rate
  426.   #--------------------------------------------------------------------------
  427.   # If a "gold: amount" setting is not included in an <ingredients> tag,
  428.   # it will use the item's Price in the database by default. This setting
  429.   # allows you to automatically increase or decrease that item, armor
  430.   # or weapon price by a specified rate where 100.0 is normal price and
  431.   # 0.0 is free.
  432.   CRAFTING_FEE_PRICE_RATE = 0.0
  433.   #--------------------------------------------------------------------------
  434.   #   Gold Window Settings
  435.   #--------------------------------------------------------------------------
  436.   # true  : Gold window appears in crafting scene
  437.   # false : Gold crafting fees appear in ingredients list, no gold window
  438.   USE_GOLD_WINDOW = true
  439.   GOLD_WINDOW_ICON_INDEX = 361 # Icon Index number
  440.   GOLD_WINDOW_TEXT = "Gold"
  441.  
  442.   #--------------------------------------------------------------------------
  443.   #   Crafting Result Header Text
  444.   #--------------------------------------------------------------------------
  445.   RESULT_WINDOW_HEADER_TEXT = "You Received"
  446.  
  447.   #--------------------------------------------------------------------------
  448.   #   Stretch Recipebook Pictures Setting
  449.   #--------------------------------------------------------------------------
  450.   # Recommended width and height for book covers images:
  451.   #
  452.   #     width: 248, height: 320 (default resolutions)
  453.   #     width: 296, height: 384 (480x640 resolutions)
  454.   #
  455.   # true  : Book cover pics are stretched to fit the contents of the window.
  456.   # false : Book cover pics are drawn normally.
  457.   STRETCH_RECIPEBOOK_PICTURES = false
  458.   #--------------------------------------------------------------------------
  459.   #   Recipebook Images Folder Directory
  460.   #--------------------------------------------------------------------------
  461.   # Project folder where recipebook pictures are located.
  462.   #
  463.   # Default: "Graphics/Pictures/"
  464.   RECIPEBOOK_PICTURES_DIRECTORY = "Graphics/Pictures/"
  465.  
  466.   #--------------------------------------------------------------------------
  467.   #   Default Crafting Result Sound Effect
  468.   #--------------------------------------------------------------------------
  469.   # Filename : SE filename in Audio/SE/ folder
  470.   # Volume   : Between 0~100
  471.   # Pitch    : Between 50~150
  472.   #
  473.   #                       Filename, Volume, Pitch
  474.   CRAFTING_RESULT_SE = [   "Bell2",     80,   100]
  475.    
  476.   #--------------------------------------------------------------------------
  477.   #   Actor Requirement Display Settings
  478.   #--------------------------------------------------------------------------
  479.   ACTOR_AVAILABLE_TEXT = "Available"
  480.   ACTOR_AVAILABLE_TEXT_COLOR = 3 # Windowskin color index, default 3 (green)
  481.   ACTOR_UNAVAILABLE_TEXT = "Unavailable"
  482.   ACTOR_UNAVAILABLE_TEXT_COLOR = 10 # Windowskin color index, default 10 (red)
  483.  
  484.   #--------------------------------------------------------------------------
  485.   #   Change Ingredident Page Button
  486.   #--------------------------------------------------------------------------
  487.   # This setting determine which gamepad button changes the ingredient
  488.   # window page. Possible buttons include :LEFT, :RIGHT, :UP, :DOWN,
  489.   # :A, :B, :C, :X, :Y, :Z, :L, :R
  490.   NEXT_INGREDIENT_PAGE_BUTTON = :A
  491.    
  492.   #--------------------------------------------------------------------------
  493.   #   YEA Ace Menu Engine - Custom Menu Command Setting
  494.   #--------------------------------------------------------------------------
  495.   # This setting only takes effect when YEA - Ace Menu Engine is installed
  496.   # in the same project.
  497.   #
  498.   # To add the TOCrafting scene to Ace Menu Engine, look for a
  499.   # configuration setting called "- Main Menu Settings -". There is a
  500.   # variable called COMMANDS that has an array of orange symbols. Add
  501.   # the symbol :tocrafting to the COMMANDS array to add the crafting
  502.   # command to your menu.
  503.   #
  504.   # The setting here working exactly the same as the CUSTOM_COMMAND
  505.   # setting in Ace Menu Engine. For more information, please refer to
  506.   # the Ace Menu Engine script.
  507.   TOCRAFTING_CUSTOM_COMMAND = {
  508.   #             ["Display Name", EnableSwitch, ShowSwitch,      Handler Method],
  509.     :tocrafting => [  "Crafting",           0,          0, :command_tocrafting],
  510.   } # <- Do not delete.
  511.  
  512.   end # module TOCrafting
  513. end # module Bubs
Advertisement
Add Comment
Please, Sign In to add comment