查看: 3193|回复: 8

[已经解决] 寻找【道具生成系统】

[复制链接]
梦石
1
星屑
7574
在线时间
2650 小时
注册时间
2013-8-23
回帖
2152

开拓者

发表于 2013-8-28 16:00:30 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 鑫晴 于 2013-8-29 11:44 编辑

                                    
                                

                                              虽然知道伸手不好,但是找了很久都没找到满意的。
                                                                                                                                                                                                  
                                如果大家手头上有这脚本,麻烦您按下手中的"Ctrl+C"然后在回帖框中"Ctrl+V" ,谢谢!




                                 吐槽 1:  关于【生成系统】的,找了很多个脚本,都是NPC版的,VA超级整合那样....
                                 吐槽 2:  在论坛翻了几个小时,10个关于【生成系统】的脚本,70%以上都是VX,XP版本....




                                      
                                      【问题描述】:
                                                                                                                             
                                                 我想要一个想【任务系统】那样子的,直接打开菜单,就可以使用。

                                       
                                     【版本要求】:
                                                
                                                  RMVXAce




                     

                                                  
                                                                            华丽丽地向各位伸手......
         

                                                                                         默默等待着各位的复制粘贴......









                     
梦石
0
星屑
600
在线时间
1118 小时
注册时间
2012-12-24
回帖
761
发表于 2013-8-28 16:22:32 | 显示全部楼层
没明白楼主想要什么啊
是合成系统吗?

点评

是的  发表于 2013-8-28 16:32

点击签名档去一个神奇的地方
回复

使用道具 举报

梦石
0
星屑
600
在线时间
1118 小时
注册时间
2012-12-24
回帖
761
发表于 2013-8-28 16:36:04 | 显示全部楼层

  1. #encoding:utf-8
  2. #==============================================================================
  3. #
  4. #每添加一个制造的类型,最上面的类别菜单就会多一项。
  5. #
  6. #添加类型的方法是:
  7. #$game_party.add_cook_type(类别名称,类别介绍, 类别状态-默认false)
  8. #
  9. #举例:
  10. #$game_party.add_cook_type("制药","调配药品", true)
  11. #
  12. #添加配方的方法:
  13. #$game_party.add_cookbook(配方名称, 配方介绍, 配方类别名称,材料的二维数组,产出物的二维数组,配方状态默认为true)
  14. #
  15. #举例:
  16. #$game_party.add_cookbook("初级补血药水", "制作初级补血药水", "制药",[[18,2],[3,4],[2,5]],[[1,1],[44,5]],true)
  17. #
  18. #调用窗口的方法:SceneManager.call(Scene_Cook)
  19. #==============================================================================

  20. #==============================================================================
  21. # ■ Cookbook_Type
  22. #------------------------------------------------------------------------------
  23. #  食谱类型类。
  24. #==============================================================================

  25. class Cookbook_Type
  26.   attr_reader :index
  27.   attr_reader :name
  28.   attr_reader :description
  29.   attr_reader :enabled
  30.   #--------------------------------------------------------------------------
  31.   # ● 初始化对象
  32.   #--------------------------------------------------------------------------
  33.   def initialize(index, name, description, enabled = false)
  34.     [url=home.php?mod=space&uid=370741]@Index[/url] = index
  35.     @name = name
  36.     @description = description
  37.     @enabled = enabled
  38.   end
  39.   
  40.   def enable(en)
  41.     @enabled = en
  42.   end
  43. end

  44. #==============================================================================
  45. # ■ Cookbook
  46. #------------------------------------------------------------------------------
  47. #  食谱类。本类在 Game_Task 类的内部使用。
  48. #   食谱属性:食谱序号,食谱名称,食谱类型,食谱介绍,原料,成品
  49. #==============================================================================

  50. class Cookbook
  51.   attr_reader :index
  52.   attr_reader :name
  53.   attr_reader :description
  54.   attr_reader :type
  55.   attr_reader :input
  56.   attr_reader :output
  57.   attr_reader :enabled
  58.   #--------------------------------------------------------------------------
  59.   # ● 初始化对象
  60.   #--------------------------------------------------------------------------
  61.   def initialize(index, name, description, type, input, output, enabled = true)
  62.     @index = index
  63.     @name = name
  64.     @description = description
  65.     @type = type
  66.     @input = input
  67.     @output = output
  68.     @enabled = enabled
  69.   end
  70.   
  71.   def enable(en)
  72.     @enabled = en
  73.   end
  74.   
  75.   #--------------------------------------------------------------------------
  76.   # ● 查询列表中的物品
  77.   #--------------------------------------------------------------------------
  78.   def in_list?(item, list)
  79.     list.each do |arr|
  80.       return true if arr[0] == item.id
  81.     end
  82.     return false
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ● 查询是否是材料列表中的物品
  86.   #--------------------------------------------------------------------------
  87.   def resource?(item)
  88.     in_list?(item, @input)
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # ● 查询是否是产出列表中的物品
  92.   #--------------------------------------------------------------------------
  93.   def output?(item)
  94.     in_list?(item, @output)
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # ● 查询材料需求量
  98.   #--------------------------------------------------------------------------
  99.   def amount(item, i)
  100.     if i == 0
  101.       @input.each do |arr|
  102.         return arr[1] if arr[0] == item.id
  103.       end
  104.     else
  105.       @output.each do |arr|
  106.         return arr[1] if arr[0] == item.id
  107.       end
  108.     end
  109.     return 0
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   # ● 查询材料是否足够
  113.   #--------------------------------------------------------------------------
  114.   def enough?
  115.     input.each do |arr|
  116.       return false if $data_items[arr[0]] && arr[1] > $game_party.item_number($data_items[arr[0]])
  117.     end
  118.     return true
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● 查询某件材料是否足够
  122.   #--------------------------------------------------------------------------
  123.   def item_enough?(item)
  124.     input.each do |arr|
  125.       return false if arr[0] == item.id && arr[1] > $game_party.item_number(item)
  126.     end
  127.     return true
  128.   end
  129. end

  130. #==============================================================================
  131. # ■ Game_Party
  132. #==============================================================================

  133. class Game_Party < Game_Unit
  134.   #--------------------------------------------------------------------------
  135.   # ● 初始化对象
  136.   #--------------------------------------------------------------------------
  137.   alias old_init initialize
  138.   def initialize
  139.     old_init
  140.     @cook_types = []
  141.     @cookbooks = []
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # ● 添加新的食谱类型
  145.   #--------------------------------------------------------------------------
  146.   def add_cook_type(n, d, en)
  147.     @cook_types.push(Cookbook_Type.new(@cook_types.size, n, d, en)) if !have_cook_type?(n)
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # ● 添加新的食谱
  151.   #--------------------------------------------------------------------------
  152.   def add_cookbook(n, d, type, input, output, en)
  153.     if !have_cookbook?(n) && have_cook_type?(type)
  154.       @cookbooks.push(Cookbook.new(@cookbooks.size, n, d, type, input, output, en))
  155.     end
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # ● 判断名称为n的食谱类型是否存在
  159.   #--------------------------------------------------------------------------
  160.   def have_cook_type?(n)
  161.     @cook_types.each do |x|
  162.       return true if x.name == n
  163.     end
  164.     return false
  165.   end
  166.   #--------------------------------------------------------------------------
  167.   # ● 判断名称为n的食谱是否存在
  168.   #--------------------------------------------------------------------------
  169.   def have_cookbook?(n)
  170.     @cookbooks.each do |x|
  171.       return true if x.name == n
  172.     end
  173.     return false
  174.   end
  175.   #--------------------------------------------------------------------------
  176.   # ● 返回食谱类型列表
  177.   #--------------------------------------------------------------------------
  178.   def cook_types
  179.     return @cook_types
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # ● 返回食谱列表
  183.   #--------------------------------------------------------------------------
  184.   def cookbooks(type = nil)
  185.     return @cookbooks if type == nil
  186.     arr = []
  187.     @cookbooks.each do |x|
  188.       arr.push(x) if x.type == type
  189.     end
  190.     return arr
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # ● 更改序号为i的食谱类型的使用状态
  194.   #--------------------------------------------------------------------------
  195.   def set_cook_type(i, en)
  196.     @cook_types[i].enable(en)
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # ● 更改序号为i的食谱的使用状态
  200.   #--------------------------------------------------------------------------
  201.   def set_cookbook(i, en)
  202.     @cookbooks[i].enable(en)
  203.   end
  204.   #--------------------------------------------------------------------------
  205.   # ● 返回食谱类型数目
  206.   #--------------------------------------------------------------------------
  207.   def cook_types_size
  208.     return @cook_types.size
  209.   end
  210.   #--------------------------------------------------------------------------
  211.   # ● 查询名称为n的食谱类型的描述
  212.   #--------------------------------------------------------------------------
  213.   def cook_type_description(n)
  214.     @cook_types.each do |x|
  215.       return x.description if x.name == n
  216.     end
  217.     return ""
  218.   end
  219. end

  220. #==============================================================================
  221. # ■ Scene_Cook
  222. #------------------------------------------------------------------------------
  223. #  烹饪画面
  224. #==============================================================================

  225. class Scene_Cook < Scene_ItemBase
  226.   #--------------------------------------------------------------------------
  227.   # ● 开始处理
  228.   #--------------------------------------------------------------------------
  229.   def start
  230.     super
  231.     create_category_window
  232.     create_cookbook_window
  233.     create_description_window
  234.     create_needs_window
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # ● 生成分类窗口
  238.   #--------------------------------------------------------------------------
  239.   def create_category_window
  240.     @category_window = Window_CookCategory.new
  241.     @category_window.viewport = @viewport
  242.     @category_window.y = 0
  243.     @category_window.set_handler(:ok,     method(:on_category_ok))
  244.     @category_window.set_handler(:cancel, method(:return_scene))
  245.   end
  246.   #--------------------------------------------------------------------------
  247.   # ● 生成食谱窗口
  248.   #--------------------------------------------------------------------------
  249.   def create_cookbook_window
  250.     wy = @category_window.height
  251.     wh = Graphics.height - wy
  252.     @item_window = Window_CookList.new(0, wy, Graphics.width*0.5 , wh)
  253.     @item_window.viewport = @viewport
  254.     @item_window.set_handler(:ok,     method(:on_item_ok))
  255.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  256.     @category_window.item_window = @item_window
  257.   end
  258.   #--------------------------------------------------------------------------
  259.   # ● 生成描述窗口
  260.   #--------------------------------------------------------------------------
  261.   def create_description_window
  262.     wy = @category_window.height
  263.     @help_window = Window_Description.new(Graphics.width*0.5, wy)
  264.     @help_window.viewport = @viewport
  265.     @item_window.help_window = @help_window
  266.     @category_window.help_window = @help_window
  267.   end
  268.     #--------------------------------------------------------------------------
  269.   # ● 生成材料窗口
  270.   #--------------------------------------------------------------------------
  271.   def create_needs_window
  272.     wy = @category_window.height + @help_window.height
  273.     wh = Graphics.height - wy
  274.     @needs_window = Window_NeedsList.new(Graphics.width*0.5, wy, Graphics.width*0.5 , wh)
  275.     #@item_window.viewport = @viewport
  276.     @item_window.needs_window = @needs_window
  277.    
  278.   end
  279.   #--------------------------------------------------------------------------
  280.   # ● 分类“确定”
  281.   #--------------------------------------------------------------------------
  282.   def on_category_ok
  283.     @item_window.activate
  284.     @item_window.select_last
  285.   end
  286.   #--------------------------------------------------------------------------
  287.   # ● 食谱“确定”
  288.   #--------------------------------------------------------------------------
  289.   def on_item_ok
  290.     #$game_party.last_item.object = item
  291.     cook
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # ● 食谱“取消”
  295.   #--------------------------------------------------------------------------
  296.   def on_item_cancel
  297.     @item_window.unselect
  298.     @category_window.activate
  299.   end
  300.   #--------------------------------------------------------------------------
  301.   # ● 烹饪
  302.   #--------------------------------------------------------------------------
  303.   def cook
  304.     if item.enough?
  305.       play_se_for_item
  306.       use_item
  307.       @needs_window.refresh
  308.       @item_window.refresh
  309.       activate_item_window
  310.     end
  311.   end
  312.   #--------------------------------------------------------------------------
  313.   # ● 播放制作声效
  314.   #--------------------------------------------------------------------------
  315.   def play_se_for_item
  316.     Sound.play_recovery
  317.   end
  318.   #--------------------------------------------------------------------------
  319.   # ● 使用食谱
  320.   #--------------------------------------------------------------------------
  321.   def use_item
  322.     #super
  323.     #@item_window.redraw_current_item
  324.     $data_items.each do |it|
  325.       if it && !it.name.empty?
  326.         $game_party.gain_item(it,-item.amount(it,0)) if item.resource?(it)
  327.         $game_party.gain_item(it,item.amount(it,1)) if item.output?(it)
  328.       end
  329.     end
  330.   end
  331. end


  332. #==============================================================================
  333. # ■ Window_CookCategory
  334. #------------------------------------------------------------------------------
  335. #  烹饪画面中,显示食谱类型的窗口。
  336. #==============================================================================

  337. class Window_CookCategory < Window_HorzCommand
  338.   #--------------------------------------------------------------------------
  339.   # ● 定义实例变量
  340.   #--------------------------------------------------------------------------
  341.   attr_reader   :item_window
  342.   #--------------------------------------------------------------------------
  343.   # ● 初始化对象
  344.   #--------------------------------------------------------------------------
  345.   def initialize
  346.     super(0, 0)
  347.   end
  348.   #--------------------------------------------------------------------------
  349.   # ● 获取窗口的宽度
  350.   #--------------------------------------------------------------------------
  351.   def window_width
  352.     Graphics.width
  353.   end
  354.   #--------------------------------------------------------------------------
  355.   # ● 获取列数
  356.   #--------------------------------------------------------------------------
  357.   def col_max
  358.     return $game_party.cook_types_size
  359.   end
  360.   #--------------------------------------------------------------------------
  361.   # ● 更新画面
  362.   #--------------------------------------------------------------------------
  363.   def update
  364.     super
  365.     #@item_window.category = current_symbol if @item_window
  366.     @item_window.category = current_data[:name] if @item_window
  367.   end
  368.   #--------------------------------------------------------------------------
  369.   # ● 生成食谱类型列表
  370.   #--------------------------------------------------------------------------
  371.   def make_command_list
  372.     $game_party.cook_types.each do |t|
  373.       add_command(t.name, t.index, t.enabled)
  374.     end
  375.   end
  376.   #--------------------------------------------------------------------------
  377.   # ● 设置食谱列表窗口
  378.   #--------------------------------------------------------------------------
  379.   def item_window=(item_window)
  380.     @item_window = item_window
  381.     update
  382.   end
  383.   #--------------------------------------------------------------------------
  384.   # ● 更新帮助内容
  385.   #--------------------------------------------------------------------------
  386.   def update_help
  387.     @help_window.set_text($game_party.cook_type_description(current_data[:name]))
  388.   end
  389. end

  390. #==============================================================================
  391. # ■ Window_CookList
  392. #------------------------------------------------------------------------------
  393. #  任务画面中,显示已获得任务的窗口。
  394. #==============================================================================

  395. class Window_CookList < Window_Selectable
  396.   #--------------------------------------------------------------------------
  397.   # ● 定义实例变量
  398.   #--------------------------------------------------------------------------
  399.   attr_reader   :needs_window
  400.   #--------------------------------------------------------------------------
  401.   # ● 初始化对象
  402.   #--------------------------------------------------------------------------
  403.   def initialize(x, y, width, height)
  404.     super
  405.     @data = []
  406.     @category = $game_party.cook_types_size > 0 ? $game_party.cook_types[0].name : nil
  407.     refresh
  408.   end
  409.   #--------------------------------------------------------------------------
  410.   # ● 设置分类
  411.   #--------------------------------------------------------------------------
  412.   def category=(category)
  413.     return if @category == category
  414.     @category = category
  415.     refresh
  416.     self.oy = 0
  417.   end
  418.   #--------------------------------------------------------------------------
  419.   # ● 设置材料窗口
  420.   #--------------------------------------------------------------------------
  421.   def needs_window=(needs_window)
  422.     @needs_window = needs_window
  423.     update
  424.   end
  425.   #--------------------------------------------------------------------------
  426.   # ● 获取列数
  427.   #--------------------------------------------------------------------------
  428.   def col_max
  429.     return 1
  430.   end
  431.   #--------------------------------------------------------------------------
  432.   # ● 获取项目数
  433.   #--------------------------------------------------------------------------
  434.   def item_max
  435.     @data ? @data.size : 1
  436.   end
  437.   #--------------------------------------------------------------------------
  438.   # ● 获取食谱
  439.   #--------------------------------------------------------------------------
  440.   def item
  441.     @data && index >= 0 ? @data[index] : nil
  442.   end
  443.   #--------------------------------------------------------------------------
  444.   # ● 获取选择食谱的有效状态
  445.   #--------------------------------------------------------------------------
  446.   def current_item_enabled?
  447.     enable?(@data[index])
  448.   end
  449.   #--------------------------------------------------------------------------
  450.   # ● 查询此食谱是否可用
  451.   #--------------------------------------------------------------------------
  452.   def enable?(item)
  453.     item.enabled && item.enough?
  454.   end
  455.   #--------------------------------------------------------------------------
  456.   # ● 生成食谱列表
  457.   #--------------------------------------------------------------------------
  458.   def make_item_list
  459.     @data = $game_party.cookbooks(@category)
  460.   end
  461.   #--------------------------------------------------------------------------
  462.   # ● 返回上一个选择的位置
  463.   #--------------------------------------------------------------------------
  464.   def select_last
  465.     select(0)
  466.   end
  467.   #--------------------------------------------------------------------------
  468.   # ● 绘制项目
  469.   #--------------------------------------------------------------------------
  470.   def draw_item(index)
  471.     item = @data[index]
  472.     if item
  473.       rect = item_rect(index)
  474.       rect.width -= 4
  475.       draw_item_name(item, rect.x, rect.y, enable?(item))
  476.     end
  477.   end
  478.   #--------------------------------------------------------------------------
  479.   # ● 绘制名称
  480.   #     enabled : 有效的标志。false 的时候使用半透明效果绘制
  481.   #--------------------------------------------------------------------------
  482.   def draw_item_name(item, x, y, enabled = true, width = 300)
  483.     return unless item
  484.     text = item.name
  485.     text += "[材料不足]" if !item.enough?
  486.     change_color(normal_color, enabled)
  487.     draw_text(x, y, width, line_height, text)
  488.   end
  489.   #--------------------------------------------------------------------------
  490.   # ● 更新帮助内容
  491.   #--------------------------------------------------------------------------
  492.   def update_help
  493.     @help_window.set_item(item)
  494.   end
  495.    #--------------------------------------------------------------------------
  496.   # ● 更新食谱清单
  497.   #--------------------------------------------------------------------------
  498.   def update_needslist
  499.     @needs_window.set_item(item)
  500.   end
  501.   #--------------------------------------------------------------------------
  502.   # ● 调用帮助窗口的更新方法
  503.   #--------------------------------------------------------------------------
  504.   def call_update_help
  505.     update_help if @help_window
  506.     update_needslist if @needs_window
  507.   end
  508.   #--------------------------------------------------------------------------
  509.   # ● 刷新
  510.   #--------------------------------------------------------------------------
  511.   def refresh
  512.     make_item_list
  513.     create_contents
  514.     draw_all_items
  515.   end
  516. end
  517. #==============================================================================
  518. # ■ Window_Description
  519. #------------------------------------------------------------------------------
  520. #  显示食谱的说明的窗口
  521. #==============================================================================

  522. class Window_Description < Window_Base
  523.   #--------------------------------------------------------------------------
  524.   # ● 初始化对象
  525.   #--------------------------------------------------------------------------
  526.   def initialize(x, y)
  527.     super(x, y, Graphics.width*0.5, fitting_height(4))
  528.   end
  529.   #--------------------------------------------------------------------------
  530.   # ● 设置内容
  531.   #--------------------------------------------------------------------------
  532.   def set_text(text)
  533.     if text != @text
  534.       @text = text
  535.       refresh
  536.     end
  537.   end
  538.   #--------------------------------------------------------------------------
  539.   # ● 清除
  540.   #--------------------------------------------------------------------------
  541.   def clear
  542.     set_text("")
  543.   end
  544.   #--------------------------------------------------------------------------
  545.   # ● 设置食谱的介绍
  546.   #--------------------------------------------------------------------------
  547.   def set_item(item)
  548.     set_text(item ? item.description : "")
  549.   end
  550.   #--------------------------------------------------------------------------
  551.   # ● 刷新
  552.   #--------------------------------------------------------------------------
  553.   def refresh
  554.     contents.clear
  555.     draw_text_ex(4, 0, @text)
  556.   end
  557. end

  558. #==============================================================================
  559. # ■ Window_NeedsList
  560. #------------------------------------------------------------------------------
  561. #  烹饪画面中,显示食谱所需材料的窗口。
  562. #==============================================================================

  563. class Window_NeedsList < Window_Selectable
  564.   #--------------------------------------------------------------------------
  565.   # ● 初始化对象
  566.   #--------------------------------------------------------------------------
  567.   def initialize(x, y, width, height)
  568.     super
  569.     @category = :item
  570.     @cookbook = nil
  571.     @data = []
  572.     refresh
  573.   end
  574.   #--------------------------------------------------------------------------
  575.   # ● 获取列数
  576.   #--------------------------------------------------------------------------
  577.   def col_max
  578.     return 1
  579.   end
  580.   #--------------------------------------------------------------------------
  581.   # ● 获取项目数
  582.   #--------------------------------------------------------------------------
  583.   def item_max
  584.     @data ? @data.size : 1
  585.   end
  586.   #--------------------------------------------------------------------------
  587.   # ● 获取物品
  588.   #--------------------------------------------------------------------------
  589.   def item
  590.     @data && index >= 0 ? @data[index] : nil
  591.   end
  592.   #--------------------------------------------------------------------------
  593.   # ● 查询列表中是否含有此物品
  594.   #--------------------------------------------------------------------------
  595.   def include?(item)
  596.     item.is_a?(RPG::Item) && !item.key_item?
  597.   end
  598.   #--------------------------------------------------------------------------
  599.   # ● 获取选择食谱的有效状态
  600.   #--------------------------------------------------------------------------
  601.   def current_item_enabled?
  602.     enable?(@data[index])
  603.   end
  604.   #--------------------------------------------------------------------------
  605.   # ● 查询此食谱是否可用
  606.   #--------------------------------------------------------------------------
  607.   def enable?(item)
  608.     $game_party.usable?(item) && @cookbook.item_enough?(item)
  609.   end
  610.   #--------------------------------------------------------------------------
  611.   # ● 生成物品列表
  612.   #--------------------------------------------------------------------------
  613.   def make_item_list
  614.     @data = []
  615.     return if @cookbook== nil
  616.     tmp1 = []
  617.     tmp2 = []
  618.     $data_items.each do |item|
  619.       tmp1.push([item, 0]) if item && !item.name.empty? && @cookbook.resource?(item)
  620.       tmp2.push([item, 1]) if item && !item.name.empty? && @cookbook.output?(item)
  621.     end
  622.     if tmp1.size > 0 && tmp2.size > 0
  623.       @data.push(["需要材料:",0])
  624.       @data += tmp1
  625.       @data.push(["可以获得:",1])
  626.       @data += tmp2
  627.     end
  628.   end
  629.   #--------------------------------------------------------------------------
  630.   # ● 返回上一个选择的位置
  631.   #--------------------------------------------------------------------------
  632.   def select_last
  633.     select(0)
  634.   end
  635.   #--------------------------------------------------------------------------
  636.   # ● 绘制项目
  637.   #--------------------------------------------------------------------------
  638.   def draw_item(index)
  639.     item = @data[index]
  640.     if item
  641.       rect = item_rect(index)
  642.       rect.width -= 4
  643.       if item[0].is_a?(RPG::Item)
  644.         draw_item_name(item, rect.x, rect.y, enable?(item[0]))
  645.         draw_item_number(rect, item[0])
  646.       else
  647.         draw_input_output(item, rect.x, rect.y)
  648.       end
  649.     end
  650.   end
  651.   #--------------------------------------------------------------------------
  652.   # ● 绘制物品名称
  653.   #     enabled : 有效的标志。false 的时候使用半透明效果绘制
  654.   #--------------------------------------------------------------------------
  655.   def draw_item_name(item, x, y, enabled = true, width = 172)
  656.     return unless item
  657.     text = item[0].name + "*" + String(@cookbook.amount(item[0], item[1]))
  658.     draw_icon(item[0].icon_index, x, y, enabled)
  659.     change_color(normal_color, enable?(item[0]))
  660.     draw_text(x + 24, y, width, line_height, text)
  661.   end
  662.   #--------------------------------------------------------------------------
  663.   # ● 绘制输入和产出
  664.   #--------------------------------------------------------------------------
  665.   def draw_input_output(item, x, y, enabled = false, width = 172)
  666.     return unless item
  667.     if item[1] == 0
  668.       text = "[需要]"
  669.     else
  670.       text = "[可以获得]"
  671.     end
  672.     change_color(normal_color, @cookbook.enough?)
  673.     draw_text(x , y, width, line_height, text)
  674.   end
  675.   #--------------------------------------------------------------------------
  676.   # ● 绘制物品个数
  677.   #--------------------------------------------------------------------------
  678.   def draw_item_number(rect, item)
  679.     draw_text(rect, sprintf("现有%2d", $game_party.item_number(item)), 2)
  680.   end
  681.   #--------------------------------------------------------------------------
  682.   # ● 刷新
  683.   #--------------------------------------------------------------------------
  684.   def refresh
  685.     make_item_list
  686.     create_contents
  687.     draw_all_items
  688.   end
  689.   #--------------------------------------------------------------------------
  690.   # ● 设置食谱的材料
  691.   #--------------------------------------------------------------------------
  692.   def set_item(item)
  693.     @cookbook = item
  694.     refresh
  695.   end
  696. end
