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

Project1

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

[已经解决] 请教使用物品合成脚本出问题?

[复制链接]

Lv1.梦旅人

井蓝

梦石
0
星屑
58
在线时间
351 小时
注册时间
2011-1-14
帖子
277
跳转到指定楼层
1
发表于 2013-1-1 22:32:42 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x

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

Lv3.寻梦者

梦石
0
星屑
3589
在线时间
2260 小时
注册时间
2008-1-28
帖子
3193

开拓者

2
发表于 2013-1-2 21:49:58 | 只看该作者
ArgumentError 类表示一种错误,如果函数提供的参数与为该函数定义的参数不一致,则会出现该错误。例如,如果在调用函数时使用了错误的参数数目、不正确的参数类型或无效参数,则会发生此错误。

从322行来看,问题不是出在这一行。
我尝试把楼主提供的脚本贴到一个新建的工程上面,然后139行报了语法错误(也不知道错在什么地方,去掉了后面email 的那个斜杠还是报错。)

不知道是不是和别的脚本冲突了。

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-27 10:28

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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