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

Project1

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

[已经解决] 求大神整合脚本

[复制链接]

Lv1.梦旅人

梦石
0
星屑
64
在线时间
124 小时
注册时间
2015-1-30
帖子
61
跳转到指定楼层
1
发表于 2015-2-15 13:15:21 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
9星屑
想做个类似于mh的游戏便去搞了个物品限制脚本,可这脚本好像不太善于和其他脚本搞好关系,前两天在本站解决了一些后在实际操作中还是发现了好多问题,希望能有大神帮忙解决。
问题有这些:如果背包满了合成物品会消失,一次性的事件如宝箱里的宝物会消失。
还有些小问题:物品从仓库取出时取出数量没有上限可是包里最多99个,装备卸下时若背包已满虽会提示,但提示后人可卸下导致装备消失。
新人不是很懂规矩,不知道这样是不是太少了,真心想做个游戏希望大神帮助。

Project2.zip

219.61 KB, 下载次数: 93

最佳答案

查看完整内容

整合好了: 加入了一个$judges变量,与其它脚本整合需要注意。 修改了解释器内容。 以下为修改部分: 背包限制:合成系统附加解释器修改内容:背包脚本问题: Scene_Warehouse # ———————————————————————————————————— # 本脚本来自www.66rpg.com,转载请保留此信息 # ———————————————————————————————————— #========================================= ...

Lv1.梦旅人

梦石
0
星屑
150
在线时间
332 小时
注册时间
2013-7-6
帖子
356
2
发表于 2015-2-15 13:15:22 | 只看该作者
本帖最后由 wolves 于 2015-2-16 08:40 编辑

整合好了:
加入了一个$judges变量,与其它脚本整合需要注意。
修改了解释器内容。
以下为修改部分:
背包限制:
  1. #==============================================================================
  2. # 背包可容纳最大的物品种类数。(包括物品,武器,防具)
  3. ITEMS_MAX = 5
  4. # 背包满后,如果再增加物品所提示的信息。
  5. TOP_MESSAGE = "背包已满!"
  6. #==============================================================================
  7. class Game_Party
  8.   #--------------------------------------------------------------------
  9.   def full_judge?(id, n, type)
  10.     mn = 0
  11.     @items.keys.each{|i| mn += 1 if item_number(i) > 0}
  12.     @weapons.keys.each{|i| mn += 1 if weapon_number(i) > 0}
  13.     @armors.keys.each{|i| mn += 1 if armor_number(i) > 0}
  14.     return false if mn < ITEMS_MAX
  15.     case type
  16.     when 0
  17.       if @items.keys.include?(id) and item_number(id) > 0
  18.         return false if item_number(id) + n <= 99
  19.       end
  20.     when 1
  21.       if @weapons.keys.include?(id) and weapon_number(id) > 0
  22.         return false if weapon_number(id) + n <= 99
  23.       end
  24.     when 2
  25.       if @armors.keys.include?(id) and armor_number(id) > 0
  26.         return false if armor_number(id) + n <= 99
  27.       end
  28.     end
  29.     return true
  30.   end
  31.   #---------------------------------------------------------------------
  32.   def full_top
  33.     $game_system.se_play($data_system.buzzer_se)
  34.     top = Window_Base.new(200, 100, 240, 64)
  35.     top.z = 999
  36.     top.contents = Bitmap.new(top.width - 32, top.height - 32)
  37.     top.contents.draw_text(0, 0, 200, 32, TOP_MESSAGE, 1)
  38.     for i in 1..30
  39.       Graphics.update
  40.     end
  41.     for i in 1..20
  42.       top.opacity -= 13
  43.       top.contents_opacity -= 13
  44.       Graphics.update
  45.     end
  46.     top.dispose
  47.     $judges=true
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   def gain_item(item_id, n)
  51.     # 更新 hash 的个数数据
  52.     if item_id > 0
  53.       if n > 0 and full_judge?(item_id, n, 0)
  54.         full_top
  55.         return
  56.       end
  57.       @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
  58.     end
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # ● 增加武器 (减少)
  62.   #     weapon_id : 武器 ID
  63.   #     n         : 个数
  64.   #--------------------------------------------------------------------------
  65.   def gain_weapon(weapon_id, n)
  66.     # 更新 hash 的个数数据
  67.     if weapon_id > 0
  68.       if n > 0 and full_judge?(weapon_id, n, 1)
  69.         full_top
  70.         return
  71.       end
  72.       @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
  73.     end
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # ● 增加防具 (减少)
  77.   #     armor_id : 防具 ID
  78.   #     n        : 个数
  79.   #--------------------------------------------------------------------------
  80.   def gain_armor(armor_id, n)
  81.     # 更新 hash 的个数数据
  82.     if armor_id > 0
  83.       if n > 0 and full_judge?(armor_id, n, 2)
  84.         full_top
  85.         return
  86.       end
  87.       @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
  88.     end
  89.   end
  90. end
  91. #----------------------------------------------------------------------------
  92. class Scene_Shop
  93.   #--------------------------------------------------------------------------
  94.   # ● 刷新画面 (个数输入窗口激活的情况下)
  95.   #--------------------------------------------------------------------------
  96.   def update_number
  97.     # 按下 B 键的情况下
  98.     if Input.trigger?(Input::B)
  99.       # 演奏取消 SE
  100.       $game_system.se_play($data_system.cancel_se)
  101.       # 设置个数输入窗口为不活动·非可视状态
  102.       @number_window.active = false
  103.       @number_window.visible = false
  104.       # 命令窗口光标位置分支
  105.       case @command_window.index
  106.       when 0  # 购买
  107.         # 窗口状态转向购买模式
  108.         @buy_window.active = true
  109.         @buy_window.visible = true
  110.       when 1  # 卖出
  111.         # 窗口状态转向卖出模式
  112.         @sell_window.active = true
  113.         @sell_window.visible = true
  114.         @status_window.visible = false
  115.       end
  116.       return
  117.     end
  118.     # 按下 C 键的情况下
  119.     if Input.trigger?(Input::C)
  120.       # 设置个数输入窗口为不活动·非可视状态
  121.       @number_window.active = false
  122.       @number_window.visible = false
  123.       # 命令窗口光标位置分支
  124.       case @command_window.index
  125.       when 0  # 购买
  126.         type = @item.is_a?(RPG::Item) ? 0 : (@item.is_a?(RPG::Weapon) ? 1 : 2)
  127.         if $game_party.full_judge?(@item.id, @number_window.number, type)
  128.           $game_party.full_top
  129.           @buy_window.active = true
  130.           @buy_window.visible = true
  131.           return
  132.         end
  133.         # 演奏商店 SE
  134.         $game_system.se_play($data_system.shop_se)
  135.         # 购买处理
  136.         case @item
  137.         when RPG::Item
  138.           $game_party.gain_item(@item.id, @number_window.number)
  139.         when RPG::Weapon
  140.           $game_party.gain_weapon(@item.id, @number_window.number)
  141.         when RPG::Armor
  142.           $game_party.gain_armor(@item.id, @number_window.number)
  143.         end
  144.         $game_party.lose_gold(@number_window.number * @item.price)
  145.         # 刷新各窗口
  146.         @gold_window.refresh
  147.         @buy_window.refresh
  148.         @status_window.refresh
  149.         # 窗口状态转向购买模式
  150.         @buy_window.active = true
  151.         @buy_window.visible = true
  152.       when 1  # 卖出
  153.         # 演奏商店 SE
  154.         $game_system.se_play($data_system.shop_se)
  155.         # 卖出处理
  156.         $game_party.gain_gold(@number_window.number * (@item.price / 2))
  157.         case @item
  158.         when RPG::Item
  159.           $game_party.lose_item(@item.id, @number_window.number)
  160.         when RPG::Weapon
  161.           $game_party.lose_weapon(@item.id, @number_window.number)
  162.         when RPG::Armor
  163.           $game_party.lose_armor(@item.id, @number_window.number)
  164.         end
  165.         # 刷新各窗口
  166.         @gold_window.refresh
  167.         @sell_window.refresh
  168.         @status_window.refresh
  169.         # 窗口状态转向卖出模式
  170.         @sell_window.active = true
  171.         @sell_window.visible = true
  172.         @status_window.visible = false
  173.       end
  174.       return
  175.     end
  176.   end
  177. end
  178. #==============================================================================