复制代码
每添加一个制造的类型,最上面的类别菜单就会多一项。
添加类型的方法是:$game_party.add_cook_type(类别名称,类别介绍, 类别状态-默认false)
举例:$game_party.add_cook_type("制药","调配药品", true)

添加配方的方法:$game_party.add_cookbook(配方名称, 配方介绍, 配方类别名称,材料的二维数组,产出物的二维数组,true)
举例:$game_party.add_cookbook("初级补血药水配方", "用赤血草制作初级补血药水", "制药",[[18,2],[3,4],[2,5]],[[1,1],[44,5]],true)
二维数组里面,每一个[m,n]里的m是物品id,n是需要物品的数量。理论上来说加几个不同物品都是没问题的。但是显示材料的窗口会显示不下。。

调用窗口的方法:SceneManager.call(Scene_Cook)


点评

把第37行,[url=home.php?mod=space&uid=370741]以及[/url]去掉~~  发表于 2013-8-28 20:08
第37行, [url=home.php?mod=space&uid=370741]@Index[/url] = index,这句话会报错  发表于 2013-8-28 16:48

点击签名档去一个神奇的地方
回复

使用道具 举报

梦石
1
星屑
7574
在线时间
2650 小时
注册时间
2013-8-23
回帖
2152

开拓者

 楼主| 发表于 2013-8-28 16:43:46 | 显示全部楼层
调用窗口的方法:SceneManager.call(Scene_Cook)

新建一个事件,然后选择自动执行,插入脚本SceneManager.call(Scene_Cook),就可以在菜单栏中打开了吗?
回复

使用道具 举报

