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

Project1

 找回密码
 注册会员
搜索
查看: 11631|回复: 24

物品合成系统物品分类增强版 v1.1 [8月17日更新]

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
65
在线时间
400 小时
注册时间
2005-10-24
帖子
634
发表于 2005-12-31 22:28:32 | 显示全部楼层 |阅读模式

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

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

x
物品合成系统完美版原作者:Deke



(-_-||)废话不多说...介绍一下这个系统的功能(抑或是这个增强版扩展的功能?)
原来的完美版脚本的制作界面是把所有东西都放在同一个界面。
这个完美版增强版脚本可以自定义不同分类界面,召唤特定界面时只会显示特定分类的成品。
例如可以把物品分成裁缝成品,制皮成品等几类,召唤特定界面,就只会显示本分类成品。
当然也可以召唤全物品界面,显示全部成品。



v1.1更新说明:
修正了返回界面时不显示成品的BUG
修正了材料大于8个不显示的BUG
描绘物品美化
自动检测能否合成




使用方法:
复制全部脚本内容,在Main脚本之前按insert,插入此脚本全部内容



设置方法:
看脚本注释说明



冲突可能:
物品合成系统完美版,都用了这个就不用那个了吧◎_◎
其余未知,冲突可能不大



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

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

  155. #updates to Game_Party class

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  522. end #of Window_CraftResult

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

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

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

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

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

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

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

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

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

  725. end # of Scene_Craft

  726. #==============================================================================
  727. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  728. # 欢迎访问www.66RPG.com
  729. # 梦想世界,在你手中
  730. #==============================================================================
复制代码

Lv1.梦旅人

梦石
0
星屑
65
在线时间
400 小时
注册时间
2005-10-24
帖子
634
 楼主| 发表于 2005-12-31 22:28:32 | 显示全部楼层 |阅读模式

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

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

x
物品合成系统完美版原作者:Deke



(-_-||)废话不多说...介绍一下这个系统的功能(抑或是这个增强版扩展的功能?)
原来的完美版脚本的制作界面是把所有东西都放在同一个界面。
这个完美版增强版脚本可以自定义不同分类界面,召唤特定界面时只会显示特定分类的成品。
例如可以把物品分成裁缝成品,制皮成品等几类,召唤特定界面,就只会显示本分类成品。
当然也可以召唤全物品界面,显示全部成品。



v1.1更新说明:
修正了返回界面时不显示成品的BUG
修正了材料大于8个不显示的BUG
描绘物品美化
自动检测能否合成




使用方法:
复制全部脚本内容,在Main脚本之前按insert,插入此脚本全部内容



设置方法:
看脚本注释说明



冲突可能:
物品合成系统完美版,都用了这个就不用那个了吧◎_◎
其余未知,冲突可能不大



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

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

  155. #updates to Game_Party class

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  522. end #of Window_CraftResult

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

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

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

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

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

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

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

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

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

  725. end # of Scene_Craft

  726. #==============================================================================
  727. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  728. # 欢迎访问www.66RPG.com
  729. # 梦想世界,在你手中
  730. #==============================================================================
复制代码

Lv4.逐梦者

梦石
1
星屑
8785
在线时间
4363 小时
注册时间
2005-10-22
帖子
6722

开拓者贵宾

发表于 2005-12-31 23:18:00 | 显示全部楼层
偶依旧冲突着...继续郁闷地自己造脚本中-_-0
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
65
在线时间
400 小时
注册时间
2005-10-24
帖子
634
 楼主| 发表于 2005-12-31 23:39:49 | 显示全部楼层
以下引用orochi2k于2005-12-31 15:18:00的发言:

偶依旧冲突着...继续郁闷地自己造脚本中-_-0

这个脚本的冲突可能性貌似很小...只是Game_Temp和Game_Party的初始化方法用了别名,其余都是新类..
整合也应该很容易...
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
140
在线时间
0 小时
注册时间
2005-12-20
帖子
4
发表于 2006-1-1 00:25:11 | 显示全部楼层
   可以用!谢谢楼主!

   但有一个问题。在每次调用合成窗口会出现类似的对话框




如果是分类的也是差不多这类提示会闪现一下再进入窗口。有什么办法解决吗?
66RPG---中国人自己的游戏制作网站
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
65
在线时间
400 小时
注册时间
2005-10-24
帖子
634
 楼主| 发表于 2006-1-1 00:29:42 | 显示全部楼层
(-_-||)
非常不好意思............
那是我为了测试DEBUG用的东东.............
立刻编辑一下主题..改回正确的
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
140
在线时间
0 小时
注册时间
2005-12-20
帖子
4
发表于 2006-1-1 03:01:12 | 显示全部楼层
     个人验证,这套脚本运行现在已经没有问题。很实用!

     至今暂未见脚本冲突。

     谢谢叶子为我们提供如此好的脚本。
66RPG---中国人自己的游戏制作网站
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
208
在线时间
8 小时
注册时间
2005-12-14
帖子
3
发表于 2006-1-6 02:29:38 | 显示全部楼层
请问有没有能够单独显示类型1(道具)的状态呢?
本脚本似乎只有全部.防具.武器这三种单独形式的物品分类状态。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

论坛御王核潜艇

梦石
0
星屑
50
在线时间
50 小时
注册时间
2006-1-3
帖子
637

冬季迷宫创意大赛冠军

发表于 2006-1-6 02:45:34 | 显示全部楼层
有的.你在显示后面不加括号和数字就行了
默默存在,畅游于各水域
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
65
在线时间
400 小时
注册时间
2005-10-24
帖子
634
 楼主| 发表于 2006-1-6 13:55:43 | 显示全部楼层
以下引用z391xyrs于2006-1-5 18:29:38的发言:

请问有没有能够单独显示类型1(道具)的状态呢?
本脚本似乎只有全部.防具.武器这三种单独形式的物品分类状态。

汗...是不是因为注释比较乱呢...
先看这个:
# 注意:不要弄混淆“成品种类”和“成品分类”
# 成品种类是指成品是普通物品(0),防具(1)或武器(2)
# 成品分类是指此物品的自定义分类
例如:
$scene = Scene_Craft.new(10)
召唤出来的界面只会显示成品分类(注意!不是种类)为10的物品。
成品分类你分多少类也可以,没有限制。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-3-29 06:09

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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