复制代码
合成系统

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

  123. #================================
  124. # CRAFTING PROGRAM
  125. #----------------------------------------------------------------
  126. #-written by Deke
  127. #-yes_no window code created by Phsylomortis
  128. #----------------------------------------------------------------
  129. #================================

  130. #updates to Game_Party class

  131. class Game_Party
  132.   
  133.   attr_accessor       :recipes
  134.   
  135.   alias crafting_party_initialize initialize
  136.   
  137.   def initialize
  138.     crafting_party_initialize
  139.     @recipes=[]
  140.   end
  141.   
  142.   #----------------------------------------------------------------------
  143.   def know?(recipe, version = 1)
  144.     unless recipe.is_a?(Game_Recipe)
  145.       recipe = get_recipe_from_master_list(recipe, version)
  146.     end
  147.     return $game_party.recipes.include?(recipe)
  148.   end
  149.   
  150. #----------------------------------------------------------------------
  151.   def learn_recipe(recipe , version = 1)
  152.     unless recipe.is_a?(Game_Recipe)
  153.       recipe = get_recipe_from_master_list(recipe, version)
  154.     end
  155.     if recipe.is_a?(Game_Recipe)
  156.       unless know?(recipe)
  157.         @recipes.push(recipe)
  158.       end
  159.     end
  160.   end
  161.   
  162. #----------------------------------------------------------------------
  163.   def forget_recipe(recipe , version = 1)
  164.     if !recipe.is_a?(Game_Recipe)
  165.       recipe = get_recipe_from_master_list(recipe, version)
  166.     end
  167.     if recipe.is_a?(Game_Recipe)
  168.       for i in [email protected]
  169.         if recipe == @recipes[i]
  170.           index = i
  171.           break
  172.         end
  173.       end
  174.       if index != nil
  175.         @recipes.delete(@recipes[index])
  176.       end
  177.     end
  178.   end
  179.   
  180. #----------------------------------------------------------------------
  181.   def get_recipe_from_master_list(item, version)
  182.     index = nil
  183.     for i in 0...$game_temp.recipe_list.size
  184.       if item[0] == $game_temp.recipe_list[i].result and item[1] ==$game_temp.recipe_list[i].result_type
  185.         version -= 1
  186.         if version == 0
  187.           index = i
  188.           break
  189.         end
  190.       end
  191.     end
  192.     if index.is_a?(Integer)
  193.       return ($game_temp.recipe_list[index])
  194.     else
  195.       return false
  196.     end
  197.   end
  198.   
  199. end # of Game_Party updates

  200. #================================
  201. class Game_Recipe

  202.   attr_reader :ingredients
  203.   attr_reader :quantities
  204.   attr_reader :result
  205.   attr_reader :result_type
  206.   attr_reader :ingredient_types
  207.   attr_reader :craft_type  #物品分类
  208.   
  209. #----------------------------------------------------------------------
  210.   def initialize( ingredients, ingredient_types, quantities, result, result_type, craft_type=0)
  211.     @ingredients = ingredients
  212.     @ingredient_types = ingredient_types
  213.     @quantities = quantities
  214.     @result = result
  215.     @result_type = result_type
  216.     @craft_type = craft_type
  217.   end
  218.   
  219. #----------------------------------------------------------------------
  220.   def name
  221.     case @result_type
  222.       when 0
  223.         name = $data_items[@result].name
  224.       when 1
  225.         name = $data_armors[@result].name
  226.       when 2
  227.         name = $data_weapons[@result].name
  228.     end
  229.     return name
  230.   end
  231.   
  232. #----------------------------------------------------------------------

  233.   def item
  234.     case @result_type
  235.       when 0
  236.         item = $data_items[@result]
  237.       when 1
  238.         item = $data_armors[@result]
  239.       when 2
  240.         item = $data_weapons[@result]
  241.     end
  242.     return item
  243.   end

  244. #----------------------------------------------------------------------
  245.   def have
  246.     have_all = true
  247.     for i in [email protected]
  248.       case @ingredient_types[i]
  249.         when 0
  250.           if $game_party.item_number(@ingredients[i]) < @quantities[i]
  251.             have_all=false
  252.           end
  253.         when 1
  254.           if $game_party.armor_number(@ingredients[i]) < @quantities[i]
  255.             have_all=false
  256.           end
  257.         when 2
  258.           if $game_party.weapon_number(@ingredients[i]) < @quantities[i]
  259.             have_all=false
  260.           end
  261.       end
  262.     end
  263.     return have_all
  264.   end

  265. #----------------------------------------------------------------------
  266.   def decrement
  267.     for i in [email protected]
  268.       case @ingredient_types[i]
  269.       when 0
  270.         $game_party.lose_item(@ingredients[i], @quantities[i])
  271.       when 1
  272.         $game_party.lose_armor(@ingredients[i], @quantities[i])
  273.       when 2
  274.         $game_party.lose_weapon(@ingredients[i], @quantities[i])
  275.       end
  276.     end
  277.   end

  278. #----------------------------------------------------------------------
  279.   def make
  280.     if have
  281.       case @result_type
  282.       when 0
  283.         $game_party.gain_item(@result, 1)
  284.       when 1
  285.         $game_party.gain_armor(@result, 1)
  286.       when 2
  287.         $game_party.gain_weapon(@result, 1)
  288.       end
  289.       decrement if $judges.nil?
  290.       $judges=nil
  291.     end
  292.   end
  293.   
  294. #----------------------------------------------------------------------
  295.   def == (recipe)
  296.     if recipe.is_a?(Game_Recipe)
  297.       equal = true
  298.       if recipe.ingredients != self.ingredients
  299.         equal = false
  300.       end
  301.       if recipe.ingredient_types != self.ingredient_types
  302.         equal = false
  303.       end
  304.       if recipe.quantities != self.quantities
  305.         equal = false
  306.       end
  307.       if recipe.result != self.result
  308.         equal=false
  309.       end
  310.       if recipe.result_type != self.result_type
  311.         equal = false
  312.       end
  313.     else
  314.       equal = false
  315.     end
  316.     return equal
  317.   end
  318.   
  319. end # of Game_Recipe class

  320. #===================================

  321. class Window_Craft < Window_Selectable
  322.   attr_reader :data #声明数据
  323.   #--------------------------------------------------------------------------
  324.   def initialize(craft_type=0)
  325.     @craft_type = craft_type
  326.     super(0, 64, 240, 416)
  327.     @column_max = 1
  328.     refresh
  329.     self.index = 0
  330.   end

  331.   #--------------------------------------------------------------------------
  332.   def recipe
  333.     return @data[self.index]
  334.   end

  335.   #--------------------------------------------------------------------------
  336.   def refresh
  337.     if self.contents != nil
  338.       self.contents.dispose
  339.       self.contents = nil
  340.     end
  341.     @data = []
  342.     for i in 0...$game_party.recipes.size
  343.        #@craft_type为0时就显示全部物品
  344.        #不为0时就显示对应物品
  345.       if @craft_type == 0
  346.         @data.push($game_party.recipes[i])
  347.       elsif $game_party.recipes[i].craft_type == @craft_type
  348.         @data.push($game_party.recipes[i])
  349.       end
  350.     end
  351.     @item_max = @data.size
  352.     if @item_max > 0
  353.       self.contents = Bitmap.new(width - 32, row_max * 32)
  354.       self.contents.font.name = "黑体" # = "黑体"
  355.       self.contents.font.size = 18 # = 18
  356.       for i in 0...@item_max
  357.         x = 16
  358.         y = i * 32
  359.         able = true
  360.         for ingredient in 0...@data[i].ingredients.size
  361.           case @data[i].ingredient_types[ingredient]
  362.           when 0
  363.             count = $game_party.item_number(@data[i].ingredients[ingredient])
  364.           when 1
  365.             count = $game_party.armor_number(@data[i].ingredients[ingredient])
  366.           when 2
  367.             count = $game_party.weapon_number(@data[i].ingredients[ingredient])
  368.           end
  369.           if count < @data[i].quantities[ingredient]
  370.             able = false
  371.             break
  372.           end
  373.         end
  374.         draw_item_name(@data[i].item, x, y, able)
  375.       end
  376.     end
  377.   end

  378.   #--------------------------------------------------------------------------
  379.   #def draw_item(index)
  380.   #  recipe = @data[index]
  381.   #  self.contents.font.color = recipe.have ? normal_color : disabled_color
  382.   #  x = 16
  383.   #  y = index * 32
  384.   #  self.contents.draw_text(x , y, self.width-32, 32, recipe.name, 0)
  385.   #end
  386.   
  387.   #--------------------------------------------------------------------------
  388.   # ● 描绘物品名
  389.   #     item : 物品
  390.   #     x    : 描画目标 X 坐标
  391.   #     y    : 描画目标 Y 坐标
  392.   #--------------------------------------------------------------------------
  393.   def draw_item_name(item, x, y, able = true)
  394.     if item == nil
  395.       return
  396.     end
  397.     if !able
  398.       self.contents.font.color = disabled_color
  399.     end
  400.     bitmap = RPG::Cache.icon(item.icon_name)
  401.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  402.     self.contents.draw_text(x + 28, y, 212, 32, item.name)
  403.     self.contents.font.color = normal_color
  404.   end
  405.   
  406.   #--------------------------------------------------------------------------
  407.   def update_help
  408.     current_recipe = recipe
  409.     if current_recipe.is_a?(Game_Recipe)
  410.     case current_recipe.result_type
  411.       when 0
  412.         description = $data_items[current_recipe.result].description
  413.       when 1
  414.         description = $data_armors[current_recipe.result].description
  415.       when 2
  416.         description = $data_weapons[current_recipe.result].description
  417.       end
  418.     else
  419.       description = ""
  420.     end
  421.     @help_window.set_text(description)
  422.     @help_window.update
  423.   end
  424.   
  425. end # of Window_Craft

  426. #=======================================
  427. class Window_CraftResult < Window_Base

  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.   def refresh
  439.     self.contents.clear
  440.     case @type
  441.       when 0
  442.         item = $data_items[@result]
  443.         if item.recover_hp_rate > item.recover_hp
  444.           hp_string = "HP回复率:"
  445.           hp_stat = item.recover_hp_rate
  446.         else
  447.           hp_string = "HP回复量:"
  448.           hp_stat = item.recover_hp
  449.         end
  450.         if item.recover_sp_rate > item.recover_sp
  451.           sp_string = "SP回复率:"
  452.           sp_stat = item.recover_sp_rate
  453.         else
  454.           sp_string = "SP回复量:"
  455.           sp_stat = item.recover_sp
  456.         end
  457.         @strings = [hp_string, sp_string, "物理防御:" , "魔法防御:", "命中率:", "分散度:"]
  458.         @stats = [hp_stat, sp_stat, item. pdef_f, item.mdef_f, item.hit, item.variance,
  459.                        $game_party.item_number(@result)]
  460.         @bitmap = RPG::Cache.icon(item.icon_name)
  461.       when 1
  462.         item = $data_armors[@result]
  463.         @strings = ["物理防御:", "魔法防御:", "回避修正:", "力量增加:", "灵巧增加:",
  464.                        "速度增加:", "魔力增加:"]
  465.         @stats = [item.pdef, item.mdef, item.eva, item.str_plus, item.dex_plus,
  466.                     item.agi_plus, item.int_plus, $game_party.armor_number(@result) ]
  467.         @bitmap = RPG::Cache.icon(item.icon_name)
  468.       when 2
  469.         item = $data_weapons[@result]
  470.         @strings =["攻击力:", "物理防御:", "魔法防御:", "力量增加:", "灵巧增加:",
  471.                     "速度增加:", "魔力增加:"]
  472.         @stats = [item.atk, item.pdef, item.mdef, item.str_plus, item.dex_plus,
  473.                     item.agi_plus, item.int_plus, $game_party.weapon_number(@result) ]
  474.         @bitmap = RPG::Cache.icon(item.icon_name)
  475.     end
  476.     for i in [email protected]
  477.       x = i%2 * 184
  478.       y = i /2 *28 +32
  479.       self.contents.font.color = normal_color
  480.       self.contents.draw_text(x,y,100, 28,@strings[i])
  481.       self.contents.font.color = system_color
  482.       self.contents.draw_text(x + 110, y, 45, 28, @stats[i].to_s)
  483.     end
  484.     self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, 24, 24), 255)
  485.     self.contents.font.color= normal_color
  486.     self.contents.draw_text(40, 0, 300, 28, "待合成物品的现有数量:")
  487.     self.contents.font.color = system_color
  488.     count = @stats[@stats.size - 1].to_s
  489.     self.contents.draw_text(294, 0, 45, 28, count )
  490.   end
  491.    
  492. #----------------------------------------------------------------------
  493.   def set_result(result , type)
  494.     @result = result
  495.     @type = type
  496.     refresh
  497.   end

  498. end #of Window_CraftResult

  499. #=======================================
  500. class Window_CraftIngredients < Window_Base

  501.   #--------------------------------------------------------------------------
  502.   def initialize
  503.     super(240, 248, 400, 232)
  504.     self.contents = Bitmap.new(width - 32, height - 32)
  505.     self.contents.font.name = "黑体" # = $fontface.is_a?(String) ? $fontface : $defaultfonttype
  506.     self.contents.font.size = 18 # = 20
  507.     @ingredients = []
  508.     @types = []
  509.     @quantities = []
  510.     @item = nil
  511.     @count = 0
  512.     @counter = 0
  513.     @real_oy = 0
  514.   end

  515.   #--------------------------------------------------------------------------
  516.   def refresh
  517.     @counter = 0
  518.     self.contents.clear
  519.     self.contents = Bitmap.new(width - 32, @ingredients.size * 26)
  520.     for i in [email protected]
  521.       case @types[i]
  522.       when 0
  523.         @item = $data_items[@ingredients[i]]
  524.         @count = $game_party.item_number(@ingredients[i])
  525.       when 1
  526.         @item = $data_armors[@ingredients[i]]
  527.         @count = $game_party.armor_number(@ingredients[i])
  528.       when 2
  529.         @item = $data_weapons[@ingredients[i]]
  530.         @count = $game_party.weapon_number(@ingredients[i])
  531.       end
  532.       y = i *26
  533.       self.contents.blt(0, y, RPG::Cache.icon(@item.icon_name), Rect.new(0, 0, 24, 24), 255)
  534.       self.contents.font.color = @count >= @quantities[i] ? normal_color : disabled_color
  535.       self.contents.draw_text(30, y, 280, 28, @item.name)
  536.       self.contents.draw_text(300, y, 45, 28, @quantities[i].to_s)
  537.       self.contents.font.color = system_color
  538.       self.contents.draw_text(245, y, 45, 28, @count.to_s )     
  539.     end
  540.   end
  541.       
  542.   #--------------------------------------------------------------------------
  543.   def set_ingredients(ingredients , types, quantities)
  544.     @ingredients = ingredients
  545.     @types = types
  546.     @quantities = quantities
  547.     refresh
  548.     if @ingredients.size > 7
  549.       self.oy = -52
  550.       @real_oy = 0
  551.     else
  552.       self.oy = 0
  553.     end
  554.   end

  555.   def update
  556.     super
  557.     @counter += 1
  558.     if @ingredients.size > 7 and @counter > 30
  559.       @real_oy = (@real_oy + 1) % ((@ingredients.size - 3) * 26)
  560.       self.oy = @real_oy - 52
  561.     end
  562.   end
  563.    
  564. end # of Window_CraftIngredients

  565. #======================================
  566. class Scene_Craft

  567.   #--------------------------------------------------------------------------
  568.   # @craft_type:物品种类,0就是全部
  569.   def initialize(craft_type=0,craft_index=0)
  570.     @craft_index=craft_index
  571.     @craft_type = craft_type
  572.   end
  573.   
  574.   #--------------------------------------------------------------------------
  575.   def main
  576.     @craft_window = Window_Craft.new(@craft_type)
  577.     @craft_window.index=@craft_index
  578.     @confirm_window = Window_Base.new(120, 188, 400, 64)
  579.     @confirm_window.contents = Bitmap.new(368, 32)
  580.     @confirm_window.contents.font.name = "黑体"
  581.     @confirm_window.contents.font.size = 20
  582.     @help_window = Window_Help.new
  583.     @craft_window.help_window = @help_window
  584.     @result_window=Window_CraftResult.new
  585.     @ingredients_window=Window_CraftIngredients.new
  586.     if @craft_window.data.size > 0 #本类窗口物品大于0的话
  587.       @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
  588.       @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
  589.                                                           @craft_window.recipe.ingredient_types,
  590.                                                           @craft_window.recipe.quantities)
  591.     end
  592.     @yes_no_window = Window_Command.new(100, ["确定", "放弃"])
  593.     @confirm_window.visible = false
  594.     @confirm_window.z = 1500
  595.     @yes_no_window.visible = false
  596.     @yes_no_window.active = false
  597.     @yes_no_window.index = 1
  598.     @yes_no_window.x = 270
  599.     @yes_no_window.y = 252
  600.     @yes_no_window.z = 1500
  601.     @label_window = Window_Base.new(450,200,190,52)
  602.     @label_window.contents=Bitmap.new(@label_window.width - 32,@label_window.height - 32)
  603.     @label_window.contents.font.size=20
  604.     @label_window.contents.font.color = @label_window.normal_color
  605.     @label_window.contents.font.name = "黑体"
  606.     @label_window.contents.draw_text(0, 0, @label_window.contents.width, 20, "  现有   需要")
  607.     Graphics.transition
  608.     loop do
  609.       Graphics.update
  610.       Input.update
  611.       update
  612.       if $scene != self
  613.         break
  614.       end
  615.     end
  616.     Graphics.freeze
  617.     @help_window.dispose
  618.     @craft_window.dispose
  619.     @result_window.dispose
  620.     @ingredients_window.dispose
  621.     @confirm_window.dispose
  622.     @yes_no_window.dispose
  623.     @label_window.dispose
  624.   end

  625.   #--------------------------------------------------------------------------
  626.   def update
  627.     @craft_window.update
  628.     @ingredients_window.update
  629.     if @craft_window.active
  630.       update_craft
  631.       return
  632.     end
  633.     if @yes_no_window.active
  634.       confirm_update
  635.       return
  636.     end
  637.   end

  638.   #--------------------------------------------------------------------------
  639.   def update_craft
  640.     if Input.dir4 != 0
  641.       if @craft_window.data.size > 0 #本类窗口物品大于0的话
  642.         @result_window.set_result(@craft_window.recipe.result, @craft_window.recipe.result_type)
  643.         @ingredients_window.set_ingredients(@craft_window.recipe.ingredients,
  644.                                                            @craft_window.recipe.ingredient_types,
  645.                                                            @craft_window.recipe.quantities)
  646.       end
  647.     end
  648.     if Input.trigger?(Input::B)
  649.       $game_system.se_play($data_system.cancel_se)
  650.       $scene = Scene_Map.new
  651.       return
  652.     end
  653.     if Input.trigger?(Input::C) and $game_party.recipes.size != 0
  654.       @recipe = @craft_window.recipe
  655.       if @recipe != nil
  656.         if @recipe.have
  657.           @yes_no_window.active = true
  658.           @craft_window.active = false
  659.         else
  660.           $game_system.se_play($data_system.buzzer_se)
  661.           return
  662.         end
  663.       else
  664.         $game_system.se_play($data_system.buzzer_se)
  665.         return
  666.       end
  667.     end
  668.   end

  669.   #--------------------------------------------------------------------------
  670.   def confirm_update
  671.     @craft_index = @craft_window.index
  672.     @confirm_window.visible = true
  673.     @confirm_window.z = 1500
  674.     @yes_no_window.visible = true
  675.     @yes_no_window.active = true
  676.     @yes_no_window.z = 1500
  677.     @yes_no_window.update
  678.     string = "合成 " + @recipe.name + "?"
  679.     cw = @confirm_window.contents.text_size(string).width
  680.     center = @confirm_window.contents.width/2 - cw /2
  681.     unless @drawn
  682.       @confirm_window.contents.draw_text(center, 0, cw, 30, string)
  683.       @drawn = true
  684.     end
  685.     if Input.trigger?(Input::C)
  686.       if @yes_no_window.index == 0
  687.         $game_system.se_play($data_system.decision_se)
  688.         @recipe.make
  689.         $game_system.se_play($data_system.save_se)
  690.         $scene=Scene_Craft.new(@craft_type,@craft_index)
  691.       else
  692.         $game_system.se_play($data_system.cancel_se)
  693.         $scene=Scene_Craft.new(@craft_type,@craft_index)
  694.       end
  695.     end
  696.     if Input.trigger?(Input::B)
  697.       $game_system.se_play($data_system.cancel_se)
  698.       $scene=Scene_Craft.new(@craft_type,@craft_index)
  699.     end
  700.   end

  701. end # of Scene_Craft

  702. #==============================================================================
  703. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  704. # 欢迎访问www.66RPG.com
  705. # 梦想世界,在你手中
  706. #==============================================================================