梦石
1
星屑
7574
在线时间
2650 小时
注册时间
2013-8-23
回帖
2152

开拓者

 楼主| 发表于 2013-8-28 18:27:50 | 显示全部楼层
本帖最后由 鑫晴 于 2013-8-28 18:31 编辑

                                                                                                    ◆ 连贴 ◆
  
                                                                       @江户川洛奇                                             



                                                                                              那个脚本用不了。


                                   
情况一:当完整的复制粘贴过去后,F12运行,弹出错误:
                  

                                                          21.png


                    


  情况二:当删除提示错误的那句
         
[pre lang="ruby" line="1"]@Index = index[/pre]


                  再次运行,又弹出个错误:
                     
                                     12.png

              






                                                                               {:2_271:}请问要怎么解决?









点评

还是不行....T T  发表于 2013-8-28 20:16
把第37行,[url=home.php?mod=space&uid=370741]以及[/url]去掉~~ @Index不要去掉~~  发表于 2013-8-28 20:09
回复

使用道具 举报

梦石
0
星屑
407
在线时间
1291 小时
注册时间
2013-1-12
回帖
3349

贵宾

发表于 2013-8-29 04:54:17 | 显示全部楼层
試試白魔的
[pre lang="ruby" line="1"]#==============================================================================
# ■ RGSS3 合成 ver 1.01
#------------------------------------------------------------------------------
#  配布元:
#     白の魔 http://izumiwhite.web.fc2.com/
#
#  利用規約:
#     RPGツクールVXの正規の登録者のみご利用になれます。
#     利用報告・著作権表示とかは必要ありません。
#     改造もご自由にどうぞ。
#     何か問題が発生しても責任は持ちません。
#==============================================================================


#--------------------------------------------------------------------------
# ★ 初期設定。
#    合成レシピ等の設定
#--------------------------------------------------------------------------
module WD_itemsynthesis_ini
  
  Cost_view =  true #費用(G)の表示(合成の費用が全て0Gの場合はfalseを推奨)
  
  Category_i = true #カテゴリウィンドウに「アイテム」の項目を表示
  Category_w = false #カテゴリウィンドウに「武器」の項目を表示
  Category_a = false #カテゴリウィンドウに「防具」の項目を表示
  Category_k = false #カテゴリウィンドウに「大事なもの」の項目を表示
  
  I_recipe = [] #この行は削除しないこと
  W_recipe = [] #この行は削除しないこと
  A_recipe = [] #この行は削除しないこと
  
  #以下、合成レシピ。
  #例: I_recipe[3]  = [100, ["I",1,1], ["W",2,1], ["A",2,2], ["A",3,1]]
  #と記載した場合、ID3のアイテムの合成必要は、100G。
  #必要な素材は、ID1のアイテム1個、ID2の武器1個、ID2の防具2個、ID3の防具1個
  #となる。
  
  #アイテムの合成レシピ
  I_recipe[1]  = [0,  ["I",4,1], ["I",5,1]]

  #武器の合成レシピ
   W_recipe[2]  = [40,   ["A",1,2]]
  #防具の合成レシピ  
  A_recipe[2]  = [40,   ["A",1,2]]
end


#==============================================================================
# ■ WD_itemsynthesis
#------------------------------------------------------------------------------
#  アイテム合成用の共通メソッドです。
#==============================================================================

module WD_itemsynthesis
  def i_recipe_switch_on(id)
    $game_system.i_rcp_sw = [] if $game_system.i_rcp_sw == nil
    $game_system.i_rcp_sw[id] = false if $game_system.i_rcp_sw[id] == nil
    $game_system.i_rcp_sw[id] = true
  end
  def i_recipe_switch_off(id)
    $game_system.i_rcp_sw = [] if $game_system.i_rcp_sw == nil
    $game_system.i_rcp_sw[id] = false if $game_system.i_rcp_sw[id] == nil
    $game_system.i_rcp_sw[id] = false
  end
  def i_recipe_switch_on?(id)
    $game_system.i_rcp_sw = [] if $game_system.i_rcp_sw == nil
    $game_system.i_rcp_sw[id] = false if $game_system.i_rcp_sw[id] == nil
    return $game_system.i_rcp_sw[id]
  end
  def i_recipe_all_switch_on
    for i in 1..$data_items.size
      i_recipe_switch_on(i)
    end
  end
  def i_recipe_all_switch_off
    for i in 1..$data_items.size
      i_recipe_switch_off(i)
    end
  end
  def w_recipe_switch_on(id)
    $game_system.w_rcp_sw = [] if $game_system.w_rcp_sw == nil
    $game_system.w_rcp_sw[id] = false if $game_system.w_rcp_sw[id] == nil
    $game_system.w_rcp_sw[id] = true
  end
  def w_recipe_switch_off(id)
    $game_system.w_rcp_sw = [] if $game_system.w_rcp_sw == nil
    $game_system.w_rcp_sw[id] = false if $game_system.w_rcp_sw[id] == nil
    $game_system.w_rcp_sw[id] = false
  end
  def w_recipe_switch_on?(id)
    $game_system.w_rcp_sw = [] if $game_system.w_rcp_sw == nil
    $game_system.w_rcp_sw[id] = false if $game_system.w_rcp_sw[id] == nil
    return $game_system.w_rcp_sw[id]
  end
  def w_recipe_all_switch_on
    for i in 1..$data_weapons.size
      w_recipe_switch_on(i)
    end
  end
  def w_recipe_all_switch_off
    for i in 1..$data_weapons.size
      w_recipe_switch_off(i)
    end
  end
  def a_recipe_switch_on(id)
    $game_system.a_rcp_sw = [] if $game_system.a_rcp_sw == nil
    $game_system.a_rcp_sw[id] = false if $game_system.a_rcp_sw[id] == nil
    $game_system.a_rcp_sw[id] = true
  end
  def a_recipe_switch_off(id)
    $game_system.a_rcp_sw = [] if $game_system.a_rcp_sw == nil
    $game_system.a_rcp_sw[id] = false if $game_system.a_rcp_sw[id] == nil
    $game_system.a_rcp_sw[id] = false
  end
  def a_recipe_switch_on?(id)
    $game_system.a_rcp_sw = [] if $game_system.a_rcp_sw == nil
    $game_system.a_rcp_sw[id] = false if $game_system.a_rcp_sw[id] == nil
    return $game_system.a_rcp_sw[id]
  end
  def a_recipe_all_switch_on
    for i in 1..$data_armors.size
      a_recipe_switch_on(i)
    end
  end
  def a_recipe_all_switch_off
    for i in 1..$data_armors.size
      a_recipe_switch_off(i)
    end
  end
  def recipe_all_switch_on
    i_recipe_all_switch_on
    w_recipe_all_switch_on
    a_recipe_all_switch_on
  end
  def recipe_all_switch_off
    i_recipe_all_switch_off
    w_recipe_all_switch_off
    a_recipe_all_switch_off
  end

end

class Game_Interpreter
  include WD_itemsynthesis
end

class Game_System
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :i_rcp_sw
  attr_accessor :w_rcp_sw
  attr_accessor :a_rcp_sw
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias wd_orig_initialize004 initialize
  def initialize
    wd_orig_initialize004
    @i_rcp_sw = []
    @w_rcp_sw = []
    @a_rcp_sw = []
  end
end


#==============================================================================
# ■ Scene_ItemSynthesis
#------------------------------------------------------------------------------
#  合成画面の処理を行うクラスです。
#==============================================================================

class Scene_ItemSynthesis < Scene_MenuBase
  #--------------------------------------------------------------------------
  # ● 開始処理
  #--------------------------------------------------------------------------
  def start
    super
   
    create_help_window
    create_dummy_window
    create_number_window
    create_status_window
    create_material_window
    create_list_window
    create_category_window
    create_gold_window
    create_change_window
  end
  #--------------------------------------------------------------------------
  # ● ゴールドウィンドウの作成
  #--------------------------------------------------------------------------
  def create_gold_window
    @gold_window = Window_Gold.new
    @gold_window.viewport = @viewport
    @gold_window.x = Graphics.width - @gold_window.width
    @gold_window.y = @help_window.height
    @gold_window.hide
  end
  #--------------------------------------------------------------------------
  # ● 切り替え表示ウィンドウの作成
  #--------------------------------------------------------------------------
  def create_change_window
    wx = 0
    wy = @gold_window.y
    ww = Graphics.width - @gold_window.width
    wh = @gold_window.height
    @change_window = Window_ItemSynthesisChange.new(wx, wy, ww, wh)
    @change_window.viewport = @viewport
    @change_window.hide
  end
  #--------------------------------------------------------------------------
  # ● ダミーウィンドウの作成
  #--------------------------------------------------------------------------
  def create_dummy_window
    wy = @help_window.y + @help_window.height + 48
    wh = Graphics.height - wy
    @dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
    @dummy_window.viewport = @viewport
  end
  #--------------------------------------------------------------------------
  # ● 個数入力ウィンドウの作成
  #--------------------------------------------------------------------------
  def create_number_window
    wy = @dummy_window.y
    wh = @dummy_window.height
    @number_window = Window_ItemSynthesisNumber.new(0, wy, wh)
    @number_window.viewport = @viewport
    @number_window.hide
    @number_window.set_handler(:ok,     method(:on_number_ok))
    @number_window.set_handler(:cancel, method(:on_number_cancel))
  end
  #--------------------------------------------------------------------------
  # ● ステータスウィンドウの作成
  #--------------------------------------------------------------------------
  def create_status_window
    wx = @number_window.width
    wy = @dummy_window.y
    ww = Graphics.width - wx
    wh = @dummy_window.height
    @status_window = Window_ShopStatus.new(wx, wy, ww, wh)
    @status_window.viewport = @viewport
    @status_window.hide
  end
  #--------------------------------------------------------------------------
  # ● 素材ウィンドウの作成
  #--------------------------------------------------------------------------
  def create_material_window
    wx = @number_window.width
    wy = @dummy_window.y
    ww = Graphics.width - wx
    wh = @dummy_window.height
    @material_window = Window_ItemSynthesisMaterial.new(wx, wy, ww, wh)
    @material_window.viewport = @viewport
    @material_window.hide
    @number_window.material_window = @material_window
  end
  #--------------------------------------------------------------------------
  # ● 合成アイテムリストウィンドウの作成
  #--------------------------------------------------------------------------
  def create_list_window
    wy = @dummy_window.y
    wh = @dummy_window.height
    @list_window = Window_ItemSynthesisList.new(0, wy, wh)
    @list_window.viewport = @viewport
    @list_window.help_window = @help_window
    @list_window.status_window = @status_window
    @list_window.material_window = @material_window
    @list_window.hide
    @list_window.set_handler(:ok,     method(:on_list_ok))
    @list_window.set_handler(:cancel, method(:on_list_cancel))
    @list_window.set_handler(:change_window, method(:on_change_window))   
  end
  #--------------------------------------------------------------------------
  # ● カテゴリウィンドウの作成
  #--------------------------------------------------------------------------
  def create_category_window
    @category_window = Window_ItemSynthesisCategory.new
    @category_window.viewport = @viewport
    @category_window.help_window = @help_window
    @category_window.y = @help_window.height
    @category_window.activate
    @category_window.item_window = @list_window
    @category_window.set_handler(:ok,     method(:on_category_ok))
    @category_window.set_handler(:cancel, method(:return_scene))
  end
  
  def return_scene
    $game_map.autoplay
    SceneManager.return
  end
  
  #--------------------------------------------------------------------------
  # ● 合成アイテムリストウィンドウのアクティブ化
  #--------------------------------------------------------------------------
  def activate_list_window
    @list_window.money = money
    @list_window.show.activate
  end
  #--------------------------------------------------------------------------
  # ● 合成[決定]
  #--------------------------------------------------------------------------
  def on_list_ok
    @item = @list_window.item
    @list_window.hide
    @number_window.set(@item, max_buy, buying_price, currency_unit)
    @number_window.show.activate
  end
  #--------------------------------------------------------------------------
  # ● 合成[キャンセル]
  #--------------------------------------------------------------------------
  def on_list_cancel
    @category_window.activate
    @category_window.show
    @dummy_window.show
    @list_window.hide
    @status_window.hide
    @status_window.item = nil
    @material_window.hide
    @material_window.set(nil, nil)
    @gold_window.hide
    @change_window.hide
    @help_window.clear
  end
  #--------------------------------------------------------------------------
  # ● 表示切替
  #--------------------------------------------------------------------------
  def on_change_window
    if @status_window.visible
      @status_window.hide
      @material_window.show
    else
      @status_window.show
      @material_window.hide
    end
  end
  #--------------------------------------------------------------------------
  # ● カテゴリ[決定]
  #--------------------------------------------------------------------------
  def on_category_ok
    activate_list_window
    @gold_window.show
    @change_window.show
    @material_window.show
    @category_window.hide
    @list_window.select(0)
  end
  #--------------------------------------------------------------------------
  # ● 個数入力[決定]
  #--------------------------------------------------------------------------
  def on_number_ok
    Sound.play_shop
    do_syntetic(@number_window.number)
    end_number_input
    @gold_window.refresh
  end
  #--------------------------------------------------------------------------
  # ● 個数入力[キャンセル]
  #--------------------------------------------------------------------------
  def on_number_cancel
    Sound.play_cancel
    end_number_input
  end
  #--------------------------------------------------------------------------
  # ● 合成の実行
  #--------------------------------------------------------------------------
  def do_syntetic(number)
    $game_party.lose_gold(number * buying_price)
    $game_party.gain_item(@item, number)
   
      @recipe = @list_window.recipe(@item)
      for i in 1...@recipe.size
        kind = @recipe[0]
        id   = @recipe[1]
        num  = @recipe[2]
        if kind == "I"
          item = $data_items[id]
        elsif kind == "W"
          item = $data_weapons[id]
        elsif kind == "A"
          item = $data_armors[id]
        end
        $game_party.lose_item(item, num*number)
      end
  end
  #--------------------------------------------------------------------------
  # ● 個数入力の終了
  #--------------------------------------------------------------------------
  def end_number_input
    @number_window.hide
    activate_list_window
  end
  #--------------------------------------------------------------------------
  # ● 最大購入可能個数の取得
  #--------------------------------------------------------------------------
  def max_buy
    max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
   
    @recipe = @list_window.recipe(@item)
      for i in 1...@recipe.size
        kind = @recipe[0]
        id   = @recipe[1]
        num  = @recipe[2]
        if kind == "I"
          item = $data_items[id]
        elsif kind == "W"
          item = $data_weapons[id]
        elsif kind == "A"
          item = $data_armors[id]
        end
        if num > 0
          max_buf = $game_party.item_number(item)/num
        else
          max_buf = 999
        end
        max = [max, max_buf].min
      end
      
    buying_price == 0 ? max : [max, money / buying_price].min

  end
  #--------------------------------------------------------------------------
  # ● 所持金の取得
  #--------------------------------------------------------------------------
  def money
    @gold_window.value
  end
  #--------------------------------------------------------------------------
  # ● 通貨単位の取得
  #--------------------------------------------------------------------------
  def currency_unit
    @gold_window.currency_unit
  end
  #--------------------------------------------------------------------------
  # ● 合成費用の取得
  #--------------------------------------------------------------------------
  def buying_price
    @list_window.price(@item)
  end
end


#==============================================================================
# ■ Window_ItemSynthesisList
#------------------------------------------------------------------------------
#  合成画面で、合成可能なアイテムの一覧を表示するウィンドウです。
#==============================================================================

class Window_ItemSynthesisList < Window_Selectable
  include WD_itemsynthesis
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader   :status_window            # ステータスウィンドウ
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x, y, height)
    super(x, y, window_width, height)
   
    @shop_goods = []
    @shop_recipes = []
   
    for i in 1..WD_itemsynthesis_ini::I_recipe.size
      recipe = WD_itemsynthesis_ini::I_recipe
      if recipe
        good = [0, i, recipe[0]]
        if i_recipe_switch_on?(i)
          @shop_goods.push(good)
          @shop_recipes.push(recipe)
        end
      end
    end
    for i in 1..WD_itemsynthesis_ini::W_recipe.size
      recipe = WD_itemsynthesis_ini::W_recipe
      if recipe
        good = [1, i, recipe[0]]
        if w_recipe_switch_on?(i)
          @shop_goods.push(good)
          @shop_recipes.push(recipe)
        end
      end
    end
    for i in 1..WD_itemsynthesis_ini::A_recipe.size
      recipe = WD_itemsynthesis_ini::A_recipe
      if recipe
        good = [2, i, recipe[0]]
        if a_recipe_switch_on?(i)
          @shop_goods.push(good)
          @shop_recipes.push(recipe)
        end
      end
    end
   
    @Money = 0
    refresh
    select(0)
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウ幅の取得
  #--------------------------------------------------------------------------
  def window_width
    return 304
  end
  #--------------------------------------------------------------------------
  # ● 获取列数
  #--------------------------------------------------------------------------
  def col_max
    return 1
  end
  #--------------------------------------------------------------------------
  # ● 項目数の取得
  #--------------------------------------------------------------------------
  def item_max
    @data ? @data.size : 1
  end
  #--------------------------------------------------------------------------
  # ● アイテムの取得
  #--------------------------------------------------------------------------
  def item
    @data[index]
  end
  #--------------------------------------------------------------------------
  # ● 所持金の設定
  #--------------------------------------------------------------------------
  def money=(money)
    @money = money
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 選択項目の有効状態を取得
  #--------------------------------------------------------------------------
  def current_item_enabled?
    enable?(@data[index])
  end
  #--------------------------------------------------------------------------
  # ● 合成費用を取得
  #--------------------------------------------------------------------------
  def price(item)
    @price[item]
  end
  #--------------------------------------------------------------------------
  # ● 合成可否を取得
  #--------------------------------------------------------------------------
  def enable?(item)
    @makable[item]
  end
  #--------------------------------------------------------------------------
  # ● レシピを取得
  #--------------------------------------------------------------------------
  def recipe(item)
    @recipe[item]
  end
  #--------------------------------------------------------------------------
  # ● アイテムを許可状態で表示するかどうか
  #--------------------------------------------------------------------------
  def have_mat?(recipe)
    flag = true
    if @money >= recipe[0]
      for i in 1...recipe.size
        kind = recipe[0]
        id   = recipe[1]
        num  = recipe[2]
        if kind == "I"
          item = $data_items[id]
        elsif kind == "W"
          item = $data_weapons[id]
        elsif kind == "A"
          item = $data_armors[id]
        end
        if $game_party.item_number(item) < [num, 1].max
          flag = false
        end
      end
    else
      flag = false
    end
    return flag
  end
  #--------------------------------------------------------------------------
  # ● カテゴリの設定
  #--------------------------------------------------------------------------
  def category=(category)
    return if @category == category
    @category = category
    refresh
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    make_item_list
    create_contents
    draw_all_items
  end
  #--------------------------------------------------------------------------
  # ● アイテムをリストに含めるかどうか
  #--------------------------------------------------------------------------
  def include?(item)
    case @category
    when :item
      item.is_a?(RPG::Item) && !item.key_item?
    when :weapon
      item.is_a?(RPG::Weapon)
    when :armor
      item.is_a?(RPG::Armor)
    when :key_item
      item.is_a?(RPG::Item) && item.key_item?
    else
      false
    end
  end
  #--------------------------------------------------------------------------
  # ● アイテムリストの作成
  #--------------------------------------------------------------------------
  def make_item_list
    @data = []
    @price = {}
    @makable = {}
    @recipe = {}
    for i in 0...@shop_goods.size
      goods = @shop_goods
      recipe = @shop_recipes
      case goods[0]
      when 0;  item = $data_items[goods[1]]
      when 1;  item = $data_weapons[goods[1]]
      when 2;  item = $data_armors[goods[1]]
      end
      if item
        if include?(item)
          @data.push(item)
          @price[item] = goods[2]
          @makable[item] = have_mat?(recipe)
          @recipe[item] = recipe
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 項目の描画
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    rect = item_rect(index)
    draw_item_name(item, rect.x, rect.y, enable?(item))
    rect.width -= 4
    draw_text(rect, price(item), 2)  if WD_itemsynthesis_ini::Cost_view
  end
  #--------------------------------------------------------------------------
  # ● ステータスウィンドウの設定
  #--------------------------------------------------------------------------
  def status_window=(status_window)
    @status_window = status_window
    call_update_help
  end
  #--------------------------------------------------------------------------
  # ● 素材ウィンドウの設定
  #--------------------------------------------------------------------------
  def material_window=(material_window)
    @material_window = material_window
    call_update_help
  end
  #--------------------------------------------------------------------------
  # ● ヘルプテキスト更新
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_item(item) if @help_window
    @status_window.item = item if @status_window
    @material_window.set(item, recipe(item)) if @material_window
  end
  #--------------------------------------------------------------------------
  # ● ←→ ボタン(表示切替)が押されたときの処理
  #--------------------------------------------------------------------------
  def process_change_window
    Sound.play_cursor
    Input.update
    call_handler(:change_window)
  end
  #--------------------------------------------------------------------------
  # ● 決定やキャンセルなどのハンドリング処理
  #--------------------------------------------------------------------------
  def process_handling
    super
    if active
      return process_change_window if handle?(:change_window) && Input.trigger?(:RIGHT)
      return process_change_window if handle?(:change_window) && Input.trigger?(:LEFT)
    end
  end
end


#==============================================================================
# ■ Window_ItemSynthesisMaterial
#------------------------------------------------------------------------------
#  合成画面で、合成に必要な素材を表示するウィンドウです。
#==============================================================================

class Window_ItemSynthesisMaterial < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super(x, y, width, height)
     self.opacity = 150
    @item = nil
    refresh
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_possession(4, 0)
    draw_material_info(0, line_height * 2)
  end
  #--------------------------------------------------------------------------
  # ● アイテムの設定
  #--------------------------------------------------------------------------
  def set(item, recipe)
    @item = item
    @recipe = recipe
    @make_number = 1
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 作成個数の設定
  #--------------------------------------------------------------------------
  def set_num(make_number)
    @make_number = make_number
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 所持数の描画
  #--------------------------------------------------------------------------
  def draw_possession(x, y)
    rect = Rect.new(x, y, contents.width - 4 - x, line_height)
    change_color(system_color)
    draw_text(rect, Vocab::Possession)
    change_color(normal_color)
    draw_text(rect, $game_party.item_number(@item), 2)
  end
  #--------------------------------------------------------------------------
  # ● 素材情報の描画
  #--------------------------------------------------------------------------
  def draw_material_info(x, y)
    rect = Rect.new(x, y, contents.width, line_height)
    change_color(system_color)
    contents.font.size = 18
    draw_text(rect, "必要素材", 0)
    if @recipe
      for i in 1...@recipe.size
        kind = @recipe[0]
        id   = @recipe[1]
        num  = @recipe[2]
        if kind == "I"
          item = $data_items[id]
        elsif kind == "W"
          item = $data_weapons[id]
        elsif kind == "A"
          item = $data_armors[id]
        end
        rect = Rect.new(x, y + line_height*i, contents.width, line_height)
        enabled = true
        enabled = false if [num*@make_number, 1].max  > $game_party.item_number(item)
        draw_item_name(item, rect.x, rect.y, enabled)
        change_color(normal_color, enabled)
        if num > 0
          draw_text(rect, "#{num*@make_number}/#{$game_party.item_number(item)}", 2)
        end
      end
    end
    change_color(normal_color)
    contents.font.size = 24
  end
end


#==============================================================================
# ■ Window_ItemSynthesisNumber
#------------------------------------------------------------------------------
#  合成画面で、合成するアイテムの個数を入力するウィンドウです。
#==============================================================================

class Window_ItemSynthesisNumber < Window_ShopNumber
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_item_name(@item, 0, item_y)
    draw_number
    draw_total_price if WD_itemsynthesis_ini::Cost_view
  end
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def material_window=(material_window)
    @material_window = material_window
    call_update_help
  end
  #--------------------------------------------------------------------------
  # ● 作成個数の変更
  #--------------------------------------------------------------------------
  def change_number(amount)
    @number = [[@number + amount, @max].min, 1].max
    call_update_help #追加
  end
  #--------------------------------------------------------------------------
  # ● ヘルプテキスト更新
  #--------------------------------------------------------------------------
  def call_update_help
    @material_window.set_num(@number) if @material_window
  end
end


#==============================================================================
# ■ Window_ItemSynthesisCategory
#------------------------------------------------------------------------------
#  合成画面で、通常アイテムや装備品の分類を選択するウィンドウです。
#==============================================================================

class Window_ItemSynthesisCategory < Window_ItemCategory
  #--------------------------------------------------------------------------
  # ● 桁数の取得
  #--------------------------------------------------------------------------
  def col_max
    i = 1
#~     i += 1 if WD_itemsynthesis_ini::Category_i
#~     i += 1 if WD_itemsynthesis_ini::Category_w
#~     i += 1 if WD_itemsynthesis_ini::Category_a
#~     i += 1 if WD_itemsynthesis_ini::Category_k
    return i
  end
  #--------------------------------------------------------------------------
  # ● コマンドリストの作成
  #--------------------------------------------------------------------------
  def make_command_list
    add_command(Vocab::item,     :item)     if WD_itemsynthesis_ini::Category_i
    add_command(Vocab::weapon,   :weapon)   if WD_itemsynthesis_ini::Category_w
    add_command(Vocab::armor,    :armor)    if WD_itemsynthesis_ini::Category_a
    add_command(Vocab::key_item, :key_item) if WD_itemsynthesis_ini::Category_k
  end
end


#==============================================================================
# ■ Window_ItemSynthesisNumber
#------------------------------------------------------------------------------
#  合成画面で、切替を表示するウィンドウです。
#==============================================================================

class Window_ItemSynthesisChange < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super(x, y, width, height)
    refresh
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    text = "← → :切換"
    draw_text(0, 0, contents_width, line_height, text, 1)
  end
end



class Window_MenuCommand < Window_Command  
  alias itemSynthesis_add_main_commands add_main_commands
  def add_main_commands
      itemSynthesis_add_main_commands
      add_command("制作", :ItemSynthesis, main_commands_enabled)
  end
end   
class Scene_Menu < Scene_MenuBase
   alias itemSynthesis_create_command_window create_command_window
   def create_command_window
       itemSynthesis_create_command_window  
       @command_window.set_handler(:ItemSynthesis,     method(:Item_Synthesis))
   end
   def Item_Synthesis
       SceneManager.call(Scene_ItemSynthesis)
   end
end   
[/pre]

已經弄好加入菜單了~
使用方法:
如果懂漢字&進的去可以看這裡:http://izumiwhite.web.fc2.com/rgss3/rgss3_004.html
在腳本算是前面的地方可以設置合成公式  我相信你的程度 你應該懂 (不懂也請自己弄懂)
然後合成不是全開的  要用腳本句 (事件頁第三頁) 填寫來開啟
公式如下:
i_recipe_switch_on(n)        n号道具追加
i_recipe_switch_off(n)        n号道具削除
w_recipe_switch_on(n)        n号武器追加
w_recipe_switch_off(n)        n号武器削除
a_recipe_switch_on(n)        n号防具追加
a_recipe_switch_off(n)        n号防具削除
recipe_all_switch_on                全部追加
recipe_all_switch_off                全部削除


回复

使用道具 举报

