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

Project1

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

[已经过期] xp整合系统(20项脚本)中的14合成物品使用出错

[复制链接]

Lv3.寻梦者

梦石
3
星屑
261
在线时间
223 小时
注册时间
2012-8-18
帖子
143
跳转到指定楼层
1
发表于 2014-7-1 22:21:12 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
系统见https://rpg.blue/forum.php?mo ... amp;authorid=298774
我使用$scene = Scene_Craft.new召唤界面时系统显示出错了,说是296行出错,范例中也不能召唤出界面,请问如何成功召唤出界面,如何改这个脚本?

脚本
RUBY 代码复制
  1. #==============================================================================  
  2. # Sample master list for crafting script
  3. # written by Deke
  4. #============================================================================================
  5. # 简介:
  6. # 这是一个很不错的合成物品系统,可以通过游戏的过程,不断学习可以合成的
  7. # 物品方法。
  8. #
  9. # 使用方法:
  10. # 1、召唤界面:使用脚本$scene = Scene_Craft.new
  11. #
  12. # 2、学习合成:$game_party.learn_recipe(合成项目)
  13. #
  14. # 3、合成定义:
  15. # 这个合成脚本可以定义两种合成物品。一种是预先定义好了的,就像下面这样,
  16. # 直接写在这里就可以,另一种是在学习之前现场定义。
  17. #
  18. # 4、举例
  19. #  4.1、学会recipe_list[1]定义的合成:$game_party.learn_recipe($game_temp.recipe_list[1])
  20. #       注意,一行如果输入不下,在(的后面或[的后面按回车换行,否则可能出错
  21. #
  22. #  4.2、在游戏中临时定义一种合成,让玩家学会。使用事件中的脚本如下,   
  23. #  脚本:
  24. #    材料 = [$game_variables[1],$game_variables[2]]  #——材料编号是变量1、2的编号
  25. #    材料种类 = [0,0]                                #——材料是物品
  26. #    材料数量 = [$game_variables[3],$game_variables[4]]  #——需要材料数量是变量3、4的编号
  27. #    成品 = $game_variables[5]                       #——获得结果编号是5
  28. #    成品种类 = 1                                    #——成品是防具类
  29. #    $game_party.learn_recipe(Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类))
  30. #===========================================================================================
  31. class Game_Temp
  32.   attr_reader :recipe_list  
  33.   alias crafting_temp_initialize initialize
  34.   def initialize
  35.     crafting_temp_initialize
  36.     @recipe_list=[]
  37.     get_recipe_list
  38.   end  
  39.   def get_recipe_list   
  40.     ##########################################################################
  41.     # 0 号合成物品设定 (物品小药水×2 + 中药水 = 大药水)
  42.     ##########################################################################
  43.     材料 = [1, 2]             # 需要材料的数据库编号
  44.     材料种类 = [0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  45.     材料数量 = [2, 1]         # 需要材料的数量
  46.     成品 = 3                  # 获得物品编号
  47.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  48.     @recipe_list[1] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  49.  
  50.     ##########################################################################
  51.     # 1 号合成物品设定 (武器铜剑、铁剑、钢剑各1 = 密切斯特剑)
  52.     ##########################################################################
  53.     材料 = [1, 2, 3]          # 需要材料的数据库编号
  54.     材料种类 = [2, 2, 2]      # 需要材料的种类,0是普通物品,1是防具,2是武器
  55.     材料数量 = [3, 2, 1]      # 需要材料的数量
  56.     成品 = 4                  # 获得物品编号
  57.     成品种类 = 2              # 获得物品种类,0是普通物品,1是防具,2是武器
  58.     @recipe_list[2] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  59.  
  60.     ##########################################################################
  61.     # 2 号合成物品设定 (物品力量之石×2 + 防具钢盾×1 = 密切斯特盾)
  62.     ##########################################################################
  63.     材料 = [13, 3]            # 需要材料的数据库编号
  64.     材料种类 = [0, 1]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  65.     材料数量 = [2, 1]         # 需要材料的数量
  66.     成品 = 4                  # 获得物品编号
  67.     成品种类 = 1              # 获得物品种类,0是普通物品,1是防具,2是武器
  68.     @recipe_list[3] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  69.  
  70.     ##########################################################################
  71.     # 2 号合成物品设定 (金疮药×2 + 仙狐涎×1 = 大粒丸)
  72.     ##########################################################################
  73.     材料 = [1, 2]             # 需要材料的数据库编号
  74.     材料种类 = [0, 0]         # 需要材料的种类,0是普通物品,1是防具,2是武器
  75.     材料数量 = [2, 1]         # 需要材料的数量
  76.     成品 = 3                  # 获得物品编号
  77.     成品种类 = 0              # 获得物品种类,0是普通物品,1是防具,2是武器
  78.     @recipe_list[4] = Game_Recipe.new(材料,材料种类, 材料数量,成品,成品种类)
  79.  
  80.   end # of get_recipe_list method
  81. end # of updates to Game_Temp Class
  82. #================================
  83. # CRAFTING PROGRAM
  84. #----------------------------------------------------------------
  85. #-written by Deke
  86. #-yes_no window code created by Phsylomortis
  87. #----------------------------------------------------------------
  88. #================================
  89. #updates to Game_Party class
  90. class Game_Party
  91.  
  92.   attr_accessor       :recipes
  93.  
  94.   alias crafting_party_initialize initialize
  95.  
  96.   def initialize
  97.     crafting_party_initialize
  98.     @recipes=[]
  99.   end
  100.  
  101.   #----------------------------------------------------------------------
  102.   def know?(recipe, version = 1)
  103.     unless recipe.is_a?(Game_Recipe)
  104.       recipe = get_recipe_from_master_list(recipe, version)
  105.     end
  106.     return $game_party.recipes.include?(recipe)
  107.   end
  108.  
  109. #----------------------------------------------------------------------
  110.   def learn_recipe(recipe , version = 1)
  111.     unless recipe.is_a?(Game_Recipe)
  112.       recipe = get_recipe_from_master_list(recipe, version)
  113.     end
  114.     if recipe.is_a?(Game_Recipe)
  115.       unless know?(recipe)
  116.         @recipes.push(recipe)
  117.       end
  118.     end
  119.   end
  120.  
  121. #----------------------------------------------------------------------
  122.   def forget_recipe(recipe , version = 1)
  123.     if !recipe.is_a?(Game_Recipe)
  124.       recipe = get_recipe_from_master_list(recipe, version)
  125.     end
  126.     if recipe.is_a?(Game_Recipe)
  127.       for i in [email]0...@recipes.size[/email]
  128.         if recipe == @recipes
  129.           index = i
  130.           break
  131.         end
  132.       end
  133.       if index != nil
  134.         @recipes.delete(@recipes[index])
  135.       end
  136.     end
  137.   end
  138.  
  139. #----------------------------------------------------------------------
  140.   def get_recipe_from_master_list(item, version)
  141.     index = nil
  142.     for i in 0...$game_temp.recipe_list.size
  143.       if item[0] == $game_temp.recipe_list.result and item[1] ==$game_temp.recipe_list.result_type
  144.         version -= 1
  145.         if version == 0
  146.           index = i
  147.           break
  148.         end
  149.       end
  150.     end
  151.     if index.is_a?(Integer)
  152.       return ($game_temp.recipe_list[index])
  153.     else
  154.       return false
  155.     end
  156.   end
  157.  
  158. end # of Game_Party updates
  159. #================================
  160. class Game_Recipe
  161.   attr_reader :ingredients
  162.   attr_reader :quantities
  163.   attr_reader :result
  164.   attr_reader :result_type
  165.   attr_reader :ingredient_types
  166.  
  167. #----------------------------------------------------------------------
  168.   def initialize( ingredients, ingredient_types, quantities, result, result_type)
  169.     @ingredients = ingredients
  170.     @ingredient_types = ingredient_types
  171.     @quantities = quantities
  172.     @result = result
  173.     @result_type = result_type
  174.   end
  175.  
  176. #----------------------------------------------------------------------
  177.   def name
  178.     case @result_type
  179.       when 0
  180.         name = $data_items[@result].name
  181.       when 1
  182.         name = $data_armors[@result].name
  183.       when 2
  184.         name = $data_weapons[@result].name
  185.     end
  186.     return name
  187.   end
  188.  
  189. #----------------------------------------------------------------------
  190.   def have
  191.     have_all = true
  192.     for i in [email]0...@ingredients.size[/email]
  193.       case @ingredient_types
  194.         when 0
  195.           if $game_party.item_number(@ingredients) < @quantities
  196.             have_all=false
  197.           end
  198.         when 1
  199.           if $game_party.armor_number(@ingredients) < @quantities
  200.             have_all=false
  201.           end
  202.         when 2
  203.           if $game_party.weapon_number(@ingredients) < @quantities
  204.             have_all=false
  205.           end
  206.       end
  207.     end
  208.     return have_all
  209.   end
  210. #----------------------------------------------------------------------
  211.   def decrement
  212.     for i in [email]0...@ingredients.size[/email]
  213.       case @ingredient_types
  214.       when 0
  215.         $game_party.lose_item(@ingredients, @quantities)
  216.       when 1
  217.         $game_party.lose_armor(@ingredients, @quantities)
  218.       when 2
  219.         $game_party.lose_weapon(@ingredients, @quantities)
  220.       end
  221.     end
  222.   end
  223. #----------------------------------------------------------------------
  224.   def make
  225.     if have
  226.       case @result_type
  227.       when 0
  228.         $game_party.gain_item(@result, 1)
  229.       when 1
  230.         $game_party.gain_armor(@result, 1)
  231.       when 2
  232.         $game_party.gain_weapon(@result, 1)
  233.       end
  234.       decrement
  235.     end
  236.   end
  237.  
  238. #----------------------------------------------------------------------
  239.   def == (recipe)
  240.     if recipe.is_a?(Game_Recipe)
  241.       equal = true
  242.       if recipe.ingredients != self.ingredients
  243.         equal = false
  244.       end
  245.       if recipe.ingredient_types != self.ingredient_types
  246.         equal = false
  247.       end
  248.       if recipe.quantities != self.quantities
  249.         equal = false
  250.       end
  251.       if recipe.result != self.result
  252.         equal=false
  253.       end
  254.       if recipe.result_type != self.result_type
  255.         equal = false
  256.       end
  257.     else
  258.       equal = false
  259.     end
  260.     return equal
  261.   end
  262.  
  263. end # of Game_Recipe class
  264. #===================================
  265. class Window_Craft < Window_Selectable
  266.   #--------------------------------------------------------------------------
  267.   def initialize
  268.     super(0, 64 - 32 + 5, 240, 416 - 32 + 16 - 15)
  269.     @column_max = 1
  270.     refresh
  271.     self.index = 0
  272.   end
  273.   #--------------------------------------------------------------------------
  274.   def recipe
  275.     return @data[self.index]
  276.   end
  277.   ############################################################################
  278.   def item
  279.     case @types[self.index]
  280.     when 0
  281.       return $data_items[@ingredients]
  282.     when 1
  283.       return $data_armors[@ingredients]
  284.     when 2
  285.       return $data_weapons[@ingredients]
  286.     end
  287.   end
  288.   ############################################################################
  289.   #--------------------------------------------------------------------------
  290.   def refresh
  291.     if self.contents != nil
  292.       self.contents.dispose
  293.       self.contents = nil
  294.     end
  295.     @data = []
  296.     for i in 0...$game_party.recipes.size
  297.         @data.push($game_party.recipes)
  298.     end
  299.     @item_max = @data.size
  300.     if @item_max > 0
  301.       self.contents = Bitmap.new(width - 32, row_max * 32)
  302.       self.contents.font.name = "黑体" # = "黑体"
  303.       self.contents.font.size = 18 # = 18
  304.       for i in 0...@item_max
  305.         draw_item(i)
  306.       end
  307.     end
  308.   end
  309.   #--------------------------------------------------------------------------
  310.   def draw_item(index)
  311.     recipe = @data[index]
  312.     self.contents.font.color = recipe.have ? normal_color : disabled_color
  313.     x = 16
  314.     y = index * 32
  315.     self.contents.draw_text(x , y, self.width-32, 32, recipe.name, 0)
  316.   end
  317.   #--------------------------------------------------------------------------
  318.   def update_help
  319.     current_recipe = recipe
  320.     if current_recipe.is_a?(Game_Recipe)
  321.     case current_recipe.result_type
  322.       when 0
  323.         description = $data_items[current_recipe.result].description
  324.       when 1
  325.         description = $data_armors[current_recipe.result].description
  326.       when 2
  327.         description = $data_weapons[current_recipe.result].description
  328.       end
  329.     else
  330.       description = ""
  331.     end
  332.     @help_window.set_text(description)
  333.     @help_window.update
  334.   end
  335.  
  336. end # of Window_Craft
  337. #=======================================
  338. class Window_CraftResult < Window_Base
  339.   #--------------------------------------------------------------------------
  340.   def initialize
  341.     super(240, 64 - 32 + 5, 400, 184)
  342.     self.contents = Bitmap.new(width - 32, height - 32)
  343.     self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  344.     self.contents.font.size = 18 # = 20
  345.     @result = nil
  346.     @type = nil
  347.   end
  348.   #--------------------------------------------------------------------------
  349.   def refresh
  350.     self.contents.clear
  351.     case @type
  352.       when 0
  353.         item = $data_items[@result]
  354.         if item.recover_hp_rate > item.recover_hp
  355.           hp_string = "HP回复率:"
  356.           hp_stat = item.recover_hp_rate
  357.         else
  358.           hp_string = "HP回复量:"
  359.           hp_stat = item.recover_hp
  360.         end
  361.         if item.recover_sp_rate > item.recover_sp
  362.           sp_string = "SP回复率:"
  363.           sp_stat = item.recover_sp_rate
  364.         else
  365.           sp_string = "SP回复量:"
  366.           sp_stat = item.recover_sp
  367.         end
  368.         @strings = [hp_string, sp_string, "物理防御:" , "仙法防御:", "命中率:", "分散度:"]
  369.         @stats = [hp_stat, sp_stat, item. pdef_f, item.mdef_f, item.hit, item.variance,
  370.                        $game_party.item_number(@result)]
  371.         @bitmap = RPG::Cache.icon(item.icon_name)
  372.       when 1
  373.         item = $data_armors[@result]
  374.         @strings = ["物理防御:", "仙法防御:", "回避修正:", "力量增加:", "灵巧增加:",
  375.                        "速度增加:", "仙攻增加:"]
  376.         @stats = [item.pdef, item.mdef, item.eva, item.str_plus, item.dex_plus,
  377.                     item.agi_plus, item.int_plus, $game_party.armor_number(@result) ]
  378.         @bitmap = RPG::Cache.icon(item.icon_name)
  379.       when 2
  380.         item = $data_weapons[@result]
  381.         @strings =["攻击力:", "物理防御:", "仙法防御:", "力量增加:", "灵巧增加:",
  382.                     "速度增加:", "仙攻增加:"]
  383.         @stats = [item.atk, item.pdef, item.mdef, item.str_plus, item.dex_plus,
  384.                     item.agi_plus, item.int_plus, $game_party.weapon_number(@result) ]
  385.         @bitmap = RPG::Cache.icon(item.icon_name)
  386.     end
  387.     for i in [email]0...@strings.size[/email]
  388.       x = i%2 * 184
  389.       y = i /2 *28 +32
  390.       self.contents.font.color = normal_color
  391.       self.contents.draw_text(x,y,100, 28,@strings)
  392.       self.contents.font.color = system_color
  393.       self.contents.draw_text(x + 110, y, 45, 28, @stats.to_s)
  394.     end
  395.     self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, 24, 24), 255)
  396.     self.contents.font.color= normal_color
  397.     self.contents.draw_text(40, 0, 300, 28, "待合成物品的现有数量:")
  398.     self.contents.font.color = system_color
  399.     count = @stats[@stats.size - 1].to_s
  400.     self.contents.draw_text(294, 0, 45, 28, count )
  401.   end
  402.  
  403. #----------------------------------------------------------------------
  404.   def set_result(result , type)
  405.     @result = result
  406.     @type = type
  407.     refresh
  408.   end
  409. end #of Window_CraftResult
  410. #=======================================
  411. class Window_CraftIngredients < Window_Base
  412.   #--------------------------------------------------------------------------
  413.   def initialize
  414.     super(240, 248 - 32 + 5, 400, 232 - 32 + 16 - 15)
  415.     self.contents = Bitmap.new(width - 32, height - 32)
  416.     self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  417.     self.contents.font.size = 18 # = 20
  418.     @ingredients = []
  419.     @types = []
  420.     @quantities = []
  421.     @item = nil
  422.     @count = 0
  423.   end
  424.   #--------------------------------------------------------------------------
  425.   def refresh
  426.     self.contents.clear
  427.     for i in [email]0...@ingredients.size[/email]
  428.       case @types
  429.       when 0
  430.         @item = $data_items[@ingredients]
  431.         @count = $game_party.item_number(@ingredients)
  432.       when 1
  433.         @item = $data_armors[@ingredients]
  434.         @count = $game_party.armor_number(@ingredients)
  435.       when 2
  436.         @item = $data_weapons[@ingredients]
  437.         @count = $game_party.weapon_number(@ingredients)
  438.       end
  439.       y = i *26
  440.       self.contents.blt(0, y, RPG::Cache.icon(@item.icon_name), Rect.new(0, 0, 24, 24), 255)
  441.       self.contents.font.color = @count >= @quantities ? normal_color : disabled_color
  442.       self.contents.draw_text(30, y, 280, 28, @item.name)
  443.       self.contents.draw_text(300, y, 45, 28, @quantities.to_s)
  444.       self.contents.font.color = system_color
  445.       self.contents.draw_text(245, y, 45, 28, @count.to_s )     
  446.     end
  447.   end
  448.   #--------------------------------------------------------------------------
  449.   def set_ingredients(ingredients , types, quantities)
  450.     @ingredients = ingredients
  451.     @types = types
  452.     @quantities = quantities
  453.     refresh
  454.   end
  455. end # of Window_CraftIngredients
  456. #======================================
  457. class Scene_Craft
  458.   #--------------------------------------------------------------------------
  459.   def initialize(craft_index=0)
  460.     @craft_index=craft_index
  461.   end
  462.  
  463.   #--------------------------------------------------------------------------
  464.   def main
  465.     @craft_window = Window_Craft.new
  466.     @craft_window.index=@craft_index
  467.     @confirm_window = Window_Base.new(120, 188, 400, 64)
  468.     @confirm_window.contents = Bitmap.new(368, 32)
  469.     @confirm_window.contents.font.name = "黑体"
  470.     @confirm_window.contents.font.size = 20
  471.     @help_window = Window_Help.new
  472.     @craft_window.help_window = @help_window
  473.     @result_window=Window_CraftResult.new
  474.     @ingredients_window=Window_CraftIngredients.new
  475.     @yes_no_window = Window_Command.new(100, ["确定", "放弃"])
  476.     @confirm_window.visible = false
  477.     @confirm_window.z = 1500
  478.     @yes_no_window.visible = false
  479.     @yes_no_window.active = false
  480.     @yes_no_window.index = 1
  481.     @yes_no_window.x = 270
  482.     @yes_no_window.y = 252
  483.     @yes_no_window.z = 1500
  484.     @label_window = Window_Base.new(450,200,190,52)
  485.     @label_window.contents=Bitmap.new(@label_window.width - 32,@label_window.height - 32)
  486.     @label_window.contents.font.size=20
  487.     @label_window.contents.font.color = @label_window.normal_color
  488.     @label_window.contents.font.name = "黑体"
  489.     @label_window.contents.draw_text(0, 0, @label_window.contents.width, 20, "  现有   需要")
  490.     Graphics.transition
  491.     loop do
  492.       Graphics.update
  493.       Input.update
  494.       update
  495.       if $scene != self
  496.         break
  497.       end
  498.     end
  499.     Graphics.freeze
  500.     @help_window.dispose
  501.     @craft_window.dispose
  502.     @result_window.dispose
  503.     @ingredients_window.dispose
  504.     @confirm_window.dispose
  505.     @yes_no_window.dispose
  506.     @label_window.dispose
  507.   end
  508.   #--------------------------------------------------------------------------
  509.   def update
  510.     @craft_window.update
  511.     @ingredients_window.update
  512.     if $game_party.recipes.size > 0
  513.       @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
  514.       @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
  515.                                                            @craft_window.recipe.ingredient_types,
  516.                                                            @craft_window.recipe.quantities)
  517.     end
  518.     if @craft_window.active
  519.       update_craft
  520.       return
  521.     end
  522.     if @yes_no_window.active
  523.       confirm_update
  524.       return
  525.     end
  526.   end
  527.   #--------------------------------------------------------------------------
  528.   def update_craft
  529.     if Input.trigger?(Input::B)
  530.       $game_system.se_play($data_system.cancel_se)
  531.       $scene = Scene_Menu.new(3)
  532.       return
  533.     end
  534.     if Input.trigger?(Input::C) and $game_party.recipes.size != 0
  535.       [url=home.php?mod=space&uid=2564094]@recipe[/url] = @craft_window.recipe
  536.       if @recipe.have
  537.         @yes_no_window.active = true
  538.         @craft_window.active = false
  539.       else
  540.         $game_system.se_play($data_system.buzzer_se)
  541.         return
  542.       end
  543.     end
  544.   end
  545.   #--------------------------------------------------------------------------
  546.   def confirm_update
  547.     @craft_index = @craft_window.index
  548.     @confirm_window.visible = true
  549.     @confirm_window.z = 1500
  550.     @yes_no_window.visible = true
  551.     @yes_no_window.active = true
  552.     @yes_no_window.z = 1500
  553.     @yes_no_window.update
  554.     string = "合成 " + @recipe.name + "?"
  555.     cw = @confirm_window.contents.text_size(string).width
  556.     center = @confirm_window.contents.width/2 - cw /2
  557.     unless @drawn
  558.       @confirm_window.contents.draw_text(center, 0, cw, 30, string)
  559.       @drawn = true
  560.     end
  561.     if Input.trigger?(Input::C)
  562.       if @yes_no_window.index == 0
  563.         $game_system.se_play($data_system.decision_se)
  564.         @recipe.make
  565.         $game_system.se_play($data_system.save_se)
  566.         $scene=Scene_Craft.new(@craft_index)
  567.       else
  568.         $game_system.se_play($data_system.cancel_se)
  569.         $scene=Scene_Craft.new(@craft_index)
  570.       end
  571.     end
  572.     if Input.trigger?(Input::B)
  573.       $game_system.se_play($data_system.cancel_se)
  574.       $scene=Scene_Craft.new(@craft_index)
  575.     end
  576.   end
  577. end # of Scene_Craft
  578. #==============================================================================
  579. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  580. #==============================================================================
