查看: 2022|回复: 1

[已经过期] 物品合成脚本,修改后效果无法达成,在线等,挺急的

[复制链接]
梦石
0
星屑
75
在线时间
73 小时
注册时间
2015-7-10
回帖
26
发表于 2015-9-13 04:35:18 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 老王的忧郁 于 2015-9-13 14:37 编辑

我想在游戏中,将物品合成制作成需要【制作熟练度】的效果,
问题1、
我在脚本中添加了两组代码,其中,@increment = increment #熟练度增量 可以正确的增加到我指定的熟练度变量中,

    而配方的@need = need #熟练度需求却无法正确运行。如今可以合成物品,丹没法正确判断,是否达到配方要求的熟练度
问题2、
QQ截图20150913042143.png
配方中的熟练度需求和熟练度增长的数值,无法真确的显示在数据页面
class Game_Recipe
  attr_reader :ingredients  #需要的材料定义
  attr_reader :quantities   #需要的材料数量
  attr_reader :result       # 获得物品编号
  attr_reader :result_type  # 获得物品种类,0是普通物品,1是防具,2是武器
  attr_reader :ingredient_types # 需要材料的种类,0是普通物品,1是防具,2是武器
  attr_reader :craft_type  # 获得成品分类
  attr_reader :need #熟练度需求      【老王添加】
  attr_reader :increment #熟练度的增长  【老王添加】

