Advertisement
Frysning

Frysning Crafting

Sep 22nd, 2015
1,285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
RBScript 24.49 KB | None | 0 0
  1. =begin
  2. ================Frysning Crafting=====================
  3. A simple crafting class for your game.
  4. Free for commercial and non commercial use.
  5. Credits are welcome : D
  6.  
  7. ======================================================
  8. 23-9-2015: Version 1.1
  9.     added: Icons for weapons, armours items
  10.     added: More pages with more info
  11.     added: Unlock systeem
  12. 22-9-2015: Version 1.0
  13.     first release version
  14. =====================================================
  15.  
  16. Add this to items that you want to craft.
  17. <mat>
  18.   kind id amount
  19.   kind id amount
  20.   g amount
  21. </mat>
  22.   kind is the type of item
  23.    g gold   you can skip the id part then.
  24.    1 items
  25.    2 armour
  26.    3 weapons
  27.  
  28. Example
  29. <mat>
  30. 1 1 1
  31. g 10
  32. </mat>
  33. The item will cost 1 potion and 10 currency to craft.
  34.  
  35. if you want get more then 1 item for a craft:
  36. <amount: number> where you can fill in number with the desired int.
  37. Example
  38. <amount: 10>
  39. when crafting this item it will give you 10 of it.
  40.  
  41. if an item should not be craftable then don't fill the notetag with
  42. the requiremnts
  43.  
  44. if you want to ignore a complete set of types
  45. just fill the id's in here then.
  46.  
  47. Weapons and Armours get automatic sorted in category.
  48. items on the other hand... nope.
  49.  
  50. So how do we use it?
  51. in $item_categorie make the categorie's you want to use.
  52. then set in the items you want to fit in that category
  53. <ctype: category> only 1 type at the time. caseinsenstive
  54. Example
  55. <ctype: potions> wil only show items that are categorized as potions.
  56.  
  57. unlock system
  58. if an item should be unlocked first before crafting it
  59. <unlock>
  60. party level
  61. switch number
  62. </unlock
  63.  
  64. Example
  65. <unlock>
  66. party 5
  67. switch 1
  68. </unlock>
  69. The highest party member needs to be level 5 and switch 1 needs to be true.
  70.  
  71. ===============TODO=============================================
  72. ----------
  73.  
  74. =============Known issues=======================================
  75. In the item menu and then the submenu's if we return we go back to the root.
  76.  
  77. =end
  78.  
  79.  
  80. $item_categories = ["Potions"]
  81.  
  82. $weapon_ignore=[]
  83. $armor_ignore=[]
  84.  
  85. class Scene_Crafting < Scene_MenuBase
  86.   def initialize
  87.     super
  88.     @help_window = Window_Help.new(1)
  89.     @help_window.set_text("Crafting Menu")
  90.     @list_window = Window_CraftingChooices.new
  91.     @list_window.set_handler(:cancel, method(:list_cancel))
  92.     @list_window.set_handler(:ok, method(:list_ok))
  93.     @list_window.refresh
  94.     @list_window.activate
  95.     @list_window.select(0)
  96.   end
  97.  
  98.  def update
  99.     super
  100.    
  101.     if @description != nil && @description.visible == true
  102.       if Input.trigger?(:LEFT )
  103.         @description.index = -1
  104.       elsif  Input.trigger?(:RIGHT)
  105.         @description.index = 1
  106.       end
  107.     end
  108.    
  109.     if @item == @list_window.current_item
  110.       return
  111.     end
  112.    
  113.     if @description != nil &&  @list_window.item != nil
  114.       @item =   @list_window.current_item
  115.       if @item != nil
  116.         if @item[:kind] == 6
  117.           @description.refresh
  118.           @description.hide
  119.         end  
  120.         if @item[:kind] == -3  || @item[:kind] == -2 ||  @item[:kind] == -1
  121.           @description.item= @list_window.item
  122.           @description.refresh
  123.           @description.show
  124.         end
  125.       end
  126.     end
  127.  
  128.    
  129.   end
  130.  
  131.   def choice_cancel
  132.     end
  133.  
  134.   def list_cancel
  135.  
  136.     if @list_window.item == nil
  137.    
  138.     else
  139.       @item =  @list_window.item
  140.     end
  141.    
  142.     if @description != nil
  143.       @description.hide
  144.     end
  145.     if @item[:kind] == 1 || @item[:kind] == 2 || @item[:kind] == 3 then
  146.        SceneManager.return
  147.     elsif @item[:kind] == 6 &&  @list_window.item == nil
  148.       @list_window.create_list({:kind => 1, :name => "Items"})
  149.     elsif @item[:kind] == 6
  150.       @list_window.create_list(nil)
  151.     elsif @item[:kind] == 5 &&  @list_window.item == nil
  152.       @list_window.create_list({:kind => 3, :name => "Armour"})
  153.     elsif @item[:kind] == 5
  154.       @list_window.create_list(nil)
  155.     elsif @item[:kind] == 4  &&  @list_window.item == nil
  156.        @list_window.create_list({:kind => 2, :name => "Weapons"})
  157.     elsif @item[:kind] == 4
  158.       @list_window.create_list(nil)
  159.     elsif @item[:kind] == -1 &&  @list_window.item == nil
  160.       @list_window.create_list({:kind => 2, :name => "Weapons"})
  161.     elsif @item[:kind] == -1
  162.       @list_window.create_list({:kind => 2, :name => "Weapons"})
  163.     elsif @item[:kind] == -2
  164.       @list_window.create_list({:kind => 3, :name => "Armour"})
  165.     elsif @item[:kind] == -3
  166.       @list_window.create_list(nil)
  167.     end
  168.    
  169.     @list_window.refresh
  170.     @list_window.select(0)
  171.     @list_window.activate
  172.    
  173.   end
  174.  
  175.   def list_ok
  176.     if @list_window.item == nil
  177.       list_cancel
  178.       return
  179.     end
  180.      
  181.     @item = @list_window.item;
  182.      
  183.     if @item[:kind] == 1 || @item[:kind] == 4 || @item[:kind] == 5
  184.       if @description == nil
  185.         @description = Window_CraftingDetails.new
  186.       else
  187.         @description.show
  188.       end
  189.    
  190.       @list_window.create_list(@item);
  191.       @list_window.refresh
  192.       @list_window.select(0)
  193.       @list_window.activate
  194.       @description.item= @list_window.item
  195.        
  196.     elsif @item[:kind] == -3  || @item[:kind] == -2 ||  @item[:kind] == -1
  197.       if @command_window == nil
  198.          @command_window =  Window_CraftItem.new
  199.          @command_window.x = Graphics.width / 2 - @command_window.width / 2
  200.          @command_window.y = Graphics.height / 2 - @command_window.height / 2
  201.          @command_window.set_handler(:craft, method(:craft_item))
  202.          @command_window.set_handler(:cancel, method(:f_cancel))
  203.          @command_window.width = 300
  204.       else
  205.          @command_window.show
  206.       end
  207.       @command_window.Set(@item)
  208.       @command_window.refresh
  209.       @command_window.select(0)
  210.       @command_window.activate
  211.       @command_window.open
  212.       else
  213.         @list_window.create_list(@item);
  214.         @list_window.refresh
  215.         @list_window.select(0)
  216.         @list_window.activate
  217.       end
  218.     end
  219.    
  220.   def craft_item
  221.     @command_window.close
  222.  
  223.      if @item[:kind] == -3
  224.         uItem = $data_items[@item[:term_id]]
  225.      elsif @item[:kind] == -2
  226.         uItem = $data_armors[@item[:term_id]]
  227.      else
  228.         uItem = $data_weapons[@item[:term_id]]
  229.      end
  230.    
  231.       items = []
  232.       b  = true
  233.       if uItem.note =~ /<mat>((.|\s)*)<\/mat>/i
  234.         collection = $1.split("\n")
  235.         collection.each do | val |
  236.           #p val
  237.           if val == "\r"
  238.            next
  239.           end
  240.           itemcollection = val.split(' ')
  241.          
  242.           #p itemcollection
  243.           if itemcollection[0] == "g"
  244.             if Integer(itemcollection[1]) <= $game_party.gold
  245.                items.push({ :itemKind => 0, :amount =>
  246.                 Integer(itemcollection[1])})
  247.               else
  248.               b = false
  249.             end
  250.           else
  251.          
  252.           itemkind = Integer(itemcollection[0])
  253.           itemId = Integer(itemcollection[1])
  254.          
  255.           if itemkind == 1 #items
  256.             pItem = $data_items[itemId]
  257.             has = $game_party.item_number($data_items[itemId])
  258.           elsif itemkind == 2 #armours
  259.             pItem = $data_armors[itemId]
  260.           else #weapons
  261.             pItem = $data_weapons[itemId]
  262.           end
  263.          
  264.          if has >= Integer(itemcollection[2])
  265.               items.push({:itemId => itemId, :itemKind => itemkind, :amount =>
  266.               Integer(itemcollection[2])})
  267.             else
  268.               b = false
  269.             end
  270.         end
  271.        end
  272.       end
  273.      
  274.       #p b
  275.       if b == true
  276.         items.each do | makjes |
  277.           if makjes[:itemKind] == 0
  278.              $game_party.lose_gold(makjes[:amount])
  279.          
  280.           elsif makjes[:itemKind] == 1
  281.             $game_party.gain_item($data_items[makjes[:itemId]],-makjes[:amount])
  282.           elsif makjes[:itemKind] == 2
  283.              $game_party.gain_item($data_armors[makjes[:itemId]],-makjes[:amount])
  284.            else
  285.             $game_party.gain_item($data_weapons[makjes[:itemId]],-makjes[:amount])
  286.           end
  287.         end
  288.        
  289.         amounts = 1
  290.    
  291.         if uItem.note =~ /<amount: (.*)>/i
  292.           amounts = Integer($1)
  293.         end
  294.      
  295.         if @item[:kind] == -3
  296.           $game_party.gain_item( $data_items[@item[:term_id]],amounts)
  297.         elsif @item[:kind] == -2
  298.           $game_party.gain_item(  $data_armors[@item[:term_id]],amounts)
  299.         else
  300.           $game_party.gain_item(  $data_weapons[@item[:term_id]],amounts)
  301.         end
  302.       else
  303.         RPG::SE.new("Buzzer1", 50, 100).play
  304.       end      
  305.     @list_window.refresh
  306.     @list_window.activate()
  307.     @description.refresh
  308.     @command_window.hide
  309.   end
  310.  
  311.  
  312.  def f_cancel
  313.     @command_window.close
  314.     @list_window.refresh
  315.     @list_window.activate()
  316.     @command_window.hide
  317.   end
  318.  
  319.  
  320. end
  321.  
  322. class Window_CraftingDetails < Window_Base
  323.  
  324.  
  325.  
  326.   def item=(item)
  327.     return if @item == item
  328.     @item = item
  329.     refresh
  330.   end
  331.  
  332.  
  333.   def index=(i)
  334.    
  335.     if @index == nil
  336.       @index = 0
  337.     end
  338.       @index += i
  339.      
  340.       if @index < 0
  341.         @index = 4
  342.       elsif @index > 4
  343.         @index = 0
  344.       end
  345.      
  346.       refresh
  347.      
  348.   end
  349.  
  350.   def initialize
  351.     @bitmap = Cache.system("Iconset")
  352.     @index = 0
  353.     super(Graphics.width-Graphics.width/1.5,48,Graphics.width-Graphics.width/3,Graphics.height-48)
  354.   end
  355.  
  356.   def refresh
  357.     contents.clear
  358.     return unless @item
  359.     return if @item[:kind] ==6
  360.     contents.font.size = 18
  361.     change_color(system_color)
  362.    
  363.       if @item[:kind] == -3
  364.         @uItem = $data_items[@item[:term_id]]
  365.                has =   $game_party.item_number($data_items[@item[:term_id]])
  366.       elsif @item[:kind] == -2
  367.         @uItem = $data_armors[@item[:term_id]]
  368.                has =   $game_party.item_number($data_armors[@item[:term_id]])
  369.       elsif @item[:kind] == -1
  370.         @uItem = $data_weapons[@item[:term_id]]
  371.        has =   $game_party.item_number($data_weapons[@item[:term_id]])
  372.      end
  373.      
  374.     amounts = 1
  375.    
  376.     if @uItem.note =~ /<amount: (.*)>/i
  377.       amounts = Integer($1)
  378.     end
  379.      
  380.     change_color(text_color(0))
  381.    
  382.  
  383.     draw_text(0,0,contents.width,line_height,@uItem.name)
  384.    
  385.     case @index
  386.       when 0
  387.           draw_text(0,18,contents.width,line_height,@uItem.description)
  388.           change_color(text_color(14))
  389.           draw_text(0,54,contents.width,line_height,"Cost #{@uItem.price}#{$data_system.currency_unit}")
  390.           change_color(text_color(13))
  391.           draw_text(0, 72, contents.width,line_height,"You got #{has}. You will get #{amounts} for crafting. ")
  392.            y = 90
  393.  
  394.           draw_ingredients(y)
  395.          
  396.  
  397.       when 1
  398.         if@item[:kind] == -2    || @item[:kind] == -1
  399.           draw_item_stats
  400.           y = 170
  401.  
  402.         end
  403.        when 2
  404.               @loc = 2
  405.           draw_elements
  406.       when 3
  407.                   change_color(system_color)  
  408.               draw_states(0,36, @uItem.features)
  409.      when 4
  410.        draw_skills
  411.       else
  412.     end
  413.   @names = ["Main", "Stats","Elements", "States", "Features"]
  414.         first = if @index  <  1 then 4 else @index-1 end
  415.         second =if @index  >  3 then 0 else @index+1 end
  416.         prev_one = @names[first]
  417.         next_one = @names[second]
  418.         change_color(text_color(0))
  419.         draw_text(0,310, contents.width,line_height,
  420.         "<====#{prev_one}=====        ====#{next_one}====>")
  421.    
  422.     @loc=1
  423.    
  424.    
  425.    
  426.     end
  427.    
  428.    
  429.      
  430.     def draw_states(xloc, yloc, features)
  431.     size=136
  432.   change_color(system_color)
  433.     draw_text(0,36, contents.width,line_height,"Can inflict:")
  434.     yloc += line_height
  435.     $data_states.each do | id, waarde |
  436.         isDrawed = false
  437.         change_color(text_color(0))
  438.          features.each do | feature |
  439.            if feature.code == 32
  440.             if  $data_states[feature.data_id] == id
  441.               isDrawed = true
  442.               draw_background_box(xloc, yloc,size)
  443.                icon_index = $data_states[feature.data_id].icon_index
  444.                draw_icon(icon_index,xloc,yloc)
  445.  
  446.                 draw_text(xloc +26,yloc, contents.width,line_height,
  447.                   "#{$data_states[feature.data_id].name}")
  448.                 yloc += line_height if xloc == size + 20
  449.                 xloc = xloc >= 0 + size ?  0: 20+ size
  450.            end
  451.          end
  452.          
  453.        
  454.        end
  455.  
  456.       end
  457.      
  458.     yloc += line_height;
  459.     xloc = 0;
  460.   change_color(system_color)
  461.     draw_text(0,yloc,contents.width,line_height, "Can resist: ")
  462.     yloc += line_height
  463.      $data_states.each do | id, waarde |
  464.       change_color(text_color(0))
  465.        features.each do | feature |
  466.          if feature.code == 14 || feature.code == 13
  467.           if  $data_states[feature.data_id] == id
  468.             draw_background_box(xloc, yloc,size)
  469.              icon_index = $data_states[feature.data_id].icon_index
  470.              draw_icon(icon_index,xloc,yloc)
  471.  
  472.               draw_text(xloc +26,yloc, contents.width,line_height,
  473.                 "#{$data_states[feature.data_id].name}")
  474.  
  475.               yloc += line_height if xloc == size + 20
  476.               xloc = xloc >= 0 + size ?  0: 20+ size
  477.          end
  478.        end
  479.      end
  480.      end
  481.     end
  482.    
  483.    
  484.     def draw_elements
  485.     cloc = (18*@loc)
  486.     change_color(system_color)  
  487.     draw_text(0,cloc,contents.width,line_height,"Elemental Resistances: ")
  488.     draw_item_elements(0,cloc+18, @uItem.features)
  489.     change_color(system_color)  
  490.     draw_text(0,cloc+(18*8),contents.width,line_height, "Base hits with:  ")
  491.     change_color(text_color(0))
  492.     draw_attack_element(0,cloc+(18*9), @uItem.features)
  493.   end
  494.  
  495.   def draw_attack_element(xloc, yloc, features)
  496.     size=136
  497.    
  498.     $data_system.elements.drop(1).each do | elementalid |
  499.       change_color(text_color(0))
  500.  
  501.       features.each do | feature |
  502.         if feature.code == 31
  503.           if $data_system.elements[feature.data_id] == elementalid
  504.             draw_background_box(xloc, yloc,size)
  505.            
  506.             icon_index = ELEMENTME::ELEMENTS[elementalid][:icon]
  507.             draw_icon(icon_index,xloc,yloc)
  508.  
  509.             draw_text(xloc +26,yloc, contents.width,line_height,
  510.             "#{elementalid}")
  511.  
  512.             yloc += line_height if xloc == size + 20
  513.             xloc = xloc >= 0 + size ?  0: 20+ size
  514.           end
  515.         end
  516.       end
  517.     end
  518.   end
  519.  
  520.   def draw_item_elements(xloc,yloc,features)
  521.     size=136
  522.    
  523.     $data_system.elements.drop(1).each do | elementalid |
  524.       change_color(text_color(0))
  525.  
  526.       rate  = 0
  527.       features.each do | feature |
  528.          if feature.code == 11
  529.            if $data_system.elements[feature.data_id] == elementalid
  530.               rate =  (feature.value * 100).round  
  531.            end
  532.          end
  533.        end
  534.        
  535.       draw_background_box(xloc, yloc,size)
  536.  
  537.       icon_index = ELEMENTME::ELEMENTS[elementalid][:icon]
  538.       draw_icon(icon_index,xloc,yloc)
  539.  
  540.       draw_text(xloc +26,yloc, contents.width,line_height,
  541.         "#{elementalid}")
  542.      
  543.       if rate == 100 ||  rate == 0
  544.         change_color(text_color(0))
  545.       elsif rate < 100
  546.         change_color(text_color(24))
  547.       else
  548.         change_color(text_color(25))
  549.       end
  550.  
  551.       urate = 100 - rate
  552.  
  553.       if urate == 100
  554.         urate = "+0"
  555.       elsif urate > 0
  556.         urate = "+#{urate}"
  557.       end
  558.  
  559.       draw_text(xloc + 90,yloc, contents.width,line_height,
  560.         "#{urate}%" )
  561.      
  562.       yloc += line_height if xloc == size + 20
  563.       xloc = xloc >= 0 + size ?  0: 20+ size
  564.      
  565.     end
  566.   end
  567.    
  568.    
  569.    
  570.    
  571.     def draw_ingredients(y)
  572.       dx = 0
  573.       dy = y
  574.      
  575.       if @uItem.note =~ /<mat>((.|\s)*)<\/mat>/i#   /<(?:mat):[ ](.*)>/i#/<mat>(.|\s)*<\/mat>/m
  576.       collection = $1.split("\n")
  577.        collection.each do | val |
  578.          #p val
  579.          if val == "\r"
  580.            next
  581.          end
  582.          itemcollection = val.split(' ')
  583.                  
  584.          if itemcollection[0] == "g"
  585.             if $game_party.gold >= Integer(itemcollection[1])
  586.              change_color(text_color(11))
  587.             else
  588.               change_color(text_color(10))
  589.             end  
  590.             draw_text(0,dy+18, contents.width,line_height,
  591.             "Need #{$data_system.currency_unit}#{itemcollection[1]}, you have #{$game_party.gold}." )
  592.             dy += 18
  593.          else
  594.           itemkind = Integer(itemcollection[0])
  595.           itemId = Integer(itemcollection[1])
  596.  
  597.           if itemkind == 1 #items
  598.             pItem = $data_items[itemId]
  599.             has = $game_party.item_number($data_items[itemId])
  600.           elsif itemkind == 2 #armours
  601.             pItem = $data_armors[itemId]
  602.             has = $game_party.item_number($data_armors[itemId])
  603.           else #weapons
  604.             pItem = $data_weapons[itemId]
  605.             has = $game_party.item_number($data_weaponss[itemId])
  606.           end
  607.          
  608.           if has >= Integer(itemcollection[2])
  609.             change_color(text_color(11))
  610.           else
  611.             change_color(text_color(10))
  612.           end
  613.              
  614.           draw_text(0,dy+18, contents.width,line_height,"#{pItem.name}, need #{itemcollection[2]}, you have #{has}." )
  615.           dy += 18
  616.          end  
  617.         end
  618.       end  
  619.     end
  620.    
  621.    
  622.  
  623.     def draw_skills
  624.       change_color(system_color)  
  625.       draw_text(0,(36), contents.width,line_height,
  626.       "Skills Learn")
  627.       @loc += 2
  628.       @uItem.features.each do |   feature |
  629.         if feature.code == 43
  630.           change_color(text_color(14))
  631.           icon_index =  $data_skills[feature.data_id].icon_index
  632.           draw_icon(icon_index, 1, (18*@loc))
  633.           draw_text(26,(18*@loc), contents.width,line_height,
  634.           $data_skills[feature.data_id].name)
  635.           @loc +=1
  636.           change_color(text_color(0))
  637.         end
  638.       end
  639.     end
  640.    
  641.     def draw_item_stats
  642.       dx = 0; dy = 54
  643.       change_color(system_color)
  644.       draw_text(0,36, contents.width,line_height,"Stats")
  645.       dw = (contents.width - 48) / 3
  646.       for i in 0...8
  647.         draw_equip_param(i, dx, dy, dw)
  648.         dx = dx >= 0 + dw ? 0: 0 + dw
  649.         dy += line_height if dx == 0    
  650.       end
  651.     end
  652.  
  653.   def draw_equip_param(param_id, dx, dy, dw)
  654.     draw_background_box(dx, dy, dw)
  655.     change_color(text_color(0))    
  656.     draw_text(dx+4, dy, dw-8, line_height, Vocab::param(param_id))
  657.     draw_set_param(param_id, dx, dy, dw)
  658.   end
  659.  
  660.   def draw_set_param(param_id, dx, dy, dw)
  661.     value = @uItem.params[param_id]
  662.     change_color(param_change_color(value), value != 0)
  663.     text = value#.group
  664.     text = "+" + text.to_s if value > 0
  665.     draw_text(dx+4, dy, dw-8, line_height, text, 2)
  666.     return text
  667.   end
  668.    
  669.   def draw_background_box(dx, dy, dw)
  670.     colour = Color.new(0, 0, 0, translucent_alpha/2)
  671.     rect = Rect.new(dx+1, dy+1, dw-2, line_height-2)
  672.     contents.fill_rect(rect, colour)
  673.   end
  674. end
  675.  
  676. class Window_CraftingChooices < Window_ItemList
  677.     def initialize()
  678.   super(0,48,Graphics.width-Graphics.width/1.5,Graphics.height-(48))
  679.  
  680.  
  681.   end
  682.  
  683.   @m_type = "";
  684.  
  685.   def create_list(m_type)
  686.       @m_type = m_type
  687.   end
  688.  
  689.  
  690.   def see_unlocks(item)
  691.     show = true;
  692.     if item.note =~ /<unlock>((.|\s)*)<\/unlock>/i
  693.         unlocks = $1.gsub("\r", "").split("\n")
  694.          unlocks.each do | unlock|
  695.            if unlock == "" || unlock == nil
  696.              next
  697.            end
  698.            unlockVals = unlock.split(' ');
  699.            case unlockVals[0]
  700.             when "party"
  701.              if  $game_party.highest_level < Integer(unlockVals[1])
  702.                show = false
  703.             end
  704.             when "switch"
  705.               if $game_switches[Integer(unlockVals[1])] == false
  706.                 show = false
  707.               end
  708.             end
  709.            
  710.          end
  711.     end
  712.     return show
  713.   end
  714.  
  715.   def make_item_list
  716.     @data =[]
  717.      
  718.     if @m_type == nil
  719.       @data.push({:kind => 1,:name => "Items"})
  720.       @data.push({:kind => 2,:name => "Weapons"})
  721.       @data.push({:kind => 3,:name => "Armour"})
  722.     elsif @m_type[:kind] == 1
  723.      
  724.       useCategorie = false;
  725.       if $item_categories != nil
  726.         useCategorie = true;
  727.        
  728.         $item_categories.each do | categor |
  729.            @data.push({:kind => 6, :name => categor})
  730.         end
  731.        
  732.       end
  733.      
  734.       $data_items.each do | item |
  735.         if item == nil || item == ""
  736.           next
  737.         end
  738.        
  739.         if item.note =~ /<mat>(.|\s)*<\/mat>/i
  740.           if see_unlocks(item) == true
  741.             if item.note !~ /<cType: (.*)>/i
  742.               @data.push({:kind => -3, :term_id => item.id,:name => item.name , :icon => item.icon_index})
  743.             end
  744.           end
  745.         end
  746.       end
  747.       elsif @m_type[:kind] == 6
  748.         $data_items.each do | item |
  749.           if item == nil || item == ""
  750.             next
  751.           end
  752.           if item.note =~ /<mat>(.|\s)*<\/mat>/i
  753.             if see_unlocks(item) == true
  754.               if item.note =~ /<cType: (.*)>/i
  755.                 if $1.downcase == @m_type[:name].downcase
  756.                   @data.push({:kind => -3, :term_id => item.id,:name => item.name , :icon => item.icon_index})
  757.                 end
  758.               end
  759.             end
  760.           end
  761.         end
  762.     elsif @m_type[:kind] == 3
  763.       wtype = 1
  764.       $data_system.armor_types .each do |armor|
  765.         if armor == nil || armor == ""
  766.           next
  767.         end
  768.  
  769.         notuse = false
  770.  
  771.         $armor_ignore.each do | id |
  772.           if id == wtype
  773.             notuse = true
  774.           end
  775.         end
  776.  
  777.         if notuse == false
  778.           @data.push({:kind => 5, :term_id => wtype, :name => armor})
  779.         end
  780.         wtype += 1
  781.       end
  782.     elsif @m_type[:kind] == 2
  783.       wtype = 1
  784.       $data_system.weapon_types .each do |weapon|
  785.         notuse = false
  786.         if weapon == nil || weapon == ""
  787.           next
  788.         end
  789.         $weapon_ignore.each do | id |
  790.           if id == wtype
  791.             notuse = true
  792.           end
  793.         end
  794.       if notuse == false
  795.         @data.push({:kind => 4, :term_id => wtype, :name => weapon})
  796.       end  
  797.       wtype += 1
  798.     end
  799.     elsif @m_type[:kind] == 4
  800.       $data_weapons.each do | qw |
  801.       if qw == nil
  802.         next
  803.       end
  804.       if qw.wtype_id  == @m_type[:term_id]
  805.         if qw.note =~ /<mat>(.|\s)*<\/mat>/i
  806.           if see_unlocks(qw) == true
  807.             @data.push({:kind => -1, :term_id => qw.id, :name => qw.name, :icon => qw.icon_index})
  808.           end
  809.         end
  810.       end
  811.     end  
  812.     elsif @m_type[:kind] == 5
  813.       $data_armors.each do | qw |
  814.         if qw == nil
  815.           next
  816.         end
  817.         if qw.atype_id  == @m_type[:term_id]
  818.           if qw.note =~ /<mat>(.|\s)*<\/mat>/i
  819.             if see_unlocks(qw) == true
  820.             @data.push({:kind => -2, :term_id =>  qw.id, :name => qw.name, :icon =>  qw.icon_index})
  821.           end
  822.           end
  823.         end
  824.       end  
  825.     end
  826.   end
  827.  
  828.   def draw_item(index)
  829.     change_color(text_color(0))
  830.     contents.font.size = 18
  831.     item = @data[index]
  832.     if item
  833.       rect = item_rect(index)
  834.       rect.width -= 4
  835.      
  836.       if item[:icon] != nil
  837.           draw_icon(item[:icon],0,rect.y)
  838.           rect.x = 26
  839.           draw_text(rect, item[:name])
  840.         else
  841.           draw_text(rect, item[:name])
  842.       end
  843.      
  844.     end
  845.   end
  846.   def col_max; 1; end
  847.     def current_item
  848.     @data[@index]
  849.   end
  850.   def current_item_enabled?
  851.     true
  852.   end
  853.  
  854. end
  855.  
  856.  
  857. class Window_CraftItem < Window_Command
  858.   def initialize
  859.     super(0,0)
  860.     self.openness = 0
  861.   end
  862.   def Set(item)
  863.     @item = item
  864.   end
  865.   def make_command_list
  866.   return unless @item
  867.        
  868.       if @item[:kind] == -3
  869.         uItem = $data_items[@item[:term_id]]
  870.       elsif @item[:kind] == -2
  871.         uItem = $data_armors[@item[:term_id]]
  872.       else
  873.         uItem = $data_weapons[@item[:term_id]]
  874.       end
  875.  
  876.       add_command("Craft #{uItem.name}", :craft)
  877.       add_command("Cancel", :cancel)
  878.  
  879.   end
  880.   def window_height
  881.     fitting_height(2)
  882.   end
  883. end
  884.  
  885.  
  886. module ELEMENTME
  887.   ELEMENTS = {}
  888.   ELEMENTS["Physical"] = {  
  889.     :icon => 116
  890.   }
  891.   ELEMENTS["Absorb"] = {
  892.     :icon => 0
  893.   }
  894.   ELEMENTS["Fire"] = {
  895.     :icon => 96
  896.   }
  897.   ELEMENTS["Ice"] = {
  898.     :icon => 97
  899.   }
  900.   ELEMENTS["Thunder"] = {
  901.     :icon => 98
  902.   }
  903.   ELEMENTS["Water"] = {
  904.     :icon => 99
  905.   }
  906.   ELEMENTS["Earth"] = {
  907.     :icon => 100
  908.   }
  909.   ELEMENTS["Wind"] = {
  910.     :icon => 101
  911.   }
  912.   ELEMENTS["Holy"] = {
  913.     :icon => 102
  914.   }
  915.   ELEMENTS["Dark"] = {
  916.     :icon => 103
  917.   }
  918. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement