#◆◇◆◇◆ 歯車の城・CTB行動順ウィンドウ Icon.ver 1.05 ◇◆◇◆◇ # サポート掲示板 http://www2.ezbbs.net/21/minto-aaa/ # みんとのお部屋 http://oiuytrewq.hp.infoseek.co.jp/minto.html # by みんと # カウントターン・バトル(CTB) Ver 1.10 # 配布元・サポートURL # http://members.jcom.home.ne.jp/cogwheel/ # by ショウ =begin このスクリプトへの質問、 及びサポートはみんとのお部屋までお願いします。 更新履歴 ver 1.01 → ページ切り替えに対応 ver 1.02 → 敵のアイコンIDの取得が間違っていたミスを修正 ver 1.03 → ターゲット選択直後のエラー落ちを修正 ver 1.04 → アクターの名前の変更に対応 ver 1.05 → 防御の計算をしていなかったミスを修正 説明 歯車の城さんのCTB専用の行動順表示スクリプトです。 CTB本体より下に置いてください。 RTABでは使用できません。 Scene_Battle の main を再定義しています。 Aボタン(Zキーでページ切り替えが可能です) 行動順は10回先まで予測 ※注意点!! スキルの詠唱計算は CTBの性質上(というより、みんとの力不足という噂もありますが・・・)、 新たにスキルに計算専用の詠唱値を設定する必要があります。 計算用のスキルの詠唱値は スキル名 (半角スペース)ct値 となります。 例 ヒール ct1 この値を設定していないと、 詠唱を計算できませんので注意してください。 行動順ウィンドウのタイプはアイコンタイプです。 アイコンはアイコンフォルダを使用し、 スキルはそのままスキルのものをします。 アクターのアイコンは 名前I のように、「名前」+ I となっているものを参照します。 例えばアルシェスなら アルシェスI となります。 敵の場合は共用で enemy1 といったように enemy1〜enemy8 までのアイコンをアイコンフォルダに用意してください。 =end #============================================================================== # ■ Scene_Battle #------------------------------------------------------------------------------ #  バトル画面の処理を行うクラスです。 #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● 行動順序取得 #-------------------------------------------------------------------------- def next_name(battler = nil, skills = nil) # 配列を初期化 next_battler = [] skill = nil # ATまたはRTの初期値代入 for member in $game_party.actors + $game_troop.enemies member.ct = member.rtp if member == battler && skills skill = skills end if skill if skill.ct > 0 member.ct = skill.ct member.ct *= @max / 100 elsif skill.ct == 0 member.ct = 0 end end skill = nil member.cp = 100 * member.at / @max if member.ct == 0 member.cp = member.at else member.tp = member.rt end end # 配列の要素が10になるまで繰り返す while next_battler.size <= 9 for member in $game_party.actors + $game_troop.enemies if member.movable? && member.exist? if member.ct == 0 if member.cp >= @max next_battler.push(member) member.cp -= @max elsif member.cp < @max member.cp += member.agi if member.guarding? member.cp += member.agi end end else if member.tp >= member.ct data_skill = $data_skills[member.current_action.skill_id] if member == battler && skills data_skill = skills end next_battler.push(data_skill) if data_skill member.tp = 0 member.ct = 0 elsif member.tp <= member.ct member.tp += member.dex end end end end end return @next_battlers = next_battler end #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- def main # 戦闘用の各種一時データを初期化 $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 # バトルイベント用インタプリタを初期化 $game_system.battle_interpreter.setup(nil, 0) # トループを準備 @troop_id = $game_temp.battle_troop_id $game_troop.setup(@troop_id) atb_setup # アクターコマンドウィンドウを作成 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 # CTBウィンドウを作成 @ctb_window = Window_CTB.new @arrow_window = Window_CTB_Arrow.new @ctb_window.refresh(next_name) # その他のウィンドウを作成 @party_command_window = Window_PartyCommand.new @help_window = Window_Help.new @help_window.back_opacity = 160 @help_window.y += 64 @help_window.visible = false @status_window = Window_BattleStatus.new @message_window = Window_Message.new # スプライトセットを作成 @spriteset = Spriteset_Battle.new # ウェイトカウントを初期化 @wait_count = 0 # トランジション実行 if $data_system.battle_transition == "" Graphics.transition(20) else Graphics.transition(40, "Graphics/Transitions/" + $data_system.battle_transition) end # プレバトルフェーズ開始 start_phase1 # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # マップをリフレッシュ $game_map.refresh # トランジション準備 Graphics.freeze # ウィンドウを解放 @actor_command_window.dispose @party_command_window.dispose @help_window.dispose @status_window.dispose if @status_window @message_window.dispose # CTBウィンドウを解放 @ctb_window.dispose @arrow_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 # スプライトセットを解放 @spriteset.dispose # タイトル画面に切り替え中の場合 if $scene.is_a?(Scene_Title) # 画面をフェードアウト Graphics.transition Graphics.freeze end # 戦闘テストからゲームオーバー画面以外に切り替え中の場合 if $BTEST and not $scene.is_a?(Scene_Gameover) $scene = nil end end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 1 : アクション準備) #-------------------------------------------------------------------------- alias update_phase4_step1_CTB_Window update_phase4_step1 def update_phase4_step1(battler) # 元の処理を実行 update_phase4_step1_CTB_Window(battler) @arrow_window.clear end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : スキル選択) #-------------------------------------------------------------------------- alias update_phase3_skill_select_CTB_Window update_phase3_skill_select def update_phase3_skill_select @update = false @active_actor.current_action.skill_id = 0 if Input.trigger?(Input::B) @ctb_window.refresh(next_name) end # 元の処理を実行 update_phase3_skill_select_CTB_Window end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : アイテム選択) #-------------------------------------------------------------------------- alias update_phase3_item_select_CTB_Window update_phase3_item_select def update_phase3_item_select @update = false # 元の処理を実行 update_phase3_item_select_CTB_Window end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ) #-------------------------------------------------------------------------- alias update_phase4_step6_CTB_Window update_phase4_step6 def update_phase4_step6(battler) # 元の処理を実行 update_phase4_step6_CTB_Window(battler) battler.current_action.skill_id = 0 @ctb_window.refresh(next_name) end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : エネミー選択) #-------------------------------------------------------------------------- alias update_phase3_enemy_select_CTB_Window update_phase3_enemy_select def update_phase3_enemy_select # 元の処理を実行 update_phase3_enemy_select_CTB_Window if @enemy_arrow && !Input.trigger?(Input::B) enemy = @enemy_arrow.enemy end skill = $data_skills[@active_actor.current_action.skill_id] @ctb_window.refresh(next_name(@active_actor, skill)) if !@update @update = true @arrow_window.get_battlers(@next_battlers, enemy) #if Input.dir4 != 0 # A ボタンが押された場合 if Input.trigger?(Input::A) @ctb_window.move @arrow_window.set_page(@ctb_window.get_page) end end #-------------------------------------------------------------------------- # ● エネミー選択終了 #-------------------------------------------------------------------------- alias end_enemy_select_CTB_Window end_enemy_select def end_enemy_select # 元の処理を実行 @update = false end_enemy_select_CTB_Window @update = false end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : 基本コマンド) #-------------------------------------------------------------------------- alias update_phase3_basic_command_CTB_Window update_phase3_basic_command def update_phase3_basic_command # 元の処理を実行 update_phase3_basic_command_CTB_Window # A ボタンが押された場合 if Input.trigger?(Input::A) @ctb_window.move @arrow_window.set_page(@ctb_window.get_page) end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : アクター選択) #-------------------------------------------------------------------------- alias update_phase3_actor_select_CTB_Window update_phase3_actor_select def update_phase3_actor_select # 元の処理を実行 update_phase3_actor_select_CTB_Window skill = $data_skills[@active_actor.current_action.skill_id] @ctb_window.refresh(next_name(@active_actor, skill)) if !@update @update = true if @actor_arrow && !Input.trigger?(Input::B) actor = @actor_arrow.actor end @arrow_window.get_battlers(@next_battlers, actor) #if Input.dir4 != 0 # A ボタンが押された場合 if Input.trigger?(Input::A) @ctb_window.move @arrow_window.set_page(@ctb_window.get_page) end end #-------------------------------------------------------------------------- # ● アクター選択終了 #-------------------------------------------------------------------------- alias end_actor_select_CTB_Window end_actor_select def end_actor_select # 元の処理を実行 @update = false end_actor_select_CTB_Window @update = false end end #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :cp # 計算用AT値 attr_accessor :tp # 計算用RT値 attr_accessor :ct # 計算用RT値 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_CTB_Window initialize def initialize # 元の処理を実行 initialize_CTB_Window @cp = 0 @tp = 0 @ct = 0 end end #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● クリア #-------------------------------------------------------------------------- def ori_name return $data_actors[self.id].name end end #============================================================================== # ■ Window_CTB_Arrow #------------------------------------------------------------------------------ # 行動順専用のアローを表示するウィンドウです。 #============================================================================== class Window_CTB_Arrow < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 0, 230, 64) self.contents = Bitmap.new(width - 32, height - 32) self.opacity = 0 self.z = 256 @count = 0 @page = 0 end #-------------------------------------------------------------------------- # ● ページセット #-------------------------------------------------------------------------- def set_page(n = 0) @page = n end #-------------------------------------------------------------------------- # ● クリア #-------------------------------------------------------------------------- def clear self.contents.clear end #-------------------------------------------------------------------------- # ● 行動順序取得 #-------------------------------------------------------------------------- def get_battlers(next_battlers, battler) x = -40 for i in @page...next_battlers.size target = next_battlers[i] if target == battler x = 0 + ((i - @page) * 40) break end end self.contents.clear arrow = RPG::Cache.windowskin($game_system.windowskin_name) # 点滅カウントを更新 @count = (@count + 1) % 8 # 転送元の矩形を設定 if @count < 4 self.contents.blt(x, 0, arrow, Rect.new(128, 96, 32, 32), 180) else self.contents.blt(x, 0, arrow, Rect.new(160, 96, 32, 32), 180) end end end #============================================================================== # ■ Window_CTB #------------------------------------------------------------------------------ # キャラの行動順を表示するウィンドウです。 #============================================================================== class Window_CTB < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 0, 230, 64) self.contents = Bitmap.new(width - 32, height - 32) self.opacity = 160 self.z = 255 @next_battlers = [] @last_battlers = [] @page = 0 end #-------------------------------------------------------------------------- # ● ページ取得 #-------------------------------------------------------------------------- def get_page return @page end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh(next_battlers = [], move = false) @next_battlers = next_battlers return if @last_battlers == next_battlers && ! move self.contents.clear self.contents.font.size = 15 if move if @page == 5 @page = 0 else @page = 5 end end x = -40 enemy = [] for i in @page...next_battlers.size x += 40 if next_battlers[i].is_a?(Game_Actor) bitmap = RPG::Cache.icon(next_battlers[i].ori_name + "I") elsif next_battlers[i].is_a?(Game_Enemy) if enemy.include?(next_battlers[i]) bitmap = RPG::Cache.icon("enemy#{enemy.index(next_battlers[i])+1}") else enemy.push(next_battlers[i]) bitmap = RPG::Cache.icon("enemy#{enemy.index(next_battlers[i])+1}") end else bitmap = RPG::Cache.icon(next_battlers[i].icon_name) end if i != 0 self.contents.blt(x, 4, bitmap, Rect.new(0, 0, 24, 24), 160) else self.contents.blt(x, 4, bitmap, Rect.new(0, 0, 24, 24)) end #self.contents.draw_text(x, 0, 32, 32, next_battlers[i].name.to_s) end @last_battlers = next_battlers self.contents.font.size = 22 end #-------------------------------------------------------------------------- # ● リスト移動 #-------------------------------------------------------------------------- def move refresh(@last_battlers, true) end end #============================================================================== # ■ Window_PartyCommand #------------------------------------------------------------------------------ #  バトル画面で、戦うか逃げるかを選択するウィンドウです。 #============================================================================== class Window_PartyCommand < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_CTB_Window initialize def initialize # 元の処理を実行 initialize_CTB_Window self.y += 64 end end #============================================================================== # ■ Window_Item #------------------------------------------------------------------------------ #  アイテム画面、バトル画面で、所持アイテムの一覧を表示するウィンドウです。 #============================================================================== class Window_Item < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_CTB_Window initialize def initialize # 元の処理を実行 initialize_CTB_Window # 戦闘中の場合はウィンドウを画面中央へ移動し、半透明にする if $game_temp.in_battle self.y += 64 self.height -= 64 end end end #============================================================================== # ■ Window_Skill #------------------------------------------------------------------------------ #  スキル画面、バトル画面で、使用できるスキルの一覧を表示するウィンドウです。 #============================================================================== class Window_Skill < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_CTB_Window initialize def initialize(actor) # 元の処理を実行 initialize_CTB_Window(actor) # 戦闘中の場合はウィンドウを画面中央へ移動し、半透明にする if $game_temp.in_battle self.y += 64 self.height -= 64 end end end #============================================================================== # ■ RPG::Skill #============================================================================== module RPG class Skill def name name = @name.split(/ /)[0] return name != nil ? name : '' end def ct name = @name.split(/ct/)[1].to_i return name != 0 ? name : 0 end end end