设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 58|回复: 0

[转载发布] Mobius's Crafting Minigame

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    5778

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    25563
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    32235

    灌水之王

    发表于 昨天 19:05 | 显示全部楼层 |阅读模式
    Crafting Minigame
    by
    MobiusXVI

    Release Notes
    May 2014 - v. 1.0 Initial Release
    Mar 2024 - v. 2.0 Script refactored; updated database; bug fixes
    Apr 2024 - v. 2.1 Add additional customization options

    Introduction
    So a long time ago, I made this script to fulfill a request here. It then sat neglected for many years. After some prompting, I decided to clean it up, fix some bugs, and re-post it here for all to use.

    Features
    - Create as many recipes as you like
    - Create unlimited recipe types
    - Players play a minigame to craft items
    - Easily call the crafting screen from the menu using my Menu Command Manager

    Screenshots
    Spoiler





    Spoiler






    How to Use
    Instructions are in the script. Download the demo, and open the script editor for more information.

    Demo
    Download the demo from the attached files.

    Script
    I recommend you download the demo as this won't work right out of the box, but if you really just want the script and don't mind fiddling with it to get it to work then here you go.
    Spoiler: Main Script
                    Ruby:       
    1. #===============================================================================
    2. # Mobius' Crafting Program
    3. # Authors: Mobius XVI, Deke
    4. # Version: 2.1
    5. # Date: 14 APR 2024
    6. #===============================================================================
    7. #
    8. # Introduction:
    9. #
    10. #   This script allows you to add crafting to your game which includes a
    11. #   crafting minigame where the player tries to match a given recipe for
    12. #   a particular item in order to create it successfully. Failures result
    13. #   in wasted components and a junk item.
    14. #
    15. # Instructions:
    16. #
    17. #   Place this script below all the default scripts but above main.
    18. #
    19. #   Add the database section below the crafting script
    20. #   Create your recipes in the database section; think of it like an
    21. #   extension of the built-in database.
    22. #
    23. #   Each recipe needs the following:
    24. #     - Three ingredients -- These can be any item, weapon, or armor
    25. #     - Three ingredient quantites -- These can be any positive, whole numbers
    26. #       less than 100 but the sum of all three should add up to 100 exactly
    27. #     - A result -- this can be an item, weapon, or armor
    28. #     - A recipe type -- this is an arbitrary tag of your choosing, such as
    29. #       "Cooking", "Baking", "Smelting". This allows recipes to be grouped
    30. #       by their type. This will make it so that you can limit baking recipes
    31. #       to only work when using an oven for example.
    32. #
    33. #   To have the player learn recipes, simply make an event with this script call
    34. #     $game_party.learn_recipe(1) -- Replace 1 with the recipe's ID in the database
    35. #
    36. #   To call the crafting screen, simply make an event with this script call
    37. #     $scene = Scene_Craft.new("Cooking")         -- Will only have cooking recipes
    38. #     $scene = Scene_Craft.new                    -- Will have all recipes
    39. #     $scene = Scene_Craft.new(nil, "menu")       -- Will exit to the menu
    40. #     $scene = Scene_Craft.new("Cooking", "menu") -- Only cooking; exit to menu
    41. #
    42. #   The crafting minigame works by asking the player to add the three ingredients
    43. #   in the correct proportions (with an error tolerance of 10% by default).
    44. #   If the player successfully combines the items in the right portions
    45. #   then they will craft the intended item.
    46. #   If not, they'll receive a junk item of your choosing.
    47. #
    48. #   The minigame itself uses the X, Y, and Z "buttons" to add the ingredients.
    49. #   Check F1 to see what keyboard keys these are mapped to on your computer.
    50. #   By default, they 're mapped to A, S, and D.
    51. #
    52. # Issues/Bugs/Possible Bugs:
    53. #
    54. #   - None
    55. #
    56. #  Credits/Thanks:
    57. #    - Deke, author of underlying crafting script
    58. #    - Mobius XVI, author of minigame portion
    59. #    - sutorumie, for the idea/request
    60. #
    61. #  License
    62. #
    63. #    This script is available in its entirety for commercial and non-commercial
    64. #    use. View the specific license terms below.
    65. #
    66. #    The portions of this script written by me are licensed under the MIT License:
    67. #
    68. #    The MIT License (MIT)
    69. #
    70. #      Copyright (c) 2024 darmes
    71. #
    72. #       Permission is hereby granted, free of charge, to any person obtaining a copy
    73. #       of this software and associated documentation files (the "Software"), to deal
    74. #       in the Software without restriction, including without limitation the rights
    75. #       to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    76. #       copies of the Software, and to permit persons to whom the Software is
    77. #       furnished to do so, subject to the following conditions:
    78. #
    79. #       The above copyright notice and this permission notice shall be included in all
    80. #       copies or substantial portions of the Software.
    81. #
    82. #       THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    83. #       IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    84. #       FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    85. #       AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    86. #       LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    87. #       OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    88. #       SOFTWARE.
    89. #
    90. #      Further, if you do decide to use this script in a commercial product,
    91. #      I'd ask that you let me know via a forum post or a PM. Thanks.
    92. #
    93. #==============================================================================
    94. # ** CUSTOMIZATION START
    95. #==============================================================================
    96. module Mobius
    97.   module Crafting
    98.     # Set the following value to false if you don' t want the game
    99.     # to check whether your recipes are properly formatted
    100.     # Note that data checking only works in playtest mode
    101.     # and so will not function in any final release
    102.     DATA_CHECK = true
    103.     # Set the item ID for the waste item. This must be an item that exists.
    104.     WASTE_ITEM_ID = 1
    105.     # Do you have a custom menu system? When the crafting scene ends we can
    106.     # return to the menu with a chosen menu index selected.
    107.     MENU_INDEX = 0
    108.     # Set the icons to use for the X, Y, and Z buttons.
    109.     # The icons should be about 24x24, but the script will auto-adjust them
    110.     # if they are slightly larger/smaller. Don't expect miracles though.
    111.     # This is a filename without extension within the icon folder.
    112.     X_BUTTON_ICON = "A"
    113.     Y_BUTTON_ICON = "S"
    114.     Z_BUTTON_ICON = "D"
    115.     # Set the picture to use for the progress bar.
    116.     # Picture should be exactly 204x20 pixels
    117.     # This is a filename without extension within the pictures folder.
    118.     BAR_PIC = "Bar"
    119.     # This lets you set pictures to use for window dressing.
    120.     # Pictures should be about 256x128 pixels
    121.     # You can set a different picture depending on the recipe type.
    122.     # If you'd rather just use a single picture then you can set a
    123.     # default picture below and it will always use that.
    124.     CRAFTING_PICTURES = {
    125.       # Recipe Type => picture filename without extension
    126.       "Smithing" => "Blacksmith",
    127.       # Start with recipe type then make this symbol '=>' then put a
    128.       # picture filename without extension within the pictures folder.
    129.       # End each entry with a comma ',' to separate them from each other.
    130.     }
    131.     # You can set a default picture here.
    132.     CRAFTING_PICTURES.default = "Laboratory"
    133.     # This lets you set sound effects for success and failure
    134.     # These are filenames without extension within the sound effects (SE) folder
    135.     # You can set a different SE depending on the recipe type.
    136.     # If you'd rather just use a single SE then you can set a default
    137.     # SE below and it will always use that.
    138.     CRAFT_SUCCESS_SE = {
    139.       # Recipe Type => SE filename without extension
    140.       "Smithing" => "055-Right01",
    141.       # Start with recipe type then make this symbol '=>' then put a
    142.       # SE filename without extension within the SE folder.
    143.       # End each entry with a comma ',' to separate them from each other.
    144.     }
    145.     # You can set a default success SE here.
    146.     CRAFT_SUCCESS_SE.default = "056-Right02"
    147.     CRAFT_FAILURE_SE = {
    148.       # Recipe Type => SE filename without extension
    149.       "Smithing" => "057-Wrong01",
    150.       # Start with recipe type then make this symbol '=>' then put a
    151.       # SE filename without extension within the SE folder.
    152.       # End each entry with a comma ',' to separate them from each other.
    153.     }
    154.     # You can set a default failure SE here.
    155.     CRAFT_FAILURE_SE.default = "058-Wrong02"
    156.     # Set the error tolerance for recipes, this is a percentage value
    157.     # i.e. the player needs to mix the ingredients according to the
    158.     # recipe within +/- 10%. Given the inherent inaccuracies, I
    159.     # recommend being fairly generous with this.
    160.     ERROR_TOLERANCE = 10
    161.     # Set the color to use for the outlines drawn around the ingredients
    162.     # and the finish/cancel buttons.
    163.     # Black by default. Colors are RGB.
    164.     OUTLINE_COLOR = Color.new(0, 0, 0) # Black
    165.     # Set the colors to use for filling the mixing bar. The colors show
    166.     # how much of each ingredient has been added, and can be set independently.
    167.     X_BUTTON_FILL_COLOR = Color.new(255, 0, 0) # Red
    168.     Y_BUTTON_FILL_COLOR = Color.new(0, 255, 0) # Green
    169.     Z_BUTTON_FILL_COLOR = Color.new(0, 0, 255) # Blue
    170.     # The following words are used for various displays
    171.     # Think of these as additional database words
    172.     HP_RECOVERY_AMOUNT = "HP Heal"
    173.     HP_DAMAGE_AMOUNT = "Damage"
    174.     HP_RECOVERY_PERCENT = "HP Heal %"
    175.     HP_DAMAGE_PERCENT = "Damage %"
    176.     SP_RECOVERY_AMOUNT = "SP Restore"
    177.     SP_DAMAGE_AMOUNT = "SP Drain"
    178.     SP_RECOVERY_PERCENT = "SP Restore %"
    179.     SP_DAMAGE_PERCENT = "SP Drain %"
    180.     HIT_RATE = "Accuracy"
    181.     EVASION = "EVA"
    182.     QUANTITY_OWNED = "Quantity currently owned:"
    183.     HAVE = "Have"
    184.     REQUIRED = "Req %"
    185.     FINISH = "Finish"
    186.     CANCEL = "Cancel"
    187.   end
    188. end
    189. #==============================================================================
    190. # ** CUSTOMIZATION END
    191. #------------------------------------------------------------------------------
    192. # ** EDIT BELOW THIS LINE AT OWN RISK!!!
    193. #==============================================================================
    194. #==============================================================================
    195. # ** Game_Party
    196. #==============================================================================
    197. class Game_Party
    198.   attr_accessor      :known_recipe_ids
    199.   #--------------------------------------------------------------------------
    200.   # * Object Initialization
    201.   #--------------------------------------------------------------------------
    202.   alias crafting_party_initialize initialize
    203.   def initialize
    204.     crafting_party_initialize
    205.     @known_recipe_ids=[]
    206.   end
    207.   #--------------------------------------------------------------------------
    208.   # * Know
    209.   #--------------------------------------------------------------------------
    210.   def know_recipe?(recipe_id)
    211.     return $game_party.known_recipe_ids.include?(recipe_id)
    212.   end
    213.   #--------------------------------------------------------------------------
    214.   # * Learn Recipe
    215.   #--------------------------------------------------------------------------
    216.   def learn_recipe(recipe_id)
    217.     # Don't learn recipes that aren't in the database
    218.     return if recipe_id <= 0
    219.     return if recipe_id >= Mobius::Recipes::RECIPES.size
    220.     # Don't learn recipes that we already know
    221.     return if know_recipe?(recipe_id)
    222.     @known_recipe_ids.push(recipe_id)
    223.   end
    224.   #--------------------------------------------------------------------------
    225.   # * Forget Recipe
    226.   #--------------------------------------------------------------------------
    227.   def forget_recipe(recipe_id)
    228.     @known_recipe_ids.delete(recipe_id)
    229.   end
    230. end
    231. #==============================================================================
    232. # ** Game_Recipe
    233. #==============================================================================
    234. class Game_Recipe
    235.   include Mobius::Crafting
    236.   attr_reader    :ingredients
    237.   attr_reader    :quantities
    238.   attr_reader    :result
    239.   attr_reader    :result_type
    240.   attr_reader    :ingredient_types
    241.   attr_reader    :recipe_type
    242.   attr_reader    :result
    243.   attr_reader    :result_type
    244.   #--------------------------------------------------------------------------
    245.   # * Object Initialization
    246.   #--------------------------------------------------------------------------
    247.   def initialize(ingredients, ingredient_types, quantities, result,
    248.     result_type, recipe_type = nil)
    249.     @ingredients = ingredients
    250.     @ingredient_types = ingredient_types
    251.     @quantities = quantities
    252.     @result = result
    253.     @result_type = result_type
    254.     @recipe_type = recipe_type
    255.     data_check if $DEBUG and DATA_CHECK
    256.   end
    257.   #--------------------------------------------------------------------------
    258.   # * Data_Check - Checks recipes for errors and reports them to user
    259.   #--------------------------------------------------------------------------
    260.   def data_check
    261.     unless @ingredients.size == 3
    262.       text = "WARNING:\n The recipe for \'#{name}\' does not have 3 ingredients."
    263.       text << "\nScript may not function as intended."
    264.       print(text)
    265.     end
    266.     unless @ingredient_types.size == 3
    267.       text = "WARNING:\n The recipe for \'#{name}\' does not have 3 ingredient"
    268.       text << " types.\nScript may not function as intended."
    269.       print(text)
    270.     end
    271.     unless @quantities.size == 3
    272.       text = "WARNING:\n The recipe for \'#{name}\' does not have 3 entries for"
    273.       text << " quantities.\nScript may not function as intended."
    274.       print(text)
    275.     end
    276.     unless @quantities.inject {|sum, n| sum + n } == 100
    277.       text = "WARNING:\n The recipe for \'#{name}\' has quantites which do not"
    278.       text << " equal 100%.\nScript may not function as intended."
    279.       print(text)
    280.     end
    281.     unless @result.is_a?(Integer)
    282.       text = "WARNING:\n The recipe for \'#{name}\' has a result which is not"
    283.       text << " a integer.\nScript may not function as intended."
    284.       print(text)
    285.     end
    286.     unless [0, 1, 2].include?(@result_type)
    287.       text = "WARNING:\n The recipe for \'#{name}\' has a result_type which is"
    288.       text << " not 0, 1, or 2.\nScript may not function as intended."
    289.       print(text)
    290.     end
    291.     unless @recipe_type.is_a?(String)
    292.       text = "WARNING:\n The recipe for \'#{name}\' has a recipe_type which is"
    293.       text << " not a String.\nScript may not function as intended."
    294.       print(text)
    295.     end
    296.   end
    297.   #--------------------------------------------------------------------------
    298.   # * Name - Returns the name of the item the recipe makes
    299.   #--------------------------------------------------------------------------
    300.   def name
    301.     case @result_type
    302.       when 0
    303.         name = $data_items[@result].name
    304.       when 1
    305.         name = $data_armors[@result].name
    306.       when 2
    307.         name = $data_weapons[@result].name
    308.     end
    309.     return name
    310.   end
    311.   #--------------------------------------------------------------------------
    312.   # * Have - Checks that the party has all the ingredients for this recipe
    313.   #--------------------------------------------------------------------------
    314.   def have
    315.     have_all = true
    316.     for i in 0...@ingredients.size
    317.       case @ingredient_types[i]
    318.         when 0
    319.           if $game_party.item_number(@ingredients[i]) < 1
    320.             have_all = false
    321.           end
    322.         when 1
    323.           if $game_party.armor_number(@ingredients[i]) < 1
    324.             have_all = false
    325.           end
    326.         when 2
    327.           if $game_party.weapon_number(@ingredients[i]) < 1
    328.             have_all = false
    329.           end
    330.       end
    331.     end
    332.     return have_all
    333.   end
    334.   #--------------------------------------------------------------------------
    335.   # * Decrement - Removes the recipe's ingredients from the party's inventory
    336.   #--------------------------------------------------------------------------
    337.   def decrement
    338.     for i in 0...@ingredients.size
    339.       case @ingredient_types[i]
    340.       when 0
    341.         $game_party.lose_item(@ingredients[i], 1)
    342.       when 1
    343.         $game_party.lose_armor(@ingredients[i], 1)
    344.       when 2
    345.         $game_party.lose_weapon(@ingredients[i], 1)
    346.       end
    347.     end
    348.   end
    349.   #--------------------------------------------------------------------------
    350.   # * Make - Adds the recipe's result to the party's inventory
    351.   #--------------------------------------------------------------------------
    352.   def make
    353.     if have
    354.       case @result_type
    355.       when 0
    356.         $game_party.gain_item(@result, 1)
    357.       when 1
    358.         $game_party.gain_armor(@result, 1)
    359.       when 2
    360.         $game_party.gain_weapon(@result, 1)
    361.       end
    362.       decrement
    363.     end
    364.   end
    365.   #--------------------------------------------------------------------------
    366.   # * Make Waste - Adds the waste item to the party's inventory
    367.   #--------------------------------------------------------------------------
    368.   def make_waste
    369.     if have
    370.       $game_party.gain_item(WASTE_ITEM_ID, 1)
    371.       decrement
    372.     end
    373.   end
    374.   #--------------------------------------------------------------------------
    375.   # * == - Compares two recipes for equality
    376.   #--------------------------------------------------------------------------
    377.   def == (recipe)
    378.     if recipe.is_a?(Game_Recipe)
    379.       equal = true
    380.       if recipe.ingredients != self.ingredients
    381.         equal = false
    382.       end
    383.       if recipe.ingredient_types != self.ingredient_types
    384.         equal = false
    385.       end
    386.       if recipe.quantities != self.quantities
    387.         equal = false
    388.       end
    389.       if recipe.result != self.result
    390.          equal=false
    391.       end
    392.       if recipe.result_type != self.result_type
    393.         equal = false
    394.       end
    395.       if recipe.recipe_type != self.recipe_type
    396.         equal = false
    397.       end
    398.     else
    399.       equal = false
    400.     end
    401.     return equal
    402.   end
    403. end
    404. #==============================================================================
    405. # ** Window_Base
    406. #==============================================================================
    407. class Window_Base
    408.   #--------------------------------------------------------------------------
    409.   # * Draw Icon - draws icons on "x, y"
    410.   #     icon_name : filename of the icon ("String")
    411.   #     x         : draw spot x-coordinate
    412.   #     y         : draw spot y-coordinate
    413.   #--------------------------------------------------------------------------
    414.   def draw_icon(icon_name, x, y)
    415.     bitmap = RPG::Cache.icon(icon_name)
    416.     src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
    417.     self.contents.blt(x, y, bitmap, src_rect)
    418.   end
    419.   #--------------------------------------------------------------------------
    420.   # * Draw Icon Centered- draws icons centered on "x, y"
    421.   #     icon_name : filename of the icon ("String")
    422.   #     x         : draw spot x-coordinate
    423.   #     y         : draw spot y-coordinate
    424.   #--------------------------------------------------------------------------
    425.   def draw_icon_centered(icon_name, x, y)
    426.     bitmap = RPG::Cache.icon(icon_name)
    427.     src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
    428.     draw_x = x - (bitmap.width / 2)
    429.     draw_y = y - (bitmap.height / 2)
    430.     self.contents.blt(draw_x, draw_y, bitmap, src_rect)
    431.   end
    432.   #--------------------------------------------------------------------------
    433.   # * Draw Pic - draws pic on "x, y"
    434.   #     pic_name  : filename of the pic ("String")
    435.   #     x         : draw spot x-coordinate
    436.   #     y         : draw spot y-coordinate
    437.   #--------------------------------------------------------------------------
    438.   def draw_pic(pic_name, x, y)
    439.     bitmap = RPG::Cache.picture(pic_name)
    440.     src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
    441.     self.contents.blt(x, y, bitmap, src_rect)
    442.   end
    443. end
    444. #==============================================================================
    445. # ** Window_Craft - Displays the list of recipes
    446. #==============================================================================
    447. class Window_Craft < Window_Selectable
    448.   attr_reader    :data
    449.   #--------------------------------------------------------------------------
    450.   # * Object Initialization
    451.   #--------------------------------------------------------------------------
    452.   def initialize(recipe_type = nil)
    453.     super(0, 64, 240, 416)
    454.     @recipe_type = recipe_type
    455.     @column_max = 1
    456.     @data = []
    457.     self.index = 0
    458.     get_recipes
    459.     refresh
    460.   end
    461.   #--------------------------------------------------------------------------
    462.   # * Recipe - Returns the recipe currently selected
    463.   #--------------------------------------------------------------------------
    464.   def recipe
    465.     return @data[self.index]
    466.   end
    467.   #--------------------------------------------------------------------------
    468.   # * Get Recipes - Gets the party's known recipes
    469.   #--------------------------------------------------------------------------
    470.   def get_recipes
    471.     for recipe_id in $game_party.known_recipe_ids.sort
    472.       recipe = Mobius::Recipes::RECIPES[recipe_id]
    473.       next if !recipe # If we didn't get a recipe, skip
    474.       if @recipe_type # If not nil
    475.         @data.push(recipe) if recipe.recipe_type == @recipe_type
    476.       else
    477.         @data.push(recipe)
    478.       end
    479.     end
    480.   end
    481.   #--------------------------------------------------------------------------
    482.   # * Refresh
    483.   #--------------------------------------------------------------------------
    484.   def refresh
    485.     # Dispose old contents
    486.     if self.contents != nil
    487.       self.contents.dispose
    488.       self.contents = nil
    489.     end
    490.     # Draw all recipes
    491.     @item_max = @data.size
    492.     if @item_max > 0
    493.       self.contents = Bitmap.new(width - 32, row_max * 32)
    494.       for i in 0...@item_max
    495.         draw_item(i)
    496.       end
    497.     end
    498.   end
    499.   #--------------------------------------------------------------------------
    500.   # * Draw Item - Draws a single recipe to the screen
    501.   #--------------------------------------------------------------------------
    502.   def draw_item(index)
    503.     recipe = @data[index]
    504.     self.contents.font.color = recipe.have ? normal_color : disabled_color
    505.     x = 16
    506.     y = index * 32
    507.     w = self.width - 32
    508.     h = 32
    509.     self.contents.draw_text(x, y, w, h, recipe.name, 0)
    510.   end
    511.   #--------------------------------------------------------------------------
    512.   # * Update Help - Updates the help window with the recipe's description
    513.   #--------------------------------------------------------------------------
    514.   def update_help
    515.     if self.recipe.is_a?(Game_Recipe)
    516.       case self.recipe.result_type
    517.         when 0
    518.           description = $data_items[self.recipe.result].description
    519.         when 1
    520.           description = $data_armors[self.recipe.result].description
    521.         when 2
    522.           description = $data_weapons[self.recipe.result].description
    523.         end
    524.     else
    525.       description = ""
    526.     end
    527.     @help_window.set_text(description)
    528.   end
    529. end
    530. #==============================================================================
    531. # ** Window_CraftResult - Displays the result of the chosen recipe
    532. #==============================================================================
    533. class Window_CraftResult < Window_Base
    534.   include Mobius::Crafting
    535.   #--------------------------------------------------------------------------
    536.   # * Object Initialization
    537.   #--------------------------------------------------------------------------
    538.   def initialize
    539.     super(240, 64, 400, 192)
    540.     self.contents = Bitmap.new(width - 32, height - 32)
    541.     @result = nil
    542.     @type = nil
    543.     @item = nil
    544.     @item_count = nil
    545.   end
    546.   #--------------------------------------------------------------------------
    547.   # * Set Result - Sets the recipe result to display
    548.   #--------------------------------------------------------------------------
    549.   def set_result(recipe)
    550.     @result = recipe.result
    551.     @type = recipe.result_type
    552.     case @type
    553.       when 0
    554.         @item = $data_items[@result]
    555.         @item_count = $game_party.item_number(@result)
    556.       when 1
    557.         @item = $data_armors[@result]
    558.         @item_count = $game_party.armor_number(@result)
    559.       when 2
    560.         @item = $data_weapons[@result]
    561.         @item_count = $game_party.weapon_number(@result)
    562.     end
    563.     refresh
    564.   end
    565.   #--------------------------------------------------------------------------
    566.   # * Refresh
    567.   #--------------------------------------------------------------------------
    568.   def refresh
    569.     self.contents.clear
    570.     # Draw recipe icon and quantity owned
    571.     self.draw_icon(@item.icon_name, 0, 0)
    572.     self.contents.font.color = normal_color
    573.     self.contents.draw_text(40, 0, 300, 32, QUANTITY_OWNED)
    574.     self.contents.font.color = system_color
    575.     self.contents.draw_text(294, 0, 45, 32,  @item_count.to_s)
    576.     # Analyze Item
    577.     case @type
    578.       when 0
    579.         stats = analyze_item
    580.       when 1
    581.         stats = analyze_armor
    582.       when 2
    583.         stats = analyze_weapon
    584.     end
    585.     # Draw item's stats
    586.     for i in 0...stats.size
    587.       x = i % 2 * 184
    588.       y = i / 2 * 32 + 32
    589.       stat_label = stats[i][0]
    590.       stat_amount = stats[i][1].to_s
    591.       self.contents.font.color = normal_color
    592.       self.contents.draw_text(x, y, 100, 32, stat_label)
    593.       self.contents.font.color = system_color
    594.       self.contents.draw_text(x + 110, y, 45, 32, stat_amount)
    595.     end
    596.   end
    597.   #--------------------------------------------------------------------------
    598.   # * Analyze Item - Gets the item's relevant stats
    599.   #--------------------------------------------------------------------------
    600.   def analyze_item
    601.     stats = []
    602.     # For each stat, include it for display only if it's non-zero
    603.     if @item.recover_hp > 0
    604.       stats.push([HP_RECOVERY_AMOUNT, @item.recover_hp])
    605.     end
    606.     if @item.recover_hp < 0
    607.       stats.push([HP_DAMAGE_AMOUNT, @item.recover_hp])
    608.     end
    609.     if @item.recover_hp_rate > 0
    610.       stats.push([HP_RECOVERY_PERCENT, @item.recover_hp_rate])
    611.     end
    612.     if @item.recover_hp_rate < 0
    613.       stats.push([HP_DAMAGE_PERCENT, @item.recover_hp_rate])
    614.     end
    615.     if @item.recover_sp > 0
    616.       stats.push([SP_RECOVERY_AMOUNT, @item.recover_sp])
    617.     end
    618.     if @item.recover_sp < 0
    619.       stats.push([SP_DAMAGE_AMOUNT, @item.recover_sp])
    620.     end
    621.     if @item.recover_sp_rate > 0
    622.       stats.push([SP_RECOVERY_PERCENT, @item.recover_sp_rate])
    623.     end
    624.     if @item.recover_sp_rate < 0
    625.       stats.push([SP_DAMAGE_PERCENT, @item.recover_sp_rate])
    626.     end
    627.     if @item.parameter_type > 0 and @item.parameter_points != 0
    628.       case @item.parameter_type
    629.       when 1  # Max HP
    630.         stats.push(["Max " + $data_system.words.hp, @item.parameter_points])
    631.       when 2  # Max SP
    632.         stats.push(["Max " + $data_system.words.sp, @item.parameter_points])
    633.       when 3  # Strength
    634.         stats.push([$data_system.words.str, @item.parameter_points])
    635.       when 4  # Dexterity
    636.         stats.push([$data_system.words.dex, @item.parameter_points])
    637.       when 5  # Agility
    638.         stats.push([$data_system.words.agi, @item.parameter_points])
    639.       when 6  # Intelligence
    640.         stats.push([$data_system.words.int, @item.parameter_points])
    641.       end
    642.     end
    643.     if @item.hit < 0
    644.       stats.push([HIT_RATE, @item.hit])
    645.     end
    646.     return stats
    647.   end
    648.   #--------------------------------------------------------------------------
    649.   # * Analyze Armor - Gets the armor's relevant stats
    650.   #--------------------------------------------------------------------------
    651.   def analyze_armor
    652.     stats = []
    653.     # For each stat, include it for display only if it's non-zero
    654.     if @item.pdef != 0
    655.       stats.push([$data_system.words.pdef, @item.pdef])
    656.     end
    657.     if @item.mdef != 0
    658.       stats.push([$data_system.words.mdef, @item.mdef])
    659.     end
    660.     if @item.eva != 0
    661.       stats.push([EVASION, @item.eva])
    662.     end
    663.     if @item.str_plus != 0
    664.       stats.push([$data_system.words.str, @item.str_plus])
    665.     end
    666.     if @item.dex_plus != 0
    667.       stats.push([$data_system.words.dex, @item.dex_plus])
    668.     end
    669.     if @item.agi_plus != 0
    670.       stats.push([$data_system.words.agi, @item.agi_plus])
    671.     end
    672.     if @item.int_plus != 0
    673.       stats.push([$data_system.words.int, @item.int_plus])
    674.     end
    675.     return stats
    676.   end
    677.   #--------------------------------------------------------------------------
    678.   # * Analyze Weapon - Gets the weapon's relevant stats
    679.   #--------------------------------------------------------------------------
    680.   def analyze_weapon
    681.     stats = []
    682.     # For each stat, include it for display only if it's non-zero
    683.     if @item.atk != 0
    684.       stats.push([$data_system.words.atk, @item.atk])
    685.     end
    686.     if @item.pdef != 0
    687.       stats.push([$data_system.words.pdef, @item.pdef])
    688.     end
    689.     if @item.mdef != 0
    690.       stats.push([$data_system.words.mdef, @item.mdef])
    691.     end
    692.     if @item.str_plus != 0
    693.       stats.push([$data_system.words.str, @item.str_plus])
    694.     end
    695.     if @item.dex_plus != 0
    696.       stats.push([$data_system.words.dex, @item.dex_plus])
    697.     end
    698.     if @item.agi_plus != 0
    699.       stats.push([$data_system.words.agi, @item.agi_plus])
    700.     end
    701.     if @item.int_plus != 0
    702.       stats.push([$data_system.words.int, @item.int_plus])
    703.     end
    704.     return stats
    705.   end
    706. end
    707. #==============================================================================
    708. # ** Window_CraftIngredients - Displays the ingredients of the chosen recipe
    709. #==============================================================================
    710. class Window_CraftIngredients < Window_Base
    711.   #--------------------------------------------------------------------------
    712.   # * Object Initialization
    713.   #--------------------------------------------------------------------------
    714.   def initialize
    715.     super(240, 256, 400, 224)
    716.     self.contents = Bitmap.new(width - 32, height - 32)
    717.     @ingredients = []
    718.     @counts = []
    719.     @percentages = []
    720.   end
    721.   #--------------------------------------------------------------------------
    722.   # * Set Ingredients - Sets the recipe ingredients to display
    723.   #--------------------------------------------------------------------------
    724.   def set_ingredients(recipe)
    725.     @ingredients = []
    726.     @counts = []
    727.     @percentages = recipe.quantities
    728.     for i in 0...recipe.ingredients.size
    729.       ingredient = recipe.ingredients[i]
    730.       case recipe.ingredient_types[i]
    731.       when 0
    732.         item = $data_items[ingredient]
    733.         count = $game_party.item_number(ingredient)
    734.       when 1
    735.         item = $data_armors[ingredient]
    736.         count = $game_party.armor_number(ingredient)
    737.       when 2
    738.         item = $data_weapons[ingredient]
    739.         count = $game_party.weapon_number(ingredient)
    740.       end
    741.       @ingredients.push(item)
    742.       @counts.push(count)
    743.     end
    744.     refresh
    745.   end
    746.   #--------------------------------------------------------------------------
    747.   # * Refresh
    748.   #--------------------------------------------------------------------------
    749.   def refresh
    750.     self.contents.clear
    751.     for i in 0...@ingredients.size
    752.       ingredient = @ingredients[i]
    753.       count = @counts[i]
    754.       y = i * 32
    755.       self.draw_icon(ingredient.icon_name, 0, y)
    756.       self.contents.font.color = count >= 1 ? normal_color : disabled_color
    757.       self.contents.draw_text(30, y, 280, 28, ingredient.name)
    758.       self.contents.font.color = normal_color
    759.       self.contents.draw_text(300, y, 45, 28, @percentages[i].to_s + "%")
    760.       self.contents.font.color = system_color
    761.       self.contents.draw_text(245, y, 45, 28, count.to_s )
    762.     end
    763.   end
    764. end
    765. #==============================================================================
    766. # ** Window_CraftIngredientsLabel - Displays the labels above the ingredients
    767. #==============================================================================
    768. class Window_CraftIngredientsLabel < Window_Base
    769.   include Mobius::Crafting
    770.   #--------------------------------------------------------------------------
    771.   # * Object Initialization
    772.   #--------------------------------------------------------------------------
    773.   def initialize
    774.     super(440, 224, 196, 48)
    775.     # Weird hack so that this window can have smaller borders than normal
    776.     @bitmap = Bitmap.new(width - 16, height - 16)
    777.     @sprite = RPG::Sprite.new(self.viewport)
    778.     @sprite.bitmap = @bitmap
    779.     @sprite.visible = true
    780.     @sprite.x = self.x + 16
    781.     @sprite.y = self.y + 8
    782.     @sprite.z = self.z + 1
    783.     refresh
    784.   end
    785.   #--------------------------------------------------------------------------
    786.   # * Refresh
    787.   #--------------------------------------------------------------------------
    788.   def refresh
    789.     @bitmap.clear
    790.     @bitmap.draw_text(4, 0, 82, 32, HAVE)
    791.     @bitmap.draw_text(86, 0, 82, 32, REQUIRED)
    792.   end
    793.   #--------------------------------------------------------------------------
    794.   # * Dispose
    795.   #--------------------------------------------------------------------------
    796.   def dispose
    797.     @sprite.bitmap = nil
    798.     @sprite.dispose
    799.     @bitmap.dispose
    800.     super
    801.   end
    802. end
    803. #==============================================================================
    804. # ** Window_CraftCombine - Displays the crafting minigame
    805. #==============================================================================
    806. class Window_CraftCombine < Window_Selectable
    807.   include Mobius::Crafting
    808.   TEMP_COLOR = Color.new(0, 0, 0) # Black
    809.   CLEAR_COLOR = Color.new(0, 0, 0, 0) # Clear
    810.   #---------------------------------------------------------------------------
    811.   # Object Initialization
    812.   #---------------------------------------------------------------------------
    813.   def initialize(recipe)
    814.     super(176, 78, 256 + 32, 288 + 32)
    815.     self.contents = Bitmap.new(width - 32, height - 32)
    816.     @recipe = recipe
    817.     @combined_percentages = [0, 0, 0]
    818.     self.z = 1000
    819.     @item_max = 2
    820.     @column_max = 2
    821.     @index = 0
    822.     refresh
    823.   end
    824.   #--------------------------------------------------------------------------
    825.   # * Update
    826.   #--------------------------------------------------------------------------
    827.   def update
    828.     super
    829.     # Check if percentage bar is maxed out
    830.     unless @combined_percentages.inject {|sum, n| sum += n } >= 100
    831.       # If it isn't, allow additional adding
    832.       if Input.press?(Input::X)
    833.         @combined_percentages[0] += 1
    834.       elsif Input.press?(Input::Y)
    835.         @combined_percentages[1] += 1
    836.       elsif Input.press?(Input::Z)
    837.         @combined_percentages[2] += 1
    838.       end
    839.       draw_bar
    840.     # If it is full, don't allow adding
    841.     else
    842.       if Input.trigger?(Input::X) or
    843.         Input.trigger?(Input::Y) or
    844.         Input.trigger?(Input::Z)
    845.         $game_system.se_play($data_system.buzzer_se)
    846.       end
    847.     end
    848.   end
    849.   #---------------------------------------------------------------------------
    850.   # Refresh
    851.   #---------------------------------------------------------------------------
    852.   def refresh
    853.     # Dispose old contents
    854.     self.contents.clear
    855.     # Draws the window dressing
    856.     draw_picture
    857.     # Draw the ingredient icons
    858.     draw_ingredient(0)
    859.     draw_ingredient(1)
    860.     draw_ingredient(2)
    861.     # Draw the ingredient button icons
    862.     draw_ingredient_button(0)
    863.     draw_ingredient_button(1)
    864.     draw_ingredient_button(2)
    865.     # Draw the progress bar
    866.     draw_bar
    867.     # Draw the finish / cancel buttons
    868.     draw_action_buttons
    869.   end
    870.   #--------------------------------------------------------------------------
    871.   # * Draw picture
    872.   #--------------------------------------------------------------------------
    873.   def draw_picture
    874.     picture_name = CRAFTING_PICTURES[@recipe.recipe_type]
    875.     if picture_name == ""
    876.       self.contents.fill_rect(0, 0, 256, 128, TEMP_COLOR)
    877.     else
    878.       draw_pic(picture_name, 0, 0)
    879.     end
    880.   end
    881.   #--------------------------------------------------------------------------
    882.   # * Draw Ingredient
    883.   #--------------------------------------------------------------------------
    884.   def draw_ingredient(index)
    885.     x = 22 + 80 * index
    886.     y, w, h = 132, 52, 52
    887.     self.contents.fill_rect(x, y, w, h, OUTLINE_COLOR)
    888.     self.contents.fill_rect(x + 2, y + 2, w - 4, h - 4, CLEAR_COLOR)
    889.     ingredient = get_ingredient(index)
    890.     draw_icon_centered(ingredient.icon_name, x + w/2, y + h/2)
    891.   end
    892.   #--------------------------------------------------------------------------
    893.   # * Draw Ingredient Button
    894.   #--------------------------------------------------------------------------
    895.   def draw_ingredient_button(index)
    896.     button = [X_BUTTON_ICON, Y_BUTTON_ICON, Z_BUTTON_ICON][index]
    897.     x = 22 + 80 * index
    898.     y, w, h = 184, 52, 32
    899.     if button == ""
    900.       self.contents.fill_rect(x, y, 18, 18, TEMP_COLOR)
    901.     else
    902.       draw_icon_centered(button, x + w/2, y + h/2)
    903.     end
    904.   end
    905.   #--------------------------------------------------------------------------
    906.   # * Draw Bar
    907.   #--------------------------------------------------------------------------
    908.   def draw_bar
    909.     x, y, h = 28, 218, 16
    910.     # Draw inner bar background fill first
    911.     self.contents.fill_rect(x, y, 200, 16, Color.new(255,255,255))
    912.     # Draw inner bar ingredient fills
    913.     x_percent = (@combined_percentages[0] * 2)
    914.     y_percent = (@combined_percentages[1] * 2)
    915.     z_percent = (@combined_percentages[2] * 2)
    916.     self.contents.fill_rect(x, y, x_percent, h, X_BUTTON_FILL_COLOR)
    917.     self.contents.fill_rect(x + x_percent, y, y_percent, h, Y_BUTTON_FILL_COLOR)
    918.     self.contents.fill_rect(x + x_percent + y_percent, y, z_percent, h, Z_BUTTON_FILL_COLOR)
    919.     # Draw the outer bar outline with tick marks over the top
    920.     draw_pic(BAR_PIC, x - 2, y - 2)
    921.   end
    922.   #--------------------------------------------------------------------------
    923.   # * Draw Action Button
    924.   #--------------------------------------------------------------------------
    925.   def draw_action_buttons
    926.     x1, x2 = 36, 138
    927.     y, w, h = 254, 82, 22
    928.     # Finish Button
    929.     self.contents.fill_rect(x1 - 2, y - 2, w + 4, h + 4, OUTLINE_COLOR)
    930.     self.contents.fill_rect(x1, y, w, h, CLEAR_COLOR)
    931.     self.contents.draw_text(x1, y, w, h, FINISH, 1)
    932.     # Cancel Button
    933.     self.contents.fill_rect(x2 - 2, y - 2, w + 4, h + 4, OUTLINE_COLOR)
    934.     self.contents.fill_rect(x2, y, w, h, CLEAR_COLOR)
    935.     self.contents.draw_text(x2, y, w, h, CANCEL, 1)
    936.   end
    937.   #--------------------------------------------------------------------------
    938.   # * Update Cursor Rectangle
    939.   #--------------------------------------------------------------------------
    940.   def update_cursor_rect
    941.     x1, x2 = 36, 138
    942.     y, w, h = 254, 82, 22
    943.     # If cursor position is less than 0
    944.     if @index < 0
    945.       self.cursor_rect.empty
    946.       return
    947.     end
    948.     if @index == 0
    949.       self.cursor_rect.set(x1, y, w, h)
    950.     elsif @index == 1
    951.       self.cursor_rect.set(x2, y, w, h)
    952.     end
    953.   end
    954.   #--------------------------------------------------------------------------
    955.   # * Judge Craft - Determines if crafting was successful
    956.   #--------------------------------------------------------------------------
    957.   def judge_craft
    958.     craft = true
    959.     correct_percentages = @recipe.quantities
    960.     for i in 0...correct_percentages.size
    961.       min = @combined_percentages[i] - ERROR_TOLERANCE
    962.       max = @combined_percentages[i] + ERROR_TOLERANCE
    963.       range = min..max
    964.       unless range.include?(correct_percentages[i])
    965.         craft = false
    966.         break
    967.       end
    968.     end
    969.     # If successful
    970.     if craft
    971.       # Play succes SE
    972.       success_name = CRAFT_SUCCESS_SE[@recipe.recipe_type]
    973.       Audio.se_play("Audio/SE/" + success_name)
    974.       # Make result
    975.       @recipe.make
    976.     else
    977.       # Play failure SE
    978.       failure_name = CRAFT_FAILURE_SE[@recipe.recipe_type]
    979.       Audio.se_play("Audio/SE/" + failure_name)
    980.       # Make waste
    981.       @recipe.make_waste
    982.     end
    983.   end
    984.   #--------------------------------------------------------------------------
    985.   # * Get ingredient - returns item/weapon/armor
    986.   #     id : 0, 1, or 2
    987.   #--------------------------------------------------------------------------
    988.   def get_ingredient(id)
    989.     item_id = @recipe.ingredients[id]
    990.     item_type = @recipe.ingredient_types[id]
    991.     case item_type
    992.     when 0 # item
    993.       item = $data_items[item_id]
    994.     when 1 # weapon
    995.       item = $data_weapons[item_id]
    996.     when 2 # armor
    997.       item = $data_armors[item_id]
    998.     end
    999.     return item
    1000.   end
    1001. end
    1002. #==============================================================================
    1003. # ** Scene_Craft
    1004. #==============================================================================
    1005. class Scene_Craft
    1006.   #--------------------------------------------------------------------------
    1007.   # * Object Initialization
    1008.   #--------------------------------------------------------------------------
    1009.   def initialize(recipe_type = nil, return_scene = nil)
    1010.     @craft_index = -1
    1011.     @return_scene = return_scene
    1012.     @recipe_type = recipe_type
    1013.   end
    1014.   #--------------------------------------------------------------------------
    1015.   # * Create Windows
    1016.   #--------------------------------------------------------------------------
    1017.   def create_windows
    1018.     @craft_window = Window_Craft.new(@recipe_type)
    1019.     @help_window = Window_Help.new
    1020.     @craft_window.help_window = @help_window
    1021.     @result_window = Window_CraftResult.new
    1022.     @ingredients_window = Window_CraftIngredients.new
    1023.     @label_window = Window_CraftIngredientsLabel.new
    1024.     # If there's at least one known recipe
    1025.     if @craft_window.data.size > 0
    1026.       @craft_index = 0
    1027.       @craft_window.index = 0
    1028.       @result_window.set_result(@craft_window.recipe)
    1029.       @ingredients_window.set_ingredients(@craft_window.recipe)
    1030.     end
    1031.   end
    1032.   #--------------------------------------------------------------------------
    1033.   # * Dispose Windows
    1034.   #--------------------------------------------------------------------------
    1035.   def dispose_windows
    1036.     @craft_window.dispose
    1037.     @help_window.dispose
    1038.     @result_window.dispose
    1039.     @ingredients_window.dispose
    1040.     @label_window.dispose
    1041.   end
    1042.   #--------------------------------------------------------------------------
    1043.   # * Main
    1044.   #--------------------------------------------------------------------------
    1045.   def main
    1046.     create_windows
    1047.     Graphics.transition
    1048.     loop do
    1049.       Graphics.update
    1050.       Input.update
    1051.       update
    1052.       if $scene != self
    1053.         break
    1054.       end
    1055.     end
    1056.     Graphics.freeze
    1057.     dispose_windows
    1058.   end
    1059.   #--------------------------------------------------------------------------
    1060.   # * Update
    1061.   #--------------------------------------------------------------------------
    1062.   def update
    1063.     @craft_window.update
    1064.     # If there's a selectable recipe and we've changed selection
    1065.     if @craft_index >= 0 and @craft_index != @craft_window.index
    1066.       @craft_index = @craft_window.index
    1067.       set_recipe_in_windows
    1068.     end
    1069.     # If we're selecting a recipe
    1070.     if @craft_window.active
    1071.       update_craft
    1072.       return
    1073.     end
    1074.     # If we're in the crafting mini-game
    1075.     if @craft_combine_window
    1076.       update_craft_combine
    1077.       return
    1078.     end
    1079.   end
    1080.   #--------------------------------------------------------------------------
    1081.   # * Set Recipe in Windows
    1082.   #--------------------------------------------------------------------------
    1083.   def set_recipe_in_windows
    1084.     @result_window.set_result(@craft_window.recipe)
    1085.     @ingredients_window.set_ingredients(@craft_window.recipe)
    1086.   end
    1087.   #--------------------------------------------------------------------------
    1088.   # * Update Craft - Updates the selection of a recipe
    1089.   #--------------------------------------------------------------------------
    1090.   def update_craft
    1091.     if Input.trigger?(Input::B)
    1092.       $game_system.se_play($data_system.cancel_se)
    1093.       if @return_scene == "menu"
    1094.         $scene = Scene_Menu.new(Mobius::Crafting::MENU_INDEX)
    1095.       else
    1096.         $scene = Scene_Map.new
    1097.       end
    1098.       return
    1099.     end
    1100.     if Input.trigger?(Input::C) and @craft_window.data.size > 0
    1101.       @recipe = @craft_window.recipe
    1102.       if @recipe.have
    1103.         $game_system.se_play($data_system.decision_se)
    1104.         @craft_window.active = false
    1105.         @craft_combine_window = Window_CraftCombine.new(@recipe)
    1106.       else
    1107.         $game_system.se_play($data_system.buzzer_se)
    1108.         return
    1109.       end
    1110.     end
    1111.   end
    1112.   #---------------------------------------------------------------------------
    1113.   # * Update Craft Combine - Updates the crafting minigame
    1114.   #---------------------------------------------------------------------------
    1115.   def update_craft_combine
    1116.     @craft_combine_window.update
    1117.     # If cancel button is pressed
    1118.     if Input.trigger?(Input::B)
    1119.       # Play cancel SE
    1120.       $game_system.se_play($data_system.cancel_se)
    1121.       @craft_window.active = true
    1122.       @craft_combine_window.dispose
    1123.     end
    1124.     # If confirm button is pressed
    1125.     if Input.trigger?(Input::C)
    1126.       # If finish is chosen
    1127.       if @craft_combine_window.index == 0
    1128.         @craft_combine_window.judge_craft
    1129.         @craft_window.active = true
    1130.         @craft_combine_window.dispose
    1131.         # Refresh item counts
    1132.         @craft_window.refresh
    1133.         set_recipe_in_windows
    1134.       # If cancel is chosen
    1135.       elsif @craft_combine_window.index == 1
    1136.         $game_system.se_play($data_system.cancel_se)
    1137.         @craft_window.active = true
    1138.         @craft_combine_window.dispose
    1139.       end
    1140.     end
    1141.   end
    1142. end
    复制代码

    Spoiler: Database Section
                    Ruby:       
    1. # This is the database section for storing your recipes
    2. # Follow the instructions below for how to create recipes
    3. module Mobius
    4.   module Recipes
    5.     #===== Don't touch this block =====
    6.     RECIPES = [nil]
    7.     def Recipes.add_receipe_to_database(
    8.       ingredients,
    9.       ingredient_types,
    10.       quantities,
    11.       result,
    12.       result_type,
    13.       recipe_type
    14.     )
    15.       RECIPES.push(
    16.         Game_Recipe.new(
    17.           ingredients,
    18.           ingredient_types,
    19.           quantities,
    20.           result,
    21.           result_type,
    22.           recipe_type
    23.         )
    24.       )
    25.     end
    26.     #===== You can edit below this line =====
    27.     # This is how you create a new recipe
    28.     # Specify the ingredient IDs (Item/Armor/Weapon) from the database
    29.     ingredients = [30, 31, 32]
    30.     # Specify what types the ingredients are (0 = Item, 1 = Armor, 2 = Weapon)
    31.     ingredient_types = [0, 0, 0]
    32.     # Specify how much of each ingredient
    33.     # 20% of ingredient #1, 30% of ingredient #2, 50% of ingredient #3
    34.     quantities = [20, 30, 50]
    35.     # Specify what the recipe makes (Item/Armor/Weapon) from the database
    36.     result = 1
    37.     # Specify what type the result is (0 = Item, 1 = Armor, 2 = Weapon)
    38.     result_type = 0
    39.     # Specify the recipe type.
    40.     # The tag must be in quotes, and capitalization does matter.
    41.     recipe_type = "Brewing"
    42.     # Add the recipe to the database by doing this
    43.     # (the first recipe added will be recipe with ID = 1)
    44.     # This will be a potion in the default project
    45.     Recipes.add_receipe_to_database(
    46.       ingredients,
    47.       ingredient_types,
    48.       quantities,
    49.       result,
    50.       result_type,
    51.       recipe_type
    52.     )
    53.     # This will be a full potion in the default project
    54.     # Because this is the second recipe added it will have ID = 2
    55.     ingredients = [1, 2, 32]
    56.     ingredient_types = [0, 0, 0]
    57.     quantities = [20, 30, 50]
    58.     result = 3
    59.     result_type = 0
    60.     recipe_type = "Brewing"
    61.     Recipes.add_receipe_to_database(
    62.       ingredients,
    63.       ingredient_types,
    64.       quantities,
    65.       result,
    66.       result_type,
    67.       recipe_type
    68.     )
    69.     # This will be a perfume in the default project
    70.     ingredients = [30, 31, 32]
    71.     ingredient_types = [0, 0, 0]
    72.     quantities = [20, 30, 50]
    73.     result = 4
    74.     result_type = 0
    75.     recipe_type = "Brewing"
    76.     Recipes.add_receipe_to_database(
    77.       ingredients,
    78.       ingredient_types,
    79.       quantities,
    80.       result,
    81.       result_type,
    82.       recipe_type
    83.     )
    84.     # This will be a full perfume in the default project
    85.     ingredients = [4, 5, 32]
    86.     ingredient_types = [0, 0, 0]
    87.     quantities = [45, 45, 10]
    88.     result = 6
    89.     result_type = 0
    90.     recipe_type = "Brewing"
    91.     Recipes.add_receipe_to_database(
    92.       ingredients,
    93.       ingredient_types,
    94.       quantities,
    95.       result,
    96.       result_type,
    97.       recipe_type
    98.     )
    99.     # This will be an elixir in the default project
    100.     ingredients = [3, 6, 32]
    101.     ingredient_types = [0, 0, 0]
    102.     quantities = [40, 40, 20]
    103.     result = 7
    104.     result_type = 0
    105.     recipe_type = "Brewing"
    106.     Recipes.add_receipe_to_database(
    107.       ingredients,
    108.       ingredient_types,
    109.       quantities,
    110.       result,
    111.       result_type,
    112.       recipe_type
    113.     )
    114.     # This will be a full elixir in the default project
    115.     ingredients = [3, 6, 7]
    116.     ingredient_types = [0, 0, 0]
    117.     quantities = [40, 40, 20]
    118.     result = 8
    119.     result_type = 0
    120.     recipe_type = "Brewing"
    121.     Recipes.add_receipe_to_database(
    122.       ingredients,
    123.       ingredient_types,
    124.       quantities,
    125.       result,
    126.       result_type,
    127.       recipe_type
    128.     )
    129.     # This will be a seed of life in the default project
    130.     ingredients = [30, 31, 32]
    131.     ingredient_types = [0, 0, 0]
    132.     quantities = [40, 40, 20]
    133.     result = 17
    134.     result_type = 0
    135.     recipe_type = "Brewing"
    136.     Recipes.add_receipe_to_database(
    137.       ingredients,
    138.       ingredient_types,
    139.       quantities,
    140.       result,
    141.       result_type,
    142.       recipe_type
    143.     )
    144.     # This will be a seed of strength in the default project
    145.     ingredients = [30, 31, 32]
    146.     ingredient_types = [0, 0, 0]
    147.     quantities = [40, 40, 20]
    148.     result = 19
    149.     result_type = 0
    150.     recipe_type = "Brewing"
    151.     Recipes.add_receipe_to_database(
    152.       ingredients,
    153.       ingredient_types,
    154.       quantities,
    155.       result,
    156.       result_type,
    157.       recipe_type
    158.     )
    159.     # This will be a bronze sword in the default project
    160.     ingredients = [30, 31, 32]
    161.     ingredient_types = [0, 0, 0]
    162.     quantities = [30, 30, 40]
    163.     result = 1
    164.     result_type = 2
    165.     recipe_type = "Smithing"
    166.     Recipes.add_receipe_to_database(
    167.       ingredients,
    168.       ingredient_types,
    169.       quantities,
    170.       result,
    171.       result_type,
    172.       recipe_type
    173.     )
    174.     # This will be a mythril sword in the default project
    175.     ingredients = [30, 31, 32]
    176.     ingredient_types = [0, 0, 0]
    177.     quantities = [30, 30, 40]
    178.     result = 4
    179.     result_type = 2
    180.     recipe_type = "Smithing"
    181.     Recipes.add_receipe_to_database(
    182.       ingredients,
    183.       ingredient_types,
    184.       quantities,
    185.       result,
    186.       result_type,
    187.       recipe_type
    188.     )
    189.     # This will be a bronze shield in the default project
    190.     ingredients = [30, 31, 32]
    191.     ingredient_types = [0, 0, 0]
    192.     quantities = [30, 30, 40]
    193.     result = 1
    194.     result_type = 1
    195.     recipe_type = "Smithing"
    196.     Recipes.add_receipe_to_database(
    197.       ingredients,
    198.       ingredient_types,
    199.       quantities,
    200.       result,
    201.       result_type,
    202.       recipe_type
    203.     )
    204.     # This will be a mythril shield in the default project
    205.     ingredients = [30, 31, 32]
    206.     ingredient_types = [0, 0, 0]
    207.     quantities = [30, 30, 40]
    208.     result = 4
    209.     result_type = 1
    210.     recipe_type = "Smithing"
    211.     Recipes.add_receipe_to_database(
    212.       ingredients,
    213.       ingredient_types,
    214.       quantities,
    215.       result,
    216.       result_type,
    217.       recipe_type
    218.     )
    219.   end
    220. end
    复制代码



    FAQ
    Q. Can I disable the minigame?
    A. Not with this version. I'd like to make an easy way to do that. You can always grab Deke's original version though if that's what you want.

    Q. I used the old version you made; will this work with that?
    A. No, I made enough changes "under the hood" that if you had been using the 1.0 version you can't simply drop this in to replace it.

    Credit and Thanks
    - Deke, author of underlying crafting script
    - Mobius XVI, author of minigame portion
    - sutorumie, for the idea/request

    Author's Notes
    This script is available in its entirety for commercial and non-commercial use. View the full license terms in the script header.


    本贴来自国际rpgmaker官方论坛作者:MobiusXVI处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/mobiuss-crafting-minigame.167296/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-7-26 02:47 , Processed in 0.125119 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表