查看: 1813|回复: 2

[已经过期] 怎样显示局部变量在合成界面?在线等,挺急的

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

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

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

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

经过一天的努力,终于做出了通过合成配方实现:合成需要熟练度

现在还留有一个问题,局部变量  【need】和 【increment】无法显示在合成界面。

求教,各位大神帮忙!!!

QQ截图20150913042143.png

  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.   attr_accessor       :recipes

  242.   alias crafting_party_initialize initialize

  243.   def initialize
  244.     crafting_party_initialize
  245.     @recipes=[]
  246.   end

  247.   #----------------------------------------------------------------------
  248.   def know?(recipe, version = 1)     #系统理解配方的;
  249.     unless recipe.is_a?(Game_Recipe)
  250.       recipe = get_recipe_from_master_list(recipe, version)
  251.     end
  252.     return $game_party.recipes.include?(recipe)
  253.   end

  254. #----------------------------------------------------------------------
  255.   def learn_recipe(recipe , version = 1)  #配方学习的类
  256.     unless recipe.is_a?(Game_Recipe)
  257.       recipe = get_recipe_from_master_list(recipe, version)
  258.     end
  259.     if recipe.is_a?(Game_Recipe)
  260.       unless know?(recipe)
  261.         @recipes.push(recipe)
  262.       end
  263.     end
  264.   end

  265. #----------------------------------------------------------------------
  266.   def forget_recipe(recipe , version = 1) #遗忘配方的类
  267.     if !recipe.is_a?(Game_Recipe)
  268.       recipe = get_recipe_from_master_list(recipe, version)
  269.     end
  270.     if recipe.is_a?(Game_Recipe)
  271.       for i in [email]0...@recipes.size[/email]
  272.         if recipe == @recipes[i]
  273.           index = i
  274.           break
  275.         end
  276.       end
  277.       if index != nil
  278.         @recipes.delete(@recipes[index])
  279.       end
  280.     end
  281.   end

  282. #----------------------------------------------------------------------
  283.   def get_recipe_from_master_list(item, version)
  284.     index = nil
  285.     for i in 0...$game_temp.recipe_list.size
  286.       if item[0] == $game_temp.recipe_list[i].result and item[1] ==$game_temp.recipe_list[i].result_type
  287.         version -= 1
  288.         if version == 0
  289.           index = i
  290.           break
  291.         end
  292.       end
  293.     end
  294.     if index.is_a?(Integer)
  295.       return ($game_temp.recipe_list[index])
  296.     else
  297.       return false
  298.     end
  299.   end

  300. end # of Game_Party updates

  301. #================================
  302. class Game_Recipe

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

  323. #----------------------------------------------------------------------
  324.   def name  #配方名称
  325.     case @result_type #分别属于成品种类
  326.       when 0
  327.         name = $data_items[@result].name #配方名称来源于成品的名称,属于物品类
  328.       when 1
  329.         name = $data_armors[@result].name #配方名称来源于成品的名称,属于武器类
  330.       when 2
  331.         name = $data_weapons[@result].name #配方名称来源于成品的名称,属于防具类
  332.     end
  333.     return name
  334.   end

  335. #----------------------------------------------------------------------

  336.   def item #成品物品
  337.     case @result_type
  338.       when 0
  339.         item = $data_items[@result] #成品物品编号等于 物品编号
  340.       when 1
  341.         item = $data_armors[@result] #成品物品编号等于 武器编号
  342.       when 2
  343.         item = $data_weapons[@result] #成品物品编号等于 防具编号
  344.     end
  345.     return item
  346.   end

  347. #----------------------------------------------------------------------
  348.   def have #初始化,用于判断配方所需材料是否齐全
  349.     have_all = true #材料齐全
  350.     for i in [email]0...@ingredients.size[/email]
  351.       case @ingredient_types[i]
  352.         when 0
  353.           if $game_party.item_number(@ingredients[i]) < @quantities[i]
  354.             have_all=false
  355.           end
  356.         when 1
  357.           if $game_party.armor_number(@ingredients[i]) < @quantities[i]
  358.             have_all=false
  359.           end
  360.         when 2
  361.           if $game_party.weapon_number(@ingredients[i]) < @quantities[i]
  362.             have_all=false
  363.           end
  364.       end
  365.     end
  366.     return have_all
  367.   end
  368.   
  369. #----------------------------------------------------------------------
  370.   def needs
  371.     needs_all = true
  372.     case @result_type
  373.       when 0
  374.         if $game_variables[751] < @need
  375.           needs_all=false
  376.         end
  377.       when 1
  378.         if $game_variables[754] < @need
  379.           needs_all=false
  380.         end
  381.       when 2
  382.         if $game_variables[753] < @need
  383.           needs_all=false
  384.         end
  385.       end
  386.     return needs_all
  387.   end

  388. #----------------------------------------------------------------------
  389.   def decrement #初始化材料的消耗数量
  390.     for i in [email]0...@ingredients.size[/email]
  391.       case @ingredient_types[i]
  392.       when 0
  393.         $game_party.lose_item(@ingredients[i], @quantities[i])
  394.       when 1
  395.         $game_party.lose_armor(@ingredients[i], @quantities[i])
  396.       when 2
  397.         $game_party.lose_weapon(@ingredients[i], @quantities[i])
  398.       end
  399.     end
  400.   end

  401. #----------------------------------------------------------------------
  402.   def make #初始化  物品合成
  403.     if have and needs #如果材料齐全
  404.       case @result_type #根据成品种类制造
  405.       when 0 #物品
  406.         if @craft_type  == 7 #如果成品的自定义类型为  7
  407.         $game_party.gain_item(@result, 10) #获得这样的成品 10个
  408.         elsif @craft_type  == 4 #如果成品的自定义类型为  4
  409.         $game_party.gain_item(@result, 5) ##获得这样的成品 5个
  410.         else
  411.         $game_party.gain_item(@result, 1)
  412.         $game_variables[751] += @increment
  413.         end
  414.       when 1 #武器
  415.         $game_party.gain_armor(@result, 1)
  416.         $game_variables[754] += @increment
  417.       when 2 #防具
  418.         $game_party.gain_weapon(@result, 1)
  419.         $game_variables[753] += @increment
  420.       end
  421.       decrement
  422.     end
  423.   end

  424. #----------------------------------------------------------------------
  425.   def == (recipe)
  426.     if recipe.is_a?(Game_Recipe)
  427.       equal = true
  428.       if recipe.ingredients != self.ingredients
  429.         equal = false
  430.       end
  431.       if recipe.ingredient_types != self.ingredient_types
  432.         equal = false
  433.       end
  434.       if recipe.quantities != self.quantities
  435.         equal = false
  436.       end
  437.       if recipe.result != self.result
  438.         equal=false
  439.       end
  440.       if recipe.result_type != self.result_type
  441.         equal = false
  442.       end
  443.       if recipe.need != self.need  #老王添加
  444.         equal = false
  445.       end
  446.     else
  447.       equal = false
  448.     end
  449.     return equal
  450.   end

  451. end # of Game_Recipe class

  452. #===================================

  453. class Window_Craft < Window_Selectable
  454.   attr_reader :data #声明数据
  455.   #--------------------------------------------------------------------------
  456.   def initialize(craft_type=0)
  457.     @craft_type = craft_type
  458.     super(0, 64-64, 240, 416+64)
  459.     @column_max = 1
  460.     refresh
  461.     self.index = 0
  462.   end

  463.   #--------------------------------------------------------------------------
  464.   def recipe
  465.     return @data[self.index]
  466.   end

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

  510.   #--------------------------------------------------------------------------
  511.   #def draw_item(index)
  512.   #  recipe = @data[index]
  513.   #  self.contents.font.color = recipe.have ? normal_color : disabled_color
  514.   #  x = 16
  515.   #  y = index * 32
  516.   #  self.contents.draw_text(x , y, self.width-32, 32, recipe.name, 0)
  517.   #end

  518.   #--------------------------------------------------------------------------
  519.   # ● 描绘物品名
  520.   #     item : 物品
  521.   #     x    : 描画目标 X 坐标
  522.   #     y    : 描画目标 Y 坐标
  523.   #--------------------------------------------------------------------------
  524.   def draw_item_name(item, x, y, able = true)
  525.     if item == nil
  526.       return
  527.     end
  528.     if !able
  529.       self.contents.font.color = disabled_color
  530.     end
  531.     bitmap = RPG::Cache.icon(item.icon_name)
  532.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  533.     self.contents.draw_text(x + 28, y, 212, 32, item.name)
  534.     self.contents.font.color = normal_color
  535.   end

  536.   #--------------------------------------------------------------------------
  537.   def update_help
  538.     current_recipe = recipe
  539.     if current_recipe.is_a?(Game_Recipe)
  540.     case current_recipe.result_type
  541.       when 0
  542.         item = $data_items[current_recipe.result]
  543.         #description = $data_items[current_recipe.result].description
  544.       when 1
  545.         item = $data_armors[current_recipe.result]
  546.         #description = $data_armors[current_recipe.result].description
  547.       when 2
  548.         item = $data_weapons[current_recipe.result]
  549.         #description = $data_weapons[current_recipe.result].description
  550.       end
  551.     else
  552.       #description = ""
  553.     end
  554.     @help_window.set_text(item)
  555.     #校正帮助窗口位置
  556.     @help_window.set_pos(self.x-64,self.y+16,self.width,self.oy,self.index,@column_max)
  557.     # @help_window.set_text(description)
  558.     @help_window.update
  559.   end

  560. end # of Window_Craft

  561. #=======================================
  562. class Window_CraftResult < Window_Base

  563.   #--------------------------------------------------------------------------
  564.   def initialize
  565.     super(240, 64-64, 400, 184+64)
  566.     self.contents = Bitmap.new(width - 32, height - 32)
  567.     self.contents.font.name = ["黑体", "楷体", "宋体"] # = $fontface.is_a?(String) ? $fontface :

  568. $defaultfonttype
  569.     self.contents.font.size = 18 # = 20
  570.     @result = nil
  571.     @type = nil
  572.   end

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

  625. #----------------------------------------------------------------------
  626.   def set_result(result , type)
  627.     @result = result
  628.     @type = type
  629.     refresh
  630.   end

  631. end #of Window_CraftResult

  632. #=======================================
  633. class Window_CraftIngredients < Window_Base

  634.   #--------------------------------------------------------------------------
  635.   def initialize
  636.     super(240, 248, 400, 232)
  637.     self.contents = Bitmap.new(width - 32, height - 32)
  638.     self.contents.font.name = ["黑体", "楷体", "宋体"] # = $fontface.is_a?(String) ? $fontface :

  639. $defaultfonttype
  640.     self.contents.font.size = 18 # = 20
  641.     @ingredients = []
  642.     @types = []
  643.     @quantities = []
  644.     @item = nil
  645.     @count = 0
  646.     @counter = 0
  647.     @real_oy = 0
  648.   end

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

  675.   #--------------------------------------------------------------------------
  676.   def set_ingredients(ingredients , types, quantities)
  677.     @ingredients = ingredients
  678.     @types = types
  679.     @quantities = quantities
  680.     refresh
  681.     if @ingredients.size > 7
  682.       self.oy = -52
  683.       @real_oy = 0
  684.     else
  685.       self.oy = 0
  686.     end
  687.   end

  688.   def update
  689.     super
  690.     @counter += 1
  691.     if @ingredients.size > 7 and @counter > 30
  692.       @real_oy = (@real_oy + 1) % ((@ingredients.size - 3) * 26)
  693.       self.oy = @real_oy - 52
  694.     end
  695.   end

  696. end # of Window_CraftIngredients

  697. #======================================
  698. class Scene_Craft

  699.   #--------------------------------------------------------------------------
  700.   # @craft_type:物品种类,0就是全部
  701.   def initialize(craft_type=0,craft_index=0)
  702.     @craft_index=craft_index
  703.     @craft_type = craft_type
  704.   end

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

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

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

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

  836. end # of Scene_Craft

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

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

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

发表于 2015-9-14 15:19:59 | 显示全部楼层
看了一下脚本。。有点乱。。稍微能理解一点。。不过只能提供思路:
首先这两个变量在【Window_CraftResult】里面没有赋值(还是窝看漏了?)所以即使强行显示也是nil弹错,
PS:【Scene】里面的(label_window)从根本上就没传这两个数字进去draw_text,所以并不会显示……

然后就是好像现有和需求数量的窗口内容会根据左侧选项切换发生变化(?),
如果这样的话,那最后的【Scene】里面的(label_window)最好不要这样写,
另外写一个Window_Base子类,在refresh里传这两个数值过去刷新,然后再调用refresh……
回复

使用道具 举报

梦石
0
星屑
75
在线时间
73 小时
注册时间
2015-7-10
回帖
26
 楼主| 发表于 2015-9-14 19:04:27 | 显示全部楼层
cinderelmini 发表于 2015-9-14 15:19
看了一下脚本。。有点乱。。稍微能理解一点。。不过只能提供思路:
首先这两个变量在【Window_CraftResult ...

  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

我能用$game_variables[]代替@need 吗

点评

不,两处不同的类的赋值用法不一样,唔…………还是坐等触手来看看吧~  发表于 2015-9-15 14:42
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部