#===============================================================# CRAFTING PROGRAM#----------------------------------------------------------------#-written by Deke#-yes_no window code created by Phsylomortis# Modified by MobiusXVI to add crafting minigame#===============================================================# New Usage Notes:# All recipes now assume that there will be three ingredients# and that the recipe takes one of each ingredient to make.# The "quantities" should therefore now be treated as # percentages in whole numbers, i.e. 45 = 45%, of the total# mix. These should always add up to 100. If the player # successfully combines the items in the right portions # (+/-10%) then they will craft the intended item.# If not, they'll receive a junk item of your choosing. ## Every recipe made can be tagged with a recipe type, such as# "Cooking", "Baking", "Smelting", etc. There are no limits# to how many different recipe types you have overall, but# each recipe can have only one type. When you call the# crafting screen, you can specify a recipe type and only# recipe of that type will be display. Example, you have a# forge so you want the player to be able to make "smelting"# recipes, but not "cooking" recipes. If you call the screen# without specifying a type, all recipes will be available# for crafting.## The minigame itself uses the X, Y, and Z "buttons" to add# the ingredients. Check F1 to see what keyboard keys these# are mapped to on your computer. By default, they're mapped# to A, S, and D.## Example Script Calls -- Information on Calls# # Create New Recipe with recipe type# ingredients = [1, 2, 3] -- Item IDs (Item/Armor/Weapon)# ingredient_types = [0, 1, 2] -- (0 = Item, 1 = Armor, 2 = Weapon)# quantities = [20, 30, 50] -- 20% of item #1, 30% of armor #2, 50% of weapon #3# result = 10 -- Item ID (Item/Armor/Weapon)# result_type = 1 -- (0 = Item, 1 = Armor, 2 = Weapon)# recipe_type = "Cooking" -- Tag must be in quotes, and capitalization does matter. # recipe1 = Game_Recipe.new(ingredients, ingredient_types, quantities, result, result_type, recipe_type)# $game_party.learn_recipe(recipe1)# Create New Recipe without recipe type# ingredients = [4, 5, 6] -- Item IDs (Item/Armor/Weapon)# ingredient_types = [0, 0, 2] -- (0 = Item, 1 = Armor, 2 = Weapon)# quantities = [10, 70, 20] -- 10% of item #4, 70% of item #5, 20% of weapon #6# result = 35 -- Item ID (Item/Armor/Weapon)# result_type = 2 -- (0 = Item, 1 = Armor, 2 = Weapon)# recipe2 = Game_Recipe.new(ingredients, ingredient_types, quantities, result, result_type)# $game_party.learn_recipe(recipe2)## Call Crafting Screen with recipe type# $scene = Scene_Craft.new("Cooking") ## Call Crafting Screen without recipe type# $scene = Scene_Craft.new#===============================================================#**********************CONFIGURATION*****************************class Game_Recipe # Set the following value to false if you don't want the game # to check whether your recipes are properly formatted # Note that data checking only works in playtest mode # and so will not function in any final release DATA_CHECK = trueendclass Window_CraftCombine < Window_Selectable # Set the item ID for the waste item. This must be an item, and # it must exist. WASTE_ITEM_ID = 1 # Set the sound effect for successfully crafting an item. # This is a filename without extension, and must be within # the sound effects (SE) folder CRAFT_SUCCESS_SE = "056-Right02" # Set the sound effect for failing to craft an item. # This is a filename without extension, and must be within # the sound effects (SE) folder CRAFT_FAILURE_SE = "058-Wrong02" # Set the icons to use for the X, Y, and Z buttons. # Icon should be about 24x24, but script will auto-adjust # if slightly larger/smaller. Don't expect miracles though. # This is a filename without extension, and must be within # the icon folder. X_BUTTON_ICON = "" Y_BUTTON_ICON = "" Z_BUTTON_ICON = "" # Set the picture to use for the top left corner of the # crafting screen. Picture should be about 91x106 pixels # This is a filename without extension, and must be within # the pictures folder. TOP_LEFT_PIC = "" # Set the picture to use for the top left corner of the # crafting screen. Picture should be about 158x106 pixels # This is a filename without extension, and must be within # the pictures folder. TOP_RIGHT_PIC = "" # Set the color to use for the outlines drawn around the # ingredients, the mixing bar, and the finish/cancel buttons. # Black by default. Colors are RGB. OUTLINE_COLOR = Color.new(0, 0, 0) # Black # Set the colors to use for filling the mixing bar. # The colors show how much of each ingredient has # been added, and can be set independently. X_BUTTON_FILL_COLOR = Color.new(255, 0, 0) # Red Y_BUTTON_FILL_COLOR = Color.new(0, 255, 0) # Green Z_BUTTON_FILL_COLOR = Color.new(0, 0, 255) # Blue end #*******************END OF CONFIGURATION*************************#===============================================================#updates to Game_Party classclass Game_Party attr_accessor :recipes alias crafting_party_initialize initialize def initialize crafting_party_initialize @recipes=[] end #---------------------------------------------------------------------- def know?(recipe, version = 1) unless recipe.is_a?(Game_Recipe) recipe = get_recipe_from_master_list(recipe, version) end return $game_party.recipes.include?(recipe) end #---------------------------------------------------------------------- def learn_recipe(recipe , version = 1) unless recipe.is_a?(Game_Recipe) recipe = get_recipe_from_master_list(recipe, version) end if recipe.is_a?(Game_Recipe) unless know?(recipe) @recipes.push(recipe) end end end #---------------------------------------------------------------------- def forget_recipe(recipe , version = 1) if !recipe.is_a?(Game_Recipe) recipe = get_recipe_from_master_list(recipe, version) end if recipe.is_a?(Game_Recipe) for i in 0...@recipes.size if recipe == @recipes[i] index = i break end end if index != nil @recipes.delete(@recipes[index]) end end end #---------------------------------------------------------------------- def get_recipe_from_master_list(item, version) index = nil for i in 0...$game_temp.recipe_list.size if item[0] == $game_temp.recipe_list[i].result and item[1] ==$game_temp.recipe_list[i].result_type version -= 1 if version == 0 index = i break end end end if index.is_a?(Integer) return ($game_temp.recipe_list[index]) else return false end end end # of Game_Party updates#================================class Game_Recipe attr_reader :ingredients attr_reader :quantities attr_reader :result attr_reader :result_type attr_reader :ingredient_types attr_reader :recipe_type # MOBIUS ADDED attr_accessor :result attr_accessor :result_type #---------------------------------------------------------------------- def initialize( ingredients, ingredient_types, quantities, result, result_type, recipe_type = nil) @ingredients = ingredients @ingredient_types = ingredient_types @quantities = quantities @result = result @result_type = result_type @recipe_type = recipe_type data_check if $DEBUG and DATA_CHECK# MOBIUS ADDED end #--------------------------------------------------------------------- # * Data_Check - Confirms all data is as expected and prompts user # if mistakes are found # MOBIUS ADDED #--------------------------------------------------------------------- def data_check unless @ingredients.size == 3 text = "WARNING:\n The recipe for \'#{name}\' does not have 3 ingredients." text << "\nScript may not function as intended." print(text) end unless @ingredient_types.size == 3 text = "WARNING:\n The recipe for \'#{name}\' does not have 3 ingredient" text << " types.\nScript may not function as intended." print(text) end unless @quantities.size == 3 text = "WARNING:\n The recipe for \'#{name}\' does not have 3 entries for" text << " quantities.\nScript may not function as intended." print(text) end unless @quantities.inject {|sum, n| sum + n } == 100 text = "WARNING:\n The recipe for \'#{name}\' has quantities which do not" text << " equal 100%.\nScript may not function as intended." print(text) end unless @result.is_a?(Integer) text = "WARNING:\n The recipe for \'#{name}\' has a result which is not" text << " a integer.\nScript may not function as intended." print(text) end unless [0, 1, 2].include?(@result_type) text = "WARNING:\n The recipe for \'#{name}\' has a result_type which is" text << " not 0, 1, or 2.\nScript may not function as intended." print(text) end unless @recipe_type.is_a?(String) text = "WARNING:\n The recipe for \'#{name}\' has a recipe_type which is" text << " not a String.\nScript may not function as intended." print(text) end end #---------------------------------------------------------------------- def name case @result_type when 0 name = $data_items[@result].name when 1 name = $data_armors[@result].name when 2 name = $data_weapons[@result].name end return name end#---------------------------------------------------------------------- def have have_all = true for i in 0...@ingredients.size case @ingredient_types[i] when 0 if $game_party.item_number(@ingredients[i]) < 1 #@quantities[i] OLD have_all=false end when 1 if $game_party.armor_number(@ingredients[i]) < 1 #@quantities[i] OLD have_all=false end when 2 if $game_party.weapon_number(@ingredients[i]) < 1 #@quantities[i] OLD have_all=false end end end return have_all end#---------------------------------------------------------------------- def decrement for i in 0...@ingredients.size case @ingredient_types[i] when 0 #$game_party.lose_item(@ingredients[i], @quantities[i]) -- OLD $game_party.lose_item(@ingredients[i], 1) when 1 #$game_party.lose_armor(@ingredients[i], @quantities[i]) -- OLD $game_party.lose_armor(@ingredients[i], 1) when 2 #$game_party.lose_weapon(@ingredients[i], @quantities[i]) -- OLD $game_party.lose_weapon(@ingredients[i], 1) end end end#---------------------------------------------------------------------- def make if have case @result_type when 0 $game_party.gain_item(@result, 1) when 1 $game_party.gain_armor(@result, 1) when 2 $game_party.gain_weapon(@result, 1) end decrement end end #---------------------------------------------------------------------- def == (recipe) if recipe.is_a?(Game_Recipe) equal = true if recipe.ingredients != self.ingredients equal = false end if recipe.ingredient_types != self.ingredient_types equal = false end if recipe.quantities != self.quantities equal = false end if recipe.result != self.result equal=false end if recipe.result_type != self.result_type equal = false end if recipe.recipe_type != self.recipe_type equal = false end else equal = false end return equal end end # of Game_Recipe class#===================================class Window_Craft < Window_Selectable #-------------------------------------------------------------------------- def initialize(recipe_type = nil) @recipe_type = recipe_type super(0, 64, 240, 416) @column_max = 1 refresh self.index = 0 end #-------------------------------------------------------------------------- def recipe return @data[self.index] end #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for recipe in $game_party.recipes if @recipe_type # If not nil @data.push(recipe) if recipe.recipe_type == @recipe_type else @data.push(recipe) end end @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) self.contents.font.name = $fontface.is_a?(String) ? $fontface : $defaultfonttype self.contents.font.size = $fontsize.is_a?(Integer) ? $fontsize : $defaultfontsize for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- def draw_item(index) recipe = @data[index] self.contents.font.color = recipe.have ? normal_color : disabled_color x = 16 y = index * 32 self.contents.draw_text(x , y, self.width-32, 32, recipe.name, 0) end #-------------------------------------------------------------------------- def update_help current_recipe = recipe if current_recipe.is_a?(Game_Recipe) case current_recipe.result_type when 0 description = $data_items[current_recipe.result].description when 1 description = $data_armors[current_recipe.result].description when 2 description = $data_weapons[current_recipe.result].description end else description = "" end @help_window.set_text(description) @help_window.update end end # of Window_Craft#=======================================class Window_CraftResult < Window_Base #-------------------------------------------------------------------------- def initialize super(240, 64, 400, 184) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = $fontface.is_a?(String) ? $fontface : $defaultfonttype self.contents.font.size = 20 @result = nil @type = nil end #-------------------------------------------------------------------------- def refresh self.contents.clear case @type when 0 item = $data_items[@result] if item.recover_hp_rate > item.recover_hp hp_string = "HP Recovery% :" hp_stat = item.recover_hp_rate else hp_string = "HP Recovery Points:" hp_stat = item.recover_hp end if item.recover_sp_rate > item.recover_sp sp_string = "SP Recovery% :" sp_stat = item.recover_sp_rate else sp_string = "SP Recovery Points:" sp_stat = item.recover_sp end @strings = [hp_string, sp_string, "Phy. Def:" , "Mag Def:", "Accuracy:", "Variance:"] @stats = [hp_stat, sp_stat, item. pdef_f, item.mdef_f, item.hit, item.variance, $game_party.item_number(@result)] @bitmap = RPG::Cache.icon(item.icon_name) when 1 item = $data_armors[@result] @strings = ["Phy. Def:", "Mag. Def:", "Evasion plus:", "Strength plus:", "Dex. plus:", "Agility plus:", "Int. plus:"] @stats = [item.pdef, item.mdef, item.eva, item.str_plus, item.dex_plus, item.agi_plus, item.int_plus, $game_party.armor_number(@result) ] @bitmap = RPG::Cache.icon(item.icon_name) when 2 item = $data_weapons[@result] @strings =["Attack Power:", "Phy. Def:", "Mag. Def:", "Strength plus:", "Dex. plus:", "Agility plus:", "Int. plus:"] @stats = [item.atk, item.pdef, item.mdef, item.str_plus, item.dex_plus, item.agi_plus, item.int_plus, $game_party.weapon_number(@result) ] @bitmap = RPG::Cache.icon(item.icon_name) end for i in 0...@strings.size x = i%2 * 184 y = i /2 *28 +32 self.contents.font.color = normal_color self.contents.draw_text(x,y,100, 28,@strings[i]) self.contents.font.color = system_color self.contents.draw_text(x + 110, y, 45, 28, @stats[i].to_s) end self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, 24, 24), 255) self.contents.font.color= normal_color self.contents.draw_text(40, 0, 300, 28, "Quantity currently owned:") self.contents.font.color = system_color count = @stats[@stats.size - 1].to_s self.contents.draw_text(294, 0, 45, 28, count ) end #---------------------------------------------------------------------- def set_result(result , type) @result = result @type = type refresh endend #of Window_CraftResult#=======================================class Window_CraftIngredients < Window_Base #-------------------------------------------------------------------------- def initialize super(240, 248, 400, 232) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = $fontface.is_a?(String) ? $fontface : $defaultfonttype self.contents.font.size = 20 @ingredients = [] @types = [] @quantities = [] @item = nil @count = 0 end #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...@ingredients.size case @types[i] when 0 @item = $data_items[@ingredients[i]] @count = $game_party.item_number(@ingredients[i]) when 1 @item = $data_armors[@ingredients[i]] @count = $game_party.armor_number(@ingredients[i]) when 2 @item = $data_weapons[@ingredients[i]] @count = $game_party.weapon_number(@ingredients[i]) end y = i *26 self.contents.blt(0, y, RPG::Cache.icon(@item.icon_name), Rect.new(0, 0, 24, 24), 255) #self.contents.font.color = @count >= @quantities[i] ? normal_color : disabled_color self.contents.font.color = normal_color self.contents.draw_text(30, y, 280, 28, @item.name) self.contents.draw_text(300, y, 45, 28, @quantities[i].to_s + "%") self.contents.font.color = system_color self.contents.draw_text(245, y, 45, 28, @count.to_s ) end end #-------------------------------------------------------------------------- def set_ingredients(ingredients , types, quantities) @ingredients = ingredients @types = types @quantities = quantities refresh endend # of Window_CraftIngredients#======================================class Scene_Craft #-------------------------------------------------------------------------- def initialize(recipe_type = nil, craft_index=0, return_scene = "menu") @craft_index=craft_index @return_scene = return_scene @recipe_type = recipe_type end #-------------------------------------------------------------------------- def main @craft_window = Window_Craft.new(@recipe_type) @craft_window.index=@craft_index @help_window = Window_Help.new @craft_window.help_window = @help_window @result_window=Window_CraftResult.new @ingredients_window=Window_CraftIngredients.new =begin OLD CODE @confirm_window = Window_Base.new(120, 188, 400, 64) @confirm_window.contents = Bitmap.new(368, 32) @confirm_window.contents.font.name = $fontface.is_a?(String) ? $fontface : $defaultfonttype @confirm_window.contents.font.size = $fontsize.is_a?(Integer) ? $fontsize : $defaultfontsize @yes_no_window = Window_Command.new(100, ["Yes", "No"]) @confirm_window.visible = false @confirm_window.z = 1500 @yes_no_window.visible = false @yes_no_window.active = false @yes_no_window.index = 1 @yes_no_window.x = 270 @yes_no_window.y = 252 @yes_no_window.z = 1500=end @label_window = Window_Base.new(450,200,190,52) @label_window.contents=Bitmap.new(@label_window.width - 32,@label_window.height - 32) @label_window.contents.font.size=20 @label_window.contents.font.color = @label_window.normal_color @label_window.contents.font.name = $fontface.is_a?(String) ? $fontface : $defaultfonttype @label_window.contents.draw_text(0, 0, @label_window.contents.width, 20, " Have Req%") Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @help_window.dispose @craft_window.dispose @result_window.dispose @ingredients_window.dispose #@confirm_window.dispose -- OLD CODE #@yes_no_window.dispose -- OLD CODE @label_window.dispose end #-------------------------------------------------------------------------- def update @craft_window.update @ingredients_window.update if $game_party.recipes.size > 0 @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type) @ingredients_window.set_ingredients(@craft_window.recipe.ingredients, @craft_window.recipe.ingredient_types, @craft_window.recipe.quantities) end if @craft_window.active update_craft return end if @craft_combine_window update_craft_combine return end =begin # OLD CODE if @yes_no_window.active confirm_update return end=end end #-------------------------------------------------------------------------- def update_craft if Input.trigger?(Input:: $game_system.se_play($data_system.cancel_se) if @return_scene == "menu" $scene = Scene_Menu.new(0) else $scene = Scene_Map.new end return end if Input.trigger?(Input::C) and $game_party.recipes.size != 0 @recipe = @craft_window.recipe if @recipe.have @craft_window.active = false @craft_combine_window = Window_CraftCombine.new(@recipe) #@yes_no_window.active = true OLD CODE else $game_system.se_play($data_system.buzzer_se) return end end end #---------------------------------------------------------------------------# Update Craft Combine - updates the crafting minigame# Added by Mobius_XVI#--------------------------------------------------------------------------- def update_craft_combine @craft_combine_window.update # If cancel button is pressed if Input.trigger?(Input:: # Play cancel SE $game_system.se_play($data_system.cancel_se) @craft_window.active = true @craft_combine_window.dispose end # If confirm button is pressed if Input.trigger?(Input::C) # If finish is chosen if @craft_combine_window.index == 0 @craft_combine_window.judge_craft @craft_window.active = true @craft_combine_window.dispose # If cancel is chosen elsif @craft_combine_window.index == 1 $game_system.se_play($data_system.cancel_se) @craft_window.active = true @craft_combine_window.dispose end end end #--------------------------------------------------------------------------=begin NO LONGER CALLED def confirm_update @craft_index = @craft_window.index @confirm_window.visible = true @confirm_window.z = 1500 @yes_no_window.visible = true @yes_no_window.active = true @yes_no_window.z = 1500 @yes_no_window.update string = "Create " + @recipe.name + "?" cw = @confirm_window.contents.text_size(string).width center = @confirm_window.contents.width/2 - cw /2 unless @drawn @confirm_window.contents.draw_text(center, 0, cw, 30, string) @drawn = true end if Input.trigger?(Input::C) if @yes_no_window.index == 0 $game_system.se_play($data_system.decision_se) @recipe.make #$game_system.se_play($data_system.save_se) -- OLD #$scene=Scene_Craft.new(@craft_index) -- OLD else $game_system.se_play($data_system.cancel_se) @confirm_window.visible = false @yes_no_window.visible = false @yes_no_window.active = false @craft_window.active = true #$scene=Scene_Craft.new(@craft_index) -- OLD end end if Input.trigger?(Input:: $game_system.se_play($data_system.cancel_se) @confirm_window.visible = false @yes_no_window.visible = false @yes_no_window.active = false @craft_window.active = true #$scene=Scene_Craft.new(@craft_index) -- OLD end end=endend # of Scene_Craft#==============================================================================# ** Window_CraftCombine#------------------------------------------------------------------------------# This window displays the crafting minigame# Added by Mobius_XVI#==============================================================================class Window_CraftCombine < Window_Selectable TEMP_COLOR = Color.new(0, 0, 0) # Black CLEAR_COLOR = Color.new(0, 0, 0, 0) # Clear #--------------------------------------------------------------------------- # Object Initialization #--------------------------------------------------------------------------- def initialize(recipe) super(154, 74, 332, 332) @recipe = recipe @combined_percentages = [0, 0, 0] self.z = 1000 @item_max = 2 @column_max = 2 @index = 0 refresh end #--------------------------------------------------------------------------- # Refresh #--------------------------------------------------------------------------- def refresh # Dispose old contents if self.contents != nil self.contents.dispose end # Create contents self.contents = Bitmap.new(width - 32, height - 32) # TOP LEFT if TOP_LEFT_PIC == "" self.contents.fill_rect(19, 31, 91, 106, TEMP_COLOR) else draw_pic(TOP_LEFT_PIC, 19, 31) end # TOP RIGHT if TOP_RIGHT_PIC == "" self.contents.fill_rect(119, 31, 158, 106, TEMP_COLOR) else draw_pic(TOP_RIGHT_PIC, 119, 31) end # X BUTTON INGREDIENT self.contents.fill_rect(33, 146, 59, 52, OUTLINE_COLOR) self.contents.fill_rect(35, 148, 55, 48, CLEAR_COLOR) ingredient = get_ingredient(0) draw_icon_centered(ingredient.icon_name, 33 + 59 /2, 146 + 52 / 2) # Y BUTTON INGREDIENT self.contents.fill_rect(119, 146, 59, 52, OUTLINE_COLOR) self.contents.fill_rect(121, 148, 55, 48, CLEAR_COLOR) ingredient = get_ingredient(1) draw_icon_centered(ingredient.icon_name, 119 + 59 /2, 146 + 52 / 2) # Z BUTTON INGREDIENT self.contents.fill_rect(207, 146, 59, 52, OUTLINE_COLOR) self.contents.fill_rect(209, 148, 55, 48, CLEAR_COLOR) ingredient = get_ingredient(2) draw_icon_centered(ingredient.icon_name, 207 + 59 /2, 146 + 52 / 2) # X BUTTON ICON if X_BUTTON_ICON == "" self.contents.fill_rect(53, 202, 18, 18, TEMP_COLOR) else draw_icon(X_BUTTON_ICON, 53, 202) end # Y BUTTON ICON if Y_BUTTON_ICON == "" self.contents.fill_rect(139, 202, 18, 18, TEMP_COLOR) else draw_icon(Y_BUTTON_ICON, 139, 202) end # Z BUTTON ICON if Z_BUTTON_ICON == "" self.contents.fill_rect(228, 202, 18, 18, TEMP_COLOR) else draw_icon(Z_BUTTON_ICON, 228, 202) end # PERCENTAGE BAR OUTER self.contents.fill_rect(48, 229, 204, 17, OUTLINE_COLOR) # PERCENTAGE BAR INNER self.contents.fill_rect(50, 231, 200, 13, Color.new(255,255,255)) # # FINISH BUTTON self.contents.fill_rect(51, 257, 75, 26, OUTLINE_COLOR) self.contents.fill_rect(53, 259, 71, 22, CLEAR_COLOR) self.contents.draw_text(53, 259, 71, 22, "Finish", 1) # CANCEL BUTTON self.contents.fill_rect(159, 257, 92, 26, OUTLINE_COLOR) self.contents.fill_rect(161, 259, 88, 22, CLEAR_COLOR) self.contents.draw_text(161, 259, 88, 22, "Cancel", 1) end #-------------------------------------------------------------------------- # * Percentage Bar Refresh - Redraws only the percentage bar #-------------------------------------------------------------------------- def percentage_bar_refresh x_percent = (@combined_percentages[0] * 2) y_percent = (@combined_percentages[1] * 2) z_percent = (@combined_percentages[2] * 2) self.contents.fill_rect(50, 231, x_percent, 13, X_BUTTON_FILL_COLOR) self.contents.fill_rect(50 + x_percent, 231, y_percent, 13, Y_BUTTON_FILL_COLOR) self.contents.fill_rect(50 + x_percent + y_percent, 231, z_percent, 13, Z_BUTTON_FILL_COLOR) end #-------------------------------------------------------------------------- # * Update #-------------------------------------------------------------------------- def update super # Check if percentage bar is maxed out unless @combined_percentages.inject {|sum, n| sum += n } >= 100 # If it isn't, allow additional adding if Input.press?(Input::X) @combined_percentages[0] += 1 elsif Input.press?(Input::Y) @combined_percentages[1] += 1 elsif Input.press?(Input::Z) @combined_percentages[2] += 1 end percentage_bar_refresh # If it is full, don't allow adding else if Input.trigger?(Input::X) or Input.trigger?(Input::Y) or Input.trigger?(Input::Z) $game_system.se_play($data_system.buzzer_se) end end end #-------------------------------------------------------------------------- # * Update Cursor Rectangle #-------------------------------------------------------------------------- def update_cursor_rect # If cursor position is less than 0 if @index < 0 self.cursor_rect.empty return end if @index == 0 self.cursor_rect.set(51, 257, 75, 26) elsif @index == 1 self.cursor_rect.set(159, 257, 92, 26) end end #-------------------------------------------------------------------------- # * Judge Craft - Determines if crafting was successful #-------------------------------------------------------------------------- def judge_craft craft = true correct_percentages = @recipe.quantities for i in 0...correct_percentages.size min = @combined_percentages[i] - 10 max = @combined_percentages[i] + 10 range = min..max unless range.include?(correct_percentages[i]) craft = false break end end # If successful if craft # Play succes SE Audio.se_play("Audio/SE/" + CRAFT_SUCCESS_SE) else # Play failure SE Audio.se_play("Audio/SE/" + CRAFT_FAILURE_SE) # Set result to food waste @recipe.result = WASTE_ITEM_ID @recipe.result_type = 0 end # Make result @recipe.make end #-------------------------------------------------------------------------- # * Draw Icon - draws icons on "x, y" # icon_name : filename of the icon ("String") # x : draw spot x-coordinate # y : draw spot y-coordinate #-------------------------------------------------------------------------- def draw_icon(icon_name, x, y) bitmap = RPG::Cache.icon(icon_name) src_rect = Rect.new(0, 0, bitmap.width, bitmap.height) self.contents.blt(x, y, bitmap, src_rect) end #-------------------------------------------------------------------------- # * Draw Icon Centered- draws icons centered on "x, y" # icon_name : filename of the icon ("String") # x : draw spot x-coordinate # y : draw spot y-coordinate #-------------------------------------------------------------------------- def draw_icon_centered(icon_name, x, y) bitmap = RPG::Cache.icon(icon_name) src_rect = Rect.new(0, 0, bitmap.width, bitmap.height) draw_x = x - (bitmap.width / 2) draw_y = y - (bitmap.height / 2) self.contents.blt(draw_x, draw_y, bitmap, src_rect) end #-------------------------------------------------------------------------- # * Draw Pic - draws pic on "x, y" # pic_name : filename of the pic ("String") # x : draw spot x-coordinate # y : draw spot y-coordinate #-------------------------------------------------------------------------- def draw_pic(pic_name, x, y) bitmap = RPG::Cache.picture(pic_name) src_rect = Rect.new(0, 0, bitmap.width, bitmap.height) self.contents.blt(x, y, bitmap, src_rect) end #-------------------------------------------------------------------------- # * Get ingredient - returns item/weapon/armor # id : 0, 1, or 2 #-------------------------------------------------------------------------- def get_ingredient(id) item_id = @recipe.ingredients[id] item_type = @recipe.ingredient_types[id] case item_type when 0 # item item = $data_items[item_id] when 1 # armor item = $data_armors[item_id] when 2 # weapon item = $data_weapons[item_id] end return item end end