| 赞 | 189 |
| VIP | |
| 好人卡 | |
| 积分 | 96 |
| 经验 | |
| 最后登录 | 2026-5-4 |
| 在线时间 | 5074 小时 |
- 梦石
- 0
- 星屑
- 9557
- 在线时间
- 5074 小时
- 注册时间
- 2013-6-21
- 回帖
- 3459
  
|
发表于 2014-9-18 13:54:37
|
显示全部楼层
本帖最后由 RyanBern 于 2015-7-31 11:35 编辑
感觉LS的回答有点问题,如果真的那样去做了,那么点击一个物品之后,到底是使用还是丢弃就不确定了。
这个脚本重设了def update_item方法,在点击任何一件物品时(武器防具也可),会出现“使用”和“丢弃”的命令框,根据命令进行操作。
用法:粘贴到Main前,可能会和某些脚本冲突(例如更改物品界面结构的脚本)。另外这个丢弃功能只在平时有效,战斗的时候无效。
范例:
Project10.rar
(188.08 KB, 下载次数: 82)
- class Window_ItemCommand < Window_Command
- attr_accessor :calling_window
- def initialize(width, commands)
- super(width, commands)
- @item = nil
- @calling_window = nil
- self.z = 120
- self.active = false
- self.visible = false
- end
- def item=(item)
- @item = item
- refresh
- end
- def refresh
- self.contents.clear
- (0...@item_max).each do |i|
- draw_item(i, normal_color)
- end
- unless @item.is_a?(RPG::Item) && $game_party.item_can_use?(@item.id)
- disable_item(0)
- end
- end
- def adjust_position
- if @calling_window.nil?
- return
- end
- if @calling_window.cursor_y + 32 + self.height < 480
- self.y = @calling_window.cursor_y + 32
- else
- self.y = @calling_window.cursor_y - self.height
- end
- self.x = @calling_window.cursor_x
- end
- end
- class Window_Selectable
- def cursor_x
- cursor_width = self.width / @column_max - 32
- x = @index % @column_max * (cursor_width + 32) + self.x + 16
- return x
- end
- def cursor_y
- y = @index / @column_max * 32 - self.oy + self.y + 16
- return y
- end
- end
- class Window_Dump < Window_Base
- def initialize
- super(0, 0, 176, 96)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.x = 320 - width / 2
- self.y = 240 - height / 2
- self.z = 200
- self.active = false
- self.visible = false
- @max = 1
- @number = 1
- end
- def set(max)
- @max = max
- @number = 1
- refresh
- end
- def number
- return @number
- end
- def refresh
- self.contents.clear
- self.contents.font.color = system_color
- self.contents.draw_text(0, 0, 144, 32, "输入丢弃个数")
- self.contents.font.color = normal_color
- self.contents.draw_text(72, 32, 32, 32, "×")
- self.contents.draw_text(104, 32, 24, 32, @number.to_s, 2)
- self.cursor_rect.set(100, 32, 32, 32)
- end
- def update
- super
- if self.active
- # 光标右 (+1)
- if Input.repeat?(Input::RIGHT) and @number < @max
- $game_system.se_play($data_system.cursor_se)
- @number += 1
- refresh
- end
- # 光标左 (-1)
- if Input.repeat?(Input::LEFT) and @number > 1
- $game_system.se_play($data_system.cursor_se)
- @number -= 1
- refresh
- end
- # 光标上 (+10)
- if Input.repeat?(Input::UP) and @number < @max
- $game_system.se_play($data_system.cursor_se)
- @number = [@number + 10, @max].min
- refresh
- end
- # 光标下 (-10)
- if Input.repeat?(Input::DOWN) and @number > 1
- $game_system.se_play($data_system.cursor_se)
- @number = [@number - 10, 1].max
- refresh
- end
- end
- end
- end
- class Scene_Item
- alias rb_main main
- def main
- @dump_window = Window_Dump.new
- @command_window = Window_ItemCommand.new(108, ["使用", "丢弃"])
- rb_main
- @dump_window.dispose
- @command_window.dispose
- end
- def update
- @command_window.calling_window = @item_window
- @dump_window.update
- @command_window.update
- @help_window.update
- @item_window.update
- @target_window.update
- if @item_window.active
- update_item
- return
- end
- if @target_window.active
- update_target
- return
- end
- if @command_window.active
- update_command
- return
- end
- if @dump_window.active
- update_dump
- return
- end
- end
- def update_item
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- $scene = Scene_Menu.new(0)
- return
- end
- if Input.trigger?(Input::C)
- @item = @item_window.item
- if @item.nil?
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- $game_system.se_play($data_system.decision_se)
- @command_window.item = @item
- @command_window.adjust_position
- @command_window.index = 0
- @command_window.active = true
- @command_window.visible = true
- @item_window.active = false
- return
- end
- end
- def update_command
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @command_window.visible = false
- @command_window.active = false
- @item_window.active = true
- return
- end
- if Input.trigger?(Input::C)
- case @command_window.index
- when 0
- unless @item.is_a?(RPG::Item) && $game_party.item_can_use?(@item.id)
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- $game_system.se_play($data_system.decision_se)
- if @item.scope >= 3
- @command_window.active = false
- @command_window.visible = false
- @target_window.x = (@item_window.index + 1) % 2 * 304
- @target_window.visible = true
- @target_window.active = true
- if @item.scope == 4 || @item.scope == 6
- @target_window.index = -1
- else
- @target_window.index = 0
- end
- else
- if @item.common_event_id > 0
- $game_temp.common_event_id = @item.common_event_id
- $game_system.se_play(@item.menu_se)
- if @item.consumable
- $game_party.lose_item(@item.id, 1)
- @item_window.draw_item(@item_window.index)
- end
- $scene = Scene_Map.new
- return
- end
- end
- when 1
- case @item
- when RPG::Item
- number = $game_party.item_number(@item.id)
- when RPG::Weapon
- number = $game_party.weapon_number(@item.id)
- when RPG::Armor
- number = $game_party.weapon_number(@item.id)
- end
- $game_system.se_play($data_system.decision_se)
- @dump_window.set(number)
- @dump_window.visible = true
- @dump_window.active = true
- @command_window.visible = false
- @command_window.active = false
- end
- end
- return
- end
- def update_dump
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- @dump_window.visible = false
- @dump_window.active = false
- @command_window.active = true
- @command_window.visible = true
- return
- end
- if Input.trigger?(Input::C)
- $game_system.se_play($data_system.shop_se)
- number = @dump_window.number
- case @item
- when RPG::Item
- $game_party.lose_item(@item.id, number)
- when RPG::Weapon
- $game_party.lose_weapon(@item.id, number)
- when RPG::Armor
- $game_party.lose_armor(@item.id, number)
- end
- @dump_window.visible = false
- @dump_window.active = false
- @item_window.active = true
- @item_window.refresh
- return
- end
- end
- end
复制代码 |
评分
-
查看全部评分
|