取名不慎,我的名字是BobCheng,做游戏什么的,其实是安慰自己而已。
很烧脑的推理游戏
猜不到结局的故事

Lv2.观梦者

梦石
0
星屑
600
在线时间
1118 小时
注册时间
2012-12-24
帖子
831
2
发表于 2014-7-1 23:14:14 | 只看该作者
本帖最后由 江户川洛奇 于 2014-7-1 23:15 编辑

测试了一下,没有LZ所说的问题,可能是脚本冲突吧
LZ可以试试这个
https://rpg.blue/thread-311885-1-1.html

点击签名档去一个神奇的地方
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
3
星屑
261
在线时间
223 小时
注册时间
2012-8-18
帖子
143
3
 楼主| 发表于 2014-7-2 10:06:06 | 只看该作者
江户川洛奇 发表于 2014-7-1 23:14
测试了一下,没有LZ所说的问题,可能是脚本冲突吧
LZ可以试试这个
https://rpg.blue/thread-311885-1-1. ...

我用了那个脚本,但是也出错了,我也就用了这些脚本,哪个冲突了?

取名不慎,我的名字是BobCheng,做游戏什么的,其实是安慰自己而已。
很烧脑的推理游戏
猜不到结局的故事
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
48
在线时间
560 小时
注册时间
2012-12-29
帖子
1075
4
发表于 2014-7-2 10:17:25 | 只看该作者
好像得先学会什么合成
然后你再召唤试试
MOBA以及回合制的一个创新,点这里查看游戏新思路
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
55
在线时间
465 小时
注册时间
2011-4-13
帖子
174
5
发表于 2014-7-2 10:39:17 | 只看该作者
劝楼主还是不要用这个20项脚本整合了,错误太多,运行非常不稳定,而且画面拙劣,排版乱七八糟,做出来的游戏也不会好的。
如果非要使用的话,是任务系统把Game_Party重新定义了,可以把任务系统移到合成系统前面或是用alias重写任务系统的前几行。
不过,这样合成系统还是不能使用,里面有N多低级错误,而且运行效率极低,建议换用别的合成系统
附一张经过N处改动勉强能用的chaochao合成系统(想要的话告诉我):

无标题.png (147.37 KB, 下载次数: 6)

无标题.png

点评

好像你是对的,有可以用的合成系统吗?还是用事件做好?  发表于 2014-7-3 12:32
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
9280
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

6
发表于 2014-7-2 11:48:00 | 只看该作者
  1. =begin
  2. ==============================================================================
  3. ★ Item_Transmute
  4. ------------------------------------------------------------------------------
  5.   配方不公开的物品合成(加强版)
  6.   原作者 Summoner
  7.   By Chd114
  8. ------------------------------------------------------------------------------
  9.   注:该脚本具有至高权威性,可以覆盖任何此脚本的前身脚本!
  10. ==============================================================================
  11. 本脚本以知识共享署名-非商业性使用 3.0 Unported 许可协议进行许可。
  12. 详见 http://creativecommons.org/licenses/by-nc/3.0/
  13. ==============================================================================
  14. 原作者的话:  
  15. 这是一个配方不公开的物品合成,也就是说什么材料可以合成什么物品玩家在
  16. 游戏中的合成界面是不能直接看到的。由于物品的合成配方不是公开的,所以
  17. 玩家需要通过自己探索或从NPC处得到合成配方(当然看攻略也是一种可能)
  18. 例如M&M中的配药水,Diablo II的盒子,NWV中的铁匠铺、Wizard Lab……
  19. 可扩展性:可以加强、扩展的东西应该很多。
  20. 例如:合成需要花费GP、SP甚至XP,合成需要特定器具,合成失败受到伤害,
  21. 某些物品的几率合成、物品图鉴等等。
  22. 有的东西已经注释清楚了,搞懂原理的话,根据自己需要改起来也不会很麻烦。
  23. 个人一下子没时间实现这些,欢迎大家多多修改分享。

  24. Chd114的话(2013年6月9日 11:45:40):
  25. 其实这个脚本的改进思路早在去年此脚本出来之前就有想法了···只不过那个
  26. 时候本人的技术还差了一点所以就没有盲目去弄今天(2013年6月9日 9:33:40)
  27. 花了2小时左右的时间鼓捣了下最后把大部分东西都弄好了

  28. Chd114的话(2013年6月10日 7:59:49):
  29. 吃饭前来了新的灵感,于是就在吃完饭后鼓捣了下下···现在一个配方里的每一种成
  30. 功额外产物和失败额外产物都可以设定独立的出现概率了,而且还加了新功能,
  31. 可以控制开关与变量!(2013年6月10日 8:28:03)

  32. 此脚本冲突可能性:与装备耐久度、随即装备属性之类会导致装备具有独立性的
  33. 脚本功能冲突,其他脚本基本上不冲突

  34. 使用方法:在事件中使用脚本$scene = Scene_Compose.new,然后等待2帧
  35. ==============================================================================
  36. 若合成失败(无匹配的配方、因合成概率低而失败)物品是否失去
  37. =end
  38. $Ingredient_Lost_When_Fail = true#false
  39. # 合成成功/失败SE  
  40. # 若不使用SE请设置为“""”(不含外引号)
  41. $SE_Compose_Successful = ""  
  42. $SE_Compose_Failed = ""
  43.   
  44. #=============================================================================
  45. # ■ 配方及补充的定义
  46. #-----------------------------------------------------------------------------
  47. # Game_System
  48. #=============================================================================
  49. class Game_System
  50.   attr_accessor :formulas
  51.   attr_accessor :products
  52.   attr_accessor :sproducts
  53.   attr_accessor :fproducts
  54.   attr_accessor :other
  55.   attr_accessor :probability
  56.   alias formulas_initialize initialize  
  57.   def initialize  
  58.     formulas_initialize
  59.     @formulas = []  
  60.     @products = []
  61.     @sproducts = []
  62.     @fproducts = []
  63.     @other = []
  64.     @probability = []
  65. =begin
  66. ===========================配方表===========================================   

  67.   配方格式
  68.   @formulas[i] = [[材料种类,材料编号,数量],[材料种类,材料编号,数量]……]                  
  69.   @products[i] = [[成品种类,成品编号,数量],[成品种类,成品编号,数量]……]
  70.   @sproducts[i] = [[成功额外产物种类,编号,数量,出现概率],[成功额外产物种类,编号,数量,出现概率]]
  71.   @fproducts[i] = [[失败额外产物种类,编号,数量,出现概率],[失败额外产物种类,编号,数量,出现概率]]
  72.   @other[i] = [[开关/变量,开关/变量编号,控制系数],[开关/变量,开关/变量编号,控制系数]]
  73.   @probability[i] = 合成成功率
  74.   种类:物品 0 武器 1 防具 2
  75.   1.如果有两个配方材料相同,理论上会按编号较小的处理
  76.   2.配方材料的顺序与合成是无关的(当然如果你想改成有关肯定也不会太麻烦)
  77.   3.允许某个材料拆成多件成品(可能就不叫物品合成,应该叫物品分解了)
  78.   4.产物数量神马的理论上你可以无限写,只要你不怕麻烦加手抽筋。
  79.   5.暂时不支持多步合并为一步的合成  
  80.     例如 A + B = C,C + D = E,如果不存在A + B + D = E的配方
  81.     A + B + D无法合成 E
  82.   6.暂时不支持将配方逆向使用(本功能会尝试完善)
  83.     例如 A + B = C,C = A + B,如果不存在C = A + B的配方
  84.     C无法拆解成A + B
  85.   7.暂时不支持花费金钱的合成与配方学习(本功能会尝试完善)
  86.     例如A + B = C,作者设定成合成此配方的成品需要花费5000金币之类的
  87.   8.成功额外产物出现的概率与失败额外产物出现的概率会导致所有成功额外
  88.   产物或所有失败额外产物同时出现,比如失败额外产物有大药膏和艾西非远
  89.   古祭祀,则在合成失败后若出现失败的额外产物时同时出现大药膏和艾西非
  90.   远古祭祀。
  91.   9.成功额外产物和失败额外产物的设定和配方材料、配方成品设定格式是一致的。
  92.   10.@other[i]里面控制开关与变量,当[开关/变量,开关/变量编号,控制系数]
  93.   里面的[开关/变量]为0时是改变开关,改变开关的时候若控制系数为0则是关闭,
  94.   1就是打开,当[开关/变量]为1时是改变变量,这个时候控制系数可以添任意正负
  95.   整数。
  96.   11.当你要改变开关状态时控制系数只能是1或0
  97.   12.不需要的功能全部数字写0即可
  98.   13.只有合成/拆分成功时才能改变开关与变量
  99.   14.已经打开的开关依然可以用合成/拆分操作重复打开

  100. =end
  101.     #初始化模板
  102.     @formulas[0] = []
  103.     @products[0] = []
  104.     @sproducts[0] = []
  105.     @fproducts[0] = []
  106.     @other[0] = []
  107.     @probability[0] = []
  108.     #这个才是样例!!!
  109.     @formulas[1] = [[1,1,1]]         
  110.     @products[1] = [[2,29,1]]
  111.     @sproducts[1] = [[1,2,1,50],[1,3,1,100]]
  112.     @fproducts[1] = [[0,2,1,50],[0,3,3,100]]
  113.     @other[1] = [[0,10,1],[1,20,2]]#10号开关打开,20号变量+2
  114.     @probability[1] = 100
  115.   end  
  116. end
  117.   
  118. class Game_Temp  
  119.   attr_accessor :forge
  120.   alias forge_item_initialize initialize  
  121.   def initialize  
  122.     forge_item_initialize
  123.     # 定义合成窗口中的物品储存区
  124.     [url=home.php?mod=space&uid=14254]@Forge[/url] = []  
  125.   end  
  126. end
  127.   
  128. #==============================================================================
  129. # ■ Window_ForgeCommand
  130. #------------------------------------------------------------------------------
  131. #  合成画面、选择要做的事的窗口
  132. #==============================================================================
  133.   
  134. class Window_ComposeCommand < Window_Selectable
  135.   #--------------------------------------------------------------------------
  136.   # ● 初始化对像
  137.   #--------------------------------------------------------------------------
  138.   def initialize
  139.     super(0, 64, 640, 64)
  140.     self.contents = Bitmap.new(width - 32, height - 32)
  141.     @item_max = 4
  142.     @column_max = 4
  143.     @commands = ["更改材料", "合成", "放弃合成", "离开"]
  144.     refresh
  145.     self.index = 0
  146.   end
  147.   #--------------------------------------------------------------------------
  148.   # ● 刷新
  149.   #--------------------------------------------------------------------------
  150.   def refresh
  151.     self.contents.clear
  152.     for i in 0...@item_max
  153.       draw_item(i)
  154.     end
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   # ● 描绘项目
  158.   #     index : 项目编号
  159.   #--------------------------------------------------------------------------
  160.   def draw_item(index)
  161.     x = 4 + index * 160
  162.     self.contents.draw_text(x, 0, 128, 32, @commands[index])
  163.   end
  164. end
  165.   
  166. #==============================================================================
  167. # ■ Window_ForgeLeft
  168. #------------------------------------------------------------------------------
  169. #  合成画面中显示拥有的物品的窗口
  170. #==============================================================================
  171.   
  172. class Window_ComposeLeft < Window_Selectable
  173.   #--------------------------------------------------------------------------
  174.   # ● 初始化对像
  175.   #--------------------------------------------------------------------------
  176.   def initialize
  177.     super(0, 128, 320, 352)
  178.     @column_max = 1
  179.     refresh
  180.     self.index = 0
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # ● 获取物品
  184.   #--------------------------------------------------------------------------
  185.   def item
  186.     return @data[self.index]
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ● 刷新
  190.   #--------------------------------------------------------------------------
  191.   def refresh
  192.     if self.contents != nil
  193.       self.contents.dispose
  194.       self.contents = nil
  195.     end
  196.     self.update_cursor_rect
  197.     @data = []
  198.     for i in 1...$data_items.size
  199.       if $game_party.item_number(i) > 0
  200.         @data.push($data_items[i])
  201.       end
  202.     end
  203.     for i in 1...$data_weapons.size
  204.       if $game_party.weapon_number(i) > 0
  205.         @data.push($data_weapons[i])
  206.       end
  207.     end
  208.     for i in 1...$data_armors.size
  209.       if $game_party.armor_number(i) > 0
  210.         @data.push($data_armors[i])
  211.       end
  212.     end
  213.     # 如果项目数不是 0 就生成位图、描绘全部项目
  214.     @item_max = @data.size
  215.     if @item_max > 0
  216.       self.contents = Bitmap.new(width - 32, row_max * 32)
  217.       for i in 0...@item_max
  218.         draw_item(i)
  219.       end
  220.     end
  221.   end
  222.   #--------------------------------------------------------------------------
  223.   # ● 描绘项目
  224.   #     index : 项目标号
  225.   #--------------------------------------------------------------------------
  226.   def draw_item(index)
  227.     item = @data[index]
  228.     case item
  229.     when RPG::Item
  230.       number = $game_party.item_number(item.id)
  231.     when RPG::Weapon
  232.       number = $game_party.weapon_number(item.id)
  233.     when RPG::Armor
  234.       number = $game_party.armor_number(item.id)
  235.     end
  236.     self.contents.font.color = text_color(item.name_color_66RPG)
  237.     x = 4
  238.     y = index * 32
  239.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  240.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  241.     bitmap = RPG::Cache.icon(item.icon_name)
  242.     opacity = self.contents.font.color == text_color(item.name_color_66RPG) ? 255 : 128
  243.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 32, 32), opacity)
  244.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  245.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  246.     self.contents.draw_text(x + 256, y, 32, 32, number.to_s, 2)
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # ● 刷新帮助文本
  250.   #--------------------------------------------------------------------------
  251.   def update_help
  252.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  253.   end
  254. end
  255.   
  256. #==============================================================================
  257. # ■ Window_ForgeRight
  258. #------------------------------------------------------------------------------
  259. #  合成画面中的合成区窗口
  260. #==============================================================================
  261.   
  262. class Window_ComposeRight < Window_Selectable
  263.   attr_accessor :forge_item
  264.   #--------------------------------------------------------------------------
  265.   # ● 初始化对像
  266.   #--------------------------------------------------------------------------
  267.   def initialize(forge_item)
  268.     super(320, 128, 320, 352)
  269.     @column_max = 1
  270.     @forge_item = []
  271.     refresh
  272.     self.index = 0
  273.   end
  274.   #--------------------------------------------------------------------------
  275.   # ● 获取物品
  276.   #--------------------------------------------------------------------------
  277.   def item
  278.     return @data[self.index]
  279.   end
  280.   #--------------------------------------------------------------------------  
  281.   # ● 获取物品  
  282.   #--------------------------------------------------------------------------  
  283.   def item_number  
  284.     return @data_number[self.index]  
  285.   end  
  286.   #--------------------------------------------------------------------------
  287.   # ● 刷新
  288.   #--------------------------------------------------------------------------
  289.   def refresh
  290.     if self.contents != nil
  291.       self.contents.dispose
  292.       self.contents = nil
  293.     end
  294.     @data = []
  295.     @data_number = []  
  296.     @forge_item = $game_temp.forge
  297.     for item_forge in @forge_item
  298.       case item_forge[0]
  299.       when 0
  300.         item = $data_items[item_forge[1]]
  301.       when 1
  302.         item = $data_weapons[item_forge[1]]
  303.       when 2
  304.         item = $data_armors[item_forge[1]]
  305.       end
  306.       if (item != nil) and (item_forge[2] != 0)  
  307.         @data.push(item)  
  308.         @data_number.push(item_forge[2])  
  309.       else  
  310.         @data.delete(item)  
  311.       end  
  312.     end
  313.     # 如果项目数不是 0 就生成位图、描绘全部项目
  314.     @item_max = @data.size
  315.     if @item_max > 0
  316.       self.contents = Bitmap.new(width - 32, row_max * 32)
  317.       for i in 0...@item_max
  318.         draw_item(i)
  319.       end
  320.     end
  321.   end
  322.   #--------------------------------------------------------------------------
  323.   # ● 描绘项目
  324.   #     index : 项目标号
  325.   #--------------------------------------------------------------------------
  326.   def draw_item(index)
  327.     item = @data[index]
  328.     case item
  329.     when RPG::Item
  330.       number = $game_temp.forge[index][2]
  331.     when RPG::Weapon
  332.       number = $game_temp.forge[index][2]
  333.     when RPG::Armor
  334.       number = $game_temp.forge[index][2]
  335.     end
  336.     self.contents.font.color = text_color(item.name_color_66RPG)
  337.     x = 4
  338.     y = index * 32
  339.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  340.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  341.     bitmap = RPG::Cache.icon(item.icon_name)
  342.     opacity = self.contents.font.color == text_color(item.name_color_66RPG) ? 255 : 128
  343.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 32, 32), opacity)
  344.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  345.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  346.     self.contents.draw_text(x + 256, y, 32, 32, number.to_s, 2)
  347.   end
  348.   #--------------------------------------------------------------------------
  349.   # ● 刷新帮助文本
  350.   #--------------------------------------------------------------------------
  351.   def update_help
  352.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  353.   end
  354. end
  355.   
  356. #==============================================================================
  357. # ■ Scene_Compose
  358. #------------------------------------------------------------------------------
  359. #  处理物品合成画面的类
  360. #==============================================================================
  361.   
  362. class Scene_Compose
  363. #--------------------------------------------------------------------------
  364. # ● 初始化
  365. #--------------------------------------------------------------------------
  366. def initialize
  367.    # 生成帮助窗口
  368.    @help_window = Window_Help.new
  369.    # 生成命令窗口
  370.    @command_window = Window_ComposeCommand.new
  371.    @command_window.active = false
  372.    # 生成左方窗口
  373.    @item_window = Window_ComposeLeft.new
  374.    @item_window.active = true
  375.    @item_window.help_window = @help_window
  376.    # 生成右方窗口
  377.    @forge_window = Window_ComposeRight.new([])
  378.    @forge_window.active = false
  379.    @forge_window.help_window = @help_window
  380.    # 初始化配方与合成区
  381.    @formulas = $game_system.formulas
  382.    @products = $game_system.products
  383.    @sproducts = $game_system.sproducts
  384.    @fproducts = $game_system.fproducts
  385.    @other = $game_system.other
  386.    @probability = $game_system.probability
  387.    @forge = []
  388.    @products_temp = []  
  389.    @sproducts_temp = []
  390.    @fproducts_temp = []
  391.    @other_temp = []
  392.    @probability_temp = []
  393. end
  394.   #--------------------------------------------------------------------------
  395.   # ● 主处理
  396.   #--------------------------------------------------------------------------
  397. def main
  398.    # 执行过渡
  399.    Graphics.transition
  400.    # 主循环
  401.    loop do
  402.      # 刷新游戏画面
  403.      Graphics.update
  404.      # 刷新输入情报
  405.      Input.update
  406.      # 刷新画面
  407.      update
  408.      # 如果画面被切换的话就中断循环
  409.      if $scene != self
  410.        break
  411.      end
  412.    end
  413.    # 准备过渡
  414.    Graphics.freeze
  415.    # 释放窗口
  416.    @help_window.dispose
  417.    @command_window.dispose
  418.    @item_window.dispose
  419.    @forge_window.dispose
  420. end
  421.   #--------------------------------------------------------------------------
  422.   # ● 刷新画面
  423.   #--------------------------------------------------------------------------  
  424. def update
  425.    @help_window.update
  426.    @command_window.update
  427.    @item_window.update
  428.    @forge_window.update
  429.    if @command_window.active
  430.      update_command
  431.      return
  432.    end
  433.    if @item_window.active
  434.      update_item
  435.      return
  436.    end
  437.    if @forge_window.active
  438.      update_forge
  439.      return
  440.    end
  441.     return
  442. end
  443.   #--------------------------------------------------------------------------
  444.   # ● 刷新画面(指令窗口激活的情况下)
  445.   #--------------------------------------------------------------------------
  446.   def update_command
  447.     # 按下 B 键的情况下
  448.     if Input.trigger?(Input::B)
  449.       # 演奏取消 SE
  450.       $game_system.se_play($data_system.cancel_se)
  451.       abort
  452.       # 切换到地图画面
  453.       $scene = Scene_Map.new
  454.       return
  455.     end
  456.      # 按下 C 键的情况下
  457.     if Input.trigger?(Input::C)
  458.       # 命令窗口光标位置分支
  459.       case @command_window.index
  460.       when 0  # 更改材料
  461.         # 演奏确定 SE
  462.         $game_system.se_play($data_system.decision_se)
  463.         # 窗口状态转向物品窗口
  464.         @command_window.active = false
  465.         @item_window.active = true
  466.         @forge_window.active = false
  467.       when 1  # 合成
  468.         # 演奏确定 SE
  469.         $game_system.se_play($data_system.decision_se)
  470.         # 执行合成命令
  471.         if $game_temp.forge != []
  472.           compose
  473.         end
  474.       when 2  # 放弃合成
  475.         # 演奏确定 SE
  476.         $game_system.se_play($data_system.decision_se)
  477.         # 放弃合成
  478.         abort
  479.       when 3  # 离开
  480.         # 演奏确定 SE
  481.         $game_system.se_play($data_system.decision_se)
  482.         # 放弃合成
  483.         abort
  484.         # 切换到地图画面
  485.         $scene = Scene_Map.new
  486.       end
  487.       return
  488.     end
  489.   end
  490.   #--------------------------------------------------------------------------
  491.   # ● 刷新画面(物品窗口激活的情况下)
  492.   #--------------------------------------------------------------------------
  493.   def update_item
  494.      # 按下 B 键的情况下
  495.     if Input.trigger?(Input::B)
  496.       # 演奏取消 SE
  497.       $game_system.se_play($data_system.cancel_se)
  498.       # 切换到指令窗口
  499.       @item_window.active = false
  500.       @command_window.active = true
  501.       @help_window.set_text("")
  502.       return
  503.     end
  504.      # 按下 C 键的情况
  505.     if Input.trigger?(Input::C)
  506.       # 演奏确定 SE
  507.       $game_system.se_play($data_system.decision_se)
  508.       # 获取物品
  509.       @item = @item_window.item
  510.       # 获取物品的所持数
  511.       case @item
  512.       when RPG::Item
  513.         number = $game_party.item_number(@item.id)
  514.         typetemp = 0
  515.       when RPG::Weapon
  516.         number = $game_party.weapon_number(@item.id)
  517.         typetemp = 1
  518.       when RPG::Armor
  519.         number = $game_party.armor_number(@item.id)
  520.         typetemp = 2
  521.       end
  522.       if number != nil
  523.         # 更改合成窗口的物品
  524.         case @item
  525.         when RPG::Item
  526.           $game_party.lose_item(@item.id, 1)
  527.         when RPG::Weapon
  528.           $game_party.lose_weapon(@item.id, 1)
  529.         when RPG::Armor
  530.           $game_party.lose_armor(@item.id, 1)
  531.         end
  532.         forge_change(typetemp, @item.id, 1)
  533.         # 刷新各窗口
  534.         @item_window.update
  535.         @help_window.update
  536.         @forge_window.update
  537.         @item_window.refresh
  538.         @forge_window.refresh
  539.       end
  540.     end
  541.      # 按下 右方向键 的情况
  542.     if Input.trigger?(Input::RIGHT)
  543.       # 切换到合成窗口
  544.       @item_window.active = false
  545.       @forge_window.active = true
  546.     end
  547.   end
  548.   #--------------------------------------------------------------------------
  549.   # ● 刷新画面(合成窗口激活的情况下)
  550.   #--------------------------------------------------------------------------
  551.   def update_forge
  552.      # 按下 B 键的情况下
  553.     if Input.trigger?(Input::B)
  554.       # 演奏取消 SE
  555.       $game_system.se_play($data_system.cancel_se)
  556.       # 切换到指令窗口
  557.       @forge_window.active = false
  558.       @command_window.active = true
  559.       @help_window.set_text("")
  560.       return
  561.     end
  562.      # 按下 C 键的情况
  563.     if Input.trigger?(Input::C)
  564.      # 演奏确定 SE
  565.      $game_system.se_play($data_system.decision_se)
  566.      # 获取物品
  567.       @item = @forge_window.item
  568.       # 获取物品的所持数
  569.       case @item
  570.       when RPG::Item
  571.         number = @forge_window.item_number
  572.         typetemp = 0
  573.       when RPG::Weapon
  574.         number = @forge_window.item_number
  575.         typetemp = 1
  576.       when RPG::Armor
  577.         number = @forge_window.item_number
  578.         typetemp = 2
  579.       end
  580.      if number != nil
  581.        # 更改合成窗口的物品
  582.        case @item
  583.        when RPG::Item
  584.          $game_party.gain_item(@item.id, 1)
  585.        when RPG::Weapon
  586.          $game_party.gain_weapon(@item.id, 1)
  587.        when RPG::Armor
  588.          $game_party.gain_armor(@item.id, 1)
  589.        end
  590.        #p number
  591.        forge_change(typetemp, @item.id, -1)
  592.        # 刷新各窗口
  593.        @item_window.refresh
  594.        @forge_window.refresh
  595.        @help_window.update
  596.        @item_window.update
  597.        @forge_window.update
  598.       end
  599.     end
  600.        # 按下 左方向键 的情况下
  601.     if Input.trigger?(Input::LEFT)
  602.       # 切换到合成窗口
  603.       @forge_window.active = false
  604.       @item_window.active = true
  605.     end
  606.   end
  607.   #--------------------------------------------------------------------------
  608.   # ● 更改合成窗口物品
  609.   #--------------------------------------------------------------------------
  610.   def forge_change(type,id,number)  
  611.      quantity = number  
  612.      for item in $game_temp.forge
  613.        if (item[0]==type) and (item[1]==id)  
  614.          item[2] = [item[2] += quantity,99].min  
  615.          if item[2] == 0  
  616.            $game_temp.forge.delete(item)  
  617.          end
  618.          return  
  619.        end  
  620.      end  
  621.      $game_temp.forge.push([type,id,number])  
  622.   end  
  623.   #--------------------------------------------------------------------------
  624.   # ● 放弃合成
  625.   #--------------------------------------------------------------------------  
  626.   def abort
  627.     # 将合成窗口中的物品转移至物品窗口中
  628.     for item in $game_temp.forge
  629.       # 判断物品类型并归还
  630.       case item[0]
  631.       when 0
  632.         $game_party.gain_item(item[1], item[2])
  633.       when 1
  634.         $game_party.gain_weapon(item[1], item[2])
  635.       when 2
  636.         $game_party.gain_armor(item[1], item[2])
  637.       end
  638.     end
  639.     $game_temp.forge = []
  640.     # 刷新各窗口
  641.     @item_window.refresh
  642.     @forge_window.refresh
  643.   end
  644.   #--------------------------------------------------------------------------
  645.   # ● 检测是否有符合的配方
  646.   #--------------------------------------------------------------------------
  647. def match
  648.    match_one = false
  649.    match_this = false
  650.     # 检测每一个配方
  651.    for i in [email protected]
  652.      # 将合成窗口中的物品复制到合成缓存区
  653.      # 注意: 直接使用"="将传引用 导致检测配方是否匹配时合成窗口中物品被删除
  654.      @forge = $game_temp.forge.dup
  655.      # 检测这个配方中每一项材料
  656.      for ingredient in @formulas[i]
  657.        match_this = true
  658.        # 合成区中没有此项材料的情况
  659.        unless @forge.include?(ingredient)
  660.          match_this = false
  661.          break
  662.        end
  663.        # 从合成区中暂时删除这项材料
  664.        @forge.delete(ingredient)
  665.      end
  666.      if match_this == false
  667.        next
  668.      end
  669.      # 检测合成区中是否还有配方外的材料剩余
  670.      unless @forge == []
  671.        match_this = false
  672.      end
  673.      # 满足这一个配方的情况
  674.      if match_this == true
  675.        match_one = true
  676.        # 获取配方的成品、成功额外产物、失败额外产物、合成各种概率
  677.        @products_temp = @products[i]
  678.        @sproducts_temp = @sproducts[i]
  679.        @fproducts_temp = @fproducts[i]
  680.        @other_temp = @other[i]
  681.        @probability_temp = @probability[i]
  682.        $g=i
  683.        break
  684.      end
  685.    end
  686.    return match_one
  687. end
  688.   #--------------------------------------------------------------------------
  689.   # ● 合成
  690.   #--------------------------------------------------------------------------
  691. def compose
  692.    # 如果有符合的配方
  693.    if match
  694.      # 将合成窗口中的材料改变为成品
  695.      $game_temp.forge = []
  696.      if @probability_temp==100
  697.        @pro1=0#当成功率为100%时随机概率是0
  698.      else
  699.        @pro1=rand(99)#当成功率不为100%时随即概率为0-99
  700.      end
  701.      if @pro1<@probability_temp
  702.        for i in 0...@other_temp.size
  703.          if @other_temp[i][1]!=0
  704.            if @other_temp[i][0]==0
  705.              $game_switches[@other_temp[i][1]]=@other_temp[i][2]#控制开关
  706.            else
  707.              $game_variables[@other_temp[i][1]]+=@other_temp[i][2]#控制变量
  708.            end
  709.          end
  710.          $game_map.need_refresh = true#强制刷新地图
  711.        end
  712.        for i in 0...@products_temp.size
  713.          forge_change(@products_temp[i][0], @products_temp[i][1], @products_temp[i][2])
  714.        end
  715.        for i in 0...@sproducts_temp.size
  716.          if @sproducts_temp[i][3]==100
  717.            @pro2=0#成功额外产率为100%时随即概率为0
  718.          elsif @sproducts_temp[i][3]<100
  719.            @pro2=rand(99)#成功额外产率为0-99%时随即概率为0-99%
  720.          else
  721.            @pro2=0#成功额外产率为0%时没有成功额外产物
  722.          end
  723.          if @pro2<@sproducts_temp[i][3]
  724.            forge_change(@sproducts_temp[i][0], @sproducts_temp[i][1], @sproducts_temp[i][2])
  725.          end
  726.        end  
  727.      else
  728.        for i in 0...@fproducts_temp.size
  729.          if @fproducts_temp[i][3]==100
  730.            @pro3=0#成功额外产率为100%时随即概率为0
  731.          elsif @fproducts_temp[i][3]<100
  732.            @pro3=rand(99)#成功额外产率为0-99%时随即概率为0-99%
  733.          else
  734.            @pro3=0#成功额外产率为0%时没有成功额外产物
  735.          end
  736.          if @pro3<@fproducts_temp[i][3]
  737.            forge_change(@fproducts_temp[i][0], @fproducts_temp[i][1], @fproducts_temp[i][2])
  738.          end
  739.        end
  740.      end
  741.      if $SE_Compose_Successful != ""
  742.        Audio.se_play($SE_Compose_Successful)
  743.      end
  744.    # 合成失败的情况
  745.    else  
  746.      if $SE_Compose_Failed != ""
  747.        Audio.se_play($SE_Compose_Failed)
  748.      end
  749.      if $Ingredient_Lost_When_Fail
  750.        $game_temp.forge = []
  751.      end
  752.    end
  753.     # 刷新各窗口
  754.    @item_window.refresh
  755.    @forge_window.refresh
  756. end
  757. end