def initialize( ingredients, ingredient_types, quantities, result, result_type, craft_type, need, increment=0)
    #初始化(成分,成分_类型,数量,成品,成品_种类,成品_分类= 0)
    @ingredients = ingredients   #成分赋值
    @ingredient_types = ingredient_types #成分种类赋值
    @quantities = quantities  #成分数量
    @result = result  #成品赋值
    @result_type = result_type #成品种类,0是普通物品,1是防具,2是武器
    @craft_type = craft_type # 获得成品分类
    @need = need #熟练度需求赋值
    @increment = increment #熟练度增量赋值
  end



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

  119.     ##########################################################################
  120.     # 2 号合成物品设定 武器 成品分类:2
  121.     ##########################################################################
  122.     # 剑
  123.     材料 = [11]          # 需要材料的数据库编号
  124.     材料种类 = [0]      # 需要材料的种类,0是普通物品,1是防具,2是武器
  125.     材料数量 = [5]      # 需要材料的数量
  126.     成品 = 1                  # 获得物品编号
  127.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  128.     成品分类 = 2              # 获得成品分类
  129.     熟练度需求 = 0
  130.     熟练度增长 = 10
  131.     @recipe_list[1] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类,熟练度需求,熟练度增长)

  132.     材料 = [11]          # 需要材料的数据库编号
  133.     材料种类 = [0]      # 需要材料的种类,0是普通物品,1是防具,2是武器
  134.     材料数量 = [5]      # 需要材料的数量
  135.     成品 = 2                  # 获得物品编号
  136.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  137.     成品分类 = 2              # 获得成品分类
  138.     熟练度需求 = 200
  139.     熟练度增长 = 22
  140.     @recipe_list[2] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类,熟练度需求,熟练度增长)

  141.     #刀
  142.     材料 = [11]          # 需要材料的数据库编号
  143.     材料种类 = [0]      # 需要材料的种类,0是普通物品,1是防具,2是武器
  144.     材料数量 = [5]      # 需要材料的数量
  145.     成品 = 6                  # 获得物品编号
  146.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  147.     成品分类 = 2              # 获得成品分类
  148.     熟练度需求 = 0
  149.     熟练度增长 = 10
  150.     @recipe_list[6] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类,熟练度需求,熟练度增长)

  151.     材料 = [11]          # 需要材料的数据库编号
  152.     材料种类 = [0]      # 需要材料的种类,0是普通物品,1是防具,2是武器
  153.     材料数量 = [5]      # 需要材料的数量
  154.     成品 = 7                 # 获得物品编号
  155.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  156.     成品分类 = 2              # 获得成品分类
  157.     熟练度需求 = 220
  158.     熟练度增长 = 44
  159.     @recipe_list[7] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类,熟练度需求,熟练度增长)

  160.     #棍
  161.     材料 = [11]          # 需要材料的数据库编号
  162.     材料种类 = [0]      # 需要材料的种类,0是普通物品,1是防具,2是武器
  163.     材料数量 = [5]      # 需要材料的数量
  164.     成品 = 11                  # 获得物品编号
  165.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  166.     成品分类 = 2              # 获得成品分类
  167.     熟练度需求 = 0
  168.     熟练度增长 = 10
  169.     @recipe_list[11] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类,熟练度需求,熟练度增长)

  170.     材料 = [11]          # 需要材料的数据库编号
  171.     材料种类 = [0]      # 需要材料的种类,0是普通物品,1是防具,2是武器
  172.     材料数量 = [5]      # 需要材料的数量
  173.     成品 = 12                  # 获得物品编号
  174.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  175.     成品分类 = 2              # 获得成品分类
  176.     熟练度需求 = 150
  177.     熟练度增长 = 66
  178.     @recipe_list[12] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类,熟练度需求,熟练度增长)

  179.     #指
  180.     材料 = [11]          # 需要材料的数据库编号
  181.     材料种类 = [0]      # 需要材料的种类,0是普通物品,1是防具,2是武器
  182.     材料数量 = [5]      # 需要材料的数量
  183.     成品 = 16                  # 获得物品编号
  184.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  185.     成品分类 = 2              # 获得成品分类
  186.     熟练度需求 = 0
  187.     熟练度增长 = 10
  188.     @recipe_list[16] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类,熟练度需求,熟练度增长)

  189.     材料 = [11]          # 需要材料的数据库编号
  190.     材料种类 = [0]      # 需要材料的种类,0是普通物品,1是防具,2是武器
  191.     材料数量 = [5]      # 需要材料的数量
  192.     成品 = 17                  # 获得物品编号
  193.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  194.     成品分类 = 2              # 获得成品分类
  195.     熟练度需求 = 160
  196.     熟练度增长 = 77
  197.     @recipe_list[17] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类,熟练度需求,熟练度增长)

  198.     #奇门
  199.     材料 = [11]          # 需要材料的数据库编号
  200.     材料种类 = [0]      # 需要材料的种类,0是普通物品,1是防具,2是武器
  201.     材料数量 = [5]      # 需要材料的数量
  202.     成品 = 21                 # 获得物品编号
  203.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  204.     成品分类 = 2              # 获得成品分类
  205.     熟练度需求 = 0
  206.     熟练度增长 = 10
  207.     @recipe_list[21] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类,熟练度需求,熟练度增长)

  208.     材料 = [11]          # 需要材料的数据库编号
  209.     材料种类 = [0]      # 需要材料的种类,0是普通物品,1是防具,2是武器
  210.     材料数量 = [5]      # 需要材料的数量
  211.     成品 = 22                  # 获得物品编号
  212.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  213.     成品分类 = 2              # 获得成品分类
  214.     熟练度需求 = 120
  215.     熟练度增长 = 10
  216.     @recipe_list[22] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类,熟练度需求,熟练度增长)

  217.     ##########################################################################
  218.     # 3 号合成物品设定  织造   成品分类:3
  219.     ##########################################################################
  220.     #帽
  221.     材料 = [26]            # 需要材料的数据库编号
  222.     材料种类 = [0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  223.     材料数量 = [10]         # 需要材料的数量
  224.     成品 = 26                 # 获得物品编号
  225.     成品种类 = 1              # 获得物品种类,0是普通物品,1是防具,2是武器
  226.     成品分类 = 3              # 获得成品分类
  227.     熟练度需求 = 0
  228.     熟练度增长 = 10
  229.     @recipe_list[26] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类,成品分类,熟练度需求,熟练度增长)
  230.     end # of get_recipe_list method  结束对配方的设定
  231. end # of updates to Game_Temp Class  更新配方表结束

  232. #================================
  233. # CRAFTING PROGRAM
  234. #----------------------------------------------------------------
  235. #-written by Deke
  236. #-yes_no window code created by Phsylomortis
  237. #----------------------------------------------------------------
  238. #================================

  239. #updates to Game_Party class  对game_party类更新

  240. class Game_Party
  241.   
  242.   attr_accessor       :recipes
  243.   
  244.   alias crafting_party_initialize initialize
  245.   
  246.   def initialize
  247.     crafting_party_initialize
  248.     @recipes=[]
  249.   end
  250.   
  251.   #----------------------------------------------------------------------
  252.   def know?(recipe, version = 1)     #系统理解配方的;
  253.     unless recipe.is_a?(Game_Recipe)
  254.       recipe = get_recipe_from_master_list(recipe, version)
  255.     end
  256.     return $game_party.recipes.include?(recipe)
  257.   end
  258.   
  259. #----------------------------------------------------------------------
  260.   def learn_recipe(recipe , version = 1)  #配方学习的类
  261.     unless recipe.is_a?(Game_Recipe)
  262.       recipe = get_recipe_from_master_list(recipe, version)
  263.     end
  264.     if recipe.is_a?(Game_Recipe)
  265.       unless know?(recipe)
  266.         @recipes.push(recipe)
  267.       end
  268.     end
  269.   end
  270.   
  271. #----------------------------------------------------------------------
  272.   def forget_recipe(recipe , version = 1) #遗忘配方的类
  273.     if !recipe.is_a?(Game_Recipe)
  274.       recipe = get_recipe_from_master_list(recipe, version)
  275.     end
  276.     if recipe.is_a?(Game_Recipe)
  277.       for i in [email]0...@recipes.size[/email]
  278.         if recipe == @recipes[i]
  279.           index = i
  280.           break
  281.         end
  282.       end
  283.       if index != nil
  284.         @recipes.delete(@recipes[index])
  285.       end
  286.     end
  287.   end
  288.   
  289. #----------------------------------------------------------------------
  290.   def get_recipe_from_master_list(item, version)
  291.     index = nil
  292.     for i in 0...$game_temp.recipe_list.size
  293.       if item[0] == $game_temp.recipe_list[i].result and item[1] ==$game_temp.recipe_list[i].result_type
  294.         version -= 1
  295.         if version == 0
  296.           index = i
  297.           break
  298.         end
  299.       end
  300.     end
  301.     if index.is_a?(Integer)
  302.       return ($game_temp.recipe_list[index])
  303.     else
  304.       return false
  305.     end
  306.   end
  307.   
  308. end # of Game_Party updates

  309. #================================
  310. class Game_Recipe

  311.   attr_reader :ingredients  #需要的材料  定义
  312.   attr_reader :quantities   #需要的材料数量
  313.   attr_reader :result       # 获得物品编号
  314.   attr_reader :result_type  # 获得物品种类,0是普通物品,1是防具,2是武器
  315.   attr_reader :ingredient_types # 需要材料的种类,0是普通物品,1是防具,2是武器
  316.   attr_reader :craft_type  # 获得成品分类
  317.   attr_reader :need #熟练度需求      【老王添加】
  318.   attr_reader :increment #熟练度的增量  【老王添加】
  319. #----------------------------------------------------------------------
  320.   def initialize( ingredients, ingredient_types, quantities, result, result_type, craft_type, need, increment=0)
  321.     #初始化(成分,成分_类型,数量,成品,成品_种类,成品_分类= 0)
  322.     @ingredients = ingredients   #成分赋值
  323.     @ingredient_types = ingredient_types #成分种类赋值
  324.     @quantities = quantities  #成分数量
  325.     @result = result  #成品赋值
  326.     @result_type = result_type #成品种类,0是普通物品,1是防具,2是武器
  327.     @craft_type = craft_type # 获得成品分类
  328.     @need = need #熟练度需求赋值  【老王添加】
  329.     @increment = increment #熟练度增量赋值 【老王添加】
  330.   end

  331. #----------------------------------------------------------------------
  332.   def name  #配方名称
  333.     case @result_type #分别属于成品种类
  334.       when 0
  335.         name = $data_items[@result].name #配方名称来源于成品的名称,属于物品类
  336.       when 1
  337.         name = $data_armors[@result].name #配方名称来源于成品的名称,属于武器类
  338.       when 2
  339.         name = $data_weapons[@result].name #配方名称来源于成品的名称,属于防具类
  340.     end
  341.     return name
  342.   end
  343.   
  344. #----------------------------------------------------------------------

  345.   def item #成品物品
  346.     case @result_type
  347.       when 0
  348.         item = $data_items[@result] #成品物品编号等于 物品编号
  349.       when 1
  350.         item = $data_armors[@result] #成品物品编号等于 武器编号
  351.       when 2
  352.         item = $data_weapons[@result] #成品物品编号等于 防具编号
  353.     end
  354.     return item
  355.   end

  356. #----------------------------------------------------------------------
  357.   def have #初始化,用于判断配方所需材料是否齐全
  358.     have_all = true #材料齐全
  359.     for i in [email]0...@ingredients.size[/email]
  360.       case @ingredient_types[i]
  361.         when 0
  362.           if $game_party.item_number(@ingredients[i]) < @quantities[i] and $game_variables[751] < @need[i]
  363.             have_all=false
  364.           end
  365.         when 1
  366.           if $game_party.armor_number(@ingredients[i]) < @quantities[i] and $game_variables[754] < @need[i]
  367.             have_all=false
  368.           end
  369.         when 2
  370.           if $game_party.weapon_number(@ingredients[i]) < @quantities[i]and $game_variables[753] < @need[i]
  371.             have_all=false
  372.           end
  373.       end
  374.     end
  375.     return have_all
  376.   end

  377. #----------------------------------------------------------------------
  378.   def decrement #初始化材料的消耗数量
  379.     for i in [email]0...@ingredients.size[/email]
  380.       case @ingredient_types[i]
  381.       when 0
  382.         $game_party.lose_item(@ingredients[i], @quantities[i])
  383.       when 1
  384.         $game_party.lose_armor(@ingredients[i], @quantities[i])
  385.       when 2
  386.         $game_party.lose_weapon(@ingredients[i], @quantities[i])
  387.       end
  388.     end
  389.   end

  390. #----------------------------------------------------------------------
  391.   def make #初始化  物品合成
  392.     if have #如果材料齐全
  393.       case @result_type #根据成品种类制造
  394.       when 0 #物品
  395.         if @craft_type  == 7 #如果成品的自定义类型为  7
  396.         $game_party.gain_item(@result, 10) #获得这样的成品 10个
  397.         elsif @craft_type  == 4 #如果成品的自定义类型为  4
  398.         $game_party.gain_item(@result, 5) ##获得这样的成品 5个
  399.         else
  400.         $game_party.gain_item(@result, 1)
  401.         $game_variables[751] += @increment
  402.         end
  403.       when 1 #武器
  404.         $game_party.gain_armor(@result, 1)
  405.         $game_variables[754] += @increment
  406.       when 2 #防具
  407.         $game_party.gain_weapon(@result, 1)
  408.         $game_variables[753] += @increment
  409.       end
  410.       decrement
  411.     end
  412.   end
  413.   
  414. #----------------------------------------------------------------------
  415.   def == (recipe)
  416.     if recipe.is_a?(Game_Recipe)
  417.       equal = true
  418.       if recipe.ingredients != self.ingredients
  419.         equal = false
  420.       end
  421.       if recipe.ingredient_types != self.ingredient_types
  422.         equal = false
  423.       end
  424.       if recipe.quantities != self.quantities
  425.         equal = false
  426.       end
  427.       if recipe.result != self.result
  428.         equal=false
  429.       end
  430.       if recipe.result_type != self.result_type
  431.         equal = false
  432.       end
  433.       if recipe.need != self.need  #老王添加
  434.         equal = false
  435.       end
  436.     else
  437.       equal = false
  438.     end
  439.     return equal
  440.   end
  441.   
  442. end # of Game_Recipe class

  443. #===================================

  444. class Window_Craft < Window_Selectable
  445.   attr_reader :data #声明数据
  446.   #--------------------------------------------------------------------------
  447.   def initialize(craft_type=0)
  448.     @craft_type = craft_type
  449.     super(0, 64-64, 240, 416+64)
  450.     @column_max = 1
  451.     refresh
  452.     self.index = 0
  453.   end

  454.   #--------------------------------------------------------------------------
  455.   def recipe
  456.     return @data[self.index]
  457.   end

  458.   #--------------------------------------------------------------------------
  459.   def refresh
  460.     if self.contents != nil
  461.       self.contents.dispose
  462.       self.contents = nil
  463.     end
  464.     @data = []
  465.     for i in 0...$game_party.recipes.size
  466.        #@craft_type为0时就显示全部物品
  467.        #不为0时就显示对应物品
  468.       if @craft_type == 0
  469.         @data.push($game_party.recipes[i])
  470.       elsif $game_party.recipes[i].craft_type == @craft_type
  471.         @data.push($game_party.recipes[i])
  472.       end
  473.     end
  474.     @item_max = @data.size
  475.     if @item_max > 0
  476.       self.contents = Bitmap.new(width - 32, row_max * 32)
  477.       self.contents.font.name = ["黑体", "楷体", "宋体"]
  478.       self.contents.font.size = 18 # = 18
  479.       for i in 0...@item_max
  480.         x = 16
  481.         y = i * 32
  482.         able = true
  483.         for ingredient in 0...@data[i].ingredients.size
  484.           case @data[i].ingredient_types[ingredient]
  485.           when 0
  486.             count = $game_party.item_number(@data[i].ingredients[ingredient])
  487.           when 1
  488.             count = $game_party.armor_number(@data[i].ingredients[ingredient])
  489.           when 2
  490.             count = $game_party.weapon_number(@data[i].ingredients[ingredient])
  491.           end
  492.           if count < @data[i].quantities[ingredient]
  493.             able = false
  494.             break
  495.           end
  496.         end
  497.         draw_item_name(@data[i].item, x, y, able)
  498.       end
  499.     end
  500.   end

  501.   #--------------------------------------------------------------------------
  502.   #def draw_item(index)
  503.   #  recipe = @data[index]
  504.   #  self.contents.font.color = recipe.have ? normal_color : disabled_color
  505.   #  x = 16
  506.   #  y = index * 32
  507.   #  self.contents.draw_text(x , y, self.width-32, 32, recipe.name, 0)
  508.   #end
  509.   
  510.   #--------------------------------------------------------------------------
  511.   # ● 描绘物品名
  512.   #     item : 物品
  513.   #     x    : 描画目标 X 坐标
  514.   #     y    : 描画目标 Y 坐标
  515.   #--------------------------------------------------------------------------
  516.   def draw_item_name(item, x, y, able = true)
  517.     if item == nil
  518.       return
  519.     end
  520.     if !able
  521.       self.contents.font.color = disabled_color
  522.     end
  523.     bitmap = RPG::Cache.icon(item.icon_name)
  524.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  525.     self.contents.draw_text(x + 28, y, 212, 32, item.name)
  526.     self.contents.font.color = normal_color
  527.   end
  528.   
  529.   #--------------------------------------------------------------------------
  530.   def update_help
  531.     current_recipe = recipe
  532.     if current_recipe.is_a?(Game_Recipe)
  533.     case current_recipe.result_type
  534.       when 0
  535.         item = $data_items[current_recipe.result]
  536.         #description = $data_items[current_recipe.result].description
  537.       when 1
  538.         item = $data_armors[current_recipe.result]
  539.         #description = $data_armors[current_recipe.result].description
  540.       when 2
  541.         item = $data_weapons[current_recipe.result]
  542.         #description = $data_weapons[current_recipe.result].description
  543.       end
  544.     else
  545.       #description = ""
  546.     end
  547.     @help_window.set_text(item)
  548.     #校正帮助窗口位置
  549.     @help_window.set_pos(self.x-64,self.y+16,self.width,self.oy,self.index,@column_max)
  550.     # @help_window.set_text(description)
  551.     @help_window.update
  552.   end
  553.   
  554. end # of Window_Craft

  555. #=======================================
  556. class Window_CraftResult < Window_Base

  557.   #--------------------------------------------------------------------------
  558.   def initialize
  559.     super(240, 64-64, 400, 184+64)
  560.     self.contents = Bitmap.new(width - 32, height - 32)
  561.     self.contents.font.name = ["黑体", "楷体", "宋体"] # = $fontface.is_a?(String) ? $fontface :

  562. $defaultfonttype
  563.     self.contents.font.size = 18 # = 20
  564.     @result = nil
  565.     @type = nil
  566.   end

  567.   #--------------------------------------------------------------------------
  568.   def refresh
  569.     self.contents.clear
  570.     case @type
  571.       #玄:修改显示方式,分散度和命中为隐藏数值,不显示
  572.       when 0
  573.         item = $data_items[@result]
  574.         #if item.recover_hp_rate > item.recover_hp
  575.           #hp_string = "生命回复率:"
  576.           #hp_stat = item.recover_hp_rate
  577.        # else
  578.           hp_string = "生命回复量:"
  579.           hp_stat = item.recover_hp
  580.         #end
  581.         #if item.recover_sp_rate > item.recover_sp
  582.           #sp_string = "真气回复率:"
  583.           #sp_stat = item.recover_sp_rate
  584.         #else
  585.           sp_string = "真气回复量:"
  586.           sp_stat = item.recover_sp
  587.         #end
  588.         @strings = [hp_string, sp_string, "护甲:" , "气防:", "生命回复率:", "真气回复率:","熟练度需求:","熟练度增长:","熟练度:"]
  589.         @stats = [hp_stat, sp_stat, item. pdef_f, item.mdef_f, item.recover_hp_rate, item.recover_sp_rate,@need.to_s,@increment.to_s,$game_variables[751],$game_party.item_number(@result)]
  590.         @bitmap = RPG::Cache.icon(item.icon_name)
  591.       when 1
  592.         item = $data_armors[@result]
  593.         @strings = ["护甲:", "气防:", "回避修正:", "力道增加:", "招式增加:",
  594.                        "身法增加:", "内力增加:","熟练度需求:","熟练度增长:","熟练度:"]
  595.         @stats = [item.pdef, item.mdef, item.eva, item.str_plus, item.dex_plus,item.agi_plus, item.int_plus,@need.to_s,@increment.to_s,$game_variables[754],$game_party.armor_number(@result) ]
  596.         @bitmap = RPG::Cache.icon(item.icon_name)
  597.       when 2
  598.         item = $data_weapons[@result]
  599.         @strings =["攻击力:", "护甲:", "气防:", "力道增加:", "招式增加:",
  600.                     "身法增加:", "内力增加:","熟练度需求:","熟练度增长:","熟练度:"]
  601.         @stats = [item.atk, item.pdef, item.mdef, item.str_plus, item.dex_plus,item.agi_plus, item.int_plus,@need,@increment,$game_variables[753],$game_party.weapon_number(@result) ]
  602.         @bitmap = RPG::Cache.icon(item.icon_name)
  603.       end
  604.     for i in [email]0...@strings.size[/email]
  605.       x = i%2 * 184
  606.       y = i /2 *28 +32
  607.       self.contents.font.color = normal_color
  608.       self.contents.draw_text(x,y,100, 28,@strings[i])
  609.       self.contents.font.color = system_color
  610.       self.contents.draw_text(x + 110, y, 45, 28, @stats[i].to_s)
  611.     end
  612.     self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, 24, 24), 255)
  613.     self.contents.font.color= normal_color
  614.     self.contents.draw_text(40, 0, 300, 28, "待合成物品的现有数量:")
  615.     self.contents.font.color = system_color
  616.     count = @stats[@stats.size - 1].to_s
  617.     self.contents.draw_text(294, 0, 45, 28, count )
  618.   end

  619. #----------------------------------------------------------------------
  620.   def set_result(result , type)
  621.     @result = result
  622.     @type = type
  623.     refresh
  624.   end

  625. end #of Window_CraftResult

  626. #=======================================
  627. class Window_CraftIngredients < Window_Base

  628.   #--------------------------------------------------------------------------
  629.   def initialize
  630.     super(240, 248, 400, 232)
  631.     self.contents = Bitmap.new(width - 32, height - 32)
  632.     self.contents.font.name = ["黑体", "楷体", "宋体"] # = $fontface.is_a?(String) ? $fontface :

  633. $defaultfonttype
  634.     self.contents.font.size = 18 # = 20
  635.     @ingredients = []
  636.     @types = []
  637.     @quantities = []
  638.     @item = nil
  639.     @count = 0
  640.     @counter = 0
  641.     @real_oy = 0
  642.   end

  643.   #--------------------------------------------------------------------------
  644.   def refresh
  645.     @counter = 0
  646.     self.contents.clear
  647.     self.contents = Bitmap.new(width - 32, @ingredients.size * 26)
  648.     for i in [email]0...@ingredients.size[/email]
  649.       case @types[i]
  650.       when 0
  651.         @item = $data_items[@ingredients[i]]
  652.         @count = $game_party.item_number(@ingredients[i])
  653.       when 1
  654.         @item = $data_armors[@ingredients[i]]
  655.         @count = $game_party.armor_number(@ingredients[i])
  656.       when 2
  657.         @item = $data_weapons[@ingredients[i]]
  658.         @count = $game_party.weapon_number(@ingredients[i])
  659.       end
  660.       y = i *26
  661.       self.contents.blt(0, y, RPG::Cache.icon(@item.icon_name), Rect.new(0, 0, 24, 24), 255)
  662.       self.contents.font.color = @count >= @quantities[i] ? normal_color : disabled_color
  663.       self.contents.draw_text(30, y, 280, 28, @item.name)
  664.       self.contents.draw_text(300, y, 45, 28, @quantities[i].to_s)
  665.       self.contents.font.color = system_color
  666.       self.contents.draw_text(245, y, 45, 28, @count.to_s )     
  667.     end
  668.   end
  669.       
  670.   #--------------------------------------------------------------------------
  671.   def set_ingredients(ingredients , types, quantities)
  672.     @ingredients = ingredients
  673.     @types = types
  674.     @quantities = quantities
  675.     refresh
  676.     if @ingredients.size > 7
  677.       self.oy = -52
  678.       @real_oy = 0
  679.     else
  680.       self.oy = 0
  681.     end
  682.   end

  683.   def update
  684.     super
  685.     @counter += 1
  686.     if @ingredients.size > 7 and @counter > 30
  687.       @real_oy = (@real_oy + 1) % ((@ingredients.size - 3) * 26)
  688.       self.oy = @real_oy - 52
  689.     end
  690.   end
  691.    
  692. end # of Window_CraftIngredients

  693. #======================================
  694. class Scene_Craft

  695.   #--------------------------------------------------------------------------
  696.   # @craft_type:物品种类,0就是全部
  697.   def initialize(craft_type=0,craft_index=0)
  698.     @craft_index=craft_index
  699.     @craft_type = craft_type
  700.   end
  701.   
  702.   #--------------------------------------------------------------------------
  703.   def main
  704.     @craft_window = Window_Craft.new(@craft_type)
  705.     @craft_window.index=@craft_index
  706.     @confirm_window = Window_Base.new(120, 188, 400, 64)
  707.     @confirm_window.contents = Bitmap.new(368, 32)
  708.     @confirm_window.contents.font.name = ["黑体", "楷体", "宋体"]
  709.     @confirm_window.contents.font.size = 20
  710.     @help_window = Window_Help_Self.new #Window_Help.new
  711.     @craft_window.help_window = @help_window
  712.     @result_window=Window_CraftResult.new
  713.     @ingredients_window=Window_CraftIngredients.new
  714.     if @craft_window.data.size > 0 #本类窗口物品大于0的话
  715.       @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
  716.       @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
  717.                                                           @craft_window.recipe.ingredient_types,
  718.                                                           @craft_window.recipe.quantities)
  719.     end
  720.     @yes_no_window = Window_Command.new(100, ["确定", "放弃"])
  721.     @confirm_window.visible = false
  722.     @confirm_window.z = 1500
  723.     @yes_no_window.visible = false
  724.     @yes_no_window.active = false
  725.     @yes_no_window.index = 1
  726.     @yes_no_window.x = 270
  727.     @yes_no_window.y = 252
  728.     @yes_no_window.z = 1500
  729.     @label_window = Window_Base.new(450,200,190,52)
  730.     @label_window.contents=Bitmap.new(@label_window.width - 32,@label_window.height - 32)
  731.     @label_window.contents.font.size=20
  732.     @label_window.contents.font.color = @label_window.normal_color
  733.     @label_window.contents.font.name = ["黑体", "楷体", "宋体"]
  734.     @label_window.contents.draw_text(0, 0, @label_window.contents.width, 20, "  现有   需要")
  735.     Graphics.transition
  736.     loop do
  737.       Graphics.update
  738.       Input.update
  739.       update
  740.       if $scene != self
  741.         break
  742.       end
  743.     end
  744.     Graphics.freeze
  745.     @help_window.dispose
  746.     @craft_window.dispose
  747.     @result_window.dispose
  748.     @ingredients_window.dispose
  749.     @confirm_window.dispose
  750.     @yes_no_window.dispose
  751.     @label_window.dispose
  752.   end

  753.   #--------------------------------------------------------------------------
  754.   def update
  755.     @craft_window.update
  756.     @ingredients_window.update
  757.     if @craft_window.active
  758.       update_craft
  759.       return
  760.     end
  761.     if @yes_no_window.active
  762.       confirm_update
  763.       return
  764.     end
  765.   end

  766.   #--------------------------------------------------------------------------
  767.   def update_craft
  768.     if Input.dir4 != 0
  769.       if @craft_window.data.size > 0 #本类窗口物品大于0的话
  770.         @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
  771.         @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
  772.                                                            @craft_window.recipe.ingredient_types,
  773.                                                            @craft_window.recipe.quantities)
  774.       end
  775.     end
  776.     if Input.trigger?(Input::B)
  777.       $game_system.se_play($data_system.cancel_se)
  778.       if @craft_type <= 4 #玄:普通铸造、织造回到菜单,强化回到地图
  779.       $scene = Scene_Menu.new(0) #按下B键返回主菜单
  780.      else
  781.       $scene = Scene_Map.new  #按下B键返回地图
  782.       end
  783.       return
  784.     end
  785.     if Input.trigger?(Input::C) and $game_party.recipes.size != 0
  786.       @recipe = @craft_window.recipe
  787.       if @recipe != nil
  788.         if @recipe.have
  789.           @yes_no_window.active = true
  790.           @craft_window.active = false
  791.         else
  792.           $game_system.se_play($data_system.buzzer_se)
  793.           return
  794.         end
  795.       else
  796.         $game_system.se_play($data_system.buzzer_se)
  797.         return
  798.       end
  799.     end
  800.   end

  801.   #--------------------------------------------------------------------------
  802.   def confirm_update
  803.     @craft_index = @craft_window.index
  804.     @confirm_window.visible = true
  805.     @confirm_window.z = 1500
  806.     @yes_no_window.visible = true
  807.     @yes_no_window.active = true
  808.     @yes_no_window.z = 1500
  809.     @yes_no_window.update
  810.     string = "合成 " + @recipe.name + "?"
  811.     cw = @confirm_window.contents.text_size(string).width
  812.     center = @confirm_window.contents.width/2 - cw /2
  813.     unless @drawn
  814.       @confirm_window.contents.draw_text(center, 0, cw, 30, string)
  815.       @drawn = true
  816.     end
  817.     if Input.trigger?(Input::C)
  818.       if @yes_no_window.index == 0
  819.         $game_system.se_play($data_system.decision_se)
  820.         @recipe.make
  821.         $game_system.se_play($data_system.save_se)
  822.         $scene=Scene_Craft.new(@craft_type,@craft_index)
  823.       else
  824.         $game_system.se_play($data_system.cancel_se)
  825.         $scene=Scene_Craft.new(@craft_type,@craft_index)
  826.       end
  827.     end
  828.     if Input.trigger?(Input::B)
  829.       $game_system.se_play($data_system.cancel_se)
  830.       $scene=Scene_Craft.new(@craft_type,@craft_index)
  831.     end
  832.   end

  833. end # of Scene_Craft

  834. #==============================================================================
  835. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  836. # 欢迎访问[url]www.66RPG.com[/url]
  837. # 梦想世界,在你手中
  838. #==============================================================================
复制代码
梦石
0
星屑
75
在线时间
73 小时
注册时间
2015-7-10
回帖
26
 楼主| 发表于 2015-9-13 14:36:35 | 显示全部楼层
各位大神,必要无视我好吗,在线等,挺急的
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部