Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #################################################################################
- #################################################################################
- #Nightowl79a Iconic Crafting System#
- # V 1.5 7/3/13 #
- #################################################################################
- #################################################################################
- ##################################################
- # Channel Log
- # V 1.0
- # Initial release
- # V 1.1
- # **New Feature: Toggle Between Names and just icons, see below
- # **New Feature: Set Restrictions to recipes based on location, see below
- # **Redesigned Recipe list to show ingredient names.
- # V 1.2
- # **Fixed a bug that would mess with scrolling
- # **Added Sound and graphic file options
- # V 1.3
- # **New Feature: Can have recipes require Gold and/or Mana
- # **New Feature: Fully Custom Colors for ingredients, and recipe list
- # -Minor Recipe list changes, to include mana and gold.
- # V1.4
- # **Added compatibility with Yanfly Core engine(the screen re sizeing part)
- # V1.5
- # **New Feature: Can have recipes require TP
- # **New Feature: Can toggle on/off ingredient order requirements.
- # -Fixed a bug that would cause an error when the player had more than one of a item.
- # -Recipe list font size adjustment to allow for more clean looking recipes.
- # -Added a game messge to inform the player when restrictions are on
- # -Added a game messge to inform the player when a certain party member can not craft
- # -Added a sort command to sort items by Items, Armor, Weapons, All
- # -Changed WANTED_PARTY_LEADER to CRAFTER to be more clear.
- ################################################################################
- #-------------------------------------------------------------------------------#
- #- I made this script because I wanted a crafting system more like mine craft
- #- or Skyrim in my game. Iconic Crafting System is not exactly like either
- #- of them but I'm happy with it so far. I tried to make everything flow
- #- as smooth as I could, I personally hate having to press to many
- #- buttons to make stuff work. Hopefully you enjoy this script.
- #- On a side note, this is my very first script, and I have
- #- Tested it to my breaking point. If you have constructive criticism
- #- for me I'd be happy to listen.
- #-------------------------------------------------------------------------------#
- #-------------------------------------------------------------------------------#
- # Things planned for the future:
- # Add items that teach you recipes
- # Add crafting times, xp, progression and bonuses
- #
- #
- #
- #-------------------------------------------------------------------------------#
- # INSTRUCTIONS:
- # You can call the crafting scene through a script call like this:
- # SceneManager.call(IconicCrafting)
- # Add that to any event, and you should be able to craft.
- #
- # Optional: If you would like to Restrict recipes to a certain crafting area
- # such as you can only make this at a blacksmith, call
- # SceneManager.scene.prepare("black") === "black" is a keyword you set up in Recpie list
- # Right after SceneManager.call(IconicCrafting)
- #
- #
- #
- #Add Recipe's Below!
- #in the same format as
- # RECIPE[0] = {
- # :name => "Fire Immunity",
- # :ingredients => [20,18,19,21],
- # :types => [RPG::Item,RPG::Weapon],
- # :product => 22,
- # :product_type => RPG::Item,
- # :amount => 2,
- # :discovered => true,
- # :sound => "Hammer",
- # :restrictions => nil,
- # :goldcost => 0,
- # :mpcost => 0,
- # :tpcost => 0
- # }
- #
- # RECIPE[0] To add more than 3 recipes just copy the format above and replace
- # the 0 with the next number. For example, the next recipe would be RECIPE[1]
- #
- # :name Is the name of the recipe, It does not have to be the same as the item it makes
- #
- # :ingredients These are the Item Id's of the ingredients needed to make the item
- # (note) Make sure they are in the correct order.
- # In this exsample the player will have to put item 20 in first, followed by item 18
- #
- # :types These are the Item types of the ingredients needed to make the item
- # Make sure they are in the same order as the Item ID's
- # In this exsample, the first ingredient is a Item, the Second is a weapon
- # RPG::Item = Item RPG::Armor = Armor RPG::Weapon = Weapon
- #
- # :product This is the Item ID for what will be made when using this recipe
- #
- # :product_type This is the item type of the product
- #
- # :amount This is the amount of product that will be produced
- # In this exsample the product will be 2 of item 22
- #
- # :discovered This value defines weather the recipe is added to the recipe list
- # at the start of the game. Setting it to false, will mean the player must learn
- # the recipe or discover the recipe by experimentation.(note they can still use
- # the recipe even if its not discovered)
- #
- # :sound This is the name of the sound file that will be used when the item
- # is crafted. Please put these in Audio/SE if using custom files.
- #
- # :restrictions This is a custom string value that will limit the crafting of
- # the recipe depending on the scene call. Set this to nil for none. For example
- # if you put "Blacksmith" in the restriction you will only be able to craft
- # this recipe from a Blacksmith scene call.
- # Make a restriction scene call like this:
- # SceneManager.call(IconicCrafting)
- # SceneManager.scene.prepare("Blacksmith")
- # That way only recipes with blacksmith restrction can be made.
- # If you dont want any resrictions set the value to nil and make the
- # scene call as normal, without the prepare line
- #
- # :goldcost This is the gold cost the the recipe. When the recipe is made
- # the gold will be taken from the party.
- #
- # :mpcost This is the mp cost of the recipe. There are two options for mp cost,
- # controlled by SHARELOSS bellow. If SHARELOSS is true the total MP of all
- # party members will be used to check if the player has enough mp. If it is
- # false, The lead party member's MP will be used to check if the player has
- # enough MP.
- #
- # :tpcost This is the tp cost of the recipe. The cost will be taken from the
- # PARTYLEAD party leader. Set this to 0 for none.
- #
- # (NOTE: Gold cost is always done first. For example, if the recipe requires
- # 15 gold, and 10 mana, and the player has 11 gold and 20 mana, they will not
- # be able to craft the recipe, even though they have enough MP)
- #
- #
- # Item Order is important!!
- # for example. To make a Fire Immunity Potion you must put item 20(Bottle)
- # and then item 18(Fire), if the player puts fire first it will not work!
- #
- # The player can add up to 6 Items, If the player adds them in the right order the
- # product item window will light up, and the player can press escape/cancel then press craft.
- #
- # If the player messed up the order, they can just press escape/cancel and use the reset
- # command to restart.
- #
- # If a recipe is less than 6 items, the item window will light up after the correct
- # ingredents are added, the player can then press escape/cancel key and, use the craft command to
- # craft the item
- #
- # After the player makes an item for the first time, it is added to a recipe list.
- # The player can view the recipe list from the crafting menu.
- #
- #
- #
- #
- #######################################################################
- module Recipe_List#<====Dont Edit this#################################
- #######################################################################
- ICONONLY = false ######################################################
- #######################################################################
- ############ Use this Value to Toggle the Names of ingredent on or off
- ############ ICONONLY = false means Names and icons will be shown
- ############ ICONONLY = true means only icons will be shown
- #######################################################################
- #######################################################################
- #----------------------------------------------------------------------#
- #Other Options:
- CORRECT_ORDER = false
- #Set this option false if you want to player to be able to add ingredence in any
- #order, set this option to true if you want to require the player to add items
- #in the order you place them in the recipe.
- #for example if the recipe needs a flask and water, if this option is false
- # the player can add either the water or the flast first and then add the flast
- # to make the recipe. If this option is set to true, the player must add the flask
- # first then the water(depending on how u set up the recipe) to be able to craft the
- #item
- #Picture Filename:
- INGREDIENTS_END = "crusor2"
- #This is a small sprite placed at the end of the top window, It only apreares
- #when the correct ingredients are added(be sure to import the correctly named
- #picture into Graphics/Pictures)
- INGREDIENTS_BACK = "crusor3"
- #This is a longer picture that is placed behind the top window to create a effect
- #of the window lighting up.(be sure to import the correctly named
- #picture into Graphics/Pictures)
- SORT = "All"
- #This is the starting option for the sort menu, if it is set to ALL all items/weapons/armors will be show
- #Or you can set it to Item, Weapon, Armor, to show only items, weapons or armors.
- #Sounds Should be placed in Audio/SE
- ADD_SOUND = "Item1"
- #This is the sound played when the player adds an ingredient
- CANCEL_SOUND = "Miss"
- #This is the sound played when the player preses the escape/cancel key while
- #adding ingredents
- CORRECT_SOUND = "Bell3"
- #This is the sound played when the player preses the escape/cancel key and
- #has added the correct ingredients
- CANT_CRAFT_SOUND = "Attack1"
- #This is the sound played when the player preses the craft button and does not
- #have the correct ingredients
- RESET_SOUND = "Item2"
- #This is the sound played when the player resets the ingredient list
- CRAFTER = [18,3]
- #This is the ID's of the actors you want to be able to use the crafting station
- #if actor 18 is in the party that actor will be using the crafting system, and that actor will loose the mana tp
- # if both actor 18 and actor 3 are in the party, actor 18 will still loose the mana
- FAIL_MESSAGE = "I can not craft"
- #This is the message that will be shown when the crafting station closes because
- #the wanted party leader dosnt not match the current party leader.
- SHARELOSS = false
- #This option will divide the MP cost of the recipe by the total members of the
- #party, so if a recipe costs 40 MP and you have 4 party members all 4 will lose
- # 10 mp.
- BAD_MANA = "Not enough Mana"
- #This option is displayed when the player dosn't have the correct amount of mana.
- BAD_GOLD = "Not enough Gold"
- #This option is displayed when the player dosn't have the correct amount of gold.
- BAD_TP = "Not enough Tp"
- #This option is displayed when the player dosn't have the correct amount of TP
- RESTRICTED = "Can't make that here"
- #This option is displayed when the player can't make the certain reciped due to restrictions
- TERM_GOLD = "Gold"
- #This is the term that will be displayed in the recipe list for gold.
- TERM_MP = "Mp"
- #This is the term that will be displayed in the recipe list for MP.
- TERM_TP = "Fp"
- #This is the term that will be displayed in the recipe list for TP.
- #(NOTE: Long Terms will Look bad!)
- #
- #Colors:
- # You can set the colors = to any color in your window skin
- # 0 to 31. (These are the little color boxes at the bottom)
- # (Remeber they start at 0)
- #
- NAMES_COLOR = 16
- #This is the color for Recipe Names
- TERM_GOLD_COLOR = 17
- #This is the color for the gold term
- NUMBER_GOLD_COLOR = 6
- #This is the color for the number amount of gold the recipe costs
- TERM_MP_COLOR = 9
- #This is the color for the MP term
- NUMBER_MP_COLOR = 1
- #This is the color for the number amount of MP the recipe costs
- TERM_TP_COLOR = 1
- #This is the color for the tp term
- NUMBER_TP_COLOR = 25
- #This is the color for the number amount of Tp the recipe costs
- ITEM_NAME_COLOR = 24
- #This is the color used for the names of item type materials
- WEAPON_NAME_COLOR = 8
- #This is the color used for the names of weapon type materials
- ARMOR_NAME_COLOR = 31
- #This is the color used for the names of armor type materials
- OUT_OF_COLOR = 18
- #This is the color used for BAD_MANA AND BAD_GOLD messeges.
- #----------------------------------------------------------------------#
- RECIPE = []
- RECIPE[0] = {
- :name => "Paralysis Rune",
- :ingredients => [24,26],
- :types => [RPG::Item,RPG::Item],
- :product => 25,
- :product_type => RPG::Item,
- :amount => 1,
- :discovered => false,
- :sound => "Hammer",
- :restrictions => nil,
- :goldcost => 0,
- :mpcost => 20,
- :tpcost => 0
- }
- RECIPE[1] = {
- :name => "Sharp HandAxe",
- :ingredients => [24,26],
- :types => [RPG::Weapon,RPG::Item],
- :product => 1,
- :product_type => RPG::Weapon,
- :amount => 1,
- :discovered => false,
- :sound => "Hammer",
- :restrictions => nil,
- :goldcost => 0,
- :mpcost => 0,
- :tpcost => 0
- }
- RECIPE[2] = {
- :name => "Paralysis Rune",
- :ingredients => [24,26],
- :types => [RPG::Armor,RPG::Item],
- :product => 25,
- :product_type => RPG::Armor,
- :amount => 1,
- :discovered => false,
- :sound => "Hammer",
- :restrictions => nil,
- :goldcost => 0,
- :mpcost => 10,
- :tpcost => 0
- }
- end
- class Game_System
- attr_accessor :recipe_list_discovered
- alias NO79a_IconicCraftingSystem_Game_system_initialize initialize
- def initialize
- @recipe_list_discovered = Recipe_List::RECIPE
- NO79a_IconicCraftingSystem_Game_system_initialize()
- end
- end
- ##################################### Window Command Class
- class MyCraftCommands < Window_Command
- def initialize
- super(0, 0)
- end
- def col_max
- return 1
- end
- def make_command_list
- add_main_commands
- end
- def add_main_commands
- add_command("Add", :add)
- add_command("Reset", :reset)
- add_command("Craft", :craft)
- add_command("Sort", :sort)
- add_command("Recpie", :recipie)
- add_command("Exit", :cancel)
- end
- def select_last(last)
- select_symbol(last)
- end
- def set_command_sym
- current_data ? current_data[:symbol] : nil
- end
- end
- ############################################################
- ##################################### Class to Display added items
- class MyAddedItemsDisplay < Window_Base
- def initialize()
- super(Graphics.width - 394,0,Graphics.width-150,Graphics.height - 366)
- end
- def draw_add_item(item, slot)
- remove_from_invitory(item,slot)
- end
- def remove_from_invitory(item,slot)
- $temp_items[slot] = item
- $game_party.lose_item(item,1)
- draw_temp_items()
- end
- def draw_reset(all = false)
- contents.clear
- @check.dispose() unless @check == nil
- @box.dispose() unless @box == nil
- return if all
- draw_temp_items()
- end
- def draw_temp_items()
- ab = 0
- while ab < $temp_items.length
- draw_icon($temp_items[ab].icon_index,ab*65,0,true)
- ab+=1
- end
- end
- def draw_correct()
- @check = Sprite.new()
- @check.bitmap = Cache.picture(Recipe_List::INGREDIENTS_END)
- @check.x = 500
- @check.x = Graphics.width - 44 if Graphics.width > 544
- @check.y = 8
- @check.z = 300
- @box = Sprite.new()
- @box.bitmap = Cache.picture(Recipe_List::INGREDIENTS_BACK)
- @box.x = 150
- @box.x = Graphics.width - 390 if Graphics.width > 544
- @box.y = 0
- end
- def draw_mana()
- change_color(text_color(Recipe_List::OUT_OF_COLOR))
- contents.draw_text(0,0,300,30,Recipe_List::BAD_MANA)
- change_color(normal_color)
- end
- def draw_gold()
- change_color(text_color(Recipe_List::OUT_OF_COLOR))
- contents.draw_text(0,0,300,30,Recipe_List::BAD_GOLD)
- change_color(normal_color)
- end
- def draw_tp()
- change_color(text_color(Recipe_List::OUT_OF_COLOR))
- contents.draw_text(0,0,300,30,Recipe_List::BAD_TP)
- change_color(normal_color)
- end
- def draw_restricted()
- change_color(text_color(Recipe_List::OUT_OF_COLOR))
- contents.draw_text(0,0,300,30,Recipe_List::RESTRICTED)
- change_color(normal_color)
- end
- end #endclass
- ##################################### Class Item Stats in window
- class MyItemsStatsDisplay < Window_Base
- def initialize(line_number = 2)
- super(Graphics.width - 394, Graphics.height - 366 , Graphics.width - 150, Graphics.height - 306)
- end
- def clearz()
- contents.clear
- end
- def draw_descript(x,y,text,item_type,draw_type)
- if draw_type == 0
- change_color(text_color(Recipe_List::ITEM_NAME_COLOR)) if item_type == RPG::Item
- change_color(text_color(Recipe_List::WEAPON_NAME_COLOR)) if item_type == RPG::Weapon
- change_color(text_color(Recipe_List::ARMOR_NAME_COLOR)) if item_type == RPG::Armor
- contents.draw_text(x,y,400,30,text)
- change_color(normal_color)
- end
- if draw_type == 1
- draw_text_ex(x,y,text)
- end
- end
- end
- ############################################################ Pop Class
- class MyPop < Window_Selectable
- def initialize()
- super(Graphics.width - 394, Graphics.height - 366 , Graphics.width - 150, Graphics.height - 306)
- close
- end
- def draw_crafted(id, type, amount)
- contents.clear
- if type == RPG::Item
- item = $data_items[id]
- change_color(text_color(Recipe_List::ITEM_NAME_COLOR))
- contents.draw_text(0,0,300,30,item.name)
- end
- if type == RPG::Weapon
- item = $data_weapons[id]
- change_color(text_color(Recipe_List::WEAPON_NAME_COLOR))
- contents.draw_text(0,0,300,30,item.name)
- end
- if type == RPG::Armor
- item = $data_armors[id]
- change_color(text_color(Recipe_List::ARMOR_NAME_COLOR))
- contents.draw_text(0,0,300,30,item.name)
- end
- change_color(normal_color)
- draw_text_ex(0,25,item.description)
- draw_text_ex(300,0,"=>")
- draw_text_ex(320,0,amount)
- end
- end
- ##################################### Class to Display Item Icons in window
- class MyItemDisplay < Window_Selectable########################
- def initialize() ####################################JUMPHERE#####
- super(0, Graphics.height - 258, Graphics.width, Graphics.height - 158) ################################
- $itemsz = $game_party.items
- $weaponsz = $game_party.weapons
- $armorsz = $game_party.armors
- $rdyitem = {}
- draw_mycons()
- end
- #----------------------------------------------------------------------------#
- def col_max
- return 7 if Recipe_List::ICONONLY == true
- return 2 if Recipe_List::ICONONLY == false
- end
- def spacing
- return 5
- end
- def item_max
- itemsz = $game_party.items
- weaponsz = $game_party.weapons
- armorsz = $game_party.armors
- sort = SceneManager.scene.get_sort
- item_maxx = 0
- if sort == "All" || sort == "Item"
- item_maxx += itemsz.length if itemsz != []
- end
- if sort == "All" || sort == "Armor"
- item_maxx += weaponsz.length if weaponsz != []
- end
- if sort == "All" || sort == "Weapon"
- item_maxx += armorsz.length if armorsz != []
- end
- item_maxx += SceneManager.scene.get_slots
- return item_maxx
- end
- #------------------------------------------------------------------------------#
- def refreshz(everything = false)
- contents.clear()
- draw_mycons()
- end
- def draw_mycons()
- counter = 0
- sx = 0
- sy = 0
- $maxx = 0
- $maxy = 0
- item_number = 0
- sort = SceneManager.scene.get_sort
- #-------------------------------------------------------------------#
- # Icons Item-Names #
- #-------------------------------------------------------------------#
- if sort == "All" || sort == "Item"
- if $items != []
- if Recipe_List::ICONONLY == true && showitems == true
- maxitemsz = $itemsz.length
- while counter < maxitemsz
- $maxy = sy
- $maxx = sx
- $rdyitem[[item_number,:item]] = $itemsz[counter]
- draw_icon($itemsz[counter].icon_index, sx, sy, true)
- $item_amountsz = "=>" + $game_party.item_number($itemsz[counter]).to_s()
- contents.draw_text(sx+25,sy,50,30,$item_amountsz,0)
- sx += Graphics.width - 551 if Graphics.width > 544
- sx += 76 if Graphics.width == 544
- if sx > Graphics.width - 76
- sy += 24
- sx = 0
- end
- item_number +=1
- counter += 1
- end #while
- end #items
- end #Icononly
- #-------------------------------------------------------------------#
- # Icons + Names Item-Names #
- #-------------------------------------------------------------------#
- if $items != []
- if Recipe_List::ICONONLY == false
- maxitemsz = $itemsz.length
- while counter < maxitemsz
- $maxy = sy
- $maxx = sx
- change_color(text_color(Recipe_List::ITEM_NAME_COLOR))
- $rdyitem[[item_number,:item]] = $itemsz[counter]
- contents.draw_text(sx, sy, 150, 25, $itemsz[counter].name)
- draw_icon($itemsz[counter].icon_index, sx+185, sy, true)
- $item_amountsz = "=>" + $game_party.item_number($itemsz[counter]).to_s()
- contents.draw_text(sx+210,sy,50,30,$item_amountsz,0)
- sx += Graphics.width - 284
- if sx > Graphics.width - 200
- sy += 24
- sx = 0
- end
- item_number +=1
- counter += 1
- end #while
- end #items
- end #Icononly
- end #if sort
- #-------------------------------------------------------------------#
- # Icons + Names Weapon-Names #
- #-------------------------------------------------------------------#
- if sort == "All" || sort == "Weapon"
- if $weaponsz != []
- if Recipe_List::ICONONLY == false
- $maxy = sy
- $maxx = sx
- maxweaponsz = $weaponsz.length
- if sx > Graphics.width - 200
- sx = 0
- sy += 24
- end
- counter = 0
- change_color(text_color(Recipe_List::WEAPON_NAME_COLOR))
- while counter < maxweaponsz
- $maxy = sy
- $maxx = sx
- $rdyitem[[item_number,:item]] = $weaponsz[counter]
- contents.draw_text(sx, sy, Graphics.width - 394 , 25, $weaponsz[counter].name)
- draw_icon($weaponsz[counter].icon_index, sx+185, sy, true)
- $wep_amountsz = "=>" + $game_party.item_number($weaponsz[counter]).to_s()
- contents.draw_text(sx+210,sy,50,30,$wep_amountsz,0)
- sx += Graphics.width - 284
- if sx > Graphics.width - 200
- sy += 24
- sx = 0
- end
- item_number +=1
- counter += 1
- end
- end #weaponsz if
- end #iconsonly if
- #-------------------------------------------------------------------#
- # Icons Weapon-Names #
- #-------------------------------------------------------------------#
- if $weaponsz != []
- if Recipe_List::ICONONLY == true
- $maxy = sy
- $maxx = sx
- maxweaponsz = $weaponsz.length
- if sx > Graphics.width - 76
- sx = 0
- sy += 24
- end
- counter = 0
- while counter < maxweaponsz
- $maxy = sy
- $maxx = sx
- $rdyitem[[item_number,:item]] = $weaponsz[counter]
- draw_icon($weaponsz[counter].icon_index, sx, sy, true)
- $wep_amountsz = "=>" + $game_party.item_number($weaponsz[counter]).to_s()
- contents.draw_text(sx+25,sy,50,30,$wep_amountsz,0)
- sx += Graphics.width - 551 if Graphics.width > 544
- sx += 76 if Graphics.width == 544
- if sx > Graphics.width - 76
- sy += 24
- sx = 0
- end
- item_number +=1
- counter += 1
- end
- end #weaponsz if
- end #iconsonly if
- end # sort
- #-------------------------------------------------------------------------#
- # Icons Armor-Names #
- #-------------------------------------------------------------------------#
- if sort == "All" || sort == "Armor"
- if $armorsz != []
- if Recipe_List::ICONONLY == true
- $maxy = sy
- $maxx = sx
- maxarmorsz = $armorsz.length
- if sx > Graphics.width - 76
- sx = 0
- sy += 24
- end
- counter = 0
- while counter < maxarmorsz
- $maxy = sy
- $maxx = sx
- $rdyitem[[item_number,:item]] = $armorsz[counter]
- draw_icon($armorsz[counter].icon_index, sx, sy, true)
- $arm_amountsz = "=>" + $game_party.item_number($armorsz[counter]).to_s()
- contents.draw_text(sx+25,sy,50,30,$arm_amountsz,0)
- sx += Graphics.width - 551 if Graphics.width > 544
- sx += 76 if Graphics.width == 544
- if sx > Graphics.width - 76
- sy += 24
- sx = 0
- end
- item_number +=1
- counter += 1
- end
- end #armors if
- end #icononly if
- #-------------------------------------------------------------------------#
- # Icons + Names Armor-Names #
- #-------------------------------------------------------------------------#
- if $armorsz != []
- if Recipe_List::ICONONLY == false
- $maxy = sy
- $maxx = sx
- maxarmorsz = $armorsz.length
- if sx > Graphics.width - 200
- sx = 0
- sy += 24
- end
- change_color(text_color(Recipe_List::ARMOR_NAME_COLOR))
- counter = 0
- while counter < maxarmorsz
- $maxy = sy
- $maxx = sx
- $rdyitem[[item_number,:item]] = $armorsz[counter]
- contents.draw_text(sx, sy, 150, 25, $armorsz[counter].name)
- draw_icon($armorsz[counter].icon_index, sx+185, sy, true)
- $arm_amountsz = "=>" + $game_party.item_number($armorsz[counter]).to_s()
- contents.draw_text(sx+210,sy,50,30,$arm_amountsz,0)
- sx += Graphics.width - 284
- if sx > Graphics.width - 200
- sy += 24
- sx = 0
- end
- item_number +=1
- counter += 1
- end
- end #armors if
- end #icononly if
- end #sort
- change_color(normal_color)
- #--------------------------------------------------------------------------#
- end#def end
- end#class end
- ##################################### Main Scene Class
- class IconicCrafting < Scene_MenuBase
- def prepare(restrictions = nil)
- @restrictions = restrictions
- end
- def start
- super()
- @sort = Recipe_List::SORT
- @slot = 0
- @addslot = 0
- @last = nil
- $itemsz = []
- $armorsz = []
- $weapons = []
- $temp_items = {}
- @product = 0
- @product_type = 0
- @product_amount = 0
- @sound_p = 0
- @pop_open = false
- get_party_lead
- draw_display_window()
- create_command_window()
- end #end start
- #########################################
- def get_slots
- return @addslot
- end
- def get_party_lead
- a = 0
- Recipe_List::CRAFTER.each do |key|
- $game_party.members.each do |key2|
- if key2.id == key
- @partylead = a
- return
- end
- a+=1
- end#key1
- a=0
- end#key2
- end#def
- def get_sort
- return @sort
- end
- def give_items_back(exit)
- counter = 0
- while counter < 6
- $game_party.gain_item($temp_items[counter], 1)
- counter +=1
- end#while end
- $temp_items = {}
- @item_display.refreshz(false) if exit == false
- end
- #########################################
- def has_items?
- if $itemsz == [] && $armorsz == [] && $weaponsz == []
- return false
- else
- return true
- end #if itemsz
- end
- ########################################
- def terminate
- super()
- give_items_back(true)#do first
- @item_display.dispose()
- @command_window.dispose()
- @item_display_add.dispose()
- @item_display_stats.dispose()
- @window_mypop.dispose()
- end
- #########################################
- def draw_display_window()
- @item_display = MyItemDisplay.new
- @item_display_add = MyAddedItemsDisplay.new
- @item_display_stats = MyItemsStatsDisplay.new
- @window_mypop = MyPop.new
- end
- ###################################################
- ##########################################
- def create_command_window
- @command_window = MyCraftCommands.new
- @command_window.width = Graphics.width - 394
- @command_window.height = Graphics.height - 256
- @command_window.set_handler(:add, method(:select_items))
- @command_window.set_handler(:reset, method(:command_reset))
- @command_window.set_handler(:craft, method(:command_craft))
- @command_window.set_handler(:sort, method(:command_sort))
- @command_window.set_handler(:recipie, method(:recipie_book))
- @command_window.set_handler(:cancel, method(:return_scene))
- end
- #############################################
- def select_items
- if has_items?
- @window_mypop.close
- @pop_open = false
- @item_display_stats.open
- @item_display_stats.clearz
- @item_display.activate()
- @item_display.select(0)
- @command_window.deactivate
- else
- @command_window.activate
- end
- end
- ##########################################
- def window_alter(com)
- RPG::SE.new(Recipe_List::CORRECT_SOUND,100,100).play if com == 2
- RPG::SE.new(Recipe_List::CANCEL_SOUND,100,100).play if com == 1
- @item_display.unselect
- @item_display.deactivate
- @command_window.activate
- @command_window.select(com)
- end
- ##################################################view_known
- def recipie_book
- SceneManager.call(The_Recipie_Book)
- end
- ##################################################Sort Command
- def command_sort
- if has_items?
- if @sort == "All"
- @sort = "Item"
- @item_display.refreshz(false)
- window_alter(3)
- return
- end
- if @sort == "Item"
- @sort = "Weapon"
- @item_display.refreshz(false)
- window_alter(3)
- return
- end
- if @sort == "Weapon"
- @sort = "Armor"
- @item_display.refreshz(false)
- window_alter(3)
- return
- end
- if @sort == "Armor"
- @sort = "All"
- @item_display.refreshz(false)
- window_alter(3)
- return
- end
- end
- @command_window.activate
- end
- ############################################Command Add
- def command_add(index)
- if has_items?
- RPG::SE.stop
- if @slot <= 5
- item = $rdyitem[[index,:item]]
- if $game_party.item_number(item) > 0
- @item_display_add.draw_add_item(item, @slot)
- @slot += 1
- @addslot += 1 if $game_party.item_number(item) <= 0
- @item_display.refreshz(false)
- RPG::SE.new(Recipe_List::ADD_SOUND,100,100).play
- @item_display_add.draw_correct() if check_recipie == "true"
- @item_display_add.draw_mana() if check_recipie == "mp"
- @item_display_add.draw_gold() if check_recipie == "gold"
- @item_display_add.draw_restricted() if check_recipie == "restrected"
- @item_display_add.draw_tp() if check_recipie == "tp"
- @item_display_add.draw_reset(false) if check_recipie == ""
- if @slot == 6
- window_alter(1) if check_recipie == ""
- window_alter(2) if check_recipie == "true"
- end
- elsif $game_party.item_number(item) <= 0
- RPG::SE.new(Recipe_List::CANCEL_SOUND,100,100).play
- end
- else
- window_alter(1) if check_recipie == ""
- window_alter(2) if check_recipie == "true"
- end
- end
- end
- ##################################### Code for add item
- def command_reset
- if has_items?
- RPG::SE.stop
- RPG::SE.new(Recipe_List::CANCEL_SOUND,100,100).play if @slot == 0
- RPG::SE.new(Recipe_List::RESET_SOUND,100,100).play if @slot > 0
- @item_display.refreshz(false)
- give_items_back(false)
- @item_display_add.draw_reset(true)
- @slot = 0
- @addslot = 0
- window_alter(0)
- end
- @command_window.activate
- end
- ###############################################################
- def command_craft
- if has_items?
- if check_recipie == "true"
- RPG::SE.stop
- RPG::SE.new(@sound_p,100,100).play
- $game_party.members[@partylead].mp -= @mploss if Recipe_List::SHARELOSS == false
- if Recipe_List::SHARELOSS == true
- lossit = 0
- while lossit < $game_party.members.length
- $game_party.members[lossit].mp -= @mploss
- lossit+=1
- end
- end
- $game_party.lose_gold(@goldloss)
- $game_party.members[@partylead].tp -= @tploss
- $game_party.gain_item($data_items[@product],@product_amount) if @product_type == RPG::Item
- $game_party.gain_item($data_weapons[@product],@product_amount) if @product_type == RPG::Weapon
- $game_party.gain_item($data_armors[@product],@product_amount) if @product_type == RPG::Armor
- @item_display_add.draw_reset(true)
- $temp_items = {}
- @slot = 0
- @addslot = 0
- $itemsz = $game_party.items
- $weaponsz = $game_party.weapons
- $armorsz = $game_party.armors
- @item_display.refreshz(true)
- @command_window.activate
- @command_window.select(0)
- @command_window.activate
- @item_display_stats.close()
- @window_mypop.open()
- @pop_open = true
- @window_mypop.draw_crafted(@product,@product_type,@product_amount)
- return
- end #if check
- RPG::SE.stop
- RPG::SE.new(Recipe_List::CANT_CRAFT_SOUND,100,100).play
- @command_window.activate
- @command_window.select(0)
- end #if has items
- @command_window.activate
- end #def end
- ############################################################
- def check_recipie
- if $temp_items == nil
- return
- end
- total_recipe = Recipe_List::RECIPE.length
- rlist = Recipe_List::RECIPE
- @tempids = Array.new
- @temptyps = Array.new
- @temprecs = nil
- @Product = 0
- @Product_type = 0
- @mploss = 0
- @goldloss = 0
- @tploss = 0
- make = ""
- a = 0
- b = 0
- while a < $temp_items.length
- @tempids.push($temp_items[a].id)
- @temptyps.push($temp_items[a].class)
- a+=1
- end
- while b < total_recipe
- tot1 = 0; tot2 = 0
- if Recipe_List::CORRECT_ORDER == false
- @tempids.each do |key|
- tot1 += key
- end
- rlist[b][:ingredients].each do |key2|
- tot2 += key2
- end
- if tot1 == tot2
- tot3 = 0; tot4 = 0
- @temptyps.each do |key|
- tot3 += 1 if key == RPG::Item
- tot3 += 2 if key == RPG::Weapon
- tot3 += 2 if key == RPG::Armor
- end
- rlist[b][:types].each do |key|
- tot4 += 1 if key == RPG::Item
- tot4 += 2 if key == RPG::Weapon
- tot4 += 2 if key == RPG::Armor
- end
- if tot3 == tot4
- ######################################This is if orders are not true
- if rlist[b][:restrictions] == @restrictions &&
- $game_party.gold >= rlist[b][:goldcost]
- if Recipe_List::SHARELOSS == false &&
- $game_party.members[@partylead].mp < rlist[b][:mpcost]
- make = "mp"
- end
- if Recipe_List::SHARELOSS == false &&
- $game_party.members[@partylead].mp >= rlist[b][:mpcost]
- return "tp" if $game_party.members[@partylead].tp < rlist[b][:tpcost]
- @goldloss = rlist[b][:goldcost]
- @mploss = rlist[b][:mpcost]
- @tploss = rlist[b][:tpcost]
- @product = rlist[b][:product]
- @product_type = rlist[b][:product_type]
- @product_amount = rlist[b][:amount]
- @sound_p = rlist[b][:sound]
- $game_system.recipe_list_discovered[b][:discovered] = true
- Recipe_List::RECIPE[b][:discovered] = true
- make = "true"
- end
- if Recipe_List::SHARELOSS == true
- i = 0
- fz = 0
- while i < $game_party.members.length
- fz += $game_party.members[i].mp
- i+=1
- end
- if fz < rlist[b][:mpcost]
- make = "mp"
- end
- if fz > rlist[b][:mpcost]
- return "tp" if $game_party.members[@partylead].tp < rlist[b][:tpcost]
- @goldloss = rlist[b][:goldcost]
- @mploss = rlist[b][:mpcost] / $game_party.members.length
- @tploss = rlist[b][:tpcost]
- @product = rlist[b][:product]
- @product_type = rlist[b][:product_type]
- @product_amount = rlist[b][:amount]
- @sound_p = rlist[b][:sound]
- $game_system.recipe_list_discovered[b][:discovered] = true
- Recipe_List::RECIPE[b][:discovered] = true
- make = "true"
- end
- end#Recipe_List::SHARELOSS == true
- end#gold and restrictions are met
- if rlist[b][:restrictions] == @restrictions &&
- $game_party.gold < rlist[b][:goldcost]
- make = "gold"
- end
- make = "restrected" if rlist[b][:restrictions] != @restrictions
- end#if tot1 == tot2(types)
- end#if tot1 == tot2(id's)
- end#if correct order
- #############################################
- if @tempids == rlist[b][:ingredients] &&
- @temptyps == rlist[b][:types] &&
- rlist[b][:restrictions] == @restrictions &&
- $game_party.gold >= rlist[b][:goldcost]
- if Recipe_List::SHARELOSS == false &&
- $game_party.members[@partylead].mp < rlist[b][:mpcost]
- make = "mp"
- end
- if Recipe_List::SHARELOSS == false &&
- $game_party.members[@partylead].mp >= rlist[b][:mpcost]
- return "tp" if $game_party.members[@partylead].tp < rlist[b][:tpcost]
- @goldloss = rlist[b][:goldcost]
- @mploss = rlist[b][:mpcost]
- @tploss = rlist[b][:tpcost]
- @product = rlist[b][:product]
- @product_type = rlist[b][:product_type]
- @product_amount = rlist[b][:amount]
- @sound_p = rlist[b][:sound]
- $game_system.recipe_list_discovered[b][:discovered] = true
- Recipe_List::RECIPE[b][:discovered] = true
- make = "true"
- end
- if Recipe_List::SHARELOSS == true
- i = 0
- fz = 0
- while i < $game_party.members.length
- fz += $game_party.members[i].mp
- i+=1
- end
- if fz < rlist[b][:mpcost]
- make = "mp"
- end
- if fz > rlist[b][:mpcost]
- return "tp" if $game_party.members[@partylead].tp < rlist[b][:tpcost]
- @goldloss = rlist[b][:goldcost]
- @mploss = rlist[b][:mpcost] / $game_party.members.length
- @tploss = rlist[b][:tpcost]
- @product = rlist[b][:product]
- @product_type = rlist[b][:product_type]
- @product_amount = rlist[b][:amount]
- @sound_p = rlist[b][:sound]
- $game_system.recipe_list_discovered[b][:discovered] = true
- Recipe_List::RECIPE[b][:discovered] = true
- make = "true"
- end
- end#Recipe_List::SHARELOSS == true
- end
- if @tempids == rlist[b][:ingredients] &&
- @temptyps == rlist[b][:types] &&
- rlist[b][:restrictions] == @restrictions &&
- $game_party.gold < rlist[b][:goldcost]
- make = "gold"
- end
- make = "restrected" if rlist[b][:restrictions] != @restrictions
- b+=1
- end
- return make
- end
- def update
- super
- if @item_display.active
- @item_display_stats.clearz
- @item_display_stats.draw_descript(0,0,$rdyitem[[@item_display.index,:item]].name,
- $rdyitem[[@item_display.index,:item]].class,0)
- @item_display_stats.draw_descript(0,30,$rdyitem[[@item_display.index,:item]].description,
- $rdyitem[[@item_display.index,:item]].class,1)
- end
- if Input.trigger?(:B) && has_items?
- window_alter(1) if check_recipie == "" || check_recipie == "mp" ||
- check_recipie == "gold" || check_recipie == "restrected" ||
- check_recipie == "tp"
- window_alter(2) if check_recipie == "true"
- end
- if Input.trigger?(:C) && @item_display.active
- command_add(@item_display.index)
- end
- if $game_party.members[0].id != Recipe_List::CRAFTER
- $game_party.members.each do |key|
- Recipe_List::CRAFTER.each do |key2|
- if key.id == key2
- return
- end
- end#do
- end#do2
- RPG::SE.new(Recipe_List::CANT_CRAFT_SOUND,100,100).play
- $game_message.face_name = ($game_party.members[0].face_name)
- $game_message.face_index = ($game_party.members[0].face_index)
- $game_message.add(Recipe_List::FAIL_MESSAGE)
- return_scene
- end
- end
- end #class
- ##################################### End of Main Class
- class The_Recipie_Book < Scene_MenuBase
- def start
- super()
- @sort = Recipe_List::SORT
- draw_windows_r()
- create_command_window()
- end
- def create_command_window
- @command_window = MyRecipieBookCommands.new
- @command_window.width = Graphics.width
- @command_window.height = 50
- @command_window.set_handler(:view, method(:view_me))
- @command_window.set_handler(:sort, method(:sort_command))
- @command_window.set_handler(:cancel, method(:return_scene))
- end
- def draw_windows_r
- @my_recipie_dis = My_recipie_display.new
- end
- def view_me
- @my_recipie_dis.activate()
- @command_window.unselect
- @my_recipie_dis.select(0)
- @command_window.deactivate
- end
- def sort_command
- if @sort == "All"
- @sort = "Item"
- @my_recipie_dis.set_sort(@sort)
- @command_window.activate
- @command_window.select(1)
- return
- end
- if @sort == "Item"
- @sort = "Weapon"
- @my_recipie_dis.set_sort(@sort)
- @command_window.activate
- @command_window.select(1)
- return
- end
- if @sort == "Weapon"
- @sort = "Armor"
- @my_recipie_dis.set_sort(@sort)
- @command_window.activate
- @command_window.select(1)
- return
- end
- if @sort == "Armor"
- @sort = "All"
- @my_recipie_dis.set_sort(@sort)
- @command_window.activate
- @command_window.select(1)
- return
- end
- end
- def update
- super
- if Input.trigger?(:B)
- @my_recipie_dis.unselect
- @my_recipie_dis.deactivate
- @command_window.activate
- @command_window.select(0)
- end
- end
- end
- ###########################################End of The Recipie Book
- class MyRecipieBookCommands < Window_Command
- def initialize
- super(0, 0)
- end
- def make_command_list
- add_main_commands
- end
- def add_main_commands
- add_command("View", :view)
- add_command("Sort", :sort)
- add_command("Exit", :cancel)
- end
- def select_last(last)
- select_symbol(last)
- end
- def set_command_sym
- current_data ? current_data[:symbol] : nil
- end
- end #end of class myre
- #################################################
- class My_recipie_display < Window_Selectable
- def initialize()
- super(0,Graphics.height-365,Graphics.width,Graphics.height)
- @sort = Recipe_List::SORT
- draw_recipies_to_window()
- end
- def col_max
- return 1
- end
- def item_height
- return 96
- end
- def item_max
- b = 0
- a = 0
- rec_len = Recipe_List::RECIPE.length
- while a < rec_len
- if Recipe_List::RECIPE[a][:product_type] == RPG::Item
- if @sort == "All" || @sort == "Item"
- if Recipe_List::RECIPE[a][:discovered] == true || $game_system.recipe_list_discovered[b][:discovered] == true
- b+=1
- end#recipe_list
- end#sort
- end#producttype
- if Recipe_List::RECIPE[a][:product_type] == RPG::Weapon
- if @sort == "All" || @sort == "Weapon"
- if Recipe_List::RECIPE[a][:discovered] == true || $game_system.recipe_list_discovered[b][:discovered] == true
- b+=1
- end#recipe_list
- end#sort
- end#producttype
- if Recipe_List::RECIPE[a][:product_type] == RPG::Armor
- if @sort == "All" || @sort == "Armor"
- if Recipe_List::RECIPE[a][:discovered] == true || $game_system.recipe_list_discovered[b][:discovered] == true
- b+=1
- end#recipe_list
- end#sort
- end#producttype
- a+=1
- end
- return b
- end
- def set_sort(sort)
- @sort = sort
- contents.clear
- draw_recipies_to_window
- end
- def draw_recipies_to_window
- contents.font.size = 20
- @repie = []
- @repie = Recipe_List::RECIPE
- @repie_len = 0
- @rapie_len = Recipe_List::RECIPE.length
- skip = false
- a = 0
- b = 0
- yy = 0
- iconx = 200
- icony = 0
- tab1 = Graphics.width-354
- tab2 = Graphics.width-184
- tab1 = Graphics.width-450 if Graphics.width > 544
- tab2 = Graphics.width-280 if Graphics.width > 544
- while b < @rapie_len
- if Recipe_List::RECIPE[b][:discovered] == true || $game_system.recipe_list_discovered[b][:discovered] == true
- if @sort == "Item"
- skip = true unless @repie[b][:product_type] == RPG::Item
- end
- if @sort == "Weapon"
- skip = true unless @repie[b][:product_type] == RPG::Weapon
- end
- if @sort == "Armor"
- skip = true unless @repie[b][:product_type] == RPG::Armor
- end
- skip = false if @sort == "All"
- if skip == false
- while a < @repie[b][:ingredients].length
- iconx=tab1 if a==0
- iconx=tab2 if a==1
- if a==2
- iconx=tab1
- icony+=32
- end
- iconx=tab2 if a==3
- if a==4
- iconx=tab1
- icony+=32
- end
- iconx=340 if a==5
- if @repie[b][:types][a] == RPG::Item
- change_color(text_color(Recipe_List::ITEM_NAME_COLOR))
- draw_icon($data_items[@repie[b][:ingredients][a]].icon_index,iconx,icony,true)
- contents.draw_text(iconx+23, icony, 170, 25,$data_items[@repie[b][:ingredients][a]].name)
- elsif @repie[b][:types][a] == RPG::Weapon
- change_color(text_color(Recipe_List::WEAPON_NAME_COLOR))
- draw_icon($data_weapons[@repie[b][:ingredients][a]].icon_index,iconx,icony,true)
- contents.draw_text(iconx+23, icony, 170, 25,$data_weapons[@repie[b][:ingredients][a]].name)
- elsif @repie[b][:types][a] == RPG::Armor
- change_color(text_color(Recipe_List::ARMOR_NAME_COLOR))
- draw_icon($data_armors[@repie[b][:ingredients][a]].icon_index,iconx,icony,true)
- contents.draw_text(iconx+23, icony, 170, 25,$data_armors[@repie[b][:ingredients][a]].name)
- end
- a=a+1
- end
- change_color(normal_color)
- contents.draw_text(0,yy-20,500,25,"--------------------------------------------")
- change_color(text_color(Recipe_List::NAMES_COLOR))
- contents.draw_text(23,yy,170,25,@repie[b][:name])#draw name
- change_color(text_color(Recipe_List::NUMBER_GOLD_COLOR))
- contents.draw_text(Recipe_List::TERM_GOLD.length * 12,
- yy+20,60,25,@repie[b][:goldcost].to_s)#draw goldnumber
- change_color(text_color(Recipe_List::TERM_GOLD_COLOR))
- contents.draw_text(5,yy+20,60,25, Recipe_List::TERM_GOLD + "=")#draw goldname
- change_color(text_color(Recipe_List::NUMBER_MP_COLOR))
- contents.draw_text(Recipe_List::TERM_MP.length * 15,
- yy+40,60,25,@repie[b][:mpcost].to_s)
- change_color(text_color(Recipe_List::TERM_MP_COLOR))
- contents.draw_text(5,yy+40,60,25,Recipe_List::TERM_MP + "=")
- change_color(text_color(Recipe_List::NUMBER_TP_COLOR))
- contents.draw_text(Recipe_List::TERM_TP.length * 15,
- yy+60,60,25,@repie[b][:tpcost].to_s)
- change_color(text_color(Recipe_List::TERM_TP_COLOR))
- contents.draw_text(5,yy+60,60,25,Recipe_List::TERM_TP + "=")
- draw_icon($data_items[@repie[b][:product]].icon_index,0,yy,true) if @repie[b][:product_type] == RPG::Item
- draw_icon($data_weapons[@repie[b][:product]].icon_index,0,yy,true) if @repie[b][:product_type] == RPG::Weapon
- draw_icon($data_armors[@repie[b][:product]].icon_index,0,yy,true) if @repie[b][:product_type] == RPG::Armor
- change_color(normal_color)
- yy+=96
- icony=yy
- a=0
- end
- end#skip
- b+=1
- skip = false
- end#whileb
- end#def
- end#class
RAW Paste Data