查看: 2212|回复: 6

[已经过期] 为什么物品合成脚本545行出错

[复制链接]

【欧皇】

梦石
3
星屑
2055
在线时间
1004 小时
注册时间
2013-8-19
回帖
3040

开拓者

发表于 2016-3-6 20:45:35 | 显示全部楼层 |阅读模式

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

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

×
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. #==============================================================================  

  4. # Sample master list for crafting script
  5. # written by Deke
  6. #============================================================================================
  7. # 简介:
  8. # 这是一个很不错的合成物品系统,可以通过游戏的过程,不断学习可以合成的
  9. # 物品方法。
  10. #
  11. # 使用方法:
  12. # 1、召唤界面:使用脚本$scene = Scene_Craft.new
  13. #
  14. # 2、学习合成:$game_party.learn_recipe(合成项目)
  15. #
  16. # 3、合成定义:
  17. # 这个合成脚本可以定义两种合成物品。一种是预先定义好了的,就像下面这样,
  18. # 直接写在这里就可以,另一种是在学习之前现场定义。
  19. #
  20. # 4、举例
  21. #  4.1、学会recipe_list[1]定义的合成:$game_party.learn_recipe($game_temp.recipe_list[1])
  22. #       注意,一行如果输入不下,在(的后面或[的后面按回车换行,否则可能出错
  23. #
  24. #  4.2、在游戏中临时定义一种合成,让玩家学会。使用事件中的脚本如下,   
  25. #  脚本:
  26. #    材料 = [$game_variables[1],$game_variables[2]]  #——材料编号是变量1、2的编号
  27. #    材料种类 = [0,0]                                #——材料是物品
  28. #    材料数量 = [$game_variables[3],$game_variables[4]]  #——需要材料数量是变量3、4的编号
  29. #    成品 = $game_variables[5]                       #——获得结果编号是5
  30. #    成品种类 = 1                                    #——成品是防具类
  31. #    $game_party.learn_recipe(Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类))
  32. #===========================================================================================
  33. class Game_Temp
  34. attr_reader :recipe_list  
  35. alias crafting_temp_initialize initialize
  36. def initialize
  37.    crafting_temp_initialize
  38.    @recipe_list=[]
  39.    get_recipe_list
  40. end  
  41. def get_recipe_list
  42.    ##########################################################################
  43.    ####1号物品合成设定    速度粉末*10+玻璃瓶*1=暂时加速剂              
  44.    ##########################################################################
  45.    材料 = [49,50]        # 需要材料的数据库编号
  46.    材料种类 = [0,0]      # 需要材料的种类,0是普通物品,1是防具,2是武器
  47.    材料数量 = [10,1]     # 需要材料的数量
  48.    成品 = 34             # 获得物品编号
  49.    成品种类 = 0          # 获得物品种类,0是普通物品,1是防具,2是武器
  50.    @recipe_list[1] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  51.    
  52.    ##########################################################################
  53.    ####2号物品合成设定    复活水晶*1+速度粉末*8+玻璃瓶*1=精神药水                     
  54.    ##########################################################################
  55.    材料 = [35,49,50]     # 需要材料的数据库编号
  56.    材料种类 = [0,0,0]    # 需要材料的种类,0是普通物品,1是防具,2是武器
  57.    材料数量 = [1,8,1]    # 需要材料的数量
  58.    成品 = 51             # 获得物品编号
  59.    成品种类 = 0          # 获得物品种类,0是普通物品,1是防具,2是武器
  60.    @recipe_list[2] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  61.    ##########################################################################
  62.    ####3号物品合成设定    石头*30=石盾                       
  63.    ##########################################################################
  64.    材料 = [48]           # 需要材料的数据库编号
  65.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  66.    材料数量 = [30]       # 需要材料的数量
  67.    成品 = 79             # 获得物品编号
  68.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  69.    @recipe_list[3] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  70.    ##########################################################################
  71.    ##########################################################################
  72.    ####4号物品合成设定    铝锭*20=铝质头饰                       
  73.    ##########################################################################
  74.    材料 = [47]           # 需要材料的数据库编号
  75.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  76.    材料数量 = [20]       # 需要材料的数量
  77.    成品 = 35             # 获得物品编号
  78.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  79.    @recipe_list[4] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  80.    ##########################################################################
  81.    ##########################################################################
  82.    ####5号物品合成设定    铝锭*25=铝质胸甲                       
  83.    ##########################################################################
  84.    材料 = [47]           # 需要材料的数据库编号
  85.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  86.    材料数量 = [25]       # 需要材料的数量
  87.    成品 = 50             # 获得物品编号
  88.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  89.    @recipe_list[5] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  90.    ##########################################################################
  91.    ##########################################################################
  92.    ####6号物品合成设定    铝锭*15=铝质鞋子                       
  93.    ##########################################################################
  94.    材料 = [47]           # 需要材料的数据库编号
  95.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  96.    材料数量 = [15]       # 需要材料的数量
  97.    成品 = 65             # 获得物品编号
  98.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  99.    @recipe_list[6] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  100.    ##########################################################################
  101.    ##########################################################################
  102.    ####7号物品合成设定    铝锭*20=铝质小盾                       
  103.    ##########################################################################
  104.    材料 = [47]           # 需要材料的数据库编号
  105.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  106.    材料数量 = [20]       # 需要材料的数量
  107.    成品 = 80             # 获得物品编号
  108.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  109.    @recipe_list[7] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  110.    ##########################################################################
  111.    ##########################################################################
  112.    ####8号物品合成设定    铁锭*22=铁质面具                       
  113.    ##########################################################################
  114.    材料 = [46]           # 需要材料的数据库编号
  115.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  116.    材料数量 = [22]       # 需要材料的数量
  117.    成品 = 36             # 获得物品编号
  118.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  119.    @recipe_list[8] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  120.    ##########################################################################
  121.    ##########################################################################
  122.    ####9号物品合成设定    铁锭*28=铁质胸甲                       
  123.    ##########################################################################
  124.    材料 = [46]           # 需要材料的数据库编号
  125.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  126.    材料数量 = [28]       # 需要材料的数量
  127.    成品 = 51             # 获得物品编号
  128.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  129.    @recipe_list[9] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  130.    ##########################################################################
  131.    ##########################################################################
  132.    ####10号物品合成设定   铁锭*16=铁质鞋子                       
  133.    ##########################################################################
  134.    材料 = [46]           # 需要材料的数据库编号
  135.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  136.    材料数量 = [16]       # 需要材料的数量
  137.    成品 = 66             # 获得物品编号
  138.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  139.    @recipe_list[10] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  140.    ##########################################################################
  141.    ##########################################################################
  142.    ####11号物品合成设定   铁锭*23=铁质小盾                       
  143.    ##########################################################################
  144.    材料 = [46]           # 需要材料的数据库编号
  145.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  146.    材料数量 = [23]       # 需要材料的数量
  147.    成品 = 81             # 获得物品编号
  148.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  149.    @recipe_list[11] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  150.    ##########################################################################
  151.    ##########################################################################
  152.    ####12号物品合成设定    铜锭*24=铜质头盔                       
  153.    ##########################################################################
  154.    材料 = [45]           # 需要材料的数据库编号
  155.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  156.    材料数量 = [24]       # 需要材料的数量
  157.    成品 = 37             # 获得物品编号
  158.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  159.    @recipe_list[12] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  160.    ##########################################################################
  161.    ##########################################################################
  162.    ####13号物品合成设定    铜锭*31=黄铜护甲                     
  163.    ##########################################################################
  164.    材料 = [45]           # 需要材料的数据库编号
  165.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  166.    材料数量 = [31]       # 需要材料的数量
  167.    成品 = 52             # 获得物品编号
  168.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  169.    @recipe_list[13] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  170.    ##########################################################################
  171.    ##########################################################################
  172.    ####14号物品合成设定   铜锭*17=黄铜跑鞋                       
  173.    ##########################################################################
  174.    材料 = [45]           # 需要材料的数据库编号
  175.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  176.    材料数量 = [17]       # 需要材料的数量
  177.    成品 = 67             # 获得物品编号
  178.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  179.    @recipe_list[14] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  180.    ##########################################################################
  181.    ##########################################################################
  182.    ####15号物品合成设定   铜锭*26=黄铜盾牌                       
  183.    ##########################################################################
  184.    材料 = [45]           # 需要材料的数据库编号
  185.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  186.    材料数量 = [26]       # 需要材料的数量
  187.    成品 = 82             # 获得物品编号
  188.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  189.    @recipe_list[15] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  190.    ##########################################################################
  191.    ##########################################################################
  192.    ####16号物品合成设定    银锭*26=白银头盔                       
  193.    ##########################################################################
  194.    材料 = [62]           # 需要材料的数据库编号
  195.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  196.    材料数量 = [26]       # 需要材料的数量
  197.    成品 = 38             # 获得物品编号
  198.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  199.    @recipe_list[16] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  200.    ##########################################################################
  201.    ##########################################################################
  202.    ####17号物品合成设定    银锭*34=白银护甲                     
  203.    ##########################################################################
  204.    材料 = [62]           # 需要材料的数据库编号
  205.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  206.    材料数量 = [34]       # 需要材料的数量
  207.    成品 = 53             # 获得物品编号
  208.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  209.    @recipe_list[17] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  210.    ##########################################################################
  211.    ##########################################################################
  212.    ####18号物品合成设定   银锭*18=白银跑鞋                       
  213.    ##########################################################################
  214.    材料 = [62]           # 需要材料的数据库编号
  215.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  216.    材料数量 = [18]       # 需要材料的数量
  217.    成品 = 68             # 获得物品编号
  218.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  219.    @recipe_list[18] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  220.    ##########################################################################
  221.    ##########################################################################
  222.    ####19号物品合成设定   银锭*29=白银盾牌                       
  223.    ##########################################################################
  224.    材料 = [62]           # 需要材料的数据库编号
  225.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  226.    材料数量 = [29]       # 需要材料的数量
  227.    成品 = 83             # 获得物品编号
  228.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  229.    @recipe_list[19] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  230.    ##########################################################################
  231.    ##########################################################################
  232.    ####20号物品合成设定    金锭*28=黄金战盔                       
  233.    ##########################################################################
  234.    材料 = [44]           # 需要材料的数据库编号
  235.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  236.    材料数量 = [28]       # 需要材料的数量
  237.    成品 = 39             # 获得物品编号
  238.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  239.    @recipe_list[20] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  240.    ##########################################################################
  241.    ##########################################################################
  242.    ####21号物品合成设定    金锭*37=黄金铠甲                     
  243.    ##########################################################################
  244.    材料 = [44]           # 需要材料的数据库编号
  245.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  246.    材料数量 = [37]       # 需要材料的数量
  247.    成品 = 54             # 获得物品编号
  248.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  249.    @recipe_list[21] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  250.    ##########################################################################
  251.    ##########################################################################
  252.    ####22号物品合成设定    金锭*19=黄金飞靴                       
  253.    ##########################################################################
  254.    材料 = [44]           # 需要材料的数据库编号
  255.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  256.    材料数量 = [19]       # 需要材料的数量
  257.    成品 = 69             # 获得物品编号
  258.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  259.    @recipe_list[22] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  260.    ##########################################################################
  261.    ##########################################################################
  262.    ####23号物品合成设定    金锭*32=黄金盾牌                       
  263.    ##########################################################################
  264.    材料 = [44]           # 需要材料的数据库编号
  265.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  266.    材料数量 = [32]       # 需要材料的数量
  267.    成品 = 84             # 获得物品编号
  268.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  269.    @recipe_list[23] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  270.    ##########################################################################
  271.    ##########################################################################
  272.    ####24号物品合成设定    钻石*30=金刚战盔                       
  273.    ##########################################################################
  274.    材料 = [43]           # 需要材料的数据库编号
  275.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  276.    材料数量 = [30]       # 需要材料的数量
  277.    成品 = 40             # 获得物品编号
  278.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  279.    @recipe_list[24] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  280.    ##########################################################################
  281.    ##########################################################################
  282.    ####25号物品合成设定    钻石*40=金刚铠甲                     
  283.    ##########################################################################
  284.    材料 = [43]           # 需要材料的数据库编号
  285.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  286.    材料数量 = [40]       # 需要材料的数量
  287.    成品 = 55             # 获得物品编号
  288.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  289.    @recipe_list[25] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  290.    ##########################################################################
  291.    ##########################################################################
  292.    ####26号物品合成设定    钻石*20=金刚飞靴                       
  293.    ##########################################################################
  294.    材料 = [43]           # 需要材料的数据库编号
  295.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  296.    材料数量 = [20]       # 需要材料的数量
  297.    成品 = 70             # 获得物品编号
  298.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  299.    @recipe_list[26] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  300.    ##########################################################################
  301.    ##########################################################################
  302.    ####27号物品合成设定    钻石*35=金刚盾牌                       
  303.    ##########################################################################
  304.    材料 = [43]           # 需要材料的数据库编号
  305.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  306.    材料数量 = [35]       # 需要材料的数量
  307.    成品 = 85             # 获得物品编号
  308.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  309.    @recipe_list[27] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  310.    ##########################################################################
  311. end # of get_recipe_list method
  312. end # of updates to Game_Temp Class

  313. #================================
  314. # CRAFTING PROGRAM
  315. #----------------------------------------------------------------
  316. #-written by Deke
  317. #-yes_no window code created by Phsylomortis
  318. #----------------------------------------------------------------
  319. #================================

  320. #updates to Game_Party class

  321. class Game_Party

  322. attr_accessor       :recipes

  323. alias crafting_party_initialize initialize

  324. def initialize
  325.    crafting_party_initialize
  326.    @recipes=[]
  327. end

  328. #----------------------------------------------------------------------
  329. def know?(recipe, version = 1)
  330.    unless recipe.is_a?(Game_Recipe)
  331.      recipe = get_recipe_from_master_list(recipe, version)
  332.    end
  333.    return $game_party.recipes.include?(recipe)
  334. end

  335. #----------------------------------------------------------------------
  336. def learn_recipe(recipe , version = 1)
  337.    unless recipe.is_a?(Game_Recipe)
  338.      recipe = get_recipe_from_master_list(recipe, version)
  339.    end
  340.    if recipe.is_a?(Game_Recipe)
  341.      unless know?(recipe)
  342.        @recipes.push(recipe)
  343.      end
  344.    end
  345. end

  346. #----------------------------------------------------------------------
  347. def forget_recipe(recipe , version = 1)
  348.    if !recipe.is_a?(Game_Recipe)
  349.      recipe = get_recipe_from_master_list(recipe, version)
  350.    end
  351.    if recipe.is_a?(Game_Recipe)
  352.      for i in [email]0...@recipes.size[/email]
  353.        if recipe == @recipes
  354.          index = i
  355.          break
  356.        end
  357.      end
  358.      if index != nil
  359.        @recipes.delete(@recipes[index])
  360.      end
  361.    end
  362. end

  363. #----------------------------------------------------------------------
  364. def get_recipe_from_master_list(item, version)
  365.    index = nil
  366.    for i in 0...$game_temp.recipe_list.size
  367.      if item[0] == $game_temp.recipe_list.result and item[1] == $game_temp.recipe_list.result_type
  368.        version -= 1
  369.        if version == 0
  370.          index = i
  371.          break
  372.        end
  373.      end
  374.    end
  375.    if index.is_a?(Integer)
  376.      return ($game_temp.recipe_list[index])
  377.    else
  378.      return false
  379.    end
  380. end

  381. end # of Game_Party updates

  382. #================================
  383. class Game_Recipe

  384. attr_reader :ingredients
  385. attr_reader :quantities
  386. attr_reader :result
  387. attr_reader :result_type
  388. attr_reader :ingredient_types

  389. #----------------------------------------------------------------------
  390. def initialize( ingredients, ingredient_types, quantities, result, result_type)
  391.    @ingredients = ingredients
  392.    @ingredient_types = ingredient_types
  393.    @quantities = quantities
  394.    @result = result
  395.    @result_type = result_type
  396. end

  397. #----------------------------------------------------------------------
  398. def name
  399.    case @result_type
  400.      when 0
  401.        name = $data_items[@result].name
  402.      when 1
  403.        name = $data_armors[@result].name
  404.      when 2
  405.        name = $data_weapons[@result].name
  406.    end
  407.    return name
  408. end

  409. #----------------------------------------------------------------------
  410. def have
  411.    have_all = true
  412.    for i in [email]0...@ingredients.size[/email]
  413.      case @ingredient_types
  414.        when 0
  415.          if $game_party.item_number(@ingredients) < @quantities
  416.            have_all=false
  417.          end
  418.        when 1
  419.          if $game_party.armor_number(@ingredients) < @quantities
  420.            have_all=false
  421.          end
  422.        when 2
  423.          if $game_party.weapon_number(@ingredients) < @quantities
  424.            have_all=false
  425.          end
  426.      end
  427.    end
  428.    return have_all
  429. end

  430. #----------------------------------------------------------------------
  431. def decrement
  432.    for i in [email]0...@ingredients.size[/email]
  433.      case @ingredient_types
  434.      when 0
  435.        $game_party.lose_item(@ingredients, @quantities)
  436.      when 1
  437.        $game_party.lose_armor(@ingredients, @quantities)
  438.      when 2
  439.        $game_party.lose_weapon(@ingredients, @quantities)
  440.      end
  441.    end
  442. end

  443. #----------------------------------------------------------------------
  444. def make
  445.    if have
  446.      case @result_type
  447.      when 0
  448.        $game_party.gain_item(@result, 1)
  449.      when 1
  450.        $game_party.gain_armor(@result, 1)
  451.      when 2
  452.        $game_party.gain_weapon(@result, 1)
  453.      end
  454.      decrement
  455.    end
  456. end

  457. #----------------------------------------------------------------------
  458. def == (recipe)
  459.    if recipe.is_a?(Game_Recipe)
  460.      equal = true
  461.      if recipe.ingredients != self.ingredients
  462.        equal = false
  463.      end
  464.      if recipe.ingredient_types != self.ingredient_types
  465.        equal = false
  466.      end
  467.      if recipe.quantities != self.quantities
  468.        equal = false
  469.      end
  470.      if recipe.result != self.result
  471.        equal=false
  472.      end
  473.      if recipe.result_type != self.result_type
  474.        equal = false
  475.      end
  476.    else
  477.      equal = false
  478.    end
  479.    return equal
  480. end

  481. end # of Game_Recipe class

  482. #===================================

  483. class Window_Craft < Window_Selectable

  484. #--------------------------------------------------------------------------
  485. def initialize
  486.    super(0, 64, 240, 416)
  487.    @column_max = 1
  488.    refresh
  489.    self.index = 0
  490. end

  491. #--------------------------------------------------------------------------
  492. def recipe
  493.    return @data[self.index]
  494. end

  495. #--------------------------------------------------------------------------
  496. def refresh
  497.    if self.contents != nil
  498.      self.contents.dispose
  499.      self.contents = nil
  500.    end
  501.    @data = []
  502.    for i in 0...$game_party.recipes.size
  503.        @data.push($game_party.recipes)
  504.    end
  505.    @item_max = @data.size
  506.    if @item_max > 0
  507.      self.contents = Bitmap.new(width - 32, row_max * 32)
  508.      self.contents.font.name = "黑体" # = "黑体"
  509.      self.contents.font.size = 18 # = 18
  510.      for i in 0...@item_max
  511.        draw_item(i)
  512.      end
  513.    end
  514. end

  515. #--------------------------------------------------------------------------
  516. def draw_item(index)
  517.    recipe = @data[index]
  518.    self.contents.font.color = recipe.have ? normal_color : disabled_color
  519.    x = 16
  520.    y = index * 32
  521.    self.contents.draw_text(x , y, self.width-32, 32, recipe.name, 0)
  522. end

  523. #--------------------------------------------------------------------------
  524. def update_help
  525.    current_recipe = recipe
  526.    if current_recipe.is_a?(Game_Recipe)
  527.    case current_recipe.result_type
  528.      when 0
  529.        description = $data_items[current_recipe.result].description
  530.      when 1
  531.        description = $data_armors[current_recipe.result].description
  532.      when 2
  533.        description = $data_weapons[current_recipe.result].description
  534.      end
  535.    else
  536.      description = ""
  537.    end
  538.    @help_window.set_text(description)
  539.    @help_window.update
  540. end

  541. end # of Window_Craft

  542. #=======================================
  543. class Window_CraftResult < Window_Base

  544. #--------------------------------------------------------------------------
  545. def initialize
  546.    super(240, 64, 400, 184)
  547.    self.contents = Bitmap.new(width - 32, height - 32)
  548.    self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  549.    self.contents.font.size = 18 # = 20
  550.    @result = nil
  551.    @type = nil
  552. end

  553. #--------------------------------------------------------------------------
  554. def refresh
  555.    self.contents.clear
  556.    case @type
  557.      when 0
  558.        item = $data_items[@result]
  559.       
  560.          hp_string = "HP回复率:"
  561.          hp_stat = item.recover_hp_rate
  562.          hp_string2 = "HP回复量:"
  563.          hp_stat2 = item.recover_hp
  564.          sp_string = "SP回复率:"
  565.          sp_stat = item.recover_sp_rate
  566.          sp_string2 = "SP回复量:"
  567.          sp_stat2 = item.recover_sp
  568.        @strings = [hp_string, sp_string,hp_string2,sp_string2]
  569.        @stats = [hp_stat, sp_stat,hp_stat2 ,sp_stat2,
  570.                       $game_party.item_number(@result)]
  571.        @bitmap = RPG::Cache.icon(item.icon_name)
  572.        when 1
  573.        item = $data_armors[@result]
  574.        @strings = ["物御增加:", "魔御增加:",  "力量增加:", "灵巧增加:",
  575.                       "速度增加:", "魔力增加:"]
  576.        @stats = [item.pdef, item.mdef, item.str_plus, item.dex_plus,
  577.                    item.agi_plus, item.int_plus, $game_party.armor_number(@result) ]
  578.        @bitmap = RPG::Cache.icon(item.icon_name)
  579.      when 2
  580.        item = $data_weapons[@result]
  581.        @strings =["破坏:", "物御增加:", "魔御增加:", "力量增加:", "灵巧增加:",
  582.                    "速度增加:", "魔力增加:"]
  583.        @stats = [item.atk, item.pdef, item.mdef, item.str_plus, item.dex_plus,
  584.                    item.agi_plus, item.int_plus, $game_party.weapon_number(@result) ]
  585.        @bitmap = RPG::Cache.icon(item.icon_name)
  586.    end
  587.    for i in [email]0...@strings.size[/email]
  588.      x = i%2 * 184
  589.      y = i /2 *28 +32
  590.      self.contents.font.color = normal_color
  591.      self.contents.draw_text(x,y,100, 28,@strings)
  592.      self.contents.font.color = system_color
  593.      self.contents.draw_text(x + 110, y, 45, 28, @stats.to_s)
  594.    end
  595.    self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, 24, 24), 255)
  596.    self.contents.font.color= normal_color
  597.    self.contents.draw_text(40, 0, 300, 28, "待合成物品的现有数量:")
  598.    self.contents.font.color = system_color
  599.    count = @stats[@stats.size - 1].to_s
  600.    self.contents.draw_text(294, 0, 45, 28, count )
  601. end
  602.    
  603. #----------------------------------------------------------------------
  604. def set_result(result , type)
  605.    @result = result
  606.    @type = type
  607.    refresh
  608. end

  609. end #of Window_CraftResult

  610. #=======================================
  611. class Window_CraftIngredients < Window_Base

  612. #--------------------------------------------------------------------------
  613. def initialize
  614.    super(240, 248, 400, 232)
  615.    self.contents = Bitmap.new(width - 32, height - 32)
  616.    self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  617.    self.contents.font.size = 18 # = 20
  618.    @ingredients = []
  619.    @types = []
  620.    @quantities = []
  621.    @item = nil
  622.    @count = 0
  623. end

  624. #--------------------------------------------------------------------------
  625. def refresh
  626.    self.contents.clear
  627.    for i in [email]0...@ingredients.size[/email]
  628.      case @types
  629.      when 0
  630.        @item = $data_items[@ingredients]
  631.        @count = $game_party.item_number(@ingredients)
  632.      when 1
  633.        @item = $data_armors[@ingredients]
  634.        @count = $game_party.armor_number(@ingredients)
  635.      when 2
  636.        @item = $data_weapons[@ingredients]
  637.        @count = $game_party.weapon_number(@ingredients)
  638.      end
  639.      y = i *26
  640.      self.contents.blt(0, y, RPG::Cache.icon(@item.icon_name), Rect.new(0, 0, 24, 24), 255)
  641.      self.contents.font.color = @count >= @quantities ? normal_color : disabled_color
  642.      self.contents.draw_text(30, y, 280, 28, @item.name)
  643.      self.contents.draw_text(300, y, 45, 28, @quantities.to_s)
  644.      self.contents.font.color = system_color
  645.      self.contents.draw_text(245, y, 45, 28, @count.to_s )     
  646.    end
  647. end
  648.      
  649. #--------------------------------------------------------------------------
  650. def set_ingredients(ingredients , types, quantities)
  651.    @ingredients = ingredients
  652.    @types = types
  653.    @quantities = quantities
  654.    refresh
  655. end

  656. end # of Window_CraftIngredients

  657. #======================================
  658. class Scene_Craft

  659. #--------------------------------------------------------------------------
  660. def initialize(craft_index=0)
  661.    @craft_index=craft_index
  662. end

  663. #--------------------------------------------------------------------------
  664. def main
  665.    @craft_window = Window_Craft.new
  666.    @craft_window.index=@craft_index
  667.    @confirm_window = Window_Base.new(120, 188, 400, 64)
  668.    @confirm_window.contents = Bitmap.new(368, 32)
  669.    @confirm_window.contents.font.name = "黑体"
  670.    @confirm_window.contents.font.size = 20
  671.    @help_window = Window_Help.new
  672.    @craft_window.help_window = @help_window
  673.    @result_window=Window_CraftResult.new
  674.    @ingredients_window=Window_CraftIngredients.new
  675.    @yes_no_window = Window_Command.new(100, ["确定", "放弃"])
  676.    @confirm_window.visible = false
  677.    @confirm_window.z = 1500
  678.    @yes_no_window.visible = false
  679.    @yes_no_window.active = false
  680.    @yes_no_window.index = 1
  681.    @yes_no_window.x = 270
  682.    @yes_no_window.y = 252
  683.    @yes_no_window.z = 1500
  684.    @label_window = Window_Base.new(450,200,190,52)
  685.    @label_window.contents=Bitmap.new(@label_window.width - 32,@label_window.height - 32)
  686.    @label_window.contents.font.size=20
  687.    @label_window.contents.font.color = @label_window.normal_color
  688.    @label_window.contents.font.name = "黑体"
  689.    @label_window.contents.draw_text(0, 0, @label_window.contents.width, 20, "  现有   需要")
  690.    Graphics.transition
  691.    loop do
  692.      Graphics.update
  693.      Input.update
  694.      update
  695.      if $scene != self
  696.        break
  697.      end
  698.    end
  699.    Graphics.freeze
  700.    @help_window.dispose
  701.    @craft_window.dispose
  702.    @result_window.dispose
  703.    @ingredients_window.dispose
  704.    @confirm_window.dispose
  705.    @yes_no_window.dispose
  706.    @label_window.dispose
  707. end

  708. #--------------------------------------------------------------------------
  709. def update
  710.    @craft_window.update
  711.    @ingredients_window.update
  712.    if $game_party.recipes.size > 0
  713.      @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
  714.      @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
  715.                                                           @craft_window.recipe.ingredient_types,
  716.                                                           @craft_window.recipe.quantities)
  717.    end
  718.    if @craft_window.active
  719.      update_craft
  720.      return
  721.    end
  722.    if @yes_no_window.active
  723.      confirm_update
  724.      return
  725.    end
  726. end

  727. #--------------------------------------------------------------------------
  728. def update_craft
  729.    if Input.trigger?(Input::B)
  730.      $game_system.se_play($data_system.cancel_se)
  731.      $scene = Scene_Map.new
  732.      return
  733.    end
  734.    if Input.trigger?(Input::C) and $game_party.recipes.size != 0
  735.      @recipe = @craft_window.recipe
  736.      if @recipe.have
  737.        @yes_no_window.active = true
  738.        @craft_window.active = false
  739.      else
  740.        $game_system.se_play($data_system.buzzer_se)
  741.        return
  742.      end
  743.    end
  744. end

  745. #--------------------------------------------------------------------------
  746. def confirm_update
  747.    @craft_index = @craft_window.index
  748.    @confirm_window.visible = true
  749.    @confirm_window.z = 1500
  750.    @yes_no_window.visible = true
  751.    @yes_no_window.active = true
  752.    @yes_no_window.z = 1500
  753.    @yes_no_window.update
  754.    string = "合成 " + @recipe.name + "?"
  755.    cw = @confirm_window.contents.text_size(string).width
  756.    center = @confirm_window.contents.width/2 - cw /2
  757.    unless @drawn
  758.      @confirm_window.contents.draw_text(center, 0, cw, 30, string)
  759.      @drawn = true
  760.    end
  761.    if Input.trigger?(Input::C)
  762.      if @yes_no_window.index == 0
  763.        $game_system.se_play($data_system.decision_se)
  764.        @recipe.make
  765.        $game_system.se_play($data_system.save_se)
  766.        $scene=Scene_Craft.new(@craft_index)
  767.      else
  768.        $game_system.se_play($data_system.cancel_se)
  769.        $scene=Scene_Craft.new(@craft_index)
  770.      end
  771.    end
  772.    if Input.trigger?(Input::B)
  773.      $game_system.se_play($data_system.cancel_se)
  774.      $scene=Scene_Craft.new(@craft_index)
  775.    end
  776. end

  777. end # of Scene_Craft

  778. #==============================================================================
  779. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  780. #==============================================================================
