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

Project1

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

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

[复制链接]

Lv4.逐梦者

梦石
0
星屑
12157
在线时间
4435 小时
注册时间
2014-4-11
帖子
5955

开拓者

跳转到指定楼层
1
发表于 2014-11-30 13:06:45 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
默认的物品栏点过去是直接使用的。能不能改成点过去弹出使用和丢弃。除了重要物品以外全可以丢弃。

Lv4.逐梦者 (版主)

梦石
0
星屑
9532
在线时间
5073 小时
注册时间
2013-6-21
帖子
3580

开拓者贵宾剧作品鉴家

2
发表于 2014-11-30 14:53:44 | 只看该作者
https://rpg.blue/forum.php?mod=viewthread&tid=371528
记得提问区曾经有这样的帖子,不知道我写的那个直接拿去用还行不行
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
12157
在线时间
4435 小时
注册时间
2014-4-11
帖子
5955

开拓者

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

和我的脚本冲突了。
我有物品分类脚本
RUBY 代码复制
  1. #==============================================================================
  2. # ■ 物品分类
  3. #==============================================================================
  4.  
  5. # 主体窗口透明度
  6. OPACITY_Item = 0
  7. # 使用物品窗口透明度
  8. OPACITY_Target = 200
  9. #==============================================================================
  10. # ■ RPG追加定义
  11. #==============================================================================
  12. module RPG
  13.   #--------------------------------------------------------------------------
  14.   # ● 物品追加
  15.   #--------------------------------------------------------------------------
  16.   class Item
  17.     def description
  18.       description = @description.split(/@/)[0]
  19.       return description != nil ? description : ''
  20.     end
  21.     def desc
  22.       desc = @description.split(/@/)[1]
  23.       return desc != nil ? desc : "物品"
  24.     end
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ● 武器追加
  28.   #--------------------------------------------------------------------------
  29.   class Weapon
  30.     def description
  31.       description = @description.split(/@/)[0]
  32.       return description != nil ? description : ''
  33.     end
  34.     def desc
  35.       desc = @description.split(/@/)[1]
  36.       return desc != nil ? desc : "武器"
  37.     end
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   # ● 防具追加
  41.   #--------------------------------------------------------------------------
  42.   class Armor
  43.     def description
  44.       description = @description.split(/@/)[0]
  45.       return description != nil ? description : ''
  46.     end
  47.     def desc
  48.       desc = @description.split(/@/)[1]
  49.       return desc != nil ? desc : "防具"
  50.     end
  51.   end
  52. end
  53.  
  54. #==============================================================================
  55. # ■ Window_Target
  56. #------------------------------------------------------------------------------
  57. #  物品画面与特技画面的、使用对像角色选择窗口。
  58. #   修复使用物品时还有跟随帮助窗口....
  59. #==============================================================================
  60.  
  61. class Window_Target < Window_Selectable
  62.   #--------------------------------------------------------------------------
  63.   # ● 刷新帮助文本
  64.   #--------------------------------------------------------------------------
  65.   def update_help
  66.     @help_window.set_text(item)
  67.     #校正帮助窗口位置
  68.     @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
  69.   end
  70. end
  71.  
  72. #==============================================================================
  73. # ■ Window_ItemCommand
  74. #------------------------------------------------------------------------------
  75. #  显示分类的窗口。
  76. #==============================================================================
  77.  
  78. class Window_ItemCommand < Window_Selectable
  79.   attr_accessor :commands
  80.   #--------------------------------------------------------------------------
  81.   # ● 初始化对像
  82.   #     commands : 命令字符串序列
  83.   #--------------------------------------------------------------------------
  84.   def initialize
  85.     super(0, 0, 160, 416)
  86.     self.opacity = OPACITY_Item
  87.     @commands = []
  88.     # 获取物品
  89.     for i in 1...$data_items.size
  90.       if $game_party.item_number(i) > 0
  91.         push = true
  92.         for com in @commands
  93.           if com == $data_items[i].desc
  94.             push = false
  95.           end
  96.         end
  97.         if push == true
  98.           @commands.push($data_items[i].desc)
  99.         end
  100.       end
  101.     end
  102.     # 获取武器
  103.     for i in 1...$data_weapons.size
  104.       if $game_party.weapon_number(i) > 0
  105.         push = true
  106.         for com in @commands
  107.           if com == $data_weapons[i].desc
  108.             push = false
  109.           end
  110.         end
  111.         if push == true
  112.           @commands.push($data_weapons[i].desc)
  113.         end
  114.       end
  115.     end
  116.     # 获取防具
  117.     for i in 1...$data_armors.size
  118.       if $game_party.armor_number(i) > 0
  119.         push = true
  120.         for com in @commands
  121.           if com == $data_armors[i].desc
  122.             push = false
  123.           end
  124.         end
  125.         if push == true
  126.           @commands.push($data_armors[i].desc)
  127.         end
  128.       end
  129.     end
  130.     if @commands == []
  131.       @commands.push("普通物品")
  132.     end
  133.     @item_max = @commands.size
  134.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  135.     refresh
  136.     self.index = 0
  137.   end
  138.   #--------------------------------------------------------------------------
  139.   # ● 刷新
  140.   #--------------------------------------------------------------------------
  141.   def refresh
  142.     self.contents.clear
  143.     for i in 0...@item_max
  144.       draw_item(i, normal_color)
  145.     end
  146.   end
  147.   #--------------------------------------------------------------------------
  148.   # ● 描绘项目
  149.   #     index : 项目编号
  150.   #     color : 文字色
  151.   #--------------------------------------------------------------------------
  152.   def draw_item(index, color)
  153.     self.contents.font.color = color
  154.     y = index * 32
  155.     self.contents.draw_text(4, y, 128, 32, @commands[index])
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # ● 刷新帮助文本
  159.   #--------------------------------------------------------------------------
  160.   def update_help
  161.     @help_window.set_text(item)
  162.     #校正帮助窗口位置
  163.     @help_window.set_pos(self.x,self.y,32,self.oy,self.index,@column_max)
  164.   end
  165. end
  166.  
  167. #==============================================================================
  168. # ■ Window_Item
  169. #------------------------------------------------------------------------------
  170. #  物品画面、战斗画面、显示浏览物品的窗口。
  171. #==============================================================================
  172.  
  173. class Window_ItemList < Window_Selectable
  174.   #--------------------------------------------------------------------------
  175.   # ● 初始化对像
  176.   #--------------------------------------------------------------------------
  177.   def initialize
  178.     super(160, 0, 480, 480)
  179.     self.opacity = OPACITY_Item
  180.     @column_max = 2
  181.     refresh
  182.     self.index = 0
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # ● 获取物品
  186.   #--------------------------------------------------------------------------
  187.   def item
  188.     return @data[self.index]
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # ● 刷新
  192.   #--------------------------------------------------------------------------
  193.   def refresh
  194.     if self.contents != nil
  195.       self.contents.dispose
  196.       self.contents = nil
  197.     end
  198.     @data = []
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # ● 分类
  202.   #     command : 类别名称
  203.   #--------------------------------------------------------------------------
  204.   def set_item(command)
  205.     refresh
  206.     if $game_temp.in_battle
  207.       # 添加物品
  208.       for i in 1...$data_items.size
  209.         if $game_party.item_number(i) > 0
  210.           @data.push($data_items[i])
  211.         end
  212.       end
  213.     end
  214.     for i in 1...$data_items.size
  215.       if $game_party.item_number(i) > 0 and $data_items[i].desc == command
  216.         @data.push($data_items[i])
  217.       end
  218.     end
  219.     for i in 1...$data_weapons.size
  220.       if $game_party.weapon_number(i) > 0 and $data_weapons[i].desc == command
  221.         @data.push($data_weapons[i])
  222.       end
  223.     end
  224.     for i in 1...$data_armors.size
  225.       if $game_party.armor_number(i) > 0 and $data_armors[i].desc == command
  226.         @data.push($data_armors[i])
  227.       end
  228.     end
  229.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  230.     @item_max = @data.size
  231.     if @item_max > 0
  232.       self.contents = Bitmap.new(width - 32, row_max * 32)
  233.       self.contents.clear
  234.       for i in 0...@item_max
  235.         draw_item(i)
  236.       end
  237.     end
  238.   end
  239.   #--------------------------------------------------------------------------
  240.   # ● 获取物品的所持数
  241.   #--------------------------------------------------------------------------
  242.   def item_number
  243.     return @item_max
  244.   end
  245.   #--------------------------------------------------------------------------
  246.   # ● 描绘项目
  247.   #     index : 项目编号
  248.   #--------------------------------------------------------------------------
  249.   def draw_item(index)
  250.     item = @data[index]
  251.     case item
  252.     when RPG::Item
  253.       number = $game_party.item_number(item.id)
  254.     when RPG::Weapon
  255.       number = $game_party.weapon_number(item.id)
  256.     when RPG::Armor
  257.       number = $game_party.armor_number(item.id)
  258.     end
  259.     if item.is_a?(RPG::Item) and
  260.       $game_party.item_can_use?(item.id)
  261.       self.contents.font.color = normal_color
  262.     else
  263.       self.contents.font.color = disabled_color
  264.     end
  265.     x = 4 + index % 2 * (208 + 32)
  266.     y = index / 2 * 32
  267.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  268.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  269.     bitmap = RPG::Cache.icon(item.icon_name)
  270.     opacity = self.contents.font.color == normal_color ? 255 : 128
  271.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  272.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  273.     self.contents.draw_text(x + 170, y, 16, 32, ":", 1)
  274.     self.contents.draw_text(x + 176, y, 24, 32, number.to_s, 2)
  275.   end
  276.   #--------------------------------------------------------------------------
  277.   # ● 刷新帮助文本
  278.   #--------------------------------------------------------------------------
  279.   def update_help
  280.     @help_window.set_text(item)
  281.     #校正帮助窗口位置
  282.     @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
  283.   end
  284. end
  285.  
  286. #==============================================================================
  287. # ■ Scene_Item
  288. #------------------------------------------------------------------------------
  289. #  处理物品画面的类。
  290. #==============================================================================
  291.  
  292. class Scene_Item
  293.   #--------------------------------------------------------------------------
  294.   # ● 主处理
  295.   #--------------------------------------------------------------------------
  296.   def main
  297.     # 创建背景图
  298.     @itemmenu = Sprite.new
  299.     @itemmenu.bitmap = RPG::Cache.picture("物品背景.png")
  300.     # 生成帮助窗口、物品窗口
  301.     @itemcommand_window = Window_ItemCommand.new
  302.     @command_index = @itemcommand_window.index
  303.     @itemlist_window = Window_ItemList.new
  304.     @itemlist_window.active = false
  305.     @help_window = Window_Help.new
  306.     # 生成金钱窗口
  307.     @gold_window = Window_Gold.new
  308.     @gold_window.y = 416
  309.     @gold_window.opacity = OPACITY_Item
  310.     # 关联帮助窗口
  311.     @itemcommand_window.help_window = @help_window
  312.     @itemlist_window.help_window = @help_window
  313.     # 生成目标窗口 (设置为不可见・不活动)
  314.     @target_window = Window_Target.new
  315.     # 关联帮助窗口
  316.     @target_window.help_window = @help_window
  317.     @target_window.opacity = OPACITY_Target
  318.     @target_window.visible = false
  319.     @target_window.active = false
  320.     @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  321.     # 执行过度
  322.     Graphics.transition
  323.     # 主循环
  324.     loop do
  325.       # 刷新游戏画面
  326.       Graphics.update
  327.       # 刷新输入信息
  328.       Input.update
  329.       # 刷新画面
  330.       update
  331.       # 如果画面切换就中断循环
  332.       if $scene != self
  333.         break
  334.       end
  335.     end
  336.     # 装备过渡
  337.     Graphics.freeze
  338.     # 释放窗口
  339.     @itemmenu.dispose
  340.     @itemcommand_window.dispose
  341.     @itemlist_window.dispose
  342.     @gold_window.dispose
  343.     @help_window.dispose
  344.     @target_window.dispose
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # ● 刷新画面
  348.   #--------------------------------------------------------------------------
  349.   def update
  350.     # 刷新窗口
  351.     @help_window.update
  352.     @gold_window.update
  353.     @itemlist_window.update
  354.     @itemcommand_window.update
  355.     @target_window.update
  356.     if @command_index != @itemcommand_window.index
  357.       @command_index = @itemcommand_window.index
  358.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  359.     end
  360.     # 分类窗口被激活的情况下: 调用 update_itemcommand
  361.     if @itemcommand_window.active
  362.       update_itemcommand
  363.       return
  364.     end
  365.     # 物品窗口被激活的情况下: 调用 update_itemlist
  366.     if @itemlist_window.active
  367.       update_itemlist
  368.       return
  369.     end
  370.     # 目标窗口被激活的情况下: 调用 update_target
  371.     if @target_window.active
  372.       update_target
  373.       return
  374.     end
  375.   end
  376.   #--------------------------------------------------------------------------
  377.   # ● 刷新画面 (分类窗口被激活的情况下)
  378.   #--------------------------------------------------------------------------
  379.   def update_itemcommand
  380.     # 按下 B 键的情况下
  381.     if Input.trigger?(Input::B)
  382.       # 演奏取消 SE
  383.       $game_system.se_play($data_system.cancel_se)
  384.       # 切换到菜单画面
  385.       $scene = Scene_Menu.new(0)
  386.       return
  387.     end
  388.     if Input.trigger?(Input::C)
  389.       # 按下 C 键的情况下
  390.       if @itemlist_window.item_number == 0
  391.         # 演奏冻结 SE
  392.         $game_system.se_play($data_system.buzzer_se)
  393.         return
  394.       end
  395.       # 演奏确定 SE
  396.       $game_system.se_play($data_system.decision_se)
  397.       # 激活目标窗口
  398.       @itemcommand_window.active = false
  399.       @itemlist_window.active = true
  400.       @itemlist_window.index = 0
  401.       return
  402.     end
  403.   end
  404.   #--------------------------------------------------------------------------
  405.   # ● 刷新画面 (物品窗口被激活的情况下)
  406.   #--------------------------------------------------------------------------
  407.   def update_itemlist
  408.     # 按下 B 键的情况下
  409.     if Input.trigger?(Input::B)
  410.       # 演奏取消 SE
  411.       $game_system.se_play($data_system.cancel_se)
  412.       @itemcommand_window.active = true
  413.       @itemlist_window.active = false
  414.       @itemlist_window.index = 0
  415.       # 切换到分类窗口
  416.       @itemcommand_window.index = @command_index
  417.       return
  418.     end
  419.     if Input.trigger?(Input::C)
  420.       # 获取物品窗口当前选中的物品数据
  421.       @item = @itemlist_window.item
  422.       # 不使用物品的情况下
  423.       unless @item.is_a?(RPG::Item)
  424.         # 演奏冻结 SE
  425.         $game_system.se_play($data_system.buzzer_se)
  426.         return
  427.       end
  428.       # 不能使用的情况下
  429.       unless $game_party.item_can_use?(@item.id)
  430.         # 演奏冻结 SE
  431.         $game_system.se_play($data_system.buzzer_se)
  432.         return
  433.       end
  434.       # 演奏确定 SE
  435.       $game_system.se_play($data_system.decision_se)
  436.       # 效果范围是我方的情况下
  437.       if @item.scope >= 3
  438.         # 激活目标窗口
  439.         @itemlist_window.active = false
  440.         @target_window.x = 304
  441.         @target_window.visible = true
  442.         @target_window.active = true
  443.         # 设置效果范围 (单体/全体) 的对应光标位置
  444.         if @item.scope == 4 || @item.scope == 6
  445.           @target_window.index = -1
  446.         else
  447.           @target_window.index = 0
  448.         end
  449.         # 效果在我方以外的情况下
  450.       else
  451.         # 公共事件 ID 有效的情况下
  452.         if @item.common_event_id > 0
  453.           # 预约调用公共事件
  454.           $game_temp.common_event_id = @item.common_event_id
  455.           # 演奏物品使用时的 SE
  456.           $game_system.se_play(@item.menu_se)
  457.           # 消耗品的情况下
  458.           if @item.consumable
  459.             # 使用的物品数减 1
  460.             $game_party.lose_item(@item.id, 1)
  461.             # 再描绘物品窗口的项目
  462.             @itemlist_window.draw_item(@itemlist_window.index)
  463.           end
  464.           # 切换到地图画面
  465.           $scene = Scene_Map.new
  466.           return
  467.         end
  468.       end
  469.       return
  470.     end
  471.   end
  472.   #--------------------------------------------------------------------------
  473.   # ● 刷新画面 (目标窗口被激活的情况下)
  474.   #--------------------------------------------------------------------------
  475.   def update_target
  476.     # 按下 B 键的情况下
  477.     if Input.trigger?(Input::B)
  478.       # 演奏取消 SE
  479.       $game_system.se_play($data_system.cancel_se)
  480.       # 由于物品用完而不能使用的场合
  481.       unless $game_party.item_can_use?(@item.id)
  482.         # 再次生成物品窗口的内容
  483.         @itemlist_window.refresh
  484.       end
  485.       # 删除目标窗口
  486.       @itemlist_window.active = true
  487.       @target_window.visible = false
  488.       @target_window.active = false
  489.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  490.       return
  491.     end
  492.     # 按下 C 键的情况下
  493.     if Input.trigger?(Input::C)
  494.       # 如果物品用完的情况下
  495.       if $game_party.item_number(@item.id) == 0
  496.         # 演奏冻结 SE
  497.         $game_system.se_play($data_system.buzzer_se)
  498.         return
  499.       end
  500.       # 目标是全体的情况下
  501.       if @target_window.index == -1
  502.         used = false
  503.         for i in $game_party.actors
  504.           used |= i.item_effect(@item)
  505.         end
  506.       end
  507.       # 目标是单体的情况下
  508.       if @target_window.index >= 0
  509.         # 对目标角色应用物品的使用效果
  510.         target = $game_party.actors[@target_window.index]
  511.         used = target.item_effect(@item)
  512.       end
  513.       # 使用物品的情况下
  514.       if used
  515.         # 演奏物品使用时的 SE
  516.         $game_system.se_play(@item.menu_se)
  517.         # 使用的物品数减 1
  518.         if @item.consumable
  519.           $game_party.lose_item(@item.id, 1)
  520.           # 再描绘物品窗口的项目
  521.           @itemlist_window.draw_item(@itemlist_window.index)
  522.           @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  523.         end
  524.         # 再生成目标窗口的内容
  525.         @target_window.refresh
  526.         # 全灭的情况下
  527.         if $game_party.all_dead?
  528.           # 切换到游戏结束画面
  529.           $scene = Scene_Gameover.new
  530.           return
  531.         end
  532.         # 公共事件 ID 有效的情况下
  533.         if @item.common_event_id > 0
  534.           # 预约调用公共事件
  535.           $game_temp.common_event_id = @item.common_event_id
  536.           # 切换到地图画面
  537.           $scene = Scene_Map.new
  538.           return
  539.         end
  540.       end
  541.       # 无法使用物品的情况下
  542.       unless used
  543.         # 演奏冻结 SE
  544.         $game_system.se_play($data_system.buzzer_se)
  545.       end
  546.     return
  547.     end
  548.   end
  549. end