复制代码
试试这个吧,唯一缺陷是没法直接按照某个配方按一个键就合成···要自己放材料

点评

130行出错了,又冲突了?  发表于 2014-7-3 12:45
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
3
星屑
261
在线时间
223 小时
注册时间
2012-8-18
帖子
143
7
 楼主| 发表于 2014-7-3 12:43:47 | 只看该作者
经过我的多次试验,发现以下情况:
1.目前的合成系统似乎都有问题
2.似乎如果不使用,其他脚本与合成脚本并不冲突(已试验,任务,物品分类,魔法商店不冲突,有范例) Project1.rar (212.18 KB, 下载次数: 55)
3.但如果放到我的游戏里,不知道为什么,就冲突了
4.还是用事件合成好,确实很方便

点评

不算  发表于 2014-7-3 13:36
这个问题,算完结了吗?  发表于 2014-7-3 12:49
取名不慎,我的名字是BobCheng,做游戏什么的,其实是安慰自己而已。
很烧脑的推理游戏
猜不到结局的故事
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
9280
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

8
发表于 2014-7-3 13:37:27 | 只看该作者
ccqtxwd 发表于 2014-7-3 12:43
经过我的多次试验,发现以下情况:
1.目前的合成系统似乎都有问题
2.似乎如果不使用,其他脚本与合成脚本并 ...

