Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #################################################################################
- #################################################################################
- #Nightowl79a Iconic Crafting System#
- # V 0.5 7/3/13 #
- #################################################################################
- #################################################################################
- ##################################################
- # Channel Log
- # V 0.5
- # Initial release
- #-------------------------------------------------------------------------------#
- #Things planned for the future:
- # chance to fail / bonus items when crafting
- # animation upon crafting
- # backround images
- # restrictions on crafting items based on profession
- #Instructions:
- #Install below Materials above Main
- #
- #To call this script use
- #
- # SceneManager.call(ICS)
- #
- #This can either be put in a event script call or something like Yanfly's Custom
- #menu
- #
- #Formulas, must be set up very specificly to work properly follow this format
- #exactly.
- #
- # FORMULA[0] = {
- # :name => '5x Elixir Formula',
- # :mats => [['i',1,10],['i',2,1]],
- # :products => [['i',8,20]],
- # :costs => [0,0,0],
- # :sound => "Hammer",
- # :discovered => true,
- # :know_mats => true
- # }
- #
- # :name => is the name of the formula the name should be less than 24 leters
- # and in a '' or ""
- #
- # :mats => is each material need to make the formula. the first part('i') is
- # the type of item of the material. Use
- # 'i' or 'a' or 'w'
- #
- # The second part(1) is the name of the material. You can use either
- # the number of the item from the database or you can use the name of
- # the item. ex 'Potion' Must be in "" or ''.
- #
- # The third part(10) is the amount of the item the material requires.
- # Only if the user has this many of the item in thier invetory will
- # they be able to craft the item.
- #
- # You can have up to 6 materials following this format:
- # [['i',1,1],['i',2,1],['a',1,1],['i','Potion',1]]
- # Make sure to seperate each material with a comma.
- #
- # :products => is each product if the user supplies the correct materials.
- # Follow the same format as used with the :mats.
- # rembmer: [[type,name,amount],[type,name,amount]]
- #
- # :costs => is the gold, mana and tp cost of the material in that order.
- # eg. costs [10,20,30] would mean the formula will cost
- # 10 gold, 20 mana, 30 tp. If left at 0 the user will only need the
- # items.
- #
- # :sound => is the sound played when the formula is made. Make sure you use
- # "" around it.
- #
- # :discovered => is weather the formula is the formula book or not at the start of
- # the game. When a formula is made for the fisrt time
- # it is added to the formula book automatically.
- #
- #
- # :know_mats => determains if the required materials are hidden in the formula
- # book at the start of the game. When a formula is made for the
- # first time it's materials are unhidden in the formula book
- # automatically.
- module ICS_Custom_Formula
- ADD_SOUND = 'Item1'
- CANCEL_SOUND = 'Miss'
- CANT_CRAFT_SOUND = 'Attack1'
- CORRECT_SOUND = 'Bell3'
- REMOVE_SOUND = 'Blow1'
- RESET_SOUND = 'Item2'
- FORMULA_BOOK_NAME = 'Formula Book'
- COLORS = [12,6,1,2,3,10]
- #name color, gold color, mana color, tp color, good color, out color
- FORMULA = []
- ##############################################################
- FORMULA[0] = {
- :name => '5x Elixir Formula', #name should be < 24 chr
- :mats => [['i',1,10],['i',2,1]],
- :products => [['i',8,5]],
- :costs => [0,0,0],
- :sound => "Hammer",
- :discovered => true,
- :know_mats => true
- }
- FORMULA[1] = {
- :name => 'Poison Cure Formula',
- :mats => [['i','Magic Water',1]],
- :products => [['i','Poison Cure',1]],
- :costs => [0,0,0],
- :sound => "Hammer",
- :discovered => true,
- :know_mats => true
- }
- FORMULA[2] = {
- :name => 'Potion Ax Formula',
- :mats => [['w','Hand Ax',1],['i','Potion',1]],
- :products => [['w','Potion Ax',1]],
- :costs => [0,0,0],
- :sound => "Hammer",
- :discovered => true,
- :know_mats => true
- }
- FORMULA[3] = {
- :name => 'Potion Ax BreakDown',
- :mats => [['w','Potion Ax',1]],
- :products => [['w','Hand Ax',1],['i','Potion',1]],
- :costs => [0,10,0],
- :sound => "Hammer",
- :discovered => true,
- :know_mats => true
- }
- FORMULA[4] = {
- :name => 'Armor Upgrade',
- :mats => [['a','Casual Clothes',1],['i','Life Up',1]],
- :products => [['a',4,1],['a','Brigandine',1]],
- :costs => [0,10,0],
- :sound => "Hammer",
- :discovered => true,
- :know_mats => true
- }
- FORMULA[5] = {
- :name => 'Great Armor',
- :mats => [['i','Stim',1],['a',1,1]],
- :products => [['a','Talisman of Light',1]],
- :costs => [0,10,0],
- :sound => "Hammer",
- :discovered => true,
- :know_mats => true
- }
- end
- class Game_System
- attr_accessor :formula_list
- alias NO79a_ICS_Game_system_initialize initialize
- def initialize
- @formula_list = ICS_Custom_Formula::FORMULA
- NO79a_ICS_Game_system_initialize()
- end
- end
- class ICS < Scene_MenuBase
- def start
- super()
- @formula_book = false
- Convert_Formulas()
- Start_Windows()
- end
- def Convert_Formulas
- @formula_max = ICS_Custom_Formula::FORMULA.length
- @name = []
- @mats = []
- @current_formula = []
- @amounts = []
- @products = []
- @product_amounts = []
- count=0
- ICS_Custom_Formula::FORMULA.each do |custom_formula|
- @name[count] = custom_formula[:name]
- @mats[count] = []
- @amounts[count] = []
- @products[count] = []
- @product_amounts[count] = []
- custom_formula[:mats].each do |mats|
- $data_items.each do |data|
- if data != nil
- if mats[0] == 'i' && mats[1] == data.name
- @mats[count].push(data)
- @amounts[count].push(mats[2])
- elsif mats[0] == 'i' && mats[1] == data.id
- @mats[count].push(data)
- @amounts[count].push(mats[2])
- end
- end
- end
- $data_weapons.each do |data|
- if data != nil
- if mats[0] == 'w' && mats[1] == data.name
- @mats[count].push(data)
- @amounts[count].push(mats[2])
- elsif mats[0] == 'w' && mats[1] == data.id
- @mats[count].push(data)
- @amounts[count].push(mats[2])
- end
- end
- end
- $data_armors.each do |data|
- if data != nil
- if mats[0] == 'a' && mats[1] == data.name
- @mats[count].push(data)
- @amounts[count].push(mats[2])
- elsif mats[0] == 'a' && mats[1] == data.id
- @mats[count].push(data)
- @amounts[count].push(mats[2])
- end
- end
- end
- end
- custom_formula[:products].each do |products|
- $data_items.each do |data|
- if data != nil
- if products[0] == 'i' && products[1] == data.name
- @products[count].push(data)
- @product_amounts[count].push(products[2])
- elsif products[0] == 'i' && products[1] == data.id
- @products[count].push(data)
- @product_amounts[count].push(products[2])
- end
- end
- end
- $data_weapons.each do |data|
- if data != nil
- if products[0] == 'w' && products[1] == data.name
- @products[count].push(data)
- @product_amounts[count].push(products[2])
- elsif products[0] == 'w' && products[1] == data.id
- @products[count].push(data)
- @product_amounts[count].push(products[2])
- end
- end
- end
- $data_armors.each do |data|
- if data != nil
- if products[0] == 'a' && products[1] == data.name
- @products[count].push(data)
- @product_amounts[count].push(products[2])
- elsif products[0] == 'a' && products[1] == data.id
- @products[count].push(data)
- @product_amounts[count].push(products[2])
- end
- end
- end
- end
- count+=1
- end
- end
- def Start_Windows
- @d_items = D_Items_Window.new()
- @d_weapons = D_Weapons_Window.new()
- @d_armors = D_Armors_Window.new()
- @formula_book_items = Formula_book_items.new()
- @formula_book_weapons = Formula_book_weapons.new()
- @formula_book_armors = Formula_book_armors.new()
- @formula_book_all = Formula_book_all.new()
- @d_items.close()
- @d_weapons.close()
- @d_armors.close()
- @formula_book_items.close()
- @formula_book_weapons.close()
- @formula_book_armors.close()
- @formula_book_all.close()
- @cost_pro = Cost_Pro_Window.new(@d_items.x + @d_items.width,0)
- @mix = Mix_Window.new(@d_items.x + @d_items.width,
- @cost_pro.y + @cost_pro.height)
- @menu = Menu_Window.new(@d_items.x + @d_items.width,
- @mix.y + @mix.height)
- @menu.set_handler(:add, method(:com_add))
- @menu.set_handler(:rl, method(:com_rl))
- @menu.set_handler(:reset, method(:com_reset))
- @menu.set_handler(:craft, method(:com_craft))
- @menu.set_handler(:formula_book, method(:com_formula_book))
- @menu.set_handler(:exit, method(:return_scene))
- @menu.activate()
- end
- def com_add
- @cost_pro.reset_stuff()
- @menu.close()
- update until @menu.close?
- @selection_menu = Selection_Menu.new(@d_items.x + @d_items.width,
- @mix.y + @mix.height,@formula_book)
- if @formula_book == true
- @selection_menu.set_handler(:mat_formula_all, method(:com_all))
- end
- @selection_menu.set_handler(:mat_item, method(:com_item))
- @selection_menu.set_handler(:mat_weapon, method(:com_weapon))
- @selection_menu.set_handler(:mat_armor, method(:com_armor))
- @selection_menu.set_handler(:cancel, method(:com_cancel_selection_menu))
- @selection_menu.activate()
- end
- def com_rl
- a=false
- RPG::SE.stop
- if @mix.has_items()
- RPG::SE.new(ICS_Custom_Formula::REMOVE_SOUND,100,100).play
- else
- RPG::SE.new(ICS_Custom_Formula::CANT_CRAFT_SOUND,100,100).play
- a=true
- end
- @current_formula = []
- @cost_pro.reset_stuff()
- @mix.remove_item()
- @menu.activate
- @menu.select(0) if a == true
- end
- def com_reset
- RPG::SE.stop
- if @mix.has_items()
- RPG::SE.new(ICS_Custom_Formula::RESET_SOUND,100,100).play
- else
- RPG::SE.new(ICS_Custom_Formula::CANT_CRAFT_SOUND,100,100).play
- end
- @current_formula = []
- @cost_pro.reset_stuff()
- @mix.mix_reset()
- @menu.activate()
- @menu.select(0)
- end
- def com_craft
- RPG::SE.stop
- @cost_pro.reset_stuff()
- if @mix.has_items && formula_match()
- process_craft()
- @menu.activate()
- else
- RPG::SE.new(ICS_Custom_Formula::CANT_CRAFT_SOUND,100,100).play
- @menu.activate()
- @menu.select(0)
- end
- end
- def com_formula_book
- @mix.close()
- @mix.mix_reset()
- update until @mix.close?
- @cost_pro.height += 100
- @cost_pro.create_contents
- @cost_pro.refresh
- @formula_book = true
- com_add()
- end
- def formula_match
- worked = false
- @current_formula = []
- items = @mix.mix_get_items()
- count=0
- while count < @formula_max
- if items.length == @mats[count].length && items - @mats[count] == []
- @current_formula = count
- return worked = true
- end
- count+=1
- end
- return worked
- end
- def process_craft
- cost = ICS_Custom_Formula::FORMULA[@current_formula][:costs]
- m = ICS_Custom_Formula::FORMULA[@current_formula][:mats]
- tot_amounts = 0
- tot_amounts_in_party = 0
- items = @mix.mix_get_items()
- if @actor.mp >= cost[1] && $game_party.gold >= cost[0] && @actor.tp >= cost[2]
- m.each do |amounts|
- tot_amounts+=amounts[2]
- end
- items.each do |item|
- tot_amounts_in_party+=$game_party.item_number(item)+1
- end
- if tot_amounts_in_party >= tot_amounts
- #Take the items from player inventory
- count2=0
- while count2 < m.length
- a_loss = @amounts[@current_formula][count2]-1
- i_loss = @mats[@current_formula][count2]
- $game_party.lose_item(i_loss,a_loss)
- count2+=1
- end
- count3=0
- #Add the products to the player inventory
- while count3 < @products[@current_formula].length
- $game_party.gain_item(@products[@current_formula][count3],@product_amounts[@current_formula][count3])
- count3+=1
- end
- #Remove the costs
- @actor.mp -= cost[1]
- @actor.tp -= cost[2]
- $game_party.lose_gold(cost[0])
- RPG::SE.new(ICS_Custom_Formula::FORMULA[@current_formula][:sound].to_s,100,100).play
- #set recipe discovered to true
- $game_system.formula_list[@current_formula][:discovered] = true
- $game_system.formula_list[@current_formula][:know_mats] = true
- #clear the mix items
- @mix.mix_clear_items()
- formula_match()
- @mix.draw_mix()
- @menu.select(0)
- return
- else
- @cost_pro.not_enough_items()
- end
- else
- if @actor.mp < cost[1]
- @cost_pro.not_enough_mp()
- end
- if @actor.tp < cost[2]
- @cost_pro.not_enough_tp()
- end
- if $game_party.gold < cost[0]
- @cost_pro.not_enough_gold()
- end
- end
- end
- # selection menu ############################################################
- ###############################################################################
- def com_all
- if @formula_book == true
- @formula_book_all.draw_formulas()
- @formula_book_all.open()
- @formula_book_all.activate()
- @formula_book_all.select(0)
- else
- @selection_menu.activate()
- end
- end
- def com_item
- if $game_party.items != [] && @formula_book == false
- @d_items.open()
- @d_items.draw_items()
- @d_items.activate()
- @d_items.select(0)
- elsif @formula_book == true
- @formula_book_items.draw_formulas()
- @formula_book_items.open()
- @formula_book_items.activate()
- @formula_book_items.select(0)
- else
- @selection_menu.activate()
- end
- end
- def com_weapon
- if $game_party.weapons != [] && @formula_book == false
- @d_weapons.open()
- @d_weapons.draw_weapons()
- @d_weapons.activate()
- @d_weapons.select(0)
- elsif @formula_book == true
- @formula_book_weapons.draw_formulas()
- @formula_book_weapons.open()
- @formula_book_weapons.activate()
- @formula_book_weapons.select(0)
- else
- @selection_menu.activate()
- end
- end
- def com_armor
- if $game_party.armors != [] && @formula_book == false
- @d_armors.open()
- @d_armors.draw_armors()
- @d_armors.activate()
- @d_armors.select(0)
- elsif @formula_book == true
- @formula_book_armors.draw_formulas()
- @formula_book_armors.open()
- @formula_book_armors.activate()
- @formula_book_armors.select(0)
- else
- @selection_menu.activate()
- end
- end
- def com_cancel_selection_menu
- if formula_match
- RPG::SE.new(ICS_Custom_Formula::CORRECT_SOUND,100,100).play
- back_to_main_menu(3)
- elsif @mix.has_items()
- RPG::SE.new(ICS_Custom_Formula::CANCEL_SOUND,100,100).play
- back_to_main_menu(2)
- else
- RPG::SE.new(ICS_Custom_Formula::CANCEL_SOUND,100,100).play
- back_to_main_menu()
- end
- end
- def back_to_selection_menu
- @formula_book_items.unselect()
- @formula_book_items.deactivate()
- @formula_book_items.close()
- @formula_book_weapons.unselect()
- @formula_book_weapons.deactivate()
- @formula_book_weapons.close()
- @formula_book_armors.unselect()
- @formula_book_armors.deactivate()
- @formula_book_armors.close()
- @formula_book_all.unselect()
- @formula_book_all.deactivate()
- @formula_book_all.close()
- @d_items.unselect()
- @d_items.deactivate()
- @d_items.clear()
- @d_items.close()
- @d_weapons.unselect()
- @d_weapons.deactivate()
- @d_weapons.clear()
- @d_weapons.close()
- @d_armors.unselect()
- @d_armors.deactivate()
- @d_armors.clear()
- @d_armors.close()
- @selection_menu.activate()
- end
- def back_to_main_menu(index=0)
- if @cost_pro.height > 150
- @cost_pro.height -= 100
- @cost_pro.create_contents
- @cost_pro.refresh
- end
- @mix.open()
- update until @mix.open?
- @formula_book_items.unselect()
- @formula_book_items.deactivate()
- @formula_book_items.close()
- @formula_book_weapons.unselect()
- @formula_book_weapons.deactivate()
- @formula_book_weapons.close()
- @formula_book_armors.unselect()
- @formula_book_armors.deactivate()
- @formula_book_armors.close()
- @formula_book_all.unselect()
- @formula_book_all.deactivate()
- @formula_book_all.close()
- @formula_book = false
- @d_items.unselect()
- @d_items.deactivate()
- @d_items.clear()
- @d_items.close()
- @d_weapons.unselect()
- @d_weapons.deactivate()
- @d_weapons.clear()
- @d_weapons.close()
- @d_armors.unselect()
- @d_armors.deactivate()
- @d_armors.clear()
- @d_armors.close()
- @selection_menu.close()
- @selection_menu.deactivate()
- update until @selection_menu.close?
- @menu.open()
- @menu.activate()
- @menu.select(index)
- end
- def add_item_to_mix(item = 'none')
- $game_party.lose_item(item, 1)
- @mix.add_in(item)
- end
- def get_formula
- formula_match()
- return @current_formula
- end
- def update
- super()
- if @menu.active
- return_scene() if Input.trigger?(:B)
- end
- if @d_items.active()
- item = ($game_party.items[@d_items.index]) #item is = to the index
- @cost_pro.display_cost_item(item)
- elsif @d_weapons.active()
- item = ($game_party.weapons[@d_weapons.index])
- @cost_pro.display_cost_item(item)
- elsif @d_armors.active()
- item = ($game_party.armors[@d_armors.index])
- @cost_pro.display_cost_item(item)
- elsif @formula_book_items.active()
- @cost_pro.display_formula_req(@formula_book_items.get_current_formula)
- elsif @formula_book_weapons.active()
- @cost_pro.display_formula_req(@formula_book_weapons.get_current_formula)
- elsif @formula_book_armors.active()
- @cost_pro.display_formula_req(@formula_book_armors.get_current_formula)
- elsif @formula_book_all.active()
- @cost_pro.display_formula_req(@formula_book_all.get_current_formula)
- else
- @cost_pro.clear_me()
- end
- if Input.trigger?(:B) && (@d_items.active() || @d_weapons.active() || @d_armors.active())
- RPG::SE.new(ICS_Custom_Formula::CANCEL_SOUND,100,100).play
- back_to_selection_menu()
- elsif Input.trigger?(:C) && (@d_items.active() || @d_weapons.active() || @d_armors.active())
- if @mix.mix_full || @mix.same_item(item)#if mix has more than 6 items alrdy quit
- back_to_selection_menu()
- else
- RPG::SE.new(ICS_Custom_Formula::ADD_SOUND,100,100).play
- add_item_to_mix(item)
- back_to_selection_menu()
- end
- elsif Input.trigger?(:C) && (@formula_book_items.active() || @formula_book_weapons.active() || @formula_book_armors.active() || @formula_book_all.active())
- temp_items = @formula_book_items.get_items if @formula_book_items.active()
- temp_items = @formula_book_weapons.get_items if @formula_book_weapons.active()
- temp_items = @formula_book_armors.get_items if @formula_book_armors.active()
- temp_items = @formula_book_all.get_items if @formula_book_all.active()
- if temp_items != []
- @mix.mix_reset()
- temp_items.each do |item|
- if $game_party.item_number(item) > 0
- RPG::SE.new(ICS_Custom_Formula::ADD_SOUND,100,100).play
- add_item_to_mix(item)
- else
- @mix.mix_reset()
- RPG::SE.new(ICS_Custom_Formula::CANT_CRAFT_SOUND,100,100).play
- return
- end
- end
- back_to_main_menu(3)
- else
- @mix.mix_reset()
- RPG::SE.new(ICS_Custom_Formula::CANT_CRAFT_SOUND,100,100).play
- end
- elsif Input.trigger?(:B) && (@formula_book_items.active() || @formula_book_weapons.active() || @formula_book_armors.active() || @formula_book_all.active())
- RPG::SE.new(ICS_Custom_Formula::CANCEL_SOUND,100,100).play
- back_to_selection_menu()
- end
- end
- def terminate
- super()
- @mix.mix_drain() if @mix
- @d_items.dispose()
- @d_weapons.dispose()
- @d_armors.dispose()
- @cost_pro.dispose()
- @mix.dispose()
- @menu.dispose()
- @selection_menu.dispose() if @selection_menu
- @formula_book_items.dispose()
- @formula_book_weapons.dispose()
- @formula_book_armors.dispose()
- @formula_book_all.dispose()
- end
- end
- ####################################################################
- ####################################################################
- class D_Items_Window < Window_Selectable
- def initialize()
- super(0,0,Graphics.width / 2, Graphics.height)
- end
- def col_max
- return 1
- end
- def clear
- contents.clear()
- end
- def item_max()
- count = 0
- for key in $game_party.items
- count += 1
- end
- return count
- end
- def draw_items
- row = 0
- for item in $game_party.items
- draw_icon(item.icon_index, 0, row * 24, true)
- draw_text_ex(26, row * 24, item.name)
- x = $game_party.item_number(item)
- draw_text_ex((self.x + self.width)-64, row*24,x)
- row += 1
- end
- end
- end
- class D_Weapons_Window < Window_Selectable
- def initialize()
- super(0,0,Graphics.width / 2, Graphics.height)
- end
- def col_max
- return 1
- end
- def clear
- contents.clear()
- end
- def item_max
- count = 0
- for key in $game_party.weapons
- count += 1
- end
- return count
- end
- def draw_weapons
- row = 0
- for item in $game_party.weapons
- draw_icon(item.icon_index, 0, row * 24, true)
- draw_text_ex(26, row * 24, item.name)
- x = $game_party.item_number(item)
- draw_text_ex((self.x + self.width)-64, row*24,x)
- row += 1
- end
- end
- end
- class D_Armors_Window < Window_Selectable
- def initialize()
- super(0,0,Graphics.width / 2, Graphics.height)
- end
- def col_max
- return 1
- end
- def clear
- contents.clear()
- end
- def item_max()
- count = 0
- for key in $game_party.armors
- count += 1
- end
- return count
- end
- def draw_armors
- row = 0
- for item in $game_party.armors
- draw_icon(item.icon_index, 0, row * 24, true)
- draw_text_ex(26, row * 24, item.name)
- x = $game_party.item_number(item)
- draw_text_ex((self.x + self.width)-64, row*24,x)
- row += 1
- end
- end
- end
- class Cost_Pro_Window < Window_Selectable
- def initialize(x,y)
- @not_enough_items = false
- @need_mp = false
- @need_tp = false
- @need_gold = false
- super(x,y,Graphics.width-x,150)
- end
- def display_formula_req(formula_display)
- clear_me()
- if $game_system.formula_list[formula_display][:know_mats] == true
- y=26
- colors = ICS_Custom_Formula::COLORS
- count=0
- ICS_Custom_Formula::FORMULA[formula_display][:mats].each do |mat|
- if mat[1].is_a?(Integer)
- req = $data_items[mat[1]] if mat[0] == 'i'
- req = $data_weapons[mat[1]] if mat[0] == 'w'
- req = $data_armors[mat[1]] if mat[0] == 'a'
- elsif mat[0] == 'i' && mat[1].is_a?(String)
- count=1
- while count<$data_items.length
- if mat[1] == $data_items[count].name
- req = $data_items[count]
- end
- count+=1
- end
- elsif mat[0] == 'w' && mat[1].is_a?(String)
- count=1
- while count<$data_weapons.length
- if mat[1] == $data_weapons[count].name
- req = $data_weapons[count]
- end
- count+=1
- end
- elsif mat[0] == 'a' && mat[1].is_a?(String)
- count=1
- while count<$data_armors.length
- if mat[1] == $data_armors[count].name
- req = $data_armors[count]
- end
- count+=1
- end
- end
- if $game_party.item_number(req) >= mat[2]
- draw_text_ex(0,0,'Requires:')
- change_color(text_color(colors[4]))
- draw_icon(req.icon_index,0,y,true)
- contents.draw_text(20,y,300,26,req.name + ' x' + mat[2].to_s)
- else
- draw_text_ex(0,0,'Requires:')
- change_color(text_color(colors[5]))
- draw_icon(req.icon_index,0,y,true)
- contents.draw_text(20,y,300,26,req.name + ' x' + mat[2].to_s)
- end
- y+=26
- end
- else
- draw_text_ex(0,0,'??????')
- end
- end
- def clear_me
- contents.clear()
- if @not_enough_items == true
- draw_text_ex(0,0,'\C[10]Not enough items in Inventory\C[0]')
- end
- if @need_gold == true
- draw_text_ex(0,0,'\C[10]Not enough Gold\C[0]')
- end
- if @need_mp == true
- draw_text_ex(0,25,'\C[10]Not enough Mp\C[0]')
- end
- if @need_tp == true
- draw_text_ex(0,50,'\C[10]Not enough Tp\C[0]')
- end
- end
- def display_cost_item(item = 'none')
- clear_me()
- draw_text_ex(0,0,item.name)
- draw_text_ex(0,26,item.description)
- end
- def not_enough_items
- @not_enough_items = true
- clear_me()
- end
- def not_enough_gold
- @need_gold = true
- end
- def not_enough_mp
- @need_mp = true
- end
- def not_enough_tp
- @need_tp = true
- end
- def reset_stuff
- @not_enough_items = false
- @need_gold = false
- @need_tp = false
- @need_mp = false
- end
- end
- class Mix_Window < Window_Selectable
- def initialize(x,y)
- @items = []
- super(x,y,Graphics.width-x,100)
- end
- def add_in(item)
- @items.push(item)
- draw_mix()
- end
- def mix_full
- if @items.length >= 6
- return true
- else
- return false
- end
- end
- def same_item(item)
- @items.each do |compare_item|
- if item == compare_item
- RPG::SE.new(ICS_Custom_Formula::CANT_CRAFT_SOUND,100,100).play
- return true
- end
- end
- return false
- end
- def has_items
- return true if @items != []
- return false
- end
- def draw_mix()
- contents.clear()
- col = 0
- for p in @items
- draw_icon(p.icon_index, col * 32, 0, true)
- col += 1
- end
- formula_number = SceneManager.scene.get_formula
- if formula_number != nil && formula_number != []
- formula_name = ICS_Custom_Formula::FORMULA[formula_number][:name][0,24]
- formula_costs = ICS_Custom_Formula::FORMULA[formula_number][:costs]
- colors = ICS_Custom_Formula::COLORS
- #This Draws the Cost of the formula below the Materials
- contents.draw_text(0,24,200,40,formula_name)
- x = self.width / 3
- change_color(text_color(colors[1]))
- contents.draw_text(0,45,200,40,formula_costs[0].to_s)
- change_color(text_color(colors[2]))
- contents.draw_text(x,45,200,40,formula_costs[1].to_s)
- change_color(text_color(colors[3]))
- contents.draw_text(x*2,45,200,40,formula_costs[2].to_s)
- change_color(normal_color)
- end
- end
- def remove_item
- if @items != []
- $game_party.gain_item(@items[-1],1)
- @items.delete_at(-1)
- draw_mix()
- end
- end
- def mix_drain #used to give back items in case of termination
- if @items != []
- for item in @items
- $game_party.gain_item(item,1)
- end
- @items = []
- end
- end
- def mix_reset
- if @items != []
- for item in @items
- $game_party.gain_item(item,1)
- end
- @items = []
- draw_mix()
- end
- end
- def mix_clear_items
- @items = []
- end
- def mix_get_items
- return @items
- end
- end#class
- class Menu_Window < Window_Command
- def initialize(x,y)
- @width = Graphics.width-x
- super(x,y)
- end
- def make_command_list
- add_command("Add", :add)
- add_command("Remove Last", :rl)
- add_command("Reset All", :reset)
- add_command("Craft!", :craft)
- add_command(ICS_Custom_Formula::FORMULA_BOOK_NAME, :formula_book)
- add_command("Exit", :exit)
- end
- def window_width
- return @width
- end
- end
- class Selection_Menu < Window_Command
- def initialize(x,y,formula_book)
- @formula_book = formula_book
- @width = Graphics.width-x
- super(x,y)
- end
- def make_command_list
- if @formula_book == true
- add_command("All", :mat_formula_all)
- end
- add_command("Item", :mat_item)
- add_command("Weapon", :mat_weapon)
- add_command("Armor", :mat_armor)
- add_command("Cancel", :cancel)
- end
- def window_width
- return @width
- end
- end
- class Formula_book_weapons < Window_Selectable
- def initialize
- super(0,0,Graphics.width / 2, Graphics.height)
- @set_items = []
- @draw_formula_list = []
- @current_formula = 0
- @formula_list = ICS_Custom_Formula::FORMULA
- draw_formulas()
- end
- def get_items
- @set_items = []
- if $game_system.formula_list[@draw_formula_list[index]][:discovered] == true && @formula_list[@draw_formula_list[index]][:know_mats] == true
- @formula_list[@draw_formula_list[index]][:mats].each do |mat|
- if mat[1].is_a?(String) && mat[0] == 'w'
- $data_weapons.each do |data|
- if data != nil
- if mat[1] == data.name
- @set_items.push(data)
- end
- end
- end
- elsif mat[1].is_a?(String) && mat[0] == 'i'
- $data_items.each do |data|
- if data != nil
- if mat[1] == data.name
- @set_items.push(data)
- end
- end
- end
- elsif mat[1].is_a?(String) && mat[0] == 'a'
- $data_armors.each do |data|
- if data != nil
- if mat[1] == data.name
- @set_items.push(data)
- end
- end
- end
- elsif mat[1].is_a?(Integer) && mat[0] == 'i'
- @set_items.push($data_items[mat[1]])
- elsif mat[1].is_a?(Integer) && mat[0] == 'a'
- @set_items.push($data_armors[mat[1]])
- elsif mat[1].is_a?(Integer) && mat[0] == 'w'
- @set_items.push($data_weapons[mat[1]])
- end
- end
- else
- @set_items = []
- end
- return @set_items
- end
- def item_max()
- count = 0
- ICS_Custom_Formula::FORMULA.each do |formula|
- if formula[:products][0][0] == 'w'
- count +=1
- end
- end
- return count
- end
- def item_height
- return 60
- end
- def get_current_formula
- return @draw_formula_list[self.index]
- end
- def draw_formulas
- contents.clear()
- formula_list = []
- x = self.width / 3
- y = 0
- count = 0
- t_width = Graphics.width
- colors = ICS_Custom_Formula::COLORS
- @formula_list.each do |formula|
- if formula[:discovered] == true
- if formula[:products][0][0] == 'w'
- contents.draw_text(5,y,t_width,line_height,formula[:name])
- change_color(text_color(colors[1]))
- contents.draw_text(5,y+30,t_width,line_height,formula[:costs][0])
- change_color(text_color(colors[2]))
- contents.draw_text(x,y+30,t_width,line_height, formula[:costs][1])
- change_color(text_color(colors[3]))
- contents.draw_text(x*2,y+30,t_width,line_height, formula[:costs][2])
- change_color(normal_color)
- @draw_formula_list.push(count)
- y+=60
- end
- elsif formula[:products][0][0] == 'w' && formula[:discovered] == false
- contents.draw_text(5,y,t_width,line_height,'??????')
- @draw_formula_list.push(count)
- y+=60
- end
- count+=1
- end
- end
- end #class
- class Formula_book_items < Window_Selectable
- def initialize
- super(0,0,Graphics.width / 2, Graphics.height)
- @set_items = []
- @draw_formula_list = []
- @current_formula = 0
- @formula_list = ICS_Custom_Formula::FORMULA
- draw_formulas()
- end
- def get_items
- @set_items = []
- if $game_system.formula_list[@draw_formula_list[index]][:discovered] == true && @formula_list[@draw_formula_list[index]][:know_mats] == true
- @formula_list[@draw_formula_list[index]][:mats].each do |mat|
- if mat[1].is_a?(String) && mat[0] == 'w'
- $data_weapons.each do |data|
- if data != nil
- if mat[1] == data.name
- @set_items.push(data)
- end
- end
- end
- elsif mat[1].is_a?(String) && mat[0] == 'i'
- $data_items.each do |data|
- if data != nil
- if mat[1] == data.name
- @set_items.push(data)
- end
- end
- end
- elsif mat[1].is_a?(String) && mat[0] == 'a'
- $data_armors.each do |data|
- if data != nil
- if mat[1] == data.name
- @set_items.push(data)
- end
- end
- end
- elsif mat[1].is_a?(Integer) && mat[0] == 'i'
- @set_items.push($data_items[mat[1]])
- elsif mat[1].is_a?(Integer) && mat[0] == 'a'
- @set_items.push($data_armors[mat[1]])
- elsif mat[1].is_a?(Integer) && mat[0] == 'w'
- @set_items.push($data_weapons[mat[1]])
- end
- end
- else
- @set_items = []
- end
- return @set_items
- end
- def item_max()
- count = 0
- ICS_Custom_Formula::FORMULA.each do |formula|
- if formula[:products][0][0] == 'i'
- count +=1
- end
- end
- return count
- end
- def item_height
- return 60
- end
- def get_current_formula
- return @draw_formula_list[self.index]
- end
- def draw_formulas
- contents.clear()
- formula_list = []
- x = self.width / 3
- y = 0
- count = 0
- t_width = Graphics.width
- colors = ICS_Custom_Formula::COLORS
- @formula_list.each do |formula|
- if formula[:discovered] == true
- if formula[:products][0][0] == 'i'
- contents.draw_text(5,y,t_width,line_height,formula[:name])
- change_color(text_color(colors[1]))
- contents.draw_text(5,y+30,t_width,line_height,formula[:costs][0])
- change_color(text_color(colors[2]))
- contents.draw_text(x,y+30,t_width,line_height, formula[:costs][1])
- change_color(text_color(colors[3]))
- contents.draw_text(x*2,y+30,t_width,line_height, formula[:costs][2])
- change_color(normal_color)
- @draw_formula_list.push(count)
- y+=60
- end
- elsif formula[:products][0][0] == 'i' && formula[:discovered] == false
- contents.draw_text(5,y,t_width,line_height,'??????')
- @draw_formula_list.push(count)
- y+=60
- end
- count+=1
- end
- end
- end #class
- class Formula_book_armors < Window_Selectable
- def initialize
- super(0,0,Graphics.width / 2, Graphics.height)
- @set_items = []
- @draw_formula_list = []
- @current_formula = 0
- @formula_list = ICS_Custom_Formula::FORMULA
- draw_formulas()
- end
- def get_items
- @set_items = []
- if $game_system.formula_list[@draw_formula_list[index]][:discovered] == true && @formula_list[@draw_formula_list[index]][:know_mats] == true
- @formula_list[@draw_formula_list[index]][:mats].each do |mat|
- if mat[1].is_a?(String) && mat[0] == 'w'
- $data_weapons.each do |data|
- if data != nil
- if mat[1] == data.name
- @set_items.push(data)
- end
- end
- end
- elsif mat[1].is_a?(String) && mat[0] == 'i'
- $data_items.each do |data|
- if data != nil
- if mat[1] == data.name
- @set_items.push(data)
- end
- end
- end
- elsif mat[1].is_a?(String) && mat[0] == 'a'
- $data_armors.each do |data|
- if data != nil
- if mat[1] == data.name
- @set_items.push(data)
- end
- end
- end
- elsif mat[1].is_a?(Integer) && mat[0] == 'i'
- @set_items.push($data_items[mat[1]])
- elsif mat[1].is_a?(Integer) && mat[0] == 'a'
- @set_items.push($data_armors[mat[1]])
- elsif mat[1].is_a?(Integer) && mat[0] == 'w'
- @set_items.push($data_weapons[mat[1]])
- end
- end
- else
- @set_items = []
- end
- return @set_items
- end
- def item_max()
- count = 0
- ICS_Custom_Formula::FORMULA.each do |formula|
- if formula[:products][0][0] == 'a'
- count +=1
- end
- end
- return count
- end
- def item_height
- return 60
- end
- def get_current_formula
- return @draw_formula_list[self.index]
- end
- def draw_formulas
- contents.clear()
- formula_list = []
- x = self.width / 3
- y = 0
- count = 0
- t_width = Graphics.width
- colors = ICS_Custom_Formula::COLORS
- @formula_list.each do |formula|
- if formula[:discovered] == true
- if formula[:products][0][0] == 'a'
- contents.draw_text(5,y,t_width,line_height,formula[:name])
- change_color(text_color(colors[1]))
- contents.draw_text(5,y+30,t_width,line_height,formula[:costs][0])
- change_color(text_color(colors[2]))
- contents.draw_text(x,y+30,t_width,line_height, formula[:costs][1])
- change_color(text_color(colors[3]))
- contents.draw_text(x*2,y+30,t_width,line_height, formula[:costs][2])
- change_color(normal_color)
- @draw_formula_list.push(count)
- y+=60
- end
- elsif formula[:products][0][0] == 'a' && formula[:discovered] == false
- contents.draw_text(5,y,t_width,line_height,'??????')
- @draw_formula_list.push(count)
- y+=60
- end
- count+=1
- end
- end
- end #class
- class Formula_book_all < Window_Selectable
- def initialize
- super(0,0,Graphics.width / 2, Graphics.height)
- @set_items = []
- @draw_formula_list = []
- @current_formula = 0
- @formula_list = ICS_Custom_Formula::FORMULA
- draw_formulas()
- end
- def get_items
- @set_items = []
- if $game_system.formula_list[@draw_formula_list[index]][:discovered] == true && @formula_list[@draw_formula_list[index]][:know_mats] == true
- @formula_list[@draw_formula_list[index]][:mats].each do |mat|
- if mat[1].is_a?(String) && mat[0] == 'w'
- $data_weapons.each do |data|
- if data != nil
- if mat[1] == data.name
- @set_items.push(data)
- end
- end
- end
- elsif mat[1].is_a?(String) && mat[0] == 'i'
- $data_items.each do |data|
- if data != nil
- if mat[1] == data.name
- @set_items.push(data)
- end
- end
- end
- elsif mat[1].is_a?(String) && mat[0] == 'a'
- $data_armors.each do |data|
- if data != nil
- if mat[1] == data.name
- @set_items.push(data)
- end
- end
- end
- elsif mat[1].is_a?(Integer) && mat[0] == 'i'
- @set_items.push($data_items[mat[1]])
- elsif mat[1].is_a?(Integer) && mat[0] == 'a'
- @set_items.push($data_armors[mat[1]])
- elsif mat[1].is_a?(Integer) && mat[0] == 'w'
- @set_items.push($data_weapons[mat[1]])
- end
- end
- else
- @set_items = []
- end
- return @set_items
- end
- def item_max()
- count = 0
- ICS_Custom_Formula::FORMULA.each do |formula|
- count +=1
- end
- return count
- end
- def item_height
- return 60
- end
- def get_current_formula
- return @draw_formula_list[self.index]
- end
- def draw_formulas
- contents.clear()
- formula_list = []
- x = self.width / 3
- y = 0
- count = 0
- t_width = Graphics.width
- colors = ICS_Custom_Formula::COLORS
- @formula_list.each do |formula|
- if formula[:discovered] == true
- if formula[:products][0][0] == 'a' || formula[:products][0][0] == 'i' || formula[:products][0][0] == 'w'
- contents.draw_text(5,y,t_width,line_height,formula[:name])
- change_color(text_color(colors[1]))
- contents.draw_text(5,y+30,t_width,line_height,formula[:costs][0])
- change_color(text_color(colors[2]))
- contents.draw_text(x,y+30,t_width,line_height, formula[:costs][1])
- change_color(text_color(colors[3]))
- contents.draw_text(x*2,y+30,t_width,line_height, formula[:costs][2])
- change_color(normal_color)
- @draw_formula_list.push(count)
- y+=60
- end
- elsif (formula[:products][0][0] == 'a' || formula[:products][0][0] == 'i' || formula[:products][0][0] == 'w') && formula[:discovered] == false
- contents.draw_text(5,y,t_width,line_height,'??????')
- @draw_formula_list.push(count)
- y+=60
- end
- count+=1
- end
- end
- end #class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement