Advertisement
nightowl79a

ICS_0.1

Nov 30th, 2013
1,130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 41.80 KB | None | 0 0
  1. #################################################################################
  2. #################################################################################
  3.             #Nightowl79a Iconic Crafting System#
  4.             #     V 0.5  7/3/13                #
  5. #################################################################################
  6. #################################################################################
  7. ##################################################
  8. #     Channel Log
  9. #     V 0.5
  10. #         Initial release
  11. #-------------------------------------------------------------------------------#
  12. #Things planned for the future:
  13. #   chance to fail / bonus items when crafting
  14. #   animation upon crafting
  15. #   backround images
  16. #   restrictions on crafting items based on profession
  17.  
  18. #Instructions:
  19. #Install below Materials above Main
  20. #
  21. #To call this script use
  22. #
  23. #  SceneManager.call(ICS)
  24. #
  25. #This can either be put in a event script call or something like Yanfly's Custom
  26. #menu
  27. #
  28. #Formulas, must be set up very specificly to work properly follow this format
  29. #exactly.
  30. #
  31. #  FORMULA[0] = {
  32. #    :name => '5x Elixir Formula',                        
  33. #    :mats => [['i',1,10],['i',2,1]],
  34. #    :products => [['i',8,20]],
  35. #    :costs => [0,0,0],
  36. #    :sound => "Hammer",
  37. #    :discovered => true,
  38. #    :know_mats => true
  39. #    }  
  40. #
  41. # :name => is the name of the formula the name should be less than 24 leters
  42. #          and in a '' or ""
  43. #
  44. # :mats => is each material need to make the formula. the first part('i') is
  45. #          the type of item of the material. Use
  46. #          'i'  or  'a' or  'w'
  47. #          
  48. #          The second part(1) is the name of the material. You can use either
  49. #          the number of the item from the database or you can use the name of
  50. #          the item. ex 'Potion' Must be in "" or ''.
  51. #
  52. #          The third part(10) is the amount of the item the material requires.
  53. #          Only if the user has this many of the item in thier invetory will
  54. #          they be able to craft the item.
  55. #                    
  56. #          You can have up to 6 materials following this format:
  57. #          [['i',1,1],['i',2,1],['a',1,1],['i','Potion',1]]
  58. #          Make sure to seperate each material with a comma.
  59. #
  60. # :products => is each product if the user supplies the correct materials.
  61. #              Follow the same format as used with the :mats.
  62. #              rembmer:   [[type,name,amount],[type,name,amount]]
  63. #  
  64. # :costs => is the gold, mana and tp cost of the material in that order.
  65. #           eg. costs [10,20,30] would mean the formula will cost
  66. #           10 gold, 20 mana, 30 tp. If left at 0 the user will only need the
  67. #           items.
  68. #
  69. # :sound => is the sound played when the formula is made. Make sure you use
  70. #           "" around it.
  71. #
  72. # :discovered => is weather the formula is the formula book or not at the start of
  73. #                the game. When a formula is made for the fisrt time
  74. #                it is added to the formula book automatically.
  75. #
  76. #                
  77. # :know_mats => determains if the required materials are hidden in the formula
  78. #               book at the start of the game. When a formula is made for the
  79. #               first time it's materials are unhidden in the formula book
  80. #               automatically.
  81. module ICS_Custom_Formula
  82.  
  83.   ADD_SOUND               = 'Item1'
  84.   CANCEL_SOUND            = 'Miss'
  85.   CANT_CRAFT_SOUND        = 'Attack1'
  86.   CORRECT_SOUND           = 'Bell3'
  87.   REMOVE_SOUND            = 'Blow1'
  88.   RESET_SOUND             = 'Item2'
  89.  
  90.   FORMULA_BOOK_NAME       = 'Formula Book'
  91.  
  92.   COLORS                  = [12,6,1,2,3,10]
  93.   #name color, gold color, mana color, tp color, good color, out color
  94.  
  95.   FORMULA = []
  96.  
  97. ##############################################################
  98.  
  99.   FORMULA[0] = {
  100.     :name => '5x Elixir Formula',                        #name should be < 24 chr
  101.     :mats => [['i',1,10],['i',2,1]],
  102.     :products => [['i',8,5]],
  103.     :costs => [0,0,0],
  104.     :sound => "Hammer",
  105.     :discovered => true,
  106.     :know_mats => true
  107.     }  
  108.   FORMULA[1] = {
  109.     :name => 'Poison Cure Formula',
  110.     :mats => [['i','Magic Water',1]],
  111.     :products => [['i','Poison Cure',1]],
  112.     :costs => [0,0,0],
  113.     :sound => "Hammer",
  114.     :discovered => true,
  115.     :know_mats => true
  116.     }
  117.   FORMULA[2] = {
  118.     :name => 'Potion Ax Formula',
  119.     :mats => [['w','Hand Ax',1],['i','Potion',1]],
  120.     :products => [['w','Potion Ax',1]],
  121.     :costs => [0,0,0],
  122.     :sound => "Hammer",
  123.     :discovered => true,
  124.     :know_mats => true
  125.     }
  126.   FORMULA[3] = {
  127.     :name => 'Potion Ax BreakDown',
  128.     :mats => [['w','Potion Ax',1]],
  129.     :products => [['w','Hand Ax',1],['i','Potion',1]],
  130.     :costs => [0,10,0],
  131.     :sound => "Hammer",
  132.     :discovered => true,
  133.     :know_mats => true
  134.     }
  135.   FORMULA[4] = {
  136.     :name => 'Armor Upgrade',
  137.     :mats => [['a','Casual Clothes',1],['i','Life Up',1]],
  138.     :products => [['a',4,1],['a','Brigandine',1]],
  139.     :costs => [0,10,0],
  140.     :sound => "Hammer",
  141.     :discovered => true,
  142.     :know_mats => true
  143.     }
  144.   FORMULA[5] = {
  145.     :name => 'Great Armor',
  146.     :mats => [['i','Stim',1],['a',1,1]],
  147.     :products => [['a','Talisman of Light',1]],
  148.     :costs => [0,10,0],
  149.     :sound => "Hammer",
  150.     :discovered => true,
  151.     :know_mats => true
  152.     }
  153. end
  154.  
  155. class Game_System
  156.   attr_accessor :formula_list
  157. alias NO79a_ICS_Game_system_initialize initialize
  158.   def initialize
  159.     @formula_list = ICS_Custom_Formula::FORMULA
  160.     NO79a_ICS_Game_system_initialize()
  161.   end
  162. end
  163.  
  164. class ICS < Scene_MenuBase
  165.  
  166.   def start
  167.     super()
  168.     @formula_book = false
  169.     Convert_Formulas()
  170.     Start_Windows()
  171.   end
  172.   def Convert_Formulas
  173.     @formula_max = ICS_Custom_Formula::FORMULA.length
  174.     @name             = []
  175.     @mats             = []
  176.     @current_formula  = []
  177.     @amounts          = []
  178.     @products         = []
  179.     @product_amounts  = []
  180.     count=0
  181.     ICS_Custom_Formula::FORMULA.each do |custom_formula|
  182.      
  183.       @name[count]             = custom_formula[:name]
  184.       @mats[count]             = []
  185.       @amounts[count]          = []
  186.       @products[count]         = []
  187.       @product_amounts[count]  = []
  188.      
  189.       custom_formula[:mats].each do |mats|
  190.         $data_items.each do |data|
  191.           if data != nil
  192.             if mats[0] == 'i' && mats[1] == data.name
  193.               @mats[count].push(data)
  194.               @amounts[count].push(mats[2])
  195.             elsif mats[0] == 'i' && mats[1] == data.id
  196.               @mats[count].push(data)
  197.               @amounts[count].push(mats[2])
  198.             end
  199.           end
  200.         end
  201.         $data_weapons.each do |data|
  202.           if data != nil
  203.             if mats[0] == 'w' && mats[1] == data.name
  204.               @mats[count].push(data)
  205.               @amounts[count].push(mats[2])
  206.             elsif mats[0] == 'w' && mats[1] == data.id
  207.               @mats[count].push(data)
  208.               @amounts[count].push(mats[2])
  209.             end
  210.           end
  211.         end
  212.         $data_armors.each do |data|
  213.           if data != nil
  214.             if mats[0] == 'a' && mats[1] == data.name
  215.               @mats[count].push(data)
  216.               @amounts[count].push(mats[2])
  217.             elsif mats[0] == 'a' && mats[1] == data.id
  218.               @mats[count].push(data)
  219.               @amounts[count].push(mats[2])
  220.             end
  221.           end
  222.         end
  223.       end
  224.      
  225.       custom_formula[:products].each do |products|
  226.         $data_items.each do |data|
  227.           if data != nil
  228.             if products[0] == 'i' && products[1] == data.name
  229.               @products[count].push(data)
  230.               @product_amounts[count].push(products[2])
  231.             elsif products[0] == 'i' && products[1] == data.id
  232.               @products[count].push(data)
  233.               @product_amounts[count].push(products[2])
  234.             end
  235.           end
  236.         end
  237.         $data_weapons.each do |data|
  238.           if data != nil
  239.             if products[0] == 'w' && products[1] == data.name
  240.               @products[count].push(data)
  241.               @product_amounts[count].push(products[2])
  242.             elsif products[0] == 'w' && products[1] == data.id
  243.               @products[count].push(data)
  244.               @product_amounts[count].push(products[2])
  245.             end
  246.           end
  247.         end
  248.         $data_armors.each do |data|
  249.           if data != nil
  250.             if products[0] == 'a' && products[1] == data.name
  251.               @products[count].push(data)
  252.               @product_amounts[count].push(products[2])
  253.             elsif products[0] == 'a' && products[1] == data.id
  254.               @products[count].push(data)
  255.               @product_amounts[count].push(products[2])
  256.             end
  257.           end
  258.         end
  259.       end
  260.      
  261.       count+=1
  262.     end
  263.   end
  264.  
  265.   def Start_Windows
  266.     @d_items                   =  D_Items_Window.new()
  267.     @d_weapons                 =  D_Weapons_Window.new()
  268.     @d_armors                  =  D_Armors_Window.new()
  269.     @formula_book_items        = Formula_book_items.new()
  270.     @formula_book_weapons      = Formula_book_weapons.new()
  271.     @formula_book_armors       = Formula_book_armors.new()
  272.     @formula_book_all          = Formula_book_all.new()
  273.    
  274.     @d_items.close()
  275.     @d_weapons.close()
  276.     @d_armors.close()
  277.     @formula_book_items.close()
  278.     @formula_book_weapons.close()
  279.     @formula_book_armors.close()
  280.     @formula_book_all.close()
  281.    
  282.     @cost_pro = Cost_Pro_Window.new(@d_items.x + @d_items.width,0)
  283.  
  284.     @mix = Mix_Window.new(@d_items.x + @d_items.width,
  285.                           @cost_pro.y + @cost_pro.height)
  286.    
  287.     @menu = Menu_Window.new(@d_items.x + @d_items.width,
  288.                             @mix.y + @mix.height)
  289.                            
  290.     @menu.set_handler(:add,          method(:com_add))
  291.     @menu.set_handler(:rl,           method(:com_rl))
  292.     @menu.set_handler(:reset,        method(:com_reset))
  293.     @menu.set_handler(:craft,        method(:com_craft))
  294.     @menu.set_handler(:formula_book, method(:com_formula_book))
  295.     @menu.set_handler(:exit,         method(:return_scene))
  296.     @menu.activate()
  297.    
  298.    
  299.   end
  300.  
  301.   def com_add
  302.     @cost_pro.reset_stuff()
  303.     @menu.close()
  304.     update until @menu.close?
  305.     @selection_menu = Selection_Menu.new(@d_items.x + @d_items.width,
  306.                                           @mix.y + @mix.height,@formula_book)
  307.     if @formula_book == true
  308.       @selection_menu.set_handler(:mat_formula_all, method(:com_all))
  309.     end
  310.     @selection_menu.set_handler(:mat_item,      method(:com_item))
  311.     @selection_menu.set_handler(:mat_weapon,    method(:com_weapon))
  312.     @selection_menu.set_handler(:mat_armor,     method(:com_armor))
  313.     @selection_menu.set_handler(:cancel,        method(:com_cancel_selection_menu))
  314.     @selection_menu.activate()
  315.    
  316.   end
  317.  
  318.   def com_rl
  319.     a=false
  320.     RPG::SE.stop
  321.     if @mix.has_items()
  322.       RPG::SE.new(ICS_Custom_Formula::REMOVE_SOUND,100,100).play
  323.     else
  324.       RPG::SE.new(ICS_Custom_Formula::CANT_CRAFT_SOUND,100,100).play
  325.       a=true
  326.     end
  327.     @current_formula = []
  328.     @cost_pro.reset_stuff()
  329.     @mix.remove_item()
  330.     @menu.activate
  331.     @menu.select(0) if a == true
  332.   end
  333.  
  334.   def com_reset
  335.     RPG::SE.stop
  336.     if @mix.has_items()
  337.       RPG::SE.new(ICS_Custom_Formula::RESET_SOUND,100,100).play
  338.     else
  339.       RPG::SE.new(ICS_Custom_Formula::CANT_CRAFT_SOUND,100,100).play
  340.     end
  341.     @current_formula = []
  342.     @cost_pro.reset_stuff()
  343.     @mix.mix_reset()
  344.     @menu.activate()
  345.     @menu.select(0)
  346.   end
  347.  
  348.   def com_craft
  349.     RPG::SE.stop
  350.     @cost_pro.reset_stuff()
  351.     if @mix.has_items && formula_match()
  352.       process_craft()
  353.       @menu.activate()
  354.     else
  355.       RPG::SE.new(ICS_Custom_Formula::CANT_CRAFT_SOUND,100,100).play
  356.       @menu.activate()
  357.       @menu.select(0)
  358.     end  
  359.   end
  360.  
  361.   def com_formula_book
  362.     @mix.close()
  363.     @mix.mix_reset()
  364.     update until @mix.close?
  365.     @cost_pro.height += 100
  366.     @cost_pro.create_contents
  367.     @cost_pro.refresh
  368.  
  369.     @formula_book = true
  370.     com_add()
  371.   end
  372.  
  373.   def formula_match
  374.     worked = false
  375.     @current_formula = []
  376.     items = @mix.mix_get_items()
  377.     count=0
  378.     while count < @formula_max
  379.       if items.length == @mats[count].length && items - @mats[count] == []
  380.         @current_formula = count
  381.         return worked = true
  382.       end
  383.       count+=1
  384.     end
  385.     return worked
  386.   end
  387. def process_craft
  388.   cost = ICS_Custom_Formula::FORMULA[@current_formula][:costs]
  389.   m = ICS_Custom_Formula::FORMULA[@current_formula][:mats]
  390.   tot_amounts = 0
  391.   tot_amounts_in_party = 0
  392.   items = @mix.mix_get_items()
  393.  
  394.   if @actor.mp >= cost[1] && $game_party.gold >= cost[0] && @actor.tp >= cost[2]
  395.     m.each do |amounts|
  396.       tot_amounts+=amounts[2]
  397.     end
  398.  
  399.     items.each do |item|
  400.       tot_amounts_in_party+=$game_party.item_number(item)+1
  401.     end
  402.    
  403.     if tot_amounts_in_party >= tot_amounts
  404.       #Take the items from player inventory
  405.       count2=0
  406.       while count2 < m.length
  407.         a_loss = @amounts[@current_formula][count2]-1
  408.         i_loss = @mats[@current_formula][count2]
  409.         $game_party.lose_item(i_loss,a_loss)
  410.         count2+=1
  411.       end
  412.     count3=0
  413.     #Add the products to the player inventory
  414.     while count3 < @products[@current_formula].length
  415.       $game_party.gain_item(@products[@current_formula][count3],@product_amounts[@current_formula][count3])
  416.       count3+=1
  417.     end
  418.    
  419.     #Remove the costs
  420.     @actor.mp -= cost[1]
  421.     @actor.tp -= cost[2]
  422.     $game_party.lose_gold(cost[0])
  423.     RPG::SE.new(ICS_Custom_Formula::FORMULA[@current_formula][:sound].to_s,100,100).play
  424.     #set recipe discovered to true
  425.     $game_system.formula_list[@current_formula][:discovered] = true
  426.     $game_system.formula_list[@current_formula][:know_mats] = true
  427.     #clear the mix items
  428.     @mix.mix_clear_items()
  429.     formula_match()
  430.     @mix.draw_mix()
  431.     @menu.select(0)
  432.     return
  433.     else
  434.     @cost_pro.not_enough_items()
  435.     end
  436.   else
  437.     if @actor.mp < cost[1]
  438.       @cost_pro.not_enough_mp()
  439.     end
  440.     if @actor.tp < cost[2]
  441.       @cost_pro.not_enough_tp()
  442.     end
  443.     if $game_party.gold < cost[0]
  444.       @cost_pro.not_enough_gold()
  445.     end
  446.   end
  447.  
  448. end
  449.  
  450. # selection menu   ############################################################
  451. ###############################################################################
  452.   def com_all
  453.     if @formula_book == true
  454.       @formula_book_all.draw_formulas()
  455.       @formula_book_all.open()
  456.       @formula_book_all.activate()
  457.       @formula_book_all.select(0)
  458.     else
  459.       @selection_menu.activate()
  460.     end
  461.   end
  462.  
  463.   def com_item
  464.     if $game_party.items != [] && @formula_book == false
  465.       @d_items.open()
  466.       @d_items.draw_items()
  467.       @d_items.activate()
  468.       @d_items.select(0)
  469.     elsif @formula_book == true
  470.       @formula_book_items.draw_formulas()
  471.       @formula_book_items.open()
  472.       @formula_book_items.activate()
  473.       @formula_book_items.select(0)
  474.     else
  475.       @selection_menu.activate()
  476.     end
  477.   end
  478.  
  479.   def com_weapon
  480.     if $game_party.weapons != [] && @formula_book == false
  481.       @d_weapons.open()
  482.       @d_weapons.draw_weapons()
  483.       @d_weapons.activate()
  484.       @d_weapons.select(0)
  485.     elsif @formula_book == true
  486.       @formula_book_weapons.draw_formulas()
  487.       @formula_book_weapons.open()
  488.       @formula_book_weapons.activate()
  489.       @formula_book_weapons.select(0)
  490.     else
  491.       @selection_menu.activate()
  492.     end
  493.   end
  494.  
  495.   def com_armor
  496.     if $game_party.armors != [] && @formula_book == false
  497.       @d_armors.open()
  498.       @d_armors.draw_armors()
  499.       @d_armors.activate()
  500.       @d_armors.select(0)
  501.     elsif @formula_book == true
  502.       @formula_book_armors.draw_formulas()
  503.       @formula_book_armors.open()
  504.       @formula_book_armors.activate()
  505.       @formula_book_armors.select(0)
  506.     else
  507.       @selection_menu.activate()
  508.     end
  509.   end
  510.  
  511.   def com_cancel_selection_menu
  512.     if formula_match
  513.       RPG::SE.new(ICS_Custom_Formula::CORRECT_SOUND,100,100).play
  514.       back_to_main_menu(3)
  515.     elsif @mix.has_items()
  516.       RPG::SE.new(ICS_Custom_Formula::CANCEL_SOUND,100,100).play
  517.       back_to_main_menu(2)
  518.     else
  519.       RPG::SE.new(ICS_Custom_Formula::CANCEL_SOUND,100,100).play
  520.       back_to_main_menu()
  521.     end
  522.   end
  523.  
  524.   def back_to_selection_menu
  525.       @formula_book_items.unselect()
  526.       @formula_book_items.deactivate()
  527.       @formula_book_items.close()
  528.      
  529.       @formula_book_weapons.unselect()
  530.       @formula_book_weapons.deactivate()
  531.       @formula_book_weapons.close()
  532.      
  533.       @formula_book_armors.unselect()
  534.       @formula_book_armors.deactivate()
  535.       @formula_book_armors.close()
  536.      
  537.       @formula_book_all.unselect()
  538.       @formula_book_all.deactivate()
  539.       @formula_book_all.close()
  540.      
  541.       @d_items.unselect()
  542.       @d_items.deactivate()
  543.       @d_items.clear()
  544.       @d_items.close()
  545.       @d_weapons.unselect()
  546.       @d_weapons.deactivate()
  547.       @d_weapons.clear()
  548.       @d_weapons.close()
  549.       @d_armors.unselect()
  550.       @d_armors.deactivate()
  551.       @d_armors.clear()
  552.       @d_armors.close()
  553.       @selection_menu.activate()
  554.     end
  555.   def back_to_main_menu(index=0)
  556.       if @cost_pro.height > 150
  557.         @cost_pro.height -= 100
  558.         @cost_pro.create_contents
  559.         @cost_pro.refresh
  560.       end
  561.       @mix.open()
  562.       update until @mix.open?
  563.       @formula_book_items.unselect()
  564.       @formula_book_items.deactivate()
  565.       @formula_book_items.close()
  566.      
  567.       @formula_book_weapons.unselect()
  568.       @formula_book_weapons.deactivate()
  569.       @formula_book_weapons.close()
  570.      
  571.       @formula_book_armors.unselect()
  572.       @formula_book_armors.deactivate()
  573.       @formula_book_armors.close()
  574.      
  575.       @formula_book_all.unselect()
  576.       @formula_book_all.deactivate()
  577.       @formula_book_all.close()
  578.      
  579.       @formula_book = false
  580.       @d_items.unselect()
  581.       @d_items.deactivate()
  582.       @d_items.clear()
  583.       @d_items.close()
  584.       @d_weapons.unselect()
  585.       @d_weapons.deactivate()
  586.       @d_weapons.clear()
  587.       @d_weapons.close()
  588.       @d_armors.unselect()
  589.       @d_armors.deactivate()
  590.       @d_armors.clear()
  591.       @d_armors.close()
  592.       @selection_menu.close()
  593.       @selection_menu.deactivate()
  594.       update until @selection_menu.close?
  595.       @menu.open()
  596.       @menu.activate()
  597.       @menu.select(index)
  598.   end
  599.  
  600.   def add_item_to_mix(item = 'none')
  601.     $game_party.lose_item(item, 1)
  602.     @mix.add_in(item)
  603.   end
  604.  
  605.   def get_formula
  606.     formula_match()
  607.     return @current_formula
  608.   end
  609.  
  610.   def update
  611.     super()
  612.     if @menu.active
  613.       return_scene() if Input.trigger?(:B)
  614.     end
  615.    
  616.    
  617.    
  618.     if @d_items.active()
  619.       item = ($game_party.items[@d_items.index]) #item is = to the index
  620.       @cost_pro.display_cost_item(item)
  621.     elsif @d_weapons.active()
  622.       item = ($game_party.weapons[@d_weapons.index])
  623.       @cost_pro.display_cost_item(item)
  624.     elsif @d_armors.active()
  625.       item = ($game_party.armors[@d_armors.index])
  626.       @cost_pro.display_cost_item(item)
  627.     elsif @formula_book_items.active()
  628.       @cost_pro.display_formula_req(@formula_book_items.get_current_formula)
  629.     elsif @formula_book_weapons.active()
  630.       @cost_pro.display_formula_req(@formula_book_weapons.get_current_formula)
  631.     elsif @formula_book_armors.active()
  632.       @cost_pro.display_formula_req(@formula_book_armors.get_current_formula)
  633.     elsif @formula_book_all.active()
  634.       @cost_pro.display_formula_req(@formula_book_all.get_current_formula)
  635.     else
  636.       @cost_pro.clear_me()
  637.     end
  638.      
  639.    
  640.     if Input.trigger?(:B) && (@d_items.active() || @d_weapons.active() || @d_armors.active())
  641.         RPG::SE.new(ICS_Custom_Formula::CANCEL_SOUND,100,100).play
  642.         back_to_selection_menu()
  643.     elsif Input.trigger?(:C) && (@d_items.active() || @d_weapons.active() || @d_armors.active())
  644.       if @mix.mix_full || @mix.same_item(item)#if mix has more than 6 items alrdy quit
  645.         back_to_selection_menu()
  646.       else
  647.         RPG::SE.new(ICS_Custom_Formula::ADD_SOUND,100,100).play
  648.         add_item_to_mix(item)  
  649.         back_to_selection_menu()
  650.       end
  651.     elsif Input.trigger?(:C) && (@formula_book_items.active() || @formula_book_weapons.active() || @formula_book_armors.active() || @formula_book_all.active())
  652.       temp_items = @formula_book_items.get_items if @formula_book_items.active()
  653.       temp_items = @formula_book_weapons.get_items if @formula_book_weapons.active()
  654.       temp_items = @formula_book_armors.get_items if @formula_book_armors.active()
  655.       temp_items = @formula_book_all.get_items if @formula_book_all.active()
  656.       if temp_items != []
  657.         @mix.mix_reset()
  658.         temp_items.each do |item|
  659.           if $game_party.item_number(item) > 0
  660.             RPG::SE.new(ICS_Custom_Formula::ADD_SOUND,100,100).play
  661.             add_item_to_mix(item)
  662.           else
  663.             @mix.mix_reset()
  664.             RPG::SE.new(ICS_Custom_Formula::CANT_CRAFT_SOUND,100,100).play
  665.             return
  666.           end
  667.         end
  668.       back_to_main_menu(3)
  669.       else
  670.         @mix.mix_reset()
  671.         RPG::SE.new(ICS_Custom_Formula::CANT_CRAFT_SOUND,100,100).play
  672.       end
  673.     elsif Input.trigger?(:B) && (@formula_book_items.active() || @formula_book_weapons.active() || @formula_book_armors.active() || @formula_book_all.active())
  674.       RPG::SE.new(ICS_Custom_Formula::CANCEL_SOUND,100,100).play
  675.       back_to_selection_menu()
  676.     end
  677.   end
  678.  
  679.  
  680.  
  681.   def terminate
  682.     super()
  683.     @mix.mix_drain() if @mix
  684.     @d_items.dispose()
  685.     @d_weapons.dispose()
  686.     @d_armors.dispose()
  687.     @cost_pro.dispose()
  688.     @mix.dispose()
  689.     @menu.dispose()
  690.     @selection_menu.dispose() if @selection_menu
  691.     @formula_book_items.dispose()
  692.     @formula_book_weapons.dispose()
  693.     @formula_book_armors.dispose()
  694.     @formula_book_all.dispose()
  695.   end
  696.  
  697. end
  698.  
  699. ####################################################################
  700.  
  701.  
  702.  
  703.  
  704. ####################################################################
  705.  
  706. class D_Items_Window < Window_Selectable
  707.   def initialize()
  708.     super(0,0,Graphics.width / 2, Graphics.height)
  709.   end
  710.  
  711.   def col_max
  712.     return 1
  713.   end
  714.  
  715.   def clear
  716.     contents.clear()
  717.   end
  718.  
  719.   def item_max()
  720.     count = 0
  721.     for key in $game_party.items
  722.       count += 1
  723.     end
  724.     return count
  725.   end
  726.  
  727.  
  728.   def draw_items
  729.     row = 0
  730.    
  731.     for item in $game_party.items
  732.       draw_icon(item.icon_index, 0, row * 24, true)
  733.       draw_text_ex(26, row * 24, item.name)
  734.       x = $game_party.item_number(item)
  735.       draw_text_ex((self.x + self.width)-64, row*24,x)
  736.       row += 1
  737.     end
  738.    
  739.   end
  740. end
  741.  
  742.  
  743.  
  744. class D_Weapons_Window < Window_Selectable
  745.  
  746.   def initialize()
  747.     super(0,0,Graphics.width / 2, Graphics.height)
  748.   end
  749.  
  750.   def col_max
  751.     return 1
  752.   end
  753.  
  754.   def clear
  755.     contents.clear()
  756.   end
  757.  
  758.   def item_max
  759.     count = 0
  760.     for key in $game_party.weapons
  761.       count += 1
  762.     end
  763.     return count
  764.   end
  765.  
  766.  
  767.   def draw_weapons
  768.     row = 0
  769.     for item in $game_party.weapons
  770.       draw_icon(item.icon_index, 0, row * 24, true)
  771.       draw_text_ex(26, row * 24, item.name)
  772.       x = $game_party.item_number(item)
  773.       draw_text_ex((self.x + self.width)-64, row*24,x)
  774.       row += 1
  775.     end
  776.   end
  777. end
  778.  
  779. class D_Armors_Window < Window_Selectable
  780.   def initialize()
  781.     super(0,0,Graphics.width / 2, Graphics.height)
  782.   end
  783.  
  784.   def col_max
  785.     return 1
  786.   end
  787.  
  788.   def clear
  789.     contents.clear()
  790.   end
  791.  
  792.   def item_max()
  793.     count = 0
  794.     for key in $game_party.armors
  795.       count += 1
  796.     end
  797.     return count
  798.   end
  799.  
  800.  
  801.   def draw_armors
  802.     row = 0
  803.    
  804.     for item in $game_party.armors
  805.       draw_icon(item.icon_index, 0, row * 24, true)
  806.       draw_text_ex(26, row * 24, item.name)
  807.       x = $game_party.item_number(item)
  808.       draw_text_ex((self.x + self.width)-64, row*24,x)
  809.       row += 1
  810.     end
  811.    
  812.   end
  813. end
  814.  
  815. class Cost_Pro_Window < Window_Selectable
  816.  
  817.   def initialize(x,y)
  818.     @not_enough_items = false
  819.     @need_mp = false
  820.     @need_tp = false
  821.     @need_gold = false
  822.    
  823.     super(x,y,Graphics.width-x,150)
  824.   end
  825.  
  826.   def display_formula_req(formula_display)
  827.     clear_me()
  828.    
  829.     if $game_system.formula_list[formula_display][:know_mats] == true
  830.       y=26
  831.       colors = ICS_Custom_Formula::COLORS
  832.       count=0
  833.       ICS_Custom_Formula::FORMULA[formula_display][:mats].each do |mat|
  834.         if mat[1].is_a?(Integer)
  835.           req = $data_items[mat[1]] if mat[0] == 'i'
  836.           req = $data_weapons[mat[1]] if mat[0] == 'w'
  837.           req = $data_armors[mat[1]] if mat[0] == 'a'
  838.         elsif mat[0] == 'i' && mat[1].is_a?(String)
  839.           count=1
  840.           while count<$data_items.length
  841.             if mat[1] == $data_items[count].name
  842.               req = $data_items[count]
  843.             end
  844.           count+=1
  845.           end
  846.         elsif mat[0] == 'w' && mat[1].is_a?(String)
  847.           count=1
  848.           while count<$data_weapons.length
  849.             if mat[1] == $data_weapons[count].name
  850.               req = $data_weapons[count]
  851.             end
  852.           count+=1
  853.           end
  854.         elsif mat[0] == 'a' && mat[1].is_a?(String)
  855.           count=1
  856.           while count<$data_armors.length
  857.             if mat[1] == $data_armors[count].name
  858.               req = $data_armors[count]
  859.             end
  860.           count+=1
  861.           end
  862.         end
  863.        
  864.         if $game_party.item_number(req) >= mat[2]
  865.           draw_text_ex(0,0,'Requires:')
  866.           change_color(text_color(colors[4]))
  867.           draw_icon(req.icon_index,0,y,true)
  868.           contents.draw_text(20,y,300,26,req.name + ' x' + mat[2].to_s)
  869.         else
  870.           draw_text_ex(0,0,'Requires:')
  871.           change_color(text_color(colors[5]))
  872.           draw_icon(req.icon_index,0,y,true)
  873.           contents.draw_text(20,y,300,26,req.name + ' x' + mat[2].to_s)
  874.         end
  875.         y+=26
  876.       end
  877.     else
  878.       draw_text_ex(0,0,'??????')
  879.     end
  880.   end
  881.  
  882.   def clear_me
  883.     contents.clear()
  884.     if @not_enough_items == true
  885.       draw_text_ex(0,0,'\C[10]Not enough items in Inventory\C[0]')
  886.     end
  887.     if @need_gold == true
  888.       draw_text_ex(0,0,'\C[10]Not enough Gold\C[0]')
  889.     end
  890.     if @need_mp == true
  891.       draw_text_ex(0,25,'\C[10]Not enough Mp\C[0]')
  892.     end
  893.     if @need_tp == true
  894.       draw_text_ex(0,50,'\C[10]Not enough Tp\C[0]')
  895.     end
  896.   end
  897.  
  898.   def display_cost_item(item = 'none')
  899.     clear_me()
  900.     draw_text_ex(0,0,item.name)
  901.     draw_text_ex(0,26,item.description)
  902.   end
  903.  
  904.   def not_enough_items
  905.     @not_enough_items = true
  906.     clear_me()
  907.   end
  908.   def not_enough_gold
  909.     @need_gold = true
  910.   end
  911.   def not_enough_mp
  912.     @need_mp = true
  913.   end
  914.   def not_enough_tp
  915.     @need_tp = true
  916.   end
  917.   def reset_stuff
  918.     @not_enough_items = false
  919.     @need_gold = false
  920.     @need_tp = false
  921.     @need_mp = false
  922.   end
  923.  
  924.  
  925. end
  926.  
  927. class Mix_Window < Window_Selectable
  928.  
  929.   def initialize(x,y)
  930.     @items = []
  931.     super(x,y,Graphics.width-x,100)
  932.   end
  933.  
  934.   def add_in(item)
  935.     @items.push(item)
  936.     draw_mix()
  937.   end
  938.  
  939.   def mix_full
  940.     if @items.length >= 6
  941.       return true
  942.     else
  943.       return false
  944.     end
  945.   end
  946.   def same_item(item)
  947.     @items.each do |compare_item|
  948.       if item == compare_item
  949.         RPG::SE.new(ICS_Custom_Formula::CANT_CRAFT_SOUND,100,100).play
  950.         return true
  951.       end
  952.     end
  953.     return false
  954.   end
  955.  
  956.   def has_items
  957.     return true if @items != []
  958.     return false
  959.   end
  960.  
  961.   def draw_mix()
  962.     contents.clear()
  963.     col = 0
  964.     for p in @items
  965.       draw_icon(p.icon_index, col * 32, 0, true)
  966.       col += 1
  967.     end
  968.    
  969.     formula_number = SceneManager.scene.get_formula
  970.     if formula_number != nil && formula_number != []
  971.       formula_name = ICS_Custom_Formula::FORMULA[formula_number][:name][0,24]
  972.       formula_costs = ICS_Custom_Formula::FORMULA[formula_number][:costs]
  973.       colors = ICS_Custom_Formula::COLORS
  974.       #This Draws the Cost of the formula below the Materials
  975.       contents.draw_text(0,24,200,40,formula_name)
  976.       x = self.width / 3
  977.       change_color(text_color(colors[1]))
  978.       contents.draw_text(0,45,200,40,formula_costs[0].to_s)
  979.      
  980.       change_color(text_color(colors[2]))
  981.       contents.draw_text(x,45,200,40,formula_costs[1].to_s)
  982.      
  983.       change_color(text_color(colors[3]))
  984.       contents.draw_text(x*2,45,200,40,formula_costs[2].to_s)
  985.      
  986.       change_color(normal_color)
  987.     end
  988.   end
  989.  
  990.  
  991.  
  992.   def remove_item
  993.     if @items != []
  994.       $game_party.gain_item(@items[-1],1)
  995.       @items.delete_at(-1)
  996.       draw_mix()
  997.     end
  998.   end
  999.   def mix_drain #used to give back items in case of termination
  1000.     if @items != []
  1001.       for item in @items
  1002.         $game_party.gain_item(item,1)
  1003.       end
  1004.       @items = []
  1005.     end    
  1006.   end
  1007.  
  1008.  
  1009.   def mix_reset
  1010.     if @items != []
  1011.       for item in @items
  1012.         $game_party.gain_item(item,1)
  1013.       end
  1014.       @items = []
  1015.       draw_mix()
  1016.     end    
  1017.   end
  1018.   def mix_clear_items
  1019.     @items = []
  1020.   end
  1021.  
  1022.   def mix_get_items
  1023.     return @items
  1024.   end
  1025.  
  1026. end#class
  1027.  
  1028. class Menu_Window < Window_Command
  1029.   def initialize(x,y)
  1030.     @width = Graphics.width-x
  1031.     super(x,y)
  1032.   end
  1033.  
  1034.   def make_command_list
  1035.     add_command("Add",   :add)
  1036.     add_command("Remove Last", :rl)
  1037.     add_command("Reset All", :reset)
  1038.     add_command("Craft!", :craft)
  1039.     add_command(ICS_Custom_Formula::FORMULA_BOOK_NAME, :formula_book)
  1040.     add_command("Exit", :exit)
  1041.   end
  1042.  
  1043.   def window_width
  1044.     return @width
  1045.   end
  1046.  
  1047. end
  1048.  
  1049. class Selection_Menu < Window_Command
  1050.   def initialize(x,y,formula_book)
  1051.     @formula_book = formula_book
  1052.     @width = Graphics.width-x
  1053.     super(x,y)
  1054.   end
  1055.  
  1056.   def make_command_list
  1057.     if @formula_book == true
  1058.       add_command("All", :mat_formula_all)
  1059.     end
  1060.     add_command("Item",   :mat_item)
  1061.     add_command("Weapon", :mat_weapon)
  1062.     add_command("Armor", :mat_armor)
  1063.     add_command("Cancel", :cancel)
  1064.   end
  1065.  
  1066.   def window_width
  1067.     return @width
  1068.   end
  1069.  
  1070. end
  1071.  
  1072.  
  1073.  
  1074. class Formula_book_weapons < Window_Selectable
  1075.   def initialize
  1076.     super(0,0,Graphics.width / 2, Graphics.height)
  1077.     @set_items = []
  1078.     @draw_formula_list = []
  1079.     @current_formula = 0
  1080.     @formula_list = ICS_Custom_Formula::FORMULA
  1081.     draw_formulas()
  1082.   end
  1083.  
  1084. def get_items
  1085.   @set_items = []
  1086.   if $game_system.formula_list[@draw_formula_list[index]][:discovered] == true && @formula_list[@draw_formula_list[index]][:know_mats] == true
  1087.     @formula_list[@draw_formula_list[index]][:mats].each do |mat|
  1088.       if mat[1].is_a?(String) && mat[0] == 'w'
  1089.         $data_weapons.each do |data|
  1090.           if data != nil
  1091.             if mat[1] == data.name
  1092.               @set_items.push(data)
  1093.             end
  1094.           end
  1095.         end
  1096.       elsif mat[1].is_a?(String) && mat[0] == 'i'
  1097.       $data_items.each do |data|
  1098.         if data != nil
  1099.           if mat[1] == data.name
  1100.             @set_items.push(data)
  1101.           end
  1102.         end
  1103.       end
  1104.       elsif mat[1].is_a?(String) && mat[0] == 'a'
  1105.       $data_armors.each do |data|
  1106.         if data != nil
  1107.           if mat[1] == data.name
  1108.             @set_items.push(data)
  1109.           end
  1110.         end
  1111.       end
  1112.       elsif mat[1].is_a?(Integer) && mat[0] == 'i'
  1113.         @set_items.push($data_items[mat[1]])
  1114.       elsif mat[1].is_a?(Integer) && mat[0] == 'a'
  1115.         @set_items.push($data_armors[mat[1]])
  1116.       elsif mat[1].is_a?(Integer) && mat[0] == 'w'
  1117.         @set_items.push($data_weapons[mat[1]])
  1118.       end
  1119.     end
  1120.   else
  1121.     @set_items = []
  1122.   end
  1123.     return @set_items    
  1124. end
  1125.  
  1126.   def item_max()
  1127.     count = 0
  1128.     ICS_Custom_Formula::FORMULA.each do |formula|
  1129.       if formula[:products][0][0] == 'w'
  1130.         count +=1
  1131.       end
  1132.     end
  1133.     return count
  1134.   end
  1135.  
  1136.   def item_height
  1137.     return 60
  1138.   end
  1139.  
  1140.   def get_current_formula
  1141.     return @draw_formula_list[self.index]
  1142.   end
  1143.  
  1144.  
  1145.   def draw_formulas
  1146.     contents.clear()
  1147.     formula_list = []
  1148.     x = self.width / 3
  1149.     y = 0
  1150.     count = 0
  1151.     t_width = Graphics.width
  1152.     colors = ICS_Custom_Formula::COLORS
  1153.     @formula_list.each do |formula|
  1154.       if formula[:discovered] == true
  1155.         if formula[:products][0][0] == 'w'
  1156.           contents.draw_text(5,y,t_width,line_height,formula[:name])
  1157.           change_color(text_color(colors[1]))
  1158.           contents.draw_text(5,y+30,t_width,line_height,formula[:costs][0])
  1159.           change_color(text_color(colors[2]))
  1160.           contents.draw_text(x,y+30,t_width,line_height, formula[:costs][1])
  1161.           change_color(text_color(colors[3]))
  1162.           contents.draw_text(x*2,y+30,t_width,line_height, formula[:costs][2])
  1163.           change_color(normal_color)
  1164.           @draw_formula_list.push(count)
  1165.           y+=60
  1166.         end
  1167.       elsif formula[:products][0][0] == 'w' && formula[:discovered] == false
  1168.         contents.draw_text(5,y,t_width,line_height,'??????')
  1169.         @draw_formula_list.push(count)
  1170.         y+=60
  1171.       end
  1172.       count+=1
  1173.     end
  1174.   end
  1175.  
  1176. end #class
  1177.  
  1178. class Formula_book_items < Window_Selectable
  1179.   def initialize
  1180.     super(0,0,Graphics.width / 2, Graphics.height)
  1181.     @set_items = []
  1182.     @draw_formula_list = []
  1183.     @current_formula = 0
  1184.     @formula_list = ICS_Custom_Formula::FORMULA
  1185.     draw_formulas()
  1186.   end
  1187.  
  1188. def get_items
  1189.   @set_items = []
  1190.   if $game_system.formula_list[@draw_formula_list[index]][:discovered] == true && @formula_list[@draw_formula_list[index]][:know_mats] == true
  1191.     @formula_list[@draw_formula_list[index]][:mats].each do |mat|
  1192.       if mat[1].is_a?(String) && mat[0] == 'w'
  1193.         $data_weapons.each do |data|
  1194.           if data != nil
  1195.             if mat[1] == data.name
  1196.               @set_items.push(data)
  1197.             end
  1198.           end
  1199.         end
  1200.       elsif mat[1].is_a?(String) && mat[0] == 'i'
  1201.       $data_items.each do |data|
  1202.         if data != nil
  1203.           if mat[1] == data.name
  1204.             @set_items.push(data)
  1205.           end
  1206.         end
  1207.       end
  1208.       elsif mat[1].is_a?(String) && mat[0] == 'a'
  1209.       $data_armors.each do |data|
  1210.         if data != nil
  1211.           if mat[1] == data.name
  1212.             @set_items.push(data)
  1213.           end
  1214.         end
  1215.       end
  1216.       elsif mat[1].is_a?(Integer) && mat[0] == 'i'
  1217.         @set_items.push($data_items[mat[1]])
  1218.       elsif mat[1].is_a?(Integer) && mat[0] == 'a'
  1219.         @set_items.push($data_armors[mat[1]])
  1220.       elsif mat[1].is_a?(Integer) && mat[0] == 'w'
  1221.         @set_items.push($data_weapons[mat[1]])
  1222.       end
  1223.     end
  1224.   else
  1225.     @set_items = []
  1226.   end
  1227.     return @set_items    
  1228. end
  1229.  
  1230.   def item_max()
  1231.     count = 0
  1232.     ICS_Custom_Formula::FORMULA.each do |formula|
  1233.       if formula[:products][0][0] == 'i'
  1234.         count +=1
  1235.       end
  1236.     end
  1237.     return count
  1238.   end
  1239.  
  1240.   def item_height
  1241.     return 60
  1242.   end
  1243.  
  1244.   def get_current_formula
  1245.     return @draw_formula_list[self.index]
  1246.   end
  1247.  
  1248.  
  1249.   def draw_formulas
  1250.     contents.clear()
  1251.     formula_list = []
  1252.     x = self.width / 3
  1253.     y = 0
  1254.     count = 0
  1255.     t_width = Graphics.width
  1256.     colors = ICS_Custom_Formula::COLORS
  1257.     @formula_list.each do |formula|
  1258.       if formula[:discovered] == true
  1259.         if formula[:products][0][0] == 'i'
  1260.           contents.draw_text(5,y,t_width,line_height,formula[:name])
  1261.           change_color(text_color(colors[1]))
  1262.           contents.draw_text(5,y+30,t_width,line_height,formula[:costs][0])
  1263.           change_color(text_color(colors[2]))
  1264.           contents.draw_text(x,y+30,t_width,line_height, formula[:costs][1])
  1265.           change_color(text_color(colors[3]))
  1266.           contents.draw_text(x*2,y+30,t_width,line_height, formula[:costs][2])
  1267.           change_color(normal_color)
  1268.           @draw_formula_list.push(count)
  1269.           y+=60
  1270.         end
  1271.       elsif formula[:products][0][0] == 'i' && formula[:discovered] == false
  1272.         contents.draw_text(5,y,t_width,line_height,'??????')
  1273.         @draw_formula_list.push(count)
  1274.         y+=60
  1275.       end
  1276.       count+=1
  1277.     end
  1278.   end
  1279.  
  1280. end #class
  1281.  
  1282. class Formula_book_armors < Window_Selectable
  1283.   def initialize
  1284.     super(0,0,Graphics.width / 2, Graphics.height)
  1285.     @set_items = []
  1286.     @draw_formula_list = []
  1287.     @current_formula = 0
  1288.     @formula_list = ICS_Custom_Formula::FORMULA
  1289.     draw_formulas()
  1290.   end
  1291.  
  1292. def get_items
  1293.   @set_items = []
  1294.   if $game_system.formula_list[@draw_formula_list[index]][:discovered] == true && @formula_list[@draw_formula_list[index]][:know_mats] == true
  1295.     @formula_list[@draw_formula_list[index]][:mats].each do |mat|
  1296.       if mat[1].is_a?(String) && mat[0] == 'w'
  1297.         $data_weapons.each do |data|
  1298.           if data != nil
  1299.             if mat[1] == data.name
  1300.               @set_items.push(data)
  1301.             end
  1302.           end
  1303.         end
  1304.       elsif mat[1].is_a?(String) && mat[0] == 'i'
  1305.       $data_items.each do |data|
  1306.         if data != nil
  1307.           if mat[1] == data.name
  1308.             @set_items.push(data)
  1309.           end
  1310.         end
  1311.       end
  1312.       elsif mat[1].is_a?(String) && mat[0] == 'a'
  1313.       $data_armors.each do |data|
  1314.         if data != nil
  1315.           if mat[1] == data.name
  1316.             @set_items.push(data)
  1317.           end
  1318.         end
  1319.       end
  1320.       elsif mat[1].is_a?(Integer) && mat[0] == 'i'
  1321.         @set_items.push($data_items[mat[1]])
  1322.       elsif mat[1].is_a?(Integer) && mat[0] == 'a'
  1323.         @set_items.push($data_armors[mat[1]])
  1324.       elsif mat[1].is_a?(Integer) && mat[0] == 'w'
  1325.         @set_items.push($data_weapons[mat[1]])
  1326.       end
  1327.     end
  1328.   else
  1329.     @set_items = []
  1330.   end
  1331.     return @set_items    
  1332. end
  1333.  
  1334.   def item_max()
  1335.     count = 0
  1336.     ICS_Custom_Formula::FORMULA.each do |formula|
  1337.       if formula[:products][0][0] == 'a'
  1338.         count +=1
  1339.       end
  1340.     end
  1341.     return count
  1342.   end
  1343.  
  1344.   def item_height
  1345.     return 60
  1346.   end
  1347.  
  1348.   def get_current_formula
  1349.     return @draw_formula_list[self.index]
  1350.   end
  1351.  
  1352.  
  1353.   def draw_formulas
  1354.     contents.clear()
  1355.     formula_list = []
  1356.     x = self.width / 3
  1357.     y = 0
  1358.     count = 0
  1359.     t_width = Graphics.width
  1360.     colors = ICS_Custom_Formula::COLORS
  1361.     @formula_list.each do |formula|
  1362.       if formula[:discovered] == true
  1363.         if formula[:products][0][0] == 'a'
  1364.           contents.draw_text(5,y,t_width,line_height,formula[:name])
  1365.           change_color(text_color(colors[1]))
  1366.           contents.draw_text(5,y+30,t_width,line_height,formula[:costs][0])
  1367.           change_color(text_color(colors[2]))
  1368.           contents.draw_text(x,y+30,t_width,line_height, formula[:costs][1])
  1369.           change_color(text_color(colors[3]))
  1370.           contents.draw_text(x*2,y+30,t_width,line_height, formula[:costs][2])
  1371.           change_color(normal_color)
  1372.           @draw_formula_list.push(count)
  1373.           y+=60
  1374.         end
  1375.       elsif formula[:products][0][0] == 'a' && formula[:discovered] == false
  1376.         contents.draw_text(5,y,t_width,line_height,'??????')
  1377.         @draw_formula_list.push(count)
  1378.         y+=60
  1379.       end
  1380.       count+=1
  1381.     end
  1382.   end
  1383.  
  1384. end #class
  1385.  
  1386. class Formula_book_all < Window_Selectable
  1387.   def initialize
  1388.     super(0,0,Graphics.width / 2, Graphics.height)
  1389.     @set_items = []
  1390.     @draw_formula_list = []
  1391.     @current_formula = 0
  1392.     @formula_list = ICS_Custom_Formula::FORMULA
  1393.     draw_formulas()
  1394.   end
  1395.  
  1396. def get_items
  1397.   @set_items = []
  1398.   if $game_system.formula_list[@draw_formula_list[index]][:discovered] == true && @formula_list[@draw_formula_list[index]][:know_mats] == true
  1399.     @formula_list[@draw_formula_list[index]][:mats].each do |mat|
  1400.       if mat[1].is_a?(String) && mat[0] == 'w'
  1401.         $data_weapons.each do |data|
  1402.           if data != nil
  1403.             if mat[1] == data.name
  1404.               @set_items.push(data)
  1405.             end
  1406.           end
  1407.         end
  1408.       elsif mat[1].is_a?(String) && mat[0] == 'i'
  1409.       $data_items.each do |data|
  1410.         if data != nil
  1411.           if mat[1] == data.name
  1412.             @set_items.push(data)
  1413.           end
  1414.         end
  1415.       end
  1416.       elsif mat[1].is_a?(String) && mat[0] == 'a'
  1417.       $data_armors.each do |data|
  1418.         if data != nil
  1419.           if mat[1] == data.name
  1420.             @set_items.push(data)
  1421.           end
  1422.         end
  1423.       end
  1424.       elsif mat[1].is_a?(Integer) && mat[0] == 'i'
  1425.         @set_items.push($data_items[mat[1]])
  1426.       elsif mat[1].is_a?(Integer) && mat[0] == 'a'
  1427.         @set_items.push($data_armors[mat[1]])
  1428.       elsif mat[1].is_a?(Integer) && mat[0] == 'w'
  1429.         @set_items.push($data_weapons[mat[1]])
  1430.       end
  1431.     end
  1432.   else
  1433.     @set_items = []
  1434.   end
  1435.     return @set_items    
  1436. end
  1437.  
  1438.   def item_max()
  1439.     count = 0
  1440.     ICS_Custom_Formula::FORMULA.each do |formula|
  1441.         count +=1
  1442.     end
  1443.     return count
  1444.   end
  1445.  
  1446.   def item_height
  1447.     return 60
  1448.   end
  1449.  
  1450.   def get_current_formula
  1451.     return @draw_formula_list[self.index]
  1452.   end
  1453.  
  1454.  
  1455.   def draw_formulas
  1456.     contents.clear()
  1457.     formula_list = []
  1458.     x = self.width / 3
  1459.     y = 0
  1460.     count = 0
  1461.     t_width = Graphics.width
  1462.     colors = ICS_Custom_Formula::COLORS
  1463.     @formula_list.each do |formula|
  1464.       if formula[:discovered] == true
  1465.         if formula[:products][0][0] == 'a' || formula[:products][0][0] == 'i' || formula[:products][0][0] == 'w'
  1466.           contents.draw_text(5,y,t_width,line_height,formula[:name])
  1467.           change_color(text_color(colors[1]))
  1468.           contents.draw_text(5,y+30,t_width,line_height,formula[:costs][0])
  1469.           change_color(text_color(colors[2]))
  1470.           contents.draw_text(x,y+30,t_width,line_height, formula[:costs][1])
  1471.           change_color(text_color(colors[3]))
  1472.           contents.draw_text(x*2,y+30,t_width,line_height, formula[:costs][2])
  1473.           change_color(normal_color)
  1474.           @draw_formula_list.push(count)
  1475.           y+=60
  1476.         end
  1477.       elsif (formula[:products][0][0] == 'a' || formula[:products][0][0] == 'i' || formula[:products][0][0] == 'w') && formula[:discovered] == false
  1478.         contents.draw_text(5,y,t_width,line_height,'??????')
  1479.         @draw_formula_list.push(count)
  1480.         y+=60
  1481.       end
  1482.       count+=1
  1483.     end
  1484.   end
  1485.  
  1486. end #class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement