幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1344|回复: 4

[求助]物品合成系统完美版的修改问题(级别:简单)

[复制链接]

3

主题

18

帖子

200

积分

③业余

积分
200
发表于 2007-2-1 21:40:29 | 显示全部楼层 |阅读模式
本来以为很简单……但是改了一个晚上都没有结果[s:6] ……本想直接把窗口里的数据删了……可是会出错……(果然是菜鸟…… [s:4] )

目标的确很简单,就是把右上方的合成物品数据的窗口简化成只显示“待合成物品的现有数量”和“备注”两行,其他都不要了……

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

使用道具 举报

3

主题

18

帖子

200

积分

③业余

积分
200
 楼主| 发表于 2007-2-2 12:52:49 | 显示全部楼层
好冷……清……

难道RGSS的帖子也应该发到外面去才比较会有人看么?

求签中~ [s:4]
回复 支持 反对

使用道具 举报

好人卡的 该用户已被删除
发表于 2007-2-2 13:45:29 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

3

主题

18

帖子

200

积分

③业余

积分
200
 楼主| 发表于 2007-2-3 21:46:53 | 显示全部楼层
多谢了!向您这样的好人一定一辈子都不会被发好人卡的! [s:2]
回复 支持 反对

使用道具 举报

好人卡的 该用户已被删除
发表于 2007-2-4 00:17:04 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2025-6-26 05:42 , Processed in 0.011325 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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