Game_Battler下。新手一枚,不知道有没有bug。
def hp=(hp)
@hp = [[hp, maxhp].min, 0].max
##########以下为添加部分
if self.is_a?(Game_Actor) and self.id == 1 #判断为角色并且id为1。【根据你的主角自行更改】
if self.hp < self.maxhp * 5 / 100 #如果hp低于5%
$game_temp.next_scene = "map"#中断战斗,返回地图
$game_temp.common_event_id = 1#执行公共事件1。【自行设定内容。】
end
end
##########以上为添加部分
if @hp == 0 and not state?(1) and not @immortal
add_state(1) # 附加「无法战斗」状态(1号状态)
@added_states.push(1)
elsif @hp > 0 and state?(1)
remove_state(1) # 移除「无法战斗」状态(1号状态)
@removed_states.push(1)
end
end