查看: 2327|回复: 2

[已经过期] 怎么改可以给物品栏添加丢弃功能

[复制链接]
梦石
0
星屑
12161
在线时间
4435 小时
注册时间
2014-4-11
回帖
5616

开拓者

发表于 2014-11-30 13:06:45 | 显示全部楼层 |阅读模式

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

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

×
默认的物品栏点过去是直接使用的。能不能改成点过去弹出使用和丢弃。除了重要物品以外全可以丢弃。
梦石
0
星屑
9557
在线时间
5074 小时
注册时间
2013-6-21
回帖
3459

开拓者贵宾剧作品鉴家

发表于 2014-11-30 14:53:44 | 显示全部楼层
https://rpg.blue/forum.php?mod=viewthread&tid=371528
记得提问区曾经有这样的帖子,不知道我写的那个直接拿去用还行不行
回复

使用道具 举报

梦石
0
星屑
12161
在线时间
4435 小时
注册时间
2014-4-11
回帖
5616

开拓者

 楼主| 发表于 2014-11-30 22:34:09 | 显示全部楼层
RyanBern 发表于 2014-11-30 14:53
https://rpg.blue/forum.php?mod=viewthread&tid=371528
记得提问区曾经有这样的帖子,不知道我写的那个 ...

和我的脚本冲突了。
我有物品分类脚本
  1. #==============================================================================
  2. # ■ 物品分类
  3. #==============================================================================

  4. # 主体窗口透明度
  5. OPACITY_Item = 0
  6. # 使用物品窗口透明度
  7. OPACITY_Target = 200
  8. #==============================================================================
  9. # ■ RPG追加定义
  10. #==============================================================================
  11. module RPG
  12.   #--------------------------------------------------------------------------
  13.   # ● 物品追加
  14.   #--------------------------------------------------------------------------
  15.   class Item
  16.     def description
  17.       description = @description.split(/@/)[0]
  18.       return description != nil ? description : ''
  19.     end
  20.     def desc
  21.       desc = @description.split(/@/)[1]
  22.       return desc != nil ? desc : "物品"
  23.     end
  24.   end
  25.   #--------------------------------------------------------------------------
  26.   # ● 武器追加
  27.   #--------------------------------------------------------------------------
  28.   class Weapon
  29.     def description
  30.       description = @description.split(/@/)[0]
  31.       return description != nil ? description : ''
  32.     end
  33.     def desc
  34.       desc = @description.split(/@/)[1]
  35.       return desc != nil ? desc : "武器"
  36.     end
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # ● 防具追加
  40.   #--------------------------------------------------------------------------
  41.   class Armor
  42.     def description
  43.       description = @description.split(/@/)[0]
  44.       return description != nil ? description : ''
  45.     end
  46.     def desc
  47.       desc = @description.split(/@/)[1]
  48.       return desc != nil ? desc : "防具"
  49.     end
  50.   end
  51. end

  52. #==============================================================================
  53. # ■ Window_Target
  54. #------------------------------------------------------------------------------
  55. #  物品画面与特技画面的、使用对像角色选择窗口。
  56. #   修复使用物品时还有跟随帮助窗口....
  57. #==============================================================================

  58. class Window_Target < Window_Selectable
  59.   #--------------------------------------------------------------------------
  60.   # ● 刷新帮助文本
  61.   #--------------------------------------------------------------------------
  62.   def update_help
  63.     @help_window.set_text(item)
  64.     #校正帮助窗口位置
  65.     @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
  66.   end
  67. end

  68. #==============================================================================
  69. # ■ Window_ItemCommand
  70. #------------------------------------------------------------------------------
  71. #  显示分类的窗口。
  72. #==============================================================================

  73. class Window_ItemCommand < Window_Selectable
  74.   attr_accessor :commands
  75.   #--------------------------------------------------------------------------
  76.   # ● 初始化对像
  77.   #     commands : 命令字符串序列
  78.   #--------------------------------------------------------------------------
  79.   def initialize
  80.     super(0, 0, 160, 416)
  81.     self.opacity = OPACITY_Item
  82.     @commands = []
  83.     # 获取物品
  84.     for i in 1...$data_items.size
  85.       if $game_party.item_number(i) > 0
  86.         push = true
  87.         for com in @commands
  88.           if com == $data_items[i].desc
  89.             push = false
  90.           end
  91.         end
  92.         if push == true
  93.           @commands.push($data_items[i].desc)
  94.         end
  95.       end
  96.     end
  97.     # 获取武器
  98.     for i in 1...$data_weapons.size
  99.       if $game_party.weapon_number(i) > 0
  100.         push = true
  101.         for com in @commands
  102.           if com == $data_weapons[i].desc
  103.             push = false
  104.           end
  105.         end
  106.         if push == true
  107.           @commands.push($data_weapons[i].desc)
  108.         end
  109.       end
  110.     end
  111.     # 获取防具
  112.     for i in 1...$data_armors.size
  113.       if $game_party.armor_number(i) > 0
  114.         push = true
  115.         for com in @commands
  116.           if com == $data_armors[i].desc
  117.             push = false
  118.           end
  119.         end
  120.         if push == true
  121.           @commands.push($data_armors[i].desc)
  122.         end
  123.       end
  124.     end
  125.     if @commands == []
  126.       @commands.push("普通物品")
  127.     end
  128.     @item_max = @commands.size
  129.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  130.     refresh
  131.     self.index = 0
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # ● 刷新
  135.   #--------------------------------------------------------------------------
  136.   def refresh
  137.     self.contents.clear
  138.     for i in 0...@item_max
  139.       draw_item(i, normal_color)
  140.     end
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● 描绘项目
  144.   #     index : 项目编号
  145.   #     color : 文字色
  146.   #--------------------------------------------------------------------------
  147.   def draw_item(index, color)
  148.     self.contents.font.color = color
  149.     y = index * 32
  150.     self.contents.draw_text(4, y, 128, 32, @commands[index])
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # ● 刷新帮助文本
  154.   #--------------------------------------------------------------------------
  155.   def update_help
  156.     @help_window.set_text(item)
  157.     #校正帮助窗口位置
  158.     @help_window.set_pos(self.x,self.y,32,self.oy,self.index,@column_max)
  159.   end
  160. end

  161. #==============================================================================
  162. # ■ Window_Item
  163. #------------------------------------------------------------------------------
  164. #  物品画面、战斗画面、显示浏览物品的窗口。
  165. #==============================================================================

  166. class Window_ItemList < Window_Selectable
  167.   #--------------------------------------------------------------------------
  168.   # ● 初始化对像
  169.   #--------------------------------------------------------------------------
  170.   def initialize
  171.     super(160, 0, 480, 480)
  172.     self.opacity = OPACITY_Item
  173.     @column_max = 2
  174.     refresh
  175.     self.index = 0
  176.   end
  177.   #--------------------------------------------------------------------------
  178.   # ● 获取物品
  179.   #--------------------------------------------------------------------------
  180.   def item
  181.     return @data[self.index]
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # ● 刷新
  185.   #--------------------------------------------------------------------------
  186.   def refresh
  187.     if self.contents != nil
  188.       self.contents.dispose
  189.       self.contents = nil
  190.     end
  191.     @data = []
  192.   end
  193.   #--------------------------------------------------------------------------
  194.   # ● 分类
  195.   #     command : 类别名称
  196.   #--------------------------------------------------------------------------
  197.   def set_item(command)
  198.     refresh
  199.     if $game_temp.in_battle
  200.       # 添加物品
  201.       for i in 1...$data_items.size
  202.         if $game_party.item_number(i) > 0
  203.           @data.push($data_items[i])
  204.         end
  205.       end
  206.     end
  207.     for i in 1...$data_items.size
  208.       if $game_party.item_number(i) > 0 and $data_items[i].desc == command
  209.         @data.push($data_items[i])
  210.       end
  211.     end
  212.     for i in 1...$data_weapons.size
  213.       if $game_party.weapon_number(i) > 0 and $data_weapons[i].desc == command
  214.         @data.push($data_weapons[i])
  215.       end
  216.     end
  217.     for i in 1...$data_armors.size
  218.       if $game_party.armor_number(i) > 0 and $data_armors[i].desc == command
  219.         @data.push($data_armors[i])
  220.       end
  221.     end
  222.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  223.     @item_max = @data.size
  224.     if @item_max > 0
  225.       self.contents = Bitmap.new(width - 32, row_max * 32)
  226.       self.contents.clear
  227.       for i in 0...@item_max
  228.         draw_item(i)
  229.       end
  230.     end
  231.   end
  232.   #--------------------------------------------------------------------------
  233.   # ● 获取物品的所持数
  234.   #--------------------------------------------------------------------------
  235.   def item_number
  236.     return @item_max
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # ● 描绘项目
  240.   #     index : 项目编号
  241.   #--------------------------------------------------------------------------
  242.   def draw_item(index)
  243.     item = @data[index]
  244.     case item
  245.     when RPG::Item
  246.       number = $game_party.item_number(item.id)
  247.     when RPG::Weapon
  248.       number = $game_party.weapon_number(item.id)
  249.     when RPG::Armor
  250.       number = $game_party.armor_number(item.id)
  251.     end
  252.     if item.is_a?(RPG::Item) and
  253.       $game_party.item_can_use?(item.id)
  254.       self.contents.font.color = normal_color
  255.     else
  256.       self.contents.font.color = disabled_color
  257.     end
  258.     x = 4 + index % 2 * (208 + 32)
  259.     y = index / 2 * 32
  260.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  261.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  262.     bitmap = RPG::Cache.icon(item.icon_name)
  263.     opacity = self.contents.font.color == normal_color ? 255 : 128
  264.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  265.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  266.     self.contents.draw_text(x + 170, y, 16, 32, ":", 1)
  267.     self.contents.draw_text(x + 176, y, 24, 32, number.to_s, 2)
  268.   end
  269.   #--------------------------------------------------------------------------
  270.   # ● 刷新帮助文本
  271.   #--------------------------------------------------------------------------
  272.   def update_help
  273.     @help_window.set_text(item)
  274.     #校正帮助窗口位置
  275.     @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
  276.   end
  277. end

  278. #==============================================================================
  279. # ■ Scene_Item
  280. #------------------------------------------------------------------------------
  281. #  处理物品画面的类。
  282. #==============================================================================

  283. class Scene_Item
  284.   #--------------------------------------------------------------------------
  285.   # ● 主处理
  286.   #--------------------------------------------------------------------------
  287.   def main
  288.     # 创建背景图
  289.     @itemmenu = Sprite.new
  290.     @itemmenu.bitmap = RPG::Cache.picture("物品背景.png")
  291.     # 生成帮助窗口、物品窗口
  292.     @itemcommand_window = Window_ItemCommand.new
  293.     @command_index = @itemcommand_window.index
  294.     @itemlist_window = Window_ItemList.new
  295.     @itemlist_window.active = false
  296.     @help_window = Window_Help.new
  297.     # 生成金钱窗口
  298.     @gold_window = Window_Gold.new
  299.     @gold_window.y = 416
  300.     @gold_window.opacity = OPACITY_Item
  301.     # 关联帮助窗口
  302.     @itemcommand_window.help_window = @help_window
  303.     @itemlist_window.help_window = @help_window
  304.     # 生成目标窗口 (设置为不可见・不活动)
  305.     @target_window = Window_Target.new
  306.     # 关联帮助窗口
  307.     @target_window.help_window = @help_window
  308.     @target_window.opacity = OPACITY_Target
  309.     @target_window.visible = false
  310.     @target_window.active = false
  311.     @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  312.     # 执行过度
  313.     Graphics.transition
  314.     # 主循环
  315.     loop do
  316.       # 刷新游戏画面
  317.       Graphics.update
  318.       # 刷新输入信息
  319.       Input.update
  320.       # 刷新画面
  321.       update
  322.       # 如果画面切换就中断循环
  323.       if $scene != self
  324.         break
  325.       end
  326.     end
  327.     # 装备过渡
  328.     Graphics.freeze
  329.     # 释放窗口
  330.     @itemmenu.dispose
  331.     @itemcommand_window.dispose
  332.     @itemlist_window.dispose
  333.     @gold_window.dispose
  334.     @help_window.dispose
  335.     @target_window.dispose
  336.   end
  337.   #--------------------------------------------------------------------------
  338.   # ● 刷新画面
  339.   #--------------------------------------------------------------------------
  340.   def update
  341.     # 刷新窗口
  342.     @help_window.update
  343.     @gold_window.update
  344.     @itemlist_window.update
  345.     @itemcommand_window.update
  346.     @target_window.update
  347.     if @command_index != @itemcommand_window.index
  348.       @command_index = @itemcommand_window.index
  349.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  350.     end
  351.     # 分类窗口被激活的情况下: 调用 update_itemcommand
  352.     if @itemcommand_window.active
  353.       update_itemcommand
  354.       return
  355.     end
  356.     # 物品窗口被激活的情况下: 调用 update_itemlist
  357.     if @itemlist_window.active
  358.       update_itemlist
  359.       return
  360.     end
  361.     # 目标窗口被激活的情况下: 调用 update_target
  362.     if @target_window.active
  363.       update_target
  364.       return
  365.     end
  366.   end
  367.   #--------------------------------------------------------------------------
  368.   # ● 刷新画面 (分类窗口被激活的情况下)
  369.   #--------------------------------------------------------------------------
  370.   def update_itemcommand
  371.     # 按下 B 键的情况下
  372.     if Input.trigger?(Input::B)
  373.       # 演奏取消 SE
  374.       $game_system.se_play($data_system.cancel_se)
  375.       # 切换到菜单画面
  376.       $scene = Scene_Menu.new(0)
  377.       return
  378.     end
  379.     if Input.trigger?(Input::C)
  380.       # 按下 C 键的情况下
  381.       if @itemlist_window.item_number == 0
  382.         # 演奏冻结 SE
  383.         $game_system.se_play($data_system.buzzer_se)
  384.         return
  385.       end
  386.       # 演奏确定 SE
  387.       $game_system.se_play($data_system.decision_se)
  388.       # 激活目标窗口
  389.       @itemcommand_window.active = false
  390.       @itemlist_window.active = true
  391.       @itemlist_window.index = 0
  392.       return
  393.     end
  394.   end
  395.   #--------------------------------------------------------------------------
  396.   # ● 刷新画面 (物品窗口被激活的情况下)
  397.   #--------------------------------------------------------------------------
  398.   def update_itemlist
  399.     # 按下 B 键的情况下
  400.     if Input.trigger?(Input::B)
  401.       # 演奏取消 SE
  402.       $game_system.se_play($data_system.cancel_se)
  403.       @itemcommand_window.active = true
  404.       @itemlist_window.active = false
  405.       @itemlist_window.index = 0
  406.       # 切换到分类窗口
  407.       @itemcommand_window.index = @command_index
  408.       return
  409.     end
  410.     if Input.trigger?(Input::C)
  411.       # 获取物品窗口当前选中的物品数据
  412.       @item = @itemlist_window.item
  413.       # 不使用物品的情况下
  414.       unless @item.is_a?(RPG::Item)
  415.         # 演奏冻结 SE
  416.         $game_system.se_play($data_system.buzzer_se)
  417.         return
  418.       end
  419.       # 不能使用的情况下
  420.       unless $game_party.item_can_use?(@item.id)
  421.         # 演奏冻结 SE
  422.         $game_system.se_play($data_system.buzzer_se)
  423.         return
  424.       end
  425.       # 演奏确定 SE
  426.       $game_system.se_play($data_system.decision_se)
  427.       # 效果范围是我方的情况下
  428.       if @item.scope >= 3
  429.         # 激活目标窗口
  430.         @itemlist_window.active = false
  431.         @target_window.x = 304
  432.         @target_window.visible = true
  433.         @target_window.active = true
  434.         # 设置效果范围 (单体/全体) 的对应光标位置
  435.         if @item.scope == 4 || @item.scope == 6
  436.           @target_window.index = -1
  437.         else
  438.           @target_window.index = 0
  439.         end
  440.         # 效果在我方以外的情况下
  441.       else
  442.         # 公共事件 ID 有效的情况下
  443.         if @item.common_event_id > 0
  444.           # 预约调用公共事件
  445.           $game_temp.common_event_id = @item.common_event_id
  446.           # 演奏物品使用时的 SE
  447.           $game_system.se_play(@item.menu_se)
  448.           # 消耗品的情况下
  449.           if @item.consumable
  450.             # 使用的物品数减 1
  451.             $game_party.lose_item(@item.id, 1)
  452.             # 再描绘物品窗口的项目
  453.             @itemlist_window.draw_item(@itemlist_window.index)
  454.           end
  455.           # 切换到地图画面
  456.           $scene = Scene_Map.new
  457.           return
  458.         end
  459.       end
  460.       return
  461.     end
  462.   end
  463.   #--------------------------------------------------------------------------
  464.   # ● 刷新画面 (目标窗口被激活的情况下)
  465.   #--------------------------------------------------------------------------
  466.   def update_target
  467.     # 按下 B 键的情况下
  468.     if Input.trigger?(Input::B)
  469.       # 演奏取消 SE
  470.       $game_system.se_play($data_system.cancel_se)
  471.       # 由于物品用完而不能使用的场合
  472.       unless $game_party.item_can_use?(@item.id)
  473.         # 再次生成物品窗口的内容
  474.         @itemlist_window.refresh
  475.       end
  476.       # 删除目标窗口
  477.       @itemlist_window.active = true
  478.       @target_window.visible = false
  479.       @target_window.active = false
  480.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  481.       return
  482.     end
  483.     # 按下 C 键的情况下
  484.     if Input.trigger?(Input::C)
  485.       # 如果物品用完的情况下
  486.       if $game_party.item_number(@item.id) == 0
  487.         # 演奏冻结 SE
  488.         $game_system.se_play($data_system.buzzer_se)
  489.         return
  490.       end
  491.       # 目标是全体的情况下
  492.       if @target_window.index == -1
  493.         used = false
  494.         for i in $game_party.actors
  495.           used |= i.item_effect(@item)
  496.         end
  497.       end
  498.       # 目标是单体的情况下
  499.       if @target_window.index >= 0
  500.         # 对目标角色应用物品的使用效果
  501.         target = $game_party.actors[@target_window.index]
  502.         used = target.item_effect(@item)
  503.       end
  504.       # 使用物品的情况下
  505.       if used
  506.         # 演奏物品使用时的 SE
  507.         $game_system.se_play(@item.menu_se)
  508.         # 使用的物品数减 1
  509.         if @item.consumable
  510.           $game_party.lose_item(@item.id, 1)
  511.           # 再描绘物品窗口的项目
  512.           @itemlist_window.draw_item(@itemlist_window.index)
  513.           @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  514.         end
  515.         # 再生成目标窗口的内容
  516.         @target_window.refresh
  517.         # 全灭的情况下
  518.         if $game_party.all_dead?
  519.           # 切换到游戏结束画面
  520.           $scene = Scene_Gameover.new
  521.           return
  522.         end
  523.         # 公共事件 ID 有效的情况下
  524.         if @item.common_event_id > 0
  525.           # 预约调用公共事件
  526.           $game_temp.common_event_id = @item.common_event_id
  527.           # 切换到地图画面
  528.           $scene = Scene_Map.new
  529.           return
  530.         end
  531.       end
  532.       # 无法使用物品的情况下
  533.       unless used
  534.         # 演奏冻结 SE
  535.         $game_system.se_play($data_system.buzzer_se)
  536.       end
  537.     return
  538.     end
  539.   end
  540. end
