# ● 设置战斗事件
#--------------------------------------------------------------------------
def setup_battle_event
# 正在执行战斗事件的情况下
if $game_system.battle_interpreter.running?
return
end
# 搜索全部页的战斗事件
event_flags2 = 0
for index in 0...$data_troops[4].pages.size
# 获取事件页
page2 = $data_troops[4].pages[index]
# 事件条件可以参考 c
c = page2.condition
# 没有指定任何条件的情况下转到下一页
unless c.turn_valid or c.enemy_valid or
c.actor_valid or c.switch_valid
next
end
# 执行完毕的情况下转到下一页
if $game_temp.battle_event_flags[index]
next
end
# 确认回合条件
if c.turn_valid
n = $game_temp.battle_turn
a = c.turn_a
b = c.turn_b
if (b == 0 and n != a) or
(b > 0 and (n < 1 or n < a or n % b != a % b))
next
end
end
# 确认敌人条件
if c.enemy_valid
enemy = $game_troop.enemies[c.enemy_index]
if enemy == nil or enemy.hp * 100.0 / enemy.maxhp > c.enemy_hp
next
end
end
# 确认角色条件
if c.actor_valid
actor = $game_actors[c.actor_id]
if actor == nil or actor.hp * 100.0 / actor.maxhp > c.actor_hp
next
end
end
# 确认开关条件
if c.switch_valid
if $game_switches[c.switch_id] == false
next
end
end
event_flags = true
# 设置事件
$game_system.battle_interpreter.setup(page2.list, 0)
if page2.span <= 1
# 设置执行结束标志
$game_temp.battle_event_flags[index] = true
end
#return
end
for index2 in 0...$data_troops[@troop_id].pages.size
# 获取事件页
page = $data_troops[@troop_id].pages[index2]
# 事件条件可以参考 c
c = page.condition
# 没有指定任何条件的情况下转到下一页
unless c.turn_valid or c.enemy_valid or
c.actor_valid or c.switch_valid
next
end
# 执行完毕的情况下转到下一页
if event_flags2 == true
#event_flags2 = 0
next
end
# 确认回合条件
if c.turn_valid
n = $game_temp.battle_turn
a = c.turn_a
b = c.turn_b
if (b == 0 and n != a) or
(b > 0 and (n < 1 or n < a or n % b != a % b))
next
end
end
# 确认敌人条件
if c.enemy_valid
enemy = $game_troop.enemies[c.enemy_index]
if enemy == nil or enemy.hp * 100.0 / enemy.maxhp > c.enemy_hp
next
end
end
# 确认角色条件
if c.actor_valid
actor = $game_actors[c.actor_id]
if actor == nil or actor.hp * 100.0 / actor.maxhp > c.actor_hp
next
end
end
# 确认开关条件
if c.switch_valid
if $game_switches[c.switch_id] == false
next
end
end
# 设置事件
$game_system.battle_interpreter.setup(page.list, 0) if $game_temp.battle_event_flags[index2] != true
$game_system.battle_interpreter.setup(page.list+page2.list, 0) if event_flags == true
event_flags2 = true
# 本页的范围是 [战斗] 或 [回合] 的情况下
if page.span <= 1
# 设置执行结束标志
$game_temp.battle_event_flags[index2] = true
end
return
end
end
end