复制代码
附加解释器修改内容:
  1. class Interpreter
  2.   def command_126
  3.     # 获取要操作的值
  4.     value = operate_value(@parameters[1], @parameters[2], @parameters[3])
  5.     # 增减物品
  6.     $game_party.gain_item(@parameters[0], value)
  7.     # 继续
  8.     if $judges.nil?
  9.       return true
  10.     else
  11.       $judges=nil
  12.       command_115
  13.     end
  14.   end
  15.   #--------------------------------------------------------------------------
  16.   # ● 增减武器
  17.   #--------------------------------------------------------------------------
  18.   def command_127
  19.     # 获取要操作的值
  20.     value = operate_value(@parameters[1], @parameters[2], @parameters[3])
  21.     # 增减武器
  22.     $game_party.gain_weapon(@parameters[0], value)
  23.     # 继续
  24.     if $judges.nil?
  25.       return true
  26.     else
  27.       $judges=nil
  28.       command_115
  29.     end
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # ● 增减防具
  33.   #--------------------------------------------------------------------------
  34.   def command_128
  35.     # 获取要操作的值
  36.     value = operate_value(@parameters[1], @parameters[2], @parameters[3])
  37.     # 增减防具
  38.     $game_party.gain_armor(@parameters[0], value)
  39.     # 继续
  40.     if $judges.nil?
  41.       return true
  42.     else
  43.       $judges=nil
  44.       command_115
  45.     end
  46.   end
  47. end