复制代码

合成已经学习了

点评

NoMetHodError  发表于 2016-3-6 20:57
这样完全看不出什么错吧……弹了什么窗?  发表于 2016-3-6 20:48
QQ:2223942063
Q群:365819625
贪吃方1.4

梦石
0
星屑
9726
在线时间
2775 小时
注册时间
2008-9-5
回帖
3458

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

发表于 2016-3-6 22:09:38 | 显示全部楼层
在544和545之间插入一行
  1. return unless recipe
复制代码
回复

使用道具 举报

【欧皇】

梦石
3
星屑
2055
在线时间
1004 小时
注册时间
2013-8-19
回帖
3040

开拓者

 楼主| 发表于 2016-3-7 12:12:23 | 显示全部楼层
本帖最后由 欧买歌 于 2016-3-7 17:58 编辑
cinderelmini 发表于 2016-3-6 22:09
在544和545之间插入一行


QQ截图20160307121130.png
插入之后打开合成界面还是错误,貌似是判断有没有这个材料然后改变颜色的吧




QQ截图20160307175506.png
原754行出错,我想知道脚本作者真的有测试过吗……

点评

那再改成【return unless recipe.is_a?(Game_Recipe)】  发表于 2016-3-7 13:16
QQ:2223942063
Q群:365819625
贪吃方1.4
回复

