在战斗中选指令时,按 A 对应的键(键盘上默认是 Z),就开启自动普攻,选择下一个行动的敌人为目标(适用于CP战斗);
如果角色血量百分比低于指定值,就停止自动普攻。
RUBY 代码
[code]class Scene_Battle
STOP_AUTO_HP = 10
#--------------------------------------------------------------------------
# ● 刷新画面 (角色命令回合 : 基本命令)
#--------------------------------------------------------------------------
alias super_update_phase3_basic_command update_phase3_basic_command
def update_phase3_basic_command
# 按下 A 键的情况下
if Input.trigger?(Input::A)
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 设置默认攻击目标,启用自动普攻
@auto_enemy_index = 0
auto
return
end
super_update_phase3_basic_command
end
#--------------------------------------------------------------------------
# ● 设置角色指令窗口
#--------------------------------------------------------------------------
alias super_phase3_setup_command_window phase3_setup_command_window
def phase3_setup_command_window
# 如果启用自动普攻
if@auto_enemy_index != nil
auto
return
end
super_phase3_setup_command_window
end
##########################
def auto
# 如果角色的血量小于指定比例, 停止自动普攻
for actor in$game_party.actors
if actor.hp * 100.0 / actor.maxhp