赞 | 1 |
VIP | 95 |
好人卡 | 8 |
积分 | 1 |
经验 | 23267 |
最后登录 | 2020-10-15 |
在线时间 | 433 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 65
- 在线时间
- 433 小时
- 注册时间
- 2007-5-1
- 帖子
- 993
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 水镜风生 于 2009-8-28 10:25 编辑
12.20更新,修正点击空物品时出错的BUG,并新增一个版本。
所谓种类限制,就是仿照网游的物品格,一种物品算占一格,格子数量有限。
而这里没有格子,只有显示【当前物品种数/最大种数】的窗口……
使用方法:
1.复制脚本插入main前。
2.默认丢弃物品的音效是回避音效,要修改的话请用新SE的名称代替第一行的Evasion。
3.默认用12号变量来储存物品最大种类数,需要在游戏开始时给此变量赋初值。
4.价格为0的物品认定为任务物品,不可丢弃。
注意:
1.物品名称超过7个字时会发生字体重叠。
2.物品种类超过999个时会发生字体重叠。
3.最大种数超过999个时其数量将不能完全显示。
这是物品界面提示版,当前物品种数超过最大种数时会提示背包已满且不能退出物品画面。
- #==============================================================================
- # ■ 物品丢弃 + 物品种类数限制 —— by 水镜风生
- #------------------------------------------------------------------------------
- LOSE_ITEM_SE_NAME = "Evasion" # 丢弃物品时播放的SE
- ITEM_MAX_N = 12 # 储存物品最大种类数的事件变量的编号
- #==============================================================================
- # ■ Scene_Item
- #------------------------------------------------------------------------------
- # 处理物品画面的类。
- #==============================================================================
- class Scene_Item < Scene_Base
- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- def start
- super
- create_menu_background
- @viewport = Viewport.new(0, 0, 544, 416)
- @help_window = Window_Help.new
- @help_window.viewport = @viewport
- @item_window = Window_Item.new(0, 67, 544, 280)
- @item_window.viewport = @viewport
- @item_window.help_window = @help_window
- @item_window.active = false
- @target_window = Window_MenuStatus.new(0, 0)
- @max_window = Window_Item_Max.new
- @max_window.viewport = @viewport
- @number_window = Window_LoseNumber.new(142, 156)
- @number_window.viewport = @viewport
- @command_window = Window_Command.new(145, [" 使用"," 丢弃"], 1, 2)
- @command_window.x = 200
- @command_window.y = 160
- @over_window = Window_Help.new
- @over_window.set_text("背包放不下了,丢弃一些没用的物品吧。")
- @over_window.visible = false
- hide_command_window
- hide_number_window
- hide_target_window
- end
- #--------------------------------------------------------------------------
- # ● 结束处理
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_menu_background
- @viewport.dispose
- @help_window.dispose
- @item_window.dispose
- @target_window.dispose
- @max_window.dispose
- @command_window.dispose
- @number_window.dispose
- @over_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 回到原画面
- #--------------------------------------------------------------------------
- def return_scene
- $scene = Scene_Menu.new(0)
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- update_menu_background
- @over_window.update
- @help_window.update
- @item_window.update
- @target_window.update
- @max_window.update
- @command_window.update
- @number_window.update
- if @item_window.active
- update_item_selection
- elsif @target_window.active
- update_target_selection
- elsif @command_window.active
- update_command_selection
- elsif @number_window.active
- update_number_selection
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新物品选择
- #--------------------------------------------------------------------------
- def update_item_selection
- if Input.trigger?(Input::B)
- item_max = $game_variables[ITEM_MAX_N]
- item_max = 0 if item_max == nil
- if $game_party.items.size > item_max # 如果物品种类超过限制
- Sound.play_buzzer
- @over_window.visible = true
- @item_window.help_window.visible = false
- else
- Sound.play_cancel
- return_scene
- end
- elsif Input.trigger?(Input::C)
- @item_window.help_window.visible = true
- @over_window.visible = false
- @item = @item_window.item
- if @item != nil
- $game_party.last_item_id = @item.id
- Sound.play_decision
- if $game_party.item_can_use?(@item) # 物品是否可用
- @command_window.draw_item(0,true)
- else @command_window.draw_item(0,false) # 不可用的话【使用】选项颜色无效
- end
- if @item.price == 0 # 物品价格是否为0
- @command_window.draw_item(1,false) # 是的话【丢弃】选项无效
- else
- @command_window.draw_item(1,true)
- end
- show_command_window
- else
- Sound.play_buzzer
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新目标选择
- #--------------------------------------------------------------------------
- def update_target_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- if $game_party.item_number(@item) == 0 # 判断物品是否耗尽
- @item_window.refresh # 刷新窗口内容
- @max_window.refresh # 刷新物品种类窗口
- end
- hide_target_window
- elsif Input.trigger?(Input::C)
- if not $game_party.item_can_use?(@item)
- Sound.play_buzzer
- else
- determine_target
- end
- end
- end
- #--------------------------------------------------------------------------
- # ★ 更新指令选择
- #--------------------------------------------------------------------------
- def update_command_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- hide_command_window
- elsif Input.trigger?(Input::C)
- if @command_window.index == 0
- if $game_party.item_can_use?(@item)
- Sound.play_decision
- @command_window.active = false
- @command_window.visible =false
- determine_item
- else
- Sound.play_buzzer
- end
- elsif @item == nil or @item.price == 0
- Sound.play_buzzer
- else
- Sound.play_decision
- @command_window.active = false
- @command_window.visible =false
- max = $game_party.item_number(@item)
- @number_window.set(@item, max)
- show_number_window
- end
- end
- end
- #--------------------------------------------------------------------------
- # ★ 更新数量输入
- #--------------------------------------------------------------------------
- def update_number_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- hide_number_window
- elsif Input.trigger?(Input::C)
- Audio.se_play("Audio/SE/#{LOSE_ITEM_SE_NAME}", 80, 100)
- $game_party.lose_item(@item, @number_window.number)
- @item_window.refresh
- @max_window.refresh
- hide_number_window
- end
- end
- #--------------------------------------------------------------------------
- # ★ 显示指令选择窗口
- #--------------------------------------------------------------------------
- def show_command_window
- @command_window.index = 0
- @item_window.active = false
- @command_window.visible = true
- @command_window.active = true
- end
- #--------------------------------------------------------------------------
- # ★ 显示数量窗口
- #--------------------------------------------------------------------------
- def show_number_window
- @command_window.active = false
- @number_window.visible = true
- @number_window.active = true
- end
- #--------------------------------------------------------------------------
- # ★ 隐藏指令选择窗口
- #--------------------------------------------------------------------------
- def hide_command_window
- @item_window.active = true
- @command_window.visible = false
- @command_window.active = false
- @viewport.rect.set(0, 0, 544, 416)
- @viewport.ox = 0
- end
- #--------------------------------------------------------------------------
- # ★ 隐藏数量窗口
- #--------------------------------------------------------------------------
- def hide_number_window
- @item_window.active = true
- @number_window.visible = false
- @number_window.active = false
- @viewport.rect.set(0, 0, 544, 416)
- @viewport.ox = 0
- end
- end
- #==============================================================================
- # ■ Window_lost_item
- #------------------------------------------------------------------------------
- # 显示物品丢弃数量的窗口,仿 Window_ShopNumber。
- #==============================================================================
- class Window_LoseNumber < Window_Base
- #--------------------------------------------------------------------------
- # ★ 初始化对像
- # x : 窗口 X 座标
- # y : 窗口 Y 座标
- #--------------------------------------------------------------------------
- def initialize(x, y)
- super(x, y, 260, 104)
- @item = nil
- @max = 1
- @number = 1
- end
- #--------------------------------------------------------------------------
- # ★ 设置物品、最大数量
- #--------------------------------------------------------------------------
- def set(item, max)
- @item = item
- @max = max
- @number = 1
- refresh
- end
- #--------------------------------------------------------------------------
- # ★ 设置数量输入
- #--------------------------------------------------------------------------
- def number
- return @number
- end
- #--------------------------------------------------------------------------
- # ★ 刷新
- #--------------------------------------------------------------------------
- def refresh
- y = 24
- self.contents.clear
- draw_item_name(@item, 0, y)
- self.contents.font.color = normal_color
- self.contents.draw_text(164, y, 20, WLH, "×")
- self.contents.draw_text(190, y, 20, WLH, @number, 2)
- self.cursor_rect.set(186, y, 28, WLH)
- end
- #--------------------------------------------------------------------------
- # ★ 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- if self.active
- last_number = @number
- if Input.repeat?(Input::RIGHT) and @number < @max
- @number += 1
- end
- if Input.repeat?(Input::LEFT) and @number > 1
- @number -= 1
- end
- if Input.repeat?(Input::UP) and @number < @max
- @number = [@number + 10, @max].min
- end
- if Input.repeat?(Input::DOWN) and @number > 1
- @number = [@number - 10, 1].max
- end
- if @number != last_number
- Sound.play_cursor
- refresh
- end
- end
- end
- end
- #==============================================================================
- # ■ Window_Item_Max
- #-----------------------------------------------------------------------------
- # 显示背包容量和当前物品数的窗口
- #============================================================================
- class Window_Item_Max < Window_Base
- #--------------------------------------------------------------------------
- # ★ 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(290, 360, 254, 56)
- refresh
- end
-
- #--------------------------------------------------------------------------
- # ★ 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- draw_icon(144, 0, 0)
- self.contents.draw_text(36, 0, 100, 24, "背包容量:")
- item = $game_party.items
- string = item.size.to_s
- item_max = $game_variables[ITEM_MAX_N]
- item_max = 0 if item_max == nil
- self.contents.font.color = knockout_color if item.size > item_max
- self.contents.draw_text(135, 0, 30, 24, string, 2)
- self.contents.font.color = normal_color
- string = "/ " + item_max.to_s
- self.contents.draw_text(173, 0, 100, 24, string )
- end
-
- end
复制代码 这是负重版,当物品超过限制时将在地图上显示超重信息并减速。在物品界面没有提示并且没有限制退出物品界面。
- #==============================================================================
- # ■ 物品丢弃 + 物品种类数限制 —— by 水镜风生
- #------------------------------------------------------------------------------
- LOSE_ITEM_SE_NAME = "Evasion" # 丢弃物品时播放的SE
- LOW_SPEED = 2 # 物品超重时的移动速度
- USUAL_SPEED = 4 # 平时的移动速度
- ITEM_MAX_N = 12 # 储存物品最大种类数的事件变量的编号
- #==============================================================================
- # ■ Scene_Item
- #------------------------------------------------------------------------------
- # 处理物品画面的类。
- #==============================================================================
- class Scene_Item < Scene_Base
- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- def start
- super
- create_menu_background
- @viewport = Viewport.new(0, 0, 544, 416)
- @help_window = Window_Help.new
- @help_window.viewport = @viewport
- @item_window = Window_Item.new(0, 67, 544, 280)
- @item_window.viewport = @viewport
- @item_window.help_window = @help_window
- @item_window.active = false
- @target_window = Window_MenuStatus.new(0, 0)
- @max_window = Window_Item_Max.new
- @max_window.viewport = @viewport
- @number_window = Window_LoseNumber.new(142, 156)
- @number_window.viewport = @viewport
- @command_window = Window_Command.new(145, [" 使用"," 丢弃"], 1, 2)
- @command_window.x = 200
- @command_window.y = 160
- hide_command_window
- hide_number_window
- hide_target_window
- end
- #--------------------------------------------------------------------------
- # ● 结束处理
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_menu_background
- @viewport.dispose
- @help_window.dispose
- @item_window.dispose
- @target_window.dispose
- @max_window.dispose
- @command_window.dispose
- @number_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 回到原画面
- #--------------------------------------------------------------------------
- def return_scene
- $scene = Scene_Menu.new(0)
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- update_menu_background
- @help_window.update
- @item_window.update
- @target_window.update
- @max_window.update
- @command_window.update
- @number_window.update
- if @item_window.active
- update_item_selection
- elsif @target_window.active
- update_target_selection
- elsif @command_window.active
- update_command_selection
- elsif @number_window.active
- update_number_selection
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新物品选择
- #--------------------------------------------------------------------------
- def update_item_selection
- if Input.trigger?(Input::B)
- item_max = $game_variables[ITEM_MAX_N]
- item_max = 0 if item_max == nil
- if $game_party.items.size <= item_max # 如果物品种类没超过限制
- $game_player.change_move_speed(USUAL_SPEED)
- end
- Sound.play_cancel
- return_scene
- elsif Input.trigger?(Input::C)
- @item = @item_window.item
- if @item != nil
- $game_party.last_item_id = @item.id
- Sound.play_decision
- if $game_party.item_can_use?(@item) # 物品是否可用
- @command_window.draw_item(0,true)
- else @command_window.draw_item(0,false) # 不可用的话【使用】选项颜色无效
- end
- if @item.price == 0 # 物品价格是否为0
- @command_window.draw_item(1,false) # 是的话【丢弃】选项无效
- else
- @command_window.draw_item(1,true)
- end
- show_command_window
- else
- Sound.play_buzzer
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新目标选择
- #--------------------------------------------------------------------------
- def update_target_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- if $game_party.item_number(@item) == 0 # 判断物品是否耗尽
- @item_window.refresh # 刷新窗口内容
- @max_window.refresh # 刷新物品种类窗口
- end
- hide_target_window
- elsif Input.trigger?(Input::C)
- if not $game_party.item_can_use?(@item)
- Sound.play_buzzer
- else
- determine_target
- end
- end
- end
- #--------------------------------------------------------------------------
- # ★ 更新指令选择
- #--------------------------------------------------------------------------
- def update_command_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- hide_command_window
- elsif Input.trigger?(Input::C)
- if @command_window.index == 0
- if $game_party.item_can_use?(@item)
- Sound.play_decision
- @command_window.active = false
- @command_window.visible =false
- determine_item
- else
- Sound.play_buzzer
- end
- elsif @item == nil or @item.price == 0
- Sound.play_buzzer
- else
- Sound.play_decision
- @command_window.active = false
- @command_window.visible =false
- max = $game_party.item_number(@item)
- @number_window.set(@item, max)
- show_number_window
- end
- end
- end
- #--------------------------------------------------------------------------
- # ★ 更新数量输入
- #--------------------------------------------------------------------------
- def update_number_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- hide_number_window
- elsif Input.trigger?(Input::C)
- Audio.se_play("Audio/SE/#{LOSE_ITEM_SE_NAME}", 80, 100)
- $game_party.lose_item(@item, @number_window.number)
- @item_window.refresh
- @max_window.refresh
- hide_number_window
- end
- end
- #--------------------------------------------------------------------------
- # ★ 显示指令选择窗口
- #--------------------------------------------------------------------------
- def show_command_window
- @command_window.index = 0
- @item_window.active = false
- @command_window.visible = true
- @command_window.active = true
- end
- #--------------------------------------------------------------------------
- # ★ 显示数量窗口
- #--------------------------------------------------------------------------
- def show_number_window
- @command_window.active = false
- @number_window.visible = true
- @number_window.active = true
- end
- #--------------------------------------------------------------------------
- # ★ 隐藏指令选择窗口
- #--------------------------------------------------------------------------
- def hide_command_window
- @item_window.active = true
- @command_window.visible = false
- @command_window.active = false
- @viewport.rect.set(0, 0, 544, 416)
- @viewport.ox = 0
- end
- #--------------------------------------------------------------------------
- # ★ 隐藏数量窗口
- #--------------------------------------------------------------------------
- def hide_number_window
- @item_window.active = true
- @number_window.visible = false
- @number_window.active = false
- @viewport.rect.set(0, 0, 544, 416)
- @viewport.ox = 0
- end
- end
- #==============================================================================
- # ■ Window_lost_item
- #------------------------------------------------------------------------------
- # 显示物品丢弃数量的窗口,仿 Window_ShopNumber。
- #==============================================================================
- class Window_LoseNumber < Window_Base
- #--------------------------------------------------------------------------
- # ★ 初始化对像
- # x : 窗口 X 座标
- # y : 窗口 Y 座标
- #--------------------------------------------------------------------------
- def initialize(x, y)
- super(x, y, 260, 104)
- @item = nil
- @max = 1
- @number = 1
- end
- #--------------------------------------------------------------------------
- # ★ 设置物品、最大数量
- #--------------------------------------------------------------------------
- def set(item, max)
- @item = item
- @max = max
- @number = 1
- refresh
- end
- #--------------------------------------------------------------------------
- # ★ 设置数量输入
- #--------------------------------------------------------------------------
- def number
- return @number
- end
- #--------------------------------------------------------------------------
- # ★ 刷新
- #--------------------------------------------------------------------------
- def refresh
- y = 24
- self.contents.clear
- draw_item_name(@item, 0, y)
- self.contents.font.color = normal_color
- self.contents.draw_text(164, y, 20, WLH, "×")
- self.contents.draw_text(190, y, 20, WLH, @number, 2)
- self.cursor_rect.set(186, y, 28, WLH)
- end
- #--------------------------------------------------------------------------
- # ★ 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- if self.active
- last_number = @number
- if Input.repeat?(Input::RIGHT) and @number < @max
- @number += 1
- end
- if Input.repeat?(Input::LEFT) and @number > 1
- @number -= 1
- end
- if Input.repeat?(Input::UP) and @number < @max
- @number = [@number + 10, @max].min
- end
- if Input.repeat?(Input::DOWN) and @number > 1
- @number = [@number - 10, 1].max
- end
- if @number != last_number
- Sound.play_cursor
- refresh
- end
- end
- end
- end
- #==============================================================================
- # ■ Window_Item_Max
- #-----------------------------------------------------------------------------
- # 显示背包容量和当前物品数的窗口
- #============================================================================
- class Window_Item_Max < Window_Base
- #--------------------------------------------------------------------------
- # ★ 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(290, 360, 254, 56)
- refresh
- end
-
- #--------------------------------------------------------------------------
- # ★ 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- draw_icon(144, 0, 0)
- self.contents.draw_text(36, 0, 100, 24, "背包容量:")
- item = $game_party.items
- string = item.size.to_s
- item_max = $game_variables[ITEM_MAX_N]
- item_max = 0 if item_max == nil
- self.contents.font.color = knockout_color if item.size > item_max
- self.contents.draw_text(135, 0, 30, 24, string, 2)
- self.contents.font.color = normal_color
- string = "/ " + item_max.to_s
- self.contents.draw_text(173, 0, 100, 24, string )
- end
- end
- #==============================================================================
- # ■ Window_Waring
- #-----------------------------------------------------------------------------
- # 显示超重警告的窗口
- #============================================================================
- class Window_Waring < Window_Base
- def initialize
- super(544 - 180, 416 - 56, 180, 56)
- refresh
- end
-
- def refresh
- self.contents.clear
- self.contents.draw_text(0, -4, 150, 32, "你已经超重了。")
- end
- end
- #==============================================================================
- # Game_Player 添加更改移动速度的方法
- #============================================================================
- class Game_Player
- def change_move_speed(n)
- @move_speed = n
- end
- end
- #==============================================================================
- # Scene_Map 添加在地图上显示警告窗口的处理
- #============================================================================
- class Scene_Map
- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- def start
- super
- $game_map.refresh
- @spriteset = Spriteset_Map.new
- @message_window = Window_Message.new
- @waring_window = Window_Waring.new
- @waring_window.visible = false
- end
- #--------------------------------------------------------------------------
- # ● 结束处理
- #--------------------------------------------------------------------------
- def terminate
- super
- if $scene.is_a?(Scene_Battle) # 正在切换战斗画面的情况下
- @spriteset.dispose_characters # 为了生成背景隐藏角色
- end
- snapshot_for_background
- @spriteset.dispose
- @message_window.dispose
- @waring_window.dispose
- if $scene.is_a?(Scene_Battle) # 正在切换战斗画面的情况下
- perform_battle_transition # 执行战斗前变换
- end
- end
- #--------------------------------------------------------------------------
- # ● フレーム更新
- #--------------------------------------------------------------------------
- def update
- super
- $game_map.interpreter.update # 更新解释器
- $game_map.update # 更新滴入
- $game_player.update # 更新玩家
- $game_system.update # 更新计时器
- @spriteset.update # 更新活动块元件
- @message_window.update # 更新消息窗口
- unless $game_message.visible # 正在显示消息以外的情况
- update_transfer_player
- update_encounter
- update_call_menu
- update_call_debug
- update_scene_change
- update_over_item
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新物品超限判定
- #--------------------------------------------------------------------------
- def update_over_item
- item_max = $game_variables[ITEM_MAX_N]
- item_max = 0 if item_max == nil
- if $game_party.items.size > item_max
- @waring_window.visible = true
- $game_player.change_move_speed(LOW_SPEED)
- else
- @waring_window.visible = false
- end
- end
- end
复制代码 此贴于 2008-12-19 23:27:14 被版主66RPG发布员提醒,请楼主看到后对本贴做出回应。 |
|