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

Project1

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

能不能告诉我怎么做合成系统

 关闭 [复制链接]
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
1 小时
注册时间
2007-2-23
帖子
10
跳转到指定楼层
1
发表于 2007-7-4 18:45:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
1 小时
注册时间
2007-2-23
帖子
10
2
 楼主| 发表于 2007-7-4 18:45:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽

Lv1.梦旅人

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

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

  154. #updates to Game_Party class

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

  224. #================================
  225. class Game_Recipe

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

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

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

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

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

  343. #===================================

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

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

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

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

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

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

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

  521. end #of Window_CraftResult

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

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

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

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

  588. #======================================
  589. class Scene_Craft

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

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

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

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

  724. end # of Scene_Craft

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

系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-7-3
帖子
21
4
发表于 2007-7-4 18:47:46 | 只看该作者
虽然现在不需要`但以后可能会用到,雪藏了。
“对不起,这种时刻,我不知道该用怎样的表情面对你。 ” “只要微笑就可以了…… ”
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
1 小时
注册时间
2007-2-23
帖子
10
5
 楼主| 发表于 2007-7-4 18:51:56 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
15 小时
注册时间
2007-2-18
帖子
2464
6
发表于 2007-7-4 18:56:27 | 只看该作者
没快捷键
呼出的方法是
$scene = Scene_Craft.new(1)

这段你可以加在事件中,比如建立一个物品叫合成壶,对应个公共事件中输入那段脚本

具体的看脚本前解说
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-6-22
帖子
23
7
发表于 2007-7-4 19:59:56 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-8-23
帖子
69
8
发表于 2007-8-28 04:37:18 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-6-24 06:17

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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