复制代码
背包脚本问题:
Scene_Warehouse
RUBY 代码复制
  1. # ————————————————————————————————————
  2. # 本脚本来自[url]www.66rpg.com[/url],转载请保留此信息
  3. # ————————————————————————————————————
  4. #==============================================================================
  5. # ■ Scene_Warehouse
  6. #------------------------------------------------------------------------------
  7. #  处理仓库画面的类。
  8. #==============================================================================
  9. class Scene_Warehouse
  10.   def main
  11.    # 生成帮助窗口
  12.    @help_window = Window_Help.new
  13.    # 生成动作窗口
  14.    @action_window = Window_Warehouse_Action.new
  15.    # 生成仓库标题
  16.    @title_window = Window_Warehouse_Title.new
  17.    # 生成分类窗口
  18.    @sorting_window = Window_Warehouse_Sorting.new
  19.    @sorting_window.index = -1
  20.    @sorting_window.active = false
  21.    # 生成物品窗口
  22.    @item_window = Window_Warehouse_Item.new
  23.    @item_window.active = false
  24.    @item_window.help_window = @help_window
  25.    # 生成数量输入窗口
  26.    @number_window = Window_Warehouse_Number.new
  27.    @number_window.active = false
  28.    @number_window.visible = false
  29.    # 初始化项目
  30.    @item_index = -1
  31.    # 执行过渡
  32.    Graphics.transition
  33.    # 主循环
  34.    loop do
  35.      # 刷新游戏画面
  36.      Graphics.update
  37.      # 刷新输入信息
  38.      Input.update
  39.      # 刷新画面
  40.      update
  41.      # 如果画面切换的话就中断循环
  42.      if $scene != self
  43.        break
  44.      end
  45.    end
  46.    # 准备过渡
  47.    Graphics.freeze
  48.    # 释放窗口
  49.    @help_window.dispose
  50.    @action_window.dispose
  51.    @title_window.dispose
  52.    @sorting_window.dispose
  53.    @item_window.dispose
  54.    @number_window.dispose
  55. end
  56.  
  57.  
  58.   #--------------------------------------------------------------------------
  59.   # 更新画面
  60.   #--------------------------------------------------------------------------
  61. def update
  62.    # 更新窗口内容
  63.      @help_window.update
  64.      @action_window.update
  65.      @title_window.update
  66.    # 更新动作窗口
  67.      if @action_window.active
  68.        update_action_window
  69.        return
  70.      end
  71.    # 更新分类窗口
  72.      if @sorting_window.active
  73.        update_sorting_window
  74.      end
  75.    # 更新物品窗口  
  76.      if @item_window.active
  77.        update_item_window
  78.       return
  79.      end
  80.    # 更新数量输入窗口
  81.      if @number_window.active
  82.        update_number_window
  83.      end
  84.  
  85. end
  86.   #--------------------------------------------------------------------------
  87.   # 更新动作窗口
  88.   #--------------------------------------------------------------------------
  89. def update_action_window
  90.       # 按下 B 键的情况下
  91.    if Input.trigger?(Input::B)
  92.      # 演奏取消 SE
  93.      $game_system.se_play($data_system.cancel_se)
  94.      # 切换到地图画面
  95.      $scene = Scene_Map.new
  96.      return
  97.    end
  98.       # 按下 C 键的情况下
  99.    if Input.trigger?(Input::C)
  100.      # 命令窗口光标位置分支
  101.      case @action_window.index
  102.      when 0  # 存入
  103.        # 演奏确定 SE
  104.        $game_system.se_play($data_system.decision_se)
  105.        @action_window.active = false
  106.        @sorting_window.active = true
  107.        @sorting_window.index = 0
  108.        when 1  # 取出
  109.        # 演奏确定 SE
  110.        $game_system.se_play($data_system.decision_se)
  111.        @action_window.active = false
  112.        @sorting_window.active = true
  113.        @sorting_window.index = 0
  114.        @sorting_window.refresh(1)
  115.      when 2  # 取消
  116.        # 演奏确定 SE
  117.        $game_system.se_play($data_system.decision_se)
  118.        # 切换到地图画面
  119.        $scene = Scene_Map.new
  120.      end
  121.      return
  122.    end
  123.    @sorting_window.refresh(@action_window.index)
  124. end
  125.  
  126.   #--------------------------------------------------------------------------
  127.   # 更新分类窗口
  128.   #--------------------------------------------------------------------------
  129.  
  130. def update_sorting_window
  131.          # 按下 B 键的情况下
  132.    if Input.trigger?(Input::B)
  133.      # 演奏取消 SE
  134.      $game_system.se_play($data_system.cancel_se)
  135.      # 切换到地图画面
  136.        @sorting_window.index = -1
  137.        @sorting_window.update
  138.        @action_window.active = true
  139.        @sorting_window.active = false
  140.        @item_window.set_item("")
  141.      return
  142.    end
  143.       # 按下 C 键的情况下
  144.      if Input.trigger?(Input::C)
  145.        if @action_window.index == 0
  146.          if @sorting_window.have_item(@sorting_window.index) != @sorting_window.disabled_color
  147.           $game_system.se_play($data_system.decision_se)
  148.           @sorting_window.active = false
  149.           @item_window.active = true
  150.           @item_window.index = 0
  151.          else
  152.           $game_system.se_play($data_system.buzzer_se)
  153.         end
  154.       else
  155.         if @sorting_window.have_item_w(@sorting_window.index) != @sorting_window.disabled_color
  156.           $game_system.se_play($data_system.decision_se)
  157.           @sorting_window.active = false
  158.           @item_window.active = true
  159.           @item_window.index = 0
  160.         else
  161.           $game_system.se_play($data_system.buzzer_se)
  162.         end
  163.       end
  164.     end
  165.  
  166.       # 更新物品窗口
  167.         if @action_window.index == 0
  168.           @item_window.set_item(@sorting_window.commands[@sorting_window.index])
  169.         elsif @action_window.index ==1
  170.           @item_window.set_item_w(@sorting_window.commands[@sorting_window.index])
  171.         end
  172.       @sorting_window.update
  173. end
  174.  
  175.   #--------------------------------------------------------------------------
  176.   # 更新物品窗口
  177.   #--------------------------------------------------------------------------
  178.   def update_item_window
  179.    if Input.trigger?(Input::B)
  180.      # 演奏取消 SE
  181.      $game_system.se_play($data_system.cancel_se)
  182.      @sorting_window.active = true
  183.      @item_window.active = false
  184.      @item_window.index = -1
  185.      @help_window.set_text("")
  186.      return
  187.    end
  188.    # 按下确定键
  189.    if Input.trigger?(Input::C)
  190.      # 获取物品数量
  191.        $game_system.se_play($data_system.decision_se)
  192.        if @item_window.item.is_a?(RPG::Item)
  193.            if @action_window.index == 0
  194.              i = $game_party.item_number(@item_window.item.id)
  195.            else
  196.              i = $game_party.get_warehouse(@item_window.item.id,"I")
  197.            end
  198.          elsif @item_window.item.is_a?(RPG::Weapon)
  199.            if @action_window.index == 0
  200.              i = $game_party.weapon_number(@item_window.item.id)
  201.            else
  202.              i = $game_party.get_warehouse(@item_window.item.id,"W")
  203.            end
  204.          else
  205.            if @action_window.index == 0
  206.              i = $game_party.armor_number(@item_window.item.id)
  207.            else
  208.              i = $game_party.get_warehouse(@item_window.item.id,"A")
  209.            end
  210.         end
  211.      @number_window.set(@item_window.item, i)      
  212.      @number_window.active = true
  213.      @number_window.visible = true
  214.      @item_window.active = false
  215.    end
  216.    @item_window.update
  217.         if @action_window.index == 0
  218.           @item_window.set_item(@sorting_window.commands[@sorting_window.index])
  219.         elsif @action_window.index ==1
  220.           @item_window.set_item_w(@sorting_window.commands[@sorting_window.index])
  221.         end
  222.  
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # 更新输入窗口
  226.   #--------------------------------------------------------------------------
  227.   def update_number_window
  228.     @number_window.update
  229.     if Input.trigger?(Input::B)
  230.      # 演奏取消 SE
  231.      $game_system.se_play($data_system.cancel_se)
  232.      @number_window.active = false
  233.      @number_window.visible = false
  234.      @item_window.active = true
  235.      return
  236.    end
  237.    if Input.trigger?(Input::C)
  238.      #处理存储操作
  239.      if @action_window.index == 0
  240.         $game_system.se_play($data_system.decision_se)
  241.         @number_window.active = false
  242.         @number_window.visible = false
  243.         @item_window.active = true
  244.         if @number_window.get_item.is_a?(RPG::Item)
  245.            $game_party.add_warehouse(@number_window.get_item.id,@number_window.number,"I")
  246.            $game_party.lose_item(@number_window.get_item.id, @number_window.number)
  247.         elsif @number_window.get_item.is_a?(RPG::Weapon)
  248.            $game_party.add_warehouse(@number_window.get_item.id,@number_window.number,"W")
  249.            $game_party.lose_weapon(@number_window.get_item.id, @number_window.number)
  250.         else
  251.            $game_party.add_warehouse(@number_window.get_item.id,@number_window.number,"A")
  252.            $game_party.lose_armor(@number_window.get_item.id, @number_window.number)
  253.          end
  254.         #判读储存后状态
  255.         if @sorting_window.have_item(@sorting_window.index) == @sorting_window.disabled_color
  256.           @item_window.index = -1
  257.           @item_window.active = false
  258.           @sorting_window.active = true
  259.           @sorting_window.refresh
  260.           @help_window.set_text("")
  261.         end
  262.       elsif @action_window.index == 1
  263.         @item = @number_window.get_item
  264.         type = @item.is_a?(RPG::Item) ? 0 : (@item.is_a?(RPG::Weapon) ? 1 : 2)
  265.         if $game_party.full_judge?(@item.id, @number_window.number, type)
  266.           $game_party.full_top
  267.           return
  268.         end
  269.          @number_window.active = false
  270.          @number_window.visible = false
  271.          @item_window.active = true
  272.  
  273.         if @number_window.get_item.is_a?(RPG::Item)
  274.           i = $game_party.item_number(@item_window.item.id) + @number_window.number
  275.         elsif @number_window.get_item.is_a?(RPG::Weapon)
  276.           i = $game_party.weapon_number(@item_window.item.id) + @number_window.number
  277.         else
  278.           i = $game_party.armor_number(@item_window.item.id) + @number_window.number
  279.         end
  280.         if i <= 99
  281.           $game_system.se_play($data_system.decision_se)
  282.           if @number_window.get_item.is_a?(RPG::Item)
  283.             $game_party.gain_item(@number_window.get_item.id, @number_window.number)
  284.             $game_party.del_warehouse(@number_window.get_item.id,@number_window.number,"I") if $judges.nil?
  285.             $judge=nil
  286.           elsif @number_window.get_item.is_a?(RPG::Weapon)
  287.             $game_party.gain_weapon(@number_window.get_item.id, @number_window.number)
  288.             $game_party.del_warehouse(@number_window.get_item.id,@number_window.number,"W") if $judges.nil?
  289.             $judge=nil
  290.           else
  291.             $game_party.gain_armor(@number_window.get_item.id, @number_window.number)
  292.             $game_party.del_warehouse(@number_window.get_item.id,@number_window.number,"A") if $judges.nil?
  293.             $judge=nil
  294.           end
  295.         else
  296.           $game_system.se_play($data_system.buzzer_se)
  297.         end
  298.         #判读储存后状态
  299.         if @sorting_window.have_item_w(@sorting_window.index) == @sorting_window.disabled_color
  300.           @item_window.index = -1
  301.           @item_window.active = false
  302.           @sorting_window.active = true
  303.           @sorting_window.refresh(1)
  304.           @help_window.set_text("")
  305.         end
  306.       end
  307.     end
  308.   end
  309. end