还有这个背包限制脚本不冲突,不过我想改成0价格的物品不受限制。
RUBY 代码复制
  1. #==============================================================================
  2. # 背包可容纳最大的物品种类数。(包括物品,武器,防具)
  3. ITEMS_MAX = 2
  4. # 背包满后,如果再增加物品所提示的信息。
  5. TOP_MESSAGE = "背包已满!"
  6. $不显示金钱窗口 = 41
  7. $不显示物品窗口 = 42
  8. $不显示武器窗口 = 43
  9. $不显示防具窗口 = 44
  10. # 以上开关,当打开的时候,获得物品将不会提示,比如默认打开41号开关,获得金钱不再提示
  11.  
  12. #==============================================================================
  13. class Game_Party
  14.   #---------------------------------------------------------------------
  15.   def items
  16.     return @items
  17.   end
  18.   #---------------------------------------------------------------------
  19.   def weapons
  20.     return @weapons
  21.   end
  22.   #---------------------------------------------------------------------
  23.   def armors
  24.     return @armors
  25.   end
  26. end
  27. #==============================================================================
  28. class Interpreter
  29.   #--------------------------------------------------------------------
  30.   def full_judge?(id, n, type)
  31.     mn = 0
  32.     mn += $game_party.items.keys.size
  33.     mn += $game_party.weapons.keys.size
  34.     mn += $game_party.armors.keys.size
  35.     return false if mn < ITEMS_MAX
  36.     case type
  37.     when 0
  38.       if $game_party.items.keys.include?(id)
  39.         return false if $game_party.item_number(id) + n <= 99
  40.       end
  41.     when 1
  42.       if $game_party.weapons.keys.include?(id)
  43.         return false if $game_party.weapon_number(id) + n <= 99
  44.       end
  45.     when 2
  46.       if $game_party.armors.keys.include?(id)
  47.         return false if $game_party.armor_number(id) + n <= 99
  48.       end
  49.     end
  50.     return true
  51.   end
  52.   #---------------------------------------------------------------------
  53.   def full_top
  54.     $game_system.se_play($data_system.buzzer_se)
  55.     top = Window_Base.new(200, 100, 240, 64)
  56.     top.contents = Bitmap.new(top.width - 32, top.height - 32)
  57.     top.contents.draw_text(0, 0, 200, 32, TOP_MESSAGE, 1)
  58.     for i in 1..30
  59.       Graphics.update
  60.     end
  61.     for i in 1..20
  62.       top.opacity -= 13
  63.       top.contents_opacity -= 13
  64.       Graphics.update
  65.     end
  66.     top.dispose
  67.   end
  68.  
  69.  
  70.  
  71.     def command_125
  72.     value = operate_value(@parameters[0], @parameters[1], @parameters[2])
  73.     $game_party.gain_gold(value)
  74.     if $game_switches[$不显示金钱窗口]==false
  75.       carol3_66RPG = Window_Base.new((640-160)/2,128,180,100)
  76.       carol3_66RPG.contents = Bitmap.new(carol3_66RPG.width - 32, carol3_66RPG.height - 32)
  77.       if value >= 0
  78.         carol3_66RPG.contents.draw_text(0,0,240,32,"获得金钱:")
  79.         #——声效,可以自己改
  80.         Audio.se_play("Audio/SE/"+"006-System06",80,100)
  81.       else
  82.         carol3_66RPG.contents.draw_text(0,0,240,32,"失去金钱:")
  83.         #——声效,可以自己改
  84.         Audio.se_play("Audio/SE/"+"005-System05",80,100)
  85.       end     
  86.       carol3_66RPG.contents.draw_text(0,32,240,32,value.abs.to_s)
  87.       carol3_66RPG.contents.draw_text(0,32,140,32, $data_system.words.gold,2)
  88.       carol3_66RPG.opacity = 160
  89.       for i in 0..10
  90.         Graphics.update
  91.       end
  92.       for i in 0..10
  93.         carol3_66RPG.opacity -= 30
  94.         carol3_66RPG.contents_opacity -= 30
  95.         Graphics.update
  96.       end
  97.       carol3_66RPG.dispose
  98.     end
  99.     return true
  100.   end
  101.  
  102.   #--------------------------------------------------------------------------
  103.   # ● 增减物品
  104.   #--------------------------------------------------------------------------
  105.   def command_126
  106.     # 获取要操作的值
  107.     value = operate_value(@parameters[1], @parameters[2], @parameters[3])
  108.         if full_judge?(@parameters[0], value, 0)
  109.       full_top
  110.       command_115
  111.       return
  112.     end
  113.         # 增减物品
  114.     $game_party.gain_item(@parameters[0], value)
  115.         if $game_switches[$不显示物品窗口]==false
  116.       carol3_66RPG_item = $data_items[@parameters[0]]
  117.       carol3_66RPG = Window_Base.new((640-300)/2,128,300,100)
  118.       carol3_66RPG.contents = Bitmap.new(carol3_66RPG.width - 32, carol3_66RPG.height - 32)
  119.       if value >= 0
  120.         carol3_66RPG.contents.draw_text(0,0,240,32,"获得物品:")     
  121.         #——声效,可以自己改
  122.         Audio.se_play("Audio/SE/"+"006-System06",80,100)
  123.       else
  124.         carol3_66RPG.contents.draw_text(0,0,240,32,"失去物品:")     
  125.         #——声效,可以自己改
  126.         Audio.se_play("Audio/SE/"+"005-System05",80,100)
  127.       end
  128.       carol3_66RPG_bitmap = RPG::Cache.icon(carol3_66RPG_item.icon_name)
  129.       carol3_66RPG.contents.blt(0, 32, carol3_66RPG_bitmap, Rect.new(0, 0, 24, 24), 255)
  130.       carol3_66RPG.contents.draw_text(0 + 28, 32, 212, 32, carol3_66RPG_item.name, 0)
  131.       carol3_66RPG.contents.draw_text(0, 32, 268, 32, "×"+value.abs.to_s, 2)
  132.       carol3_66RPG.opacity = 160
  133.       for i in 0..10
  134.         Graphics.update
  135.       end
  136.       for i in 0..10
  137.         carol3_66RPG.opacity -= 30
  138.         carol3_66RPG.contents_opacity -= 30
  139.         Graphics.update
  140.       end
  141.       carol3_66RPG.dispose
  142.     end
  143.  
  144.     # 继续
  145.  
  146.     return true
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● 增减武器
  150.   #--------------------------------------------------------------------------
  151.   def command_127
  152.     # 获取要操作的值
  153.     value = operate_value(@parameters[1], @parameters[2], @parameters[3])
  154.     if full_judge?(@parameters[0], value, 1)
  155.       full_top
  156.       command_115
  157.       return
  158.     end
  159.     # 增减武器
  160.     $game_party.gain_weapon(@parameters[0], value)
  161.         if $game_switches[$不显示武器窗口]==false
  162.       carol3_66RPG_item = $data_weapons[@parameters[0]]
  163.       carol3_66RPG = Window_Base.new((640-300)/2,128,300,100)
  164.       carol3_66RPG.contents = Bitmap.new(carol3_66RPG.width - 32, carol3_66RPG.height - 32)
  165.       if value >= 0
  166.         carol3_66RPG.contents.draw_text(0,0,240,32,"获得武器:")     
  167.         #——声效,可以自己改
  168.         Audio.se_play("Audio/SE/"+"006-System06",80,100)
  169.       else
  170.         carol3_66RPG.contents.draw_text(0,0,240,32,"失去武器:")     
  171.         #——声效,可以自己改
  172.         Audio.se_play("Audio/SE/"+"005-System05",80,100)
  173.       end
  174.       carol3_66RPG_bitmap = RPG::Cache.icon(carol3_66RPG_item.icon_name)
  175.       carol3_66RPG.contents.blt(0, 32, carol3_66RPG_bitmap, Rect.new(0, 0, 24, 24), 255)
  176.       carol3_66RPG.contents.draw_text(0 + 28, 32, 212, 32, carol3_66RPG_item.name, 0)
  177.       carol3_66RPG.contents.draw_text(0, 32, 268, 32, "×"+value.abs.to_s, 2)
  178.       carol3_66RPG.opacity = 160
  179.       for i in 0..10
  180.         Graphics.update
  181.       end
  182.       for i in 0..10
  183.         carol3_66RPG.opacity -= 30
  184.         carol3_66RPG.contents_opacity -= 30
  185.         Graphics.update
  186.       end
  187.       carol3_66RPG.dispose
  188.     end
  189.  
  190.     # 继续
  191.     return true
  192.   end
  193.   #--------------------------------------------------------------------------
  194.   # ● 增减防具
  195.   #--------------------------------------------------------------------------
  196.   def command_128
  197.     # 获取要操作的值
  198.     value = operate_value(@parameters[1], @parameters[2], @parameters[3])
  199.     if full_judge?(@parameters[0], value, 2)
  200.       full_top
  201.       command_115
  202.       return
  203.     end
  204.     # 增减防具
  205.     $game_party.gain_armor(@parameters[0], value)
  206.         if $game_switches[$不显示防具窗口]==false
  207.       carol3_66RPG_item = $data_armors[@parameters[0]]
  208.       carol3_66RPG = Window_Base.new((640-300)/2,128,300,100)
  209.       carol3_66RPG.contents = Bitmap.new(carol3_66RPG.width - 32, carol3_66RPG.height - 32)
  210.       if value >= 0
  211.         carol3_66RPG.contents.draw_text(0,0,240,32,"获得防具:")     
  212.         #——声效,可以自己改
  213.         Audio.se_play("Audio/SE/"+"006-System06",80,100)
  214.       else
  215.         carol3_66RPG.contents.draw_text(0,0,240,32,"失去防具:")     
  216.         #——声效,可以自己改
  217.         Audio.se_play("Audio/SE/"+"005-System05",80,100)
  218.       end
  219.       carol3_66RPG_bitmap = RPG::Cache.icon(carol3_66RPG_item.icon_name)
  220.       carol3_66RPG.contents.blt(0, 32, carol3_66RPG_bitmap, Rect.new(0, 0, 24, 24), 255)
  221.       carol3_66RPG.contents.draw_text(0 + 28, 32, 212, 32, carol3_66RPG_item.name, 0)
  222.       carol3_66RPG.contents.draw_text(0, 32, 268, 32, "×"+value.abs.to_s, 2)
  223.       carol3_66RPG.opacity = 160
  224.       for i in 0..10
  225.         Graphics.update
  226.       end
  227.       for i in 0..10
  228.         carol3_66RPG.opacity -= 30
  229.         carol3_66RPG.contents_opacity -= 30
  230.         Graphics.update
  231.       end
  232.       carol3_66RPG.dispose
  233.     end
  234.  
  235.     # 继续
  236.     return true
  237.   end
  238. end
  239. #==============================================================================