使用道具 举报

梦石
0
星屑
9726
在线时间
2775 小时
注册时间
2008-9-5
回帖
3458

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

发表于 2016-3-7 19:26:31 | 显示全部楼层
…….应该是坛子转码的锅……
代码框529行
  1. @data.push($game_party.recipes)
复制代码
后面的取数组位置的i被坛子吃了……
改成这样:
  1. @data.push($game_party.recipes[i])
复制代码

点评

还有663行的【 for i in [email]0...@ingredients.size[/email]】得把email代码去掉。  发表于 2016-3-7 19:28
回复

使用道具 举报

【欧皇】

梦石
3
星屑
2055
在线时间
1004 小时
注册时间
2013-8-19
回帖
3040

开拓者

 楼主| 发表于 2016-3-8 12:48:41 | 显示全部楼层
本帖最后由 欧买歌 于 2016-3-11 19:33 编辑
cinderelmini 发表于 2016-3-7 19:26
…….应该是坛子转码的锅……
代码框529行后面的取数组位置的i被坛子吃了……
改成这样: ...


QQ截图20160308124717.png
这……
还是有错误……
self.contents.draw_text(x,y,100, 28,@strings)

警察叔叔就是这一行





self.contents.blt(0, y, RPG::Cache.icon(@item.icon_name), Rect.new(0, 0, 24, 24), 255)