卸下装备的问题解决代码:
RUBY 代码复制
  1. class Game_Actor
  2.   def tests(id)
  3.     case id
  4.     when 0
  5.       $game_party.gain_weapon($data_actors[@actor_id].weapon_id,1)
  6.     when 1
  7.       $game_party.gain_weapon($data_actors[@actor_id].armor1_id,1)
  8.     when 2
  9.       $game_party.gain_weapon($data_actors[@actor_id].armor2_id,1)
  10.     when 3
  11.       $game_party.gain_weapon($data_actors[@actor_id].armor3_id,1)
  12.     when 4
  13.       $game_party.gain_weapon($data_actors[@actor_id].armor4_id,1)
  14.     end
  15.     if $judges.nil?
  16.       case id
  17.       when 0
  18.         $game_party.gain_weapon($data_actors[@actor_id].weapon_id,-1)
  19.       when 1
  20.         $game_party.gain_weapon($data_actors[@actor_id].armor1_id,-1)
  21.       when 2
  22.         $game_party.gain_weapon($data_actors[@actor_id].armor2_id,-1)
  23.       when 3
  24.         $game_party.gain_weapon($data_actors[@actor_id].armor3_id,-1)
  25.       when 4
  26.         $game_party.gain_weapon($data_actors[@actor_id].armor4_id,-1)
  27.       end
  28.       return false
  29.     else
  30.       $judges = nil
  31.       return true
  32.     end
  33.   end
  34. end
  35. class Scene_Equip
  36.   def update_right
  37.     # 按下 B 键的情况下
  38.     if Input.trigger?(Input::B)
  39.       # 演奏取消 SE
  40.       $game_system.se_play($data_system.cancel_se)
  41.       # 切换到菜单画面
  42.       $scene = Scene_Menu.new(2)
  43.       return
  44.     end
  45.     # 按下 C 键的情况下
  46.     if Input.trigger?(Input::C)
  47.       # 固定装备的情况下
  48.       if @actor.equip_fix?(@right_window.index) or @actor.tests(@right_window.index)
  49.         # 演奏冻结 SE
  50.         $game_system.se_play($data_system.buzzer_se)
  51.         return
  52.       end
  53.       # 演奏确定 SE
  54.       $game_system.se_play($data_system.decision_se)
  55.       # 激活物品窗口
  56.       @right_window.active = false
  57.       @item_window.active = true
  58.       @item_window.index = 0
  59.       return
  60.     end
  61.     # 按下 R 键的情况下
  62.     if Input.trigger?(Input::R)
  63.       # 演奏光标 SE
  64.       $game_system.se_play($data_system.cursor_se)
  65.       # 移至下一位角色
  66.       @actor_index += 1
  67.       @actor_index %= $game_party.actors.size
  68.       # 切换到别的装备画面
  69.       $scene = Scene_Equip.new(@actor_index, @right_window.index)
  70.       return
  71.     end
  72.     # 按下 L 键的情况下
  73.     if Input.trigger?(Input::L)
  74.       # 演奏光标 SE
  75.       $game_system.se_play($data_system.cursor_se)
  76.       # 移至上一位角色
  77.       @actor_index += $game_party.actors.size - 1
  78.       @actor_index %= $game_party.actors.size
  79.       # 切换到别的装备画面
  80.       $scene = Scene_Equip.new(@actor_index, @right_window.index)
  81.       return
  82.     end
  83.   end
  84. end


