Scene_Battle 1

Publié le par chindan

#============================================
# ¡ Scene_Battle (•ªŠ„’è‹` 1)
#----------------------------------------------
# @ƒoƒgƒ‹‰æ–ʂ̏ˆ—‚ðs‚¤ƒNƒ‰ƒX‚Å‚·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
# ƒoƒgƒ‹ƒCƒxƒ“ƒg—pƒCƒ“ƒ^ƒvƒŠƒ^‚ð‰Šú‰»
$game_system.battle_interpreter.setup(nil, 0)
# ƒgƒ‹[ƒv‚ð€”õ
@troop_id = $game_temp.battle_troop_id
$game_troop.setup(@troop_id)
# ƒAƒNƒ^[ƒRƒ}ƒ“ƒhƒEƒBƒ“ƒhƒE‚ðì¬
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
# ‚»‚Ì‘¼‚̃EƒBƒ“ƒhƒE‚ðì¬
@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
# ƒXƒvƒ‰ƒCƒgƒZƒbƒg‚ðì¬
@spriteset = Spriteset_Battle.new
# ƒEƒFƒCƒgƒJƒEƒ“ƒg‚ð‰Šú‰»
@wait_count = 0
# ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“ŽÀs
if $data_system.battle_transition == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$data_system.battle_transition)
end
# ƒvƒŒƒoƒgƒ‹ƒtƒF[ƒYŠJŽn
start_phase1
# ƒƒCƒ“ƒ‹[ƒv
loop do
# ƒQ[ƒ€‰æ–Ê‚ðXV
Graphics.update
# “ü—͏î•ñ‚ðXV
Input.update
# ƒtƒŒ[ƒ€XV
update
# ‰æ–Ê‚ªØ‚è‘Ö‚í‚Á‚½‚烋[ƒv‚ð’†’f
if $scene != self
break
end
end
# ƒ}ƒbƒv‚ðƒŠƒtƒŒƒbƒVƒ…
$game_map.refresh
# ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“€”õ
Graphics.freeze
# ƒEƒBƒ“ƒhƒE‚ð‰ð•ú
@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
# ƒXƒvƒ‰ƒCƒgƒZƒbƒg‚ð‰ð•ú
@spriteset.dispose
# ƒ^ƒCƒgƒ‹‰æ–ʂɐ؂è‘Ö‚¦’†‚̏ꍇ
if $scene.is_a?(Scene_Title)
# ‰æ–Ê‚ðƒtƒF[ƒhƒAƒEƒg
Graphics.transition
Graphics.freeze
end
# í“¬ƒeƒXƒg‚©‚çƒQ[ƒ€ƒI[ƒo[‰æ–ʈȊO‚ɐ؂è‘Ö‚¦’†‚̏ꍇ
if $BTEST and not $scene.is_a?(Scene_Gameover)
$scene = nil
end
end
#------------------------------------------
# œ Ÿ”s”»’è
#------------------------------------------
def judge
# ‘S–Å”»’肪^A‚Ü‚½‚̓p[ƒeƒBl”‚ª 0 l‚̏ꍇ
if $game_party.all_dead? or $game_party.actors.size == 0
# ”s–k‰Â”‚̏ꍇ
if $game_temp.battle_can_lose
# ƒoƒgƒ‹ŠJŽn‘O‚Ì BGM ‚É–ß‚·
$game_system.bgm_play($game_temp.map_bgm)
# ƒoƒgƒ‹I—¹
battle_end(2)
# true ‚ð•Ô‚·
return true
end
# ƒQ[ƒ€ƒI[ƒo[ƒtƒ‰ƒO‚ðƒZƒbƒg
$game_temp.gameover = true
# true ‚ð•Ô‚·
return true
end
# ƒGƒlƒ~[‚ª 1 ‘Ì‚Å‚à‘¶Ý‚·‚ê‚Î false ‚ð•Ô‚·
for enemy in $game_troop.enemies
if enemy.exist?
return false
end
end
# ƒAƒtƒ^[ƒoƒgƒ‹ƒtƒF[ƒYŠJŽn (Ÿ—˜)
start_phase5
# true ‚ð•Ô‚·
return true
end
#------------------------------------------
# œ ƒoƒgƒ‹I—¹
# result : Œ‹‰Ê (0:Ÿ—˜ 1:”s–k 2:“¦‘–)
#------------------------------------------
def battle_end(result)
# í“¬’†ƒtƒ‰ƒO‚ðƒNƒŠƒA
$game_temp.in_battle = false
# ƒp[ƒeƒB‘Sˆõ‚̃AƒNƒVƒ‡ƒ“‚ðƒNƒŠƒA
$game_party.clear_actions
# ƒoƒgƒ‹—pƒXƒe[ƒg‚ð‰ðœ
for actor in $game_party.actors
actor.remove_states_battle
end
# ƒGƒlƒ~[‚ðƒNƒŠƒA
$game_troop.enemies.clear
# ƒoƒgƒ‹ ƒR[ƒ‹ƒoƒbƒN‚ðŒÄ‚Ô
if $game_temp.battle_proc != nil
$game_temp.battle_proc.call(result)
$game_temp.battle_proc = nil
end
# ƒ}ƒbƒv‰æ–ʂɐ؂è‘Ö‚¦
$scene = Scene_Map.new
end
#------------------------------------------
# œ ƒoƒgƒ‹ƒCƒxƒ“ƒg‚̃ZƒbƒgƒAƒbƒv
#------------------------------------------
def setup_battle_event
# ƒoƒgƒ‹ƒCƒxƒ“ƒgŽÀs’†‚̏ꍇ
if $game_system.battle_interpreter.running?
return
end
# ƒoƒgƒ‹ƒCƒxƒ“ƒg‚Ì‘Sƒy[ƒW‚ðŒŸõ
for index in 0...$data_troops[@troop_id].pages.size
# ƒCƒxƒ“ƒgƒy[ƒW‚ðŽæ“¾
page = $data_troops[@troop_id].pages[index]
# ƒCƒxƒ“ƒgðŒ‚ð 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
# ƒ^[ƒ“ ðŒŠm”F
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
# ƒGƒlƒ~[ ðŒŠm”F
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
# ƒAƒNƒ^[ ðŒŠm”F
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
# ƒXƒCƒbƒ` ðŒŠm”F
if c.switch_valid
if $game_switches[c.switch_id] == false
next
end
end
# ƒCƒxƒ“ƒg‚ðƒZƒbƒgƒAƒbƒv
$game_system.battle_interpreter.setup(page.list, 0)
# ‚±‚̃y[ƒW‚̃Xƒpƒ“‚ª [ƒoƒgƒ‹] ‚© [ƒ^[ƒ“] ‚̏ꍇ
if page.span <= 1
# ŽÀsÏ‚݃tƒ‰ƒO‚ðƒZƒbƒg
$game_temp.battle_event_flags[index] = true
end
return
end
end
#------------------------------------------
# œ ƒtƒŒ[ƒ€XV
#------------------------------------------
def update
# ƒoƒgƒ‹ƒCƒxƒ“ƒgŽÀs’†‚̏ꍇ
if $game_system.battle_interpreter.running?
# ƒCƒ“ƒ^ƒvƒŠƒ^‚ðXV
$game_system.battle_interpreter.update
# ƒAƒNƒVƒ‡ƒ“‚ð‹­§‚³‚ê‚Ä‚¢‚éƒoƒgƒ‰[‚ª‘¶Ý‚µ‚È‚¢ê‡
if $game_temp.forcing_battler == nil
# ƒoƒgƒ‹ƒCƒxƒ“ƒg‚̎Às‚ªI‚í‚Á‚½ê‡
unless $game_system.battle_interpreter.running?
# í“¬Œp‘±‚̏ꍇAƒoƒgƒ‹ƒCƒxƒ“ƒg‚̃ZƒbƒgƒAƒbƒv‚ðÄŽÀs
unless judge
setup_battle_event
end
end
# ƒAƒtƒ^[ƒoƒgƒ‹ƒtƒF[ƒY‚Å‚È‚¯‚ê‚Î
if @phase != 5
# ƒXƒe[ƒ^ƒXƒEƒBƒ“ƒhƒE‚ðƒŠƒtƒŒƒbƒVƒ…
@status_window.refresh
end
end
end
# ƒVƒXƒeƒ€ (ƒ^ƒCƒ}[)A‰æ–Ê‚ðXV
$game_system.update
$game_screen.update
# ƒ^ƒCƒ}[‚ª 0 ‚É‚È‚Á‚½ê‡
if $game_system.timer_working and $game_system.timer == 0
# ƒoƒgƒ‹’†’f
$game_temp.battle_abort = true
end
# ƒEƒBƒ“ƒhƒE‚ðXV
@help_window.update
@party_command_window.update
@actor_command_window.update
@status_window.update
@message_window.update
# ƒXƒvƒ‰ƒCƒgƒZƒbƒg‚ðXV
@spriteset.update
# ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“ˆ—’†‚̏ꍇ
if $game_temp.transition_processing
# ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“ˆ—’†ƒtƒ‰ƒO‚ðƒNƒŠƒA
$game_temp.transition_processing = false
# ƒgƒ‰ƒ“ƒWƒVƒ‡ƒ“ŽÀs
if $game_temp.transition_name == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$game_temp.transition_name)
end
end
# ƒƒbƒZ[ƒWƒEƒBƒ“ƒhƒE•Ž¦’†‚̏ꍇ
if $game_temp.message_window_showing
return
end
# ƒGƒtƒFƒNƒg•Ž¦’†‚̏ꍇ
if @spriteset.effect?
return
end
# ƒQ[ƒ€ƒI[ƒo[‚̏ꍇ
if $game_temp.gameover
# ƒQ[ƒ€ƒI[ƒo[‰æ–ʂɐ؂è‘Ö‚¦
$scene = Scene_Gameover.new
return
end
# ƒ^ƒCƒgƒ‹‰æ–Ê‚É–ß‚·ê‡
if $game_temp.to_title
# ƒ^ƒCƒgƒ‹‰æ–ʂɐ؂è‘Ö‚¦
$scene = Scene_Title.new
return
end
# ƒoƒgƒ‹’†’f‚̏ꍇ
if $game_temp.battle_abort
# ƒoƒgƒ‹ŠJŽn‘O‚Ì BGM ‚É–ß‚·
$game_system.bgm_play($game_temp.map_bgm)
# ƒoƒgƒ‹I—¹
battle_end(1)
return
end
# ƒEƒFƒCƒg’†‚̏ꍇ
if @wait_count > 0
# ƒEƒFƒCƒgƒJƒEƒ“ƒg‚ðŒ¸‚ç‚·
@wait_count -= 1
return
end
# ƒAƒNƒVƒ‡ƒ“‚ð‹­§‚³‚ê‚Ä‚¢‚éƒoƒgƒ‰[‚ª‘¶Ý‚¹‚¸A
# ‚©‚ƒoƒgƒ‹ƒCƒxƒ“ƒg‚ªŽÀs’†‚̏ꍇ
if $game_temp.forcing_battler == nil and
$game_system.battle_interpreter.running?
return
end
# ƒtƒF[ƒY‚É‚æ‚Á‚Ä•ªŠò
case @phase
when 1 # ƒvƒŒƒoƒgƒ‹ƒtƒF[ƒY
update_phase1
when 2 # ƒp[ƒeƒBƒRƒ}ƒ“ƒhƒtƒF[ƒY
update_phase2
when 3 # ƒAƒNƒ^[ƒRƒ}ƒ“ƒhƒtƒF[ƒY
update_phase3
when 4 # ƒƒCƒ“ƒtƒF[ƒY
update_phase4
when 5 # ƒAƒtƒ^[ƒoƒgƒ‹ƒtƒF[ƒY
update_phase5
end
end
end

Publié dans poubelle

Pour être informé des derniers articles, inscrivez vous :
Commenter cet article