梦石
0
星屑
600
在线时间
1118 小时
注册时间
2012-12-24
回帖
761
发表于 2013-8-29 09:12:31 | 显示全部楼层
  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. # 欢迎访问www.66RPG.com
  4. # 梦想世界,在你手中
  5. #==============================================================================  
  6. #
  7. # Sample master list for crafting script (物品分类增强版) v1.1
  8. # written by Deke
  9. # 增强:叶子
  10. #
  11. # 12-30-2005 v1.0
  12. # 8-17-2006 v1.1
  13. # 修正了返回界面时不显示成品的BUG
  14. # 修正了材料大于8个不显示的BUG
  15. # 描绘物品美化
  16. # 自动检测能否合成
  17. #============================================================================================
  18. # 简介:
  19. # 这是一个很不错的合成物品系统,可以通过游戏的过程,不断学习可以合成的
  20. # 物品方法。
  21. # ------
  22. # 增强版补充说明:
  23. # 在这个增强版中,可以对成品进行手动分类。
  24. # 成品增加了一个分类属性。
  25. # 这个分类纯粹是按自己的意愿,没有规定第几类必须是什么。
  26. # 召唤特定分类的界面,就只会看到特定分类的成品。
  27. #
  28. # 例如:
  29. # 使用脚本$scene = Scene_Craft.new(1),
  30. # 出来的界面就只会显示成品分类为1的东西
  31. # 同样道理,使用脚本$scene = Scene_Craft.new(2),
  32. # 出来的界面就只会显示成品分类为2的东西
  33. #
  34. # 如果使用脚本$scene = Scene_Craft.new或$scene = Scene_Craft.new(0)来召唤界面
  35. # 就可以看到所有成品。
  36. #
  37. # 注意:不要弄混淆“成品种类”和“成品分类”
  38. # 成品种类是指成品是普通物品(0),防具(1)或武器(2)
  39. # 成品分类是指此物品的自定义分类
  40. #
  41. #
  42. # 使用方法:
  43. # 1、召唤界面:使用脚本$scene = Scene_Craft.new(分类的数字)
  44. # 例如:使用脚本$scene = Scene_Craft.new(1),出来分类1的界面
  45. #
  46. # 2、学习合成:$game_party.learn_recipe(合成项目)
  47. #
  48. #  2.1、其实这个脚本可以使同一成品有不同配方
  49. #
  50. #    就这样说可能解释得不清楚,先来解释一下脚本学习配方的原理:
  51. #    $game_party.learn_recipe(合成项目)的处理过程并不是直接学习这个配方,
  52. #    而是在配方库中找到和合成项目成品相同的配方。
  53. #
  54. #    如果配方库中有两个配方成品相同的话,配方版本就变得重要。
  55. #    $game_party.learn_recipe(合成项目,配方版本)
  56. #    配方版本为1的话,学到的配方就是@recipe_list[xx]中与合成项目成品相同且数字最小的配方
  57. #    配方版本为2的话,学到的配方就是数字第二小的配方
  58. #    在上面这个脚本语句中,不填配方版本的话就默认为1
  59. #
  60. #  2.2、忘记配方:$game_party.forget_recipe(合成项目)
  61. #   2.21、同样道理,这个语句也可以写配方版本
  62. #    $game_party.forget_recipe(合成项目,配方版本)
  63. #    配方版本定义见2.1
  64. #
  65. #  2.3、配方版本不能乱填!例如游戏中某一个配方的成品是唯一的,与所有其它配方的成品都不相同
  66. #   那么学习的时候就不用填配方版本。
  67. #   如果这时在配方版本填了2的话,就有可能学不到或者忘不了(-_-||)
  68. #   
  69. #
  70. # 3、合成定义:
  71. # 这个合成脚本可以定义两种合成物品。一种是预先定义好了的,就像下面这样,
  72. # 直接写在这里就可以,另一种是在学习之前现场定义。
  73. #
  74. # 4、举例
  75. #  4.1、学会recipe_list[1]定义的合成:$game_party.learn_recipe($game_temp.recipe_list[1])
  76. #       注意,一行如果输入不下,在(的后面或[的后面按回车换行,否则可能出错
  77. #
  78. #  4.2、在游戏中临时定义一种合成,让玩家学会。使用事件中的脚本如下,   
  79. #  脚本:
  80. #    材料 = [$game_variables[1],$game_variables[2]]  #——材料编号是变量1、2的编号
  81. #    材料种类 = [0,0]                                #——材料是物品
  82. #    材料数量 = [$game_variables[3],$game_variables[4]]  #——需要材料数量是变量3、4的编号
  83. #    成品 = $game_variables[5]                       #——获得结果编号是5
  84. #    成品种类 = 1                                    #——成品是防具类
  85. #    成品分类 = 1                                    #——这一项不写的话默认为0
  86. #    $game_party.learn_recipe(Game_Recipe.new(材料,材料种类,材料数量,成品,成品种类,成品分类))
  87. #    上面这条语句的成品分类这一项不写也行,这样它就默认为0了。
  88. #    (也就是此物品没有分类,不会在分类菜单中出现)
  89. #    省略成品分类的脚本语句可以像下面这样写:
  90. #    $game_party.learn_recipe(Game_Recipe.new(材料,材料种类,材料数量,成品,成品种类))
  91. #
  92. #===========================================================================================
  93. class Game_Temp
  94.   attr_reader :recipe_list  
  95.   alias crafting_temp_initialize initialize
  96.   def initialize
  97.     crafting_temp_initialize
  98.     @recipe_list=[]
  99.     get_recipe_list
  100.   end  
  101.   def get_recipe_list   
  102.     ##########################################################################
  103.     # 1 号合成物品设定 (物品小药水×2 + 中药水 = 大药水) 成品分类:1
  104.     ##########################################################################
  105.     材料 = [1, 2]             # 需要材料的数据库编号
  106.     材料种类 = [0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  107.     材料数量 = [2, 1]         # 需要材料的数量
  108.     成品 = 3                  # 获得物品编号
  109.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  110.     成品分类 = 1              # 获得成品分类
  111.     @recipe_list[1] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)
  112.    
  113.     ##########################################################################
  114.     # 2 号合成物品设定 (武器铜剑3、铁剑2、钢剑1 = 密切斯特剑) 成品分类:2
  115.     ##########################################################################
  116.     材料 = [1, 2, 3]          # 需要材料的数据库编号
  117.     材料种类 = [2, 2, 2]      # 需要材料的种类,0是普通物品,1是防具,2是武器
  118.     材料数量 = [3, 2, 1]      # 需要材料的数量
  119.     成品 = 4                  # 获得物品编号
  120.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  121.     成品分类 = 2              # 获得成品分类
  122.     @recipe_list[2] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)
  123.    
  124.     ##########################################################################
  125.     # 3 号合成物品设定 (物品力量之石×2 + 防具钢盾×1 = 密切斯特盾) 成品分类:3
  126.     ##########################################################################
  127.     材料 = [13, 3]            # 需要材料的数据库编号
  128.     材料种类 = [0, 1]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  129.     材料数量 = [2, 1]         # 需要材料的数量
  130.     成品 = 4                  # 获得物品编号
  131.     成品种类 = 1              # 获得物品种类,0是普通物品,1是防具,2是武器
  132.     成品分类 = 3              # 获得成品分类
  133.     @recipe_list[3] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)
  134.    
  135.     ##########################################################################
  136.     # 4 号合成物品设定 成品分类:3
  137.     ##########################################################################
  138.     材料 = [1,2,3,4,5,6,7,8,9,10]            # 需要材料的数据库编号
  139.     材料种类 = [0,0,0,0,0,0,0,0,0,0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  140.     材料数量 = [1,1,1,1,1,1,1,1,1,1]         # 需要材料的数量
  141.     成品 = 28                  # 获得物品编号
  142.     成品种类 = 1              # 获得物品种类,0是普通物品,1是防具,2是武器
  143.     成品分类 = 3              # 获得成品分类
  144.     @recipe_list[4] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)
  145.    
  146.   end # of get_recipe_list method
  147. end # of updates to Game_Temp Class

  148. #================================
  149. # CRAFTING PROGRAM
  150. #----------------------------------------------------------------
  151. #-written by Deke
  152. #-yes_no window code created by Phsylomortis
  153. #----------------------------------------------------------------
  154. #================================

  155. #updates to Game_Party class

  156. class Game_Party
  157.   
  158.   attr_accessor       :recipes
  159.   
  160.   alias crafting_party_initialize initialize
  161.   
  162.   def initialize
  163.     crafting_party_initialize
  164.     @recipes=[]
  165.   end
  166.   
  167.   #----------------------------------------------------------------------
  168.   def know?(recipe, version = 1)
  169.     unless recipe.is_a?(Game_Recipe)
  170.       recipe = get_recipe_from_master_list(recipe, version)
  171.     end
  172.     return $game_party.recipes.include?(recipe)
  173.   end
  174.   
  175. #----------------------------------------------------------------------
  176.   def learn_recipe(recipe , version = 1)
  177.     unless recipe.is_a?(Game_Recipe)
  178.       recipe = get_recipe_from_master_list(recipe, version)
  179.     end
  180.     if recipe.is_a?(Game_Recipe)
  181.       unless know?(recipe)
  182.         @recipes.push(recipe)
  183.       end
  184.     end
  185.   end
  186.   
  187. #----------------------------------------------------------------------
  188.   def forget_recipe(recipe , version = 1)
  189.     if !recipe.is_a?(Game_Recipe)
  190.       recipe = get_recipe_from_master_list(recipe, version)
  191.     end
  192.     if recipe.is_a?(Game_Recipe)
  193.       for i in 0...@recipes.size
  194.         if recipe == @recipes[i]
  195.           index = i
  196.           break
  197.         end
  198.       end
  199.       if index != nil
  200.         @recipes.delete(@recipes[index])
  201.       end
  202.     end
  203.   end
  204.   
  205. #----------------------------------------------------------------------
  206.   def get_recipe_from_master_list(item, version)
  207.     index = nil
  208.     for i in 0...$game_temp.recipe_list.size
  209.       if item[0] == $game_temp.recipe_list[i].result and item[1] ==$game_temp.recipe_list[i].result_type
  210.         version -= 1
  211.         if version == 0
  212.           index = i
  213.           break
  214.         end
  215.       end
  216.     end
  217.     if index.is_a?(Integer)
  218.       return ($game_temp.recipe_list[index])
  219.     else
  220.       return false
  221.     end
  222.   end
  223.   
  224. end # of Game_Party updates

  225. #================================
  226. class Game_Recipe

  227.   attr_reader :ingredients
  228.   attr_reader :quantities
  229.   attr_reader :result
  230.   attr_reader :result_type
  231.   attr_reader :ingredient_types
  232.   attr_reader :craft_type  #物品分类
  233.   
  234. #----------------------------------------------------------------------
  235.   def initialize( ingredients, ingredient_types, quantities, result, result_type, craft_type=0)
  236.     @ingredients = ingredients
  237.     @ingredient_types = ingredient_types
  238.     @quantities = quantities
  239.     @result = result
  240.     @result_type = result_type
  241.     @craft_type = craft_type
  242.   end
  243.   
  244. #----------------------------------------------------------------------
  245.   def name
  246.     case @result_type
  247.       when 0
  248.         name = $data_items[@result].name
  249.       when 1
  250.         name = $data_armors[@result].name
  251.       when 2
  252.         name = $data_weapons[@result].name
  253.     end
  254.     return name
  255.   end
  256.   
  257. #----------------------------------------------------------------------

  258.   def item
  259.     case @result_type
  260.       when 0
  261.         item = $data_items[@result]
  262.       when 1
  263.         item = $data_armors[@result]
  264.       when 2
  265.         item = $data_weapons[@result]
  266.     end
  267.     return item
  268.   end

  269. #----------------------------------------------------------------------
  270.   def have
  271.     have_all = true
  272.     for i in 0...@ingredients.size
  273.       case @ingredient_types[i]
  274.         when 0
  275.           if $game_party.item_number(@ingredients[i]) < @quantities[i]
  276.             have_all=false
  277.           end
  278.         when 1
  279.           if $game_party.armor_number(@ingredients[i]) < @quantities[i]
  280.             have_all=false
  281.           end
  282.         when 2
  283.           if $game_party.weapon_number(@ingredients[i]) < @quantities[i]
  284.             have_all=false
  285.           end
  286.       end
  287.     end
  288.     return have_all
  289.   end

  290. #----------------------------------------------------------------------
  291.   def decrement
  292.     for i in 0...@ingredients.size
  293.       case @ingredient_types[i]
  294.       when 0
  295.         $game_party.lose_item(@ingredients[i], @quantities[i])
  296.       when 1
  297.         $game_party.lose_armor(@ingredients[i], @quantities[i])
  298.       when 2
  299.         $game_party.lose_weapon(@ingredients[i], @quantities[i])
  300.       end
  301.     end
  302.   end

  303. #----------------------------------------------------------------------
  304.   def make
  305.     if have
  306.       case @result_type
  307.       when 0
  308.         $game_party.gain_item(@result, 1)
  309.       when 1
  310.         $game_party.gain_armor(@result, 1)
  311.       when 2
  312.         $game_party.gain_weapon(@result, 1)
  313.       end
  314.       decrement
  315.     end
  316.   end
  317.   
  318. #----------------------------------------------------------------------
  319.   def == (recipe)
  320.     if recipe.is_a?(Game_Recipe)
  321.       equal = true
  322.       if recipe.ingredients != self.ingredients
  323.         equal = false
  324.       end
  325.       if recipe.ingredient_types != self.ingredient_types
  326.         equal = false
  327.       end
  328.       if recipe.quantities != self.quantities
  329.         equal = false
  330.       end
  331.       if recipe.result != self.result
  332.         equal=false
  333.       end
  334.       if recipe.result_type != self.result_type
  335.         equal = false
  336.       end
  337.     else
  338.       equal = false
  339.     end
  340.     return equal
  341.   end
  342.   
  343. end # of Game_Recipe class

  344. #===================================

  345. class Window_Craft < Window_Selectable
  346.   attr_reader :data #声明数据
  347.   #--------------------------------------------------------------------------
  348.   def initialize(craft_type=0)
  349.     @craft_type = craft_type
  350.     super(0, 64, 240, 416)
  351.     @column_max = 1
  352.     refresh
  353.     self.index = 0
  354.   end

  355.   #--------------------------------------------------------------------------
  356.   def recipe
  357.     return @data[self.index]
  358.   end

  359.   #--------------------------------------------------------------------------
  360.   def refresh
  361.     if self.contents != nil
  362.       self.contents.dispose
  363.       self.contents = nil
  364.     end
  365.     @data = []
  366.     for i in 0...$game_party.recipes.size
  367.        #@craft_type为0时就显示全部物品
  368.        #不为0时就显示对应物品
  369.       if @craft_type == 0
  370.         @data.push($game_party.recipes[i])
  371.       elsif $game_party.recipes[i].craft_type == @craft_type
  372.         @data.push($game_party.recipes[i])
  373.       end
  374.     end
  375.     @item_max = @data.size
  376.     if @item_max > 0
  377.       self.contents = Bitmap.new(width - 32, row_max * 32)
  378.       self.contents.font.name = "黑体" # = "黑体"
  379.       self.contents.font.size = 18 # = 18
  380.       for i in 0...@item_max
  381.         x = 16
  382.         y = i * 32
  383.         able = true
  384.         for ingredient in 0...@data[i].ingredients.size
  385.           case @data[i].ingredient_types[ingredient]
  386.           when 0
  387.             count = $game_party.item_number(@data[i].ingredients[ingredient])
  388.           when 1
  389.             count = $game_party.armor_number(@data[i].ingredients[ingredient])
  390.           when 2
  391.             count = $game_party.weapon_number(@data[i].ingredients[ingredient])
  392.           end
  393.           if count < @data[i].quantities[ingredient]
  394.             able = false
  395.             break
  396.           end
  397.         end
  398.         draw_item_name(@data[i].item, x, y, able)
  399.       end
  400.     end
  401.   end

  402.   #--------------------------------------------------------------------------
  403.   #def draw_item(index)
  404.   #  recipe = @data[index]
  405.   #  self.contents.font.color = recipe.have ? normal_color : disabled_color
  406.   #  x = 16
  407.   #  y = index * 32
  408.   #  self.contents.draw_text(x , y, self.width-32, 32, recipe.name, 0)
  409.   #end
  410.   
  411.   #--------------------------------------------------------------------------
  412.   # ● 描绘物品名
  413.   #     item : 物品
  414.   #     x    : 描画目标 X 坐标
  415.   #     y    : 描画目标 Y 坐标
  416.   #--------------------------------------------------------------------------
  417.   def draw_item_name(item, x, y, able = true)
  418.     if item == nil
  419.       return
  420.     end
  421.     if !able
  422.       self.contents.font.color = disabled_color
  423.     end
  424.     bitmap = RPG::Cache.icon(item.icon_name)
  425.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  426.     self.contents.draw_text(x + 28, y, 212, 32, item.name)
  427.     self.contents.font.color = normal_color
  428.   end
  429.   
  430.   #--------------------------------------------------------------------------
  431.   def update_help
  432.     current_recipe = recipe
  433.     if current_recipe.is_a?(Game_Recipe)
  434.     case current_recipe.result_type
  435.       when 0
  436.         description = $data_items[current_recipe.result].description
  437.       when 1
  438.         description = $data_armors[current_recipe.result].description
  439.       when 2
  440.         description = $data_weapons[current_recipe.result].description
  441.       end
  442.     else
  443.       description = ""
  444.     end
  445.     @help_window.set_text(description)
  446.     @help_window.update
  447.   end
  448.   
  449. end # of Window_Craft

  450. #=======================================
  451. class Window_CraftResult < Window_Base

  452.   #--------------------------------------------------------------------------
  453.   def initialize
  454.     super(240, 64, 400, 184)
  455.     self.contents = Bitmap.new(width - 32, height - 32)
  456.     self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  457.     self.contents.font.size = 18 # = 20
  458.     @result = nil
  459.     @type = nil
  460.   end

  461.   #--------------------------------------------------------------------------
  462.   def refresh
  463.     self.contents.clear
  464.     case @type
  465.       when 0
  466.         item = $data_items[@result]
  467.         if item.recover_hp_rate > item.recover_hp
  468.           hp_string = "HP回复率:"
  469.           hp_stat = item.recover_hp_rate
  470.         else
  471.           hp_string = "HP回复量:"
  472.           hp_stat = item.recover_hp
  473.         end
  474.         if item.recover_sp_rate > item.recover_sp
  475.           sp_string = "SP回复率:"
  476.           sp_stat = item.recover_sp_rate
  477.         else
  478.           sp_string = "SP回复量:"
  479.           sp_stat = item.recover_sp
  480.         end
  481.         @strings = [hp_string, sp_string, "物理防御:" , "魔法防御:", "命中率:", "分散度:"]
  482.         @stats = [hp_stat, sp_stat, item. pdef_f, item.mdef_f, item.hit, item.variance,
  483.                        $game_party.item_number(@result)]
  484.         @bitmap = RPG::Cache.icon(item.icon_name)
  485.       when 1
  486.         item = $data_armors[@result]
  487.         @strings = ["物理防御:", "魔法防御:", "回避修正:", "力量增加:", "灵巧增加:",
  488.                        "速度增加:", "魔力增加:"]
  489.         @stats = [item.pdef, item.mdef, item.eva, item.str_plus, item.dex_plus,
  490.                     item.agi_plus, item.int_plus, $game_party.armor_number(@result) ]
  491.         @bitmap = RPG::Cache.icon(item.icon_name)
  492.       when 2
  493.         item = $data_weapons[@result]
  494.         @strings =["攻击力:", "物理防御:", "魔法防御:", "力量增加:", "灵巧增加:",
  495.                     "速度增加:", "魔力增加:"]
  496.         @stats = [item.atk, item.pdef, item.mdef, item.str_plus, item.dex_plus,
  497.                     item.agi_plus, item.int_plus, $game_party.weapon_number(@result) ]
  498.         @bitmap = RPG::Cache.icon(item.icon_name)
  499.     end
  500.     for i in 0...@strings.size
  501.       x = i%2 * 184
  502.       y = i /2 *28 +32
  503.       self.contents.font.color = normal_color
  504.       self.contents.draw_text(x,y,100, 28,@strings[i])
  505.       self.contents.font.color = system_color
  506.       self.contents.draw_text(x + 110, y, 45, 28, @stats[i].to_s)
  507.     end
  508.     self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, 24, 24), 255)
  509.     self.contents.font.color= normal_color
  510.     self.contents.draw_text(40, 0, 300, 28, "待合成物品的现有数量:")
  511.     self.contents.font.color = system_color
  512.     count = @stats[@stats.size - 1].to_s
  513.     self.contents.draw_text(294, 0, 45, 28, count )
  514.   end
  515.    
  516. #----------------------------------------------------------------------
  517.   def set_result(result , type)
  518.     @result = result
  519.     @type = type
  520.     refresh
  521.   end

  522. end #of Window_CraftResult

  523. #=======================================
  524. class Window_CraftIngredients < Window_Base

  525.   #--------------------------------------------------------------------------
  526.   def initialize
  527.     super(240, 248, 400, 232)
  528.     self.contents = Bitmap.new(width - 32, height - 32)
  529.     self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  530.     self.contents.font.size = 18 # = 20
  531.     @ingredients = []
  532.     @types = []
  533.     @quantities = []
  534.     @item = nil
  535.     @count = 0
  536.     @counter = 0
  537.     @real_oy = 0
  538.   end

  539.   #--------------------------------------------------------------------------
  540.   def refresh
  541.     @counter = 0
  542.     self.contents.clear
  543.     self.contents = Bitmap.new(width - 32, @ingredients.size * 26)
  544.     for i in 0...@ingredients.size
  545.       case @types[i]
  546.       when 0
  547.         @item = $data_items[@ingredients[i]]
  548.         @count = $game_party.item_number(@ingredients[i])
  549.       when 1
  550.         @item = $data_armors[@ingredients[i]]
  551.         @count = $game_party.armor_number(@ingredients[i])
  552.       when 2
  553.         @item = $data_weapons[@ingredients[i]]
  554.         @count = $game_party.weapon_number(@ingredients[i])
  555.       end
  556.       y = i *26
  557.       self.contents.blt(0, y, RPG::Cache.icon(@item.icon_name), Rect.new(0, 0, 24, 24), 255)
  558.       self.contents.font.color = @count >= @quantities[i] ? normal_color : disabled_color
  559.       self.contents.draw_text(30, y, 280, 28, @item.name)
  560.       self.contents.draw_text(300, y, 45, 28, @quantities[i].to_s)
  561.       self.contents.font.color = system_color
  562.       self.contents.draw_text(245, y, 45, 28, @count.to_s )     
  563.     end
  564.   end
  565.       
  566.   #--------------------------------------------------------------------------
  567.   def set_ingredients(ingredients , types, quantities)
  568.     @ingredients = ingredients
  569.     @types = types
  570.     @quantities = quantities
  571.     refresh
  572.     if @ingredients.size > 7
  573.       self.oy = -52
  574.       @real_oy = 0
  575.     else
  576.       self.oy = 0
  577.     end
  578.   end

  579.   def update
  580.     super
  581.     @counter += 1
  582.     if @ingredients.size > 7 and @counter > 30
  583.       @real_oy = (@real_oy + 1) % ((@ingredients.size - 3) * 26)
  584.       self.oy = @real_oy - 52
  585.     end
  586.   end
  587.    
  588. end # of Window_CraftIngredients

  589. #======================================
  590. class Scene_Craft

  591.   #--------------------------------------------------------------------------
  592.   # @craft_type:物品种类,0就是全部
  593.   def initialize(craft_type=0,craft_index=0)
  594.     @craft_index=craft_index
  595.     @craft_type = craft_type
  596.   end
  597.   
  598.   #--------------------------------------------------------------------------
  599.   def main
  600.     @craft_window = Window_Craft.new(@craft_type)
  601.     @craft_window.index=@craft_index
  602.     @confirm_window = Window_Base.new(120, 188, 400, 64)
  603.     @confirm_window.contents = Bitmap.new(368, 32)
  604.     @confirm_window.contents.font.name = "黑体"
  605.     @confirm_window.contents.font.size = 20
  606.     @help_window = Window_Help.new
  607.     @craft_window.help_window = @help_window
  608.     @result_window=Window_CraftResult.new
  609.     @ingredients_window=Window_CraftIngredients.new
  610.     if @craft_window.data.size > 0 #本类窗口物品大于0的话
  611.       @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
  612.       @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
  613.                                                           @craft_window.recipe.ingredient_types,
  614.                                                           @craft_window.recipe.quantities)
  615.     end
  616.     @yes_no_window = Window_Command.new(100, ["确定", "放弃"])
  617.     @confirm_window.visible = false
  618.     @confirm_window.z = 1500
  619.     @yes_no_window.visible = false
  620.     @yes_no_window.active = false
  621.     @yes_no_window.index = 1
  622.     @yes_no_window.x = 270
  623.     @yes_no_window.y = 252
  624.     @yes_no_window.z = 1500
  625.     @label_window = Window_Base.new(450,200,190,52)
  626.     @label_window.contents=Bitmap.new(@label_window.width - 32,@label_window.height - 32)
  627.     @label_window.contents.font.size=20
  628.     @label_window.contents.font.color = @label_window.normal_color
  629.     @label_window.contents.font.name = "黑体"
  630.     @label_window.contents.draw_text(0, 0, @label_window.contents.width, 20, "  现有   需要")
  631.     Graphics.transition
  632.     loop do
  633.       Graphics.update
  634.       Input.update
  635.       update
  636.       if $scene != self
  637.         break
  638.       end
  639.     end
  640.     Graphics.freeze
  641.     @help_window.dispose
  642.     @craft_window.dispose
  643.     @result_window.dispose
  644.     @ingredients_window.dispose
  645.     @confirm_window.dispose
  646.     @yes_no_window.dispose
  647.     @label_window.dispose
  648.   end

  649.   #--------------------------------------------------------------------------
  650.   def update
  651.     @craft_window.update
  652.     @ingredients_window.update
  653.     if @craft_window.active
  654.       update_craft
  655.       return
  656.     end
  657.     if @yes_no_window.active
  658.       confirm_update
  659.       return
  660.     end
  661.   end

  662.   #--------------------------------------------------------------------------
  663.   def update_craft
  664.     if Input.dir4 != 0
  665.       if @craft_window.data.size > 0 #本类窗口物品大于0的话
  666.         @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
  667.         @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
  668.                                                            @craft_window.recipe.ingredient_types,
  669.                                                            @craft_window.recipe.quantities)
  670.       end
  671.     end
  672.     if Input.trigger?(Input::B)
  673.       $game_system.se_play($data_system.cancel_se)
  674.       $scene = Scene_Map.new
  675.       return
  676.     end
  677.     if Input.trigger?(Input::C) and $game_party.recipes.size != 0
  678.       @recipe = @craft_window.recipe
  679.       if @recipe != nil
  680.         if @recipe.have
  681.           @yes_no_window.active = true
  682.           @craft_window.active = false
  683.         else
  684.           $game_system.se_play($data_system.buzzer_se)
  685.           return
  686.         end
  687.       else
  688.         $game_system.se_play($data_system.buzzer_se)
  689.         return
  690.       end
  691.     end
  692.   end

  693.   #--------------------------------------------------------------------------
  694.   def confirm_update
  695.     @craft_index = @craft_window.index
  696.     @confirm_window.visible = true
  697.     @confirm_window.z = 1500
  698.     @yes_no_window.visible = true
  699.     @yes_no_window.active = true
  700.     @yes_no_window.z = 1500
  701.     @yes_no_window.update
  702.     string = "合成 " + @recipe.name + "?"
  703.     cw = @confirm_window.contents.text_size(string).width
  704.     center = @confirm_window.contents.width/2 - cw /2
  705.     unless @drawn
  706.       @confirm_window.contents.draw_text(center, 0, cw, 30, string)
  707.       @drawn = true
  708.     end
  709.     if Input.trigger?(Input::C)
  710.       if @yes_no_window.index == 0
  711.         $game_system.se_play($data_system.decision_se)
  712.         @recipe.make
  713.         $game_system.se_play($data_system.save_se)
  714.         $scene=Scene_Craft.new(@craft_type,@craft_index)
  715.       else
  716.         $game_system.se_play($data_system.cancel_se)
  717.         $scene=Scene_Craft.new(@craft_type,@craft_index)
  718.       end
  719.     end
  720.     if Input.trigger?(Input::B)
  721.       $game_system.se_play($data_system.cancel_se)
  722.       $scene=Scene_Craft.new(@craft_type,@craft_index)
  723.     end
  724.   end

  725. end # of Scene_Craft

  726. #==============================================================================
  727. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  728. # 欢迎访问www.66RPG.com
  729. # 梦想世界,在你手中
  730. #==============================================================================
