Auteur: Yukihiro matsumoto
#============================================
# ‘ Scene_Battle (ͺθ` 1)
#----------------------------------------------
# @ogζΚΜπs€NXΕ·B
#============================================
class Scene_Battle
#------------------------------------------
# C
#------------------------------------------
def main
# ν¬pΜeνκf[^πϊ»
$game_temp.in_battle = true
$game_temp.battle_turn = 0
$game_temp.battle_event_flags.clear
$game_temp.battle_abort = false
$game_temp.battle_main_phase = false
$game_temp.battleback_name = $game_map.battleback_name
$game_temp.forcing_battler = nil
# ogCxgpC^v^πϊ»
$game_system.battle_interpreter.setup(nil, 0)
# g[vπυ
@troop_id = $game_temp.battle_troop_id
$game_troop.setup(@troop_id)
# AN^[R}hEBhEπμ¬
s1 = $data_system.words.attack
s2 = $data_system.words.skill
s3 = $data_system.words.guard
s4 = $data_system.words.item
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
@actor_command_window.y = 160
@actor_command_window.back_opacity = 160
@actor_command_window.active = false
@actor_command_window.visible = false
# »ΜΌΜEBhEπμ¬
@party_command_window = Window_PartyCommand.new
@help_window = Window_Help.new
@help_window.back_opacity = 160
@help_window.visible = false
@status_window = Window_BattleStatus.new
@message_window = Window_Message.new
# XvCgZbgπμ¬
@spriteset = Spriteset_Battle.new
# EFCgJEgπϊ»
@wait_count = 0
# gWVΐs
if $data_system.battle_transition == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$data_system.battle_transition)
end
# vogtF[YJn
start_phase1
# C[v
loop do
# Q[ζΚπXV
Graphics.update
# όΝξρπXV
Input.update
# t[XV
update
# ζΚͺΨθΦνΑ½η[vπf
if $scene != self
break
end
end
# }bvπtbV
$game_map.refresh
# gWVυ
Graphics.freeze
# EBhEππϊ
@actor_command_window.dispose
@party_command_window.dispose
@help_window.dispose
@status_window.dispose
@message_window.dispose
if @skill_window != nil
@skill_window.dispose
end
if @item_window != nil
@item_window.dispose
end
if @result_window != nil
@result_window.dispose
end
# XvCgZbgππϊ
@spriteset.dispose
# ^CgζΚΙΨθΦ¦Μκ
if $scene.is_a?(Scene_Title)
# ζΚπtF[hAEg
Graphics.transition
Graphics.freeze
end
# ν¬eXg©ηQ[I[o[ζΚΘOΙΨθΦ¦Μκ
if $BTEST and not $scene.is_a?(Scene_Gameover)
$scene = nil
end
end
#------------------------------------------
# s»θ
#------------------------------------------
def judge
# SΕ»θͺ^Aά½Νp[eBlͺ 0 lΜκ
if $game_party.all_dead? or $game_party.actors.size == 0
# skΒΜκ
if $game_temp.battle_can_lose
# ogJnOΜ BGM Ιί·
$game_system.bgm_play($game_temp.map_bgm)
# ogIΉ
battle_end(2)
# true πΤ·
return true
end
# Q[I[o[tOπZbg
$game_temp.gameover = true
# true πΤ·
return true
end
# Gl~[ͺ 1 ΜΕΰΆέ·κΞ false πΤ·
for enemy in $game_troop.enemies
if enemy.exist?
return false
end
end
# At^[ogtF[YJn ()
start_phase5
# true πΤ·
return true
end
#------------------------------------------
# ogIΉ
# result : Κ (0: 1:sk 2:¦)
#------------------------------------------
def battle_end(result)
# ν¬tOπNA
$game_temp.in_battle = false
# p[eBSυΜANVπNA
$game_party.clear_actions
# ogpXe[gππ
for actor in $game_party.actors
actor.remove_states_battle
end
# Gl~[πNA
$game_troop.enemies.clear
# og R[obNπΔΤ
if $game_temp.battle_proc != nil
$game_temp.battle_proc.call(result)
$game_temp.battle_proc = nil
end
# }bvζΚΙΨθΦ¦
$scene = Scene_Map.new
end
#------------------------------------------
# ogCxgΜZbgAbv
#------------------------------------------
def setup_battle_event
# ogCxgΐsΜκ
if $game_system.battle_interpreter.running?
return
end
# ogCxgΜSy[Wπυ
for index in 0...$data_troops[@troop_id].pages.size
# Cxgy[WπζΎ
page = $data_troops[@troop_id].pages[index]
# Cxgππ c ΕQΖΒΙ
c = page.condition
# ½ΰπͺwθ³κΔ’Θ’κΝΜy[WΦ
unless c.turn_valid or c.enemy_valid or
c.actor_valid or c.switch_valid
next
end
# ΐsΟέΜκΝΜy[WΦ
if $game_temp.battle_event_flags[index]
next
end
# ^[ πmF
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
# Gl~[ πmF
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
# AN^[ πmF
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
# XCb` πmF
if c.switch_valid
if $game_switches[c.switch_id] == false
next
end
end
# CxgπZbgAbv
$game_system.battle_interpreter.setup(page.list, 0)
# ±Μy[WΜXpͺ [og] © [^[] Μκ
if page.span <= 1
# ΐsΟέtOπZbg
$game_temp.battle_event_flags[index] = true
end
return
end
end
#------------------------------------------
# t[XV
#------------------------------------------
def update
# ogCxgΐsΜκ
if $game_system.battle_interpreter.running?
# C^v^πXV
$game_system.battle_interpreter.update
# ANVπ§³κΔ’ιog[ͺΆέ΅Θ’κ
if $game_temp.forcing_battler == nil
# ogCxgΜΐsͺIνΑ½κ
unless $game_system.battle_interpreter.running?
# ν¬p±ΜκAogCxgΜZbgAbvπΔΐs
unless judge
setup_battle_event
end
end
# At^[ogtF[YΕΘ―κΞ
if @phase != 5
# Xe[^XEBhEπtbV
@status_window.refresh
end
end
end
# VXe (^C}[)AζΚπXV
$game_system.update
$game_screen.update
# ^C}[ͺ 0 ΙΘΑ½κ
if $game_system.timer_working and $game_system.timer == 0
# ogf
$game_temp.battle_abort = true
end
# EBhEπXV
@help_window.update
@party_command_window.update
@actor_command_window.update
@status_window.update
@message_window.update
# XvCgZbgπXV
@spriteset.update
# gWVΜκ
if $game_temp.transition_processing
# gWVtOπNA
$game_temp.transition_processing = false
# gWVΐs
if $game_temp.transition_name == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$game_temp.transition_name)
end
end
# bZ[WEBhE¦Μκ
if $game_temp.message_window_showing
return
end
# GtFNg¦Μκ
if @spriteset.effect?
return
end
# Q[I[o[Μκ
if $game_temp.gameover
# Q[I[o[ζΚΙΨθΦ¦
$scene = Scene_Gameover.new
return
end
# ^CgζΚΙί·κ
if $game_temp.to_title
# ^CgζΚΙΨθΦ¦
$scene = Scene_Title.new
return
end
# ogfΜκ
if $game_temp.battle_abort
# ogJnOΜ BGM Ιί·
$game_system.bgm_play($game_temp.map_bgm)
# ogIΉ
battle_end(1)
return
end
# EFCgΜκ
if @wait_count > 0
# EFCgJEgπΈη·
@wait_count -= 1
return
end
# ANVπ§³κΔ’ιog[ͺΆέΉΈA
# ©ΒogCxgͺΐsΜκ
if $game_temp.forcing_battler == nil and
$game_system.battle_interpreter.running?
return
end
# tF[YΙζΑΔͺς
case @phase
when 1 # vogtF[Y
update_phase1
when 2 # p[eBR}htF[Y
update_phase2
when 3 # AN^[R}htF[Y
update_phase3
when 4 # CtF[Y
update_phase4
when 5 # At^[ogtF[Y
update_phase5
end
end
end |
|