复制代码



还有这个背包限制脚本不冲突,不过我想改成0价格的物品不受限制。
  1. #==============================================================================
  2. # 背包可容纳最大的物品种类数。(包括物品,武器,防具)
  3. ITEMS_MAX = 2
  4. # 背包满后,如果再增加物品所提示的信息。
  5. TOP_MESSAGE = "背包已满!"
  6. $不显示金钱窗口 = 41
  7. $不显示物品窗口 = 42
  8. $不显示武器窗口 = 43
  9. $不显示防具窗口 = 44
  10. # 以上开关,当打开的时候,获得物品将不会提示,比如默认打开41号开关,获得金钱不再提示

  11. #==============================================================================
  12. class Game_Party
  13.   #---------------------------------------------------------------------
  14.   def items
  15.     return @items
  16.   end
  17.   #---------------------------------------------------------------------
  18.   def weapons
  19.     return @weapons
  20.   end
  21.   #---------------------------------------------------------------------
  22.   def armors
  23.     return @armors
  24.   end
  25. end
  26. #==============================================================================
  27. class Interpreter
  28.   #--------------------------------------------------------------------
  29.   def full_judge?(id, n, type)
  30.     mn = 0
  31.     mn += $game_party.items.keys.size
  32.     mn += $game_party.weapons.keys.size
  33.     mn += $game_party.armors.keys.size
  34.     return false if mn < ITEMS_MAX
  35.     case type
  36.     when 0
  37.       if $game_party.items.keys.include?(id)
  38.         return false if $game_party.item_number(id) + n <= 99
  39.       end
  40.     when 1
  41.       if $game_party.weapons.keys.include?(id)
  42.         return false if $game_party.weapon_number(id) + n <= 99
  43.       end
  44.     when 2
  45.       if $game_party.armors.keys.include?(id)
  46.         return false if $game_party.armor_number(id) + n <= 99
  47.       end
  48.     end
  49.     return true
  50.   end
  51.   #---------------------------------------------------------------------
  52.   def full_top
  53.     $game_system.se_play($data_system.buzzer_se)
  54.     top = Window_Base.new(200, 100, 240, 64)
  55.     top.contents = Bitmap.new(top.width - 32, top.height - 32)
  56.     top.contents.draw_text(0, 0, 200, 32, TOP_MESSAGE, 1)
  57.     for i in 1..30
  58.       Graphics.update
  59.     end
  60.     for i in 1..20
  61.       top.opacity -= 13
  62.       top.contents_opacity -= 13
  63.       Graphics.update
  64.     end
  65.     top.dispose
  66.   end
  67.   
  68.   
  69.   
  70.     def command_125
  71.     value = operate_value(@parameters[0], @parameters[1], @parameters[2])
  72.     $game_party.gain_gold(value)
  73.     if $game_switches[$不显示金钱窗口]==false
  74.       carol3_66RPG = Window_Base.new((640-160)/2,128,180,100)
  75.       carol3_66RPG.contents = Bitmap.new(carol3_66RPG.width - 32, carol3_66RPG.height - 32)
  76.       if value >= 0
  77.         carol3_66RPG.contents.draw_text(0,0,240,32,"获得金钱:")
  78.         #——声效,可以自己改
  79.         Audio.se_play("Audio/SE/"+"006-System06",80,100)
  80.       else
  81.         carol3_66RPG.contents.draw_text(0,0,240,32,"失去金钱:")
  82.         #——声效,可以自己改
  83.         Audio.se_play("Audio/SE/"+"005-System05",80,100)
  84.       end     
  85.       carol3_66RPG.contents.draw_text(0,32,240,32,value.abs.to_s)
  86.       carol3_66RPG.contents.draw_text(0,32,140,32, $data_system.words.gold,2)
  87.       carol3_66RPG.opacity = 160
  88.       for i in 0..10
  89.         Graphics.update
  90.       end
  91.       for i in 0..10
  92.         carol3_66RPG.opacity -= 30
  93.         carol3_66RPG.contents_opacity -= 30
  94.         Graphics.update
  95.       end
  96.       carol3_66RPG.dispose
  97.     end
  98.     return true
  99.   end

  100.   #--------------------------------------------------------------------------
  101.   # ● 增减物品
  102.   #--------------------------------------------------------------------------
  103.   def command_126
  104.     # 获取要操作的值
  105.     value = operate_value(@parameters[1], @parameters[2], @parameters[3])
  106.         if full_judge?(@parameters[0], value, 0)
  107.       full_top
  108.       command_115
  109.       return
  110.     end
  111.         # 增减物品
  112.     $game_party.gain_item(@parameters[0], value)
  113.         if $game_switches[$不显示物品窗口]==false
  114.       carol3_66RPG_item = $data_items[@parameters[0]]
  115.       carol3_66RPG = Window_Base.new((640-300)/2,128,300,100)
  116.       carol3_66RPG.contents = Bitmap.new(carol3_66RPG.width - 32, carol3_66RPG.height - 32)
  117.       if value >= 0
  118.         carol3_66RPG.contents.draw_text(0,0,240,32,"获得物品:")     
  119.         #——声效,可以自己改
  120.         Audio.se_play("Audio/SE/"+"006-System06",80,100)
  121.       else
  122.         carol3_66RPG.contents.draw_text(0,0,240,32,"失去物品:")     
  123.         #——声效,可以自己改
  124.         Audio.se_play("Audio/SE/"+"005-System05",80,100)
  125.       end
  126.       carol3_66RPG_bitmap = RPG::Cache.icon(carol3_66RPG_item.icon_name)
  127.       carol3_66RPG.contents.blt(0, 32, carol3_66RPG_bitmap, Rect.new(0, 0, 24, 24), 255)
  128.       carol3_66RPG.contents.draw_text(0 + 28, 32, 212, 32, carol3_66RPG_item.name, 0)
  129.       carol3_66RPG.contents.draw_text(0, 32, 268, 32, "×"+value.abs.to_s, 2)
  130.       carol3_66RPG.opacity = 160
  131.       for i in 0..10
  132.         Graphics.update
  133.       end
  134.       for i in 0..10
  135.         carol3_66RPG.opacity -= 30
  136.         carol3_66RPG.contents_opacity -= 30
  137.         Graphics.update
  138.       end
  139.       carol3_66RPG.dispose
  140.     end

  141.     # 继续

  142.     return true
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # ● 增减武器
  146.   #--------------------------------------------------------------------------
  147.   def command_127
  148.     # 获取要操作的值
  149.     value = operate_value(@parameters[1], @parameters[2], @parameters[3])
  150.     if full_judge?(@parameters[0], value, 1)
  151.       full_top
  152.       command_115
  153.       return
  154.     end
  155.     # 增减武器
  156.     $game_party.gain_weapon(@parameters[0], value)
  157.         if $game_switches[$不显示武器窗口]==false
  158.       carol3_66RPG_item = $data_weapons[@parameters[0]]
  159.       carol3_66RPG = Window_Base.new((640-300)/2,128,300,100)
  160.       carol3_66RPG.contents = Bitmap.new(carol3_66RPG.width - 32, carol3_66RPG.height - 32)
  161.       if value >= 0
  162.         carol3_66RPG.contents.draw_text(0,0,240,32,"获得武器:")     
  163.         #——声效,可以自己改
  164.         Audio.se_play("Audio/SE/"+"006-System06",80,100)
  165.       else
  166.         carol3_66RPG.contents.draw_text(0,0,240,32,"失去武器:")     
  167.         #——声效,可以自己改
  168.         Audio.se_play("Audio/SE/"+"005-System05",80,100)
  169.       end
  170.       carol3_66RPG_bitmap = RPG::Cache.icon(carol3_66RPG_item.icon_name)
  171.       carol3_66RPG.contents.blt(0, 32, carol3_66RPG_bitmap, Rect.new(0, 0, 24, 24), 255)
  172.       carol3_66RPG.contents.draw_text(0 + 28, 32, 212, 32, carol3_66RPG_item.name, 0)
  173.       carol3_66RPG.contents.draw_text(0, 32, 268, 32, "×"+value.abs.to_s, 2)
  174.       carol3_66RPG.opacity = 160
  175.       for i in 0..10
  176.         Graphics.update
  177.       end
  178.       for i in 0..10
  179.         carol3_66RPG.opacity -= 30
  180.         carol3_66RPG.contents_opacity -= 30
  181.         Graphics.update
  182.       end
  183.       carol3_66RPG.dispose
  184.     end

  185.     # 继续
  186.     return true
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ● 增减防具
  190.   #--------------------------------------------------------------------------
  191.   def command_128
  192.     # 获取要操作的值
  193.     value = operate_value(@parameters[1], @parameters[2], @parameters[3])
  194.     if full_judge?(@parameters[0], value, 2)
  195.       full_top
  196.       command_115
  197.       return
  198.     end
  199.     # 增减防具
  200.     $game_party.gain_armor(@parameters[0], value)
  201.         if $game_switches[$不显示防具窗口]==false
  202.       carol3_66RPG_item = $data_armors[@parameters[0]]
  203.       carol3_66RPG = Window_Base.new((640-300)/2,128,300,100)
  204.       carol3_66RPG.contents = Bitmap.new(carol3_66RPG.width - 32, carol3_66RPG.height - 32)
  205.       if value >= 0
  206.         carol3_66RPG.contents.draw_text(0,0,240,32,"获得防具:")     
  207.         #——声效,可以自己改
  208.         Audio.se_play("Audio/SE/"+"006-System06",80,100)
  209.       else
  210.         carol3_66RPG.contents.draw_text(0,0,240,32,"失去防具:")     
  211.         #——声效,可以自己改
  212.         Audio.se_play("Audio/SE/"+"005-System05",80,100)
  213.       end
  214.       carol3_66RPG_bitmap = RPG::Cache.icon(carol3_66RPG_item.icon_name)
  215.       carol3_66RPG.contents.blt(0, 32, carol3_66RPG_bitmap, Rect.new(0, 0, 24, 24), 255)
  216.       carol3_66RPG.contents.draw_text(0 + 28, 32, 212, 32, carol3_66RPG_item.name, 0)
  217.       carol3_66RPG.contents.draw_text(0, 32, 268, 32, "×"+value.abs.to_s, 2)
  218.       carol3_66RPG.opacity = 160
  219.       for i in 0..10
  220.         Graphics.update
  221.       end
  222.       for i in 0..10
  223.         carol3_66RPG.opacity -= 30
  224.         carol3_66RPG.contents_opacity -= 30
  225.         Graphics.update
  226.       end
  227.       carol3_66RPG.dispose
  228.     end

  229.     # 继续
  230.     return true
  231.   end
  232. end
  233. #==============================================================================
