# encoding: utf-8
module Item_ShortCut
Variable_ID = 1
Switches_ID = 1
CommonEvent_ID = 1
Animation_ID = 3
Select_Key = Input::X
Use_Key = Input::X
Cool_Down = 40
end
class Scene_Item
include Item_ShortCut
alias _item_shortcut_update_item update_item
def update_item
if Input.trigger?(Select_Key)
# 获取物品窗口当前选中的物品数据
@item = @item_window.item
# 不使用物品的情况下
unless @item.is_a?(RPG::Item)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 不能使用的情况下
if !$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)
# 标记并激活公共事件
item_id = $game_variables[Variable_ID]
if @item.id == item_id
$game_switches[Switches_ID] = false
$game_variables[Variable_ID] = 0
else
$game_switches[Switches_ID] = true
$game_variables[Variable_ID] = @item.id
# 准备公共事件
$data_common_events[CommonEvent_ID] ||= RPG::CommonEvent.new
event = $data_common_events[CommonEvent_ID]
if event.name != "_item_shortcut"
event.name = "_item_shortcut"
event.trigger = 2
event.switch_id = Switches_ID
event.list = [
RPG::EventCommand.new(355, 0, ["_item_shortcut_use_item"]),
RPG::EventCommand.new,
]
$game_map.need_refresh = true
end
end
end
# 继续后面的判断
_item_shortcut_update_item
end
end
class Interpreter
include Item_ShortCut
def _item_shortcut_use_item
if !Input.trigger?(Use_Key)
return
end
if !$scene.is_a?(Scene_Map)
return
end
item_id = $game_variables[Variable_ID]
item = $data_items[item_id]
if !$game_party.item_can_use?(item.id)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
if item.scope > 3
if item.scope == 4 || item.scope == 6
$game_party.actors.each do |actor|
actor.item_effect(item)
end
else
# 给队伍第一个角色使用
$game_party.actors[0].item_effect(item)
end
end
if item.consumable
$game_party.lose_item(item.id, 1)
end
if item.common_event_id > 0
$game_temp.common_event_id = item.common_event_id
end
# 播放动画和设置冷却时间
$game_player.animation_id = Animation_ID
@wait_count = Cool_Down
end
end