范例:
Project2.rar (731.34 KB, 下载次数: 78)
偶是熬夜学编程的傻子
回复

使用道具 举报

Lv1.梦旅人

超级囧神 无尽的灌水

梦石
0
星屑
144
在线时间
784 小时
注册时间
2010-6-27
帖子
2065
3
发表于 2015-2-15 13:56:31 | 只看该作者
需求呢
比如说你装备卸下,你是希望 此件装备 无法卸下去
还是会提示丢掉某件物品
比如说仓库里取出物品有限制
不过我觉得为脚本互相添加逻辑是很麻烦的一件事情(主要是我不想读这些脚本),不过没有需求问题不会被实际解决这点请你注意
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
64
在线时间
124 小时
注册时间
2015-1-30
帖子
61
4
 楼主| 发表于 2015-2-15 16:07:25 | 只看该作者
a554187203 发表于 2015-2-15 13:56
需求呢
比如说你装备卸下,你是希望 此件装备 无法卸下去
还是会提示丢掉某件物品

我不想弄的太复杂,背包满时一切往背包里添加东西的行动都无法进行就可以了,当然这些东西不要凭空消失

点评

刚刚又修改了下,突然发现了点错误,现在改完了。  发表于 2015-2-15 21:00
回复

使用道具 举报

Lv1.梦旅人