我并不知道要在什么地方加……于是我会一直这样伸手下去直到问题解决

点评

背锅银23333,捶地23333  发表于 2016-3-11 23:46
你不是触吗= =  发表于 2016-3-11 23:03
这个锅去找原作者和乱改代码的坛子背→_→  发表于 2016-3-11 21:14
除了把这行之上的【[email]0...@strings.size[/email]】去掉email代码,还得【(x,y,100, 28,@strings[i])】[i]依然是被坛子转为斜体代码了……  发表于 2016-3-8 15:02
QQ:2223942063
Q群:365819625
贪吃方1.4
回复

使用道具 举报

梦石
0
星屑
1052
在线时间
1692 小时
注册时间
2009-7-25
回帖
512

开拓者

发表于 2016-3-11 23:42:23 | 显示全部楼层
本帖最后由 烁灵 于 2016-3-12 00:26 编辑

测试
  1. 测试[i]
复制代码


正经脸。

你使用的脚本如果是从站内直接复制得到的话,如你所见,@被解析为[email],同时,
  1. [i]
复制代码
被当做编辑器代码未匹配到
  1. [/i]
复制代码
而消失掉了,所以建议找原作者要一份或者再搜索一下其他地方有没有这份脚本。

点评

你想表达什么  发表于 2016-3-11 23:54
233333333333333333333333333333  发表于 2016-3-11 23:43