我觉得这个VA的脚本可以参考
RUBY 代码复制
  1. #==============================================================================
  2. # ■ 物品丢弃 + 物品种类数限制 —— by 水镜风生
  3. #------------------------------------------------------------------------------
  4. LOSE_ITEM_SE_NAME = "Evasion"         # 丢弃物品时播放的SE
  5. ITEM_MAX_N = 12    # 储存物品最大种类数的事件变量的编号
  6.  
  7. #==============================================================================
  8. # ■ Scene_Item
  9. #------------------------------------------------------------------------------
  10. #  处理物品画面的类。
  11. #==============================================================================
  12.  
  13. class Scene_Item < Scene_Base
  14.   #--------------------------------------------------------------------------
  15.   # ● 开始处理
  16.   #--------------------------------------------------------------------------
  17.   def start
  18.     super
  19.     create_menu_background
  20.     @viewport = Viewport.new(0, 0, 544, 416)
  21.     @help_window = Window_Help.new
  22.     @help_window.viewport = @viewport
  23.     @item_window = Window_Item.new(0, 67, 544, 280)
  24.     @item_window.viewport = @viewport
  25.     @item_window.help_window = @help_window
  26.     @item_window.active = false
  27.     @target_window = Window_MenuStatus.new(0, 0)
  28.     @max_window = Window_Item_Max.new
  29.     @max_window.viewport = @viewport
  30.     @number_window = Window_LoseNumber.new(142, 156)
  31.     @number_window.viewport = @viewport
  32.     @command_window = Window_Command.new(145, ["   使用","   丢弃"], 1, 2)
  33.     @command_window.x = 200
  34.     @command_window.y = 160
  35.     @over_window = Window_Help.new
  36.     @over_window.set_text("背包放不下了,丢弃一些没用的物品吧。")
  37.     @over_window.visible = false
  38.     hide_command_window
  39.     hide_number_window
  40.     hide_target_window
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # ● 结束处理
  44.   #--------------------------------------------------------------------------
  45.   def terminate
  46.     super
  47.     dispose_menu_background
  48.     @viewport.dispose
  49.     @help_window.dispose
  50.     @item_window.dispose
  51.     @target_window.dispose
  52.     @max_window.dispose
  53.     @command_window.dispose
  54.     @number_window.dispose
  55.     @over_window.dispose
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # ● 回到原画面
  59.   #--------------------------------------------------------------------------
  60.   def return_scene
  61.     $scene = Scene_Menu.new(0)
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # ● 更新画面
  65.   #--------------------------------------------------------------------------
  66.   def update
  67.     super
  68.     update_menu_background
  69.     @over_window.update
  70.     @help_window.update
  71.     @item_window.update
  72.     @target_window.update
  73.     @max_window.update
  74.     @command_window.update
  75.     @number_window.update
  76.     if @item_window.active
  77.       update_item_selection
  78.     elsif @target_window.active
  79.       update_target_selection
  80.     elsif @command_window.active
  81.       update_command_selection
  82.     elsif @number_window.active
  83.       update_number_selection
  84.     end
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # ● 更新物品选择
  88.   #--------------------------------------------------------------------------
  89.   def update_item_selection
  90.     if Input.trigger?(Input::B)
  91.       item_max = $game_variables[ITEM_MAX_N]
  92.       item_max = 0 if item_max == nil
  93.       if  $game_party.items.size >  item_max # 如果物品种类超过限制
  94.         Sound.play_buzzer
  95.         @over_window.visible = true
  96.         @item_window.help_window.visible = false
  97.       else
  98.         Sound.play_cancel
  99.         return_scene
  100.       end
  101.     elsif Input.trigger?(Input::C)
  102.       @item_window.help_window.visible = true
  103.       @over_window.visible = false
  104.       @item = @item_window.item
  105.       if @item != nil
  106.         $game_party.last_item_id = @item.id
  107.         Sound.play_decision
  108.           if $game_party.item_can_use?(@item)     # 物品是否可用
  109.             @command_window.draw_item(0,true)      
  110.           else  @command_window.draw_item(0,false) # 不可用的话【使用】选项颜色无效
  111.           end
  112.           if @item.price == 0                     # 物品价格是否为0   
  113.              @command_window.draw_item(1,false)    # 是的话【丢弃】选项无效
  114.           else  
  115.              @command_window.draw_item(1,true)
  116.           end
  117.              show_command_window
  118.        else
  119.          Sound.play_buzzer
  120.        end
  121.     end
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   # ● 更新目标选择
  125.   #--------------------------------------------------------------------------
  126.   def update_target_selection
  127.     if Input.trigger?(Input::B)
  128.       Sound.play_cancel
  129.       if $game_party.item_number(@item) == 0    # 判断物品是否耗尽
  130.         @item_window.refresh                    # 刷新窗口内容      
  131.         @max_window.refresh                     # 刷新物品种类窗口
  132.       end
  133.       hide_target_window
  134.     elsif Input.trigger?(Input::C)
  135.       if not $game_party.item_can_use?(@item)
  136.         Sound.play_buzzer
  137.       else
  138.         determine_target
  139.       end
  140.     end
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ★ 更新指令选择
  144.   #--------------------------------------------------------------------------
  145.   def update_command_selection
  146.     if Input.trigger?(Input::B)
  147.       Sound.play_cancel
  148.       hide_command_window
  149.     elsif Input.trigger?(Input::C)
  150.       if @command_window.index == 0
  151.         if $game_party.item_can_use?(@item)
  152.           Sound.play_decision
  153.           @command_window.active = false
  154.           @command_window.visible =false
  155.           determine_item
  156.         else
  157.           Sound.play_buzzer
  158.         end
  159.       elsif  @item == nil or @item.price == 0
  160.         Sound.play_buzzer
  161.       else
  162.         Sound.play_decision
  163.         @command_window.active = false
  164.         @command_window.visible =false        
  165.         max = $game_party.item_number(@item)
  166.         @number_window.set(@item, max)
  167.         show_number_window
  168.       end
  169.     end
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ★ 更新数量输入
  173.   #--------------------------------------------------------------------------
  174.   def update_number_selection   
  175.     if Input.trigger?(Input::B)
  176.       Sound.play_cancel
  177.       hide_number_window
  178.     elsif Input.trigger?(Input::C)
  179.       Audio.se_play("Audio/SE/#{LOSE_ITEM_SE_NAME}", 80, 100)
  180.       $game_party.lose_item(@item, @number_window.number)
  181.       @item_window.refresh
  182.       @max_window.refresh  
  183.       hide_number_window
  184.     end  
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # ★ 显示指令选择窗口
  188.   #--------------------------------------------------------------------------
  189.   def show_command_window
  190.     @command_window.index = 0
  191.     @item_window.active = false
  192.     @command_window.visible = true
  193.     @command_window.active = true
  194.   end
  195.   #--------------------------------------------------------------------------
  196.   # ★ 显示数量窗口
  197.   #--------------------------------------------------------------------------
  198.   def show_number_window
  199.     @command_window.active = false
  200.     @number_window.visible = true
  201.     @number_window.active = true
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   # ★ 隐藏指令选择窗口
  205.   #--------------------------------------------------------------------------
  206.   def hide_command_window
  207.     @item_window.active = true
  208.     @command_window.visible = false
  209.     @command_window.active = false
  210.     @viewport.rect.set(0, 0, 544, 416)
  211.     @viewport.ox = 0
  212.   end
  213.   #--------------------------------------------------------------------------
  214.   # ★ 隐藏数量窗口
  215.   #--------------------------------------------------------------------------
  216.   def hide_number_window
  217.     @item_window.active = true
  218.     @number_window.visible = false
  219.     @number_window.active = false
  220.     @viewport.rect.set(0, 0, 544, 416)
  221.     @viewport.ox = 0
  222.   end  
  223. end
  224. #==============================================================================
  225. # ■ Window_lost_item  
  226. #------------------------------------------------------------------------------
  227. #  显示物品丢弃数量的窗口,仿 Window_ShopNumber。
  228. #==============================================================================
  229.  
  230. class Window_LoseNumber < Window_Base
  231.   #--------------------------------------------------------------------------
  232.   # ★ 初始化对像
  233.   #     x      : 窗口 X 座标
  234.   #     y      : 窗口 Y 座标
  235.   #--------------------------------------------------------------------------
  236.   def initialize(x, y)
  237.     super(x, y, 260, 104)
  238.     @item = nil
  239.     @max = 1
  240.     @number = 1
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # ★ 设置物品、最大数量
  244.   #--------------------------------------------------------------------------
  245.   def set(item, max)
  246.     @item = item
  247.     @max = max
  248.     @number = 1
  249.     refresh
  250.   end
  251.   #--------------------------------------------------------------------------
  252.   # ★ 设置数量输入
  253.   #--------------------------------------------------------------------------
  254.   def number
  255.     return @number
  256.   end
  257.   #--------------------------------------------------------------------------
  258.   # ★ 刷新
  259.   #--------------------------------------------------------------------------
  260.   def refresh
  261.     y = 24
  262.     self.contents.clear
  263.     draw_item_name(@item, 0, y)
  264.     self.contents.font.color = normal_color
  265.     self.contents.draw_text(164, y, 20, WLH, "×")
  266.     self.contents.draw_text(190, y, 20, WLH, @number, 2)
  267.     self.cursor_rect.set(186, y, 28, WLH)
  268.   end
  269.   #--------------------------------------------------------------------------
  270.   # ★ 更新画面
  271.   #--------------------------------------------------------------------------
  272.   def update
  273.     super
  274.     if self.active
  275.       last_number = @number
  276.       if Input.repeat?(Input::RIGHT) and @number < @max
  277.         @number += 1
  278.       end
  279.       if Input.repeat?(Input::LEFT) and @number > 1
  280.         @number -= 1
  281.       end
  282.       if Input.repeat?(Input::UP) and @number < @max
  283.         @number = [@number + 10, @max].min
  284.       end
  285.       if Input.repeat?(Input::DOWN) and @number > 1
  286.         @number = [@number - 10, 1].max
  287.       end
  288.       if @number != last_number
  289.         Sound.play_cursor
  290.         refresh
  291.       end
  292.     end
  293.   end
  294. end
  295. #==============================================================================
  296. # ■ Window_Item_Max
  297. #-----------------------------------------------------------------------------
  298. #   显示背包容量和当前物品数的窗口
  299. #============================================================================
  300.  
  301.  
  302. class Window_Item_Max < Window_Base
  303.   #--------------------------------------------------------------------------
  304.   # ★ 初始化对像
  305.   #--------------------------------------------------------------------------
  306.   def initialize
  307.     super(290, 360, 254, 56)
  308.     refresh
  309.   end
  310.  
  311.   #--------------------------------------------------------------------------
  312.   # ★ 刷新
  313.   #--------------------------------------------------------------------------  
  314.   def refresh
  315.     self.contents.clear
  316.     draw_icon(144, 0, 0)
  317.     self.contents.draw_text(36, 0, 100, 24, "背包容量:")
  318.     item = $game_party.items
  319.     string = item.size.to_s
  320.     item_max = $game_variables[ITEM_MAX_N]
  321.     item_max = 0 if item_max == nil
  322.     self.contents.font.color = knockout_color if item.size > item_max
  323.     self.contents.draw_text(135, 0, 30, 24, string, 2)
  324.     self.contents.font.color = normal_color
  325.     string = "/ " + item_max.to_s
  326.     self.contents.draw_text(173, 0, 100, 24, string )
  327.   end
  328.  
  329. end

点评

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-22 14:29

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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