是你自己的整合系统有问题···
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
90
在线时间
250 小时
注册时间
2011-12-18
帖子
59
9
发表于 2014-7-5 17:32:25 | 只看该作者
本帖最后由 鱼剑浆糊 于 2014-7-5 17:42 编辑

https://rpg.blue/thread-363553-1-1.html    楼主不妨试试我整合的这个系统
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
155
在线时间
332 小时
注册时间
2013-7-6
帖子
356
10
发表于 2014-7-5 18:41:41 | 只看该作者
本帖最后由 wolves 于 2014-7-6 10:15 编辑

不知道你是要解决系统的问题还是要解决你问的nilclass问题,如果你要解决nilclass那个问题,可以在296行那个if前的一行插入这段脚本:
  1.     if $game_party.recipes.class == NilClass
  2.       $game_party.recipes = []
  3.     end
复制代码
估计那个$game_party.recipes是数组,这样可以解决一下问题。

点评

问题没法解决就只能掩盖了,真正要解决问题的话以楼主这些脚本容量,我是爱莫能助了。  发表于 2014-7-6 10:40
所以我不清楚。我不用XP,没看过XP的脚本,也没看楼主的脚本,只是说一下解决问题的原则而已。  发表于 2014-7-6 10:30
单看initialize初始化部分脚本确实没有问题。。。 比如attr_reader :list 后面调用 if @list.size > 1 @starting = true end 的时候就会出 nil的size没有被定义的问题   发表于 2014-7-6 10:29
如果是这样,应该在initialize里面就初始化,而不是在出错的位置修复  发表于 2014-7-6 10:23
通常是因为没有正确的初始化造成的。  发表于 2014-7-6 10:22
偶是熬夜学编程的傻子
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-30 23:33

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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