Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ╔══════════════════════════════════════════════════════╤═══════╤═══════════╗
- # ║ Tactics Ogre PSP Crafting System │ v1.13 │ (3/26/13) ║
- # ╚══════════════════════════════════════════════════════╧═══════╧═══════════╝
- # Script by:
- # Mr. Bubble ( http://mrbubblewand.wordpress.com/ )
- # Thanks:
- # Mithran, regexp references
- #--------------------------------------------------------------------------
- # This item crafting script is modeled after the crafting system implemented
- # in the PSP remake of Tactics Ogre: Let Us Cling Together. It's a very
- # simple crafting system with a very simple GUI which I also used as
- # a model.
- #
- # Players must have recipe books in their inventory when entering the
- # crafting scene. Any recipe books owned by the player will be displayed
- # in a list. When a recipe book is selected, all possible items, armors,
- # and weapons in the recipe book will be listed and you will be able to
- # craft them provided that the player has the necessary ingredients.
- #
- # The script "Reader Functions for Features/Effects" v1.2 or above is
- # required to display item info with this script, but is optional in
- # terms of this script's ability to function.
- #
- # Feel free to reguest custom information to be added to item info pages
- # in the crafting scene.
- #--------------------------------------------------------------------------
- # ++ Changelog ++
- #--------------------------------------------------------------------------
- # v1.13 : Bugfix: Custom craft result sound effects should no longer
- # : crash the game.
- # : Equippable members info page added.
- # : Cleaned up some code. (3/26/13)
- # v1.12 : Quick compatibility update with Tsukihime's TO Crafting Shop
- # : script. (3/13/13)
- # v1.11 : You can now require specific actors in the party as a crafting
- # : requirement.
- # : New ingredient notetag added.
- # : New options in the customization module added.
- # : Slight code efficiency update. (2/06/2013)
- # v1.10 : TP Recovery now displays the correct value.
- # : Recipebook images are now centered by default. (9/04/2012)
- # v1.9 : State resistance item info is now viewable.
- # : Footer text is now properly aligned. (8/28/2012)
- # v1.8 : Compatibility: "YEA-AceMenuEngine" support added.
- # : You can now view item details in the crafting scene if the
- # : script "Reader Functions for Features/Effects" is installed.
- # : Info window style has changed.
- # : Any amount of ingredients can now be displayed, not just 6.
- # : Configuration module has many new settings.
- # : Some method names have changed.
- # : Removed a chunk of redundant code.
- # : Efficiency update. (8/25/2012)
- # v1.7 : Fixed issue where you can still craft from a recipebook even if
- # : you have zero left as a result of using it in a crafting recipe.
- # : Script call for the crafting scene has changed. The old one can
- # : still be used though.
- # : New Notetag for recipebooks added.
- # : You can now choose which recipebooks can be included in the
- # : crafting scene by category.
- # : Efficiency update. (8/18/2012)
- # v1.6 : Compatibility: "XAS VX Ace" support added. (8/08/2012)
- # v1.5 : You can now change the recipebook pictures directory.
- # : You can now assign sound effects for crafted items.
- # : Slight code efficiency update. (7/29/2012)
- # v1.4 : Added the option to use images as recipebook covers.
- # : New Notetag for recipebooks added.
- # : New option in customization module for book images. (7/27/2012)
- # v1.3 : Colon between type and ID no longer needed.
- # : Updated comments to reflect changes.
- # : Tool regexp updated. (7/27/2012)
- # v1.2 : You can now change the Gold icon in the customization module.
- # : You can now change the name of Gold in windows. (7/27/2012)
- # v1.1 : Fixed issue with long item names getting cut off in windows.
- # : Confirm window removed.
- # : Quantity selection window implemented.
- # : Crafting Gold fee implemented.
- # : Crafting tool requirement implemented.
- # : New options added in customization module. (7/26/2012)
- # v1.0 : Initial release. (7/25/2012)
- #--------------------------------------------------------------------------
- # ++ Installation ++
- #--------------------------------------------------------------------------
- # Install this script in the Materials section in your project's
- # script editor.
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # ++ Notetags ++
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # Note: Some tags are given shorter tags for typing convenience. You only
- # need to use one <tag> from a given group for a notebox.
- # Use common sense.
- #
- # The following Notetags are for Items, Weapons, and Armors only:
- #
- # <recipebook>
- # setting
- # setting
- # </recipebook>
- # This tag allows you define a recipe book. You can add as many
- # settings between the <recipebook> tags as you like. Only items with
- # this tag will appear in the recipes window in the crafting scene.
- # The following settings are available:
- #
- # item: id
- # item: id, id, id ...
- # i: id
- # i: id, id, id ...
- # This setting defines the items that can be crafted from the
- # recipe book where id is the Item ID number found in your database.
- # You can list multiple id numbers on the same line separated by commas.
- # This setting can be used multiple times within the <recipebook> tags.
- #
- # weapon: id
- # weapon: id, id, id ...
- # w: id
- # w: id, id, id ...
- # This setting defines the weapons that can be crafted from the
- # recipe book where id is the Weapon ID number found in your database.
- # You can list multiple id numbers on the same line separated by commas.
- # This setting can be used multiple times within the <recipebook> tags.
- #
- # armor: id
- # armor: id, id, id ...
- # armour: id
- # armour: id, id, id ...
- # a: id
- # a: id, id, id ...
- # This setting defines the armors that can be crafted from the
- # recipe book where id is the Armor ID number found in your database.
- # You can list multiple id numbers on the same line separated by commas.
- # This setting can be used multiple times within the <recipebook> tags.
- #
- # picture: filename
- # pic: filename
- # cover: filename
- # This setting defines the image used to represent the recipe book
- # in the crafting scene where filename is the name of a picture
- # located in the Graphics/Pictures/ folder of your project. Do
- # not include the filename's extension. Recommended picture
- # resolutions are [width: 248, height: 320] for default resolutions
- # and [width: 296, height: 384] for 480x640 resolutions.
- #
- # category: name
- # This setting defines the recipebook's category label. Category
- # labels are used by developers to determine which recipebooks
- # they want included in the crafting scene. If a category label is
- # not defined, the default category is "none". This is a completely
- # optional setting.
- #
- # <ingredients>
- # setting
- # setting
- # </ingredients>
- # This tag allows you define the ingredients required to craft an item.
- # You can add as many settings between the <ingredients> tags as you like.
- # If an item, weapon, or armor has no ingredients, you can still craft it.
- # The following settings are available:
- #
- # item: id
- # item: id xN
- # i: id
- # i: id xN
- # This setting defines the item ingredients required to craft the
- # item, weapon, or armor where id is the Item ID number found in
- # your database. xN is total number of that ingredient required if
- # it is included after the id number where N is a whole number
- # (ex. x2, x3, x4, etc.). If xN is not included, the script will
- # automatically assume x1. You can list multiple id numbers on the
- # same line separated by commas. This setting can be used multiple
- # times within the <ingredients> tags.
- #
- # weapon: id
- # weapon: id xN
- # w: id
- # w: id xN
- # This setting defines the weapon ingredients required to craft the
- # item, weapon, or armor where id is the Weapon ID number found in
- # your database. xN is total number of that ingredient required if
- # it is included after the id number where N is a whole number
- # (ex. x2, x3, x4, etc.). If xN is not included, the script will
- # automatically assume x1. You can list multiple id numbers on the
- # same line separated by commas. This setting can be used multiple
- # times within the <ingredients> tags.
- #
- # armor: id
- # armor: id xN
- # armour: id
- # armour: id xN
- # a: id
- # a: id xN
- # This setting defines the armor ingredients required to craft the
- # item, weapon, or armor where id is the Weapon ID number found in
- # your database. xN is total number of that ingredient required if
- # it is included after the id number where N is a whole number
- # (ex. x2, x3, x4, etc.). If xN is not included, the script will
- # automatically assume x1. You can list multiple id numbers on the
- # same line separated by commas. This setting can be used multiple
- # times within the <ingredients> tags.
- #
- # gold: amount
- # This setting defines the amount of Gold required to craft
- # the item, armor, or weapon where amount is any amount of gold.
- # If this setting is omitted, it will use the default fee defined
- # in the customization module.
- #
- # tool: item id
- # tool: i id
- # tool: weapon id
- # tool: w id
- # tool: armor id
- # tool: armour id
- # tool: a id
- # This setting defines the tools required to craft the item, weapon,
- # or armor where id is the item, weapon, or armor ID number found in
- # your database. Tools are not consumed in the crafting process.
- # This setting can be used multiple times within the <ingredients>
- # tags.
- #
- # actor: actor_id
- # This setting defines the actor required to craft the item, weapon,
- # or armor where actor_id is the actor ID number from your database.
- # Currently, nothing happens to the actor after crafting an item
- # that requires one. This setting can be used multiple times within
- # the <ingredients> tags.
- #
- # se: filename, volume, pitch
- # This setting defines the custom sound effect played when the
- # item is crafted. filename is a sound effect filename found in
- # the Audio/SE/ folder. volume is a value between 0~100. pitch is
- # a value between 50~150. If this setting is omitted, the default
- # crafting sound effect defined in the customization module will
- # play instead.
- #
- # Here are some examples of proper <recipebook> tags and <ingredients> tags:
- #
- # <recipebook>
- # weapon: 1, 2, 7, 8, 13, 14, 19, 20
- # weapon: 25, 37, 38
- # armor: 1, 2, 3, 4, 5
- # item: 40
- # </recipebook>
- #
- # It is important to know that Note boxes have iffy word wrap distinction.
- # If a line is too long and overflows into the next line, that next line
- # might be treated as a new line in the Note box. To stay on the safe side,
- # if you have a long list of ids for a single item type setting, you
- # should start the next line with the similar type setting. See the
- # "weapon:" settings in this example tag.
- #
- # <ingredients>
- # item: 29 x3
- # item: 30 x2
- # item: 31
- # </ingredients>
- #
- # Each ingredient id must be on its own line, unlike the recipebook tag.
- # More than 6 ingredients are possible, but the Required Ingredients
- # window will not display more than 6. The last setting tag "item: 31" does
- # not have an "xN" multiplier which means the script will automatically
- # assume "x1".
- #
- # <ingredients>
- # fee: 30
- # se: Bell3, 80, 100
- # tool: item 40
- # item: 21
- # item: 22 x2
- # </ingredients>
- #
- # This tag is an example of how to use the "fee" and "tool" setting tags.
- # Item ID 40 is required to craft the item, but it will not be consumed.
- # Each item crafted costs 30 gold. The sound effect Bell3 will play
- # when the item is crafted.
- #
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # ++ Script Calls ++
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # The following Script Calls are meant to be used in "Script..." event
- # commands found under Tab 3 when creating a new event.
- #
- # call_tocrafting_scene
- # This script call opens up a Tactics Ogre Crafting scene with all
- # recipebooks the player has in their inventory.
- #
- # call_tocrafting_scene( :category, :category, ...)
- # This script call opens up the Tactics Ogre Crafting scene with
- # only recipebooks that have the category included in one of the
- # script call's arguments. You can list as many categories in the
- # script call's arguments separated by commas as you like. Category
- # names must always be preceeded by a colon (:).
- #
- # Here is an example of a script call using call_tocrafting_scene with
- # category arguments:
- #
- # call_tocrafting_scene( :smithing )
- #
- # This script call will open up the crafting scene with only recipebooks
- # that have the category of "smithing".
- #
- #--------------------------------------------------------------------------
- # ++ FAQ ++
- #--------------------------------------------------------------------------
- # --Why am I allowed to craft items that have no required ingredients?
- #
- # This was done on purpose to ease game development. I assumed that
- # when people finalize a game, they will have an appropriate list of
- # ingredients for each craftable item defined by then.
- #
- # --Can an item/armor/weapon have a <recipebook> tag AND an <ingredients>
- # tag?
- #
- # Yes.
- #
- # --Why isn't "Success Rate" also implemented in this script from
- # Tactics Ogre PSP?
- #
- # Because I think Success Rate on crafting in single-player games
- # is annoying and pointless due to save and load. But if there is
- # demand for it, I can implement it.
- #--------------------------------------------------------------------------
- # ++ Compatibility ++
- #--------------------------------------------------------------------------
- # This script aliases the following default VXA methods:
- #
- # DataManager#load_database
- #
- # There are no default method overwrites.
- #
- # This script has built-in compatibility with the following scripts:
- #
- # -Xiderwong Action System (XAS) VX Ace
- # -Yanfly Engine Ace - Ace Menu Engine
- #
- # Requests for compatibility with other scripts are welcome.
- #--------------------------------------------------------------------------
- # ++ Terms and Conditions ++
- #--------------------------------------------------------------------------
- # Please do not repost this script elsewhere without permission.
- # Free for non-commercial use. For commercial use, contact me first.
- #
- # Newest versions of this script can be found at
- # http://mrbubblewand.wordpress.com/
- #=============================================================================
- $imported ||= {}
- $imported["BubsTOCrafting"] = true
- #==========================================================================
- # ++ START OF USER CUSTOMIZATION MODULE ++
- #==========================================================================
- module Bubs
- #==========================================================================
- # ++ TO Crafting Settings
- #==========================================================================
- module TOCrafting
- #--------------------------------------------------------------------------
- # Ingredients List Display Settings
- #--------------------------------------------------------------------------
- INGREDIENTS_HEADER_TEXT = "Ingredients" # Header text
- INGREDIENTS_PAGE_SIZE = 5 # 6 is recommended for 640x480 resolutions
- NOT_ENOUGH_INGREDIENTS_COLOR = 10 # Windowskin color index, default 10 (red)
- #--------------------------------------------------------------------------
- # Info Page Footer Text
- #--------------------------------------------------------------------------
- # Recommended length: 22 characters " "
- NORMAL_FOOTER_TEXT = "← →"
- INGREDIENTS_VIEW_MORE_FOOTER_TEXT = "← Shift: More... →"
- #--------------------------------------------------------------------------
- # Tools Display Settings
- #--------------------------------------------------------------------------
- TOOL_AVAILABLE_TEXT = "Available"
- TOOL_AVAILABLE_TEXT_COLOR = 3 # Windowskin color index, default 3 (green)
- TOOL_UNAVAILABLE_TEXT = "Unavailable"
- TOOL_UNAVAILABLE_TEXT_COLOR = 10 # Windowskin color index, default 10 (red)
- #--------------------------------------------------------------------------
- # Faded Requirement Not Met Display Settings
- #--------------------------------------------------------------------------
- # true : Ingredient quantity and Tool requirement text will be faded
- # out like the item name if the requirement isn't met
- # false : Ingredient quantity and Tool requirement text will not be faded
- FADED_REQUIREMENT_QUANTITY = false
- #--------------------------------------------------------------------------
- # Crafting Gold Fee Default Markdown/Markup Rate
- #--------------------------------------------------------------------------
- # If a "gold: amount" setting is not included in an <ingredients> tag,
- # it will use the item's Price in the database by default. This setting
- # allows you to automatically increase or decrease that item, armor
- # or weapon price by a specified rate where 100.0 is normal price and
- # 0.0 is free.
- CRAFTING_FEE_PRICE_RATE = 0.0
- #--------------------------------------------------------------------------
- # Gold Window Settings
- #--------------------------------------------------------------------------
- # true : Gold window appears in crafting scene
- # false : Gold crafting fees appear in ingredients list, no gold window
- USE_GOLD_WINDOW = true
- GOLD_WINDOW_ICON_INDEX = 361 # Icon Index number
- GOLD_WINDOW_TEXT = "Gold"
- #--------------------------------------------------------------------------
- # Crafting Result Header Text
- #--------------------------------------------------------------------------
- RESULT_WINDOW_HEADER_TEXT = "You Received"
- #--------------------------------------------------------------------------
- # Stretch Recipebook Pictures Setting
- #--------------------------------------------------------------------------
- # Recommended width and height for book covers images:
- #
- # width: 248, height: 320 (default resolutions)
- # width: 296, height: 384 (480x640 resolutions)
- #
- # true : Book cover pics are stretched to fit the contents of the window.
- # false : Book cover pics are drawn normally.
- STRETCH_RECIPEBOOK_PICTURES = false
- #--------------------------------------------------------------------------
- # Recipebook Images Folder Directory
- #--------------------------------------------------------------------------
- # Project folder where recipebook pictures are located.
- #
- # Default: "Graphics/Pictures/"
- RECIPEBOOK_PICTURES_DIRECTORY = "Graphics/Pictures/"
- #--------------------------------------------------------------------------
- # Default Crafting Result Sound Effect
- #--------------------------------------------------------------------------
- # Filename : SE filename in Audio/SE/ folder
- # Volume : Between 0~100
- # Pitch : Between 50~150
- #
- # Filename, Volume, Pitch
- CRAFTING_RESULT_SE = [ "Bell2", 80, 100]
- #--------------------------------------------------------------------------
- # Actor Icon Index Numbers
- #--------------------------------------------------------------------------
- # This setting lets you define the icon index number that represents
- # an actor in info windows.
- ACTOR_ICONS = {
- :default => 16,
- # actor_id => icon_index,
- 1 => 16,
- } # <- Do not delete.
- #--------------------------------------------------------------------------
- # Actor Requirement Display Settings
- #--------------------------------------------------------------------------
- ACTOR_AVAILABLE_TEXT = "Available"
- ACTOR_AVAILABLE_TEXT_COLOR = 3 # Windowskin color index, default 3 (green)
- ACTOR_UNAVAILABLE_TEXT = "Unavailable"
- ACTOR_UNAVAILABLE_TEXT_COLOR = 10 # Windowskin color index, default 10 (red)
- #--------------------------------------------------------------------------
- # Item Info Pages
- #--------------------------------------------------------------------------
- # This setting determines the order of info pages for usable items.
- # Each kind of info page is represented by a symbol. Possible symbols
- # include:
- #
- # :item_info # Requires "Reader Functions for Features/Effects"
- ITEM_INFO_PAGES = [:ingredients, # Page 1 (Required as 1st page)
- :item_info, # Page 2
- ] # <- Do not delete.
- #--------------------------------------------------------------------------
- # Equip Info Page List
- #--------------------------------------------------------------------------
- # This setting determines the order of info pages for equippable items.
- # Each kind of info page is represented by a symbol. Possible symbols
- # include:
- #
- # :equippable_info
- # :param_info # Requires "Reader Functions for Features/Effects"
- # :attack_info # Requires "Reader Functions for Features/Effects"
- # :element_info # Requires "Reader Functions for Features/Effects"
- # :state_info # Requires "Reader Functions for Features/Effects"
- EQUIP_INFO_PAGES = [:ingredients, # Page 1 (Required as 1st page)
- :param_info, # Page 2
- :attack_info, # Page 3
- :element_info, # Page 4
- :state_info, # Page 5
- :equippable_info, # Page 6
- ] # <- Do not delete.
- #--------------------------------------------------------------------------
- # Info Page Header Text
- #--------------------------------------------------------------------------
- INFO_PAGE_HEADER_TEXT = {
- # General
- :main_header => "Information",
- # Weapons and Armor
- :atk_elements => "Attack Elements",
- :atk_speed => "Attack Speed",
- :atk_times_add => "Number of Attacks",
- :atk_states => "Attack States",
- :element_rate => "Element Resistances",
- :state_rate => "State Resistances",
- :state_resist_set => "State Immunity",
- :equippable => "Equippable Members",
- # Items
- :hp_recovery => "HP Recovery",
- :mp_recovery => "MP Recovery",
- :tp_recovery => "TP Recovery",
- :add_states => "Adds",
- :remove_states => "Removes",
- } # <- Do not delete.
- #--------------------------------------------------------------------------
- # Element Icon Index Numbers
- #--------------------------------------------------------------------------
- # This setting lets you define the icon index number that represents
- # an element in info pages
- #
- # Requires "Reader Functions for Features/Effects" to see effects.
- ELEMENT_ICONS = {
- 1 => 116, # Physical
- 2 => 113, # Absorb
- 3 => 96, # Fire
- 4 => 97, # Ice
- 5 => 98, # Thunder
- 6 => 99, # Water
- 7 => 100, # Earth
- 8 => 101, # Wind
- 9 => 102, # Light
- 10 => 103, # Dark
- } # <- Do not delete.
- #--------------------------------------------------------------------------
- # Element ID List for Info Page
- #--------------------------------------------------------------------------
- # This setting determines which elements are seen in an item's element
- # info page where each number in the array is an Element ID number from
- # your database.
- #
- # Requires "Reader Functions for Features/Effects" to see effects.
- DISPLAYED_ELEMENT_RESISTS = [1,2,3,4,5,6,7,8,9,10]
- #--------------------------------------------------------------------------
- # State ID List for Info Page
- #--------------------------------------------------------------------------
- # This setting determines which states are seen in an item's state
- # info page where each number in the array is a State ID number from
- # your database.
- #
- # Requires "Reader Functions for Features/Effects" to see effects.
- DISPLAYED_STATE_RESISTS = [1,2,3,4,5,6,7,8]
- #--------------------------------------------------------------------------
- # Change Info Page Buttons
- #--------------------------------------------------------------------------
- # These settings determine which gamepad buttons change the info
- # window page. Possible buttons include :LEFT, :RIGHT, :UP, :DOWN,
- # :A, :B, :C, :X, :Y, :Z, :L, :R
- PREV_PAGE_BUTTON = :LEFT
- NEXT_PAGE_BUTTON = :RIGHT
- #--------------------------------------------------------------------------
- # Change Ingredident Page Button
- #--------------------------------------------------------------------------
- # This setting determine which gamepad button changes the ingredient
- # window page. Possible buttons include :LEFT, :RIGHT, :UP, :DOWN,
- # :A, :B, :C, :X, :Y, :Z, :L, :R
- NEXT_INGREDIENT_PAGE_BUTTON = :A
- #--------------------------------------------------------------------------
- # Page Change Sound Effect
- #--------------------------------------------------------------------------
- # Filename : SE filename in Audio/SE/ folder
- # Volume : Between 0~100
- # Pitch : Between 50~150
- #
- # Filename, Volume, Pitch
- PAGE_CHANGE_SE = ["Cursor1", 80, 100]
- #--------------------------------------------------------------------------
- # YEA Ace Menu Engine - Custom Menu Command Setting
- #--------------------------------------------------------------------------
- # This setting only takes effect when YEA - Ace Menu Engine is installed
- # in the same project.
- #
- # To add the TOCrafting scene to Ace Menu Engine, look for a
- # configuration setting called "- Main Menu Settings -". There is a
- # variable called COMMANDS that has an array of orange symbols. Add
- # the symbol :tocrafting to the COMMANDS array to add the crafting
- # command to your menu.
- #
- # The setting here working exactly the same as the CUSTOM_COMMAND
- # setting in Ace Menu Engine. For more information, please refer to
- # the Ace Menu Engine script.
- TOCRAFTING_CUSTOM_COMMAND = {
- # ["Display Name", EnableSwitch, ShowSwitch, Handler Method],
- :tocrafting => [ "Crafting", 0, 0, :command_tocrafting],
- } # <- Do not delete.
- end # module TOCrafting
- end # module Bubs
- #==========================================================================
- # ++ END OF USER CUSTOMIZATION MODULE ++
- #==========================================================================
- #==============================================================================
- # ++ Sound
- #==============================================================================
- module Sound
- #--------------------------------------------------------------------------
- # new method : play_tocrafting_result
- #--------------------------------------------------------------------------
- def self.play_tocrafting_result
- filename = Bubs::TOCrafting::CRAFTING_RESULT_SE[0]
- volume = Bubs::TOCrafting::CRAFTING_RESULT_SE[1]
- pitch = Bubs::TOCrafting::CRAFTING_RESULT_SE[2]
- Audio.se_play("Audio/SE/" + filename, volume, pitch)
- end
- #--------------------------------------------------------------------------
- # new method : play_custom_tocrafting_result
- #--------------------------------------------------------------------------
- def self.play_custom_tocrafting_result(filename, volume, pitch)
- Audio.se_play("Audio/SE/" + filename, volume, pitch)
- end
- #--------------------------------------------------------------------------
- # new method : play_page_change
- #--------------------------------------------------------------------------
- def self.play_page_change
- filename = Bubs::TOCrafting::PAGE_CHANGE_SE[0]
- volume = Bubs::TOCrafting::PAGE_CHANGE_SE[1]
- pitch = Bubs::TOCrafting::PAGE_CHANGE_SE[2]
- Audio.se_play("Audio/SE/" + filename, volume, pitch)
- end
- end # module Sound
- #==============================================================================
- # ++ Cache
- #==============================================================================
- module Cache
- #--------------------------------------------------------------------------
- # new method : recipebook_cover
- #--------------------------------------------------------------------------
- def self.recipebook_cover(filename)
- load_bitmap(Bubs::TOCrafting::RECIPEBOOK_PICTURES_DIRECTORY, filename)
- end
- end # module Cache
- #==========================================================================
- # ++ Bubs::Regexp
- #==========================================================================
- module Bubs
- module Regexp
- RECIPEBOOK_START_TAG = /<RECIPE[_\s]?BOOK>/i
- RECIPEBOOK_END_TAG = /<\/RECIPE[_\s]?BOOK>/i
- RECIPEBOOK_OBJ_TAG = /(\w+):\s*(\d+(?:\s*,\s*\d+)*)/i
- RECIPEBOOK_COVER_TAG = /(?:PICTURE|PIC|COVER):\s*(\w+)/i
- RECIPEBOOK_CATEGORY_TAG = /category?:\s*(\w+)/i
- INGREDIENT_START_TAG = /<INGREDIENTS?>/i
- INGREDIENT_END_TAG = /<\/INGREDIENTS?>/i
- INGREDIENT_OBJ_TAG = /(\w+):\s*[×x]?(\d+)\s*[×x]?(\d+)?/i
- REQUIRED_TOOLS_TAG = /TOOLS?:\s*(\w+)\s*(\d+)/i
- CRAFTING_CUSTOM_SE_TAG = /SE:\s*(\w+)\s*,\s*(\d+)\s*,\s*(\d+)/i
- CRAFTING_AMOUNT_TAG = /<CRAFT[_\s]*(?:AMOUNT|amt):\s*[x]*(\d+)\s*>/i
- end # module Regexp
- end # module Bubs
- #==========================================================================
- # ++ DataManager
- #==========================================================================
- module DataManager
- #--------------------------------------------------------------------------
- # alias : load_database
- #--------------------------------------------------------------------------
- class << self; alias load_database_bubs_tocrafting load_database; end
- def self.load_database
- load_database_bubs_tocrafting # alias
- load_notetags_bubs_tocrafting
- end
- #--------------------------------------------------------------------------
- # new method : load_notetags_bubs_tocrafting
- #--------------------------------------------------------------------------
- def self.load_notetags_bubs_tocrafting
- groups = [$data_items, $data_weapons, $data_armors]
- for group in groups
- for obj in group
- next if obj.nil?
- obj.load_notetags_bubs_tocrafting
- end # for obj
- end # for group
- end # def
- end # module DataManager
- #==========================================================================
- # ++ RPG::BaseItem
- #==========================================================================
- class RPG::BaseItem
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :recipe_list
- attr_accessor :ingredient_list
- attr_accessor :tocrafting_tools
- attr_accessor :tocrafting_actors
- attr_accessor :tocrafting_skills
- attr_accessor :tocrafting_gold_fee
- attr_accessor :tocrafting_bookcover
- attr_accessor :tocrafting_se
- attr_accessor :tocrafting_category
- attr_accessor :tocrafting_amount
- #--------------------------------------------------------------------------
- # common cache : load_notetags_bubs_tocrafting
- #--------------------------------------------------------------------------
- def load_notetags_bubs_tocrafting
- @recipe_list = []
- @ingredient_list = []
- @tocrafting_tools = []
- @tocrafting_actors = []
- @tocrafting_skills = []
- @tocrafting_gold_fee = self.price
- @tocrafting_bookcover = ""
- @tocrafting_se = []
- @tocrafting_category = :none
- @tocrafting_amount = 1
- load_notetags_default_fee_bubs_tocrafting
- recipe_tag = false
- ingredient_tag = false
- self.note.split(/[\r\n]+/).each { |line|
- case line
- when Bubs::Regexp::RECIPEBOOK_START_TAG
- recipe_tag = true
- when Bubs::Regexp::RECIPEBOOK_END_TAG
- recipe_tag = false
- when Bubs::Regexp::INGREDIENT_START_TAG
- ingredient_tag = true
- when Bubs::Regexp::INGREDIENT_END_TAG
- ingredient_tag = false
- when Bubs::Regexp::CRAFTING_AMOUNT_TAG
- @tocrafting_amount = $1.to_i
- when Bubs::Regexp::RECIPEBOOK_COVER_TAG
- next unless recipe_tag
- @tocrafting_bookcover = $1
- when Bubs::Regexp::RECIPEBOOK_CATEGORY_TAG
- next unless recipe_tag
- @tocrafting_category = $1.to_sym
- when Bubs::Regexp::REQUIRED_TOOLS_TAG
- next unless ingredient_tag
- load_notetags_tools_bubs_tocrafting(line)
- when Bubs::Regexp::CRAFTING_CUSTOM_SE_TAG
- next unless ingredient_tag
- @tocrafting_se = [$1, $2.to_i, $3.to_i]
- else
- load_notetags_recipelist_bubs_tocrafting(line) if recipe_tag
- load_notetags_ingredients_bubs_tocrafting(line) if ingredient_tag
- end # case
- } # self.note.split
- @recipe_list.compact!
- @ingredient_list.compact!
- @tocrafting_tools.compact!
- @tocrafting_actors.compact!
- @tocrafting_skills.compact!
- end # load_notetags_bubs_tocrafting
- #--------------------------------------------------------------------------
- # common cache : load_notetags_default_fee_bubs_tocrafting
- #--------------------------------------------------------------------------
- def load_notetags_default_fee_bubs_tocrafting
- rate = Bubs::TOCrafting::CRAFTING_FEE_PRICE_RATE
- @tocrafting_gold_fee = (@tocrafting_gold_fee * (rate * 0.01)).to_i
- end
- #--------------------------------------------------------------------------
- # common cache : load_notetags_recipelist_bubs_tocrafting
- #--------------------------------------------------------------------------
- def load_notetags_recipelist_bubs_tocrafting(line)
- return unless line =~ Bubs::Regexp::RECIPEBOOK_OBJ_TAG ? true : false
- match = $~.clone
- id_array = match[2].scan(/\d+/)
- case match[1].upcase
- when "I", "ITEM"
- for id in id_array
- @recipe_list.push( $data_items[id.to_i] )
- end
- when "W", "WEAPON", "WEP"
- for id in id_array
- @recipe_list.push( $data_weapons[id.to_i] )
- end
- when "A", "ARMOR", "ARMOUR", "ARM"
- for id in id_array
- @recipe_list.push( $data_armors[id.to_i] )
- end # for
- end # case
- end # def load_notetags_recipelist_bubs_tocrafting
- #--------------------------------------------------------------------------
- # common cache : load_notetags_ingredients_bubs_tocrafting
- #--------------------------------------------------------------------------
- def load_notetags_ingredients_bubs_tocrafting(line)
- return unless line =~ Bubs::Regexp::INGREDIENT_OBJ_TAG ? true : false
- amount = $3 ? $3.to_i : 1
- case $1.upcase
- when "I", "ITEM"
- amount.times do @ingredient_list.push( $data_items[$2.to_i] ) end
- when "W", "WEAPON", "WEP"
- amount.times do @ingredient_list.push( $data_weapons[$2.to_i] ) end
- when "A", "ARMOR", "ARMOUR", "ARM"
- amount.times do @ingredient_list.push( $data_armors[$2.to_i] ) end
- when "FEE", "GOLD"
- @tocrafting_gold_fee = $2.to_i
- when "SKILL"
- @tocrafting_skills.push( $2.to_i )
- when "ACTOR"
- @tocrafting_actors.push( $2.to_i )
- end # case $1.upcase
- end # def load_notetags_ingredients_bubs_tocrafting
- #--------------------------------------------------------------------------
- # common cache : load_notetags_tools_bubs_tocrafting
- #--------------------------------------------------------------------------
- def load_notetags_tools_bubs_tocrafting(line)
- line =~ Bubs::Regexp::REQUIRED_TOOLS_TAG
- case $1.upcase
- when "I", "ITEM"
- @tocrafting_tools.push( $data_items[$2.to_i] )
- when "W", "WEAPON", "WEP"
- @tocrafting_tools.push( $data_weapons[$2.to_i] )
- when "A", "ARMOR", "ARMOUR", "ARM"
- @tocrafting_tools.push( $data_armors[$2.to_i] )
- end # case
- end # def load_notetags_tools_bubs_tocrafting
- #--------------------------------------------------------------------------
- # new method : recipebook?
- #--------------------------------------------------------------------------
- def recipebook?
- return false unless self.is_a?(RPG::UsableItem) || self.is_a?(RPG::EquipItem)
- return !@recipe_list.empty?
- end
- end # class RPG::BaseItem
- #==============================================================================
- # ++ Window_TOCraftingRecipeList
- #==============================================================================
- class Window_TOCraftingRecipeList < Window_ItemList
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_reader :info_window
- attr_reader :header_window
- attr_reader :cover_window
- #--------------------------------------------------------------------------
- # initialize
- #--------------------------------------------------------------------------
- def initialize(x, y, height)
- super(x, y, window_width, height)
- end
- #--------------------------------------------------------------------------
- # categories=
- #--------------------------------------------------------------------------
- def categories=(categories)
- @categories = categories
- end
- #--------------------------------------------------------------------------
- # window_width
- #--------------------------------------------------------------------------
- def window_width
- Graphics.width / 2
- end
- #--------------------------------------------------------------------------
- # current_item_enabled? # Get Activation State of Selection Item
- #--------------------------------------------------------------------------
- def current_item_enabled?
- enable?(@data[index])
- end
- #--------------------------------------------------------------------------
- # enable? # Display in Enabled State?
- #--------------------------------------------------------------------------
- def enable?(item)
- return false if item.nil?
- return true
- end
- #--------------------------------------------------------------------------
- # col_max
- #--------------------------------------------------------------------------
- def col_max
- return 1
- end
- #--------------------------------------------------------------------------
- # include? # Include in Item List?
- #--------------------------------------------------------------------------
- def include?(item)
- return false if item.nil?
- return include_recipebook?(item) if item.recipebook?
- return false
- end
- #--------------------------------------------------------------------------
- # include_recipebook?
- #--------------------------------------------------------------------------
- def include_recipebook?(item)
- return true if @categories.empty?
- return true if @categories.include?(item.tocrafting_category)
- return false
- end
- #--------------------------------------------------------------------------
- # draw_item
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- if item
- rect = item_rect(index)
- rect.width -= 4
- draw_item_name(item, rect.x, rect.y, enable?(item), rect.width - 24)
- end
- end
- #--------------------------------------------------------------------------
- # info_window=
- #--------------------------------------------------------------------------
- def info_window=(info_window)
- @info_window = info_window
- call_update_help
- end
- #--------------------------------------------------------------------------
- # header_window=
- #--------------------------------------------------------------------------
- def header_window=(header_window)
- @header_window = header_window
- end
- #--------------------------------------------------------------------------
- # cover_window=
- #--------------------------------------------------------------------------
- def cover_window=(cover_window)
- @cover_window = cover_window
- end
- #--------------------------------------------------------------------------
- # update_help
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_item(item) if @help_window
- @info_window.item = item if @info_window
- @header_window.item = item if @header_window
- @cover_window.item = item if @cover_window
- end
- end # Window_TOCraftingRecipeList
- #==============================================================================
- # ++ Window_TOCraftingItemListHeader
- #==============================================================================
- class Window_TOCraftingItemListHeader < Window_Base
- #--------------------------------------------------------------------------
- # initialize
- #--------------------------------------------------------------------------
- def initialize(x, y)
- super(x, y, window_width, window_height)
- @item = nil
- end
- #--------------------------------------------------------------------------
- # window_width
- #--------------------------------------------------------------------------
- def window_width
- Graphics.width / 2
- end
- #--------------------------------------------------------------------------
- # window_height
- #--------------------------------------------------------------------------
- def window_height
- fitting_height(1)
- end
- #--------------------------------------------------------------------------
- # item= # Set window header item
- #--------------------------------------------------------------------------
- def item=(item)
- @item = item
- end
- #--------------------------------------------------------------------------
- # refresh
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_itemlist_header_item(0, 0)
- end
- #--------------------------------------------------------------------------
- # draw_itemlist_header_item
- #--------------------------------------------------------------------------
- def draw_itemlist_header_item(x, y)
- return unless @item
- draw_item_name(@item, x, y, true, contents.width - 28)
- end
- end # class Window_TOCraftingItemListHeader
- #==============================================================================
- # ++ Window_TOCraftingItemList
- #==============================================================================
- class Window_TOCraftingItemList < Window_ItemList
- #--------------------------------------------------------------------------
- # initialize
- #--------------------------------------------------------------------------
- def initialize(x, y, height)
- super(x, y, window_width, height)
- @item = nil
- end
- #--------------------------------------------------------------------------
- # window_width
- #--------------------------------------------------------------------------
- def window_width
- Graphics.width / 2
- end
- #--------------------------------------------------------------------------
- # col_max
- #--------------------------------------------------------------------------
- def col_max
- return 1
- end
- #--------------------------------------------------------------------------
- # item=
- #--------------------------------------------------------------------------
- def item=(item)
- @item = item
- refresh
- end
- #--------------------------------------------------------------------------
- # info_window=
- #--------------------------------------------------------------------------
- def info_window=(info_window)
- @info_window = info_window
- call_update_help
- end
- #--------------------------------------------------------------------------
- # gold_window=
- #--------------------------------------------------------------------------
- def gold_window=(gold_window)
- @gold_window = gold_window
- call_update_help
- end
- #--------------------------------------------------------------------------
- # current_item_enabled? # Get Activation State of Selection Item
- #--------------------------------------------------------------------------
- def current_item_enabled?
- enable?(@data[index])
- end
- #--------------------------------------------------------------------------
- # enable? # Display in Enabled State?
- #--------------------------------------------------------------------------
- def enable?(item)
- return false if item.nil?
- return false unless has_recipebook?
- return false if item.tocrafting_gold_fee > $game_party.gold
- return false if $game_party.item_max?(item)
- return false unless have_tools?(item)
- return false unless have_actors?(item)
- return true if item.ingredient_list.empty?
- return have_ingredients?(item)
- end
- #--------------------------------------------------------------------------
- # has_recipebook?
- #--------------------------------------------------------------------------
- def has_recipebook?
- return true if $imported["TH_TOCraftingShop"]
- return true if $game_party.item_number(@item) > 0
- return false
- end
- #--------------------------------------------------------------------------
- # have_ingredients?
- #--------------------------------------------------------------------------
- def have_ingredients?(item)
- item.ingredient_list.uniq.each do |ingredient|
- party_amount = $game_party.item_number(ingredient)
- required_amount = item.ingredient_list.count(ingredient)
- return false if party_amount < required_amount
- end # do
- return true
- end
- #--------------------------------------------------------------------------
- # have_tools?
- #--------------------------------------------------------------------------
- def have_tools?(item)
- item.tocrafting_tools.each do |tool|
- return false if !$game_party.has_item?(tool)
- end
- return true
- end
- #--------------------------------------------------------------------------
- # have_actors?
- #--------------------------------------------------------------------------
- def have_actors?(item)
- item.tocrafting_actors.each do |id|
- return false unless $game_party.members.include?($game_actors[id])
- end
- return true
- end
- #--------------------------------------------------------------------------
- # include? # Include in Item List?
- #--------------------------------------------------------------------------
- def include?(item)
- return false if item.nil?
- return true
- end
- #--------------------------------------------------------------------------
- # make_item_list
- #--------------------------------------------------------------------------
- def make_item_list
- @data = @item.recipe_list.each { |item| include?(item) } if @item
- end
- #--------------------------------------------------------------------------
- # update_help
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_item(item) if @help_window
- @info_window.item = item if @info_window
- @gold_window.item = item if @gold_window
- end
- #--------------------------------------------------------------------------
- # update_open
- #--------------------------------------------------------------------------
- def update_open
- self.openness += 24
- @opening = false if open?
- end
- end # class Window_TOCraftingItemList
- #==============================================================================
- # ++ Window_TOCraftingInfo
- #==============================================================================
- class Window_TOCraftingInfo < Window_Base
- #--------------------------------------------------------------------------
- # Constants (Starting Number of Buff/Debuff Icons)
- #--------------------------------------------------------------------------
- ICON_BUFF_START = 64 # buff (16 icons)
- ICON_DEBUFF_START = 80 # debuff (16 icons)
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :number
- attr_accessor :page_change
- attr_accessor :page_index
- attr_reader :ingredients
- #--------------------------------------------------------------------------
- # initialize
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super(x, y, width, height)
- @item = nil
- @number = 1
- @page_change = true
- @page_index = 0
- @ingredients = []
- set_page_keys
- end
- #--------------------------------------------------------------------------
- # set_page_keys
- #--------------------------------------------------------------------------
- def set_page_keys
- @usableitem_pages = Bubs::TOCrafting::ITEM_INFO_PAGES.clone
- @equipitem_pages = Bubs::TOCrafting::EQUIP_INFO_PAGES.clone
- refresh
- end
- #--------------------------------------------------------------------------
- # refresh
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- return unless @item
- draw_page_contents(@item)
- end
- #--------------------------------------------------------------------------
- # update
- #--------------------------------------------------------------------------
- def update
- super
- update_page
- end
- #--------------------------------------------------------------------------
- # draw_page_contents
- #--------------------------------------------------------------------------
- def draw_page_contents(item)
- if item.is_a?(RPG::Item)
- case @usableitem_pages[0]
- when :ingredients
- draw_ingredients(4, line_height * 2)
- standard_page_doodads(4, 0)
- when :item_info
- return feature_reader_text(4, 0) unless $imported["BubsFeaturesReader"]
- draw_usableitem_info(item, 4, line_height * 2)
- standard_page_doodads(4, 0)
- end
- elsif item.is_a?(RPG::EquipItem)
- case @equipitem_pages[0]
- when :ingredients
- draw_ingredients(4, line_height * 2)
- standard_page_doodads(4, 0)
- when :param_info
- return feature_reader_text(4, 0) unless $imported["BubsFeaturesReader"]
- draw_param_info(item, 4, line_height * 2)
- standard_page_doodads(4, 0)
- when :xparam_info
- return feature_reader_text(4, 0) unless $imported["BubsFeaturesReader"]
- #draw_xparam_info(item, 4, line_height * 2)
- when :sparam_info
- return feature_reader_text(4, 0) unless $imported["BubsFeaturesReader"]
- #draw_sparam_info(item, 4, line_height * 2)
- standard_page_doodads(4, 0)
- when :attack_info
- return feature_reader_text(4, 0) unless $imported["BubsFeaturesReader"]
- draw_attack_info(item, 4, line_height * 2)
- standard_page_doodads(4, 0)
- when :element_info
- return feature_reader_text(4, 0) unless $imported["BubsFeaturesReader"]
- draw_element_resists_info(item, 4, line_height * 2)
- standard_page_doodads(4, 0)
- when :state_info
- return feature_reader_text(4, 0) unless $imported["BubsFeaturesReader"]
- draw_state_resists_info(item, 4, line_height * 2)
- standard_page_doodads(4, 0)
- when :equippable_info
- draw_equippable_info(item, 4, line_height * 2)
- standard_page_doodads(4, 0)
- end # case
- end # if
- end # def
- #--------------------------------------------------------------------------
- # standard_page_doodads
- #--------------------------------------------------------------------------
- def standard_page_doodads(x, y)
- draw_info_header_text(x, y)
- draw_info_footer_text(x, y)
- draw_horz_line(line_height * 1)
- end
- #--------------------------------------------------------------------------
- # feature_reader_text
- #--------------------------------------------------------------------------
- def feature_reader_text(x, y)
- change_color(normal_color)
- rect = Rect.new(x, y, contents.width - 4 - x, line_height)
- text = "This page requires"
- rect.y = line_height * 3
- draw_text(rect, text, 1)
- text = "the script"
- rect.y = line_height * 4
- draw_text(rect, text, 1)
- text = "\"Reader Functions for "
- rect.y = line_height * 5
- draw_text(rect, text, 1)
- text = "Features\/Effects\""
- rect.y = line_height * 6
- draw_text(rect, text, 1)
- text = "to be properly viewed."
- rect.y = line_height * 7
- draw_text(rect, text, 1)
- end
- #--------------------------------------------------------------------------
- # update_page
- #--------------------------------------------------------------------------
- def update_page
- if visible
- next_info_page if Input.trigger?(next_page_button) && @page_change
- prev_info_page if Input.trigger?(prev_page_button) && @page_change
- if Input.trigger?(next_ingredient_page_button) && page_max > 1
- next_ingredient_page if current_symbol == :ingredients
- end
- end
- end
- #--------------------------------------------------------------------------
- # current_symbol
- #--------------------------------------------------------------------------
- def current_symbol
- return :none unless @item
- return @usableitem_pages[0] if @item.is_a?(RPG::UsableItem)
- return @equipitem_pages[0] if @item.is_a?(RPG::EquipItem)
- end
- #--------------------------------------------------------------------------
- # prev_page_button
- #--------------------------------------------------------------------------
- def prev_page_button
- Bubs::TOCrafting::PREV_PAGE_BUTTON
- end
- #--------------------------------------------------------------------------
- # next_page_button
- #--------------------------------------------------------------------------
- def next_page_button
- Bubs::TOCrafting::NEXT_PAGE_BUTTON
- end
- #--------------------------------------------------------------------------
- # next_ingredient_page_button
- #--------------------------------------------------------------------------
- def next_ingredient_page_button
- Bubs::TOCrafting::NEXT_INGREDIENT_PAGE_BUTTON
- end
- #--------------------------------------------------------------------------
- # normal_footer_text
- #--------------------------------------------------------------------------
- def normal_footer_text
- Bubs::TOCrafting::NORMAL_FOOTER_TEXT
- end
- #--------------------------------------------------------------------------
- # ingredients_view_more_footer_text
- #--------------------------------------------------------------------------
- def ingredients_view_more_footer_text
- Bubs::TOCrafting::INGREDIENTS_VIEW_MORE_FOOTER_TEXT
- end
- #--------------------------------------------------------------------------
- # draw_ingredients_footer_text
- #--------------------------------------------------------------------------
- def draw_ingredients_footer_text(x, y)
- y = y + line_height * (contents.height / line_height - 1)
- rect = standard_rect(x, y)
- change_color(normal_color)
- if page_max > 1
- draw_text(rect, ingredients_view_more_footer_text, 1)
- else
- draw_text(rect, normal_footer_text, 1)
- end
- end
- #--------------------------------------------------------------------------
- # draw_info_footer_text(4, 0)
- #--------------------------------------------------------------------------
- def draw_info_footer_text(x, y)
- y = y + line_height * (contents.height / line_height - 1)
- rect = standard_rect(x, y)
- change_color(normal_color)
- draw_text(rect, normal_footer_text, 1)
- end
- #--------------------------------------------------------------------------
- # next_ingredient_page
- #--------------------------------------------------------------------------
- def next_ingredient_page
- @page_index = (@page_index + 1) % page_max
- refresh
- end
- #--------------------------------------------------------------------------
- # next_info_page
- #--------------------------------------------------------------------------
- def next_info_page
- Sound.play_page_change
- @equipitem_pages.rotate! if @item.is_a?(RPG::EquipItem)
- @usableitem_pages.rotate! if @item.is_a?(RPG::UsableItem)
- refresh
- end
- #--------------------------------------------------------------------------
- # prev_info_page
- #--------------------------------------------------------------------------
- def prev_info_page
- Sound.play_page_change
- @equipitem_pages.rotate!(-1) if @item.is_a?(RPG::EquipItem)
- @usableitem_pages.rotate!(-1) if @item.is_a?(RPG::UsableItem)
- refresh
- end
- #--------------------------------------------------------------------------
- # draw_horz_line
- #--------------------------------------------------------------------------
- def draw_horz_line(y)
- line_y = y + line_height / 2 - 1
- contents.fill_rect(0, line_y, contents_width, 2, line_color)
- end
- #--------------------------------------------------------------------------
- # line_color # Get Color of Horizontal Line
- #--------------------------------------------------------------------------
- def line_color
- color = normal_color
- color.alpha = 48
- color
- end
- #--------------------------------------------------------------------------
- # info_header_text
- #--------------------------------------------------------------------------
- def info_header_text(key)
- Bubs::TOCrafting::INFO_PAGE_HEADER_TEXT[key]
- end
- #--------------------------------------------------------------------------
- # standard_rect
- #--------------------------------------------------------------------------
- def standard_rect(x, y)
- Rect.new(x, y, contents.width - 4 - x, line_height)
- end
- #--------------------------------------------------------------------------
- # draw_equippable_info
- #--------------------------------------------------------------------------
- def draw_equippable_info(item, x, y)
- draw_equippable_text(item, x, y)
- draw_equippable_members_info(item, x, y + line_height)
- end
- #--------------------------------------------------------------------------
- # draw_equippable_members_info
- #--------------------------------------------------------------------------
- def draw_equippable_members_info(item, x, y)
- change_color(normal_color)
- temp = $game_party.members.select { |member| member.equippable?(item) }
- temp.each_with_index do |member, index|
- y_plus = line_height * (index / col_max)
- x_plus = index % col_max * item_width
- icon_index = actor_icons[member.id] ? member.id : :default
- draw_icon(actor_icons[icon_index], x + x_plus, y + y_plus)
- rect = Rect.new(x, y, contents.width / col_max - 4 - x, line_height)
- rect.x += x_plus
- rect.y += y_plus
- text = sprintf("%s", member.name)
- draw_text(rect, text, 2)
- end
- end
- #--------------------------------------------------------------------------
- # draw_equippable_text
- #--------------------------------------------------------------------------
- def draw_equippable_text(item, x, y)
- change_color(system_color)
- rect = standard_rect(x, y)
- text = info_header_text(:equippable) # "Equippable Members"
- draw_text(rect, text)
- end
- #--------------------------------------------------------------------------
- # draw_param_info
- #--------------------------------------------------------------------------
- def draw_param_info(item, x, y)
- 8.times do |i|
- y_plus = line_height * i
- x_plus = 0 #i % col_max * item_width
- draw_param_name(x + x_plus, y + y_plus, i)
- draw_param_value(item, x + x_plus, y + y_plus, i)
- end
- end
- #--------------------------------------------------------------------------
- # draw_attack_info
- #--------------------------------------------------------------------------
- def draw_attack_info(item, x, y)
- draw_attack_elements(item, x, y + line_height * 0)
- draw_attack_speed(item, x, y + line_height * 1)
- draw_number_of_attacks(item, x, y + line_height * 2)
- draw_attack_states_text(item, x, y + line_height * 4)
- draw_attack_states(item, x, y + line_height * 5)
- end
- #--------------------------------------------------------------------------
- # draw_attack_elements
- #--------------------------------------------------------------------------
- def draw_attack_elements(item, x, y)
- draw_attack_elements_text(item, x, y)
- draw_attack_elements_icons(item, x, y)
- end
- #--------------------------------------------------------------------------
- # draw_attack_elements_text
- #--------------------------------------------------------------------------
- def draw_attack_elements_text(item, x, y)
- change_color(system_color)
- rect = standard_rect(x, y)
- text = info_header_text(:atk_elements) # "Attack Element"
- draw_text(rect, text)
- end
- #--------------------------------------------------------------------------
- # draw_attack_elements_icons
- #--------------------------------------------------------------------------
- def draw_attack_elements_icons(item, x, y)
- icons = item.atk_elements
- icons.reverse.each_with_index do |id, i|
- n = element_icon_id(id) ? element_icon_id(id) : 0
- draw_icon(n, contents.width - 4 - x - (24 * (i + 1)), y)
- end
- end
- #--------------------------------------------------------------------------
- # draw_attack_speed
- #--------------------------------------------------------------------------
- def draw_attack_speed(item, x, y)
- change_color(system_color)
- rect = standard_rect(x, y)
- text = info_header_text(:atk_speed) # "Attack Speed"
- draw_text(rect, text)
- value = item.atk_speed
- change_color(param_change_color(value))
- draw_text(rect, sprintf("%+d", value), 2)
- end
- #--------------------------------------------------------------------------
- # draw_number_of_attacks
- #--------------------------------------------------------------------------
- def draw_number_of_attacks(item, x, y)
- change_color(system_color)
- rect = standard_rect(x, y)
- text = info_header_text(:atk_times_add) # "Number of Attacks"
- draw_text(rect, text)
- value = item.atk_times_add
- change_color(param_change_color(value))
- draw_text(rect, sprintf("%+d", value), 2)
- end
- #--------------------------------------------------------------------------
- # draw_attack_states
- #--------------------------------------------------------------------------
- def draw_attack_states(item, x, y)
- change_color(normal_color)
- item.atk_states.each_with_index do |state_id, index|
- y_plus = line_height * (index / col_max)
- x_plus = index % col_max * item_width
- icon_index = $data_states[state_id].icon_index
- draw_icon(icon_index, x + x_plus, y + y_plus)
- rect = Rect.new(x, y, contents.width / col_max - 4 - x, line_height)
- rect.x += x_plus
- rect.y += y_plus
- rate = item.atk_states_rate(state_id) * 100
- text = sprintf("%d%%", rate)
- draw_text(rect, text, 2)
- end
- end
- #--------------------------------------------------------------------------
- # draw_attack_states_text
- #--------------------------------------------------------------------------
- def draw_attack_states_text(item, x, y)
- change_color(system_color)
- rect = standard_rect(x, y)
- text = info_header_text(:atk_states) # "Attack States"
- draw_text(rect, text)
- end
- #--------------------------------------------------------------------------
- # element_icon_id
- #--------------------------------------------------------------------------
- def element_icon_id(element_id)
- Bubs::TOCrafting::ELEMENT_ICONS[element_id]
- end
- #--------------------------------------------------------------------------
- # draw_element_resists_info
- #--------------------------------------------------------------------------
- def draw_element_resists_info(item, x, y)
- draw_element_resists_text(item, x, y + line_height * 0)
- draw_element_resists(item, x, y + line_height * 1)
- end
- #--------------------------------------------------------------------------
- # draw_state_resists_info
- #--------------------------------------------------------------------------
- def draw_state_resists_info(item, x, y)
- draw_state_resists_text(item, x, y + line_height * 0)
- draw_state_resists(item, x, y + line_height * 1)
- draw_state_immunity_text(item, x, y + line_height * 8)
- draw_state_immunity(item, x, y + + line_height * 9)
- end
- #--------------------------------------------------------------------------
- # draw_state_resists_text
- #--------------------------------------------------------------------------
- def draw_state_resists_text(item, x, y)
- change_color(system_color)
- rect = standard_rect(x, y)
- text = info_header_text(:state_rate) # "State Resistance"
- draw_text(rect, text)
- end
- #--------------------------------------------------------------------------
- # draw_state_resists
- #--------------------------------------------------------------------------
- def draw_state_resists(item, x, y)
- listed_states.each_with_index do |state_id, index|
- y_plus = line_height * (index / col_max)
- x_plus = index % col_max * item_width
- icon_index = $data_states[state_id].icon_index
- draw_icon(icon_index, x + x_plus, y + y_plus)
- rect = Rect.new(x, y, contents.width / col_max - 4 - x, line_height)
- rect.x += x_plus
- rect.y += y_plus
- rate = item.state_rate(state_id) * 100 - 100
- change_color(param_change_color(-rate))
- text = sprintf("%+d%%", -rate)
- draw_text(rect, text, 2)
- end
- end
- #--------------------------------------------------------------------------
- # draw_state_immunity_text
- #--------------------------------------------------------------------------
- def draw_state_immunity_text(item, x, y)
- change_color(system_color)
- rect = standard_rect(x, y)
- text = info_header_text(:state_resist_set) # "State Immunity"
- draw_text(rect, text)
- end
- #--------------------------------------------------------------------------
- # draw_state_immunity
- #--------------------------------------------------------------------------
- def draw_state_immunity(item, x, y)
- item.state_resist_set.each_with_index do |state_id, index|
- icon_row_max = (contents.width - 4 - x) / 24
- y_plus = (index / icon_row_max) * line_height
- x_plus = (index % icon_row_max) * 24
- icon_index = $data_states[state_id].icon_index
- draw_icon(icon_index, x + x_plus, y + y_plus)
- end
- end
- #--------------------------------------------------------------------------
- # draw_element_resists
- #--------------------------------------------------------------------------
- def draw_element_resists(item, x, y)
- change_color(normal_color)
- listed_elements.each_with_index do |element_id, index|
- y_plus = line_height * (index / col_max)
- x_plus = index % col_max * item_width
- icon_index = element_icon_id(element_id) ? element_icon_id(element_id) : 0
- draw_icon(icon_index, x + x_plus, y + y_plus)
- rect = Rect.new(x + x_plus, y + y_plus, contents.width / col_max - 4 - x, line_height)
- rate = item.element_rate(element_id) * 100 - 100
- change_color(param_change_color(-rate))
- text = sprintf("%+d%%", -rate)
- draw_text(rect, text, 2)
- end
- end
- #--------------------------------------------------------------------------
- # draw_element_resists_text
- #--------------------------------------------------------------------------
- def draw_element_resists_text(item, x, y)
- change_color(system_color)
- rect = standard_rect(x, y)
- text = info_header_text(:element_rate) # "Element Resists"
- draw_text(rect, text)
- end
- #--------------------------------------------------------------------------
- # listed_elements
- #--------------------------------------------------------------------------
- def listed_elements
- Bubs::TOCrafting::DISPLAYED_ELEMENT_RESISTS
- end
- #--------------------------------------------------------------------------
- # listed_states
- #--------------------------------------------------------------------------
- def listed_states
- Bubs::TOCrafting::DISPLAYED_STATE_RESISTS
- end
- #--------------------------------------------------------------------------
- # draw_usableitem_info
- #--------------------------------------------------------------------------
- def draw_usableitem_info(item, x, y)
- draw_hp_recovery(item, x, y + line_height * 0)
- draw_mp_recovery(item, x, y + line_height * 1)
- draw_tp_recovery(item, x, y + line_height * 2)
- draw_add_state_text(item, x, y + line_height * 4)
- draw_add_state_icons(item, x, y + line_height * 5)
- draw_remove_state_text(item, x, y + line_height * 7)
- draw_remove_state_icons(item, x, y + line_height * 8)
- end
- #--------------------------------------------------------------------------
- # draw_add_state_icons
- #--------------------------------------------------------------------------
- def draw_add_state_icons(item, x, y)
- icons = get_add_state_icons(item)
- icons.each_with_index do |n, i|
- icon_row_max = (contents.width - 4 - x) / 24
- y_plus = (i / icon_row_max) * line_height
- x_plus = (i % icon_row_max) * 24
- draw_icon(n, x + x_plus, y + y_plus)
- end
- end
- #--------------------------------------------------------------------------
- # get_add_state_icons
- #--------------------------------------------------------------------------
- def get_add_state_icons(item)
- icons = item.add_states.collect { |id| $data_states[id].icon_index }
- icons += item.add_buffs.collect { |param| buff_icon_index( 1, param) }
- icons += item.add_debuffs.collect { |param| buff_icon_index(-1, param) }
- icons.delete(0)
- icons
- end
- #--------------------------------------------------------------------------
- # draw_remove_state_icons
- #--------------------------------------------------------------------------
- def draw_remove_state_icons(item, x, y)
- icons = get_remove_state_icons(item)
- icons.each_with_index do |n, i|
- icon_row_max = (contents.width - 4 - x) / 24
- y_plus = (i / icon_row_max) * line_height
- x_plus = (i % icon_row_max) * 24
- draw_icon(n, x + x_plus, y + y_plus)
- end
- end
- #--------------------------------------------------------------------------
- # get_remove_state_icons
- #--------------------------------------------------------------------------
- def get_remove_state_icons(item)
- icons = item.remove_states.collect { |id| $data_states[id].icon_index }
- icons += item.remove_buffs.collect { |param| buff_icon_index( 1, param) }
- icons += item.remove_debuffs.collect { |param| buff_icon_index(-1, param) }
- icons.delete(0)
- icons
- end
- #--------------------------------------------------------------------------
- # buff_icon_index # Get Icon Number Corresponding to Buff/Debuff
- #--------------------------------------------------------------------------
- def buff_icon_index(buff_level, param_id)
- if buff_level > 0
- return ICON_BUFF_START + (buff_level - 1) * 8 + param_id
- elsif buff_level < 0
- return ICON_DEBUFF_START + (-buff_level - 1) * 8 + param_id
- else
- return 0
- end
- end
- #--------------------------------------------------------------------------
- # draw_add_state_text
- #--------------------------------------------------------------------------
- def draw_add_state_text(item, x, y)
- change_color(system_color)
- rect = standard_rect(x, y)
- text = info_header_text(:add_states) # "Add States"
- draw_text(rect, text)
- end
- #--------------------------------------------------------------------------
- # draw_remove_state_text
- #--------------------------------------------------------------------------
- def draw_remove_state_text(item, x, y)
- change_color(system_color)
- rect = standard_rect(x, y)
- text = info_header_text(:remove_states) # "Remove States"
- draw_text(rect, text)
- end
- #--------------------------------------------------------------------------
- # draw_hp_recovery
- #--------------------------------------------------------------------------
- def draw_hp_recovery(item, x, y)
- change_color(system_color)
- rect = standard_rect(x, y)
- text = info_header_text(:hp_recovery) # "HP Recovery"
- draw_text(rect, text)
- value = item.hp_recovery
- rate = item.hp_recovery_rate
- text = get_recovery_text(value, rate)
- draw_text(rect, text, 2)
- end
- #--------------------------------------------------------------------------
- # draw_mp_recovery
- #--------------------------------------------------------------------------
- def draw_mp_recovery(item, x, y)
- change_color(system_color)
- rect = standard_rect(x, y)
- text = info_header_text(:mp_recovery) # "MP Recovery"
- draw_text(rect, text)
- value = item.mp_recovery
- rate = item.mp_recovery_rate
- text = get_recovery_text(value, rate)
- draw_text(rect, text, 2)
- end
- #--------------------------------------------------------------------------
- # draw_tp_recovery
- #--------------------------------------------------------------------------
- def draw_tp_recovery(item, x, y)
- change_color(system_color)
- rect = standard_rect(x, y)
- text = info_header_text(:tp_recovery) # "TP Recovery"
- draw_text(rect, text)
- # If you get an error on this line, it means you are using an old
- # version of "Reader Functions for Features/Effects". Get v1.2 or above.
- value = item.tp_recovery
- text = get_recovery_text(value)
- draw_text(rect, text, 2)
- end
- #--------------------------------------------------------------------------
- # get_recovery_text
- #--------------------------------------------------------------------------
- def get_recovery_text(value, rate = 0)
- rate = rate * 100
- if value != 0 && rate != 0
- change_color(param_change_color(value))
- text = sprintf("%+d%%%+d", rate, value)
- elsif rate != 0
- change_color(param_change_color(rate))
- text = sprintf("%+d%%", rate)
- else
- change_color(param_change_color(value))
- text = sprintf("%+d", value)
- end
- return text
- end
- #--------------------------------------------------------------------------
- # draw_param_name
- #--------------------------------------------------------------------------
- def draw_param_name(x, y, param_id)
- change_color(system_color)
- text = Vocab::param(param_id)
- draw_text(x, y, contents.width - 4 - x, line_height, text)
- end
- #--------------------------------------------------------------------------
- # draw_param_value
- #--------------------------------------------------------------------------
- def draw_param_value(item, x, y, param_id)
- rect = standard_rect(x, y)
- value = item.param(param_id)
- rate = item.param_rate(param_id)
- text = get_param_text(value, rate)
- draw_text(rect, text, 2)
- end
- #--------------------------------------------------------------------------
- # get_param_text
- #--------------------------------------------------------------------------
- def get_param_text(value, rate = 0)
- rate = (rate * 100).to_i - 100
- if value != 0 && rate != 0
- change_color(param_change_color(value))
- text = sprintf("%+d%%%+d", rate, value)
- elsif rate != 0
- change_color(param_change_color(rate))
- text = sprintf("%+d%%", rate)
- else
- change_color(param_change_color(value))
- text = sprintf("%+d", value)
- end
- return text
- end
- #--------------------------------------------------------------------------
- # col_max
- #--------------------------------------------------------------------------
- def col_max
- return 2
- end
- #--------------------------------------------------------------------------
- # item_width
- #--------------------------------------------------------------------------
- def item_width
- (width - standard_padding * 2 + 4) / col_max - 4
- end
- #--------------------------------------------------------------------------
- # draw_item
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- if item
- rect = item_rect(index)
- rect.width -= 4
- draw_item_name(item, rect.x, rect.y, enable?(item))
- draw_item_number(rect, item)
- end
- end
- #--------------------------------------------------------------------------
- # draw_item_number
- #--------------------------------------------------------------------------
- def draw_item_number(rect, item)
- draw_text(rect, sprintf(":%2d", $game_party.item_number(item)), 2)
- end
- #--------------------------------------------------------------------------
- # draw_info_header_text
- #--------------------------------------------------------------------------
- def draw_info_header_text(x, y)
- rect = standard_rect(x, y)
- change_color(system_color)
- draw_text(rect, info_header_text(:main_header))
- draw_icon(@item.icon_index, rect.width - 24, y) if @item
- end
- #--------------------------------------------------------------------------
- # item= # Set Item
- #--------------------------------------------------------------------------
- def item=(item)
- @item = item
- @page_index = 0
- refresh
- end
- #--------------------------------------------------------------------------
- # ingredients
- #--------------------------------------------------------------------------
- def ingredients
- @item.ingredient_list
- end
- #--------------------------------------------------------------------------
- # tools
- #--------------------------------------------------------------------------
- def tools
- @item.tocrafting_tools
- end
- #--------------------------------------------------------------------------
- # actor_requirements
- #--------------------------------------------------------------------------
- def actor_requirements
- @item.tocrafting_actors
- end
- #--------------------------------------------------------------------------
- # ingredients_header_text
- #--------------------------------------------------------------------------
- def ingredients_header_text
- Bubs::TOCrafting::INGREDIENTS_HEADER_TEXT
- end
- #--------------------------------------------------------------------------
- # draw_ingredients_header_text
- #--------------------------------------------------------------------------
- def draw_ingredients_header_text(x, y)
- rect = standard_rect(x, y)
- change_color(system_color)
- draw_text(rect, ingredients_header_text)
- draw_icon(@item.icon_index, rect.width - 24, y) if @item
- end
- #--------------------------------------------------------------------------
- # use_gold_window?
- #--------------------------------------------------------------------------
- def use_gold_window?
- Bubs::TOCrafting::USE_GOLD_WINDOW
- end
- #--------------------------------------------------------------------------
- # create_ingredient_array
- #--------------------------------------------------------------------------
- def create_ingredients_array(item)
- @ingredients = []
- if !use_gold_window? && @item.tocrafting_gold_fee > 0
- @ingredients.push([:gold, @item.tocrafting_gold_fee])
- end
- actor_requirements.uniq.each do |id|
- @ingredients.push([:actor, $game_actors[id]])
- end
- tools.uniq.each do |tool|
- @ingredients.push([:tool, tool])
- end
- ingredients.uniq.each do |ingredient|
- @ingredients.push([:ingredient, ingredient])
- end
- end
- #--------------------------------------------------------------------------
- # draw_ingredients
- #--------------------------------------------------------------------------
- def draw_ingredients(x, y)
- return unless @item
- i = 0
- create_ingredients_array(@item)
- @page_index = 0 if viewable_ingredients.nil?
- for pair in viewable_ingredients
- case pair[0]
- when :gold
- draw_gold_info(pair[1], x, y)
- i += 1
- when :actor
- draw_actor_req_info(pair[1], x, y + line_height * (i * 2))
- i += 1
- when :tool
- draw_tools_info(pair[1], x, y + line_height * (i * 2))
- i += 1
- when :ingredient
- draw_ingredient_info(pair[1], x, y + line_height * (i * 2))
- i += 1
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Array of Actors for Which to Draw Equipment Information
- #--------------------------------------------------------------------------
- def viewable_ingredients
- @ingredients[@page_index * page_size, page_size]
- end
- #--------------------------------------------------------------------------
- # page_size # Number of Ingredients Displayable at Once
- #--------------------------------------------------------------------------
- def page_size
- Bubs::TOCrafting::INGREDIENTS_PAGE_SIZE
- end
- #--------------------------------------------------------------------------
- # page_max # Get Maximum Number of Pages
- #--------------------------------------------------------------------------
- def page_max
- (@ingredients.size + page_size - 1) / page_size
- end
- #--------------------------------------------------------------------------
- # required_amount
- #--------------------------------------------------------------------------
- def required_amount(item)
- ingredients.count(item) * @number
- end
- #--------------------------------------------------------------------------
- # party_amount
- #--------------------------------------------------------------------------
- def party_amount(item)
- $game_party.item_number(item)
- end
- #--------------------------------------------------------------------------
- # crafting_fee
- #--------------------------------------------------------------------------
- def crafting_fee
- @item.tocrafting_gold_fee
- end
- #--------------------------------------------------------------------------
- # party_gold
- #--------------------------------------------------------------------------
- def party_gold
- $game_party.gold
- end
- #--------------------------------------------------------------------------
- # currency_unit
- #--------------------------------------------------------------------------
- def currency_unit
- Vocab::currency_unit
- end
- #--------------------------------------------------------------------------
- # actor_icons
- #--------------------------------------------------------------------------
- def actor_icons
- Bubs::TOCrafting::ACTOR_ICONS
- end
- #--------------------------------------------------------------------------
- # draw_tools_info
- #--------------------------------------------------------------------------
- def draw_tools_info(item, x, y)
- enabled = $game_party.has_item?(item)
- width = contents.width - 4 - x
- draw_item_name(item, x, y, enabled, width)
- draw_tool_availability_text(item, x, y, enabled)
- end
- #--------------------------------------------------------------------------
- # draw_actor_req_info
- #--------------------------------------------------------------------------
- def draw_actor_req_info(actor, x, y)
- enabled = $game_party.members.include?(actor)
- width = contents.width - 4 - x
- icon_index = actor_icons[actor.id] ? actor_id : :default
- draw_icon(actor_icons[icon_index], x, y, enabled)
- draw_actor_availability_text(actor.id, x, y, enabled)
- change_color(normal_color, enabled)
- draw_text(x + 24, y, width, line_height, actor.name)
- end
- #--------------------------------------------------------------------------
- # draw_tool_availability_text
- #--------------------------------------------------------------------------
- def draw_tool_availability_text(item, x, y, enabled)
- rect = Rect.new(x, y + line_height, contents.width - 4 - x, line_height)
- if enabled
- change_color(text_color(Bubs::TOCrafting::TOOL_AVAILABLE_TEXT_COLOR))
- draw_text(rect, Bubs::TOCrafting::TOOL_AVAILABLE_TEXT, 2)
- else
- change_color(text_color(Bubs::TOCrafting::TOOL_UNAVAILABLE_TEXT_COLOR))
- draw_text(rect, Bubs::TOCrafting::TOOL_UNAVAILABLE_TEXT, 2)
- end
- end
- #--------------------------------------------------------------------------
- # draw_actor_availability_text
- #--------------------------------------------------------------------------
- def draw_actor_availability_text(item, x, y, enabled)
- rect = Rect.new(x, y + line_height, contents.width - 4 - x, line_height)
- if enabled
- change_color(text_color(Bubs::TOCrafting::ACTOR_AVAILABLE_TEXT_COLOR))
- draw_text(rect, Bubs::TOCrafting::ACTOR_AVAILABLE_TEXT, 2)
- else
- change_color(text_color(Bubs::TOCrafting::ACTOR_UNAVAILABLE_TEXT_COLOR))
- draw_text(rect, Bubs::TOCrafting::ACTOR_UNAVAILABLE_TEXT, 2)
- end
- end
- #--------------------------------------------------------------------------
- # draw_ingredient_info
- #--------------------------------------------------------------------------
- def draw_ingredient_info(item, x, y)
- enabled = party_amount(item) >= required_amount(item)
- width = contents.width - 4 - x
- draw_item_name(item, x, y, enabled, width)
- not_enough_ingredients_color unless enabled
- rect = Rect.new(x, y + line_height, contents.width - 4 - x, line_height)
- draw_text(rect, sprintf("×%2d/%2d", required_amount(item), party_amount(item)), 2)
- end
- #--------------------------------------------------------------------------
- # draw_gold_info
- #--------------------------------------------------------------------------
- def draw_gold_info(item, x, y)
- return if item.nil?
- enabled = party_gold >= crafting_fee
- cx = text_size(currency_unit).width
- width = contents.width - 4 - x
- draw_gold_name(x, y, enabled)
- change_color(system_color)
- draw_text(x, y + line_height, width, line_height, currency_unit, 2)
- change_color(normal_color)
- not_enough_ingredients_color unless enabled
- text = sprintf("%8d/%8d", crafting_fee * @number, party_gold)
- draw_text(x, y + line_height, width - cx - 2, line_height, text, 2)
- end
- #--------------------------------------------------------------------------
- # draw_gold_name
- #--------------------------------------------------------------------------
- def draw_gold_name(x, y, enabled = true)
- draw_icon(Bubs::TOCrafting::GOLD_WINDOW_ICON_INDEX, x, y, enabled)
- change_color(normal_color, enabled)
- draw_text(x + 24, y, width, line_height, Bubs::TOCrafting::GOLD_WINDOW_TEXT)
- end
- #--------------------------------------------------------------------------
- # not_enough_ingredients_color
- #--------------------------------------------------------------------------
- def not_enough_ingredients_color
- enabled = !Bubs::TOCrafting::FADED_REQUIREMENT_QUANTITY
- color_index = Bubs::TOCrafting::NOT_ENOUGH_INGREDIENTS_COLOR
- change_color(text_color(color_index), enabled)
- end
- end # class Window_TOCraftingInfo
- #==============================================================================
- # ++ Window_TOCraftingResult
- #==============================================================================
- class Window_TOCraftingResult < Window_Selectable
- #--------------------------------------------------------------------------
- # initialize
- #--------------------------------------------------------------------------
- def initialize(x, y)
- @item = nil
- @number = 0
- super(x, y, window_width,window_height)
- end
- #--------------------------------------------------------------------------
- # window_width
- #--------------------------------------------------------------------------
- def window_width
- Graphics.width / 2
- end
- #--------------------------------------------------------------------------
- # window_height
- #--------------------------------------------------------------------------
- def window_height
- fitting_height(2)
- end
- #--------------------------------------------------------------------------
- # set
- #--------------------------------------------------------------------------
- def set(item, number)
- @item = item
- @number = number
- end
- #--------------------------------------------------------------------------
- # refresh
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_result_header_text(4, 0)
- draw_result_item(4, line_height)
- end
- #--------------------------------------------------------------------------
- # draw_result_header_text
- #--------------------------------------------------------------------------
- def draw_result_header_text(x, y)
- return unless @item
- rect = Rect.new(x, y, contents.width - 4 - x, line_height)
- change_color(system_color)
- draw_text(rect, Bubs::TOCrafting::RESULT_WINDOW_HEADER_TEXT, 1)
- end
- #--------------------------------------------------------------------------
- # draw_result_item
- #--------------------------------------------------------------------------
- def draw_result_item(x, y)
- return unless @item
- draw_item_name(@item, x, y, true)
- draw_item_amount(x, y, @number)
- end
- #--------------------------------------------------------------------------
- # draw_item_amount
- #--------------------------------------------------------------------------
- def draw_item_amount(x, y, number)
- rect = Rect.new(x, y, contents.width - 4 - x, line_height)
- draw_text(rect, sprintf("×%2d", number), 2)
- end
- end # class Window_TOCraftingResult
- #==============================================================================
- # ++ Window_TOCraftingGold
- #==============================================================================
- class Window_TOCraftingGold < Window_Base
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :number
- #--------------------------------------------------------------------------
- # initialize
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, window_width, fitting_height(2))
- @item = nil
- @number = 1
- refresh
- end
- #--------------------------------------------------------------------------
- # window_width
- #--------------------------------------------------------------------------
- def window_width
- return Graphics.width / 2
- end
- #--------------------------------------------------------------------------
- # item=
- #--------------------------------------------------------------------------
- def item=(item)
- @item = item
- refresh
- end
- #--------------------------------------------------------------------------
- # refresh
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_gold_info(4, 0)
- end
- #--------------------------------------------------------------------------
- # currency_unit
- #--------------------------------------------------------------------------
- def currency_unit
- Vocab::currency_unit
- end
- #--------------------------------------------------------------------------
- # open
- #--------------------------------------------------------------------------
- def open
- refresh
- super
- end
- #--------------------------------------------------------------------------
- # crafting_fee
- #--------------------------------------------------------------------------
- def crafting_fee
- @item.tocrafting_gold_fee
- end
- #--------------------------------------------------------------------------
- # party_gold
- #--------------------------------------------------------------------------
- def party_gold
- $game_party.gold
- end
- #--------------------------------------------------------------------------
- # draw_gold_info
- #--------------------------------------------------------------------------
- def draw_gold_info(x, y)
- return if @item.nil?
- enabled = party_gold >= crafting_fee
- cx = text_size(currency_unit).width
- width = contents.width - 4 - x
- draw_gold_name(x, y, enabled)
- change_color(system_color)
- draw_text(x, y + line_height, width, line_height, currency_unit, 2)
- change_color(normal_color)
- not_enough_ingredients_color unless enabled
- text = sprintf("%8d/%8d", crafting_fee * @number, party_gold)
- draw_text(x, y + line_height, width - cx - 2, line_height, text, 2)
- end
- #--------------------------------------------------------------------------
- # draw_gold_name
- #--------------------------------------------------------------------------
- def draw_gold_name(x, y, enabled = true)
- draw_icon(Bubs::TOCrafting::GOLD_WINDOW_ICON_INDEX, x, y, enabled)
- change_color(normal_color, enabled)
- draw_text(x + 24, y, width, line_height, Bubs::TOCrafting::GOLD_WINDOW_TEXT)
- end
- #--------------------------------------------------------------------------
- # not_enough_ingredients_color
- #--------------------------------------------------------------------------
- def not_enough_ingredients_color
- enabled = !Bubs::TOCrafting::FADED_REQUIREMENT_QUANTITY
- color_index = Bubs::TOCrafting::NOT_ENOUGH_INGREDIENTS_COLOR
- change_color(text_color(color_index), enabled)
- end
- end # class Window_TOCraftingGold
- #==============================================================================
- # ++ Window_TOCraftingNumber
- #==============================================================================
- class Window_TOCraftingNumber < Window_Selectable
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :number # quantity entered
- attr_reader :item
- #--------------------------------------------------------------------------
- # initialize
- #--------------------------------------------------------------------------
- def initialize(x, y, height)
- super(x, y, window_width, height)
- @item = nil
- @info_window = nil
- @max = 1
- @price = 0
- @number = 1
- @currency_unit = Vocab::currency_unit
- end
- #--------------------------------------------------------------------------
- # window_width
- #--------------------------------------------------------------------------
- def window_width
- return Graphics.width / 2
- end
- #--------------------------------------------------------------------------
- # info_window=
- #--------------------------------------------------------------------------
- def info_window=(info_window)
- @info_window = info_window
- end
- #--------------------------------------------------------------------------
- # gold_window=
- #--------------------------------------------------------------------------
- def gold_window=(gold_window)
- @gold_window = gold_window
- end
- #--------------------------------------------------------------------------
- # set
- #--------------------------------------------------------------------------
- def set(item, max, price, currency_unit = nil)
- @item = item
- @max = max
- @price = price
- @currency_unit = currency_unit if currency_unit
- @number = 1
- refresh
- end
- #--------------------------------------------------------------------------
- # currency_unit
- #--------------------------------------------------------------------------
- def currency_unit=(currency_unit)
- @currency_unit = currency_unit
- refresh
- end
- #--------------------------------------------------------------------------
- # refresh
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_item_name(@item, 0, item_y)
- draw_number
- update_info_window
- update_gold_window
- end
- #--------------------------------------------------------------------------
- # draw_number
- #--------------------------------------------------------------------------
- def draw_number
- change_color(normal_color)
- draw_text(cursor_x - 28, item_y, 22, line_height, "×")
- draw_text(cursor_x, item_y, cursor_width - 4, line_height, @number, 2)
- end
- #--------------------------------------------------------------------------
- # draw_total_price
- #--------------------------------------------------------------------------
- def draw_total_price
- return if @item.nil?
- return if @item.tocrafting_gold_fee == 0
- width = contents_width - 8
- draw_currency_value(@price * @number, @currency_unit, 4, price_y, width)
- end
- #--------------------------------------------------------------------------
- # item_y # Y Coordinate of Item Name Display Line
- #--------------------------------------------------------------------------
- def item_y
- contents_height / 2 - line_height * 3 / 2
- end
- #--------------------------------------------------------------------------
- # price_y # Y Coordinate of Price Display Line
- #--------------------------------------------------------------------------
- def price_y
- contents_height / 2 + line_height / 2
- end
- #--------------------------------------------------------------------------
- # cursor_width
- #--------------------------------------------------------------------------
- def cursor_width
- figures * 10 + 12
- end
- #--------------------------------------------------------------------------
- # cursor_x # Get X Coordinate of Cursor
- #--------------------------------------------------------------------------
- def cursor_x
- contents_width - cursor_width - 4
- end
- #--------------------------------------------------------------------------
- # figures # Get Maximum Number of Digits for Quantity Display
- #--------------------------------------------------------------------------
- def figures
- return 2
- end
- #--------------------------------------------------------------------------
- # update # Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- if active
- last_number = @number
- update_number
- if @number != last_number
- Sound.play_cursor
- refresh
- end
- end
- end
- #--------------------------------------------------------------------------
- # update_number # Update Quantity
- #--------------------------------------------------------------------------
- def update_number
- change_number(1) if Input.repeat?(:RIGHT)
- change_number(-1) if Input.repeat?(:LEFT)
- change_number(10) if Input.repeat?(:UP)
- change_number(-10) if Input.repeat?(:DOWN)
- end
- #--------------------------------------------------------------------------
- # change_number
- #--------------------------------------------------------------------------
- def change_number(amount)
- @number = [[@number + amount, @max].min, 1].max
- end
- #--------------------------------------------------------------------------
- # update_cursor
- #--------------------------------------------------------------------------
- def update_cursor
- cursor_rect.set(cursor_x, item_y, cursor_width, line_height)
- end
- #--------------------------------------------------------------------------
- # update_info_window
- #--------------------------------------------------------------------------
- def update_info_window
- @info_window.number = @number
- @info_window.refresh
- end
- #--------------------------------------------------------------------------
- # update_gold_window
- #--------------------------------------------------------------------------
- def update_gold_window
- @gold_window.number = @number
- @gold_window.refresh
- end
- end # class Window_TOCraftingNumber
- #==============================================================================
- # ++ Window_TOCraftingCover
- #==============================================================================
- class Window_TOCraftingCover < Window_Base
- #--------------------------------------------------------------------------
- # refresh
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_bookcover(0, 0)
- end
- #--------------------------------------------------------------------------
- # item=
- #--------------------------------------------------------------------------
- def item=(item)
- @item = item
- refresh
- end
- #--------------------------------------------------------------------------
- # stretch_pictures?
- #--------------------------------------------------------------------------
- def stretch_pictures?
- Bubs::TOCrafting::STRETCH_RECIPEBOOK_PICTURES
- end
- #--------------------------------------------------------------------------
- # draw_bookcover
- #--------------------------------------------------------------------------
- def draw_bookcover(x, y)
- return unless @item
- bitmap = Cache.recipebook_cover(@item.tocrafting_bookcover)
- rect = Rect.new(0, 0, contents.width, contents.height)
- if stretch_pictures?
- contents.stretch_blt(rect, bitmap, bitmap.rect)
- else
- x = (contents.width - bitmap.width) / 2
- y = (contents.height - bitmap.height) / 2
- contents.blt(x, y, bitmap, rect)
- end
- bitmap.dispose
- end
- end # class Window_TOCraftingCover
- #==============================================================================
- # ++ Game_Interpreter
- #==============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # new method : call_tocrafting_scene
- #--------------------------------------------------------------------------
- def call_tocrafting_scene(*args)
- SceneManager.call(Scene_TOCrafting)
- SceneManager.scene.prepare(args)
- end
- alias open_tocrafting_shop call_tocrafting_scene
- end
- #==============================================================================
- # ++ Scene_TOCrafting
- #==============================================================================
- class Scene_TOCrafting < Scene_MenuBase
- #--------------------------------------------------------------------------
- # prepare
- #--------------------------------------------------------------------------
- def prepare(categories)
- @categories = categories
- end
- #--------------------------------------------------------------------------
- # start
- #--------------------------------------------------------------------------
- def start
- super
- create_help_window
- create_gold_window
- create_cover_window
- create_info_window
- create_itemlist_header_window
- create_itemlist_window
- create_recipelist_window
- create_number_window
- create_result_window
- end
- #--------------------------------------------------------------------------
- # create_gold_window
- #--------------------------------------------------------------------------
- def create_gold_window
- @gold_window = Window_TOCraftingGold.new
- @gold_window.viewport = @viewport
- @gold_window.hide.close
- @gold_window.x = 0
- @gold_window.y = Graphics.height - @gold_window.height
- end
- #--------------------------------------------------------------------------
- # create_recipelist_window
- #--------------------------------------------------------------------------
- def create_recipelist_window
- wx = 0
- wy = @help_window.height
- wh = Graphics.height - wy
- @recipelist_window = Window_TOCraftingRecipeList.new(wx, wy, wh)
- @recipelist_window.viewport = @viewport
- @recipelist_window.help_window = @help_window
- @recipelist_window.info_window = @info_window
- @recipelist_window.header_window = @itemlist_header_window
- @recipelist_window.cover_window = @cover_window
- @recipelist_window.categories = @categories
- @recipelist_window.set_handler(:ok, method(:on_recipelist_ok))
- @recipelist_window.set_handler(:cancel, method(:on_recipelist_cancel))
- @recipelist_window.refresh
- @recipelist_window.show.activate.select(0)
- end
- #--------------------------------------------------------------------------
- # on_recipelist_ok
- #--------------------------------------------------------------------------
- def on_recipelist_ok
- @recipelist_window.close
- @itemlist_window.item = @recipelist_window.item
- @gold_window.show.open if gold_window?
- @cover_window.hide
- @info_window.show
- @info_window.set_page_keys
- activate_itemlist_window
- end
- #--------------------------------------------------------------------------
- # on_recipelist_cancel
- #--------------------------------------------------------------------------
- def on_recipelist_cancel
- refresh
- return_scene
- end
- #--------------------------------------------------------------------------
- # activate_recipelist_window
- #--------------------------------------------------------------------------
- def activate_recipelist_window
- refresh
- @recipelist_window.show.open.activate
- end
- #--------------------------------------------------------------------------
- # create_itemlist_window
- #--------------------------------------------------------------------------
- def create_itemlist_window
- wx = 0
- wy = @help_window.height + @itemlist_header_window.height
- wh = Graphics.height - wy
- wh = wh - @gold_window.height if gold_window?
- @itemlist_window = Window_TOCraftingItemList.new(wx, wy, wh)
- @itemlist_window.viewport = @viewport
- @itemlist_window.help_window = @help_window
- @itemlist_window.info_window = @info_window
- @itemlist_window.gold_window = @gold_window
- @itemlist_window.hide
- @itemlist_window.close
- @itemlist_window.set_handler(:ok, method(:on_itemlist_ok))
- @itemlist_window.set_handler(:cancel, method(:on_itemlist_cancel))
- @itemlist_window.refresh
- end
- #--------------------------------------------------------------------------
- # on_itemlist_ok
- #--------------------------------------------------------------------------
- def on_itemlist_ok
- @item = @itemlist_window.item
- @itemlist_window.close.hide
- @number_window.set(@item, max_craft, crafting_fee)
- @info_window.page_change = false
- @info_window.set_page_keys
- @number_window.show.open.activate
- end
- #--------------------------------------------------------------------------
- # on_itemlist_cancel
- #--------------------------------------------------------------------------
- def on_itemlist_cancel
- @itemlist_window.close
- @itemlist_header_window.close
- @gold_window.close.hide if gold_window?
- @info_window.hide
- @cover_window.show
- activate_recipelist_window
- end
- #--------------------------------------------------------------------------
- # activate_itemlist_window
- #--------------------------------------------------------------------------
- def activate_itemlist_window
- refresh
- @itemlist_header_window.show.open
- @itemlist_window.show.open.activate.select(0)
- end
- #--------------------------------------------------------------------------
- # create_number_window
- #--------------------------------------------------------------------------
- def create_number_window
- wx = 0
- wy = @itemlist_header_window.y + @itemlist_header_window.height
- wh = Graphics.height - wy
- wh = wh - @gold_window.height if gold_window?
- @number_window = Window_TOCraftingNumber.new(wx, wy, wh)
- @number_window.viewport = @viewport
- @number_window.info_window = @info_window
- @number_window.gold_window = @gold_window
- @number_window.hide.close
- @number_window.set_handler(:ok, method(:on_number_ok))
- @number_window.set_handler(:cancel, method(:on_number_cancel))
- end
- #--------------------------------------------------------------------------
- # on_number_ok
- #--------------------------------------------------------------------------
- def on_number_ok
- @number_window.close.hide
- @number_window.number
- do_crafting(@item, @number_window.number)
- @result_window.set(@item, @number_window.number)
- @result_window.show.open.activate
- @itemlist_window.show.open
- @info_window.page_change = true
- @gold_window.number = @info_window.number = 1
- refresh
- @result_window.show.open.activate
- end
- #--------------------------------------------------------------------------
- # on_number_cancel
- #--------------------------------------------------------------------------
- def on_number_cancel
- @number_window.close.hide
- @gold_window.number = @info_window.number = 1
- @info_window.page_change = true
- @itemlist_window.show.open.activate
- end
- #--------------------------------------------------------------------------
- # create_result_window
- #--------------------------------------------------------------------------
- def create_result_window
- wx = Graphics.width / 4
- wy = 0
- @result_window = Window_TOCraftingResult.new(wx, wy)
- @result_window.y = (Graphics.height / 2) - (@result_window.height / 2)
- @result_window.viewport = @viewport
- @result_window.hide.close
- @result_window.set_handler(:ok, method(:on_result_ok))
- @result_window.refresh
- end
- #--------------------------------------------------------------------------
- # on_result_ok
- #--------------------------------------------------------------------------
- def on_result_ok
- @result_window.close.hide
- @itemlist_window.activate
- end
- #--------------------------------------------------------------------------
- # create_itemlist_header_window
- #--------------------------------------------------------------------------
- def create_itemlist_header_window
- wx = 0
- wy = @help_window.height
- @itemlist_header_window = Window_TOCraftingItemListHeader.new(wx, wy)
- @itemlist_header_window.viewport = @viewport
- @itemlist_header_window.hide
- @itemlist_header_window.close
- @itemlist_header_window.refresh
- end
- #--------------------------------------------------------------------------
- # create_cover_window
- #--------------------------------------------------------------------------
- def create_cover_window
- wx = Graphics.width / 2
- wy = @help_window.height
- wh = Graphics.height - @help_window.height
- ww = Graphics.width - wx
- @cover_window = Window_TOCraftingCover.new(wx, wy, ww, wh)
- @cover_window.viewport = @viewport
- @cover_window.refresh
- @cover_window.show
- end
- #--------------------------------------------------------------------------
- # create_info_window
- #--------------------------------------------------------------------------
- def create_info_window
- wx = Graphics.width / 2
- wy = @help_window.height
- ww = Graphics.width - wx
- wh = Graphics.height - @help_window.height
- @info_window = Window_TOCraftingInfo.new(wx, wy, ww, wh)
- @info_window.viewport = @viewport
- @info_window.hide
- @info_window.refresh
- end
- #--------------------------------------------------------------------------
- # refresh
- #--------------------------------------------------------------------------
- def refresh
- @info_window.refresh
- @help_window.refresh
- @itemlist_window.refresh
- @recipelist_window.refresh
- @result_window.refresh
- @itemlist_header_window.refresh
- @gold_window.refresh
- end
- #--------------------------------------------------------------------------
- # do_crafting
- #--------------------------------------------------------------------------
- def do_crafting(item, number)
- return unless item
- play_crafting_se(item)
- lose_ingredients(item, number)
- pay_crafting_fee(item, number)
- gain_crafted_item(item, number)
- end
- #--------------------------------------------------------------------------
- # play_crafting_se
- #--------------------------------------------------------------------------
- def play_crafting_se(item)
- if item.tocrafting_se.empty?
- Sound.play_tocrafting_result
- else
- se = item.tocrafting_se
- Sound.play_custom_tocrafting_result(se[0], se[1], se[2])
- end
- end
- #--------------------------------------------------------------------------
- # lose_ingredients
- #--------------------------------------------------------------------------
- def lose_ingredients(item, number)
- item.ingredient_list.each do |ingredient|
- $game_party.lose_item(ingredient, number)
- end
- end
- #--------------------------------------------------------------------------
- # pay_crafting_fee
- #--------------------------------------------------------------------------
- def pay_crafting_fee(item, number)
- $game_party.lose_gold(item.tocrafting_gold_fee * number)
- end
- #--------------------------------------------------------------------------
- # gain_crafted_item
- #--------------------------------------------------------------------------
- def gain_crafted_item(item, number)
- $game_party.gain_item(item, number)
- end
- #--------------------------------------------------------------------------
- # crafting_fee
- #--------------------------------------------------------------------------
- def crafting_fee
- @item.tocrafting_gold_fee
- end
- #--------------------------------------------------------------------------
- # gold_window?
- #--------------------------------------------------------------------------
- def gold_window?
- Bubs::TOCrafting::USE_GOLD_WINDOW
- end
- #--------------------------------------------------------------------------
- # party_gold
- #--------------------------------------------------------------------------
- def party_gold
- $game_party.gold
- end
- #--------------------------------------------------------------------------
- # max_craft
- #--------------------------------------------------------------------------
- def max_craft
- max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
- max = crafting_fee == 0 ? max : [max, party_gold / crafting_fee].min
- for ingredient in @item.ingredient_list.uniq.each
- break if max == 0
- count = @item.ingredient_list.count(ingredient)
- temp_max = 0
- for i in 1..max
- break if (i * count) > $game_party.item_number(ingredient)
- temp_max += 1
- end # for
- max = temp_max if max > temp_max
- end # for
- return max
- end
- end # class Scene_TOCrafting
- if defined?(XAS_SYSTEM)
- #==============================================================================
- # ++ Window_ItemList
- #==============================================================================
- class Window_ItemList < Window_Selectable
- #--------------------------------------------------------------------------
- # compatibility alias : can_equip_item_action?
- #--------------------------------------------------------------------------
- alias can_equip_item_action_bubs_tocrafting can_equip_item_action?
- def can_equip_item_action?
- return false if SceneManager.scene_is?(Scene_TOCrafting)
- return can_equip_item_action_bubs_tocrafting # alias
- end
- end # class Window_ItemList
- end # if defined?(XAS_SYSTEM)
- if $imported["YEA-AceMenuEngine"]
- YEA::MENU::CUSTOM_COMMANDS.merge!(Bubs::TOCrafting::TOCRAFTING_CUSTOM_COMMAND)
- #==============================================================================
- # ++ Scene_Menu
- #==============================================================================
- class Scene_Menu < Scene_MenuBase
- #--------------------------------------------------------------------------
- # compatibility method : command_tocrafting
- #--------------------------------------------------------------------------
- def command_tocrafting(*args)
- SceneManager.call(Scene_TOCrafting)
- SceneManager.scene.prepare(args)
- end
- end # class Scene_Menu
- end # if $imported["YEA-AceMenuEngine"]
Add Comment
Please, Sign In to add comment