复制代码
用这个看看吧,这个应该可以了
脚本说明在28-90行
如果添加物品合成的种类,就可以仿照102-144行
应该不麻烦把

点评

囧.我就是不会改Scene_Menu的菜单,不知道【add_command("制作", --> :这里不知填什么<-- 】  发表于 2013-8-29 12:16
对了,你如果要在菜单栏中打开的话,你要在Scene_Menu里面修改了  发表于 2013-8-29 09:22

点击签名档去一个神奇的地方
回复

使用道具 举报

梦石
1
星屑
7574
在线时间
2650 小时
注册时间
2013-8-23
回帖
2152

开拓者

 楼主| 发表于 2013-8-29 13:38:40 | 显示全部楼层
本帖最后由 鑫晴 于 2013-8-29 13:46 编辑
76213585 发表于 2013-8-29 04:54
試試白魔的
#==============================================================================
# ■ RGSS ...


          可以弹出制作页面了,可是功能却用不了。也许是我设置的问题。

                    


            当我打开全部开关也就是 recipe_all_switch_on 的时候,弹出这么一个错误:


4.png





                     也就是这句:if @Money >= recipe[0]






                     当我打开个别的开关也就是   ( w/a ) i_recipe_switch_on(n)  n=1 / n=0的时候 .

                                               

                                                     也是弹出上面那个错误。


↓.....这是加工厂....↓


6.png









         没打开开关的时候......





2.png




5.png


     



           什么都没有.....(这必须没有.....)




                    也不能切换到【装备】、【防具】的页面,只有一个【道具】、






   
                   是我设置有问题吗?



                                  事件脚本设置:


8.png



9.png







10.png
回复

使用道具 举报

梦石
0
星屑
407
在线时间
1291 小时
注册时间
2013-1-12
回帖
3349

贵宾

发表于 2013-8-30 02:30:55 | 显示全部楼层
鑫晴 发表于 2013-8-28 22:38
可以弹出制作页面了,可是功能却用不了。也许是我设置的问题。

                    

我自己改成只有道句的....  對不起......
我直接從我遊戲拿过來的  給你个原碼....

[pre lang="ruby" line="1"]#==============================================================================
# ■ RGSS3 アイテム合成 ver 1.02
#------------------------------------------------------------------------------
#  配布元:
#     白の魔 http://izumiwhite.web.fc2.com/
#
#  利用規約:
#     RPGツクールVX Aceの正規の登録者のみご利用になれます。
#     利用報告・著作権表示とかは必要ありません。
#     改造もご自由にどうぞ。
#     何か問題が発生しても責任は持ちません。
#==============================================================================


#--------------------------------------------------------------------------
# ★ 初期設定。
#    合成レシピ等の設定
#--------------------------------------------------------------------------
module WD_itemsynthesis_ini
  
  Cost_view =  true #費用(G)の表示(合成の費用が全て0Gの場合はfalseを推奨)
  
  Category_i = true #カテゴリウィンドウに「アイテム」の項目を表示
  Category_w = true #カテゴリウィンドウに「武器」の項目を表示
  Category_a = true #カテゴリウィンドウに「防具」の項目を表示
  Category_k = true #カテゴリウィンドウに「大事なもの」の項目を表示
  
  I_recipe = [] #この行は削除しないこと
  W_recipe = [] #この行は削除しないこと
  A_recipe = [] #この行は削除しないこと
  
  #以下、合成レシピ。
  #例: I_recipe[3]  = [100, ["I",1,1], ["W",2,1], ["A",2,2], ["A",3,1]]
  #と記載した場合、ID3のアイテムの合成必要は、100G。
  #必要な素材は、ID1のアイテム1個、ID2の武器1個、ID2の防具2個、ID3の防具1個
  #となる。
  #-------------------------------------------------------------------------------------
  #アイテムの合成レシピ
  I_recipe[9]  = [0,  ["I",5,1], ["I",43,3]]

  #武器の合成レシピ
  W_recipe[1]  = [50,  ["I",10,5]]
  
  #-------------------------------------------------------------------------------------
  #防具の合成レシピ  
  A_recipe[1]  = [50,   ["I",10,6]]
end


#==============================================================================
# ■ WD_itemsynthesis
#------------------------------------------------------------------------------
#  アイテム合成用の共通メソッドです。
#==============================================================================

module WD_itemsynthesis
  def i_recipe_switch_on(id)
    $game_system.i_rcp_sw = [] if $game_system.i_rcp_sw == nil
    $game_system.i_rcp_sw[id] = false if $game_system.i_rcp_sw[id] == nil
    $game_system.i_rcp_sw[id] = true
  end
  def i_recipe_switch_off(id)
    $game_system.i_rcp_sw = [] if $game_system.i_rcp_sw == nil
    $game_system.i_rcp_sw[id] = false if $game_system.i_rcp_sw[id] == nil
    $game_system.i_rcp_sw[id] = false
  end
  def i_recipe_switch_on?(id)
    $game_system.i_rcp_sw = [] if $game_system.i_rcp_sw == nil
    $game_system.i_rcp_sw[id] = false if $game_system.i_rcp_sw[id] == nil
    return $game_system.i_rcp_sw[id]
  end
  def i_recipe_all_switch_on
    for i in 1..$data_items.size
      i_recipe_switch_on(i)
    end
  end
  def i_recipe_all_switch_off
    for i in 1..$data_items.size
      i_recipe_switch_off(i)
    end
  end
  def w_recipe_switch_on(id)
    $game_system.w_rcp_sw = [] if $game_system.w_rcp_sw == nil
    $game_system.w_rcp_sw[id] = false if $game_system.w_rcp_sw[id] == nil
    $game_system.w_rcp_sw[id] = true
  end
  def w_recipe_switch_off(id)
    $game_system.w_rcp_sw = [] if $game_system.w_rcp_sw == nil
    $game_system.w_rcp_sw[id] = false if $game_system.w_rcp_sw[id] == nil
    $game_system.w_rcp_sw[id] = false
  end
  def w_recipe_switch_on?(id)
    $game_system.w_rcp_sw = [] if $game_system.w_rcp_sw == nil
    $game_system.w_rcp_sw[id] = false if $game_system.w_rcp_sw[id] == nil
    return $game_system.w_rcp_sw[id]
  end
  def w_recipe_all_switch_on
    for i in 1..$data_weapons.size
      w_recipe_switch_on(i)
    end
  end
  def w_recipe_all_switch_off
    for i in 1..$data_weapons.size
      w_recipe_switch_off(i)
    end
  end
  def a_recipe_switch_on(id)
    $game_system.a_rcp_sw = [] if $game_system.a_rcp_sw == nil
    $game_system.a_rcp_sw[id] = false if $game_system.a_rcp_sw[id] == nil
    $game_system.a_rcp_sw[id] = true
  end
  def a_recipe_switch_off(id)
    $game_system.a_rcp_sw = [] if $game_system.a_rcp_sw == nil
    $game_system.a_rcp_sw[id] = false if $game_system.a_rcp_sw[id] == nil
    $game_system.a_rcp_sw[id] = false
  end
  def a_recipe_switch_on?(id)
    $game_system.a_rcp_sw = [] if $game_system.a_rcp_sw == nil
    $game_system.a_rcp_sw[id] = false if $game_system.a_rcp_sw[id] == nil
    return $game_system.a_rcp_sw[id]
  end
  def a_recipe_all_switch_on
    for i in 1..$data_armors.size
      a_recipe_switch_on(i)
    end
  end
  def a_recipe_all_switch_off
    for i in 1..$data_armors.size
      a_recipe_switch_off(i)
    end
  end
  def recipe_all_switch_on
    i_recipe_all_switch_on
    w_recipe_all_switch_on
    a_recipe_all_switch_on
  end
  def recipe_all_switch_off
    i_recipe_all_switch_off
    w_recipe_all_switch_off
    a_recipe_all_switch_off
  end

end

class Game_Interpreter
  include WD_itemsynthesis
end

class Game_System
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :i_rcp_sw
  attr_accessor :w_rcp_sw
  attr_accessor :a_rcp_sw
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias wd_orig_initialize004 initialize
  def initialize
    wd_orig_initialize004
    @i_rcp_sw = []
    @w_rcp_sw = []
    @a_rcp_sw = []
  end
end


#==============================================================================
# ■ Scene_ItemSynthesis
#------------------------------------------------------------------------------
#  合成画面の処理を行うクラスです。
#==============================================================================

class Scene_ItemSynthesis < Scene_MenuBase
  #--------------------------------------------------------------------------
  # ● 開始処理
  #--------------------------------------------------------------------------
  def start
    super
    create_help_window
    create_dummy_window
    create_number_window
    create_status_window
    create_material_window
    create_list_window
    create_category_window
    create_gold_window
    create_change_window
  end
  #--------------------------------------------------------------------------
  # ● ゴールドウィンドウの作成
  #--------------------------------------------------------------------------
  def create_gold_window
    @gold_window = Window_Gold.new
    @gold_window.viewport = @viewport
    @gold_window.x = Graphics.width - @gold_window.width
    @gold_window.y = @help_window.height
    @gold_window.hide
  end
  #--------------------------------------------------------------------------
  # ● 切り替え表示ウィンドウの作成
  #--------------------------------------------------------------------------
  def create_change_window
    wx = 0
    wy = @gold_window.y
    ww = Graphics.width - @gold_window.width
    wh = @gold_window.height
    @change_window = Window_ItemSynthesisChange.new(wx, wy, ww, wh)
    @change_window.viewport = @viewport
    @change_window.hide
  end
  #--------------------------------------------------------------------------
  # ● ダミーウィンドウの作成
  #--------------------------------------------------------------------------
  def create_dummy_window
    wy = @help_window.y + @help_window.height + 48
    wh = Graphics.height - wy
    @dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
    @dummy_window.viewport = @viewport
  end
  #--------------------------------------------------------------------------
  # ● 個数入力ウィンドウの作成
  #--------------------------------------------------------------------------
  def create_number_window
    wy = @dummy_window.y
    wh = @dummy_window.height
    @number_window = Window_ItemSynthesisNumber.new(0, wy, wh)
    @number_window.viewport = @viewport
    @number_window.hide
    @number_window.set_handler(:ok,     method(:on_number_ok))
    @number_window.set_handler(:cancel, method(:on_number_cancel))
  end
  #--------------------------------------------------------------------------
  # ● ステータスウィンドウの作成
  #--------------------------------------------------------------------------
  def create_status_window
    wx = @number_window.width
    wy = @dummy_window.y
    ww = Graphics.width - wx
    wh = @dummy_window.height
    @status_window = Window_ShopStatus.new(wx, wy, ww, wh)
    @status_window.viewport = @viewport
    @status_window.hide
  end
  #--------------------------------------------------------------------------
  # ● 素材ウィンドウの作成
  #--------------------------------------------------------------------------
  def create_material_window
    wx = @number_window.width
    wy = @dummy_window.y
    ww = Graphics.width - wx
    wh = @dummy_window.height
    @material_window = Window_ItemSynthesisMaterial.new(wx, wy, ww, wh)
    @material_window.viewport = @viewport
    @material_window.hide
    @number_window.material_window = @material_window
  end
  #--------------------------------------------------------------------------
  # ● 合成アイテムリストウィンドウの作成
  #--------------------------------------------------------------------------
  def create_list_window
    wy = @dummy_window.y
    wh = @dummy_window.height
    @list_window = Window_ItemSynthesisList.new(0, wy, wh)
    @list_window.viewport = @viewport
    @list_window.help_window = @help_window
    @list_window.status_window = @status_window
    @list_window.material_window = @material_window
    @list_window.hide
    @list_window.set_handler(:ok,     method(:on_list_ok))
    @list_window.set_handler(:cancel, method(:on_list_cancel))
    @list_window.set_handler(:change_window, method(:on_change_window))   
  end
  #--------------------------------------------------------------------------
  # ● カテゴリウィンドウの作成
  #--------------------------------------------------------------------------
  def create_category_window
    @category_window = Window_ItemSynthesisCategory.new
    @category_window.viewport = @viewport
    @category_window.help_window = @help_window
    @category_window.y = @help_window.height
    @category_window.activate
    @category_window.item_window = @list_window
    @category_window.set_handler(:ok,     method(:on_category_ok))
    @category_window.set_handler(:cancel, method(:return_scene))
  end
  #--------------------------------------------------------------------------
  # ● 合成アイテムリストウィンドウのアクティブ化
  #--------------------------------------------------------------------------
  def activate_list_window
    @list_window.money = money
    @list_window.show.activate
  end
  #--------------------------------------------------------------------------
  # ● 合成[決定]
  #--------------------------------------------------------------------------
  def on_list_ok
    @item = @list_window.item
    @list_window.hide
    @number_window.set(@item, max_buy, buying_price, currency_unit)
    @number_window.show.activate
  end
  #--------------------------------------------------------------------------
  # ● 合成[キャンセル]
  #--------------------------------------------------------------------------
  def on_list_cancel
    @category_window.activate
    @category_window.show
    @dummy_window.show
    @list_window.hide
    @status_window.hide
    @status_window.item = nil
    @material_window.hide
    @material_window.set(nil, nil)
    @gold_window.hide
    @change_window.hide
    @help_window.clear
  end
  #--------------------------------------------------------------------------
  # ● 表示切替
  #--------------------------------------------------------------------------
  def on_change_window
    if @status_window.visible
      @status_window.hide
      @material_window.show
    else
      @status_window.show
      @material_window.hide
    end
  end
  #--------------------------------------------------------------------------
  # ● カテゴリ[決定]
  #--------------------------------------------------------------------------
  def on_category_ok
    activate_list_window
    @gold_window.show
    @change_window.show
    @material_window.show
    @category_window.hide
    @list_window.select(0)
  end
  #--------------------------------------------------------------------------
  # ● 個数入力[決定]
  #--------------------------------------------------------------------------
  def on_number_ok
    Sound.play_shop
    do_syntetic(@number_window.number)
    end_number_input
    @gold_window.refresh
  end
  #--------------------------------------------------------------------------
  # ● 個数入力[キャンセル]
  #--------------------------------------------------------------------------
  def on_number_cancel
    Sound.play_cancel
    end_number_input
  end
  #--------------------------------------------------------------------------
  # ● 合成の実行
  #--------------------------------------------------------------------------
  def do_syntetic(number)
    $game_party.lose_gold(number * buying_price)
    $game_party.gain_item(@item, number)
   
      @recipe = @list_window.recipe(@item)
      for i in 1...@recipe.size
        kind = @recipe[0]
        id   = @recipe[1]
        num  = @recipe[2]
        if kind == "I"
          item = $data_items[id]
        elsif kind == "W"
          item = $data_weapons[id]
        elsif kind == "A"
          item = $data_armors[id]
        end
        $game_party.lose_item(item, num*number)
      end
  end
  #--------------------------------------------------------------------------
  # ● 個数入力の終了
  #--------------------------------------------------------------------------
  def end_number_input
    @number_window.hide
    activate_list_window
  end
  #--------------------------------------------------------------------------
  # ● 最大購入可能個数の取得
  #--------------------------------------------------------------------------
  def max_buy
    max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
   
    @recipe = @list_window.recipe(@item)
      for i in 1...@recipe.size
        kind = @recipe[0]
        id   = @recipe[1]
        num  = @recipe[2]
        if kind == "I"
          item = $data_items[id]
        elsif kind == "W"
          item = $data_weapons[id]
        elsif kind == "A"
          item = $data_armors[id]
        end
        if num > 0
          max_buf = $game_party.item_number(item)/num
        else
          max_buf = 999
        end
        max = [max, max_buf].min
      end
      
    buying_price == 0 ? max : [max, money / buying_price].min

  end
  #--------------------------------------------------------------------------
  # ● 所持金の取得
  #--------------------------------------------------------------------------
  def money
    @gold_window.value
  end
  #--------------------------------------------------------------------------
  # ● 通貨単位の取得
  #--------------------------------------------------------------------------
  def currency_unit
    @gold_window.currency_unit
  end
  #--------------------------------------------------------------------------
  # ● 合成費用の取得
  #--------------------------------------------------------------------------
  def buying_price
    @list_window.price(@item)
  end
end


#==============================================================================
# ■ Window_ItemSynthesisList
#------------------------------------------------------------------------------
#  合成画面で、合成可能なアイテムの一覧を表示するウィンドウです。
#==============================================================================

class Window_ItemSynthesisList < Window_Selectable
  include WD_itemsynthesis
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader   :status_window            # ステータスウィンドウ
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x, y, height)
    super(x, y, window_width, height)
   
    @shop_goods = []
    @shop_recipes = []
   
    for i in 1..WD_itemsynthesis_ini::I_recipe.size
      recipe = WD_itemsynthesis_ini::I_recipe
      if recipe
        good = [0, i, recipe[0]]
        if i_recipe_switch_on?(i)
          @shop_goods.push(good)
          @shop_recipes.push(recipe)
        end
      end
    end
    for i in 1..WD_itemsynthesis_ini::W_recipe.size
      recipe = WD_itemsynthesis_ini::W_recipe
      if recipe
        good = [1, i, recipe[0]]
        if w_recipe_switch_on?(i)
          @shop_goods.push(good)
          @shop_recipes.push(recipe)
        end
      end
    end
    for i in 1..WD_itemsynthesis_ini::A_recipe.size
      recipe = WD_itemsynthesis_ini::A_recipe
      if recipe
        good = [2, i, recipe[0]]
        if a_recipe_switch_on?(i)
          @shop_goods.push(good)
          @shop_recipes.push(recipe)
        end
      end
    end
   
    @Money = 0
    refresh
    select(0)
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウ幅の取得
  #--------------------------------------------------------------------------
  def window_width
    return 304
  end
  #--------------------------------------------------------------------------
  # ● 項目数の取得
  #--------------------------------------------------------------------------
  def item_max
    @data ? @data.size : 1
  end
  #--------------------------------------------------------------------------
  # ● アイテムの取得
  #--------------------------------------------------------------------------
  def item
    @data[index]
  end
  #--------------------------------------------------------------------------
  # ● 所持金の設定
  #--------------------------------------------------------------------------
  def money=(money)
    @money = money
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 選択項目の有効状態を取得
  #--------------------------------------------------------------------------
  def current_item_enabled?
    enable?(@data[index])
  end
  #--------------------------------------------------------------------------
  # ● 合成費用を取得
  #--------------------------------------------------------------------------
  def price(item)
    @price[item]
  end
  #--------------------------------------------------------------------------
  # ● 合成可否を取得
  #--------------------------------------------------------------------------
  def enable?(item)
    @makable[item]
  end
  #--------------------------------------------------------------------------
  # ● レシピを取得
  #--------------------------------------------------------------------------
  def recipe(item)
    @recipe[item]
  end
  #--------------------------------------------------------------------------
  # ● アイテムを許可状態で表示するかどうか
  #--------------------------------------------------------------------------
  def have_mat?(recipe)
    flag = true
    if @money >= recipe[0]
      for i in 1...recipe.size
        kind = recipe[0]
        id   = recipe[1]
        num  = recipe[2]
        if kind == "I"
          item = $data_items[id]
        elsif kind == "W"
          item = $data_weapons[id]
        elsif kind == "A"
          item = $data_armors[id]
        end
        if $game_party.item_number(item) < [num, 1].max
          flag = false
        end
      end
    else
      flag = false
    end
    return flag
  end
  #--------------------------------------------------------------------------
  # ● カテゴリの設定
  #--------------------------------------------------------------------------
  def category=(category)
    return if @category == category
    @category = category
    refresh
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    make_item_list
    create_contents
    draw_all_items
  end
  #--------------------------------------------------------------------------
  # ● アイテムをリストに含めるかどうか
  #--------------------------------------------------------------------------
  def include?(item)
    case @category
    when :item
      item.is_a?(RPG::Item) && !item.key_item?
    when :weapon
      item.is_a?(RPG::Weapon)
    when :armor
      item.is_a?(RPG::Armor)
    when :key_item
      item.is_a?(RPG::Item) && item.key_item?
    else
      false
    end
  end
  #--------------------------------------------------------------------------
  # ● アイテムリストの作成
  #--------------------------------------------------------------------------
  def make_item_list
    @data = []
    @price = {}
    @makable = {}
    @recipe = {}
    for i in 0...@shop_goods.size
      goods = @shop_goods
      recipe = @shop_recipes
      case goods[0]
      when 0;  item = $data_items[goods[1]]
      when 1;  item = $data_weapons[goods[1]]
      when 2;  item = $data_armors[goods[1]]
      end
      if item
        if include?(item)
          @data.push(item)
          @price[item] = goods[2]
          @makable[item] = have_mat?(recipe)
          @recipe[item] = recipe
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 項目の描画
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    rect = item_rect(index)
    draw_item_name(item, rect.x, rect.y, enable?(item))
    rect.width -= 4
    draw_text(rect, price(item), 2)  if WD_itemsynthesis_ini::Cost_view
  end
  #--------------------------------------------------------------------------
  # ● ステータスウィンドウの設定
  #--------------------------------------------------------------------------
  def status_window=(status_window)
    @status_window = status_window
    call_update_help
  end
  #--------------------------------------------------------------------------
  # ● 素材ウィンドウの設定
  #--------------------------------------------------------------------------
  def material_window=(material_window)
    @material_window = material_window
    call_update_help
  end
  #--------------------------------------------------------------------------
  # ● ヘルプテキスト更新
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_item(item) if @help_window
    @status_window.item = item if @status_window
    @material_window.set(item, recipe(item)) if @material_window
  end
  #--------------------------------------------------------------------------
  # ● ←→ ボタン(表示切替)が押されたときの処理
  #--------------------------------------------------------------------------
  def process_change_window
    Sound.play_cursor
    Input.update
    call_handler(:change_window)
  end
  #--------------------------------------------------------------------------
  # ● 決定やキャンセルなどのハンドリング処理
  #--------------------------------------------------------------------------
  def process_handling
    super
    if active
      return process_change_window if handle?(:change_window) && Input.trigger?(:X)
      return process_change_window if handle?(:change_window) && Input.trigger?(:Y)
    end
  end
