Cooking/Crafting system similar to Mabinogi

Discussion in 'RGSS Script Requests' started by sutorumie, Apr 26, 2014.

  1. sutorumie

    sutorumie I'm a whimsical girl. Veteran

    Messages:
    30
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    https://www.youtube.com/watch?v=AuembLFMECI

    More info from the game -> http://wiki.mabinogiworld.com/view/Cooking

    Basically, you add 3 ingredients, then hold a button (which can be switched to pressing 3 different keys on the keyboard instead of the mouse) to add a certain % of the ingredient, and you have to add each ingredient in a certain amount in order to produce a better product (out of five stars). For example, a brownie is: Chocolate (48%) Wheat Flour (47%) and Yeast (5%). If you mess up the ratio badly enough, you get "food waste", which is inedible junk. There's also various types of cooking (kneading, baking, mixing, simmering, etc) which can be activated depending on what you use to cook.

    In the case of rmxp I was thinking either A.) you can equip different relevant tools as a weapon and shield or B.) you can use a script call on an event to use something on the map instead. Perhaps recipes and food items can be defined in the script as an itemid# so you know what can only be made/used in a certain type of crafting. As for the crafting window itself, I was thinking it could just be a menu like any other, where you select three items from your inventory which then go onto a top or bottom section of the menu, then you can do a minigame involving holding 3 buttons (which correspond to the 3 different ingredients) which fills a meter slowly. When it's full you are prompted to finish the craft, yes/no, and if no you do the game over again. It's up to you guys if you want to have the player reselect the food items again or if only the meter will be emptied.

    If this is asking way too much I'd enjoy it if someone could at least direct me to somewhere I can get something interesting for a crafting system? I want an actual minigame or else the crafting process itself will be... boring and pointless.
     
    #1
  2. MobiusXVI

    MobiusXVI Game Maker Veteran

    Messages:
    359
    Likes Received:
    84
    First Language:
    English
    So a system like this is a pretty tall order. Not impossible mind you, but it would be a lot of work. Now you did a pretty good job describing what it is you want in the system, but after reading your post I still have some questions.

    Does the player collect ingredients and then mixes them at random to discover recipes? Or does the player collect ingredients and recipes and simply tries to follow the recipe? In either case, will there need to be a recipe book that the player can go through? Or do you want compatible recipes to show up after the player selects the first ingredient? If you're wanting to make the ingredients as items in RMXP's database, are you going to want to use the built in 24x24 icons as the ingredient representation in the crafting window? Or do you want larger, custom icons? Does each recipe have it's own tolerances (e.g. +/- 5% versus +/-10%) before you get food waste?
     
    #2
  3. sutorumie

    sutorumie I'm a whimsical girl. Veteran

    Messages:
    30
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    Yeah, I was a bit iffy about asking in the first place, but when it came down to it I believe all I'd need is a mod of an existing crafting mod (I've installed this one but I've yet to test it, as it seems to have what I want with two exceptions: the meter, and the different forms of cooking like mixing/baking) to add on what's missing. But, then again, my scripting knowledge is limited so I don't know if that would work.

    To go through your questions:

    • Does the player collect ingredients and then mixes them at random to discover recipes? They can, or they can buy a book to read about different recipes.
    • Or does the player collect ingredients and recipes and simply tries to follow the recipe? Recipes are not added to any sort of menu/database after reading a cookbook, the player just has to remember it. But if they make the food, then it is added to a database, sort of like an achievement system. This can be skipped if it's too much, I'm not too worried about it.
    • In either case, will there need to be a recipe book that the player can go through? This doesn't need to be scripted I think, I can probably use switches/variables to add recipes to a cookbook located in the player's home provided the player has the recipe book in their inventory. Or maybe it can be used from the inventory, I can probably find something for that.
    • Or do you want compatible recipes to show up after the player selects the first ingredient? As cool as that would be, no, its not necessary. But, I mean, if you want to... I wouldn't complain...
    • If you're wanting to make the ingredients as items in RMXP's database, are you going to want to use the built in 24x24 icons as the ingredient representation in the crafting window? Or do you want larger, custom icons? I've already made a lot of the icons, I believe the biggest size is 26x26. I'll be making all the icons. (The art portion is my specialty)
    • Does each recipe have it's own tolerances (e.g. +/- 5% versus +/-10%) before you get food waste? No, I'd say the disaster rate is 10% for everything. Certain foods are learned at different levels by association that each time the cooking or crafting skill ranks, you learn a new way to make food (or whatever else). So, for example, at a certain rank, you learn "baking", and by association, you can then make cakes and whatnot. I don't think skill ranking is covered in the crafting script I listed, but we can do a workaround; I have a quest system and I think I could just make the character complete jobs to gain new recipes/cooking types instead of skill ranking. Actually, that would be a lot more similar to Mabinogi as they sell books like "Introduction to Simmering" and whatnot that rank the skill, it would nearly be the same thing.
    Edit: If you were worried that I said that script was untested (personally) well no worries! I just tested it and it worked as advertised, it's very easy and simple. Which doesn't change anything but I just wanted to mention that it worked with all my other scripts and I know how to use it. For future reference.
     
    Last edited by a moderator: Apr 27, 2014
    #3
  4. MobiusXVI

    MobiusXVI Game Maker Veteran

    Messages:
    359
    Likes Received:
    84
    First Language:
    English
    Ok so I've taken a look at the script you're using, and I think it could be modified to get what you want without too much hassle. Here's what I'm thinking - I'll change it so that you can use ingredient amount as a percentage. So for example if you've got three ingredients rather than putting [1, 1, 1] for one of each, you can put [45, 25, 30] for 45%, 25%, and 30%. Then the next thing I'll do is when you go to craft something, selecting what you want to make will start the mixing minigame. And then lastly if you want different types of cooking/baking, what I can do is add a tag of sorts to recipes. So each recipe you make will have all the same stuff is does now, but it'll also have a cooking/baking "type". Then I'll make it so that when you call the crafting screen you can specify the type and only recipes of those types will be displayed. How does all of that sound? Is it at least pretty close to what you want? If not, let me know and I'll try to come up with something else.
     
    #4
  5. sutorumie

    sutorumie I'm a whimsical girl. Veteran

    Messages:
    30
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    That sounds pretty good! In the mixing minigame, for the buttons you press to fill in each ingredient, will they use custom icons? I already have a set of buttons I'm using for another minigame that fit the windowskin and I think they would look nice in the mixing minigame as well. They're located in the pictures folder (not that I can't move them if I need to) and are 30x30 but I can easily make that 26x26. If that can't be done that's fine, so long as they can copy over the game's font. And thanks for helping me~
     
    #5
  6. MobiusXVI

    MobiusXVI Game Maker Veteran

    Messages:
    359
    Likes Received:
    84
    First Language:
    English
    It can look pretty much however you want it to. In fact if you have something specific in mind, just make a rough draft of how you want it to look and I'll do my best to accommodate. I was just gonna follow the Mabinogi style above and put the three ingredient icons horizontally, put an "add" button underneath each one, have a mix bar below that, and then have a "finish" and "cancel" button. But seriously, I'll try to do whatever you want.
     
    #6
  7. sutorumie

    sutorumie I'm a whimsical girl. Veteran

    Messages:
    30
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    As close to Mabinogi as possible is cool, I was just meaning something like this (I'm sorry this is so blindingly pink):

    [​IMG]

    So basically, the same sort of thing but the "Add" instead has images referring to what button each ingredient corresponds to on the keyboard (ignore the fact that I put up "A" twice I only have Z and A ready to use). The "Start" turns into "Finish" after the meter is filled. (The meter isn't an image I just used one to draw this) Anyway this is just an example to show what I meant by what I said yesterday, it doesn't need to look exact or anything.
     
    #7
  8. MobiusXVI

    MobiusXVI Game Maker Veteran

    Messages:
    359
    Likes Received:
    84
    First Language:
    English
    Quick heads up: I've been having some computer issues so I can't work on your script at the moment. I'm already part way done though, so as soon as I get things sorted it shouldn't take too long to finish.

    EDIT: Computer is fixed (hurrah!), so look for the finished script this weekend.

    EDIT #2: As promised, here's the finished script. I wrote and packaged it so that you can simply replace the current version you have with my version. Or you can paste the new version below the old one and that will work just as well.

    Code:
    #===============================================================# 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 
     
    Last edited by a moderator: May 26, 2014
    #8
    sutorumie likes this.
  9. sutorumie

    sutorumie I'm a whimsical girl. Veteran

    Messages:
    30
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    This script is wonderful! I had a few errors at first--I tested in a new game to make sure it wasn't a conflicting script--and I wound up deleting 2 lines of code (because I don't have the scripting prowess to fix it instead), if you're curious which ones those were I'll list them below. Other than that it works just like I asked, it looks great and it's easy to use. The code I took out didn't seem to have any adverse effects, so that's good. Thank you so much for your help! I definitely couldn't have done this myself.
     

    Code:
    self.contents.font.name = $fontface.is_a?(String) ? $fontface : $defaultfonttypeself.contents.font.size = $fontsize.is_a?(Integer) ? $fontsize : $defaultfontsizeError - line 374: TypeError "no implicit conversion from nil to integer"
     
    #9
  10. MobiusXVI

    MobiusXVI Game Maker Veteran

    Messages:
    359
    Likes Received:
    84
    First Language:
    English
    Haha, oh that's funny. Those two lines were in the original script, and I removed them because they were causing me problems as well. I guess they made it back in though. But yea, it shouldn't be a problem to have those removed. They're just used to customize font face and font size (as you might have guessed).

    Anyways, glad you like the script, and if you ever have any problems with it just ask!
     
    Last edited by a moderator: May 27, 2014
    #10
    sutorumie likes this.

Share This Page