超级囧神 无尽的灌水

梦石
0
星屑
144
在线时间
784 小时
注册时间
2010-6-27
帖子
2065
5
发表于 2015-2-15 16:42:49 | 只看该作者
XVI 发表于 2015-2-15 16:07
我不想弄的太复杂,背包满时一切往背包里添加东西的行动都无法进行就可以了,当然这些东西不要凭空消失 ...

你这功能实际上还是异常复杂的
您的整合脚本中添加物品有几种方法
合成添加 - 合成之后的物品还要个额外的合成仓库来存储吗……
仓库提取 - 这个无法提取还是好解决的
关键是,一个添加了独立开关的宝箱或是npc ,此物品应放在哪里?
(σ゚д゚)σ
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
64
在线时间
124 小时
注册时间
2015-1-30
帖子
61
6
 楼主| 发表于 2015-2-15 17:43:59 | 只看该作者
a554187203 发表于 2015-2-15 16:42
你这功能实际上还是异常复杂的
您的整合脚本中添加物品有几种方法
合成添加 - 合成之后的物品还 ...

合成的话 所有物品的分类都是数据库定义的
最后一句话我不是很理解,你的意思是拿不下了东西该怎么办么,那样的话不用担心 我还备有丢弃物品的脚本
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
64
在线时间
124 小时
注册时间
2015-1-30
帖子
61
7
 楼主| 发表于 2015-2-15 21:46:53 | 只看该作者