end


#==============================================================================
# ■ Window_ItemSynthesisMaterial
#------------------------------------------------------------------------------
#  合成画面で、合成に必要な素材を表示するウィンドウです。
#==============================================================================

class Window_ItemSynthesisMaterial < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super(x, y, width, height)
    @item = nil
    refresh
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_possession(4, 0)
    draw_material_info(0, line_height * 2)
  end
  #--------------------------------------------------------------------------
  # ● アイテムの設定
  #--------------------------------------------------------------------------
  def set(item, recipe)
    @item = item
    @recipe = recipe
    @make_number = 1
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 作成個数の設定
  #--------------------------------------------------------------------------
  def set_num(make_number)
    @make_number = make_number
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 所持数の描画
  #--------------------------------------------------------------------------
  def draw_possession(x, y)
    rect = Rect.new(x, y, contents.width - 4 - x, line_height)
    change_color(system_color)
    draw_text(rect, Vocab::Possession)
    change_color(normal_color)
    draw_text(rect, $game_party.item_number(@item), 2)
  end
  #--------------------------------------------------------------------------
  # ● 素材情報の描画
  #--------------------------------------------------------------------------
  def draw_material_info(x, y)
    rect = Rect.new(x, y, contents.width, line_height)
    change_color(system_color)
    contents.font.size = 18
    draw_text(rect, "必要素材", 0)
    if @recipe
      for i in 1...@recipe.size
        kind = @recipe[0]
        id   = @recipe[1]
        num  = @recipe[2]
        if kind == "I"
          item = $data_items[id]
        elsif kind == "W"
          item = $data_weapons[id]
        elsif kind == "A"
          item = $data_armors[id]
        end
        rect = Rect.new(x, y + line_height*i, contents.width, line_height)
        enabled = true
        enabled = false if [num*@make_number, 1].max  > $game_party.item_number(item)
        draw_item_name(item, rect.x, rect.y, enabled)
        change_color(normal_color, enabled)
        if num > 0
          draw_text(rect, "#{num*@make_number}/#{$game_party.item_number(item)}", 2)
        end
      end
    end
    change_color(normal_color)
    contents.font.size = 24
  end
