设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1166|回复: 2
打印 上一主题 下一主题

[已经解决] 合成脚本出错

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
125 小时
注册时间
2011-7-19
帖子
51
跳转到指定楼层
1
发表于 2011-8-3 22:51:41 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 lizy 于 2011-8-4 11:41 编辑

我下了个主站的合成脚本,设置在菜单选择项里,为什么在菜单里一点 就出这东西啊!!


lizy于2011-8-4 10:04补充以下内容:
  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.     # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
  104.     ##########################################################################
  105.     材料 = [1, 132]             # 需要材料的数据库编号
  106.     材料种类 = [2, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  107.     材料数量 = [1, 1]         # 需要材料的数量
  108.     成品 = 7                  # 获得物品编号
  109.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  110.     成品分类 = 1              # 获得成品分类
  111.     @recipe_list[1] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)

  112.    
  113.     ###########################################################################
  114.     # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
  115.     ##########################################################################
  116.     材料 = [3, 133]             # 需要材料的数据库编号
  117.     材料种类 = [2, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  118.     材料数量 = [1, 1]         # 需要材料的数量
  119.     成品 = 8                  # 获得物品编号
  120.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  121.     成品分类 = 1              # 获得成品分类
  122.     @recipe_list[2] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)

  123.    
  124.     ###########################################################################
  125.     # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
  126.     ##########################################################################
  127.     材料 = [4, 134]             # 需要材料的数据库编号
  128.     材料种类 = [2, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  129.     材料数量 = [1, 1]         # 需要材料的数量
  130.     成品 = 9                  # 获得物品编号
  131.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  132.     成品分类 = 1              # 获得成品分类
  133.     @recipe_list[3] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)

  134.    
  135.     ###########################################################################
  136.     # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
  137.     ##########################################################################
  138.     材料 = [6, 135]             # 需要材料的数据库编号
  139.     材料种类 = [2, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  140.     材料数量 = [1, 1]         # 需要材料的数量
  141.     成品 = 10                  # 获得物品编号
  142.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  143.     成品分类 = 1              # 获得成品分类
  144.     @recipe_list[4] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)

  145.    
  146.    
  147.     ###########################################################################
  148.     # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
  149.     ##########################################################################
  150.     材料 = [5, 135]             # 需要材料的数据库编号
  151.     材料种类 = [2, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  152.     材料数量 = [1, 1]         # 需要材料的数量
  153.     成品 = 11                  # 获得物品编号
  154.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  155.     成品分类 = 1              # 获得成品分类
  156.     @recipe_list[5] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)

  157.   
  158.     ###########################################################################
  159.     # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
  160.     ##########################################################################
  161.     材料 = [12, 136]             # 需要材料的数据库编号
  162.     材料种类 = [2, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  163.     材料数量 = [1, 1]         # 需要材料的数量
  164.     成品 = 25                  # 获得物品编号
  165.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  166.     成品分类 = 1              # 获得成品分类
  167.     @recipe_list[6] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)


  168.    
  169.     ############################################################################
  170.     # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
  171.     ##########################################################################
  172.     材料 = [18, 172]             # 需要材料的数据库编号
  173.     材料种类 = [2, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  174.     材料数量 = [1, 1]         # 需要材料的数量
  175.     成品 = 23                  # 获得物品编号
  176.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  177.     成品分类 = 1              # 获得成品分类
  178.     @recipe_list[7] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)

  179.    
  180.     ############################################################################
  181.     # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
  182.     ##########################################################################
  183.     材料 = [21, 172]             # 需要材料的数据库编号
  184.     材料种类 = [2, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  185.     材料数量 = [1, 1]         # 需要材料的数量
  186.     成品 = 24                  # 获得物品编号
  187.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  188.     成品分类 = 1              # 获得成品分类
  189.     @recipe_list[8] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)

  190.    
  191.     ############################################################################
  192.     # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
  193.     ##########################################################################
  194.     材料 = [17, 136]             # 需要材料的数据库编号
  195.     材料种类 = [2, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  196.     材料数量 = [1, 1]         # 需要材料的数量
  197.     成品 = 22                  # 获得物品编号
  198.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  199.     成品分类 = 1              # 获得成品分类
  200.     @recipe_list[9] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)

  201.    
  202.     ############################################################################
  203.     # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
  204.     ##########################################################################
  205.     材料 = [156, 175]             # 需要材料的数据库编号
  206.     材料种类 = [0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  207.     材料数量 = [1, 1]         # 需要材料的数量
  208.     成品 = 162                  # 获得物品编号
  209.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  210.     成品分类 = 2              # 获得成品分类
  211.     @recipe_list[10] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)
  212.    
  213.     #############################################################################
  214.     # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
  215.     ##########################################################################
  216.     材料 = [156, 176]             # 需要材料的数据库编号
  217.     材料种类 = [0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  218.     材料数量 = [1, 1]         # 需要材料的数量
  219.     成品 = 163                  # 获得物品编号
  220.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  221.     成品分类 = 2              # 获得成品分类
  222.     @recipe_list[11] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)
  223.    
  224.    
  225.     #############################################################################
  226.     # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
  227.     ##########################################################################
  228.     材料 = [156,177]             # 需要材料的数据库编号
  229.     材料种类 = [0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  230.     材料数量 = [1, 1]         # 需要材料的数量
  231.     成品 = 71                  # 获得物品编号
  232.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  233.     成品分类 = 2              # 获得成品分类
  234.     @recipe_list[12] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)
  235.    
  236.    
  237.     #############################################################################
  238.     # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
  239.     ##########################################################################
  240.     材料 = [156, 178]             # 需要材料的数据库编号
  241.     材料种类 = [0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  242.     材料数量 = [1, 1]         # 需要材料的数量
  243.     成品 = 161                  # 获得物品编号
  244.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  245.     成品分类 = 2              # 获得成品分类
  246.     @recipe_list[13] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)
  247.    
  248.     #############################################################################
  249.     # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
  250.     ##########################################################################
  251.     材料 = [156, 179]             # 需要材料的数据库编号
  252.     材料种类 = [0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  253.     材料数量 = [1, 1]         # 需要材料的数量
  254.     成品 = 164                  # 获得物品编号
  255.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  256.     成品分类 = 2              # 获得成品分类
  257.     @recipe_list[14] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)
  258.    
  259.     #############################################################################
  260.     # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
  261.     ##########################################################################
  262.     材料 = [157, 172]             # 需要材料的数据库编号
  263.     材料种类 = [0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  264.     材料数量 = [1, 1]         # 需要材料的数量
  265.     成品 = 153                  # 获得物品编号
  266.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  267.     成品分类 = 2              # 获得成品分类
  268.     @recipe_list[15] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)
  269.    
  270.     #############################################################################
  271.     # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
  272.     ##########################################################################
  273.     材料 = [158, 172]             # 需要材料的数据库编号
  274.     材料种类 = [0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  275.     材料数量 = [1, 1]         # 需要材料的数量
  276.     成品 = 152                  # 获得物品编号
  277.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  278.     成品分类 = 2              # 获得成品分类
  279.     @recipe_list[16] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)
  280.    
  281.     #############################################################################
  282.     # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
  283.     ##########################################################################
  284.     材料 = [152, 153]             # 需要材料的数据库编号
  285.     材料种类 = [0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  286.     材料数量 = [1, 1]         # 需要材料的数量
  287.     成品 = 165                  # 获得物品编号
  288.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  289.    成品分类 = 2              # 获得成品分类
  290.     @recipe_list[17] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类)
  291.     end # of get_recipe_list method
  292. end # of updates to Game_Temp Class
  293. #================================
  294. # CRAFTING PROGRAM
  295. #-----------------------------------------------------
  296. #-written by Deke
  297. #-yes_no window code created by Phsylomortis
  298. #-----------------------------------------------------
  299. #================================

  300. #updates to Game_Party class

  301. class Game_Party
  302.   
  303.   attr_accessor       :recipes
  304.   
  305.   alias crafting_party_initialize initialize
  306.   
  307.   def initialize
  308.     crafting_party_initialize
  309.     @recipes=[]
  310.   end
  311.   
  312.   #------------------------------------------------------
  313.   def know?(recipe, version = 1)
  314.     unless recipe.is_a?(Game_Recipe)
  315.       recipe = get_recipe_from_master_list(recipe, version)
  316.     end
  317.     return $game_party.recipes.include?(recipe)
  318.   end
  319.   
  320. #----------------------------------------------------
  321.   def learn_recipe(recipe , version = 1)
  322.     unless recipe.is_a?(Game_Recipe)
  323.       recipe = get_recipe_from_master_list(recipe, version)
  324.     end
  325.     if recipe.is_a?(Game_Recipe)
  326.       unless know?(recipe)
  327.         @recipes.push(recipe)
  328.       end
  329.     end
  330.   end
  331.   
  332. #------------------------------------------------------
  333.   def forget_recipe(recipe , version = 1)
  334.     if !recipe.is_a?(Game_Recipe)
  335.       recipe = get_recipe_from_master_list(recipe, version)
  336.     end
  337.     if recipe.is_a?(Game_Recipe)
  338.       for i in [email protected]
  339.         if recipe == @recipes[i]
  340.           index = i
  341.           break
  342.         end
  343.       end
  344.       if index != nil
  345.         @recipes.delete(@recipes[index])
  346.       end
  347.     end
  348.   end
  349.   
  350. #---------------------------------------------------------
  351.   def get_recipe_from_master_list(item, version)
  352.     index = nil
  353.     for i in 0...$game_temp.recipe_list.size
  354.       if item[0] == $game_temp.recipe_list[i].result and item[1] ==$game_temp.recipe_list[i].result_type
  355.         version -= 1
  356.         if version == 0
  357.           index = i
  358.           break
  359.         end
  360.       end
  361.     end
  362.     if index.is_a?(Integer)
  363.       return ($game_temp.recipe_list[index])
  364.     else
  365.       return false
  366.     end
  367.   end
  368.   
  369. end # of Game_Party updates

  370. #================================
  371. class Game_Recipe

  372.   attr_reader :ingredients
  373.   attr_reader :quantities
  374.   attr_reader :result
  375.   attr_reader :result_type
  376.   attr_reader :ingredient_types
  377.   attr_reader :craft_type  #物品分类
  378.   
  379. #---------------------------------------------------
  380.   def initialize( ingredients, ingredient_types, quantities, result, result_type, craft_type=0)
  381.     @ingredients = ingredients
  382.     @ingredient_types = ingredient_types
  383.     @quantities = quantities
  384.     @result = result
  385.     @result_type = result_type
  386.     @craft_type = craft_type
  387.   end
  388.   
  389. #---------------------------------------------------------
  390.   def name
  391.     case @result_type
  392.       when 0
  393.         name = $data_items[@result].name
  394.       when 1
  395.         name = $data_armors[@result].name
  396.       when 2
  397.         name = $data_weapons[@result].name
  398.     end
  399.     return name
  400.   end
  401.   
  402. #--------------------------------------------------------

  403.   def item
  404.     case @result_type
  405.       when 0
  406.         item = $data_items[@result]
  407.       when 1
  408.         item = $data_armors[@result]
  409.       when 2
  410.         item = $data_weapons[@result]
  411.     end
  412.     return item
  413.   end

  414. #-----------------------------------------------------
  415.   def have
  416.     have_all = true
  417.     for i in [email protected]
  418.       case @ingredient_types[i]
  419.         when 0
  420.           if $game_party.item_number(@ingredients[i]) < @quantities[i]
  421.             have_all=false
  422.           end
  423.         when 1
  424.           if $game_party.armor_number(@ingredients[i]) < @quantities[i]
  425.             have_all=false
  426.           end
  427.         when 2
  428.           if $game_party.weapon_number(@ingredients[i]) < @quantities[i]
  429.             have_all=false
  430.           end
  431.       end
  432.     end
  433.     return have_all
  434.   end

  435. #---------------------------------------------------------
  436.   def decrement
  437.     for i in [email protected]
  438.       case @ingredient_types[i]
  439.       when 0
  440.         $game_party.lose_item(@ingredients[i], @quantities[i])
  441.       when 1
  442.         $game_party.lose_armor(@ingredients[i], @quantities[i])
  443.       when 2
  444.         $game_party.lose_weapon(@ingredients[i], @quantities[i])
  445.       end
  446.     end
  447.   end

  448. #-------------------------------------------------------
  449.   def make
  450.     if have
  451.       case @result_type
  452.       when 0
  453.         $game_party.gain_item(@result, 1)
  454.       when 1
  455.         $game_party.gain_armor(@result, 1)
  456.       when 2
  457.         $game_party.gain_weapon(@result, 1)
  458.       end
  459.       decrement
  460.     end
  461.   end
  462.   
  463. #---------------------------------------------------------
  464.   def == (recipe)
  465.     if recipe.is_a?(Game_Recipe)
  466.       equal = true
  467.       if recipe.ingredients != self.ingredients
  468.         equal = false
  469.       end
  470.       if recipe.ingredient_types != self.ingredient_types
  471.         equal = false
  472.       end
  473.       if recipe.quantities != self.quantities
  474.         equal = false
  475.       end
  476.       if recipe.result != self.result
  477.         equal=false
  478.       end
  479.       if recipe.result_type != self.result_type
  480.         equal = false
  481.       end
  482.     else
  483.       equal = false
  484.     end
  485.     return equal
  486.   end
  487.   
  488. end # of Game_Recipe class

  489. #===================================

  490. class Window_Craft < Window_Selectable
  491.   attr_reader :data #声明数据
  492.   #-------------------------------------------------------
  493.   def initialize(craft_type=0)
  494.     @craft_type = craft_type
  495.     super(0, 64, 240, 416)
  496.     @column_max = 1
  497.     refresh
  498.     self.index = 0
  499.   end

  500.   #----------------------------------------------------------
  501.   def recipe
  502.     return @data[self.index]
  503.   end

  504.   #----------------------------------------------------------
  505.   def refresh
  506.     if self.contents != nil
  507.       self.contents.dispose
  508.       self.contents = nil
  509.     end
  510.     @data = []
  511.     for i in 0...$game_party.recipes.size
  512.        #@craft_type为0时就显示全部物品
  513.        #不为0时就显示对应物品
  514.       if @craft_type == 0
  515.         @data.push($game_party.recipes[i])
  516.       elsif $game_party.recipes[i].craft_type == @craft_type
  517.         @data.push($game_party.recipes[i])
  518.       end
  519.     end
  520.     @item_max = @data.size
  521.     if @item_max > 0
  522.       self.contents = Bitmap.new(width - 32, row_max * 32)
  523.       self.contents.font.name = "黑体" # = "黑体"
  524.       self.contents.font.size = 18 # = 18
  525.       for i in 0...@item_max
  526.         x = 16
  527.         y = i * 32
  528.         able = true
  529.         for ingredient in 0...@data[i].ingredients.size
  530.           case @data[i].ingredient_types[ingredient]
  531.           when 0
  532.             count = $game_party.item_number(@data[i].ingredients[ingredient])
  533.           when 1
  534.             count = $game_party.armor_number(@data[i].ingredients[ingredient])
  535.           when 2
  536.             count = $game_party.weapon_number(@data[i].ingredients[ingredient])
  537.           end
  538.           if count < @data[i].quantities[ingredient]
  539.             able = false
  540.             break
  541.           end
  542.         end
  543.         draw_item_name(@data[i].item, x, y, able)
  544.       end
  545.     end
  546.   end

  547.   #------------------------------------------------------------
  548.   #def draw_item(index)
  549.   #  recipe = @data[index]
  550.   #  self.contents.font.color = recipe.have ? normal_color : disabled_color
  551.   #  x = 16
  552.   #  y = index * 32
  553.   #  self.contents.draw_text(x , y, self.width-32, 32, recipe.name, 0)
  554.   #end
  555.   
  556.   #--------------------------------------------------------------
  557.   # ● 描绘物品名
  558.   #     item : 物品
  559.   #     x    : 描画目标 X 坐标
  560.   #     y    : 描画目标 Y 坐标
  561.   #--------------------------------------------------------------
  562.   def draw_item_name(item, x, y, able = true)
  563.     if item == nil
  564.       return
  565.     end
  566.     if !able
  567.       self.contents.font.color = disabled_color
  568.     end
  569.     bitmap = RPG::Cache.icon(item.icon_name)
  570.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  571.     self.contents.font.color = normal_color
  572.     self.contents.draw_text(x + 28, y, 212, 32, item.name)
  573.   end
  574.   
  575.   #--------------------------------------------------------------
  576.   def update_help
  577.     current_recipe = recipe
  578.     if current_recipe.is_a?(Game_Recipe)
  579.     case current_recipe.result_type
  580.       when 0
  581.         description = $data_items[current_recipe.result].description
  582.       when 1
  583.         description = $data_armors[current_recipe.result].description
  584.       when 2
  585.         description = $data_weapons[current_recipe.result].description
  586.       end
  587.     else
  588.       description = ""
  589.     end
  590.     @help_window.set_text(description)
  591.     @help_window.update
  592.   end
  593.   
  594. end # of Window_Craft

  595. #=======================================
  596. class Window_CraftResult < Window_Base

  597.   #---------------------------------------------------------
  598.   def initialize
  599.     super(240, 64, 400, 184)
  600.     self.contents = Bitmap.new(width - 32, height - 32)
  601.     self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  602.     self.contents.font.size = 18 # = 20
  603.     @result = nil
  604.     @type = nil
  605.   end

  606.   #------------------------------------------------------------
  607.   def refresh
  608.     self.contents.clear
  609.     case @type
  610.       when 0
  611.         item = $data_items[@result]
  612.         if item.recover_hp_rate > item.recover_hp
  613.           hp_string = "HP回复率:"
  614.           hp_stat = item.recover_hp_rate
  615.         else
  616.           hp_string = "HP回复量:"
  617.           hp_stat = item.recover_hp
  618.         end
  619.         if item.recover_sp_rate > item.recover_sp
  620.           sp_string = "SP回复率:"
  621.           sp_stat = item.recover_sp_rate
  622.         else
  623.           sp_string = "SP回复量:"
  624.           sp_stat = item.recover_sp
  625.         end
  626.         @strings = [hp_string, sp_string, "物理防御:" , "魔法防御:", "命中率:", "分散度:"]
  627.         @stats = [hp_stat, sp_stat, item. pdef_f, item.mdef_f, item.hit, item.variance,
  628.                        $game_party.item_number(@result)]
  629.         @bitmap = RPG::Cache.icon(item.icon_name)
  630.       when 1
  631.         item = $data_armors[@result]
  632.         @strings = ["物理防御:", "魔法防御:", "回避修正:", "力量增加:", "灵巧增加:",
  633.                        "速度增加:", "魔力增加:"]
  634.         @stats = [item.pdef, item.mdef, item.eva, item.str_plus, item.dex_plus,
  635.                     item.agi_plus, item.int_plus, $game_party.armor_number(@result) ]
  636.         @bitmap = RPG::Cache.icon(item.icon_name)
  637.       when 2
  638.         item = $data_weapons[@result]
  639.         @strings =["攻击力:", "物理防御:", "魔法防御:", "力量增加:", "灵巧增加:",
  640.                     "速度增加:", "魔力增加:"]
  641.         @stats = [item.atk, item.pdef, item.mdef, item.str_plus, item.dex_plus,
  642.                     item.agi_plus, item.int_plus, $game_party.weapon_number(@result) ]
  643.         @bitmap = RPG::Cache.icon(item.icon_name)
  644.     end
  645.     for i in [email protected]
  646.       x = i%2 * 184
  647.       y = i /2 *28 +32
  648.       self.contents.font.color = normal_color
  649.       self.contents.draw_text(x,y,100, 28,@strings[i])
  650.       self.contents.font.color = system_color
  651.       self.contents.draw_text(x + 110, y, 45, 28, @stats[i].to_s)
  652.     end
  653.     self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, 24, 24), 255)
  654.     self.contents.font.color= normal_color
  655.     self.contents.draw_text(40, 0, 300, 28, "待合成物品的现有数量:")
  656.     self.contents.font.color = system_color
  657.     count = @stats[@stats.size - 1].to_s
  658.     self.contents.draw_text(294, 0, 45, 28, count )
  659.   end
  660.    
  661. #-------------------------------------------------------------
  662.   def set_result(result , type)
  663.     @result = result
  664.     @type = type
  665.     refresh
  666.   end

  667. end #of Window_CraftResult

  668. #=======================================
  669. class Window_CraftIngredients < Window_Base

  670.   #----------------------------------------------------------------
  671.   def initialize
  672.     super(240, 248, 400, 232)
  673.     self.contents = Bitmap.new(width - 32, height - 32)
  674.     self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  675.     self.contents.font.size = 18 # = 20
  676.     @ingredients = []
  677.     @types = []
  678.     @quantities = []
  679.     @item = nil
  680.     @count = 0
  681.     @counter = 0
  682.     @real_oy = 0
  683.   end

  684.   #-----------------------------------------------------------------
  685.   def refresh
  686.     @counter = 0
  687.     self.contents.clear
  688.     self.contents = Bitmap.new(width - 32, @ingredients.size * 26)
  689.     for i in [email protected]
  690.       case @types[i]
  691.       when 0
  692.         @item = $data_items[@ingredients[i]]
  693.         @count = $game_party.item_number(@ingredients[i])
  694.       when 1
  695.         @item = $data_armors[@ingredients[i]]
  696.         @count = $game_party.armor_number(@ingredients[i])
  697.       when 2
  698.         @item = $data_weapons[@ingredients[i]]
  699.         @count = $game_party.weapon_number(@ingredients[i])
  700.       end
  701.       y = i *26
  702.       self.contents.blt(0, y, RPG::Cache.icon(@item.icon_name), Rect.new(0, 0, 24, 24), 255)
  703.       self.contents.font.color = @count >= @quantities[i] ? normal_color : disabled_color
  704.       self.contents.draw_text(30, y, 280, 28, @item.name)
  705.       self.contents.draw_text(300, y, 45, 28, @quantities[i].to_s)
  706.       self.contents.font.color = system_color
  707.       self.contents.draw_text(245, y, 45, 28, @count.to_s )     
  708.     end
  709.   end
  710.       
  711.   #-------------------------------------------------------------
  712.   def set_ingredients(ingredients , types, quantities)
  713.     @ingredients = ingredients
  714.     @types = types
  715.     @quantities = quantities
  716.     refresh
  717.     if @ingredients.size > 7
  718.       self.oy = -52
  719.       @real_oy = 0
  720.     else
  721.       self.oy = 0
  722.     end
  723.   end

  724.   def update
  725.     super
  726.     @counter += 1
  727.     if @ingredients.size > 7 and @counter > 30
  728.       @real_oy = (@real_oy + 1) % ((@ingredients.size - 3) * 26)
  729.       self.oy = @real_oy - 52
  730.     end
  731.   end
  732.    
  733. end # of Window_CraftIngredients

  734. #======================================
  735. class Scene_Craft

  736.   #--------------------------------------------------------------------
  737.   # @craft_type:物品种类,0就是全部
  738.   def initialize(craft_type=0,craft_index=0)
  739.     @craft_index=craft_index
  740.     @craft_type = craft_type
  741.   end
  742.   
  743.   #--------------------------------------------------------------------
  744.   def main
  745.     @craft_window = Window_Craft.new(@craft_type)
  746.     @craft_window.index=@craft_index
  747.     @confirm_window = Window_Base.new(120, 188, 400, 64)
  748.     @confirm_window.contents = Bitmap.new(368, 32)
  749.     @confirm_window.contents.font.name = "黑体"
  750.     @confirm_window.contents.font.size = 20
  751.     @help_window = Window_Help.new
  752.     @craft_window.help_window = @help_window
  753.     @result_window=Window_CraftResult.new
  754.     @ingredients_window=Window_CraftIngredients.new
  755.     if @craft_window.data.size > 0 #本类窗口物品大于0的话
  756.       @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
  757.       @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
  758.                                                           @craft_window.recipe.ingredient_types,
  759.                                                           @craft_window.recipe.quantities)
  760.     end
  761.     @yes_no_window = Window_Command.new(100, ["确定", "放弃"])
  762.     @confirm_window.visible = false
  763.     @confirm_window.z = 1500
  764.     @yes_no_window.visible = false
  765.     @yes_no_window.active = false
  766.     @yes_no_window.index = 1
  767.     @yes_no_window.x = 270
  768.     @yes_no_window.y = 252
  769.     @yes_no_window.z = 1500
  770.     @label_window = Window_Base.new(450,200,190,52)
  771.     @label_window.contents=Bitmap.new(@label_window.width - 32,@label_window.height - 32)
  772.     @label_window.contents.font.size=20
  773.     @label_window.contents.font.color = @label_window.normal_color
  774.     @label_window.contents.font.name = "黑体"
  775.     @label_window.contents.draw_text(0, 0, @label_window.contents.width, 20, "  现有   需要")
  776.     Graphics.transition
  777.     loop do
  778.       Graphics.update
  779.       Input.update
  780.       update
  781.       if $scene != self
  782.         break
  783.       end
  784.     end
  785.     Graphics.freeze
  786.     @help_window.dispose
  787.     @craft_window.dispose
  788.     @result_window.dispose
  789.     @ingredients_window.dispose
  790.     @confirm_window.dispose
  791.     @yes_no_window.dispose
  792.     @label_window.dispose
  793.   end

  794.   #--------------------------------------------------------------------
  795.   def update
  796.     @craft_window.update
  797.     @ingredients_window.update
  798.     if @craft_window.active
  799.       update_craft
  800.       return
  801.     end
  802.     if @yes_no_window.active
  803.       confirm_update
  804.       return
  805.     end
  806.   end

  807.   #-------------------------------------------------------------------
  808.   def update_craft
  809.     if Input.dir4 != 0
  810.       if @craft_window.data.size > 0 #本类窗口物品大于0的话
  811.         @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
  812.         @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
  813.                                                            @craft_window.recipe.ingredient_types,
  814.                                                            @craft_window.recipe.quantities)
  815.       end
  816.     end
  817.     if Input.trigger?(Input::B)
  818.       $game_system.se_play($data_system.cancel_se)
  819.       $game_system.windowskin_name = "skin1"
  820.       $scene = Scene_Map.new
  821.       return
  822.     end
  823.     if Input.trigger?(Input::C) and $game_party.recipes.size != 0
  824.       @recipe = @craft_window.recipe
  825.       if @recipe != nil
  826.         if @recipe.have
  827.           @yes_no_window.active = true
  828.           @craft_window.active = false
  829.         else
  830.           $game_system.se_play($data_system.buzzer_se)
  831.           return
  832.         end
  833.       else
  834.         $game_system.se_play($data_system.buzzer_se)
  835.         return
  836.       end
  837.     end
  838.   end

  839.   #-------------------------------------------------------------------
  840.   def confirm_update
  841.     @craft_index = @craft_window.index
  842.     @confirm_window.visible = true
  843.     @confirm_window.z = 1500
  844.     @yes_no_window.visible = true
  845.     @yes_no_window.active = true
  846.     @yes_no_window.z = 1500
  847.     @yes_no_window.update
  848.     string = "合成 " + @recipe.name + "?"
  849.     cw = @confirm_window.contents.text_size(string).width
  850.     center = @confirm_window.contents.width/2 - cw /2
  851.     unless @drawn
  852.       @confirm_window.contents.font.color = Color.new(80, 73, 127, 255)
  853.       @confirm_window.contents.draw_text(center, 0, cw, 30, string)
  854.       @drawn = true
  855.     end
  856.     if Input.trigger?(Input::C)
  857.       if @yes_no_window.index == 0
  858.         $game_system.se_play($data_system.decision_se)
  859.         @recipe.make
  860.         $game_system.se_play($data_system.save_se)
  861.         $scene=Scene_Craft.new(@craft_type,@craft_index)
  862.       else
  863.         $game_system.se_play($data_system.cancel_se)
  864.         $scene=Scene_Craft.new(@craft_type,@craft_index)
  865.       end
  866.     end
  867.     if Input.trigger?(Input::B)
  868.       $game_system.se_play($data_system.cancel_se)
  869.       $scene=Scene_Craft.new(@craft_type,@craft_index)
  870.     end
  871.   end

  872. end # of Scene_Craft

  873. #=============================================================
  874. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  875. # 欢迎访问www.66RPG.com
  876. # 梦想世界,在你手中
  877. #=============================================================

复制代码
脚本送上

啊,高手来教教我啊


Lv1.梦旅人

梦石
0
星屑
153
在线时间
163 小时
注册时间
2009-7-16
帖子
116
2
发表于 2011-8-4 14:48:10 | 只看该作者
工程发我看下~   这个脚本我也在用
回复

使用道具 举报

Lv1.梦旅人

虱子

梦石
0
星屑
121
在线时间
1782 小时
注册时间
2010-6-19
帖子
3597
3
发表于 2011-8-4 15:07:10 | 只看该作者
试试用新存档
回复

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-22 05:43

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表