复制代码




我觉得这个VA的脚本可以参考
  1. #==============================================================================
  2. # ■ 物品丢弃 + 物品种类数限制 —— by 水镜风生
  3. #------------------------------------------------------------------------------
  4. LOSE_ITEM_SE_NAME = "Evasion"         # 丢弃物品时播放的SE
  5. ITEM_MAX_N = 12    # 储存物品最大种类数的事件变量的编号

  6. #==============================================================================
  7. # ■ Scene_Item
  8. #------------------------------------------------------------------------------
  9. #  处理物品画面的类。
  10. #==============================================================================

  11. class Scene_Item < Scene_Base
  12.   #--------------------------------------------------------------------------
  13.   # ● 开始处理
  14.   #--------------------------------------------------------------------------
  15.   def start
  16.     super
  17.     create_menu_background
  18.     @viewport = Viewport.new(0, 0, 544, 416)
  19.     @help_window = Window_Help.new
  20.     @help_window.viewport = @viewport
  21.     @item_window = Window_Item.new(0, 67, 544, 280)
  22.     @item_window.viewport = @viewport
  23.     @item_window.help_window = @help_window
  24.     @item_window.active = false
  25.     @target_window = Window_MenuStatus.new(0, 0)
  26.     @max_window = Window_Item_Max.new
  27.     @max_window.viewport = @viewport
  28.     @number_window = Window_LoseNumber.new(142, 156)
  29.     @number_window.viewport = @viewport
  30.     @command_window = Window_Command.new(145, ["   使用","   丢弃"], 1, 2)
  31.     @command_window.x = 200
  32.     @command_window.y = 160
  33.     @over_window = Window_Help.new
  34.     @over_window.set_text("背包放不下了,丢弃一些没用的物品吧。")
  35.     @over_window.visible = false
  36.     hide_command_window
  37.     hide_number_window
  38.     hide_target_window
  39.   end
  40.   #--------------------------------------------------------------------------
  41.   # ● 结束处理
  42.   #--------------------------------------------------------------------------
  43.   def terminate
  44.     super
  45.     dispose_menu_background
  46.     @viewport.dispose
  47.     @help_window.dispose
  48.     @item_window.dispose
  49.     @target_window.dispose
  50.     @max_window.dispose
  51.     @command_window.dispose
  52.     @number_window.dispose
  53.     @over_window.dispose
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ● 回到原画面
  57.   #--------------------------------------------------------------------------
  58.   def return_scene
  59.     $scene = Scene_Menu.new(0)
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # ● 更新画面
  63.   #--------------------------------------------------------------------------
  64.   def update
  65.     super
  66.     update_menu_background
  67.     @over_window.update
  68.     @help_window.update
  69.     @item_window.update
  70.     @target_window.update
  71.     @max_window.update
  72.     @command_window.update
  73.     @number_window.update
  74.     if @item_window.active
  75.       update_item_selection
  76.     elsif @target_window.active
  77.       update_target_selection
  78.     elsif @command_window.active
  79.       update_command_selection
  80.     elsif @number_window.active
  81.       update_number_selection
  82.     end
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ● 更新物品选择
  86.   #--------------------------------------------------------------------------
  87.   def update_item_selection
  88.     if Input.trigger?(Input::B)
  89.       item_max = $game_variables[ITEM_MAX_N]
  90.       item_max = 0 if item_max == nil
  91.       if  $game_party.items.size >  item_max # 如果物品种类超过限制
  92.         Sound.play_buzzer
  93.         @over_window.visible = true
  94.         @item_window.help_window.visible = false
  95.       else
  96.         Sound.play_cancel
  97.         return_scene
  98.       end
  99.     elsif Input.trigger?(Input::C)
  100.       @item_window.help_window.visible = true
  101.       @over_window.visible = false
  102.       @item = @item_window.item
  103.       if @item != nil
  104.         $game_party.last_item_id = @item.id
  105.         Sound.play_decision
  106.           if $game_party.item_can_use?(@item)     # 物品是否可用
  107.             @command_window.draw_item(0,true)      
  108.           else  @command_window.draw_item(0,false) # 不可用的话【使用】选项颜色无效
  109.           end
  110.           if @item.price == 0                     # 物品价格是否为0   
  111.              @command_window.draw_item(1,false)    # 是的话【丢弃】选项无效
  112.           else  
  113.              @command_window.draw_item(1,true)
  114.           end
  115.              show_command_window
  116.        else
  117.          Sound.play_buzzer
  118.        end
  119.     end
  120.   end
  121.   #--------------------------------------------------------------------------
  122.   # ● 更新目标选择
  123.   #--------------------------------------------------------------------------
  124.   def update_target_selection
  125.     if Input.trigger?(Input::B)
  126.       Sound.play_cancel
  127.       if $game_party.item_number(@item) == 0    # 判断物品是否耗尽
  128.         @item_window.refresh                    # 刷新窗口内容      
  129.         @max_window.refresh                     # 刷新物品种类窗口
  130.       end
  131.       hide_target_window
  132.     elsif Input.trigger?(Input::C)
  133.       if not $game_party.item_can_use?(@item)
  134.         Sound.play_buzzer
  135.       else
  136.         determine_target
  137.       end
  138.     end
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # ★ 更新指令选择
  142.   #--------------------------------------------------------------------------
  143.   def update_command_selection
  144.     if Input.trigger?(Input::B)
  145.       Sound.play_cancel
  146.       hide_command_window
  147.     elsif Input.trigger?(Input::C)
  148.       if @command_window.index == 0
  149.         if $game_party.item_can_use?(@item)
  150.           Sound.play_decision
  151.           @command_window.active = false
  152.           @command_window.visible =false
  153.           determine_item
  154.         else
  155.           Sound.play_buzzer
  156.         end
  157.       elsif  @item == nil or @item.price == 0
  158.         Sound.play_buzzer
  159.       else
  160.         Sound.play_decision
  161.         @command_window.active = false
  162.         @command_window.visible =false        
  163.         max = $game_party.item_number(@item)
  164.         @number_window.set(@item, max)
  165.         show_number_window
  166.       end
  167.     end
  168.   end
  169.   #--------------------------------------------------------------------------
  170.   # ★ 更新数量输入
  171.   #--------------------------------------------------------------------------
  172.   def update_number_selection   
  173.     if Input.trigger?(Input::B)
  174.       Sound.play_cancel
  175.       hide_number_window
  176.     elsif Input.trigger?(Input::C)
  177.       Audio.se_play("Audio/SE/#{LOSE_ITEM_SE_NAME}", 80, 100)
  178.       $game_party.lose_item(@item, @number_window.number)
  179.       @item_window.refresh
  180.       @max_window.refresh  
  181.       hide_number_window
  182.     end  
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # ★ 显示指令选择窗口
  186.   #--------------------------------------------------------------------------
  187.   def show_command_window
  188.     @command_window.index = 0
  189.     @item_window.active = false
  190.     @command_window.visible = true
  191.     @command_window.active = true
  192.   end
  193.   #--------------------------------------------------------------------------
  194.   # ★ 显示数量窗口
  195.   #--------------------------------------------------------------------------
  196.   def show_number_window
  197.     @command_window.active = false
  198.     @number_window.visible = true
  199.     @number_window.active = true
  200.   end
  201.   #--------------------------------------------------------------------------
  202.   # ★ 隐藏指令选择窗口
  203.   #--------------------------------------------------------------------------
  204.   def hide_command_window
  205.     @item_window.active = true
  206.     @command_window.visible = false
  207.     @command_window.active = false
  208.     @viewport.rect.set(0, 0, 544, 416)
  209.     @viewport.ox = 0
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # ★ 隐藏数量窗口
  213.   #--------------------------------------------------------------------------
  214.   def hide_number_window
  215.     @item_window.active = true
  216.     @number_window.visible = false
  217.     @number_window.active = false
  218.     @viewport.rect.set(0, 0, 544, 416)
  219.     @viewport.ox = 0
  220.   end  
  221. end
  222. #==============================================================================
  223. # ■ Window_lost_item  
  224. #------------------------------------------------------------------------------
  225. #  显示物品丢弃数量的窗口,仿 Window_ShopNumber。
  226. #==============================================================================

  227. class Window_LoseNumber < Window_Base
  228.   #--------------------------------------------------------------------------
  229.   # ★ 初始化对像
  230.   #     x      : 窗口 X 座标
  231.   #     y      : 窗口 Y 座标
  232.   #--------------------------------------------------------------------------
  233.   def initialize(x, y)
  234.     super(x, y, 260, 104)
  235.     @item = nil
  236.     @max = 1
  237.     @number = 1
  238.   end
  239.   #--------------------------------------------------------------------------
  240.   # ★ 设置物品、最大数量
  241.   #--------------------------------------------------------------------------
  242.   def set(item, max)
  243.     @item = item
  244.     @max = max
  245.     @number = 1
  246.     refresh
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # ★ 设置数量输入
  250.   #--------------------------------------------------------------------------
  251.   def number
  252.     return @number
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   # ★ 刷新
  256.   #--------------------------------------------------------------------------
  257.   def refresh
  258.     y = 24
  259.     self.contents.clear
  260.     draw_item_name(@item, 0, y)
  261.     self.contents.font.color = normal_color
  262.     self.contents.draw_text(164, y, 20, WLH, "×")
  263.     self.contents.draw_text(190, y, 20, WLH, @number, 2)
  264.     self.cursor_rect.set(186, y, 28, WLH)
  265.   end
  266.   #--------------------------------------------------------------------------
  267.   # ★ 更新画面
  268.   #--------------------------------------------------------------------------
  269.   def update
  270.     super
  271.     if self.active
  272.       last_number = @number
  273.       if Input.repeat?(Input::RIGHT) and @number < @max
  274.         @number += 1
  275.       end
  276.       if Input.repeat?(Input::LEFT) and @number > 1
  277.         @number -= 1
  278.       end
  279.       if Input.repeat?(Input::UP) and @number < @max
  280.         @number = [@number + 10, @max].min
  281.       end
  282.       if Input.repeat?(Input::DOWN) and @number > 1
  283.         @number = [@number - 10, 1].max
  284.       end
  285.       if @number != last_number
  286.         Sound.play_cursor
  287.         refresh
  288.       end
  289.     end
  290.   end
  291. end
  292. #==============================================================================
  293. # ■ Window_Item_Max
  294. #-----------------------------------------------------------------------------
  295. #   显示背包容量和当前物品数的窗口
  296. #============================================================================


  297. class Window_Item_Max < Window_Base
  298.   #--------------------------------------------------------------------------
  299.   # ★ 初始化对像
  300.   #--------------------------------------------------------------------------
  301.   def initialize
  302.     super(290, 360, 254, 56)
  303.     refresh
  304.   end
  305.   
  306.   #--------------------------------------------------------------------------
  307.   # ★ 刷新
  308.   #--------------------------------------------------------------------------  
  309.   def refresh
  310.     self.contents.clear
  311.     draw_icon(144, 0, 0)
  312.     self.contents.draw_text(36, 0, 100, 24, "背包容量:")
  313.     item = $game_party.items
  314.     string = item.size.to_s
  315.     item_max = $game_variables[ITEM_MAX_N]
  316.     item_max = 0 if item_max == nil
  317.     self.contents.font.color = knockout_color if item.size > item_max
  318.     self.contents.draw_text(135, 0, 30, 24, string, 2)
  319.     self.contents.font.color = normal_color
  320.     string = "/ " + item_max.to_s
  321.     self.contents.draw_text(173, 0, 100, 24, string )
  322.   end
  323.   
  324. end
复制代码

点评

谢谢你还记着。这个不用了,已经过新脚本了  发表于 2014-12-3 13:31
不需要了。我已经整合了有这个功能的脚本  发表于 2014-12-3 13:30
两个整合脚本之间仍然可能有冲突  发表于 2014-12-3 13:29
抱歉,这几天事情比较多,现在才开始弄。我在别的帖子看到你已经让其他人把有关物品的几个脚本整合了,那么这个帖子的整合还要进行吗?  发表于 2014-12-3 13:29
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部