评分

参与人数 1星屑 +266 收起 理由
cinderelmini + 266 大师球!

查看全部评分

回复

使用道具 举报

【欧皇】

梦石
3
星屑
2055
在线时间
1004 小时
注册时间
2013-8-19
回帖
3040

开拓者

 楼主| 发表于 2016-3-16 13:26:58 | 显示全部楼层
cinderelmini 发表于 2016-3-7 19:26
…….应该是坛子转码的锅……
代码框529行后面的取数组位置的i被坛子吃了……
改成这样: ...


找到了原脚本 能用了
点击展开/收起
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. # 欢迎访问[url]www.66RPG.com[/url]
  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号物品合成设定    速度粉末*10+玻璃瓶*1=暂时加速剂              
  104.    ##########################################################################
  105.    材料 = [49,50]        # 需要材料的数据库编号
  106.    材料种类 = [0,0]      # 需要材料的种类,0是普通物品,1是防具,2是武器
  107.    材料数量 = [10,1]     # 需要材料的数量
  108.    成品 = 34             # 获得物品编号
  109.    成品种类 = 0          # 获得物品种类,0是普通物品,1是防具,2是武器
  110.    @recipe_list[1] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  111.    
  112.    ##########################################################################
  113.    ####2号物品合成设定    复活水晶*1+速度粉末*8+玻璃瓶*1=精神药水                     
  114.    ##########################################################################
  115.    材料 = [35,49,50]     # 需要材料的数据库编号
  116.    材料种类 = [0,0,0]    # 需要材料的种类,0是普通物品,1是防具,2是武器
  117.    材料数量 = [1,8,1]    # 需要材料的数量
  118.    成品 = 51             # 获得物品编号
  119.    成品种类 = 0          # 获得物品种类,0是普通物品,1是防具,2是武器
  120.    @recipe_list[2] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  121.    ##########################################################################
  122.    ####3号物品合成设定    石头*30=石盾                       
  123.    ##########################################################################
  124.    材料 = [48]           # 需要材料的数据库编号
  125.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  126.    材料数量 = [30]       # 需要材料的数量
  127.    成品 = 79             # 获得物品编号
  128.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  129.    @recipe_list[3] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  130.    ##########################################################################
  131.    ##########################################################################
  132.    ####4号物品合成设定    铝锭*20=铝质头饰                       
  133.    ##########################################################################
  134.    材料 = [47]           # 需要材料的数据库编号
  135.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  136.    材料数量 = [20]       # 需要材料的数量
  137.    成品 = 35             # 获得物品编号
  138.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  139.    @recipe_list[4] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  140.    ##########################################################################
  141.    ##########################################################################
  142.    ####5号物品合成设定    铝锭*25=铝质胸甲                       
  143.    ##########################################################################
  144.    材料 = [47]           # 需要材料的数据库编号
  145.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  146.    材料数量 = [25]       # 需要材料的数量
  147.    成品 = 50             # 获得物品编号
  148.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  149.    @recipe_list[5] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  150.    ##########################################################################
  151.    ##########################################################################
  152.    ####6号物品合成设定    铝锭*15=铝质鞋子                       
  153.    ##########################################################################
  154.    材料 = [47]           # 需要材料的数据库编号
  155.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  156.    材料数量 = [15]       # 需要材料的数量
  157.    成品 = 65             # 获得物品编号
  158.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  159.    @recipe_list[6] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  160.    ##########################################################################
  161.    ##########################################################################
  162.    ####7号物品合成设定    铝锭*20=铝质小盾                       
  163.    ##########################################################################
  164.    材料 = [47]           # 需要材料的数据库编号
  165.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  166.    材料数量 = [20]       # 需要材料的数量
  167.    成品 = 80             # 获得物品编号
  168.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  169.    @recipe_list[7] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  170.    ##########################################################################
  171.    ##########################################################################
  172.    ####8号物品合成设定    铁锭*22=铁质面具                       
  173.    ##########################################################################
  174.    材料 = [46]           # 需要材料的数据库编号
  175.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  176.    材料数量 = [22]       # 需要材料的数量
  177.    成品 = 36             # 获得物品编号
  178.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  179.    @recipe_list[8] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  180.    ##########################################################################
  181.    ##########################################################################
  182.    ####9号物品合成设定    铁锭*28=铁质胸甲                       
  183.    ##########################################################################
  184.    材料 = [46]           # 需要材料的数据库编号
  185.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  186.    材料数量 = [28]       # 需要材料的数量
  187.    成品 = 51             # 获得物品编号
  188.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  189.    @recipe_list[9] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  190.    ##########################################################################
  191.    ##########################################################################
  192.    ####10号物品合成设定   铁锭*16=铁质鞋子                       
  193.    ##########################################################################
  194.    材料 = [46]           # 需要材料的数据库编号
  195.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  196.    材料数量 = [16]       # 需要材料的数量
  197.    成品 = 66             # 获得物品编号
  198.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  199.    @recipe_list[10] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  200.    ##########################################################################
  201.    ##########################################################################
  202.    ####11号物品合成设定   铁锭*23=铁质小盾                       
  203.    ##########################################################################
  204.    材料 = [46]           # 需要材料的数据库编号
  205.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  206.    材料数量 = [23]       # 需要材料的数量
  207.    成品 = 81             # 获得物品编号
  208.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  209.    @recipe_list[11] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  210.    ##########################################################################
  211.    ##########################################################################
  212.    ####12号物品合成设定    铜锭*24=铜质头盔                       
  213.    ##########################################################################
  214.    材料 = [45]           # 需要材料的数据库编号
  215.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  216.    材料数量 = [24]       # 需要材料的数量
  217.    成品 = 37             # 获得物品编号
  218.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  219.    @recipe_list[12] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  220.    ##########################################################################
  221.    ##########################################################################
  222.    ####13号物品合成设定    铜锭*31=黄铜护甲                     
  223.    ##########################################################################
  224.    材料 = [45]           # 需要材料的数据库编号
  225.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  226.    材料数量 = [31]       # 需要材料的数量
  227.    成品 = 52             # 获得物品编号
  228.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  229.    @recipe_list[13] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  230.    ##########################################################################
  231.    ##########################################################################
  232.    ####14号物品合成设定   铜锭*17=黄铜跑鞋                       
  233.    ##########################################################################
  234.    材料 = [45]           # 需要材料的数据库编号
  235.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  236.    材料数量 = [17]       # 需要材料的数量
  237.    成品 = 67             # 获得物品编号
  238.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  239.    @recipe_list[14] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  240.    ##########################################################################
  241.    ##########################################################################
  242.    ####15号物品合成设定   铜锭*26=黄铜盾牌                       
  243.    ##########################################################################
  244.    材料 = [45]           # 需要材料的数据库编号
  245.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  246.    材料数量 = [26]       # 需要材料的数量
  247.    成品 = 82             # 获得物品编号
  248.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  249.    @recipe_list[15] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  250.    ##########################################################################
  251.    ##########################################################################
  252.    ####16号物品合成设定    银锭*26=白银头盔                       
  253.    ##########################################################################
  254.    材料 = [62]           # 需要材料的数据库编号
  255.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  256.    材料数量 = [26]       # 需要材料的数量
  257.    成品 = 38             # 获得物品编号
  258.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  259.    @recipe_list[16] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  260.    ##########################################################################
  261.    ##########################################################################
  262.    ####17号物品合成设定    银锭*34=白银护甲                     
  263.    ##########################################################################
  264.    材料 = [62]           # 需要材料的数据库编号
  265.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  266.    材料数量 = [34]       # 需要材料的数量
  267.    成品 = 53             # 获得物品编号
  268.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  269.    @recipe_list[17] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  270.    ##########################################################################
  271.    ##########################################################################
  272.    ####18号物品合成设定   银锭*18=白银跑鞋                       
  273.    ##########################################################################
  274.    材料 = [62]           # 需要材料的数据库编号
  275.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  276.    材料数量 = [18]       # 需要材料的数量
  277.    成品 = 68             # 获得物品编号
  278.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  279.    @recipe_list[18] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  280.    ##########################################################################
  281.    ##########################################################################
  282.    ####19号物品合成设定   银锭*29=白银盾牌                       
  283.    ##########################################################################
  284.    材料 = [62]           # 需要材料的数据库编号
  285.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  286.    材料数量 = [29]       # 需要材料的数量
  287.    成品 = 83             # 获得物品编号
  288.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  289.    @recipe_list[19] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  290.    ##########################################################################
  291.    ##########################################################################
  292.    ####20号物品合成设定    金锭*28=黄金战盔                       
  293.    ##########################################################################
  294.    材料 = [44]           # 需要材料的数据库编号
  295.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  296.    材料数量 = [28]       # 需要材料的数量
  297.    成品 = 39             # 获得物品编号
  298.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  299.    @recipe_list[20] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  300.    ##########################################################################
  301.    ##########################################################################
  302.    ####21号物品合成设定    金锭*37=黄金铠甲                     
  303.    ##########################################################################
  304.    材料 = [44]           # 需要材料的数据库编号
  305.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  306.    材料数量 = [37]       # 需要材料的数量
  307.    成品 = 54             # 获得物品编号
  308.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  309.    @recipe_list[21] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  310.    ##########################################################################
  311.    ##########################################################################
  312.    ####22号物品合成设定    金锭*19=黄金飞靴                       
  313.    ##########################################################################
  314.    材料 = [44]           # 需要材料的数据库编号
  315.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  316.    材料数量 = [19]       # 需要材料的数量
  317.    成品 = 69             # 获得物品编号
  318.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  319.    @recipe_list[22] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  320.    ##########################################################################
  321.    ##########################################################################
  322.    ####23号物品合成设定    金锭*32=黄金盾牌                       
  323.    ##########################################################################
  324.    材料 = [44]           # 需要材料的数据库编号
  325.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  326.    材料数量 = [32]       # 需要材料的数量
  327.    成品 = 84             # 获得物品编号
  328.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  329.    @recipe_list[23] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  330.    ##########################################################################
  331.    ##########################################################################
  332.    ####24号物品合成设定    钻石*30=金刚战盔                       
  333.    ##########################################################################
  334.    材料 = [43]           # 需要材料的数据库编号
  335.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  336.    材料数量 = [30]       # 需要材料的数量
  337.    成品 = 40             # 获得物品编号
  338.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  339.    @recipe_list[24] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  340.    ##########################################################################
  341.    ##########################################################################
  342.    ####25号物品合成设定    钻石*40=金刚铠甲                     
  343.    ##########################################################################
  344.    材料 = [43]           # 需要材料的数据库编号
  345.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  346.    材料数量 = [40]       # 需要材料的数量
  347.    成品 = 55             # 获得物品编号
  348.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  349.    @recipe_list[25] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  350.    ##########################################################################
  351.    ##########################################################################
  352.    ####26号物品合成设定    钻石*20=金刚飞靴                       
  353.    ##########################################################################
  354.    材料 = [43]           # 需要材料的数据库编号
  355.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  356.    材料数量 = [20]       # 需要材料的数量
  357.    成品 = 70             # 获得物品编号
  358.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  359.    @recipe_list[26] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  360.    ##########################################################################
  361.    ##########################################################################
  362.    ####27号物品合成设定    钻石*35=金刚盾牌                       
  363.    ##########################################################################
  364.    材料 = [43]           # 需要材料的数据库编号
  365.    材料种类 = [0]        # 需要材料的种类,0是普通物品,1是防具,2是武器
  366.    材料数量 = [35]       # 需要材料的数量
  367.    成品 = 85             # 获得物品编号
  368.    成品种类 = 1          # 获得物品种类,0是普通物品,1是防具,2是武器
  369.    @recipe_list[27] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  370.    ##########################################################################
  371.    end # of get_recipe_list method
  372. end # of updates to Game_Temp Class

  373. #================================
  374. # CRAFTING PROGRAM
  375. #----------------------------------------------------------------
  376. #-written by Deke
  377. #-yes_no window code created by Phsylomortis
  378. #----------------------------------------------------------------
  379. #================================

  380. #updates to Game_Party class

  381. class Game_Party
  382.   
  383.   attr_accessor       :recipes
  384.   
  385.   alias crafting_party_initialize initialize
  386.   
  387.   def initialize
  388.     crafting_party_initialize
  389.     @recipes=[]
  390.   end
  391.   
  392.   #----------------------------------------------------------------------
  393.   def know?(recipe, version = 1)
  394.     unless recipe.is_a?(Game_Recipe)
  395.       recipe = get_recipe_from_master_list(recipe, version)
  396.     end
  397.     return $game_party.recipes.include?(recipe)
  398.   end
  399.   
  400. #----------------------------------------------------------------------
  401.   def learn_recipe(recipe , version = 1)
  402.     unless recipe.is_a?(Game_Recipe)
  403.       recipe = get_recipe_from_master_list(recipe, version)
  404.     end
  405.     if recipe.is_a?(Game_Recipe)
  406.       unless know?(recipe)
  407.         @recipes.push(recipe)
  408.       end
  409.     end
  410.   end
  411.   
  412. #----------------------------------------------------------------------
  413.   def forget_recipe(recipe , version = 1)
  414.     if !recipe.is_a?(Game_Recipe)
  415.       recipe = get_recipe_from_master_list(recipe, version)
  416.     end
  417.     if recipe.is_a?(Game_Recipe)
  418.       for i in [email]0...@recipes.size[/email]
  419.         if recipe == @recipes[i]
  420.           index = i
  421.           break
  422.         end
  423.       end
  424.       if index != nil
  425.         @recipes.delete(@recipes[index])
  426.       end
  427.     end
  428.   end
  429.   
  430. #----------------------------------------------------------------------
  431.   def get_recipe_from_master_list(item, version)
  432.     index = nil
  433.     for i in 0...$game_temp.recipe_list.size
  434.       if item[0] == $game_temp.recipe_list[i].result and item[1] ==$game_temp.recipe_list[i].result_type
  435.         version -= 1
  436.         if version == 0
  437.           index = i
  438.           break
  439.         end
  440.       end
  441.     end
  442.     if index.is_a?(Integer)
  443.       return ($game_temp.recipe_list[index])
  444.     else
  445.       return false
  446.     end
  447.   end
  448.   
  449. end # of Game_Party updates

  450. #================================
  451. class Game_Recipe

  452.   attr_reader :ingredients
  453.   attr_reader :quantities
  454.   attr_reader :result
  455.   attr_reader :result_type
  456.   attr_reader :ingredient_types
  457.   attr_reader :craft_type  #物品分类
  458.   
  459. #----------------------------------------------------------------------
  460.   def initialize( ingredients, ingredient_types, quantities, result, result_type, craft_type=0)
  461.     @ingredients = ingredients
  462.     @ingredient_types = ingredient_types
  463.     @quantities = quantities
  464.     @result = result
  465.     @result_type = result_type
  466.     @craft_type = craft_type
  467.   end
  468.   
  469. #----------------------------------------------------------------------
  470.   def name
  471.     case @result_type
  472.       when 0
  473.         name = $data_items[@result].name
  474.       when 1
  475.         name = $data_armors[@result].name
  476.       when 2
  477.         name = $data_weapons[@result].name
  478.     end
  479.     return name
  480.   end
  481.   
  482. #----------------------------------------------------------------------

  483.   def item
  484.     case @result_type
  485.       when 0
  486.         item = $data_items[@result]
  487.       when 1
  488.         item = $data_armors[@result]
  489.       when 2
  490.         item = $data_weapons[@result]
  491.     end
  492.     return item
  493.   end

  494. #----------------------------------------------------------------------
  495.   def have
  496.     have_all = true
  497.     for i in [email]0...@ingredients.size[/email]
  498.       case @ingredient_types[i]
  499.         when 0
  500.           if $game_party.item_number(@ingredients[i]) < @quantities[i]
  501.             have_all=false
  502.           end
  503.         when 1
  504.           if $game_party.armor_number(@ingredients[i]) < @quantities[i]
  505.             have_all=false
  506.           end
  507.         when 2
  508.           if $game_party.weapon_number(@ingredients[i]) < @quantities[i]
  509.             have_all=false
  510.           end
  511.       end
  512.     end
  513.     return have_all
  514.   end

  515. #----------------------------------------------------------------------
  516.   def decrement
  517.     for i in [email]0...@ingredients.size[/email]
  518.       case @ingredient_types[i]
  519.       when 0
  520.         $game_party.lose_item(@ingredients[i], @quantities[i])
  521.       when 1
  522.         $game_party.lose_armor(@ingredients[i], @quantities[i])
  523.       when 2
  524.         $game_party.lose_weapon(@ingredients[i], @quantities[i])
  525.       end
  526.     end
  527.   end

  528. #----------------------------------------------------------------------
  529.   def make
  530.     if have
  531.       case @result_type
  532.       when 0
  533.         $game_party.gain_item(@result, 1)
  534.       when 1
  535.         $game_party.gain_armor(@result, 1)
  536.       when 2
  537.         $game_party.gain_weapon(@result, 1)
  538.       end
  539.       decrement
  540.     end
  541.   end
  542.   
  543. #----------------------------------------------------------------------
  544.   def == (recipe)
  545.     if recipe.is_a?(Game_Recipe)
  546.       equal = true
  547.       if recipe.ingredients != self.ingredients
  548.         equal = false
  549.       end
  550.       if recipe.ingredient_types != self.ingredient_types
  551.         equal = false
  552.       end
  553.       if recipe.quantities != self.quantities
  554.         equal = false
  555.       end
  556.       if recipe.result != self.result
  557.         equal=false
  558.       end
  559.       if recipe.result_type != self.result_type
  560.         equal = false
  561.       end
  562.     else
  563.       equal = false
  564.     end
  565.     return equal
  566.   end
  567.   
  568. end # of Game_Recipe class

  569. #===================================

  570. class Window_Craft < Window_Selectable
  571.   attr_reader :data #声明数据
  572.   #--------------------------------------------------------------------------
  573.   def initialize(craft_type=0)
  574.     @craft_type = craft_type
  575.     super(0, 64, 240, 416)
  576.     @column_max = 1
  577.     refresh
  578.     self.index = 0
  579.   end

  580.   #--------------------------------------------------------------------------
  581.   def recipe
  582.     return @data[self.index]
  583.   end

  584.   #--------------------------------------------------------------------------
  585.   def refresh
  586.     if self.contents != nil
  587.       self.contents.dispose
  588.       self.contents = nil
  589.     end
  590.     @data = []
  591.     for i in 0...$game_party.recipes.size
  592.        #@craft_type为0时就显示全部物品
  593.        #不为0时就显示对应物品
  594.       if @craft_type == 0
  595.         @data.push($game_party.recipes[i])
  596.       elsif $game_party.recipes[i].craft_type == @craft_type
  597.         @data.push($game_party.recipes[i])
  598.       end
  599.     end
  600.     @item_max = @data.size
  601.     if @item_max > 0
  602.       self.contents = Bitmap.new(width - 32, row_max * 32)
  603.       self.contents.font.name = "黑体" # = "黑体"
  604.       self.contents.font.size = 18 # = 18
  605.       for i in 0...@item_max
  606.         x = 16
  607.         y = i * 32
  608.         able = true
  609.         for ingredient in 0...@data[i].ingredients.size
  610.           case @data[i].ingredient_types[ingredient]
  611.           when 0
  612.             count = $game_party.item_number(@data[i].ingredients[ingredient])
  613.           when 1
  614.             count = $game_party.armor_number(@data[i].ingredients[ingredient])
  615.           when 2
  616.             count = $game_party.weapon_number(@data[i].ingredients[ingredient])
  617.           end
  618.           if count < @data[i].quantities[ingredient]
  619.             able = false
  620.             break
  621.           end
  622.         end
  623.         draw_item_name(@data[i].item, x, y, able)
  624.       end
  625.     end
  626.   end

  627.   #--------------------------------------------------------------------------
  628.   #def draw_item(index)
  629.   #  recipe = @data[index]
  630.   #  self.contents.font.color = recipe.have ? normal_color : disabled_color
  631.   #  x = 16
  632.   #  y = index * 32
  633.   #  self.contents.draw_text(x , y, self.width-32, 32, recipe.name, 0)
  634.   #end
  635.   
  636.   #--------------------------------------------------------------------------
  637.   # ● 描绘物品名
  638.   #     item : 物品
  639.   #     x    : 描画目标 X 坐标
  640.   #     y    : 描画目标 Y 坐标
  641.   #--------------------------------------------------------------------------
  642.   def draw_item_name(item, x, y, able = true)
  643.     if item == nil
  644.       return
  645.     end
  646.     if !able
  647.       self.contents.font.color = disabled_color
  648.     end
  649.     bitmap = RPG::Cache.icon(item.icon_name)
  650.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  651.     self.contents.draw_text(x + 28, y, 212, 32, item.name)
  652.     self.contents.font.color = normal_color
  653.   end
  654.   
  655.   #--------------------------------------------------------------------------
  656.   def update_help
  657.     current_recipe = recipe
  658.     if current_recipe.is_a?(Game_Recipe)
  659.     case current_recipe.result_type
  660.       when 0
  661.         description = $data_items[current_recipe.result].description
  662.       when 1
  663.         description = $data_armors[current_recipe.result].description
  664.       when 2
  665.         description = $data_weapons[current_recipe.result].description
  666.       end
  667.     else
  668.       description = ""
  669.     end
  670.     @help_window.set_text(description)
  671.     @help_window.update
  672.   end
  673.   
  674. end # of Window_Craft

  675. #=======================================
  676. class Window_CraftResult < Window_Base

  677.   #--------------------------------------------------------------------------
  678.   def initialize
  679.     super(240, 64, 400, 184)
  680.     self.contents = Bitmap.new(width - 32, height - 32)
  681.     self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  682.     self.contents.font.size = 18 # = 20
  683.     @result = nil
  684.     @type = nil
  685.   end

  686.   #--------------------------------------------------------------------------
  687.   def refresh
  688.     self.contents.clear
  689.     case @type
  690.       when 0
  691.         item = $data_items[@result]
  692.         if item.recover_hp_rate > item.recover_hp
  693.           hp_string = "HP回复率:"
  694.           hp_stat = item.recover_hp_rate
  695.         else
  696.           hp_string = "HP回复量:"
  697.           hp_stat = item.recover_hp
  698.         end
  699.         if item.recover_sp_rate > item.recover_sp
  700.           sp_string = "SP回复率:"
  701.           sp_stat = item.recover_sp_rate
  702.         else
  703.           sp_string = "SP回复量:"
  704.           sp_stat = item.recover_sp
  705.         end
  706.         @strings = [hp_string, sp_string, "物理防御:" , "魔法防御:", "命中率:", "分散度:"]
  707.         @stats = [hp_stat, sp_stat, item. pdef_f, item.mdef_f, item.hit, item.variance,
  708.                        $game_party.item_number(@result)]
  709.         @bitmap = RPG::Cache.icon(item.icon_name)
  710.       when 1
  711.         item = $data_armors[@result]
  712.         @strings = ["物理防御:", "魔法防御:", "回避修正:", "力量增加:", "灵巧增加:",
  713.                        "速度增加:", "魔力增加:"]
  714.         @stats = [item.pdef, item.mdef, item.eva, item.str_plus, item.dex_plus,
  715.                     item.agi_plus, item.int_plus, $game_party.armor_number(@result) ]
  716.         @bitmap = RPG::Cache.icon(item.icon_name)
  717.       when 2
  718.         item = $data_weapons[@result]
  719.         @strings =["攻击力:", "物理防御:", "魔法防御:", "力量增加:", "灵巧增加:",
  720.                     "速度增加:", "魔力增加:"]
  721.         @stats = [item.atk, item.pdef, item.mdef, item.str_plus, item.dex_plus,
  722.                     item.agi_plus, item.int_plus, $game_party.weapon_number(@result) ]
  723.         @bitmap = RPG::Cache.icon(item.icon_name)
  724.     end
  725.     for i in [email]0...@strings.size[/email]
  726.       x = i%2 * 184
  727.       y = i /2 *28 +32
  728.       self.contents.font.color = normal_color
  729.       self.contents.draw_text(x,y,100, 28,@strings[i])
  730.       self.contents.font.color = system_color
  731.       self.contents.draw_text(x + 110, y, 45, 28, @stats[i].to_s)
  732.     end
  733.     self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, 24, 24), 255)
  734.     self.contents.font.color= normal_color
  735.     self.contents.draw_text(40, 0, 300, 28, "待合成物品的现有数量:")
  736.     self.contents.font.color = system_color
  737.     count = @stats[@stats.size - 1].to_s
  738.     self.contents.draw_text(294, 0, 45, 28, count )
  739.   end
  740.    
  741. #----------------------------------------------------------------------
  742.   def set_result(result , type)
  743.     @result = result
  744.     @type = type
  745.     refresh
  746.   end

  747. end #of Window_CraftResult

  748. #=======================================
  749. class Window_CraftIngredients < Window_Base

  750.   #--------------------------------------------------------------------------
  751.   def initialize
  752.     super(240, 248, 400, 232)
  753.     self.contents = Bitmap.new(width - 32, height - 32)
  754.     self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  755.     self.contents.font.size = 18 # = 20
  756.     @ingredients = []
  757.     @types = []
  758.     @quantities = []
  759.     @item = nil
  760.     @count = 0
  761.     @counter = 0
  762.     @real_oy = 0
  763.   end

  764.   #--------------------------------------------------------------------------
  765.   def refresh
  766.     @counter = 0
  767.     self.contents.clear
  768.     self.contents = Bitmap.new(width - 32, @ingredients.size * 26)
  769.     for i in [email]0...@ingredients.size[/email]
  770.       case @types[i]
  771.       when 0
  772.         @item = $data_items[@ingredients[i]]
  773.         @count = $game_party.item_number(@ingredients[i])
  774.       when 1
  775.         @item = $data_armors[@ingredients[i]]
  776.         @count = $game_party.armor_number(@ingredients[i])
  777.       when 2
  778.         @item = $data_weapons[@ingredients[i]]
  779.         @count = $game_party.weapon_number(@ingredients[i])
  780.       end
  781.       y = i *26
  782.       self.contents.blt(0, y, RPG::Cache.icon(@item.icon_name), Rect.new(0, 0, 24, 24), 255)
  783.       self.contents.font.color = @count >= @quantities[i] ? normal_color : disabled_color
  784.       self.contents.draw_text(30, y, 280, 28, @item.name)
  785.       self.contents.draw_text(300, y, 45, 28, @quantities[i].to_s)
  786.       self.contents.font.color = system_color
  787.       self.contents.draw_text(245, y, 45, 28, @count.to_s )     
  788.     end
  789.   end
  790.       
  791.   #--------------------------------------------------------------------------
  792.   def set_ingredients(ingredients , types, quantities)
  793.     @ingredients = ingredients
  794.     @types = types
  795.     @quantities = quantities
  796.     refresh
  797.     if @ingredients.size > 7
  798.       self.oy = -52
  799.       @real_oy = 0
  800.     else
  801.       self.oy = 0
  802.     end
  803.   end

  804.   def update
  805.     super
  806.     @counter += 1
  807.     if @ingredients.size > 7 and @counter > 30
  808.       @real_oy = (@real_oy + 1) % ((@ingredients.size - 3) * 26)
  809.       self.oy = @real_oy - 52
  810.     end
  811.   end
  812.    
  813. end # of Window_CraftIngredients

  814. #======================================
  815. class Scene_Craft

  816.   #--------------------------------------------------------------------------
  817.   # @craft_type:物品种类,0就是全部
  818.   def initialize(craft_type=0,craft_index=0)
  819.     @craft_index=craft_index
  820.     @craft_type = craft_type
  821.   end
  822.   
  823.   #--------------------------------------------------------------------------
  824.   def main
  825.     @craft_window = Window_Craft.new(@craft_type)
  826.     @craft_window.index=@craft_index
  827.     @confirm_window = Window_Base.new(120, 188, 400, 64)
  828.     @confirm_window.contents = Bitmap.new(368, 32)
  829.     @confirm_window.contents.font.name = "黑体"
  830.     @confirm_window.contents.font.size = 20
  831.     @help_window = Window_Help.new
  832.     @craft_window.help_window = @help_window
  833.     @result_window=Window_CraftResult.new
  834.     @ingredients_window=Window_CraftIngredients.new
  835.     if @craft_window.data.size > 0 #本类窗口物品大于0的话
  836.       @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
  837.       @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
  838.                                                           @craft_window.recipe.ingredient_types,
  839.                                                           @craft_window.recipe.quantities)
  840.     end
  841.     @yes_no_window = Window_Command.new(100, ["确定", "放弃"])
  842.     @confirm_window.visible = false
  843.     @confirm_window.z = 1500
  844.     @yes_no_window.visible = false
  845.     @yes_no_window.active = false
  846.     @yes_no_window.index = 1
  847.     @yes_no_window.x = 270
  848.     @yes_no_window.y = 252
  849.     @yes_no_window.z = 1500
  850.     @label_window = Window_Base.new(450,200,190,52)
  851.     @label_window.contents=Bitmap.new(@label_window.width - 32,@label_window.height - 32)
  852.     @label_window.contents.font.size=20
  853.     @label_window.contents.font.color = @label_window.normal_color
  854.     @label_window.contents.font.name = "黑体"
  855.     @label_window.contents.draw_text(0, 0, @label_window.contents.width, 20, "  现有   需要")
  856.     Graphics.transition
  857.     loop do
  858.       Graphics.update
  859.       Input.update
  860.       update
  861.       if $scene != self
  862.         break
  863.       end
  864.     end
  865.     Graphics.freeze
  866.     @help_window.dispose
  867.     @craft_window.dispose
  868.     @result_window.dispose
  869.     @ingredients_window.dispose
  870.     @confirm_window.dispose
  871.     @yes_no_window.dispose
  872.     @label_window.dispose
  873.   end

  874.   #--------------------------------------------------------------------------
  875.   def update
  876.     @craft_window.update
  877.     @ingredients_window.update
  878.     if @craft_window.active
  879.       update_craft
  880.       return
  881.     end
  882.     if @yes_no_window.active
  883.       confirm_update
  884.       return
  885.     end
  886.   end

  887.   #--------------------------------------------------------------------------
  888.   def update_craft
  889.     if Input.dir4 != 0
  890.       if @craft_window.data.size > 0 #本类窗口物品大于0的话
  891.         @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
  892.         @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
  893.                                                            @craft_window.recipe.ingredient_types,
  894.                                                            @craft_window.recipe.quantities)
  895.       end
  896.     end
  897.     if Input.trigger?(Input::B)
  898.       $game_system.se_play($data_system.cancel_se)
  899.       $scene = Scene_Map.new
  900.       return
  901.     end
  902.     if Input.trigger?(Input::C) and $game_party.recipes.size != 0
  903.       @recipe = @craft_window.recipe
  904.       if @recipe != nil
  905.         if @recipe.have
  906.           @yes_no_window.active = true
  907.           @craft_window.active = false
  908.         else
  909.           $game_system.se_play($data_system.buzzer_se)
  910.           return
  911.         end
  912.       else
  913.         $game_system.se_play($data_system.buzzer_se)
  914.         return
  915.       end
  916.     end
  917.   end

  918.   #--------------------------------------------------------------------------
  919.   def confirm_update
  920.     @craft_index = @craft_window.index
  921.     @confirm_window.visible = true
  922.     @confirm_window.z = 1500
  923.     @yes_no_window.visible = true
  924.     @yes_no_window.active = true
  925.     @yes_no_window.z = 1500
  926.     @yes_no_window.update
  927.     string = "合成 " + @recipe.name + "?"
  928.     cw = @confirm_window.contents.text_size(string).width
  929.     center = @confirm_window.contents.width/2 - cw /2
  930.     unless @drawn
  931.       @confirm_window.contents.draw_text(center, 0, cw, 30, string)
  932.       @drawn = true
  933.     end
  934.     if Input.trigger?(Input::C)
  935.       if @yes_no_window.index == 0
  936.         $game_system.se_play($data_system.decision_se)
  937.         @recipe.make
  938.         $game_system.se_play($data_system.save_se)
  939.         $scene=Scene_Craft.new(@craft_type,@craft_index)
  940.       else
  941.         $game_system.se_play($data_system.cancel_se)
  942.         $scene=Scene_Craft.new(@craft_type,@craft_index)
  943.       end
  944.     end
  945.     if Input.trigger?(Input::B)
  946.       $game_system.se_play($data_system.cancel_se)
  947.       $scene=Scene_Craft.new(@craft_type,@craft_index)
  948.     end
  949.   end

  950. end # of Scene_Craft

  951. #==============================================================================
  952. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  953. # 欢迎访问[url]www.66RPG.com[/url]
  954. # 梦想世界,在你手中
  955. #==============================================================================
复制代码

为什么物品合成脚本545行出错 - RPG Maker XP 提问区 - 66RPG - Powered by Discuz!.p.png 首页.png
懒癌中期由于现在的我看不懂脚本了所以想再伸一下手把划红线的去掉
QQ:2223942063
Q群:365819625
贪吃方1.4
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部