end


#==============================================================================
# ■ Window_ItemSynthesisNumber
#------------------------------------------------------------------------------
#  合成画面で、合成するアイテムの個数を入力するウィンドウです。
#==============================================================================

class Window_ItemSynthesisNumber < Window_ShopNumber
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_item_name(@item, 0, item_y)
    draw_number
    draw_total_price if WD_itemsynthesis_ini::Cost_view
  end
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def material_window=(material_window)
    @material_window = material_window
    call_update_help
  end
  #--------------------------------------------------------------------------
  # ● 作成個数の変更
  #--------------------------------------------------------------------------
  def change_number(amount)
    @number = [[@number + amount, @max].min, 1].max
    call_update_help #追加
  end
  #--------------------------------------------------------------------------
  # ● ヘルプテキスト更新
  #--------------------------------------------------------------------------
  def call_update_help
    @material_window.set_num(@number) if @material_window
  end
end


#==============================================================================
# ■ Window_ItemSynthesisCategory
#------------------------------------------------------------------------------
#  合成画面で、通常アイテムや装備品の分類を選択するウィンドウです。
#==============================================================================

class Window_ItemSynthesisCategory < Window_ItemCategory
  #--------------------------------------------------------------------------
  # ● 桁数の取得
  #--------------------------------------------------------------------------
  def col_max
    i = 0
    i += 1 if WD_itemsynthesis_ini::Category_i
    i += 1 if WD_itemsynthesis_ini::Category_w
    i += 1 if WD_itemsynthesis_ini::Category_a
    i += 1 if WD_itemsynthesis_ini::Category_k
    return i
  end
  #--------------------------------------------------------------------------
  # ● コマンドリストの作成
  #--------------------------------------------------------------------------
  def make_command_list
    add_command(Vocab::item,     :item)     if WD_itemsynthesis_ini::Category_i
    add_command(Vocab::weapon,   :weapon)   if WD_itemsynthesis_ini::Category_w
    add_command(Vocab::armor,    :armor)    if WD_itemsynthesis_ini::Category_a
    add_command(Vocab::key_item, :key_item) if WD_itemsynthesis_ini::Category_k
  end
end


#==============================================================================
# ■ Window_ItemSynthesisNumber
#------------------------------------------------------------------------------
#  合成画面で、切替を表示するウィンドウです。
#==============================================================================

class Window_ItemSynthesisChange < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super(x, y, width, height)
    refresh
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    text = "X Y:表示切り替え"
    draw_text(0, 0, contents_width, line_height, text, 1)
  end
end
[/pre]

点评

谢谢!  发表于 2013-8-30 07:07

评分

参与人数 1星屑 +200 收起 理由
taroxd + 200 认可答案

查看全部评分


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部