wolves 发表于 2015-2-15 19:45
整合好了:
加入了一个$judges变量,与其它脚本整合需要注意。
修改了解释器内容。

范例工程中写不下防具 从箱子里取出道具时依然可以取出99+个 能否再看一下 谢谢
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
150
在线时间
332 小时
注册时间
2013-7-6
帖子
356
8
发表于 2015-2-15 21:51:24 | 只看该作者
XVI 发表于 2015-2-15 21:46
范例工程中写不下防具 从箱子里取出道具时依然可以取出99+个 能否再看一下 谢谢 ...

改完了,看看如何
偶是熬夜学编程的傻子
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
64
在线时间
124 小时
注册时间
2015-1-30
帖子
61
9
 楼主| 发表于 2015-2-15 22:16:33 | 只看该作者
wolves 发表于 2015-2-15 21:51
改完了,看看如何

老样子啊 难道我打开方式不对么
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
150
在线时间
332 小时
注册时间
2013-7-6
帖子
356
10
发表于 2015-2-16 00:20:04 | 只看该作者
本帖最后由 wolves 于 2015-2-16 08:47 编辑
XVI 发表于 2015-2-15 22:16
老样子啊 难道我打开方式不对么


找到问题了,忘了加个$judges=nil了,这回试试看,应该没有问题了@XVI
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-20 03:00

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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