Project1
标题: 怎么改可以给物品栏添加丢弃功能 [打印本页]
作者: yang1zhi 时间: 2014-11-30 13:06
标题: 怎么改可以给物品栏添加丢弃功能
默认的物品栏点过去是直接使用的。能不能改成点过去弹出使用和丢弃。除了重要物品以外全可以丢弃。
作者: RyanBern 时间: 2014-11-30 14:53
https://rpg.blue/forum.php?mod=viewthread&tid=371528
记得提问区曾经有这样的帖子,不知道我写的那个直接拿去用还行不行
作者: yang1zhi 时间: 2014-11-30 22:34
RyanBern 发表于 2014-11-30 14:53
https://rpg.blue/forum.php?mod=viewthread&tid=371528
记得提问区曾经有这样的帖子,不知道我写的那个 ...
和我的脚本冲突了。
我有物品分类脚本
#==============================================================================
# ■ 物品分类
#==============================================================================
# 主体窗口透明度
OPACITY_Item = 0
# 使用物品窗口透明度
OPACITY_Target = 200
#==============================================================================
# ■ RPG追加定义
#==============================================================================
module RPG
#--------------------------------------------------------------------------
# ● 物品追加
#--------------------------------------------------------------------------
class Item
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def desc
desc = @description.split(/@/)[1]
return desc != nil ? desc : "物品"
end
end
#--------------------------------------------------------------------------
# ● 武器追加
#--------------------------------------------------------------------------
class Weapon
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def desc
desc = @description.split(/@/)[1]
return desc != nil ? desc : "武器"
end
end
#--------------------------------------------------------------------------
# ● 防具追加
#--------------------------------------------------------------------------
class Armor
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def desc
desc = @description.split(/@/)[1]
return desc != nil ? desc : "防具"
end
end
end
#==============================================================================
# ■ Window_Target
#------------------------------------------------------------------------------
# 物品画面与特技画面的、使用对像角色选择窗口。
# 修复使用物品时还有跟随帮助窗口....
#==============================================================================
class Window_Target < Window_Selectable
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item)
#校正帮助窗口位置
@help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
end
end
#==============================================================================
# ■ Window_ItemCommand
#------------------------------------------------------------------------------
# 显示分类的窗口。
#==============================================================================
class Window_ItemCommand < Window_Selectable
attr_accessor :commands
#--------------------------------------------------------------------------
# ● 初始化对像
# commands : 命令字符串序列
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 416)
self.opacity = OPACITY_Item
@commands = []
# 获取物品
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
push = true
for com in @commands
if com == $data_items[i].desc
push = false
end
end
if push == true
@commands.push($data_items[i].desc)
end
end
end
# 获取武器
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
push = true
for com in @commands
if com == $data_weapons[i].desc
push = false
end
end
if push == true
@commands.push($data_weapons[i].desc)
end
end
end
# 获取防具
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
push = true
for com in @commands
if com == $data_armors[i].desc
push = false
end
end
if push == true
@commands.push($data_armors[i].desc)
end
end
end
if @commands == []
@commands.push("普通物品")
end
@item_max = @commands.size
self.contents = Bitmap.new(width - 32, @item_max * 32)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
# color : 文字色
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
y = index * 32
self.contents.draw_text(4, y, 128, 32, @commands[index])
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item)
#校正帮助窗口位置
@help_window.set_pos(self.x,self.y,32,self.oy,self.index,@column_max)
end
end
#==============================================================================
# ■ Window_Item
#------------------------------------------------------------------------------
# 物品画面、战斗画面、显示浏览物品的窗口。
#==============================================================================
class Window_ItemList < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(160, 0, 480, 480)
self.opacity = OPACITY_Item
@column_max = 2
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
end
#--------------------------------------------------------------------------
# ● 分类
# command : 类别名称
#--------------------------------------------------------------------------
def set_item(command)
refresh
if $game_temp.in_battle
# 添加物品
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
end
for i in 1...$data_items.size
if $game_party.item_number(i) > 0 and $data_items[i].desc == command
@data.push($data_items[i])
end
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and $data_weapons[i].desc == command
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and $data_armors[i].desc == command
@data.push($data_armors[i])
end
end
# 如果项目数不是 0 就生成位图、重新描绘全部项目
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 获取物品的所持数
#--------------------------------------------------------------------------
def item_number
return @item_max
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
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.armor_number(item.id)
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (208 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 170, y, 16, 32, ":", 1)
self.contents.draw_text(x + 176, y, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item)
#校正帮助窗口位置
@help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
end
end
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
# 处理物品画面的类。
#==============================================================================
class Scene_Item
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 创建背景图
@itemmenu = Sprite.new
@itemmenu.bitmap = RPG::Cache.picture("物品背景.png")
# 生成帮助窗口、物品窗口
@itemcommand_window = Window_ItemCommand.new
@command_index = @itemcommand_window.index
@itemlist_window = Window_ItemList.new
@itemlist_window.active = false
@help_window = Window_Help.new
# 生成金钱窗口
@gold_window = Window_Gold.new
@gold_window.y = 416
@gold_window.opacity = OPACITY_Item
# 关联帮助窗口
@itemcommand_window.help_window = @help_window
@itemlist_window.help_window = @help_window
# 生成目标窗口 (设置为不可见・不活动)
@target_window = Window_Target.new
# 关联帮助窗口
@target_window.help_window = @help_window
@target_window.opacity = OPACITY_Target
@target_window.visible = false
@target_window.active = false
@itemlist_window.set_item(@itemcommand_window.commands[@command_index])
# 执行过度
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换就中断循环
if $scene != self
break
end
end
# 装备过渡
Graphics.freeze
# 释放窗口
@itemmenu.dispose
@itemcommand_window.dispose
@itemlist_window.dispose
@gold_window.dispose
@help_window.dispose
@target_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
@gold_window.update
@itemlist_window.update
@itemcommand_window.update
@target_window.update
if @command_index != @itemcommand_window.index
@command_index = @itemcommand_window.index
@itemlist_window.set_item(@itemcommand_window.commands[@command_index])
end
# 分类窗口被激活的情况下: 调用 update_itemcommand
if @itemcommand_window.active
update_itemcommand
return
end
# 物品窗口被激活的情况下: 调用 update_itemlist
if @itemlist_window.active
update_itemlist
return
end
# 目标窗口被激活的情况下: 调用 update_target
if @target_window.active
update_target
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (分类窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_itemcommand
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(0)
return
end
if Input.trigger?(Input::C)
# 按下 C 键的情况下
if @itemlist_window.item_number == 0
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活目标窗口
@itemcommand_window.active = false
@itemlist_window.active = true
@itemlist_window.index = 0
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (物品窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_itemlist
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
@itemcommand_window.active = true
@itemlist_window.active = false
@itemlist_window.index = 0
# 切换到分类窗口
@itemcommand_window.index = @command_index
return
end
if Input.trigger?(Input::C)
# 获取物品窗口当前选中的物品数据
@item = @itemlist_window.item
# 不使用物品的情况下
unless @item.is_a?(RPG::Item)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 不能使用的情况下
unless $game_party.item_can_use?(@item.id)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 效果范围是我方的情况下
if @item.scope >= 3
# 激活目标窗口
@itemlist_window.active = false
@target_window.x = 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
# 公共事件 ID 有效的情况下
if @item.common_event_id > 0
# 预约调用公共事件
$game_temp.common_event_id = @item.common_event_id
# 演奏物品使用时的 SE
$game_system.se_play(@item.menu_se)
# 消耗品的情况下
if @item.consumable
# 使用的物品数减 1
$game_party.lose_item(@item.id, 1)
# 再描绘物品窗口的项目
@itemlist_window.draw_item(@itemlist_window.index)
end
# 切换到地图画面
$scene = Scene_Map.new
return
end
end
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (目标窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_target
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 由于物品用完而不能使用的场合
unless $game_party.item_can_use?(@item.id)
# 再次生成物品窗口的内容
@itemlist_window.refresh
end
# 删除目标窗口
@itemlist_window.active = true
@target_window.visible = false
@target_window.active = false
@itemlist_window.set_item(@itemcommand_window.commands[@command_index])
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 如果物品用完的情况下
if $game_party.item_number(@item.id) == 0
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 目标是全体的情况下
if @target_window.index == -1
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# 目标是单体的情况下
if @target_window.index >= 0
# 对目标角色应用物品的使用效果
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# 使用物品的情况下
if used
# 演奏物品使用时的 SE
$game_system.se_play(@item.menu_se)
# 使用的物品数减 1
if @item.consumable
$game_party.lose_item(@item.id, 1)
# 再描绘物品窗口的项目
@itemlist_window.draw_item(@itemlist_window.index)
@itemlist_window.set_item(@itemcommand_window.commands[@command_index])
end
# 再生成目标窗口的内容
@target_window.refresh
# 全灭的情况下
if $game_party.all_dead?
# 切换到游戏结束画面
$scene = Scene_Gameover.new
return
end
# 公共事件 ID 有效的情况下
if @item.common_event_id > 0
# 预约调用公共事件
$game_temp.common_event_id = @item.common_event_id
# 切换到地图画面
$scene = Scene_Map.new
return
end
end
# 无法使用物品的情况下
unless used
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
#==============================================================================
# ■ 物品分类
#==============================================================================
# 主体窗口透明度
OPACITY_Item = 0
# 使用物品窗口透明度
OPACITY_Target = 200
#==============================================================================
# ■ RPG追加定义
#==============================================================================
module RPG
#--------------------------------------------------------------------------
# ● 物品追加
#--------------------------------------------------------------------------
class Item
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def desc
desc = @description.split(/@/)[1]
return desc != nil ? desc : "物品"
end
end
#--------------------------------------------------------------------------
# ● 武器追加
#--------------------------------------------------------------------------
class Weapon
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def desc
desc = @description.split(/@/)[1]
return desc != nil ? desc : "武器"
end
end
#--------------------------------------------------------------------------
# ● 防具追加
#--------------------------------------------------------------------------
class Armor
def description
description = @description.split(/@/)[0]
return description != nil ? description : ''
end
def desc
desc = @description.split(/@/)[1]
return desc != nil ? desc : "防具"
end
end
end
#==============================================================================
# ■ Window_Target
#------------------------------------------------------------------------------
# 物品画面与特技画面的、使用对像角色选择窗口。
# 修复使用物品时还有跟随帮助窗口....
#==============================================================================
class Window_Target < Window_Selectable
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item)
#校正帮助窗口位置
@help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
end
end
#==============================================================================
# ■ Window_ItemCommand
#------------------------------------------------------------------------------
# 显示分类的窗口。
#==============================================================================
class Window_ItemCommand < Window_Selectable
attr_accessor :commands
#--------------------------------------------------------------------------
# ● 初始化对像
# commands : 命令字符串序列
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 416)
self.opacity = OPACITY_Item
@commands = []
# 获取物品
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
push = true
for com in @commands
if com == $data_items[i].desc
push = false
end
end
if push == true
@commands.push($data_items[i].desc)
end
end
end
# 获取武器
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
push = true
for com in @commands
if com == $data_weapons[i].desc
push = false
end
end
if push == true
@commands.push($data_weapons[i].desc)
end
end
end
# 获取防具
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
push = true
for com in @commands
if com == $data_armors[i].desc
push = false
end
end
if push == true
@commands.push($data_armors[i].desc)
end
end
end
if @commands == []
@commands.push("普通物品")
end
@item_max = @commands.size
self.contents = Bitmap.new(width - 32, @item_max * 32)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
# color : 文字色
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
y = index * 32
self.contents.draw_text(4, y, 128, 32, @commands[index])
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item)
#校正帮助窗口位置
@help_window.set_pos(self.x,self.y,32,self.oy,self.index,@column_max)
end
end
#==============================================================================
# ■ Window_Item
#------------------------------------------------------------------------------
# 物品画面、战斗画面、显示浏览物品的窗口。
#==============================================================================
class Window_ItemList < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(160, 0, 480, 480)
self.opacity = OPACITY_Item
@column_max = 2
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
end
#--------------------------------------------------------------------------
# ● 分类
# command : 类别名称
#--------------------------------------------------------------------------
def set_item(command)
refresh
if $game_temp.in_battle
# 添加物品
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
end
for i in 1...$data_items.size
if $game_party.item_number(i) > 0 and $data_items[i].desc == command
@data.push($data_items[i])
end
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and $data_weapons[i].desc == command
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and $data_armors[i].desc == command
@data.push($data_armors[i])
end
end
# 如果项目数不是 0 就生成位图、重新描绘全部项目
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 获取物品的所持数
#--------------------------------------------------------------------------
def item_number
return @item_max
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
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.armor_number(item.id)
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (208 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 170, y, 16, 32, ":", 1)
self.contents.draw_text(x + 176, y, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item)
#校正帮助窗口位置
@help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
end
end
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
# 处理物品画面的类。
#==============================================================================
class Scene_Item
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 创建背景图
@itemmenu = Sprite.new
@itemmenu.bitmap = RPG::Cache.picture("物品背景.png")
# 生成帮助窗口、物品窗口
@itemcommand_window = Window_ItemCommand.new
@command_index = @itemcommand_window.index
@itemlist_window = Window_ItemList.new
@itemlist_window.active = false
@help_window = Window_Help.new
# 生成金钱窗口
@gold_window = Window_Gold.new
@gold_window.y = 416
@gold_window.opacity = OPACITY_Item
# 关联帮助窗口
@itemcommand_window.help_window = @help_window
@itemlist_window.help_window = @help_window
# 生成目标窗口 (设置为不可见・不活动)
@target_window = Window_Target.new
# 关联帮助窗口
@target_window.help_window = @help_window
@target_window.opacity = OPACITY_Target
@target_window.visible = false
@target_window.active = false
@itemlist_window.set_item(@itemcommand_window.commands[@command_index])
# 执行过度
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换就中断循环
if $scene != self
break
end
end
# 装备过渡
Graphics.freeze
# 释放窗口
@itemmenu.dispose
@itemcommand_window.dispose
@itemlist_window.dispose
@gold_window.dispose
@help_window.dispose
@target_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
@gold_window.update
@itemlist_window.update
@itemcommand_window.update
@target_window.update
if @command_index != @itemcommand_window.index
@command_index = @itemcommand_window.index
@itemlist_window.set_item(@itemcommand_window.commands[@command_index])
end
# 分类窗口被激活的情况下: 调用 update_itemcommand
if @itemcommand_window.active
update_itemcommand
return
end
# 物品窗口被激活的情况下: 调用 update_itemlist
if @itemlist_window.active
update_itemlist
return
end
# 目标窗口被激活的情况下: 调用 update_target
if @target_window.active
update_target
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (分类窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_itemcommand
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(0)
return
end
if Input.trigger?(Input::C)
# 按下 C 键的情况下
if @itemlist_window.item_number == 0
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活目标窗口
@itemcommand_window.active = false
@itemlist_window.active = true
@itemlist_window.index = 0
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (物品窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_itemlist
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
@itemcommand_window.active = true
@itemlist_window.active = false
@itemlist_window.index = 0
# 切换到分类窗口
@itemcommand_window.index = @command_index
return
end
if Input.trigger?(Input::C)
# 获取物品窗口当前选中的物品数据
@item = @itemlist_window.item
# 不使用物品的情况下
unless @item.is_a?(RPG::Item)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 不能使用的情况下
unless $game_party.item_can_use?(@item.id)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 效果范围是我方的情况下
if @item.scope >= 3
# 激活目标窗口
@itemlist_window.active = false
@target_window.x = 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
# 公共事件 ID 有效的情况下
if @item.common_event_id > 0
# 预约调用公共事件
$game_temp.common_event_id = @item.common_event_id
# 演奏物品使用时的 SE
$game_system.se_play(@item.menu_se)
# 消耗品的情况下
if @item.consumable
# 使用的物品数减 1
$game_party.lose_item(@item.id, 1)
# 再描绘物品窗口的项目
@itemlist_window.draw_item(@itemlist_window.index)
end
# 切换到地图画面
$scene = Scene_Map.new
return
end
end
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (目标窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_target
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 由于物品用完而不能使用的场合
unless $game_party.item_can_use?(@item.id)
# 再次生成物品窗口的内容
@itemlist_window.refresh
end
# 删除目标窗口
@itemlist_window.active = true
@target_window.visible = false
@target_window.active = false
@itemlist_window.set_item(@itemcommand_window.commands[@command_index])
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 如果物品用完的情况下
if $game_party.item_number(@item.id) == 0
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 目标是全体的情况下
if @target_window.index == -1
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# 目标是单体的情况下
if @target_window.index >= 0
# 对目标角色应用物品的使用效果
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# 使用物品的情况下
if used
# 演奏物品使用时的 SE
$game_system.se_play(@item.menu_se)
# 使用的物品数减 1
if @item.consumable
$game_party.lose_item(@item.id, 1)
# 再描绘物品窗口的项目
@itemlist_window.draw_item(@itemlist_window.index)
@itemlist_window.set_item(@itemcommand_window.commands[@command_index])
end
# 再生成目标窗口的内容
@target_window.refresh
# 全灭的情况下
if $game_party.all_dead?
# 切换到游戏结束画面
$scene = Scene_Gameover.new
return
end
# 公共事件 ID 有效的情况下
if @item.common_event_id > 0
# 预约调用公共事件
$game_temp.common_event_id = @item.common_event_id
# 切换到地图画面
$scene = Scene_Map.new
return
end
end
# 无法使用物品的情况下
unless used
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
还有这个背包限制脚本不冲突,不过我想改成0价格的物品不受限制。
#==============================================================================
# 背包可容纳最大的物品种类数。(包括物品,武器,防具)
ITEMS_MAX = 2
# 背包满后,如果再增加物品所提示的信息。
TOP_MESSAGE = "背包已满!"
$不显示金钱窗口 = 41
$不显示物品窗口 = 42
$不显示武器窗口 = 43
$不显示防具窗口 = 44
# 以上开关,当打开的时候,获得物品将不会提示,比如默认打开41号开关,获得金钱不再提示
#==============================================================================
class Game_Party
#---------------------------------------------------------------------
def items
return @items
end
#---------------------------------------------------------------------
def weapons
return @weapons
end
#---------------------------------------------------------------------
def armors
return @armors
end
end
#==============================================================================
class Interpreter
#--------------------------------------------------------------------
def full_judge?(id, n, type)
mn = 0
mn += $game_party.items.keys.size
mn += $game_party.weapons.keys.size
mn += $game_party.armors.keys.size
return false if mn < ITEMS_MAX
case type
when 0
if $game_party.items.keys.include?(id)
return false if $game_party.item_number(id) + n <= 99
end
when 1
if $game_party.weapons.keys.include?(id)
return false if $game_party.weapon_number(id) + n <= 99
end
when 2
if $game_party.armors.keys.include?(id)
return false if $game_party.armor_number(id) + n <= 99
end
end
return true
end
#---------------------------------------------------------------------
def full_top
$game_system.se_play($data_system.buzzer_se)
top = Window_Base.new(200, 100, 240, 64)
top.contents = Bitmap.new(top.width - 32, top.height - 32)
top.contents.draw_text(0, 0, 200, 32, TOP_MESSAGE, 1)
for i in 1..30
Graphics.update
end
for i in 1..20
top.opacity -= 13
top.contents_opacity -= 13
Graphics.update
end
top.dispose
end
def command_125
value = operate_value(@parameters[0], @parameters[1], @parameters[2])
$game_party.gain_gold(value)
if $game_switches[$不显示金钱窗口]==false
carol3_66RPG = Window_Base.new((640-160)/2,128,180,100)
carol3_66RPG.contents = Bitmap.new(carol3_66RPG.width - 32, carol3_66RPG.height - 32)
if value >= 0
carol3_66RPG.contents.draw_text(0,0,240,32,"获得金钱:")
#——声效,可以自己改
Audio.se_play("Audio/SE/"+"006-System06",80,100)
else
carol3_66RPG.contents.draw_text(0,0,240,32,"失去金钱:")
#——声效,可以自己改
Audio.se_play("Audio/SE/"+"005-System05",80,100)
end
carol3_66RPG.contents.draw_text(0,32,240,32,value.abs.to_s)
carol3_66RPG.contents.draw_text(0,32,140,32, $data_system.words.gold,2)
carol3_66RPG.opacity = 160
for i in 0..10
Graphics.update
end
for i in 0..10
carol3_66RPG.opacity -= 30
carol3_66RPG.contents_opacity -= 30
Graphics.update
end
carol3_66RPG.dispose
end
return true
end
#--------------------------------------------------------------------------
# ● 增减物品
#--------------------------------------------------------------------------
def command_126
# 获取要操作的值
value = operate_value(@parameters[1], @parameters[2], @parameters[3])
if full_judge?(@parameters[0], value, 0)
full_top
command_115
return
end
# 增减物品
$game_party.gain_item(@parameters[0], value)
if $game_switches[$不显示物品窗口]==false
carol3_66RPG_item = $data_items[@parameters[0]]
carol3_66RPG = Window_Base.new((640-300)/2,128,300,100)
carol3_66RPG.contents = Bitmap.new(carol3_66RPG.width - 32, carol3_66RPG.height - 32)
if value >= 0
carol3_66RPG.contents.draw_text(0,0,240,32,"获得物品:")
#——声效,可以自己改
Audio.se_play("Audio/SE/"+"006-System06",80,100)
else
carol3_66RPG.contents.draw_text(0,0,240,32,"失去物品:")
#——声效,可以自己改
Audio.se_play("Audio/SE/"+"005-System05",80,100)
end
carol3_66RPG_bitmap = RPG::Cache.icon(carol3_66RPG_item.icon_name)
carol3_66RPG.contents.blt(0, 32, carol3_66RPG_bitmap, Rect.new(0, 0, 24, 24), 255)
carol3_66RPG.contents.draw_text(0 + 28, 32, 212, 32, carol3_66RPG_item.name, 0)
carol3_66RPG.contents.draw_text(0, 32, 268, 32, "×"+value.abs.to_s, 2)
carol3_66RPG.opacity = 160
for i in 0..10
Graphics.update
end
for i in 0..10
carol3_66RPG.opacity -= 30
carol3_66RPG.contents_opacity -= 30
Graphics.update
end
carol3_66RPG.dispose
end
# 继续
return true
end
#--------------------------------------------------------------------------
# ● 增减武器
#--------------------------------------------------------------------------
def command_127
# 获取要操作的值
value = operate_value(@parameters[1], @parameters[2], @parameters[3])
if full_judge?(@parameters[0], value, 1)
full_top
command_115
return
end
# 增减武器
$game_party.gain_weapon(@parameters[0], value)
if $game_switches[$不显示武器窗口]==false
carol3_66RPG_item = $data_weapons[@parameters[0]]
carol3_66RPG = Window_Base.new((640-300)/2,128,300,100)
carol3_66RPG.contents = Bitmap.new(carol3_66RPG.width - 32, carol3_66RPG.height - 32)
if value >= 0
carol3_66RPG.contents.draw_text(0,0,240,32,"获得武器:")
#——声效,可以自己改
Audio.se_play("Audio/SE/"+"006-System06",80,100)
else
carol3_66RPG.contents.draw_text(0,0,240,32,"失去武器:")
#——声效,可以自己改
Audio.se_play("Audio/SE/"+"005-System05",80,100)
end
carol3_66RPG_bitmap = RPG::Cache.icon(carol3_66RPG_item.icon_name)
carol3_66RPG.contents.blt(0, 32, carol3_66RPG_bitmap, Rect.new(0, 0, 24, 24), 255)
carol3_66RPG.contents.draw_text(0 + 28, 32, 212, 32, carol3_66RPG_item.name, 0)
carol3_66RPG.contents.draw_text(0, 32, 268, 32, "×"+value.abs.to_s, 2)
carol3_66RPG.opacity = 160
for i in 0..10
Graphics.update
end
for i in 0..10
carol3_66RPG.opacity -= 30
carol3_66RPG.contents_opacity -= 30
Graphics.update
end
carol3_66RPG.dispose
end
# 继续
return true
end
#--------------------------------------------------------------------------
# ● 增减防具
#--------------------------------------------------------------------------
def command_128
# 获取要操作的值
value = operate_value(@parameters[1], @parameters[2], @parameters[3])
if full_judge?(@parameters[0], value, 2)
full_top
command_115
return
end
# 增减防具
$game_party.gain_armor(@parameters[0], value)
if $game_switches[$不显示防具窗口]==false
carol3_66RPG_item = $data_armors[@parameters[0]]
carol3_66RPG = Window_Base.new((640-300)/2,128,300,100)
carol3_66RPG.contents = Bitmap.new(carol3_66RPG.width - 32, carol3_66RPG.height - 32)
if value >= 0
carol3_66RPG.contents.draw_text(0,0,240,32,"获得防具:")
#——声效,可以自己改
Audio.se_play("Audio/SE/"+"006-System06",80,100)
else
carol3_66RPG.contents.draw_text(0,0,240,32,"失去防具:")
#——声效,可以自己改
Audio.se_play("Audio/SE/"+"005-System05",80,100)
end
carol3_66RPG_bitmap = RPG::Cache.icon(carol3_66RPG_item.icon_name)
carol3_66RPG.contents.blt(0, 32, carol3_66RPG_bitmap, Rect.new(0, 0, 24, 24), 255)
carol3_66RPG.contents.draw_text(0 + 28, 32, 212, 32, carol3_66RPG_item.name, 0)
carol3_66RPG.contents.draw_text(0, 32, 268, 32, "×"+value.abs.to_s, 2)
carol3_66RPG.opacity = 160
for i in 0..10
Graphics.update
end
for i in 0..10
carol3_66RPG.opacity -= 30
carol3_66RPG.contents_opacity -= 30
Graphics.update
end
carol3_66RPG.dispose
end
# 继续
return true
end
end
#==============================================================================
#==============================================================================
# 背包可容纳最大的物品种类数。(包括物品,武器,防具)
ITEMS_MAX = 2
# 背包满后,如果再增加物品所提示的信息。
TOP_MESSAGE = "背包已满!"
$不显示金钱窗口 = 41
$不显示物品窗口 = 42
$不显示武器窗口 = 43
$不显示防具窗口 = 44
# 以上开关,当打开的时候,获得物品将不会提示,比如默认打开41号开关,获得金钱不再提示
#==============================================================================
class Game_Party
#---------------------------------------------------------------------
def items
return @items
end
#---------------------------------------------------------------------
def weapons
return @weapons
end
#---------------------------------------------------------------------
def armors
return @armors
end
end
#==============================================================================
class Interpreter
#--------------------------------------------------------------------
def full_judge?(id, n, type)
mn = 0
mn += $game_party.items.keys.size
mn += $game_party.weapons.keys.size
mn += $game_party.armors.keys.size
return false if mn < ITEMS_MAX
case type
when 0
if $game_party.items.keys.include?(id)
return false if $game_party.item_number(id) + n <= 99
end
when 1
if $game_party.weapons.keys.include?(id)
return false if $game_party.weapon_number(id) + n <= 99
end
when 2
if $game_party.armors.keys.include?(id)
return false if $game_party.armor_number(id) + n <= 99
end
end
return true
end
#---------------------------------------------------------------------
def full_top
$game_system.se_play($data_system.buzzer_se)
top = Window_Base.new(200, 100, 240, 64)
top.contents = Bitmap.new(top.width - 32, top.height - 32)
top.contents.draw_text(0, 0, 200, 32, TOP_MESSAGE, 1)
for i in 1..30
Graphics.update
end
for i in 1..20
top.opacity -= 13
top.contents_opacity -= 13
Graphics.update
end
top.dispose
end
def command_125
value = operate_value(@parameters[0], @parameters[1], @parameters[2])
$game_party.gain_gold(value)
if $game_switches[$不显示金钱窗口]==false
carol3_66RPG = Window_Base.new((640-160)/2,128,180,100)
carol3_66RPG.contents = Bitmap.new(carol3_66RPG.width - 32, carol3_66RPG.height - 32)
if value >= 0
carol3_66RPG.contents.draw_text(0,0,240,32,"获得金钱:")
#——声效,可以自己改
Audio.se_play("Audio/SE/"+"006-System06",80,100)
else
carol3_66RPG.contents.draw_text(0,0,240,32,"失去金钱:")
#——声效,可以自己改
Audio.se_play("Audio/SE/"+"005-System05",80,100)
end
carol3_66RPG.contents.draw_text(0,32,240,32,value.abs.to_s)
carol3_66RPG.contents.draw_text(0,32,140,32, $data_system.words.gold,2)
carol3_66RPG.opacity = 160
for i in 0..10
Graphics.update
end
for i in 0..10
carol3_66RPG.opacity -= 30
carol3_66RPG.contents_opacity -= 30
Graphics.update
end
carol3_66RPG.dispose
end
return true
end
#--------------------------------------------------------------------------
# ● 增减物品
#--------------------------------------------------------------------------
def command_126
# 获取要操作的值
value = operate_value(@parameters[1], @parameters[2], @parameters[3])
if full_judge?(@parameters[0], value, 0)
full_top
command_115
return
end
# 增减物品
$game_party.gain_item(@parameters[0], value)
if $game_switches[$不显示物品窗口]==false
carol3_66RPG_item = $data_items[@parameters[0]]
carol3_66RPG = Window_Base.new((640-300)/2,128,300,100)
carol3_66RPG.contents = Bitmap.new(carol3_66RPG.width - 32, carol3_66RPG.height - 32)
if value >= 0
carol3_66RPG.contents.draw_text(0,0,240,32,"获得物品:")
#——声效,可以自己改
Audio.se_play("Audio/SE/"+"006-System06",80,100)
else
carol3_66RPG.contents.draw_text(0,0,240,32,"失去物品:")
#——声效,可以自己改
Audio.se_play("Audio/SE/"+"005-System05",80,100)
end
carol3_66RPG_bitmap = RPG::Cache.icon(carol3_66RPG_item.icon_name)
carol3_66RPG.contents.blt(0, 32, carol3_66RPG_bitmap, Rect.new(0, 0, 24, 24), 255)
carol3_66RPG.contents.draw_text(0 + 28, 32, 212, 32, carol3_66RPG_item.name, 0)
carol3_66RPG.contents.draw_text(0, 32, 268, 32, "×"+value.abs.to_s, 2)
carol3_66RPG.opacity = 160
for i in 0..10
Graphics.update
end
for i in 0..10
carol3_66RPG.opacity -= 30
carol3_66RPG.contents_opacity -= 30
Graphics.update
end
carol3_66RPG.dispose
end
# 继续
return true
end
#--------------------------------------------------------------------------
# ● 增减武器
#--------------------------------------------------------------------------
def command_127
# 获取要操作的值
value = operate_value(@parameters[1], @parameters[2], @parameters[3])
if full_judge?(@parameters[0], value, 1)
full_top
command_115
return
end
# 增减武器
$game_party.gain_weapon(@parameters[0], value)
if $game_switches[$不显示武器窗口]==false
carol3_66RPG_item = $data_weapons[@parameters[0]]
carol3_66RPG = Window_Base.new((640-300)/2,128,300,100)
carol3_66RPG.contents = Bitmap.new(carol3_66RPG.width - 32, carol3_66RPG.height - 32)
if value >= 0
carol3_66RPG.contents.draw_text(0,0,240,32,"获得武器:")
#——声效,可以自己改
Audio.se_play("Audio/SE/"+"006-System06",80,100)
else
carol3_66RPG.contents.draw_text(0,0,240,32,"失去武器:")
#——声效,可以自己改
Audio.se_play("Audio/SE/"+"005-System05",80,100)
end
carol3_66RPG_bitmap = RPG::Cache.icon(carol3_66RPG_item.icon_name)
carol3_66RPG.contents.blt(0, 32, carol3_66RPG_bitmap, Rect.new(0, 0, 24, 24), 255)
carol3_66RPG.contents.draw_text(0 + 28, 32, 212, 32, carol3_66RPG_item.name, 0)
carol3_66RPG.contents.draw_text(0, 32, 268, 32, "×"+value.abs.to_s, 2)
carol3_66RPG.opacity = 160
for i in 0..10
Graphics.update
end
for i in 0..10
carol3_66RPG.opacity -= 30
carol3_66RPG.contents_opacity -= 30
Graphics.update
end
carol3_66RPG.dispose
end
# 继续
return true
end
#--------------------------------------------------------------------------
# ● 增减防具
#--------------------------------------------------------------------------
def command_128
# 获取要操作的值
value = operate_value(@parameters[1], @parameters[2], @parameters[3])
if full_judge?(@parameters[0], value, 2)
full_top
command_115
return
end
# 增减防具
$game_party.gain_armor(@parameters[0], value)
if $game_switches[$不显示防具窗口]==false
carol3_66RPG_item = $data_armors[@parameters[0]]
carol3_66RPG = Window_Base.new((640-300)/2,128,300,100)
carol3_66RPG.contents = Bitmap.new(carol3_66RPG.width - 32, carol3_66RPG.height - 32)
if value >= 0
carol3_66RPG.contents.draw_text(0,0,240,32,"获得防具:")
#——声效,可以自己改
Audio.se_play("Audio/SE/"+"006-System06",80,100)
else
carol3_66RPG.contents.draw_text(0,0,240,32,"失去防具:")
#——声效,可以自己改
Audio.se_play("Audio/SE/"+"005-System05",80,100)
end
carol3_66RPG_bitmap = RPG::Cache.icon(carol3_66RPG_item.icon_name)
carol3_66RPG.contents.blt(0, 32, carol3_66RPG_bitmap, Rect.new(0, 0, 24, 24), 255)
carol3_66RPG.contents.draw_text(0 + 28, 32, 212, 32, carol3_66RPG_item.name, 0)
carol3_66RPG.contents.draw_text(0, 32, 268, 32, "×"+value.abs.to_s, 2)
carol3_66RPG.opacity = 160
for i in 0..10
Graphics.update
end
for i in 0..10
carol3_66RPG.opacity -= 30
carol3_66RPG.contents_opacity -= 30
Graphics.update
end
carol3_66RPG.dispose
end
# 继续
return true
end
end
#==============================================================================
我觉得这个VA的脚本可以参考
#==============================================================================
# ■ 物品丢弃 + 物品种类数限制 —— 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
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
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |