バトル画面の処理を行うクラスです。
- A
- B
- C
-
- check_substitute,
- command_attack,
- command_escape,
- command_fight,
- command_guard,
- command_item,
- command_skill,
- create_actor_command_window,
- create_actor_window,
- create_all_windows,
- create_enemy_window,
- create_help_window,
- create_info_viewport,
- create_item_window,
- create_log_window,
- create_message_window,
- create_party_command_window,
- create_scroll_text_window,
- create_skill_window,
- create_spriteset,
- create_status_window
- D
- E
- I
- M
- N
- O
- P
- R
- S
- T
- U
- W
ウェイト(早送り無効)
Source: show
# File Scene_Battle.rb, line 92 def abs_wait(duration) duration.times {|i| update_for_wait } end
短時間ウェイト(早送り無効)
Source: show
# File Scene_Battle.rb, line 99 def abs_wait_short abs_wait(15) end
敵味方合わせた全バトルメンバーの取得
Source: show
# File Scene_Battle.rb, line 562 def all_battle_members $game_party.members + $game_troop.members end
スキル/アイテムの効果を適用
Source: show
# File Scene_Battle.rb, line 667 def apply_item_effects(target, item) target.item_apply(@subject, item) refresh_status @log_window.display_action_results(target, item) end
身代わりの適用
Source: show
# File Scene_Battle.rb, line 695 def apply_substitute(target, item) if check_substitute(target, item) substitute = target.friends_unit.substitute_battler if substitute && target != substitute @log_window.display_substitute(substitute, target) return substitute end end target end
戦闘開始
Source: show
# File Scene_Battle.rb, line 525 def battle_start BattleManager.battle_start process_event start_party_command_selection end
身代わり条件チェック
Source: show
# File Scene_Battle.rb, line 709 def check_substitute(target, item) target.hp < target.mhp / 4 && (!item || !item.certain?) end
コマンド[攻撃]
Source: show
# File Scene_Battle.rb, line 375 def command_attack BattleManager.actor.input.set_attack select_enemy_selection end
コマンド[逃げる]
Source: show
# File Scene_Battle.rb, line 359 def command_escape turn_start unless BattleManager.process_escape end
コマンド[戦う]
Source: show
# File Scene_Battle.rb, line 352 def command_fight next_command end
コマンド[防御]
Source: show
# File Scene_Battle.rb, line 393 def command_guard BattleManager.actor.input.set_guard next_command end
コマンド[アイテム]
Source: show
# File Scene_Battle.rb, line 401 def command_item @item_window.refresh @item_window.show.activate end
コマンド[スキル]
Source: show
# File Scene_Battle.rb, line 383 def command_skill @skill_window.actor = BattleManager.actor @skill_window.stype_id = @actor_command_window.current_ext @skill_window.refresh @skill_window.show.activate end
アクターコマンドウィンドウの作成
Source: show
# File Scene_Battle.rb, line 247 def create_actor_command_window @actor_command_window = Window_ActorCommand.new @actor_command_window.viewport = @info_viewport @actor_command_window.set_handler(:attack, method(:command_attack)) @actor_command_window.set_handler(:skill, method(:command_skill)) @actor_command_window.set_handler(:guard, method(:command_guard)) @actor_command_window.set_handler(:item, method(:command_item)) @actor_command_window.set_handler(:cancel, method(:prior_command)) @actor_command_window.x = Graphics.width end
アクターウィンドウの作成
Source: show
# File Scene_Battle.rb, line 287 def create_actor_window @actor_window = Window_BattleActor.new(@info_viewport) @actor_window.set_handler(:ok, method(:on_actor_ok)) @actor_window.set_handler(:cancel, method(:on_actor_cancel)) end
全ウィンドウの作成
Source: show
# File Scene_Battle.rb, line 175 def create_all_windows create_message_window create_scroll_text_window create_log_window create_status_window create_info_viewport create_party_command_window create_actor_command_window create_help_window create_skill_window create_item_window create_actor_window create_enemy_window end
敵キャラウィンドウの作成
Source: show
# File Scene_Battle.rb, line 296 def create_enemy_window @enemy_window = Window_BattleEnemy.new(@info_viewport) @enemy_window.set_handler(:ok, method(:on_enemy_ok)) @enemy_window.set_handler(:cancel, method(:on_enemy_cancel)) end
ヘルプウィンドウの作成
Source: show
# File Scene_Battle.rb, line 261 def create_help_window @help_window = Window_Help.new @help_window.visible = false end
情報表示ビューポートの作成
Source: show
# File Scene_Battle.rb, line 224 def create_info_viewport @info_viewport = Viewport.new @info_viewport.rect.y = Graphics.height - @status_window.height @info_viewport.rect.height = @status_window.height @info_viewport.z = 100 @info_viewport.ox = 64 @status_window.viewport = @info_viewport end
アイテムウィンドウの作成
Source: show
# File Scene_Battle.rb, line 278 def create_item_window @item_window = Window_BattleItem.new(@help_window, @info_viewport) @item_window.set_handler(:ok, method(:on_item_ok)) @item_window.set_handler(:cancel, method(:on_item_cancel)) end
ログウィンドウの作成
Source: show
# File Scene_Battle.rb, line 207 def create_log_window @log_window = Window_BattleLog.new @log_window.method_wait = method(:wait) @log_window.method_wait_for_effect = method(:wait_for_effect) end
メッセージウィンドウの作成
Source: show
# File Scene_Battle.rb, line 193 def create_message_window @message_window = Window_Message.new end
パーティコマンドウィンドウの作成
Source: show
# File Scene_Battle.rb, line 236 def create_party_command_window @party_command_window = Window_PartyCommand.new @party_command_window.viewport = @info_viewport @party_command_window.set_handler(:fight, method(:command_fight)) @party_command_window.set_handler(:escape, method(:command_escape)) @party_command_window.unselect end
スクロール文章ウィンドウの作成
Source: show
# File Scene_Battle.rb, line 200 def create_scroll_text_window @scroll_text_window = Window_ScrollText.new end
スキルウィンドウの作成
Source: show
# File Scene_Battle.rb, line 269 def create_skill_window @skill_window = Window_BattleSkill.new(@help_window, @info_viewport) @skill_window.set_handler(:ok, method(:on_skill_ok)) @skill_window.set_handler(:cancel, method(:on_skill_cancel)) end
スプライトセットの作成
Source: show
# File Scene_Battle.rb, line 161 def create_spriteset @spriteset = Spriteset_Battle.new end
ステータスウィンドウの作成
Source: show
# File Scene_Battle.rb, line 216 def create_status_window @status_window = Window_BattleStatus.new @status_window.x = 128 end
スプライトセットの解放
Source: show
# File Scene_Battle.rb, line 168 def dispose_spriteset @spriteset.dispose end
戦闘行動の実行
Source: show
# File Scene_Battle.rb, line 631 def execute_action @subject.sprite_effect_type = :whiten use_item @log_window.wait_and_clear end
反撃の発動
Source: show
# File Scene_Battle.rb, line 676 def invoke_counter_attack(target, item) @log_window.display_counter(target, item) attack_skill = $data_skills[target.attack_skill_id] @subject.item_apply(target, attack_skill) refresh_status @log_window.display_action_results(@subject, attack_skill) end
スキル/アイテムの発動
Source: show
# File Scene_Battle.rb, line 653 def invoke_item(target, item) if rand < target.item_cnt(@subject, item) invoke_counter_attack(target, item) elsif rand < target.item_mrf(@subject, item) invoke_magic_reflection(target, item) else apply_item_effects(apply_substitute(target, item), item) end @subject.last_target_index = target.index end
魔法反射の発動
Source: show
# File Scene_Battle.rb, line 687 def invoke_magic_reflection(target, item) @log_window.display_reflection(target, item) apply_item_effects(@subject, item) end
情報表示ビューポートの移動
Source: show
# File Scene_Battle.rb, line 139 def move_info_viewport(ox) current_ox = @info_viewport.ox @info_viewport.ox = [ox, current_ox + 16].min if current_ox < ox @info_viewport.ox = [ox, current_ox - 16].max if current_ox > ox end
次のコマンド入力へ
Source: show
# File Scene_Battle.rb, line 312 def next_command if BattleManager.next_command start_actor_command_selection else turn_start end end
アクター[キャンセル]
Source: show
# File Scene_Battle.rb, line 428 def on_actor_cancel @actor_window.hide case @actor_command_window.current_symbol when :skill @skill_window.activate when :item @item_window.activate end end
アクター[決定]
Source: show
# File Scene_Battle.rb, line 417 def on_actor_ok BattleManager.actor.input.target_index = @actor_window.index @actor_window.hide @skill_window.hide @item_window.hide next_command end
敵キャラ[キャンセル]
Source: show
# File Scene_Battle.rb, line 460 def on_enemy_cancel @enemy_window.hide case @actor_command_window.current_symbol when :attack @actor_command_window.activate when :skill @skill_window.activate when :item @item_window.activate end end
敵キャラ[決定]
Source: show
# File Scene_Battle.rb, line 449 def on_enemy_ok BattleManager.actor.input.target_index = @enemy_window.enemy.index @enemy_window.hide @skill_window.hide @item_window.hide next_command end
アイテム[キャンセル]
Source: show
# File Scene_Battle.rb, line 517 def on_item_cancel @item_window.hide @actor_command_window.activate end
アイテム[決定]
Source: show
# File Scene_Battle.rb, line 500 def on_item_ok @item = @item_window.item BattleManager.actor.input.set_item(@item.id) if !@item.need_selection? @item_window.hide next_command elsif @item.for_opponent? select_enemy_selection else select_actor_selection end $game_party.last_item.object = @item end
スキル[キャンセル]
Source: show
# File Scene_Battle.rb, line 492 def on_skill_cancel @skill_window.hide @actor_command_window.activate end
スキル[決定]
Source: show
# File Scene_Battle.rb, line 475 def on_skill_ok @skill = @skill_window.item BattleManager.actor.input.set_skill(@skill.id) BattleManager.actor.last_skill.object = @skill if !@skill.need_selection? @skill_window.hide next_command elsif @skill.for_opponent? select_enemy_selection else select_actor_selection end end
開始後処理
Source: show
# File Scene_Battle.rb, line 20 def post_start super battle_start end
終了前処理
Source: show
# File Scene_Battle.rb, line 28 def pre_terminate super Graphics.fadeout(30) if SceneManager.scene_is?(Scene_Map) Graphics.fadeout(60) if SceneManager.scene_is?(Scene_Title) end
前のコマンド入力へ
Source: show
# File Scene_Battle.rb, line 323 def prior_command if BattleManager.prior_command start_actor_command_selection else start_party_command_selection end end
戦闘行動の処理
Source: show
# File Scene_Battle.rb, line 598 def process_action return if scene_changing? if !@subject || !@subject.current_action @subject = BattleManager.next_subject end return turn_end unless @subject if @subject.current_action @subject.current_action.prepare if @subject.current_action.valid? @status_window.open execute_action end @subject.remove_current_action end process_action_end unless @subject.current_action end
戦闘行動終了時の処理
Source: show
# File Scene_Battle.rb, line 618 def process_action_end @subject.on_action_end refresh_status @log_window.display_auto_affected_status(@subject) @log_window.wait_and_clear @log_window.display_current_state(@subject) @log_window.wait_and_clear BattleManager.judge_win_loss end
イベントの処理
Source: show
# File Scene_Battle.rb, line 569 def process_event while !scene_changing? $game_troop.interpreter.update $game_troop.setup_battle_event wait_for_message wait_for_effect if $game_troop.all_dead? process_forced_action BattleManager.judge_win_loss break unless $game_troop.interpreter.running? update_for_wait end end
強制された戦闘行動の処理
Source: show
# File Scene_Battle.rb, line 585 def process_forced_action if BattleManager.action_forced? last_subject = @subject @subject = BattleManager.action_forced_battler BattleManager.clear_action_force process_action @subject = last_subject end end
ステータスウィンドウの情報を更新
Source: show
# File Scene_Battle.rb, line 305 def refresh_status @status_window.refresh end
アクター選択の開始
Source: show
# File Scene_Battle.rb, line 409 def select_actor_selection @actor_window.refresh @actor_window.show.activate end
敵キャラ選択の開始
Source: show
# File Scene_Battle.rb, line 441 def select_enemy_selection @enemy_window.refresh @enemy_window.show.activate end
アニメーションの表示
targets : 対象者の配列 animation_id : アニメーション ID(-1: 通常攻撃と同じ)
Source: show
# File Scene_Battle.rb, line 718 def show_animation(targets, animation_id) if animation_id < 0 show_attack_animation(targets) else show_normal_animation(targets, animation_id) end @log_window.wait wait_for_animation end
攻撃アニメーションの表示
targets : 対象者の配列 アクターの場合は二刀流を考慮(左手武器は反転して表示)。 敵キャラの場合は [敵の通常攻撃] 効果音を演奏して一瞬待つ。
Source: show
# File Scene_Battle.rb, line 734 def show_attack_animation(targets) if @subject.actor? show_normal_animation(targets, @subject.atk_animation_id1, false) show_normal_animation(targets, @subject.atk_animation_id2, true) else Sound.play_enemy_attack abs_wait_short end end
早送り判定
Source: show
# File Scene_Battle.rb, line 85 def show_fast? Input.press?(:A) || Input.press?(:C) end
通常アニメーションの表示
targets : 対象者の配列 animation_id : アニメーション ID mirror : 左右反転
Source: show
# File Scene_Battle.rb, line 750 def show_normal_animation(targets, animation_id, mirror = false) animation = $data_animations[animation_id] if animation targets.each do |target| target.animation_id = animation_id target.animation_mirror = mirror abs_wait_short unless animation.to_screen? end abs_wait_short if animation.to_screen? end end
開始処理
Source: show
# File Scene_Battle.rb, line 10 def start super create_spriteset create_all_windows BattleManager.method_wait_for_message = method(:wait_for_message) end
アクターコマンド選択の開始
Source: show
# File Scene_Battle.rb, line 366 def start_actor_command_selection @status_window.select(BattleManager.actor.index) @party_command_window.close @actor_command_window.setup(BattleManager.actor) end
パーティコマンド選択の開始
Source: show
# File Scene_Battle.rb, line 334 def start_party_command_selection unless scene_changing? refresh_status @status_window.unselect @status_window.open if BattleManager.input_start @actor_command_window.close @party_command_window.setup else @party_command_window.deactivate turn_start end end end
終了処理
Source: show
# File Scene_Battle.rb, line 37 def terminate super dispose_spriteset @info_viewport.dispose RPG::ME.stop end
ターン終了
Source: show
# File Scene_Battle.rb, line 547 def turn_end all_battle_members.each do |battler| battler.on_turn_end refresh_status @log_window.display_auto_affected_status(battler) @log_window.wait_and_clear end BattleManager.turn_end process_event start_party_command_selection end
ターン開始
Source: show
# File Scene_Battle.rb, line 534 def turn_start @party_command_window.close @actor_command_window.close @status_window.unselect @subject = nil BattleManager.turn_start @log_window.wait @log_window.clear end
フレーム更新
Source: show
# File Scene_Battle.rb, line 47 def update super if BattleManager.in_turn? process_event process_action end BattleManager.judge_win_loss end
フレーム更新(基本)
Source: show
# File Scene_Battle.rb, line 59 def update_basic super $game_timer.update $game_troop.update @spriteset.update update_info_viewport update_message_open end
フレーム更新(ウェイト用)
Source: show
# File Scene_Battle.rb, line 71 def update_for_wait update_basic end
情報表示ビューポートの更新
Source: show
# File Scene_Battle.rb, line 130 def update_info_viewport move_info_viewport(0) if @party_command_window.active move_info_viewport(128) if @actor_command_window.active move_info_viewport(64) if BattleManager.in_turn? end
メッセージウィンドウを開く処理の更新
ステータスウィンドウなどが閉じ終わるまでオープン度を 0 にする。
Source: show
# File Scene_Battle.rb, line 149 def update_message_open if $game_message.busy? && !@status_window.close? @message_window.openness = 0 @status_window.close @party_command_window.close @actor_command_window.close end end
スキル/アイテムの使用
Source: show
# File Scene_Battle.rb, line 640 def use_item item = @subject.current_action.item @log_window.display_use_item(@subject, item) @subject.use_item(item) refresh_status targets = @subject.current_action.make_targets.compact show_animation(targets, item.animation_id) targets.each {|target| item.repeats.times { invoke_item(target, item) } } end
ウェイト
Source: show
# File Scene_Battle.rb, line 78 def wait(duration) duration.times {|i| update_for_wait if i < duration / 2 || !show_fast? } end
アニメーション表示が終わるまでウェイト
Source: show
# File Scene_Battle.rb, line 114 def wait_for_animation update_for_wait update_for_wait while @spriteset.animation? end