[pre lang="ruby"]class Scene_Battle
alias cld99_use_item use_item
def use_item
p "@subject=#{@subject}"
p "use_item=#{@subject.current_action.item}"
cld99_use_item
end
end[/pre]
基本模式是这样。
不过这样子输出的是16进制object_id,建议换成你需要的参数,比如名字:
[pre lang="ruby"]class Scene_Battle
alias cld99_use_item use_item
def use_item
p "@subject=#{@subject.name}" #改为输出对象的名字
p "use_item=#{@subject.current_action.item.name}"
cld99_use_item
end
end[/pre]
经过测试,角色刚选择完的时候就显示要这样:
[pre lang="ruby"]
class Scene_Battle
alias cld99_on_enemy_ok on_enemy_ok
def on_enemy_ok
p_input ##
cld99_on_enemy_ok
end
alias cld99_on_actor_ok on_actor_ok
def on_actor_ok
p_input ##
cld99_on_actor_ok
end
def command_guard
BattleManager.actor.input.set_guard
p_input ####
next_command
end
def on_skill_ok
@skill = @skill_window.item
BattleManager.actor.input.set_skill(@skill.id)
BattleManager.actor.last_skill.object = @skill
if !@skill.need_selection?
p_input(@skill.id) ####
@skill_window.hide
next_command
elsif @skill.for_opponent?
select_enemy_selection
else
select_actor_selection
end
end
def on_item_ok
@item = @item_window.item
BattleManager.actor.input.set_item(@item.id)
if !@item.need_selection?
p_input(@item.id) ####
@item_window.hide
next_command
elsif @item.for_opponent?
select_enemy_selection
else
select_actor_selection
end
$game_party.last_item.object = @item
end
def p_input(id = nil)
actor = BattleManager.actor
input = actor.input
id ||= input.data_id
puts "#{actor.name}使用了#{id}号#{input.type}'#{input.item.name}'"
end
end
class Game_Action
attr_reader :type, :data_id
alias :cld99_set_skill :set_skill
def set_skill(id)
@type = "技能"
@data_id = id
cld99_set_skill(id)
end
alias :cld99_set_item :set_item
def set_item(id)
@type = "物品"
@data_id = id
cld99_set_item(id)
end
end
[/pre]
居然搞了一个小时……我好菜啊(