设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 770|回复: 0
打印 上一主题 下一主题

[已经过期] 戰鬥畫面的問題......

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
510 小时
注册时间
2010-5-8
帖子
266
跳转到指定楼层
1
发表于 2012-9-2 00:58:31 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 PCNinja 于 2012-9-2 01:04 编辑

使用了齒車的RTAB,之後加了不少sprite去美化……
現在敗在hud上.....

先不要吐糟HUD的模樣……
現在hud被戰鬥圖蓋過了,而且有兩個很礙眼的遊標,想不到解決方法
以下是我戰鬥的腳本 (hud的部分由3827行開始……)
RUBY 代码复制
  1. # リアルタイム・アクティブバトル(RTAB) Ver 1.16
  2. # 配布元・サポートURL
  3. # [url]http://members.jcom.home.ne.jp/cogwheel/[/url]
  4.  
  5. class Scene_Battle
  6.   #--------------------------------------------------------------------------
  7.   # ● 公開インスタンス変数
  8.   #--------------------------------------------------------------------------
  9.   attr_reader   :status_window            # ステータスウィンドウ
  10.   attr_reader   :spriteset                # バトルスプライト
  11.   attr_reader   :scroll_time              # スクリーン移動基本時間
  12.   attr_reader   :zoom_rate                # 敵バトラー基本位置
  13.   attr_reader   :drive                    # カメラ駆動
  14.   attr_accessor :force                    # アクション強制度
  15.   attr_accessor :camera                   # 現在のカメラ所持者
  16.   #--------------------------------------------------------------------------
  17.   # ● ATB基礎セットアップ
  18.   #--------------------------------------------------------------------------
  19.   def atb_setup
  20.     # ATB初期化
  21.     # speed   : バトルスピード決定。値が小さいほど早い
  22.     # @active : アクティブ度設定
  23.     #           3 : 常にアクティブ状態
  24.     #           2 : スキル・アイテム選択中のみアクティブゲージが止まる
  25.     #           1 : 2の状態に加え、ターゲット選択時もウェイトが掛かる
  26.     #           0 : 1の状態に加え、コマンド入力時にもウェイトが掛かる
  27.     # @action : 他人が行動中に自分も行動を起こすことを許すか
  28.     #           3 : 自分が行動不能でない限り限り許す
  29.     #           2 : 自分がダメージを受けていない限り許す
  30.     #           1 : 2の状態に加え、ターゲットが行動していない限り許す
  31.     #           0 : 行動を許さない。順番に行動し終えるまで待つ
  32.     # @anime_wait : trueにするとバトルアニメ・ダメージ表示中はウェイトが掛かる
  33.     # @damage_wait : ダメージ表示待ち時間(単位はフレーム)
  34.     # @after_wait : 味方・敵全滅時、次の処理に移るまでの待ち時間
  35.     #               [a, b] a は味方全滅時、b は敵全滅時(単位はフレーム)
  36.     # @enemy_speed : 敵の思考速度。1なら即時行動。
  37.     #                1フレーム毎に、1/@enemy_speedの確率で行動を起こす
  38.     # @force : 強制アクションでスキル使用時の強制具合
  39.     #          2:スキルは全て詠唱せず、必ず即時実行
  40.     #          1:単独スキルは詠唱し、連携スキルのみ即時実行
  41.     #          0:全スキル詠唱を行うだけ
  42.     # ($scene.force = x とすることにより、通常イベントのスクリプトから変更可能)
  43.     # @drive : カメラ駆動ON/OFF。trueで駆動ON、falseで駆動OFF
  44.     # @scroll_time : スクリーン移動に要する基本時間
  45.     # @zoom_rate = [i, j] : エネミーのズーム率
  46.     #                       i が画面最上部に配置した時の拡大率
  47.     #                       j が画面最下部に配置した時の拡大率
  48.     #                       1 倍としたいときも、1.0 と必ず小数で設定すること
  49.     speed = 150
  50.     @active = 1
  51.     @action = 2
  52.     @anime_wait = false
  53.     @damage_wait = 10
  54.     @after_wait = [80, 0]
  55.     @enemy_speed = 40
  56.     @force = 2
  57.     @drive = true
  58.     @scroll_time = 15
  59.     @zoom_rate = [0.2, 1.0]
  60.     @help_time = 40
  61.     @escape == false
  62.     @camera = nil
  63.     @max = 0
  64.     @turn_cnt = 0
  65.     @help_wait = 0
  66.     @action_battlers = []
  67.     @synthe = []
  68.     @spell_p = {}
  69.     @spell_e = {}
  70.     @command_a = false
  71.     @command = []
  72.     @party = false
  73.     for battler in $game_party.actors + $game_troop.enemies
  74.       spell_reset(battler)
  75.       battler.at = battler.agi * rand(speed / 2)
  76.       battler.damage_pop = {}
  77.       battler.damage = {}
  78.       battler.damage_sp = {}
  79.       battler.critical = {}
  80.       battler.recover_hp = {}
  81.       battler.recover_sp = {}
  82.       battler.state_p = {}
  83.       battler.state_m = {}
  84.       battler.animation = []
  85.       if battler.is_a?(Game_Actor)
  86.         @max += battler.agi
  87.       end
  88.     end
  89.     @max *= speed
  90.     @max /= $game_party.actors.size
  91.     for battler in $game_party.actors + $game_troop.enemies
  92.       battler.atp = 100 * battler.at / @max
  93.     end
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # ● ATゲージMax時SE
  97.   #--------------------------------------------------------------------------
  98.   def fullat_se
  99.     Audio.se_play("Audio/SE/033-switch02", 80, 100)
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # ● レベルアップSE
  103.   #--------------------------------------------------------------------------
  104.   def levelup_se
  105.     Audio.se_play("Audio/SE/056-Right02", 80, 100)
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # ● スキル習得SE
  109.   #--------------------------------------------------------------------------
  110.   def skill_se
  111.     Audio.se_play("Audio/SE/056-Right02", 80, 150)
  112.   end
  113. end
  114.  
  115. class Window_Base < Window
  116.   #--------------------------------------------------------------------------
  117.   # ● ATG の描画
  118.   #     actor : アクター
  119.   #     x     : 描画先 X 座標
  120.   #     y     : 描画先 Y 座標
  121.   #     width : 描画先の幅
  122.   #--------------------------------------------------------------------------
  123.   def draw_actor_atg(actor, x, y, width = 144)
  124.     if @at_gauge == nil
  125.       # plus_x:X座標の位置補正 rate_x:X座標の位置補正(%) plus_y:Y座標の位置補正
  126.       # plus_width:幅の補正 rate_width:幅の補正(%) height:縦幅
  127.       # align1:描画タイプ1 0:左詰め 1:中央揃え 2:右詰め
  128.       # align2:描画タイプ2 0:上詰め 1:中央揃え 2:下詰め
  129.       # align3:ゲージタイプ 0:左詰め 1:右詰め
  130.       @plus_x = 21
  131.       @rate_x = 0
  132.       @plus_y = 5
  133.       @plus_width = 0
  134.       @rate_width = 75
  135.       @width = @plus_width + width * @rate_width / 100
  136.       @height = 9
  137.       @align1 = 0
  138.       @align2 = 1
  139.       @align3 = 0
  140.       # グラデーション設定 grade1:空ゲージ grade2:実ゲージ
  141.       # (0:横にグラデーション 1:縦にグラデーション 2:斜めにグラデーション)
  142.       grade1 = 1
  143.       grade2 = 0
  144.       # 色設定。color1:最外枠,color2:中枠
  145.       # color3:空枠ダークカラー,color4:空枠ライトカラー
  146.       color1 = Color.new(0, 0, 0)
  147.       color2 = Color.new(255, 255, 192)
  148.       color3 = Color.new(0, 0, 0, 192)
  149.       color4 = Color.new(0, 0, 64, 192)
  150.       # ゲージの色設定
  151.       # 通常時の色設定
  152.       color5 = Color.new(0, 64, 80)
  153.       color6 = Color.new(0, 128, 160)
  154.       # ゲージがMAXの時の色設定
  155.       color7 = Color.new(80, 0, 0)
  156.       color8 = Color.new(240, 0, 0)
  157.       # 連携スキル使用時の色設定
  158.       color9 = Color.new(80, 64, 32)
  159.       color10 = Color.new(240, 192, 96)
  160.       # スキル詠唱時の色設定
  161.       color11 = Color.new(80, 0, 64)
  162.       color12 = Color.new(240, 0, 192)
  163.       # ゲージの描画
  164.       gauge_rect_at(@width, @height, @align3, color1, color2,
  165.                   color3, color4, color5, color6, color7, color8,
  166.                   color9, color10, color11, color12, grade1, grade2)
  167.     end
  168.     # 変数atに描画するゲージの幅を代入
  169.     if actor.rtp == 0
  170.       at = (width + @plus_width) * actor.atp * @rate_width / 10000
  171.     else
  172.       at = (width + @plus_width) * actor.rt * @rate_width / actor.rtp / 100
  173.     end
  174.     if at > width
  175.       at = width
  176.     end
  177.     # ゲージの左詰・中央構え等の補正
  178.     case @align1
  179.     when 1
  180.       x += (@rect_width - width) / 2
  181.     when 2
  182.       x += @rect_width - width
  183.     end
  184.     case @align2
  185.     when 1
  186.       y -= @height / 2
  187.     when 2
  188.       y -= @height
  189.     end
  190.     self.contents.blt(x + @plus_x + width * @rate_x / 100, y + @plus_y,
  191.                       @at_gauge, Rect.new(0, 0, @width, @height))
  192.     if @align3 == 0
  193.       rect_x = 0
  194.     else
  195.       x += @width - at - 1
  196.       rect_x = @width - at - 1
  197.     end
  198.     # ゲージの色設定
  199.     if at == width
  200.         # MAX時のゲージ描画
  201.       self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
  202.                         @at_gauge, Rect.new(rect_x, @height * 2, at, @height))
  203.     else
  204.       if actor.rtp == 0
  205.         # 通常時のゲージ描画
  206.         self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
  207.                           @at_gauge, Rect.new(rect_x, @height, at, @height))
  208.       else
  209.         if actor.spell == true
  210.           # 連携スキル使用時のゲージ描画
  211.           self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
  212.                         @at_gauge, Rect.new(rect_x, @height * 3, at, @height))
  213.         else
  214.           # スキル詠唱時のゲージ描画
  215.           self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
  216.                         @at_gauge, Rect.new(rect_x, @height * 4, at, @height))
  217.         end
  218.       end
  219.     end
  220.   end
  221. end
  222.  
  223. #==============================================================================
  224. # ■ Scene_Battle (分割定義 1)
  225. #------------------------------------------------------------------------------
  226. #  バトル画面の処理を行うクラスです。
  227. #==============================================================================
  228.  
  229. class Scene_Battle
  230.   #--------------------------------------------------------------------------
  231.   # ● メイン処理
  232.   #--------------------------------------------------------------------------
  233.   def main
  234.     # 戦闘用の各種一時データを初期化
  235.     $game_temp.in_battle = true
  236.     $game_temp.battle_turn = 0
  237.     $game_temp.battle_event_flags.clear
  238.     $game_temp.battle_abort = false
  239.     $game_temp.battle_main_phase = false
  240.     $game_temp.battleback_name = $game_map.battleback_name
  241.     $game_temp.forcing_battler = nil
  242.     # バトルイベント用インタプリタを初期化
  243.     $game_system.battle_interpreter.setup(nil, 0)
  244.     # トループを準備
  245.     @troop_id = $game_temp.battle_troop_id
  246.     $game_troop.setup(@troop_id)
  247.     atb_setup
  248.     # アクターコマンドウィンドウを作成
  249.     s1 = $data_system.words.attack
  250.     s2 = $data_system.words.skill
  251.     s3 = $data_system.words.guard
  252.     s4 = $data_system.words.item
  253.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
  254.     @actor_command_window.y = 160
  255.     @actor_command_window.back_opacity = 160
  256.     @actor_command_window.active = false
  257.     @actor_command_window.visible = false
  258.     # その他のウィンドウを作成
  259.     @party_command_window = Window_PartyCommand.new
  260.     @party_command_window.opacity = 0
  261.     @party_command_window.z = 301
  262.     @help_window = Window_Help.new
  263.     @help_window.opacity = 0
  264.     @help_window.z = 301
  265.     @help_window.visible = false
  266.     @status_window = Window_BattleStatus.new
  267.     @status_window.opacity = 0
  268.     @message_window = Window_Message.new
  269.     @back1 = Sprite.new
  270.     @back1.bitmap = RPG::Cache.batsys("help")
  271.     @back1.z = 300
  272.     #================
  273.     @back2 = Sprite.new
  274.     @back2.bitmap = RPG::Cache.batsys("status")
  275.     @back2.z = 1
  276.     #===============
  277.     @wheel = Sprite.new
  278.     @wheel.bitmap = RPG::Cache.picture("wheel1")
  279.     @wheel.ox = @wheel.bitmap.width/2
  280.     @wheel.oy = @wheel.bitmap.height/2
  281.     @wheel.x = 640
  282.     @wheel.y = 510
  283.     @wheel.z = 2
  284.     # スプライトセットを作成
  285.     @spriteset = Spriteset_Battle.new
  286.     # ウェイトカウントを初期化
  287.     @wait_count = 0
  288.     # トランジション実行
  289.     if $data_system.battle_transition == ""
  290.       Graphics.transition(20)
  291.     else
  292.       Graphics.transition(40, "Graphics/Transitions/" +
  293.         $data_system.battle_transition)
  294.     end
  295.     # プレバトルフェーズ開始
  296.     start_phase1
  297.     # メインループ
  298.     loop do
  299.       # ゲーム画面を更新
  300.       Graphics.update
  301.       # 入力情報を更新
  302.       Input.update
  303.       # フレーム更新
  304.       update
  305.       # 画面が切り替わったらループを中断
  306.       if $scene != self
  307.         break
  308.       end
  309.     end
  310.     # マップをリフレッシュ
  311.     $game_map.refresh
  312.     # トランジション準備
  313.     Graphics.freeze
  314.     # ウィンドウを解放
  315.     @actor_command_window.dispose
  316.     @party_command_window.dispose
  317.     @help_window.dispose
  318.     @status_window.dispose
  319.     @message_window.dispose
  320.     if @skill_window != nil
  321.       @skill_window.dispose
  322.     end
  323.     if @item_window != nil
  324.       @item_window.dispose
  325.     end
  326.     if @result_window != nil
  327.       @result_window.dispose
  328.     end
  329.     # スプライトセットを解放
  330.     @spriteset.dispose
  331.     # タイトル画面に切り替え中の場合
  332.     if $scene.is_a?(Scene_Title)
  333.       # 画面をフェードアウト
  334.       Graphics.transition
  335.       Graphics.freeze
  336.     end
  337.     # 戦闘テストからゲームオーバー画面以外に切り替え中の場合
  338.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  339.       $scene = nil
  340.     end
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # ● 勝敗判定
  344.   #--------------------------------------------------------------------------
  345.   def judge
  346.     # 全滅判定が真、またはパーティ人数が 0 人の場合
  347.     if $game_party.all_dead? or $game_party.actors.size == 0
  348.       # 敗北可能の場合
  349.       if $game_temp.battle_can_lose
  350.         # バトル開始前の BGM に戻す
  351.         $game_system.bgm_play($game_temp.map_bgm)
  352.         # バトル終了
  353.         battle_end(2)
  354.         # true を返す
  355.         return true
  356.       end
  357.       # ゲームオーバーフラグをセット
  358.       $game_temp.gameover = true
  359.       # true を返す
  360.       return true
  361.     end
  362.     # エネミーが 1 体でも存在すれば false を返す
  363.     for enemy in $game_troop.enemies
  364.       if enemy.exist?
  365.         return false
  366.       end
  367.     end
  368.     # アフターバトルフェーズ開始 (勝利)
  369.     start_phase5
  370.     # true を返す
  371.     return true
  372.   end
  373.   #--------------------------------------------------------------------------
  374.   # ● フレーム更新
  375.   #--------------------------------------------------------------------------
  376.   def update
  377.     # バトルイベント実行中の場合
  378.     if $game_system.battle_interpreter.running?
  379.       if @command.size > 0
  380.         @command_a = false
  381.         @command = []
  382.         command_delete
  383.       end
  384.       @status_window.at_refresh
  385.       # インタプリタを更新
  386.       $game_system.battle_interpreter.update
  387.       # アクションを強制されているバトラーが存在しない場合
  388.       if $game_temp.forcing_battler == nil
  389.         # バトルイベントの実行が終わった場合
  390.         unless $game_system.battle_interpreter.running?
  391.           # バトルイベントのセットアップを再実行
  392.           @status_window.refresh
  393.           setup_battle_event
  394.         end
  395.       end
  396.     end
  397.     # システム (タイマー)、画面を更新
  398.     $game_system.update
  399.     $game_screen.update
  400.     # タイマーが 0 になった場合
  401.     if $game_system.timer_working and $game_system.timer == 0
  402.       # バトル中断
  403.       $game_temp.battle_abort = true
  404.     end
  405.     # ウィンドウを更新
  406.     @help_window.update
  407.     @party_command_window.update
  408.     @actor_command_window.update
  409.     @status_window.update
  410.     @message_window.update
  411.     # スプライトセットを更新
  412.     @spriteset.update
  413.     # トランジション処理中の場合
  414.     if $game_temp.transition_processing
  415.       # トランジション処理中フラグをクリア
  416.       $game_temp.transition_processing = false
  417.       # トランジション実行
  418.       if $game_temp.transition_name == ""
  419.         Graphics.transition(20)
  420.       else
  421.         Graphics.transition(40, "Graphics/Transitions/" +
  422.           $game_temp.transition_name)
  423.       end
  424.     end
  425.     # メッセージウィンドウ表示中の場合
  426.     if $game_temp.message_window_showing
  427.       return
  428.     end
  429.     # ゲームオーバーの場合
  430.     if $game_temp.gameover
  431.       # ゲームオーバー画面に切り替え
  432.       $scene = Scene_Gameover.new
  433.       return
  434.     end
  435.     # タイトル画面に戻す場合
  436.     if $game_temp.to_title
  437.       # タイトル画面に切り替え
  438.       $scene = Scene_Title.new
  439.       return
  440.     end
  441.     # バトル中断の場合
  442.     if $game_temp.battle_abort
  443.       # バトル開始前の BGM に戻す
  444.       $game_system.bgm_play($game_temp.map_bgm)
  445.       # バトル終了
  446.       battle_end(1)
  447.       return
  448.     end
  449.     # ヘルプウィンドウ表示中の場合
  450.     if @help_wait > 0
  451.       @help_wait -= 1
  452.       if @help_wait == 0
  453.         # ヘルプウィンドウを隠す
  454.         @help_window.visible = false
  455.       end
  456.     end
  457.     # アクションを強制されているバトラーが存在せず、
  458.     # かつバトルイベントが実行中の場合
  459.     if $game_temp.forcing_battler == nil and
  460.        $game_system.battle_interpreter.running?
  461.       return
  462.     end
  463.     # フェーズによって分岐
  464.     case @phase
  465.     when 0  # ATゲージ更新フェーズ
  466.       if anime_wait_return
  467.         @wheel.angle += 1
  468.         update_phase0
  469.       end
  470.     when 1  # プレバトルフェーズ
  471.       update_phase1
  472.       return
  473.     when 2  # パーティコマンドフェーズ
  474.       update_phase2
  475.       return
  476.     when 5  # アフターバトルフェーズ
  477.       update_phase5
  478.       return
  479.     end
  480.     if $scene != self
  481.       return
  482.     end
  483.     if @phase == 0
  484.       if @command.size != 0  # アクターコマンドフェーズ
  485.         if @command_a == false
  486.           start_phase3
  487.         end
  488.         update_phase3
  489.       end
  490.       # ウェイト中の場合
  491.       if @wait_count > 0
  492.         # ウェイトカウントを減らす
  493.         @wait_count -= 1
  494.         return
  495.       end
  496.       update_phase4
  497.     end
  498.   end
  499.  
  500. #==============================================================================
  501. # ■ Scene_Battle (分割定義 2)
  502. #------------------------------------------------------------------------------
  503. #  バトル画面の処理を行うクラスです。
  504. #==============================================================================
  505.  
  506.   #--------------------------------------------------------------------------
  507.   # ● フレーム更新 (ATゲージ更新フェーズ)
  508.   #--------------------------------------------------------------------------
  509.   def update_phase0
  510.     if $game_temp.battle_turn == 0
  511.       $game_temp.battle_turn = 1
  512.     end
  513.     # B ボタンが押された場合
  514.     if @command_a == false and @party == false
  515.       if Input.trigger?(Input::B)
  516.         # キャンセル SE を演奏
  517.         $game_system.se_play($data_system.cancel_se)
  518.         @party = true
  519.       end
  520.     end
  521.     if @party == true and
  522.         ((@action > 0 and @action_battlers.empty?) or (@action == 0 and
  523.         (@action_battlers.empty? or @action_battlers[0].phase == 1)))
  524.       # パーティコマンドフェーズへ
  525.       start_phase2
  526.       return
  527.     end
  528.     # ATゲージ増加処理
  529.     cnt = 0
  530.     for battler in $game_party.actors + $game_troop.enemies
  531.       active?(battler)
  532.       if battler.rtp == 0
  533.         if battler.at >= @max
  534.           if battler.is_a?(Game_Actor)
  535.             if battler.inputable?
  536.               unless @action_battlers.include?(battler) or
  537.                   @command.include?(battler) or @escape == true
  538.                 if battler.current_action.forcing
  539.                   fullat_se
  540.                   force_action(battler)
  541.                   action_start(battler)
  542.                 else
  543.                   fullat_se
  544.                   @command.push(battler)
  545.                 end
  546.               end
  547.             else
  548.               unless @action_battlers.include?(battler) or
  549.                       battler == @command[0]
  550.                 battler.current_action.clear
  551.                 if @command.include?(battler)
  552.                   @command.delete(battler)
  553.                 else
  554.                   if battler.movable?
  555.                     fullat_se
  556.                   end
  557.                 end
  558.                 action_start(battler)
  559.               end
  560.             end
  561.           else
  562.             unless @action_battlers.include?(battler)
  563.               if battler.current_action.forcing
  564.                 force_action(battler)
  565.                 action_start(battler)
  566.               else
  567.                 if @enemy_speed != 0
  568.                   if rand(@enemy_speed) == 0
  569.                     number = cnt - $game_party.actors.size
  570.                     enemy_action(number)
  571.                   end
  572.                 else
  573.                   number = cnt - $game_party.actors.size
  574.                   enemy_action(number)
  575.                 end
  576.               end
  577.             end
  578.           end
  579.         else
  580.           battler.at += battler.agi
  581.           if battler.guarding?
  582.             battler.at += battler.agi
  583.           end
  584.           if battler.movable?
  585.             battler.atp = 100 * battler.at / @max
  586.           end
  587.         end
  588.       else
  589.         if battler.rt >= battler.rtp
  590.           speller = synthe?(battler)
  591.           if speller != nil
  592.             battler = speller[0]
  593.           end
  594.           unless @action_battlers.include?(battler)
  595.             if battler.is_a?(Game_Actor)
  596.               fullat_se
  597.             end
  598.             battler.rt = battler.rtp
  599.             action_start(battler)
  600.           end
  601.         else
  602.           battler.rt += battler.agi
  603.           speller = synthe?(battler)
  604.           if speller != nil
  605.             for spell in speller
  606.               if spell != battler
  607.                 spell.rt += battler.agi
  608.               end
  609.             end
  610.           end
  611.         end
  612.       end
  613.       cnt += 1
  614.     end
  615.     # ATゲージをリフレッシュ
  616.     @status_window.at_refresh
  617.     # 逃走処理
  618.     if @escape == true and
  619.         ((@action > 0 and @action_battlers.empty?) or (@action == 0 and
  620.         (@action_battlers.empty? or @action_battlers[0].phase == 1)))
  621.       temp = false
  622.       for battler in $game_party.actors
  623.         if battler.inputable?
  624.           temp = true
  625.         end
  626.       end
  627.       if temp == true
  628.         for battler in $game_party.actors
  629.           if battler.at < @max and battler.inputable?
  630.             temp = false
  631.             break
  632.           end
  633.         end
  634.         if temp == true
  635.           @escape = false
  636.           for battler in $game_party.actors
  637.             battler.at %= @max
  638.           end
  639.           $game_temp.battle_main_phase = false
  640.           update_phase2_escape
  641.         end
  642.       end
  643.     end
  644.   end
  645.   #--------------------------------------------------------------------------
  646.   # ● パーティコマンドフェーズ開始
  647.   #--------------------------------------------------------------------------
  648.   def start_phase2
  649.     # フェーズ 2 に移行
  650.     @phase = 2
  651.     @party = false
  652.     # パーティコマンドウィンドウを有効化
  653.     @party_command_window.active = true
  654.     @party_command_window.visible = true
  655.     # アクターを非選択状態に設定
  656.     @actor_index = -1
  657.     # アクターコマンドウィンドウを無効化
  658.     @actor_command_window.active = false
  659.     @actor_command_window.visible = false
  660.     if @command.size != 0
  661.       # アクターの明滅エフェクト OFF
  662.       if @active_actor != nil
  663.         @active_actor.blink = false
  664.       end
  665.     end
  666.     # カメラセット
  667.     @camera == "party"
  668.     @spriteset.screen_target(0, 0, 1)
  669.     # メインフェーズフラグをクリア
  670.     $game_temp.battle_main_phase = false
  671.   end
  672.   #--------------------------------------------------------------------------
  673.   # ● フレーム更新 (パーティコマンドフェーズ)
  674.   #--------------------------------------------------------------------------
  675.   def update_phase2
  676.     # C ボタンが押された場合
  677.     if Input.trigger?(Input::C)
  678.       # パーティコマンドウィンドウのカーソル位置で分岐
  679.       case @party_command_window.index
  680.       when 0  # 戦う
  681.         # パーティコマンドウィンドウを無効化
  682.         @party_command_window.active = false
  683.         @party_command_window.visible = false
  684.         # 決定 SE を演奏
  685.         $game_system.se_play($data_system.decision_se)
  686.         @escape = false
  687.         @phase = 0
  688.         if $game_temp.battle_turn == 0
  689.           $game_temp.battle_turn = 1
  690.         end
  691.         if @command_a == true
  692.           # アクターコマンドフェーズ開始
  693.           start_phase3
  694.         else
  695.           $game_temp.battle_main_phase = true
  696.         end
  697.       when 1  # 逃げる
  698.         # 逃走可能ではない場合
  699.         if $game_temp.battle_can_escape == false
  700.           # ブザー SE を演奏
  701.           $game_system.se_play($data_system.buzzer_se)
  702.           return
  703.         end
  704.         # 決定 SE を演奏
  705.         $game_system.se_play($data_system.decision_se)
  706.         @phase = 0
  707.         # パーティコマンドウィンドウを無効化
  708.         @party_command_window.active = false
  709.         @party_command_window.visible = false
  710.         $game_temp.battle_main_phase = true
  711.         if $game_temp.battle_turn == 0
  712.           update_phase2_escape
  713.           $game_temp.battle_turn = 1
  714.           for battler in $game_party.actors
  715.             battler.at -= @max / 2
  716.           end
  717.           return
  718.         end
  719.         # 決定 SE を演奏
  720.         $game_system.se_play($data_system.decision_se)
  721.         @escape = true
  722.         for battler in $game_party.actors
  723.           @command_a = false
  724.           @command.delete(battler)
  725.           @action_battlers.delete(battler)
  726.           skill_reset(battler)
  727.         end
  728.       end
  729.       return
  730.     end
  731.   end
  732.   #--------------------------------------------------------------------------
  733.   # ● フレーム更新 (パーティコマンドフェーズ : 逃げる)
  734.   #--------------------------------------------------------------------------
  735.   def update_phase2_escape
  736.     # エネミーの素早さ平均値を計算
  737.     enemies_agi = 0
  738.     enemies_number = 0
  739.     for enemy in $game_troop.enemies
  740.       if enemy.exist?
  741.         enemies_agi += enemy.agi
  742.         enemies_number += 1
  743.       end
  744.     end
  745.     if enemies_number > 0
  746.       enemies_agi /= enemies_number
  747.     end
  748.     # アクターの素早さ平均値を計算
  749.     actors_agi = 0
  750.     actors_number = 0
  751.     for actor in $game_party.actors
  752.       if actor.exist?
  753.         actors_agi += actor.agi
  754.         actors_number += 1
  755.       end
  756.     end
  757.     if actors_number > 0
  758.       actors_agi /= actors_number
  759.     end
  760.     # 逃走成功判定
  761.     success = rand(100) < 50 * actors_agi / enemies_agi
  762.     # 逃走成功の場合
  763.     if success
  764.       # 逃走 SE を演奏
  765.       $game_system.se_play($data_system.escape_se)
  766.       # バトル開始前の BGM に戻す
  767.       $game_system.bgm_play($game_temp.map_bgm)
  768.       # バトル終了
  769.       battle_end(1)
  770.     # 逃走失敗の場合
  771.     else
  772.       @help_window.set_text("逃走失敗", 1)
  773.       @help_wait = @help_time
  774.       # パーティ全員のアクションをクリア
  775.       $game_party.clear_actions
  776.       # メインフェーズ開始
  777.       start_phase4
  778.     end
  779.   end
  780.   #--------------------------------------------------------------------------
  781.   # ● アフターバトルフェーズ開始
  782.   #--------------------------------------------------------------------------
  783.   def start_phase5
  784.     # フェーズ 5 に移行
  785.     @phase = 5
  786.     # バトル終了 ME を演奏
  787.     $game_system.me_play($game_system.battle_end_me)
  788.     # バトル開始前の BGM に戻す
  789.     $game_system.bgm_play($game_temp.map_bgm)
  790.     # EXP、ゴールド、トレジャーを初期化
  791.     exp = 0
  792.     gold = 0
  793.     treasures = []
  794.     if @active_actor != nil
  795.       @active_actor.blink = false
  796.     end
  797.     # メインフェーズフラグをセット
  798.     $game_temp.battle_main_phase = true
  799.     # パーティコマンドウィンドウを無効化
  800.     @party_command_window.active = false
  801.     @party_command_window.visible = false
  802.     # アクターコマンドウィンドウを無効化
  803.     @actor_command_window.active = false
  804.     @actor_command_window.visible = false
  805.     if @skill_window != nil
  806.       # スキルウィンドウを解放
  807.       @skill_window.dispose
  808.       @skill_window = nil
  809.     end
  810.     if @item_window != nil
  811.       # アイテムウィンドウを解放
  812.       @item_window.dispose
  813.       @item_window = nil
  814.     end
  815.     # ヘルプウィンドウを隠す
  816.     @help_window.visible = false if @help_wait == 0
  817.     # ループ
  818.     for enemy in $game_troop.enemies
  819.       # エネミーが隠れ状態でない場合
  820.       unless enemy.hidden
  821.         # 獲得 EXP、ゴールドを追加
  822.         exp += enemy.exp
  823.         gold += enemy.gold
  824.         # トレジャー出現判定
  825.         if rand(100) < enemy.treasure_prob
  826.           if enemy.item_id > 0
  827.             treasures.push($data_items[enemy.item_id])
  828.           end
  829.           if enemy.weapon_id > 0
  830.             treasures.push($data_weapons[enemy.weapon_id])
  831.           end
  832.           if enemy.armor_id > 0
  833.             treasures.push($data_armors[enemy.armor_id])
  834.           end
  835.         end
  836.       end
  837.     end
  838.     # トレジャーの数を 6 個までに限定
  839.     treasures = treasures[0..5]
  840.     # EXP 獲得
  841.     for i in 0...$game_party.actors.size
  842.       actor = $game_party.actors[i]
  843.       if actor.cant_get_exp? == false
  844.         last_level = actor.level
  845.         actor.exp += exp
  846.         if actor.level > last_level
  847.           @status_window.level_up(i)
  848.           actor.damage[[actor, -1]] = "Level up!"
  849.           actor.up_level = actor.level - last_level
  850.         end
  851.       end
  852.     end
  853.     # ゴールド獲得
  854.     $game_party.gain_gold(gold)
  855.     # トレジャー獲得
  856.     for item in treasures
  857.       case item
  858.       when RPG::Item
  859.         $game_party.gain_item(item.id, 1)
  860.       when RPG::Weapon
  861.         $game_party.gain_weapon(item.id, 1)
  862.       when RPG::Armor
  863.         $game_party.gain_armor(item.id, 1)
  864.       end
  865.     end
  866.     # バトルリザルトウィンドウを作成
  867.     @result_window = Window_BattleResult.new(exp, gold, treasures)
  868.     # ウェイトカウントを設定
  869.     @phase5_wait_count = 100
  870.   end
  871.   #--------------------------------------------------------------------------
  872.   # ● フレーム更新 (アフターバトルフェーズ)
  873.   #--------------------------------------------------------------------------
  874.   def update_phase5
  875.     # ウェイトカウントが 0 より大きい場合
  876.     if @phase5_wait_count > 0
  877.       # ウェイトカウントを減らす
  878.       @phase5_wait_count -= 1
  879.       # ウェイトカウントが 0 になった場合
  880.       if @phase5_wait_count == 0
  881.         # リザルトウィンドウを表示
  882.         @result_window.visible = true
  883.         # メインフェーズフラグをクリア
  884.         $game_temp.battle_main_phase = false
  885.         # ステータスウィンドウをリフレッシュ
  886.         @status_window.refresh
  887.         for actor in $game_party.actors
  888.           if actor.damage.include?([actor, 0])
  889.             @phase5_wait_count = 20
  890.             actor.damage_pop[[actor, 0]] = true
  891.           end
  892.           if actor.damage.include?([actor, -1])
  893.             @phase5_wait_count = 20
  894.             actor.damage_pop[[actor, -1]] = true
  895.             for level in actor.level - actor.up_level + 1..actor.level
  896.               for skill in $data_classes[actor.class_id].learnings
  897.                 if level == skill.level and not actor.skill_learn?(skill.id)
  898.                   actor.damage[[actor, 0]] = "New Skill!"
  899.                   break
  900.                 end
  901.               end
  902.             end
  903.           end
  904.         end
  905.       end
  906.       return
  907.     end
  908.     # C ボタンが押された場合
  909.     if Input.trigger?(Input::C)
  910.       # バトル終了
  911.       battle_end(0)
  912.     end
  913.   end
  914.  
  915. #==============================================================================
  916. # ■ Scene_Battle (分割定義 3)
  917. #------------------------------------------------------------------------------
  918. #  バトル画面の処理を行うクラスです。
  919. #==============================================================================
  920.  
  921.   #--------------------------------------------------------------------------
  922.   # ● アクターコマンドフェーズ開始
  923.   #--------------------------------------------------------------------------
  924.   def start_phase3
  925.     if victory?
  926.       return
  927.     end
  928.     # メインフェーズフラグをクリア
  929.     $game_temp.battle_main_phase = false
  930.     @command_a = true
  931.     @active_actor = @command[0]
  932.     cnt = 0
  933.     for actor in $game_party.actors
  934.       if actor == @active_actor
  935.         @actor_index = cnt
  936.       end
  937.       cnt += 1
  938.     end
  939.     @active_actor.blink = true
  940.     unless @active_actor.inputable?
  941.       @active_actor.current_action.clear
  942.       phase3_next_actor
  943.       return
  944.     end
  945.     phase3_setup_command_window
  946.     # カメラの設定
  947.     @camera = "command"
  948.     plus = ($game_party.actors.size - 1) / 2.0 - @actor_index
  949.     y = [(plus.abs - 1.5) * 10 , 0].min
  950.     @spriteset.screen_target(plus * 50, y, 1.0 + y * 0.002)
  951.   end
  952.   #--------------------------------------------------------------------------
  953.   # ● アクターのコマンド入力終了
  954.   #--------------------------------------------------------------------------
  955.   def phase3_next_actor
  956.     @command.shift
  957.     @command_a = false
  958.     # メインフェーズフラグをセット
  959.     $game_temp.battle_main_phase = true
  960.     # アクターコマンドウィンドウを無効化
  961.     @actor_command_window.active = false
  962.     @actor_command_window.visible = false
  963.     # アクターの明滅エフェクト OFF
  964.     if @active_actor != nil
  965.       @active_actor.blink = false
  966.     end
  967.     action_start(@active_actor)
  968.     # カメラを元に戻す
  969.     if @camera == "command"
  970.       @spriteset.screen_target(0, 0, 1)
  971.     end
  972.     return
  973.   end
  974.   #--------------------------------------------------------------------------
  975.   # ● アクターコマンドウィンドウのセットアップ
  976.   #--------------------------------------------------------------------------
  977.   def phase3_setup_command_window
  978.     # パーティコマンドウィンドウを無効化
  979.     @party_command_window.active = false
  980.     @party_command_window.visible = false
  981.     # アクターコマンドウィンドウを有効化
  982.     @actor_command_window.active = true
  983.     @actor_command_window.visible = true
  984.     # アクターコマンドウィンドウの位置を設定
  985.     @actor_command_window.x = @actor_index * 160 +
  986.                               (4 - $game_party.actors.size) * 80
  987.     # インデックスを 0 に設定
  988.     @actor_command_window.index = 0
  989.   end
  990.   #--------------------------------------------------------------------------
  991.   # ● エネミーアクション作成
  992.   #--------------------------------------------------------------------------
  993.   def enemy_action(number)
  994.     enemy = $game_troop.enemies[number]
  995.     unless enemy.current_action.forcing
  996.       enemy.make_action
  997.     end
  998.     action_start(enemy)
  999.   end
  1000.   #--------------------------------------------------------------------------
  1001.   # ● フレーム更新 (アクターコマンドフェーズ)
  1002.   #--------------------------------------------------------------------------
  1003.   def update_phase3
  1004.     if victory? and @command_a
  1005.       command_delete
  1006.       @command.push(@active_actor)
  1007.       return
  1008.     end
  1009.     # エネミーアローが有効の場合
  1010.     if @enemy_arrow != nil
  1011.       update_phase3_enemy_select
  1012.     # アクターアローが有効の場合
  1013.     elsif @actor_arrow != nil
  1014.       update_phase3_actor_select
  1015.     # スキルウィンドウが有効の場合
  1016.     elsif @skill_window != nil
  1017.       update_phase3_skill_select
  1018.     # アイテムウィンドウが有効の場合
  1019.     elsif @item_window != nil
  1020.       update_phase3_item_select
  1021.     # アクターコマンドウィンドウが有効の場合
  1022.     elsif @actor_command_window.active
  1023.       update_phase3_basic_command
  1024.     end
  1025.   end
  1026.   #--------------------------------------------------------------------------
  1027.   # ● フレーム更新 (アクターコマンドフェーズ : 基本コマンド)
  1028.   #--------------------------------------------------------------------------
  1029.   def update_phase3_basic_command
  1030.     unless @active_actor.inputable?
  1031.       @active_actor.current_action.clear
  1032.       phase3_next_actor
  1033.       return
  1034.     end
  1035.     # B ボタンが押された場合
  1036.     if Input.trigger?(Input::B) and @party == false
  1037.       # キャンセル SE を演奏
  1038.       $game_system.se_play($data_system.cancel_se)
  1039.       @party = true
  1040.     end
  1041.     if @party == true and
  1042.         ((@action > 0 and @action_battlers.empty?) or (@action == 0 and
  1043.         (@action_battlers.empty? or @action_battlers[0].phase == 1)))
  1044.       # パーティコマンドフェーズへ
  1045.       start_phase2
  1046.       return
  1047.     end
  1048.     # C ボタンが押された場合
  1049.     if Input.trigger?(Input::C)
  1050.       @party = false
  1051.       # アクターコマンドウィンドウのカーソル位置で分岐
  1052.       case @actor_command_window.index
  1053.       when 0  # 攻撃
  1054.         # 決定 SE を演奏
  1055.         $game_system.se_play($data_system.decision_se)
  1056.         # エネミーの選択を開始
  1057.         start_enemy_select
  1058.       when 1  # スキル
  1059.         # 決定 SE を演奏
  1060.         $game_system.se_play($data_system.decision_se)
  1061.         # スキルの選択を開始
  1062.         start_skill_select
  1063.       when 2  # 防御
  1064.         # 決定 SE を演奏
  1065.         $game_system.se_play($data_system.decision_se)
  1066.         # アクションを設定
  1067.         @active_actor.current_action.kind = 0
  1068.         @active_actor.current_action.basic = 1
  1069.         # 次のアクターのコマンド入力へ
  1070.         phase3_next_actor
  1071.       when 3  # アイテム
  1072.         # 決定 SE を演奏
  1073.         $game_system.se_play($data_system.decision_se)
  1074.         # アイテムの選択を開始
  1075.         start_item_select
  1076.       end
  1077.       return
  1078.     end
  1079.     # キャラチェンジ
  1080.     if @command.size > 1
  1081.       # R ボタンが押された場合
  1082.       if Input.trigger?(Input::R)
  1083.         $game_system.se_play($data_system.cursor_se)
  1084.         @party = false
  1085.         # アクターの明滅エフェクト OFF
  1086.         if @active_actor != nil
  1087.           @active_actor.blink = false
  1088.         end
  1089.         @command.push(@command[0])
  1090.         @command.shift
  1091.         @command_a = false
  1092.         # 新たなコマンドウィンドウの立ち上げ
  1093.         start_phase3
  1094.       end
  1095.       # L ボタンが押された場合
  1096.       if Input.trigger?(Input::L)
  1097.         $game_system.se_play($data_system.cursor_se)
  1098.         @party = false
  1099.         # アクターの明滅エフェクト OFF
  1100.         if @active_actor != nil
  1101.           @active_actor.blink = false
  1102.         end
  1103.         @command.unshift(@command[@command.size - 1])
  1104.         @command.delete_at(@command.size - 1)
  1105.         @command_a = false
  1106.         # 新たなコマンドウィンドウの立ち上げ
  1107.         start_phase3
  1108.       end
  1109.       # 右 ボタンが押された場合
  1110.       if Input.trigger?(Input::RIGHT)
  1111.         $game_system.se_play($data_system.cursor_se)
  1112.         @party = false
  1113.         # アクターの明滅エフェクト OFF
  1114.         if @active_actor != nil
  1115.           @active_actor.blink = false
  1116.         end
  1117.         actor = $game_party.actors[@actor_index]
  1118.         while actor == @command[0] or (not @command.include?(actor))
  1119.           @actor_index += 1
  1120.           @actor_index %= $game_party.actors.size
  1121.           actor = $game_party.actors[@actor_index]
  1122.           if actor == @command[0]
  1123.             break
  1124.           end
  1125.         end
  1126.         while actor != @command[0]
  1127.           @command.push(@command.shift)
  1128.         end
  1129.         @command_a = false
  1130.         # 新たなコマンドウィンドウの立ち上げ
  1131.         start_phase3
  1132.       end
  1133.       # 左 ボタンが押された場合
  1134.       if Input.trigger?(Input::LEFT)
  1135.         $game_system.se_play($data_system.cursor_se)
  1136.         @party = false
  1137.         # アクターの明滅エフェクト OFF
  1138.         if @active_actor != nil
  1139.           @active_actor.blink = false
  1140.         end
  1141.         actor = $game_party.actors[@actor_index]
  1142.         while actor == @command[0] or (not @command.include?(actor))
  1143.           @actor_index -= 1
  1144.           @actor_index %= $game_party.actors.size
  1145.           actor = $game_party.actors[@actor_index]
  1146.           if actor == @command[0]
  1147.             break
  1148.           end
  1149.         end
  1150.         while actor != @command[0]
  1151.           @command.push(@command.shift)
  1152.         end
  1153.         @command_a = false
  1154.         # 新たなコマンドウィンドウの立ち上げ
  1155.         start_phase3
  1156.       end
  1157.     end
  1158.   end
  1159.   #--------------------------------------------------------------------------
  1160.   # ● フレーム更新 (アクターコマンドフェーズ : スキル選択)
  1161.   #--------------------------------------------------------------------------
  1162.   def update_phase3_skill_select
  1163.     # コマンド選択中に行動不能になった場合
  1164.     unless @active_actor.inputable?
  1165.       @active_actor.current_action.clear
  1166.       command_delete
  1167.       # 次のアクターのコマンド入力へ
  1168.       phase3_next_actor
  1169.       return
  1170.     end
  1171.     # スキルウィンドウを可視状態にする
  1172.     @skill_window.visible = true
  1173.     # スキルウィンドウを更新
  1174.     @skill_window.update
  1175.     # B ボタンが押された場合
  1176.     if Input.trigger?(Input::B)
  1177.       # キャンセル SE を演奏
  1178.       $game_system.se_play($data_system.cancel_se)
  1179.       # スキルの選択を終了
  1180.       end_skill_select
  1181.       return
  1182.     end
  1183.     # C ボタンが押された場合
  1184.     if Input.trigger?(Input::C)
  1185.       # スキルウィンドウで現在選択されているデータを取得
  1186.       @skill = @skill_window.skill
  1187.       # 使用できない場合
  1188.       if @skill == nil or not @active_actor.skill_can_use?(@skill.id)
  1189.         # ブザー SE を演奏
  1190.         $game_system.se_play($data_system.buzzer_se)
  1191.         return
  1192.       end
  1193.       # 決定 SE を演奏
  1194.       $game_system.se_play($data_system.decision_se)
  1195.       # アクションを設定
  1196.       @active_actor.current_action.skill_id = @skill.id
  1197.       # スキルウィンドウを不可視状態にする
  1198.       @skill_window.visible = false
  1199.       # 効果範囲が敵単体の場合
  1200.       if @skill.scope == 1
  1201.         # エネミーの選択を開始
  1202.         start_enemy_select
  1203.       # 効果範囲が味方単体の場合
  1204.       elsif @skill.scope == 3 or @skill.scope == 5
  1205.         # アクターの選択を開始
  1206.         start_actor_select
  1207.       # 効果範囲が単体ではない場合
  1208.       else
  1209.         # アクションを設定
  1210.         @active_actor.current_action.kind = 1
  1211.         # スキルの選択を終了
  1212.         end_skill_select
  1213.         # 次のアクターのコマンド入力へ
  1214.         phase3_next_actor
  1215.       end
  1216.       return
  1217.     end
  1218.   end
  1219.   #--------------------------------------------------------------------------
  1220.   # ● フレーム更新 (アクターコマンドフェーズ : アイテム選択)
  1221.   #--------------------------------------------------------------------------
  1222.   def update_phase3_item_select
  1223.     # コマンド選択中に行動不能になった場合
  1224.     unless @active_actor.inputable?
  1225.       @active_actor.current_action.clear
  1226.       command_delete
  1227.       # 次のアクターのコマンド入力へ
  1228.       phase3_next_actor
  1229.       return
  1230.     end
  1231.     # アイテムウィンドウを可視状態にする
  1232.     @item_window.visible = true
  1233.     # アイテムウィンドウを更新
  1234.     @item_window.update
  1235.     # B ボタンが押された場合
  1236.     if Input.trigger?(Input::B)
  1237.       # キャンセル SE を演奏
  1238.       $game_system.se_play($data_system.cancel_se)
  1239.       # アイテムの選択を終了
  1240.       end_item_select
  1241.       return
  1242.     end
  1243.     # C ボタンが押された場合
  1244.     if Input.trigger?(Input::C)
  1245.       # アイテムウィンドウで現在選択されているデータを取得
  1246.       @item = @item_window.item
  1247.       # 使用できない場合
  1248.       unless $game_party.item_can_use?(@item.id)
  1249.         # ブザー SE を演奏
  1250.         $game_system.se_play($data_system.buzzer_se)
  1251.         return
  1252.       end
  1253.       # 決定 SE を演奏
  1254.       $game_system.se_play($data_system.decision_se)
  1255.       # アクションを設定
  1256.       @active_actor.current_action.item_id = @item.id
  1257.       # アイテムウィンドウを不可視状態にする
  1258.       @item_window.visible = false
  1259.       # 効果範囲が敵単体の場合
  1260.       if @item.scope == 1
  1261.         # エネミーの選択を開始
  1262.         start_enemy_select
  1263.       # 効果範囲が味方単体の場合
  1264.       elsif @item.scope == 3 or @item.scope == 5
  1265.         # アクターの選択を開始
  1266.         start_actor_select
  1267.       # 効果範囲が単体ではない場合
  1268.       else
  1269.         # アクションを設定
  1270.         @active_actor.current_action.kind = 2
  1271.         # アイテムの選択を終了
  1272.         end_item_select
  1273.         # 次のアクターのコマンド入力へ
  1274.         phase3_next_actor
  1275.       end
  1276.       return
  1277.     end
  1278.   end
  1279.   #--------------------------------------------------------------------------
  1280.   # ● フレーム更新 (アクターコマンドフェーズ : エネミー選択)
  1281.   #--------------------------------------------------------------------------
  1282.   def update_phase3_enemy_select
  1283.     # コマンド選択中に行動不能になった場合
  1284.     unless @active_actor.inputable?
  1285.       # カメラを元に戻す
  1286.       if @camera == "select"
  1287.         @spriteset.screen_target(0, 0, 1)
  1288.       end
  1289.       @active_actor.current_action.clear
  1290.       command_delete
  1291.       # 次のアクターのコマンド入力へ
  1292.       phase3_next_actor
  1293.       return
  1294.     end
  1295.     # エネミーアローを更新
  1296.     @enemy_arrow.update
  1297.     # B ボタンが押された場合
  1298.     if Input.trigger?(Input::B)
  1299.       # キャンセル SE を演奏
  1300.       $game_system.se_play($data_system.cancel_se)
  1301.       # カメラを元に戻す
  1302.       if @camera == "select"
  1303.         # カメラの設定
  1304.         @camera = "command"
  1305.         plus = ($game_party.actors.size - 1) / 2.0 - @actor_index
  1306.         y = [(plus.abs - 1.5) * 10 , 0].min
  1307.         @spriteset.screen_target(plus * 50, y, 1.0 + y * 0.002)
  1308.       end
  1309.       # スキルウィンドウ表示中の場合
  1310.       if @skill_window != nil
  1311.         # アクションを再設定
  1312.         @active_actor.current_action.kind = 1
  1313.         # スキルの選択を終了
  1314.         end_skill_select
  1315.       end
  1316.       # アイテムウィンドウ表示中の場合
  1317.       if @item_window != nil
  1318.         # アクションを再設定
  1319.         @active_actor.current_action.kind = 2
  1320.         # アイテムの選択を終了
  1321.         end_item_select
  1322.       end
  1323.       # エネミーの選択を終了
  1324.       end_enemy_select
  1325.       return
  1326.     end
  1327.     # C ボタンが押された場合
  1328.     if Input.trigger?(Input::C)
  1329.       # 決定 SE を演奏
  1330.       $game_system.se_play($data_system.decision_se)
  1331.       # アクションを設定
  1332.       @active_actor.current_action.kind = 0
  1333.       @active_actor.current_action.basic = 0
  1334.       @active_actor.current_action.target_index = @enemy_arrow.index
  1335.       # スキルウィンドウ表示中の場合
  1336.       if @skill_window != nil
  1337.         # アクションを再設定
  1338.         @active_actor.current_action.kind = 1
  1339.         # スキルの選択を終了
  1340.         end_skill_select
  1341.       end
  1342.       # アイテムウィンドウ表示中の場合
  1343.       if @item_window != nil
  1344.         # アクションを再設定
  1345.         @active_actor.current_action.kind = 2
  1346.         # アイテムの選択を終了
  1347.         end_item_select
  1348.       end
  1349.       # エネミーの選択を終了
  1350.       end_enemy_select
  1351.       # 次のアクターのコマンド入力へ
  1352.       phase3_next_actor
  1353.     end
  1354.   end
  1355.   #--------------------------------------------------------------------------
  1356.   # ● フレーム更新 (アクターコマンドフェーズ : アクター選択)
  1357.   #--------------------------------------------------------------------------
  1358.   def update_phase3_actor_select
  1359.     # コマンド選択中に行動不能になった場合
  1360.     unless @active_actor.inputable?
  1361.       @active_actor.current_action.clear
  1362.       command_delete
  1363.       # 次のアクターのコマンド入力へ
  1364.       phase3_next_actor
  1365.       return
  1366.     end
  1367.     # アクターアローを更新
  1368.     @actor_arrow.update
  1369.     # B ボタンが押された場合
  1370.     if Input.trigger?(Input::B)
  1371.       # キャンセル SE を演奏
  1372.       $game_system.se_play($data_system.cancel_se)
  1373.       # アクターの選択を終了
  1374.       end_actor_select
  1375.       # スキルウィンドウ表示中の場合
  1376.       if @skill_window != nil
  1377.         # アクションを再設定
  1378.         @active_actor.current_action.kind = 1
  1379.         # スキルの選択を終了
  1380.         end_skill_select
  1381.       end
  1382.       # アイテムウィンドウ表示中の場合
  1383.       if @item_window != nil
  1384.         # アクションを再設定
  1385.         @active_actor.current_action.kind = 2
  1386.         # アイテムの選択を終了
  1387.         end_item_select
  1388.       end
  1389.     end
  1390.     # C ボタンが押された場合
  1391.     if Input.trigger?(Input::C)
  1392.       # 決定 SE を演奏
  1393.       $game_system.se_play($data_system.decision_se)
  1394.       # アクションを設定
  1395.       @active_actor.current_action.kind = 0
  1396.       @active_actor.current_action.basic = 0
  1397.       @active_actor.current_action.target_index = @actor_arrow.index
  1398.       # アクターの選択を終了
  1399.       end_actor_select
  1400.       # スキルウィンドウ表示中の場合
  1401.       if @skill_window != nil
  1402.         # アクションを再設定
  1403.         @active_actor.current_action.kind = 1
  1404.         # スキルの選択を終了
  1405.         end_skill_select
  1406.       end
  1407.       # アイテムウィンドウ表示中の場合
  1408.       if @item_window != nil
  1409.         # アクションを再設定
  1410.         @active_actor.current_action.kind = 2
  1411.         # アイテムの選択を終了
  1412.         end_item_select
  1413.       end
  1414.       # 次のアクターのコマンド入力へ
  1415.       phase3_next_actor
  1416.     end
  1417.   end
  1418.   #--------------------------------------------------------------------------
  1419.   # ● エネミー選択開始
  1420.   #--------------------------------------------------------------------------
  1421.   alias :start_enemy_select_rtab :start_enemy_select
  1422.   def start_enemy_select
  1423.     @camera = "select"
  1424.     for enemy in $game_troop.enemies
  1425.       if enemy.exist?
  1426.         zoom = 1 / enemy.zoom
  1427.         @spriteset.screen_target(enemy.attack_x(zoom) * 0.75,
  1428.                                   enemy.attack_y(zoom) * 0.75, zoom)
  1429.         break
  1430.       end
  1431.     end
  1432.     # オリジナルの処理
  1433.     start_enemy_select_rtab
  1434.   end
  1435.   #--------------------------------------------------------------------------
  1436.   # ● エネミー選択終了
  1437.   #--------------------------------------------------------------------------
  1438.   alias :end_enemy_select_rtab :end_enemy_select
  1439.   def end_enemy_select
  1440.     # オリジナルの処理
  1441.     end_enemy_select_rtab
  1442.     if (@action == 0 and not @action_battlers.empty?) or
  1443.           (@camera == "select" and (@active_actor.current_action.kind != 0 or
  1444.                                             @active_actor.animation1_id != 0))
  1445.       @spriteset.screen_target(0, 0, 1)
  1446.     end
  1447.   end
  1448.   #--------------------------------------------------------------------------
  1449.   # ● スキル選択開始
  1450.   #--------------------------------------------------------------------------
  1451.   def start_skill_select
  1452.     # スキルウィンドウを作成
  1453.     @skill_window = Window_Skill.new(@active_actor)
  1454.     @skill_window.z = 301
  1455.     # ヘルプウィンドウを関連付け
  1456.     @skill_window.help_window = @help_window
  1457.     @craftback = Sprite.new
  1458.     @craftback.bitmap = RPG::Cache.batsys("craft")
  1459.     @craftback.z = 299
  1460.     # アクターコマンドウィンドウを無効化
  1461.     @actor_command_window.active = false
  1462.     @actor_command_window.visible = false
  1463.   end
  1464.  
  1465. #==============================================================================
  1466. # ■ Scene_Battle (分割定義 4)
  1467. #------------------------------------------------------------------------------
  1468. #  バトル画面の処理を行うクラスです。
  1469. #==============================================================================
  1470.  
  1471.   #--------------------------------------------------------------------------
  1472.   # ● メインフェーズ開始
  1473.   #--------------------------------------------------------------------------
  1474.   def start_phase4
  1475.     $game_temp.battle_main_phase = true
  1476.   end
  1477.   #--------------------------------------------------------------------------
  1478.   # ● フレーム更新 (メインフェーズ)
  1479.   #--------------------------------------------------------------------------
  1480.   def update_phase4
  1481.     # アクションを強制されているバトラーが存在する場合
  1482.     if $game_temp.forcing_battler != nil
  1483.       battler = $game_temp.forcing_battler
  1484.       if battler.current_action.forcing == false
  1485.         if @action_battlers.include?(battler)
  1486.           if @action > 0 or @action_battlers[0].phase == 1
  1487.             @action_battlers.delete(battler)
  1488.             @action_battlers.push(battler)
  1489.           end
  1490.           if battler.phase == 1
  1491.             battler.current_action.forcing = true
  1492.             force_action(battler)
  1493.           end
  1494.         else
  1495.           battler.current_action.forcing = true
  1496.           force_action(battler)
  1497.           action_start(battler)
  1498.           @action_battlers.delete(battler)
  1499.           @action_battlers.push(battler)
  1500.         end
  1501.         battler.at = @max
  1502.         battler.atp = 100 * battler.at / @max
  1503.       end
  1504.     end
  1505.     # action が1以上の場合、一斉に行動を起こす
  1506.     for battler in @action_battlers.reverse
  1507.       # ウェイト中の場合
  1508.       if battler.wait > 0
  1509.         # ウェイトカウントを減らす
  1510.         battler.wait -= 1
  1511.         break if @action == 0
  1512.         next
  1513.       end
  1514.       unless fin? and battler.phase < 3 and
  1515.           not $game_system.battle_interpreter.running?
  1516.         action_phase(battler)
  1517.       end
  1518.       break if @action == 0
  1519.     end
  1520.     # アクションを強制されているバトラーが存在しない場合
  1521.     if $game_temp.forcing_battler == nil
  1522.       # バトルイベントをセットアップ
  1523.       setup_battle_event
  1524.       # バトルイベント実行中の場合
  1525.       if $game_system.battle_interpreter.running?
  1526.         return
  1527.       end
  1528.     end
  1529.     # 勝敗を決した際の処理
  1530.     if fin?
  1531.       # 敗北時、指定時間ウェイト
  1532.       if $game_party.all_dead? and @after_wait[0] > 0
  1533.         @after_wait[0] -= 1
  1534.         return
  1535.       end
  1536.       # 勝利時、指定時間ウェイト
  1537.       if victory? and @after_wait[1] > 0
  1538.         @after_wait[1] -= 1
  1539.         return
  1540.       end
  1541.       # 戦闘が終了し、かつアクターが行動直前の場合はアクターの行動を消去
  1542.       for battler in @action_battlers.reverse
  1543.         if battler.phase < 3 and not $game_system.battle_interpreter.running?
  1544.           @action_battlers.delete(battler)
  1545.         end
  1546.       end
  1547.       # 勝敗判定
  1548.       if @action_battlers.empty? and
  1549.           not $game_system.battle_interpreter.running?
  1550.         judge
  1551.       end
  1552.     end
  1553.   end
  1554.   #--------------------------------------------------------------------------
  1555.   # ● アクション更新 (メインフェーズ)
  1556.   #--------------------------------------------------------------------------
  1557.   def action_phase(battler)
  1558.     # action が 1 の場合、バトラーが行動中かどうか確認
  1559.     if @action == 1 and battler.phase <= 3
  1560.       for target in battler.target
  1561.         speller = synthe?(target)
  1562.         if speller == nil
  1563.           # ターゲットが通常行動中の場合
  1564.           if @action_battlers.include?(target)
  1565.             if target.phase > 2
  1566.               return
  1567.             end
  1568.           end
  1569.         else
  1570.           # ターゲットが連携スキル発動中の場合
  1571.           for spell in speller
  1572.             if @action_battlers.include?(spell)
  1573.               if spell.phase > 2
  1574.                 return
  1575.               end
  1576.             end
  1577.           end
  1578.         end
  1579.       end
  1580.     end
  1581.     case battler.phase
  1582.     when 1
  1583.       update_phase4_step1(battler)
  1584.     when 2
  1585.       update_phase4_step2(battler)
  1586.     when 3
  1587.       update_phase4_step3(battler)
  1588.     when 4
  1589.       update_phase4_step4(battler)
  1590.     when 5
  1591.       update_phase4_step5(battler)
  1592.     when 6
  1593.       update_phase4_step6(battler)
  1594.     end
  1595.   end
  1596.   #--------------------------------------------------------------------------
  1597.   # ● フレーム更新 (メインフェーズ ステップ 1 : アクション準備)
  1598.   #--------------------------------------------------------------------------
  1599.   def update_phase4_step1(battler)
  1600.     # すでに戦闘から外されている場合
  1601.     if battler.index == nil
  1602.       @action_battlers.delete(battler)
  1603.       anime_wait_return
  1604.       return
  1605.     end
  1606.     speller = synthe?(battler)
  1607.     if speller == nil
  1608.       # ダメージ食らい中の場合
  1609.       unless battler.damage.empty? or @action > 2
  1610.         return
  1611.       end
  1612.       # 行動可能かどうか判定
  1613.       unless battler.movable?
  1614.         battler.phase = 6
  1615.         return
  1616.       end
  1617.     else
  1618.       # ダメージ食らい中の場合
  1619.       for spell in speller
  1620.         unless spell.damage.empty? or @action > 2
  1621.           return
  1622.         end
  1623.         # 行動可能かどうか判定
  1624.         unless spell.movable?
  1625.           battler.phase = 6
  1626.           return
  1627.         end
  1628.       end
  1629.     end
  1630.     # スキル使用時、詠唱時間設定
  1631.     # 強制アクションかつ @force が 2 の時はスキルを即時発動
  1632.     if battler.current_action.kind == 1 and
  1633.       (not battler.current_action.forcing or @force != 2)
  1634.       if battler.rtp == 0
  1635.         # スキル詠唱中ならば、解除
  1636.         skill_reset(battler)
  1637.         # スキル詠唱時間設定
  1638.         recite_time(battler)
  1639.         # 連携技設定
  1640.         synthe_spell(battler)
  1641.         # スキルを詠唱する場合
  1642.         if battler.rtp > 0
  1643.           # 強制アクションかつ @force が 1 の時は連携スキルのみ即時発動
  1644.           speller = synthe?(battler)
  1645.           if battler.current_action.forcing and @force > 0 and speller != nil
  1646.             for spell in speller
  1647.               spell.rt = spell.rtp
  1648.             end
  1649.           else
  1650.             battler.blink = true
  1651.             if battler.current_action.forcing
  1652.               $game_temp.forcing_battler = nil
  1653.               battler.current_action.forcing = false
  1654.             end
  1655.             @action_battlers.delete(battler)
  1656.             return
  1657.           end
  1658.         end
  1659.       end
  1660.     end
  1661.     # アクターの明滅エフェクト OFF
  1662.     if battler != nil
  1663.       battler.blink = false
  1664.     end
  1665.     speller = synthe?(battler)
  1666.     if speller == nil
  1667.       @spell_p.delete(battler)
  1668.       @spell_e.delete(battler)
  1669.     else
  1670.       for spell in speller
  1671.         spell.blink = false
  1672.         @spell_p.delete(spell)
  1673.         @spell_e.delete(spell)
  1674.       end
  1675.     end
  1676.     # ステップ 2 に移行
  1677.     battler.phase = 2
  1678.   end
  1679.   #--------------------------------------------------------------------------
  1680.   # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始)
  1681.   #--------------------------------------------------------------------------
  1682.   def update_phase4_step2(battler)
  1683.     # 強制アクションでなければ
  1684.     unless battler.current_action.forcing
  1685.       # 制約が [敵を通常攻撃する] か [味方を通常攻撃する] の場合
  1686.       if battler.restriction == 2 or battler.restriction == 3
  1687.         # アクションに攻撃を設定
  1688.         battler.current_action.kind = 0
  1689.         battler.current_action.basic = 0
  1690.       end
  1691.     end
  1692.     # アクションの種別で分岐
  1693.     case battler.current_action.kind
  1694.     when 0  # 基本
  1695.       if fin?
  1696.         battler.phase = 6
  1697.         return
  1698.       end
  1699.       make_basic_action_result(battler)
  1700.     when 1  # スキル
  1701.       if fin? and $data_skills[battler.current_action.skill_id].scope == 1..2
  1702.         battler.phase = 6
  1703.         return
  1704.       end
  1705.       make_skill_action_result(battler)
  1706.     when 2  # アイテム
  1707.       if fin? and $data_items[battler.current_action.item_id].scope == 1..2
  1708.         battler.phase = 6
  1709.         return
  1710.       end
  1711.       make_item_action_result(battler)
  1712.     end
  1713.     if battler.phase == 2
  1714.       # ステップ 3 に移行
  1715.       battler.phase = 3
  1716.     end
  1717.   end
  1718.   #--------------------------------------------------------------------------
  1719.   # ● 基本アクション 結果作成
  1720.   #--------------------------------------------------------------------------
  1721.   def make_basic_action_result(battler)
  1722.     # 攻撃の場合
  1723.     if battler.current_action.basic == 0
  1724.       # アニメーション ID を設定
  1725.       battler.anime1 = battler.animation1_id
  1726.       battler.anime2 = battler.animation2_id
  1727.       # 行動側バトラーがエネミーの場合
  1728.       if battler.is_a?(Game_Enemy)
  1729.         if battler.restriction == 3
  1730.           target = $game_troop.random_target_enemy
  1731.         elsif battler.restriction == 2
  1732.           target = $game_party.random_target_actor
  1733.         else
  1734.           index = battler.current_action.target_index
  1735.           target = $game_party.smooth_target_actor(index)
  1736.         end
  1737.       end
  1738.       # 行動側バトラーがアクターの場合
  1739.       if battler.is_a?(Game_Actor)
  1740.         if battler.restriction == 3
  1741.           target = $game_party.random_target_actor
  1742.         elsif battler.restriction == 2
  1743.           target = $game_troop.random_target_enemy
  1744.         else
  1745.           index = battler.current_action.target_index
  1746.           target = $game_troop.smooth_target_enemy(index)
  1747.         end
  1748.       end
  1749.       # 対象側バトラーの配列を設定
  1750.       battler.target = [target]
  1751.       # 通常攻撃の効果を適用
  1752.       for target in battler.target
  1753.         target.attack_effect(battler)
  1754.       end
  1755.       return
  1756.     end
  1757.     # 防御の場合
  1758.     if battler.current_action.basic == 1
  1759.       return
  1760.     end
  1761.     # 逃げるの場合
  1762.     if battler.is_a?(Game_Enemy) and battler.current_action.basic == 2
  1763.       return
  1764.     end
  1765.     # 何もしないの場合
  1766.     if battler.current_action.basic == 3
  1767.       # ステップ 6 に移行
  1768.       battler.phase = 6
  1769.       return
  1770.     end
  1771.   end
  1772.   #--------------------------------------------------------------------------
  1773.   # ● スキルまたはアイテムの対象側バトラー設定
  1774.   #     scope : スキルまたはアイテムの効果範囲
  1775.   #--------------------------------------------------------------------------
  1776.   def set_target_battlers(scope, battler)
  1777.     # 行動側バトラーがエネミーの場合
  1778.     if battler.is_a?(Game_Enemy)
  1779.       # 効果範囲で分岐
  1780.       case scope
  1781.       when 1  # 敵単体
  1782.         index =battler.current_action.target_index
  1783.         battler.target.push($game_party.smooth_target_actor(index))
  1784.       when 2  # 敵全体
  1785.         for actor in $game_party.actors
  1786.           if actor.exist?
  1787.             battler.target.push(actor)
  1788.           end
  1789.         end
  1790.       when 3  # 味方単体
  1791.         index = battler.current_action.target_index
  1792.         battler.target.push($game_troop.smooth_target_enemy(index))
  1793.       when 4  # 味方全体
  1794.         for enemy in $game_troop.enemies
  1795.           if enemy.exist?
  1796.             battler.target.push(enemy)
  1797.           end
  1798.         end
  1799.       when 5  # 味方単体 (HP 0)
  1800.         index = battler.current_action.target_index
  1801.         enemy = $game_troop.enemies[index]
  1802.         if enemy != nil and enemy.hp0?
  1803.           battler.target.push(enemy)
  1804.         end
  1805.       when 6  # 味方全体 (HP 0)
  1806.         for enemy in $game_troop.enemies
  1807.           if enemy != nil and enemy.hp0?
  1808.             battler.target.push(enemy)
  1809.           end
  1810.         end
  1811.       when 7  # 使用者
  1812.         battler.target.push(battler)
  1813.       end
  1814.     end
  1815.     # 行動側バトラーがアクターの場合
  1816.     if battler.is_a?(Game_Actor)
  1817.       # 効果範囲で分岐
  1818.       case scope
  1819.       when 1  # 敵単体
  1820.         index = battler.current_action.target_index
  1821.         battler.target.push($game_troop.smooth_target_enemy(index))
  1822.       when 2  # 敵全体
  1823.         for enemy in $game_troop.enemies
  1824.           if enemy.exist?
  1825.             battler.target.push(enemy)
  1826.           end
  1827.         end
  1828.       when 3  # 味方単体
  1829.         index = battler.current_action.target_index
  1830.         battler.target.push($game_party.smooth_target_actor(index))
  1831.       when 4  # 味方全体
  1832.         for actor in $game_party.actors
  1833.           if actor.exist?
  1834.             battler.target.push(actor)
  1835.           end
  1836.         end
  1837.       when 5  # 味方単体 (HP 0)
  1838.         index = battler.current_action.target_index
  1839.         actor = $game_party.actors[index]
  1840.         if actor != nil and actor.hp0?
  1841.           battler.target.push(actor)
  1842.         end
  1843.       when 6  # 味方全体 (HP 0)
  1844.         for actor in $game_party.actors
  1845.           if actor != nil and actor.hp0?
  1846.             battler.target.push(actor)
  1847.           end
  1848.         end
  1849.       when 7  # 使用者
  1850.         battler.target.push(battler)
  1851.       end
  1852.     end
  1853.   end
  1854.   #--------------------------------------------------------------------------
  1855.   # ● スキルアクション 結果作成
  1856.   #--------------------------------------------------------------------------
  1857.   def make_skill_action_result(battler)
  1858.     # スキルを取得
  1859.     @skill = $data_skills[battler.current_action.skill_id]
  1860.     # 連携スキルであるかどうか確認
  1861.     speller = synthe?(battler)
  1862.     # 強制アクションでなければ
  1863.     unless battler.current_action.forcing
  1864.       # SP 切れなどで使用できなくなった場合
  1865.       if speller == nil
  1866.         unless battler.skill_can_use?(@skill.id)
  1867.           # ステップ 6 に移行
  1868.           battler.phase = 6
  1869.          return
  1870.         end
  1871.       end
  1872.     end
  1873.     # SP 消費
  1874.     temp = false
  1875.     if speller != nil
  1876.       for spell in speller
  1877.         if spell.current_action.spell_id == 0
  1878.           spell.sp -= @skill.sp_cost
  1879.         else
  1880.           spell.sp -= $data_skills[spell.current_action.spell_id].sp_cost
  1881.         end
  1882.         # ステータスウィンドウをリフレッシュ
  1883.         status_refresh(spell)
  1884.       end
  1885.     else
  1886.       battler.sp -= @skill.sp_cost
  1887.       # ステータスウィンドウをリフレッシュ
  1888.       status_refresh(battler)
  1889.     end
  1890.     # アニメーション ID を設定
  1891.     battler.anime1 = @skill.animation1_id
  1892.     battler.anime2 = @skill.animation2_id
  1893.     # コモンイベント ID を設定
  1894.     battler.event = @skill.common_event_id
  1895.     # 対象側バトラーを設定
  1896.     set_target_battlers(@skill.scope, battler)
  1897.     # スキルの効果を適用
  1898.     for target in battler.target
  1899.       if speller != nil
  1900.         damage = 0
  1901.         d_result = false
  1902.         effective = false
  1903.         state_p = []
  1904.         state_m = []
  1905.         for spell in speller
  1906.           if spell.current_action.spell_id != 0
  1907.             @skill = $data_skills[spell.current_action.spell_id]
  1908.           end
  1909.           effective |= target.skill_effect(spell, @skill)
  1910.           if target.damage[spell].class != String
  1911.             d_result = true
  1912.             damage += target.damage[spell]
  1913.           elsif effective
  1914.             effect = target.damage[spell]
  1915.           end
  1916.           state_p += target.state_p[spell]
  1917.           state_m += target.state_m[spell]
  1918.           target.damage.delete(spell)
  1919.           target.state_p.delete(spell)
  1920.           target.state_m.delete(spell)
  1921.         end
  1922.         if d_result
  1923.           target.damage[battler] = damage
  1924.         elsif effective
  1925.           target.damage[battler] = effect
  1926.         else
  1927.           target.damage[battler] = 0
  1928.         end
  1929.         target.state_p[battler] = state_p
  1930.         target.state_m[battler] = state_m
  1931.       else
  1932.         target.skill_effect(battler, @skill)
  1933.       end
  1934.     end
  1935.   end
  1936.   #--------------------------------------------------------------------------
  1937.   # ● アイテムアクション 結果作成
  1938.   #--------------------------------------------------------------------------
  1939.   def make_item_action_result(battler)
  1940.     # アイテムを取得
  1941.     @item = $data_items[battler.current_action.item_id]
  1942.     # アイテム切れなどで使用できなくなった場合
  1943.     unless $game_party.item_can_use?(@item.id)
  1944.       # ステップ 6 に移行
  1945.       battler.phase = 6
  1946.       return
  1947.     end
  1948.     # 消耗品の場合
  1949.     if @item.consumable
  1950.       # 使用したアイテムを 1 減らす
  1951.       $game_party.lose_item(@item.id, 1)
  1952.     end
  1953.     # アニメーション ID を設定
  1954.     battler.anime1 = @item.animation1_id
  1955.     battler.anime2 = @item.animation2_id
  1956.     # コモンイベント ID を設定
  1957.     battler.event = @item.common_event_id
  1958.     # 対象を決定
  1959.     index = battler.current_action.target_index
  1960.     target = $game_party.smooth_target_actor(index)
  1961.     # 対象側バトラーを設定
  1962.     set_target_battlers(@item.scope, battler)
  1963.     # アイテムの効果を適用
  1964.     for target in battler.target
  1965.       target.item_effect(@item, battler)
  1966.     end
  1967.   end
  1968.   #--------------------------------------------------------------------------
  1969.   # ● フレーム更新 (メインフェーズ ステップ 3 : 行動側アニメーション)
  1970.   #--------------------------------------------------------------------------
  1971.   def update_phase4_step3(battler)
  1972.     # ヘルプウィンドウの更新。アクションの種別で分岐
  1973.     case battler.current_action.kind
  1974.     when 0  # 基本
  1975.       if battler.current_action.basic == 1      
  1976.         @help_window.set_text("休息", 1)
  1977.         @help_wait = @help_time
  1978.       end
  1979.       if battler.current_action.basic == 2
  1980.         # 逃げる
  1981.         @help_window.set_text("逃走", 1)
  1982.         @help_wait = @help_time
  1983.         battler.escape
  1984.         battler.phase = 4
  1985.         return
  1986.       end
  1987.     when 1  # スキル
  1988.       skill =  $data_skills[battler.current_action.skill_id]
  1989.       @help_window.set_text(skill.name, 1)
  1990.       @help_wait = @help_time
  1991.     when 2  # アイテム
  1992.       item = $data_items[battler.current_action.item_id]
  1993.       @help_window.set_text(item.name, 1)
  1994.       @help_wait = @help_time
  1995.     end
  1996.     # 行動側アニメーション (ID が 0 の場合は白フラッシュ)
  1997.     if battler.anime1 == 0
  1998.       battler.white_flash = true
  1999.       battler.wait = 5

RUBY 代码复制
  1. # カメラ設定
  2.       if battler.target[0].is_a?(Game_Enemy)
  3.         camera_set(battler)
  4.       end
  5.     else
  6.       battler.animation.push([battler.anime1, true])
  7.       speller = synthe?(battler)
  8.       if speller != nil
  9.         for spell in speller
  10.           if spell != battler
  11.             if spell.current_action.spell_id == 0
  12.               spell.animation.push([battler.anime1, true])
  13.             else
  14.               skill = spell.current_action.spell_id
  15.               spell.animation.push([$data_skills[skill].animation1_id, true])
  16.               spell.current_action.spell_id = 0
  17.             end
  18.           end
  19.         end
  20.       end
  21.       battler.wait = 2 * $data_animations[battler.anime1].frame_max - 10
  22.     end
  23.     # ステップ 4 に移行
  24.     battler.phase = 4
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ● フレーム更新 (メインフェーズ ステップ 4 : 対象側アニメーション)
  28.   #--------------------------------------------------------------------------
  29.   def update_phase4_step4(battler)
  30.     # カメラ設定
  31.     if battler.target[0].is_a?(Game_Enemy) and battler.anime1 != 0
  32.        camera_set(battler)
  33.     end
  34.     # 対象側アニメーション
  35.     for target in battler.target
  36.       target.animation.push([battler.anime2,
  37.                                           (target.damage[battler] != "Miss")])
  38.       unless battler.anime2 == 0
  39.         battler.wait = 2 * $data_animations[battler.anime2].frame_max - 10
  40.       end
  41.     end
  42.     # ステップ 5 に移行
  43.     battler.phase = 5
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
  47.   #--------------------------------------------------------------------------
  48.   def update_phase4_step5(battler)
  49.     # ダメージ表示
  50.     for target in battler.target
  51.       if target.damage[battler] != nil
  52.         target.damage_pop[battler] = true
  53.         target.damage_effect(battler, battler.current_action.kind)
  54.         battler.wait = @damage_wait
  55.         # ステータスウィンドウをリフレッシュ
  56.         status_refresh(target)
  57.       end
  58.     end
  59.     # ステップ 6 に移行
  60.     battler.phase = 6
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ)
  64.   #--------------------------------------------------------------------------
  65.   def update_phase4_step6(battler)
  66.     # カメラを戻す
  67.     if battler.target[0].is_a?(Game_Enemy) and @camera == battler
  68.       @spriteset.screen_target(0, 0, 1)
  69.     end
  70.     # スキルラーニング
  71.     if battler.target[0].is_a?(Game_Actor) and battler.current_action.kind == 1
  72.       for target in battler.target
  73.         skill_learning(target, target.class_id,
  74.                         battler.current_action.skill_id)
  75.       end
  76.     end
  77.     # アクション強制対象のバトラーをクリア
  78.     if battler.current_action.forcing == true and
  79.         battler.current_action.force_kind == 0 and
  80.         battler.current_action.force_basic == 0 and
  81.         battler.current_action.force_skill_id == 0
  82.       $game_temp.forcing_battler = nil
  83.       battler.current_action.forcing = false
  84.     end
  85.     refresh_phase(battler)
  86.     speller = synthe?(battler)
  87.     if speller != nil
  88.       for spell in speller
  89.         if spell != battler
  90.           refresh_phase(spell)
  91.         end
  92.       end
  93.       synthe_delete(speller)
  94.     end
  95.     # コモンイベント ID が有効の場合
  96.     if battler.event > 0
  97.       # イベントをセットアップ
  98.       common_event = $data_common_events[battler.event]
  99.       $game_system.battle_interpreter.setup(common_event.list, 0)
  100.     end
  101.     act = 0
  102.     for actor in $game_party.actors + $game_troop.enemies
  103.       if actor.movable?
  104.         act += 1
  105.       end
  106.     end
  107.     if @turn_cnt >= act and act > 0
  108.       @turn_cnt %= act
  109.       $game_temp.battle_turn += 1
  110.       # バトルイベントの全ページを検索
  111.       for index in 0...$data_troops[@troop_id].pages.size
  112.         # イベントページを取得
  113.         page = $data_troops[@troop_id].pages[index]
  114.         # このページのスパンが [ターン] の場合
  115.         if page.span == 1
  116.           # 実行済みフラグをクリア
  117.           $game_temp.battle_event_flags[index] = false
  118.         end
  119.       end
  120.     end
  121.     battler.phase = 1
  122.     @action_battlers.delete(battler)
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # ● リフレッシュ
  126.   #--------------------------------------------------------------------------
  127.   def refresh_phase(battler)
  128.     battler.at -= @max
  129.     if battler.movable?
  130.       battler.atp = 100 * battler.at / @max
  131.     end
  132.     spell_reset(battler)
  133.     # スリップダメージ
  134.     if battler.hp > 0 and battler.slip_damage?
  135.       battler.slip_damage_effect
  136.       battler.damage_pop["slip"] = true
  137.     end
  138.     # ステート自然解除
  139.     battler.remove_states_auto
  140.     # ステータスウィンドウをリフレッシュ
  141.     status_refresh(battler, true)
  142.     unless battler.movable?
  143.       return
  144.     end
  145.     # ターン数カウント
  146.     @turn_cnt += 1
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● バトラーアクションスタート
  150.   #--------------------------------------------------------------------------
  151.   def action_start(battler)
  152.     battler.phase = 1
  153.     battler.anime1 = 0
  154.     battler.anime2 = 0
  155.     battler.target = []
  156.     battler.event = 0
  157.     @action_battlers.unshift(battler)
  158.   end
  159.   #--------------------------------------------------------------------------
  160.   # ● ステータスウィンドウをリフレッシュ
  161.   #--------------------------------------------------------------------------
  162.   def status_refresh(battler, at = false)
  163.     if battler.is_a?(Game_Actor)
  164.       for i in 0...$game_party.actors.size
  165.         if battler == $game_party.actors[i]
  166.           number = i + 1
  167.         end
  168.       end
  169.       @status_window.refresh(number)
  170.       if at == true
  171.         @status_window.at_refresh(number)
  172.       end
  173.     end
  174.   end
  175.   #--------------------------------------------------------------------------
  176.   # ● アニメウェイト判断処理
  177.   #--------------------------------------------------------------------------
  178.   def anime_wait_return
  179.     if (@action_battlers.empty? or @anime_wait == false) and
  180.         not $game_system.battle_interpreter.running?
  181.       # エネミーアローが有効の場合
  182.       if @enemy_arrow != nil
  183.         return [@active - 2, 0].min == 0
  184.       # アクターアローが有効の場合
  185.       elsif @actor_arrow != nil
  186.         return [@active - 2, 0].min == 0
  187.       # スキルウィンドウが有効の場合
  188.       elsif @skill_window != nil
  189.         return [@active - 3, 0].min == 0
  190.       # アイテムウィンドウが有効の場合
  191.       elsif @item_window != nil
  192.         return [@active - 3, 0].min == 0
  193.       # アクターコマンドウィンドウが有効の場合
  194.       elsif @actor_command_window.active
  195.         return [@active - 1, 0].min == 0
  196.       else
  197.         return true
  198.       end
  199.     else
  200.       return false
  201.     end
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   # ● アクターコマンド消去判断
  205.   #--------------------------------------------------------------------------
  206.   def command_delete
  207.     # エネミーアローが有効の場合
  208.     if @enemy_arrow != nil
  209.       end_enemy_select
  210.     # アクターアローが有効の場合
  211.     elsif @actor_arrow != nil
  212.       end_actor_select
  213.     end
  214.     # スキルウィンドウが有効の場合
  215.     if @skill_window != nil
  216.       end_skill_select
  217.     # アイテムウィンドウが有効の場合
  218.     elsif @item_window != nil
  219.       end_item_select
  220.     end
  221.     # アクターコマンドウィンドウが有効の場合
  222.     if @actor_command_window.active
  223.       @command.shift
  224.       @command_a = false
  225.       # メインフェーズフラグをセット
  226.       $game_temp.battle_main_phase = true
  227.       # アクターコマンドウィンドウを無効化
  228.       @actor_command_window.active = false
  229.       @actor_command_window.visible = false
  230.       # アクターの明滅エフェクト OFF
  231.       if @active_actor != nil
  232.         @active_actor.blink = false
  233.       end
  234.     end
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # ● 強制アクション設定
  238.   #--------------------------------------------------------------------------
  239.   def force_action(battler)
  240.     battler.current_action.kind = battler.current_action.force_kind
  241.     battler.current_action.basic = battler.current_action.force_basic
  242.     battler.current_action.skill_id = battler.current_action.force_skill_id
  243.     battler.current_action.force_kind = 0
  244.     battler.current_action.force_basic = 0
  245.     battler.current_action.force_skill_id = 0
  246.   end
  247.   #--------------------------------------------------------------------------
  248.   # ● カメラセット
  249.   #--------------------------------------------------------------------------
  250.   def camera_set(battler)
  251.     @camera = battler
  252.     if battler.target.size == 1
  253.       if battler.current_action.kind == 0
  254.         zoom = 1.2 / battler.target[0].zoom
  255.       elsif synthe?(battler) == nil
  256.         zoom = 1.5 / battler.target[0].zoom
  257.       else
  258.         zoom = 2.0 / battler.target[0].zoom
  259.       end
  260.       @spriteset.screen_target(battler.target[0].attack_x(zoom),
  261.                                 battler.target[0].attack_y(zoom), zoom)
  262.     else
  263.       @spriteset.screen_target(0, 0, 0.75)
  264.     end
  265.   end
  266.   #--------------------------------------------------------------------------
  267.   # ● スキル詠唱タイム作成
  268.   #--------------------------------------------------------------------------
  269.   def recite_time(battler)
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # ● 連携スキル判別
  273.   #--------------------------------------------------------------------------
  274.   def synthe_spell(battler)
  275.   end
  276.   #--------------------------------------------------------------------------
  277.   # ● スキルラーニングシステム
  278.   #--------------------------------------------------------------------------
  279.   def skill_learning(actor, class_id, skill_id)
  280.   end
  281.   #--------------------------------------------------------------------------
  282.   # ● 行動可能判定
  283.   #--------------------------------------------------------------------------
  284.   def active?(battler)
  285.     speller = synthe?(battler)
  286.     if speller != nil
  287.       if synthe_delete?(speller)
  288.         return false
  289.       end
  290.     else
  291.       unless battler.inputable?
  292.         spell_reset(battler)
  293.         unless battler.movable?
  294.           battler.atp = 0
  295.           return false
  296.         end
  297.       end
  298.       if battler.current_action.forcing
  299.         spell_reset(battler)
  300.       end
  301.     end
  302.     return true
  303.   end
  304.   #--------------------------------------------------------------------------
  305.   # ● 合成スキル詠唱中か?
  306.   #--------------------------------------------------------------------------
  307.   def synthe?(battler)
  308.     for speller in @synthe
  309.       if speller.include?(battler)
  310.         return speller
  311.       end
  312.     end
  313.     return nil
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # ● 合成スキル消去判断
  317.   #--------------------------------------------------------------------------
  318.   def synthe_delete?(speller)
  319.     for battler in speller
  320.       if not battler.inputable? and dead_ok?(battler)
  321.         synthe_delete(speller)
  322.         return true
  323.       end
  324.     end
  325.     return false
  326.   end
  327.   #--------------------------------------------------------------------------
  328.   # ● 合成スキル消去
  329.   #--------------------------------------------------------------------------
  330.   def synthe_delete(speller)
  331.     for battler in speller
  332.       spell_reset(battler)
  333.       if dead_ok?(battler)
  334.         @action_battlers.delete(battler)
  335.       end
  336.     end
  337.     @synthe.delete(speller)
  338.   end
  339.   #--------------------------------------------------------------------------
  340.   # ● 連携含むスキル詠唱解除
  341.   #--------------------------------------------------------------------------
  342.   def skill_reset(battler)
  343.     speller = synthe?(battler)
  344.     if speller != nil
  345.       synthe_delete(speller)
  346.     else
  347.       spell_reset(battler)
  348.     end
  349.   end
  350.   #--------------------------------------------------------------------------
  351.   # ● スキル詠唱解除
  352.   #--------------------------------------------------------------------------
  353.   def spell_reset(battler)
  354.     battler.rt = 0
  355.     battler.rtp = 0
  356.     battler.blink = false
  357.     battler.spell = false
  358.     battler.current_action.spell_id = 0
  359.     @spell_p.delete(battler)
  360.     @spell_e.delete(battler)
  361.   end
  362.   #--------------------------------------------------------------------------
  363.   # ● 戦闘終了判定
  364.   #--------------------------------------------------------------------------
  365.   def fin?
  366.    return (victory? or $game_party.all_dead? or $game_party.actors.size == 0)
  367.   end
  368.   #--------------------------------------------------------------------------
  369.   # ● 敵全滅判定
  370.   #--------------------------------------------------------------------------
  371.   def victory?
  372.     for battler in $game_troop.enemies
  373.       if not battler.hidden and (battler.rest_hp > 0 or
  374.           battler.immortal or battler.damage_pop.size > 0)
  375.         return false
  376.       end
  377.     end
  378.     return true
  379.   end
  380.   #--------------------------------------------------------------------------
  381.   # ● 死亡許可判定
  382.   #--------------------------------------------------------------------------
  383.   def dead_ok?(battler)
  384.     speller = synthe?(battler)
  385.     if speller == nil
  386.       if @action_battlers.include?(battler)
  387.         if battler.phase > 2
  388.           return false
  389.         end
  390.       end
  391.     else
  392.       for battler in speller
  393.         if @action_battlers.include?(battler)
  394.           if battler.phase > 2
  395.             return false
  396.           end
  397.         end
  398.       end
  399.     end
  400.     return true
  401.   end
  402. end
  403.  
  404. #==============================================================================
  405. # ■ Game_Actor
  406. #------------------------------------------------------------------------------
  407. #  アクターを扱うクラスです。このクラスは Game_Actors クラス ($game_actors)
  408. # の内部で使用され、Game_Party クラス ($game_party) からも参照されます。
  409. #==============================================================================
  410.  
  411. class Game_Actor < Game_Battler
  412.   #--------------------------------------------------------------------------
  413.   # ● バトル画面 X 座標の取得
  414.   #--------------------------------------------------------------------------
  415.   def screen_x
  416.     # パーティ内の並び順から X 座標を計算して返す
  417.     if self.index != nil
  418.       return self.index * 160 + (4 - $game_party.actors.size) * 80 + 80
  419.     else
  420.       return 0
  421.     end
  422.   end
  423. end
  424.  
  425. #==============================================================================
  426. # ■ Spriteset_Battle
  427. #------------------------------------------------------------------------------
  428. #  バトル画面のスプライトをまとめたクラスです。このクラスは Scene_Battle クラ
  429. # スの内部で使用されます。
  430. #==============================================================================
  431.  
  432. class Spriteset_Battle
  433.   #--------------------------------------------------------------------------
  434.   # ● 公開インスタンス変数
  435.   #--------------------------------------------------------------------------
  436.   attr_reader   :real_x                   # x座標補正(現在値)
  437.   attr_reader   :real_y                   # y座標補正(現在値)
  438.   attr_reader   :real_zoom                # 拡大率(現在値)
  439.   #--------------------------------------------------------------------------
  440.   # ● オブジェクト初期化
  441.   #--------------------------------------------------------------------------
  442.   def initialize
  443.     # ビューポートを作成
  444.     @viewport1 = Viewport.new(0, 0, 640, 480)
  445.     @viewport2 = Viewport.new(0, 0, 640, 480)
  446.     @viewport3 = Viewport.new(0, 0, 640, 480)
  447.     @viewport4 = Viewport.new(0, 0, 640, 480)
  448.     @viewport2.z = 101
  449.     @viewport3.z = 200
  450.     @viewport4.z = 5000
  451.     @wait = 0
  452.     @real_x = 0
  453.     @real_y = 0
  454.     @real_zoom = 1.0
  455.     @target_x = 0
  456.     @target_y = 0
  457.     @target_zoom = 1.0
  458.     @gap_x = 0
  459.     @gap_y = 0
  460.     @gap_zoom = 0.0
  461.     # バトルバックスプライトを作成
  462.     @battleback_sprite = Sprite.new(@viewport1)
  463.     # エネミースプライトを作成
  464.     @enemy_sprites = []
  465.     for enemy in $game_troop.enemies.reverse
  466.       @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
  467.     end
  468.     # アクタースプライトを作成
  469.     @actor_sprites = []
  470.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  471.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  472.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  473.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  474.     # 天候を作成
  475.     @weather = RPG::Weather.new(@viewport1)
  476.     # ピクチャスプライトを作成
  477.     @picture_sprites = []
  478.     for i in 51..100
  479.       @picture_sprites.push(Sprite_Picture.new(@viewport3,
  480.         $game_screen.pictures[i]))
  481.     end
  482.     # タイマースプライトを作成
  483.     @timer_sprite = Sprite_Timer.new
  484.     # フレーム更新
  485.     update
  486.   end
  487.   #--------------------------------------------------------------------------
  488.   # ● フレーム更新
  489.   #--------------------------------------------------------------------------
  490.   def update
  491.     # アクタースプライトの内容を更新 (アクターの入れ替えに対応)
  492.     @actor_sprites[0].battler = $game_party.actors[0]
  493.     @actor_sprites[1].battler = $game_party.actors[1]
  494.     @actor_sprites[2].battler = $game_party.actors[2]
  495.     @actor_sprites[3].battler = $game_party.actors[3]
  496.     # バトルバックのファイル名が現在のものと違う場合
  497.     if @battleback_name != $game_temp.battleback_name
  498.       make_battleback
  499.     end
  500.     # 画面のスクロール
  501.     screen_scroll
  502.     # モンスターの位置補正
  503.     for enemy in $game_troop.enemies
  504.       enemy.real_x = @real_x
  505.       enemy.real_y = @real_y
  506.       enemy.real_zoom = @real_zoom
  507.     end
  508.     # バトラースプライトを更新
  509.     for sprite in @enemy_sprites + @actor_sprites
  510.       sprite.update
  511.     end
  512.     # 天候グラフィックを更新
  513.     @weather.type = $game_screen.weather_type
  514.     @weather.max = $game_screen.weather_max
  515.     @weather.update
  516.     # ピクチャスプライトを更新
  517.     for sprite in @picture_sprites
  518.       sprite.update
  519.     end
  520.     # タイマースプライトを更新
  521.     @timer_sprite.update
  522.     # 画面の色調とシェイク位置を設定
  523.     @viewport1.tone = $game_screen.tone
  524.     @viewport1.ox = $game_screen.shake
  525.     # 画面のフラッシュ色を設定
  526.     @viewport4.color = $game_screen.flash_color
  527.     # ビューポートを更新
  528.     @viewport1.update
  529.     @viewport2.update
  530.     @viewport4.update
  531.   end
  532.   #--------------------------------------------------------------------------
  533.   # ● バトル背景の設定
  534.   #--------------------------------------------------------------------------
  535.   def make_battleback
  536.     @battleback_name = $game_temp.battleback_name
  537.     if @battleback_sprite.bitmap != nil
  538.       @battleback_sprite.bitmap.dispose
  539.     end
  540.     @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
  541.     if @battleback_sprite.bitmap.width == 640 and
  542.        @battleback_sprite.bitmap.height == 320
  543.       @battleback_sprite.src_rect.set(0, 0, 1280, 640)
  544.       @base_zoom = 2.0
  545.       @battleback_sprite.zoom_x = @base_zoom
  546.       @battleback_sprite.zoom_y = @base_zoom
  547.       @real_y = 4
  548.       @battleback_sprite.x = 320
  549.       @battleback_sprite.y = @real_y
  550.       @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
  551.       @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
  552.     elsif @battleback_sprite.bitmap.width == 640 and
  553.           @battleback_sprite.bitmap.height == 480
  554.       @battleback_sprite.src_rect.set(0, 0, 960, 720)
  555.       @base_zoom = 1.5
  556.       @battleback_sprite.zoom_x = @base_zoom
  557.       @battleback_sprite.zoom_y = @base_zoom
  558.       @battleback_sprite.x = 320
  559.       @battleback_sprite.y = 0
  560.       @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
  561.       @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
  562.     else
  563.       @battleback_sprite.src_rect.set(0, 0, @battleback_sprite.bitmap.width,
  564.                                       @battleback_sprite.bitmap.height)
  565.       @base_zoom = 1.0
  566.       @battleback_sprite.zoom_x = @base_zoom
  567.       @battleback_sprite.zoom_y = @base_zoom
  568.       @battleback_sprite.x = 320
  569.       @battleback_sprite.y = 0
  570.       @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
  571.       @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
  572.     end
  573.   end
  574.   #--------------------------------------------------------------------------
  575.   # ● 画面のスクロール目標の位置・拡大率設定
  576.   #--------------------------------------------------------------------------
  577.   def screen_target(x, y, zoom)
  578.     return unless $scene.drive
  579.     @wait = $scene.scroll_time
  580.     @target_x = x
  581.     @target_y = y
  582.     @target_zoom = zoom
  583.     screen_over
  584.     @gap_x = @target_x - @real_x
  585.     @gap_y = @target_y - @real_y
  586.     @gap_zoom = @target_zoom - @real_zoom
  587.   end
  588.   #--------------------------------------------------------------------------
  589.   # ● 画面のスクロール
  590.   #--------------------------------------------------------------------------
  591.   def screen_scroll
  592.     if @wait > 0
  593.       @real_x = @target_x - @gap_x * (@wait ** 2) / ($scene.scroll_time ** 2)
  594.       @real_y = @target_y - @gap_y * (@wait ** 2) / ($scene.scroll_time ** 2)
  595.       @real_zoom = @target_zoom -
  596.                     @gap_zoom * (@wait ** 2) / ($scene.scroll_time ** 2)
  597.       @battleback_sprite.x = 320 + @real_x
  598.       @battleback_sprite.y = @real_y
  599.       @battleback_sprite.zoom_x = @base_zoom * @real_zoom
  600.       @battleback_sprite.zoom_y = @base_zoom * @real_zoom
  601.       @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
  602.       @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
  603.       @wait -= 1
  604.     end
  605.   end
  606.   #--------------------------------------------------------------------------
  607.   # ● スクリーンが画面外に出た時の補正処理
  608.   #--------------------------------------------------------------------------
  609.   def screen_over
  610.     width = @battleback_sprite.bitmap.width * @base_zoom * @target_zoom / 2
  611.     unless 324 + @target_x > width and 324 - @target_x > width
  612.       if 324 + @target_x > width
  613.         @target_x = width - 324
  614.       elsif 324 - @target_x > width
  615.         @target_x = 324 - width
  616.       end
  617.     end
  618.     height = @battleback_sprite.bitmap.height * @base_zoom * @target_zoom / 4
  619.     unless @target_y > height - 4 and 484 - @target_y > 3 * height
  620.       if @target_y > height - 4
  621.         @target_y = height - 4
  622.       elsif 484 - @target_y > 3 * height
  623.         @target_y = 484 - 3 * height
  624.       end
  625.     end
  626.   end
  627. end
  628.  
  629. #==============================================================================
  630. # ■ Game_Battler (分割定義 1)
  631. #------------------------------------------------------------------------------
  632. #  バトラーを扱うクラスです。このクラスは Game_Actor クラスと Game_Enemy クラ
  633. # スのスーパークラスとして使用されます。
  634. #==============================================================================
  635.  
  636. class Game_Battler
  637.   #--------------------------------------------------------------------------
  638.   # ● 公開インスタンス変数追加
  639.   #--------------------------------------------------------------------------
  640.   attr_accessor :up_level                  # レベルアップ数
  641.   attr_accessor :at                        # AT(タイムゲージ)
  642.   attr_accessor :atp                       # AT(表示用)
  643.   attr_accessor :rt                        # RP(詠唱ゲージ)
  644.   attr_accessor :rtp                       # RP(詠唱必要量)
  645.   attr_accessor :spell                     # 合成スキル発動中
  646.   attr_accessor :recover_hp                # HP回復量
  647.   attr_accessor :recover_sp                # SP回復量
  648.   attr_accessor :state_p                   # ステータス異常配列
  649.   attr_accessor :state_m                   # ステータス異常配列
  650.   attr_accessor :damage_sp                 # SPダメージ表示フラグ
  651.   attr_accessor :animation                 # アニメーション ID, Hitの配列
  652.   attr_accessor :phase
  653.   attr_accessor :wait
  654.   attr_accessor :target
  655.   attr_accessor :anime1
  656.   attr_accessor :anime2
  657.   attr_accessor :event
  658.   #--------------------------------------------------------------------------
  659.   # ● オブジェクト初期化
  660.   #--------------------------------------------------------------------------
  661.   alias :initialize_rtab :initialize
  662.   def initialize
  663.     initialize_rtab
  664.     @damage_pop = {}
  665.     @damage = {}
  666.     @damage_sp = {}
  667.     @critical = {}
  668.     @recover_hp = {}
  669.     @recover_sp = {}
  670.     @state_p = {}
  671.     @state_m = {}
  672.     @animation = []
  673.     @phase = 1
  674.     @wait = 0
  675.     @target = []
  676.     @anime1 = 0
  677.     @anime2 = 0
  678.     @event = 0
  679.   end
  680.   #--------------------------------------------------------------------------
  681.   # ● 存在判定
  682.   #--------------------------------------------------------------------------
  683.   def exist?
  684.     return (not @hidden and (@hp > 0 or @immortal or @damage.size > 0))
  685.   end
  686.   #--------------------------------------------------------------------------
  687.   # ● 残HP予測
  688.   #--------------------------------------------------------------------------
  689.   def rest_hp
  690.     # rest_hp に現HPを代入
  691.     rest_hp = @hp
  692.     # バトラーが受ける全ダメージをrest_hpに反映させる
  693.     for pre_damage in @damage
  694.       if pre_damage[1].is_a?(Numeric)
  695.         rest_hp -= pre_damage[1]
  696.       end
  697.     end
  698.     return rest_hp
  699.   end
  700.   #--------------------------------------------------------------------------
  701.   # ● ステートの解除
  702.   #     state_id : ステート ID
  703.   #     force    : 強制解除フラグ (オートステートの処理で使用)
  704.   #--------------------------------------------------------------------------
  705.   def remove_state(state_id, force = false)
  706.     # このステートが付加されている場合
  707.     if state?(state_id)
  708.       # 強制付加されたステートで、かつ解除が強制ではない場合
  709.       if @states_turn[state_id] == -1 and not force
  710.         # メソッド終了
  711.         return
  712.       end
  713.       # 現在の HP が 0 かつ オプション [HP 0 の状態とみなす] が有効の場合
  714.       if @hp == 0 and $data_states[state_id].zero_hp
  715.         # ほかに [HP 0 の状態とみなす] ステートがあるかどうか判定
  716.         zero_hp = false
  717.         for i in @states
  718.           if i != state_id and $data_states[i].zero_hp
  719.             zero_hp = true
  720.           end
  721.         end
  722.         # 戦闘不能を解除してよければ、HP を 1 に変更
  723.         if zero_hp == false
  724.           @hp = 1
  725.         end
  726.       end
  727.       unless self.movable?
  728.         # ステート ID を @states 配列および @states_turn ハッシュから削除
  729.         @states.delete(state_id)
  730.         @states_turn.delete(state_id)
  731.         if self.movable?
  732.           self.at = 0
  733.         end
  734.       else
  735.         # ステート ID を @states 配列および @states_turn ハッシュから削除
  736.         @states.delete(state_id)
  737.         @states_turn.delete(state_id)
  738.       end
  739.     end
  740.     # HP および SP の最大値チェック
  741.     @hp = [@hp, self.maxhp].min
  742.     @sp = [@sp, self.maxsp].min
  743.   end
  744.   #--------------------------------------------------------------------------
  745.   # ● 通常攻撃の効果適用
  746.   #     attacker : 攻撃者 (バトラー)
  747.   #--------------------------------------------------------------------------
  748.   def attack_effect(attacker)
  749.     # クリティカルフラグをクリア
  750.     self.critical[attacker] = false
  751.     state_p[attacker] = []
  752.     state_m[attacker] = []
  753.     # 第一命中判定
  754.     hit_result = (rand(100) < attacker.hit)
  755.     # 命中の場合
  756.     if hit_result == true
  757.       # 基本ダメージを計算
  758.       atk = [attacker.atk - self.pdef / 2, 0].max
  759.       self.damage[attacker] = atk * (20 + attacker.str) / 20
  760.       # 属性修正
  761.       self.damage[attacker] *= elements_correct(attacker.element_set)
  762.       self.damage[attacker] /= 100
  763.       # ダメージの符号が正の場合
  764.       if self.damage[attacker] > 0
  765.         # クリティカル修正
  766.         if rand(100) < 4 * attacker.dex / self.agi
  767.           self.damage[attacker] *= 2
  768.           self.critical[attacker] = true
  769.         end
  770.         # 防御修正
  771.         if self.guarding?
  772.           self.damage[attacker] /= 2
  773.         end
  774.       end
  775.       # 分散
  776.       if self.damage[attacker].abs > 0
  777.         amp = [self.damage[attacker].abs * 15 / 100, 1].max
  778.         self.damage[attacker] += rand(amp+1) + rand(amp+1) - amp
  779.       end
  780.       # 第二命中判定
  781.       eva = 8 * self.agi / attacker.dex + self.eva
  782.       hit = self.damage[attacker] < 0 ? 100 : 100 - eva
  783.       hit = self.cant_evade? ? 100 : hit
  784.       hit_result = (rand(100) < hit)
  785.     end
  786.     # 命中の場合
  787.     if hit_result == true
  788.       # ステート衝撃解除
  789.       remove_states_shock
  790.       # HP からダメージを減算
  791.       # ステート変化
  792.       @state_changed = false
  793.       states_plus(attacker, attacker.plus_state_set)
  794.       states_minus(attacker, attacker.minus_state_set)
  795.     # ミスの場合
  796.     else
  797.       # ダメージに "Miss" を設定
  798.       self.damage[attacker] = "Miss"
  799.       # クリティカルフラグをクリア
  800.       self.critical[attacker] = false
  801.     end
  802.     # メソッド終了
  803.     return true
  804.   end
  805.   #--------------------------------------------------------------------------
  806.   # ● スキルの効果適用
  807.   #     user  : スキルの使用者 (バトラー)
  808.   #     skill : スキル
  809.   #--------------------------------------------------------------------------
  810.   def skill_effect(user, skill)
  811.     # クリティカルフラグをクリア
  812.     self.critical[user] = false
  813.     state_p[user] = []
  814.     state_m[user] = []
  815.     # スキルの効果範囲が HP 1 以上の味方で、自分の HP が 0、
  816.     # またはスキルの効果範囲が HP 0 の味方で、自分の HP が 1 以上の場合
  817.     if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  818.        ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  819.       # メソッド終了
  820.       return false
  821.     end
  822.     # 有効フラグをクリア
  823.     effective = false
  824.     # コモンイベント ID が有効の場合は有効フラグをセット
  825.     effective |= skill.common_event_id > 0
  826.     # 第一命中判定
  827.     hit = skill.hit
  828.     if skill.atk_f > 0
  829.       hit *= user.hit / 100
  830.     end
  831.     hit_result = (rand(100) < hit)
  832.     # 不確実なスキルの場合は有効フラグをセット
  833.     effective |= hit < 100
  834.     # 命中の場合
  835.     if hit_result == true
  836.       # 威力を計算
  837.       power = skill.power + user.atk * skill.atk_f / 100
  838.       if power > 0
  839.         power -= self.pdef * skill.pdef_f / 200
  840.         power -= self.mdef * skill.mdef_f / 200
  841.         power = [power, 0].max
  842.       end
  843.       # 倍率を計算
  844.       rate = 20
  845.       rate += (user.str * skill.str_f / 100)
  846.       rate += (user.dex * skill.dex_f / 100)
  847.       rate += (user.agi * skill.agi_f / 100)
  848.       rate += (user.int * skill.int_f / 100)
  849.       # 基本ダメージを計算
  850.       self.damage[user] = power * rate / 20
  851.       # 属性修正
  852.       self.damage[user] *= elements_correct(skill.element_set)
  853.       self.damage[user] /= 100
  854.       # ダメージの符号が正の場合
  855.       if self.damage[user] > 0
  856.         # 防御修正
  857.         if self.guarding?
  858.           self.damage[user] /= 2
  859.         end
  860.       end
  861.       # 分散
  862.       if skill.variance > 0 and self.damage[user].abs > 0
  863.         amp = [self.damage[user].abs * skill.variance / 100, 1].max
  864.         self.damage[user] += rand(amp+1) + rand(amp+1) - amp
  865.       end
  866.       # 第二命中判定
  867.       eva = 8 * self.agi / user.dex + self.eva
  868.       hit = self.damage[user] < 0 ? 100 : 100 - eva * skill.eva_f / 100
  869.       hit = self.cant_evade? ? 100 : hit
  870.       hit_result = (rand(100) < hit)
  871.       # 不確実なスキルの場合は有効フラグをセット
  872.       effective |= hit < 100
  873.     end
  874.     # 命中の場合
  875.     if hit_result == true
  876.       # 威力 0 以外の物理攻撃の場合
  877.       if skill.power != 0 and skill.atk_f > 0
  878.         # ステート衝撃解除
  879.         remove_states_shock
  880.         # 有効フラグをセット
  881.         effective = true
  882.       end
  883.       # HP の変動判定
  884.       last_hp = [[self.hp - self.damage[user], self.maxhp].min, 0].max
  885.       # 効果判定
  886.       effective |= self.hp != last_hp
  887.       # ステート変化
  888.       @state_changed = false
  889.       effective |= states_plus(user, skill.plus_state_set)
  890.       effective |= states_minus(user, skill.minus_state_set)
  891.       unless $game_temp.in_battle
  892.         self.damage_effect(user, 1)
  893.       end
  894.       # 威力が 0 の場合
  895.       if skill.power == 0
  896.         # ダメージに空文字列を設定
  897.         self.damage[user] = ""
  898.         # ステートに変化がない場合
  899.         unless @state_changed
  900.           # ダメージに "Miss" を設定
  901.           self.damage[user] = "Miss"
  902.         end
  903.       end
  904.     # ミスの場合
  905.     else
  906.       # ダメージに "Miss" を設定
  907.       self.damage[user] = "Miss"
  908.     end
  909.     # 戦闘中でない場合
  910.     unless $game_temp.in_battle
  911.       # ダメージに nil を設定
  912.       self.damage[user] = nil
  913.     end
  914.     # メソッド終了
  915.     return effective
  916.   end
  917.   #--------------------------------------------------------------------------
  918.   # ● アイテムの効果適用
  919.   #     item : アイテム
  920.   #--------------------------------------------------------------------------
  921.   def item_effect(item, user = $game_party.actors[0])
  922.     # クリティカルフラグをクリア
  923.     self.critical[user] = false
  924.     state_p[user] = []
  925.     state_m[user] = []
  926.     self.recover_hp[user] = 0
  927.     self.recover_sp[user] = 0
  928.     # アイテムの効果範囲が HP 1 以上の味方で、自分の HP が 0、
  929.     # またはアイテムの効果範囲が HP 0 の味方で、自分の HP が 1 以上の場合
  930.     if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
  931.        ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
  932.       # メソッド終了
  933.       return false
  934.     end
  935.     # 有効フラグをクリア
  936.     effective = false
  937.     # コモンイベント ID が有効の場合は有効フラグをセット
  938.     effective |= item.common_event_id > 0
  939.     # 命中判定
  940.     hit_result = (rand(100) < item.hit)
  941.     # 不確実なスキルの場合は有効フラグをセット
  942.     effective |= item.hit < 100
  943.     # 命中の場合
  944.     if hit_result == true
  945.       # 回復量を計算
  946.       self.recover_hp[user] = maxhp * item.recover_hp_rate / 100 +
  947.                               item.recover_hp
  948.       self.recover_sp[user] = maxsp * item.recover_sp_rate / 100 +
  949.                               item.recover_sp
  950.       if self.recover_hp[user] < 0
  951.         self.recover_hp[user] += self.pdef * item.pdef_f / 20
  952.         self.recover_hp[user] += self.mdef * item.mdef_f / 20
  953.         self.recover_hp[user] = [self.recover_hp[user], 0].min
  954.       end
  955.       # 属性修正
  956.       self.recover_hp[user] *= elements_correct(item.element_set)
  957.       self.recover_hp[user] /= 100
  958.       self.recover_sp[user] *= elements_correct(item.element_set)
  959.       self.recover_sp[user] /= 100
  960.       # 分散
  961.       if item.variance > 0 and self.recover_hp[user].abs > 0
  962.         amp = [self.recover_hp[user].abs * item.variance / 100, 1].max
  963.         self.recover_hp[user] += rand(amp+1) + rand(amp+1) - amp
  964.       end
  965.       if item.variance > 0 and self.recover_sp[user].abs > 0
  966.         amp = [self.recover_sp[user].abs * item.variance / 100, 1].max
  967.         self.recover_sp[user] += rand(amp+1) + rand(amp+1) - amp
  968.       end
  969.       # 回復量の符号が負の場合
  970.       if self.recover_hp[user] < 0
  971.         # 防御修正
  972.         if self.guarding?
  973.           self.recover_hp[user] /= 2
  974.         end
  975.       end
  976.       # HP 回復量の符号を反転し、ダメージの値に設定
  977.       self.damage[user] = -self.recover_hp[user]
  978.       # HP および SP の変動判定
  979.       last_hp = [[self.hp + self.recover_hp[user], self.maxhp].min, 0].max
  980.       last_sp = [[self.sp + self.recover_sp[user], self.maxsp].min, 0].max
  981.       effective |= self.hp != last_hp
  982.       effective |= self.sp != last_sp
  983.       # ステート変化
  984.       @state_changed = false
  985.       effective |= states_plus(user, item.plus_state_set)
  986.       effective |= states_minus(user, item.minus_state_set)
  987.       unless $game_temp.in_battle
  988.         self.damage_effect(user, 2)
  989.       end
  990.       # パラメータ上昇値が有効の場合
  991.       if item.parameter_type > 0 and item.parameter_points != 0
  992.         # パラメータで分岐
  993.         case item.parameter_type
  994.         when 1  # MaxHP
  995.           @maxhp_plus += item.parameter_points
  996.         when 2  # MaxSP
  997.           @maxsp_plus += item.parameter_points
  998.         when 3  # 腕力
  999.           @str_plus += item.parameter_points
  1000.         when 4  # 器用さ
  1001.           @dex_plus += item.parameter_points
  1002.         when 5  # 素早さ
  1003.           @agi_plus += item.parameter_points
  1004.         when 6  # 魔力
  1005.           @int_plus += item.parameter_points
  1006.         end
  1007.         # 有効フラグをセット
  1008.         effective = true
  1009.       end
  1010.       # HP 回復率と回復量が 0 の場合
  1011.       if item.recover_hp_rate == 0 and item.recover_hp == 0
  1012.         # ダメージに空文字列を設定
  1013.         self.damage[user] = ""
  1014.         # SP 回復率と回復量が 0、パラメータ上昇値が無効の場合
  1015.         if item.recover_sp_rate == 0 and item.recover_sp == 0 and
  1016.            (item.parameter_type == 0 or item.parameter_points == 0)
  1017.           # ステートに変化がない場合
  1018.           unless @state_changed
  1019.             # ダメージに "Miss" を設定
  1020.             self.damage[user] = "Miss"
  1021.           end
  1022.         end
  1023.       end
  1024.     # ミスの場合
  1025.     else
  1026.       # ダメージに "Miss" を設定
  1027.       self.damage[user] = "Miss"
  1028.     end
  1029.     # 戦闘中でない場合
  1030.     unless $game_temp.in_battle
  1031.       # ダメージに nil を設定
  1032.       self.damage[user] = nil
  1033.     end
  1034.     # メソッド終了
  1035.     return effective
  1036.   end
  1037.   #--------------------------------------------------------------------------
  1038.   # ● ステート変化 (+) の適用
  1039.   #     plus_state_set  : ステート変化 (+)
  1040.   #--------------------------------------------------------------------------
  1041.   def states_plus(battler, plus_state_set)
  1042.     # 有効フラグをクリア
  1043.     effective = false
  1044.     # ループ (付加するステート)
  1045.     for i in plus_state_set
  1046.       # このステートが防御されていない場合
  1047.       unless self.state_guard?(i)
  1048.         # このステートがフルでなければ有効フラグをセット
  1049.         effective |= self.state_full?(i) == false
  1050.         # ステートが [抵抗しない] の場合
  1051.         if $data_states[i].nonresistance
  1052.           # ステート変化フラグをセット
  1053.           @state_changed = true
  1054.           # ステートを付加
  1055.           self.state_p[battler].push(i)
  1056.         # このステートがフルではない場合
  1057.         elsif self.state_full?(i) == false
  1058.           # ステート有効度を確率に変換し、乱数と比較
  1059.           if rand(100) < [0,100,80,60,40,20,0][self.state_ranks[i]]
  1060.             # ステート変化フラグをセット
  1061.             @state_changed = true
  1062.             # ステートを付加
  1063.             self.state_p[battler].push(i)
  1064.           end
  1065.         end
  1066.       end
  1067.     end
  1068.     # メソッド終了
  1069.     return effective
  1070.   end
  1071.   #--------------------------------------------------------------------------
  1072.   # ● ステート変化 (-) の適用
  1073.   #     minus_state_set : ステート変化 (-)
  1074.   #--------------------------------------------------------------------------
  1075.   def states_minus(battler, minus_state_set)
  1076.     # 有効フラグをクリア
  1077.     effective = false
  1078.     # ループ (解除するステート)
  1079.     for i in minus_state_set
  1080.       # このステートが付加されていれば有効フラグをセット
  1081.       effective |= self.state?(i)
  1082.       # ステート変化フラグをセット
  1083.       @state_changed = true
  1084.       # ステートを解除
  1085.       self.state_m[battler].push(i)
  1086.     end
  1087.     # メソッド終了
  1088.     return effective
  1089.   end
  1090.   #--------------------------------------------------------------------------
  1091.   # ● ダメージ演算
  1092.   #--------------------------------------------------------------------------
  1093.   def damage_effect(battler, item)
  1094.     if item == 2
  1095.       self.hp += self.recover_hp[battler]
  1096.       self.sp += self.recover_sp[battler]
  1097.       if self.recover_sp[battler] != 0
  1098.         self.damage_sp[battler] = -self.recover_sp[battler]
  1099.       end
  1100.       self.recover_hp.delete(battler)
  1101.       self.recover_sp.delete(battler)
  1102.     else
  1103.       if self.damage[battler].class != String
  1104.         self.hp -= self.damage[battler]
  1105.       end
  1106.     end
  1107.     for i in self.state_p[battler]
  1108.       add_state(i)
  1109.     end
  1110.     for i in self.state_m[battler]
  1111.       remove_state(i)
  1112.     end
  1113.   end
  1114.   #--------------------------------------------------------------------------
  1115.   # ● スリップダメージの効果適用
  1116.   #--------------------------------------------------------------------------
  1117.   def slip_damage_effect
  1118.     # ダメージを設定
  1119.     self.damage["slip"] = self.maxhp / 10
  1120.     # 分散
  1121.     if self.damage["slip"].abs > 0
  1122.       amp = [self.damage["slip"].abs * 15 / 100, 1].max
  1123.       self.damage["slip"] += rand(amp+1) + rand(amp+1) - amp
  1124.     end
  1125.     # HP からダメージを減算
  1126.     self.hp -= self.damage["slip"]
  1127.     # メソッド終了
  1128.     return true
  1129.   end
  1130. end
  1131.  
  1132. #==============================================================================
  1133. # ■ Game_BattleAction
  1134. #------------------------------------------------------------------------------
  1135. #  アクション (戦闘中の行動) を扱うクラスです。このクラスは Game_Battler クラ
  1136. # スの内部で使用されます。
  1137. #==============================================================================
  1138.  
  1139. class Game_BattleAction
  1140.   #--------------------------------------------------------------------------
  1141.   # ● 公開インスタンス変数
  1142.   #--------------------------------------------------------------------------
  1143.   attr_accessor :spell_id                 # 合体魔法用スキル ID
  1144.   attr_accessor :force_kind               # 種別 (基本 / スキル / アイテム)
  1145.   attr_accessor :force_basic              # 基本 (攻撃 / 防御 / 逃げる)
  1146.   attr_accessor :force_skill_id           # スキル ID
  1147.   #--------------------------------------------------------------------------
  1148.   # ● 有効判定
  1149.   #--------------------------------------------------------------------------
  1150.   def valid?
  1151.     return (not (@force_kind == 0 and @force_basic == 3))
  1152.   end
  1153. end
  1154.  
  1155. #==============================================================================
  1156. # ■ Game_Actor
  1157. #------------------------------------------------------------------------------
  1158. #  アクターを扱うクラスです。このクラスは Game_Actors クラス ($game_actors)
  1159. # の内部で使用され、Game_Party クラス ($game_party) からも参照されます。
  1160. #==============================================================================
  1161.  
  1162. class Game_Actor < Game_Battler
  1163.   def skill_can_use?(skill_id)
  1164.     return super
  1165.   end
  1166. end
  1167.  
  1168. #==============================================================================
  1169. # ■ Game_Enemy
  1170. #------------------------------------------------------------------------------
  1171. #  エネミーを扱うクラスです。このクラスは Game_Troop クラス ($game_troop) の
  1172. # 内部で使用されます。
  1173. #==============================================================================
  1174.  
  1175. class Game_Enemy < Game_Battler
  1176.   #--------------------------------------------------------------------------
  1177.   # ● 公開インスタンス変数
  1178.   #--------------------------------------------------------------------------
  1179.   attr_accessor :height                  # 画像の高さ
  1180.   attr_accessor :real_x                  # X座標補正
  1181.   attr_accessor :real_y                  # Y座標補正
  1182.   attr_accessor :real_zoom               # 拡大率
  1183.   #--------------------------------------------------------------------------
  1184.   # ● オブジェクト初期化
  1185.   #     troop_id     : トループ ID
  1186.   #     member_index : トループメンバーのインデックス
  1187.   #--------------------------------------------------------------------------
  1188.   def initialize(troop_id, member_index)
  1189.     super()
  1190.     @troop_id = troop_id
  1191.     @member_index = member_index
  1192.     troop = $data_troops[@troop_id]
  1193.     @enemy_id = troop.members[@member_index].enemy_id
  1194.     enemy = $data_enemies[@enemy_id]
  1195.     @battler_name = enemy.battler_name
  1196.     @battler_hue = enemy.battler_hue
  1197.     @hp = maxhp
  1198.     @sp = maxsp
  1199.     @real_x = 0
  1200.     @real_y = 0
  1201.     @real_zoom = 1.0
  1202.     @fly = 0
  1203.     enemy.name.sub(/\\[Ff]\[([0-9]+)\]/) {@fly = $1.to_i}
  1204.     @hidden = troop.members[@member_index].hidden
  1205.     @immortal = troop.members[@member_index].immortal
  1206.   end
  1207.   alias :true_x :screen_x
  1208.   alias :true_y :screen_y
  1209.   #--------------------------------------------------------------------------
  1210.   # ● バトル画面 X 座標の取得
  1211.   #--------------------------------------------------------------------------
  1212.   def screen_x
  1213.     return 320 + (true_x - 320) * @real_zoom + @real_x
  1214.   end
  1215.   #--------------------------------------------------------------------------
  1216.   # ● バトル画面 Y 座標の取得
  1217.   #--------------------------------------------------------------------------
  1218.   def screen_y
  1219.     return true_y * @real_zoom + @real_y
  1220.   end
  1221.   #--------------------------------------------------------------------------
  1222.   # ● バトル画面 Z 座標の取得
  1223.   #--------------------------------------------------------------------------
  1224.   def screen_z
  1225.     return true_y + @fly
  1226.   end
  1227.   #--------------------------------------------------------------------------
  1228.   # ● バトル画面 拡大率の取得
  1229.   #--------------------------------------------------------------------------
  1230.   def zoom
  1231.     return ($scene.zoom_rate[1] - $scene.zoom_rate[0]) *
  1232.                           (true_y + @fly) / 320 + $scene.zoom_rate[0]
  1233.   end
  1234.   #--------------------------------------------------------------------------
  1235.   # ● 攻撃用、バトル画面 X 座標の取得
  1236.   #--------------------------------------------------------------------------
  1237.   def attack_x(z)
  1238.     return (320 - true_x) * z * 0.75
  1239.   end
  1240.   #--------------------------------------------------------------------------
  1241.   # ● 攻撃用、バトル画面 Y 座標の取得
  1242.   #--------------------------------------------------------------------------
  1243.   def attack_y(z)
  1244.     return (160 - (true_y + @fly / 4) * z + @height * zoom * z / 2) * 0.75
  1245.   end
  1246.   #--------------------------------------------------------------------------
  1247.   # ● アクション作成
  1248.   #--------------------------------------------------------------------------
  1249.   def make_action
  1250.     # カレントアクションをクリア
  1251.     self.current_action.clear
  1252.     # 動けない場合
  1253.     unless self.inputable?
  1254.       # メソッド終了
  1255.       return
  1256.     end
  1257.     # 現在有効なアクションを抽出
  1258.     available_actions = []
  1259.     rating_max = 0
  1260.     for action in self.actions
  1261.       # ターン 条件確認
  1262.       n = $game_temp.battle_turn
  1263.       a = action.condition_turn_a
  1264.       b = action.condition_turn_b
  1265.       if (b == 0 and n != a) or
  1266.          (b > 0 and (n < 1 or n < a or n % b != a % b))
  1267.         next
  1268.       end
  1269.       # HP 条件確認
  1270.       if self.hp * 100.0 / self.maxhp > action.condition_hp
  1271.         next
  1272.       end
  1273.       # レベル 条件確認
  1274.       if $game_party.max_level < action.condition_level
  1275.         next
  1276.       end
  1277.       # スイッチ 条件確認
  1278.       switch_id = action.condition_switch_id
  1279.       if switch_id > 0 and $game_switches[switch_id] == false
  1280.         next
  1281.       end
  1282.       # スキル使用可能 条件確認
  1283.       if action.kind == 1
  1284.         unless self.skill_can_use?(action.skill_id)
  1285.           next
  1286.         end
  1287.       end
  1288.       # 条件に該当 : このアクションを追加
  1289.       available_actions.push(action)
  1290.       if action.rating > rating_max
  1291.         rating_max = action.rating
  1292.       end
  1293.     end
  1294.     # 最大のレーティング値を 3 として合計を計算 (0 以下は除外)
  1295.     ratings_total = 0
  1296.     for action in available_actions
  1297.       if action.rating > rating_max - 3
  1298.         ratings_total += action.rating - (rating_max - 3)
  1299.       end
  1300.     end
  1301.     # レーティングの合計が 0 ではない場合
  1302.     if ratings_total > 0
  1303.       # 乱数を作成
  1304.       value = rand(ratings_total)
  1305.       # 作成した乱数に対応するものをカレントアクションに設定
  1306.       for action in available_actions
  1307.         if action.rating > rating_max - 3
  1308.           if value < action.rating - (rating_max - 3)
  1309.             self.current_action.kind = action.kind
  1310.             self.current_action.basic = action.basic
  1311.             self.current_action.skill_id = action.skill_id
  1312.             self.current_action.decide_random_target_for_enemy
  1313.             return
  1314.           else
  1315.             value -= action.rating - (rating_max - 3)
  1316.           end
  1317.         end
  1318.       end
  1319.     end
  1320.   end
  1321. end
  1322.  
  1323. #==============================================================================
  1324. # ■ Game_Party
  1325. #------------------------------------------------------------------------------
  1326. #  パーティを扱うクラスです。ゴールドやアイテムなどの情報が含まれます。このク
  1327. # ラスのインスタンスは $game_party で参照されます。
  1328. #==============================================================================
  1329.  
  1330. class Game_Party
  1331.   #--------------------------------------------------------------------------
  1332.   # ● 全滅判定
  1333.   #--------------------------------------------------------------------------
  1334.   def all_dead?
  1335.     # パーティ人数が 0 人の場合
  1336.     if $game_party.actors.size == 0
  1337.       return false
  1338.     end
  1339.     # HP 0 以上のアクターがパーティにいる場合
  1340.     for actor in @actors
  1341.       if actor.rest_hp > 0
  1342.         return false
  1343.       end
  1344.     end
  1345.     # 全滅
  1346.     return true
  1347.   end
  1348.   #--------------------------------------------------------------------------
  1349.   # ● 対象アクターのランダムな決定
  1350.   #     hp0 : HP 0 のアクターに限る
  1351.   #--------------------------------------------------------------------------
  1352.   # オリジナルのターゲット決定ルーチンを smooth_target_actor_rtab と名前変更
  1353.   alias :random_target_actor_rtab :random_target_actor
  1354.   def random_target_actor(hp0 = false)
  1355.     # ルーレットを初期化
  1356.     roulette = []
  1357.     # ループ
  1358.     for actor in @actors
  1359.       # 条件に該当する場合
  1360.       if (not hp0 and actor.exist? and actor.rest_hp > 0) or
  1361.           (hp0 and actor.hp0?)
  1362.         # アクターのクラスの [位置] を取得
  1363.         position = $data_classes[actor.class_id].position
  1364.         # 前衛のとき n = 4、中衛のとき n = 3、後衛のとき n = 2
  1365.         n = 4 - position
  1366.         # ルーレットにアクターを n 回追加
  1367.         n.times do
  1368.           roulette.push(actor)
  1369.         end
  1370.       end
  1371.     end
  1372.     # ルーレットのサイズが 0 の場合
  1373.     if roulette.size == 0
  1374.       return random_target_actor_rtab(hp0)
  1375.     end
  1376.     # ルーレットを回し、アクターを決定
  1377.     return roulette[rand(roulette.size)]
  1378.   end
  1379.   #--------------------------------------------------------------------------
  1380.   # ● 対象アクターのスムーズな決定
  1381.   #     actor_index : アクターインデックス
  1382.   #--------------------------------------------------------------------------
  1383.   # オリジナルのターゲット決定ルーチンを smooth_target_actor_rtab と名前変更
  1384.   alias :smooth_target_actor_rtab :smooth_target_actor
  1385.   def smooth_target_actor(actor_index)
  1386.     # アクターを取得
  1387.     actor = @actors[actor_index]
  1388.     # アクターが存在する場合
  1389.     if actor != nil and actor.exist? and actor.rest_hp > 0
  1390.       return actor
  1391.     end
  1392.     # ループ
  1393.     for actor in @actors
  1394.       # アクターが存在する場合
  1395.       if actor.exist? and actor.rest_hp > 0
  1396.         return actor
  1397.       end
  1398.     end
  1399.     # 味方が全滅している場合、オリジナルのターゲット決定ルーチンを実行する
  1400.     return smooth_target_actor_rtab(actor_index)
  1401.   end
  1402. end
  1403.  
  1404. #==============================================================================
  1405. # ■ Game_Troop
  1406. #------------------------------------------------------------------------------
  1407. #  トループを扱うクラスです。このクラスのインスタンスは $game_troop で参照さ
  1408. # れます。
  1409. #==============================================================================
  1410.  
  1411. class Game_Troop
  1412.   #--------------------------------------------------------------------------
  1413.   # ● 対象エネミーのランダムな決定
  1414.   #     hp0 : HP 0 のエネミーに限る
  1415.   #--------------------------------------------------------------------------
  1416.   # オリジナルのターゲット決定ルーチンを random_target_enemy_rtab と名前変更
  1417.   alias :random_target_enemy_rtab :random_target_enemy
  1418.   def random_target_enemy(hp0 = false)
  1419.     # ルーレットを初期化
  1420.     roulette = []
  1421.     # ループ
  1422.     for enemy in @enemies
  1423.       # 条件に該当する場合
  1424.       if (not hp0 and enemy.exist? and enemy.rest_hp > 0) or
  1425.           (hp0 and enemy.hp0?)
  1426.         # ルーレットにエネミーを追加
  1427.         roulette.push(enemy)
  1428.       end
  1429.     end
  1430.     # ルーレットのサイズが 0 の場合
  1431.     if roulette.size == 0
  1432.       return random_target_enemy_rtab(hp0)
  1433.     end
  1434.     # ルーレットを回し、エネミーを決定
  1435.     return roulette[rand(roulette.size)]
  1436.   end
  1437.   #--------------------------------------------------------------------------
  1438.   # ● 対象エネミーのスムーズな決定
  1439.   #     enemy_index : エネミーインデックス
  1440.   #--------------------------------------------------------------------------
  1441.   # オリジナルのターゲット決定ルーチンを smooth_target_enemy_rtab と名前変更
  1442.   alias :smooth_target_enemy_rtab :smooth_target_enemy
  1443.   def smooth_target_enemy(enemy_index)
  1444.     # エネミーを取得
  1445.     enemy = @enemies[enemy_index]
  1446.     # エネミーが存在する場合
  1447.     if enemy != nil and enemy.exist? and enemy.rest_hp > 0
  1448.       return enemy
  1449.     end
  1450.     # ループ
  1451.     for enemy in @enemies
  1452.       # エネミーが存在する場合
  1453.       if enemy.exist? and enemy.rest_hp > 0
  1454.         return enemy
  1455.       end
  1456.     end
  1457.     # 敵が全滅している場合、再度敵の検索を行う
  1458.     return smooth_target_enemy_rtab(enemy_index)
  1459.   end
  1460. end
  1461.  
  1462. #==============================================================================
  1463. # ■ Sprite_Battler
  1464. #------------------------------------------------------------------------------
  1465. #  バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、
  1466. # スプライトの状態を自動的に変化させます。
  1467. #==============================================================================
  1468.  
  1469. class Sprite_Battler < RPG::Sprite
  1470.   #--------------------------------------------------------------------------
  1471.   # ● フレーム更新
  1472.   #--------------------------------------------------------------------------
  1473.   def update
  1474.     super
  1475.     # バトラーが nil の場合
  1476.     if @battler == nil
  1477.       self.bitmap = nil
  1478.       loop_animation(nil)
  1479.       return
  1480.     end
  1481.     # ファイル名か色相が現在のものと異なる場合
  1482.     if @battler.battler_name != @battler_name or
  1483.        @battler.battler_hue != @battler_hue
  1484.       # ビットマップを取得、設定
  1485.       @battler_name = @battler.battler_name
  1486.       @battler_hue = @battler.battler_hue
  1487.       self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  1488.       @width = bitmap.width
  1489.       @height = bitmap.height
  1490.       self.ox = @width / 2
  1491.       self.oy = @height
  1492.       if @battler.is_a?(Game_Enemy)
  1493.         @battler.height = @height
  1494.       end
  1495.       # 戦闘不能または隠れ状態なら不透明度を 0 にする
  1496.       if @battler.dead? or @battler.hidden
  1497.         self.opacity = 0
  1498.       end
  1499.     end
  1500.     # アニメーション ID が現在のものと異なる場合
  1501.     if @battler.state_animation_id != @state_animation_id
  1502.       @state_animation_id = @battler.state_animation_id
  1503.       loop_animation($data_animations[@state_animation_id])
  1504.     end
  1505.     # 表示されるべきアクターの場合
  1506.     if @battler.is_a?(Game_Actor) and @battler_visible
  1507.       # メインフェーズでないときは不透明度をやや下げる
  1508.       if $game_temp.battle_main_phase
  1509.         self.opacity += 3 if self.opacity < 255
  1510.       else
  1511.         self.opacity -= 3 if self.opacity > 207
  1512.       end
  1513.     end
  1514.     # 明滅
  1515.     if @battler.blink
  1516.       blink_on
  1517.     else
  1518.       blink_off
  1519.     end
  1520.     # 不可視の場合
  1521.     unless @battler_visible
  1522.       # 出現
  1523.       if not @battler.hidden and not @battler.dead? and
  1524.          (@battler.damage.size < 2 or @battler.damage_pop.size < 2)
  1525.         appear
  1526.         @battler_visible = true
  1527.       end
  1528.     end
  1529.     # ダメージ
  1530.     for battler in @battler.damage_pop
  1531.       if battler[0].class == Array
  1532.         if battler[0][1] >= 0
  1533.           $scene.skill_se
  1534.         else
  1535.           $scene.levelup_se
  1536.         end
  1537.         damage(@battler.damage[battler[0]], false, 2)
  1538.       else
  1539.         damage(@battler.damage[battler[0]], @battler.critical[battler[0]])
  1540.       end
  1541.       if @battler.damage_sp.include?(battler[0])
  1542.         damage(@battler.damage_sp[battler[0]],
  1543.                 @battler.critical[battler[0]], 1)
  1544.         @battler.damage_sp.delete(battler[0])
  1545.       end
  1546.       @battler.damage_pop.delete(battler[0])
  1547.       @battler.damage.delete(battler[0])
  1548.       @battler.critical.delete(battler[0])
  1549.     end
  1550.     # 可視の場合
  1551.     if @battler_visible
  1552.       # 逃走
  1553.       if @battler.hidden
  1554.         $game_system.se_play($data_system.escape_se)
  1555.         escape
  1556.         @battler_visible = false
  1557.       end
  1558.       # 白フラッシュ
  1559.       if @battler.white_flash
  1560.         whiten
  1561.         @battler.white_flash = false
  1562.       end
  1563.       # アニメーション
  1564.       unless @battler.animation.empty?
  1565.         for animation in @battler.animation.reverse
  1566.           animation($data_animations[animation[0]], animation[1])
  1567.           @battler.animation.delete(animation)
  1568.         end
  1569.       end
  1570.       # コラプス
  1571.       if @battler.damage.empty? and @battler.dead?
  1572.         if $scene.dead_ok?(@battler)
  1573.           if @battler.is_a?(Game_Enemy)
  1574.             $game_system.se_play($data_system.enemy_collapse_se)
  1575.           else
  1576.             $game_system.se_play($data_system.actor_collapse_se)
  1577.           end
  1578.           collapse
  1579.           @battler_visible = false
  1580.         end
  1581.       end
  1582.     end
  1583.     # スプライトの座標を設定
  1584.     self.x = @battler.screen_x
  1585.     self.y = @battler.screen_y
  1586.     self.z = @battler.screen_z
  1587.     if @battler.is_a?(Game_Enemy)
  1588.       self.zoom_x = @battler.real_zoom * @battler.zoom
  1589.       self.zoom_y = @battler.real_zoom * @battler.zoom
  1590.     end
  1591.   end
  1592. end
  1593.  
  1594. #==============================================================================
  1595. # ■ Window_Base
  1596. #------------------------------------------------------------------------------
  1597. #  ゲーム中のすべてのウィンドウのスーパークラスです。
  1598. #==============================================================================
  1599.  
  1600. class Window_Base < Window
  1601.   #--------------------------------------------------------------------------
  1602.   # ● ゲージの描画
  1603.   #--------------------------------------------------------------------------
  1604.   def gauge_rect_at(width, height, align3,
  1605.                     color1, color2, color3, color4, color5, color6, color7,
  1606.                     color8, color9, color10, color11, color12, grade1, grade2)
  1607.     # 枠描画
  1608.     @at_gauge = Bitmap.new(width, height * 5)
  1609.     @at_gauge.fill_rect(0, 0, width, height, color1)
  1610.     @at_gauge.fill_rect(1, 1, width - 2, height - 2, color2)
  1611.     if (align3 == 1 and grade1 == 0) or grade1 > 0
  1612.       color = color3
  1613.       color3 = color4
  1614.       color4 = color
  1615.     end
  1616.     if (align3 == 1 and grade2 == 0) or grade2 > 0
  1617.       color = color5
  1618.       color5 = color6
  1619.       color6 = color
  1620.       color = color7
  1621.       color7 = color8
  1622.       color8 = color
  1623.       color = color9
  1624.       color9 = color10
  1625.       color10 = color
  1626.       color = color11
  1627.       color11 = color12
  1628.       color12 = color
  1629.     end
  1630.     if align3 == 0
  1631.       if grade1 == 2
  1632.         grade1 = 3
  1633.       end
  1634.       if grade2 == 2
  1635.         grade2 = 3
  1636.       end
  1637.     end
  1638.     # 空ゲージの描画 縦にグラデーション表示
  1639.     @at_gauge.gradation_rect(2, 2, width - 4, height - 4,
  1640.                                   color3, color4, grade1)
  1641.     # 実ゲージの描画
  1642.     @at_gauge.gradation_rect(2, height + 2, width- 4, height - 4,
  1643.                                   color5, color6, grade2)
  1644.     @at_gauge.gradation_rect(2, height * 2 + 2, width- 4, height - 4,
  1645.                                   color7, color8, grade2)
  1646.     @at_gauge.gradation_rect(2, height * 3 + 2, width- 4, height - 4,
  1647.                                   color9, color10, grade2)
  1648.     @at_gauge.gradation_rect(2, height * 4 + 2, width- 4, height - 4,
  1649.                                   color11, color12, grade2)
  1650.   end
  1651. end
  1652.  
  1653. #==============================================================================
  1654. # ■ Window_Help
  1655. #------------------------------------------------------------------------------
  1656. #  スキルやアイテムの説明、アクターのステータスなどを表示するウィンドウです。
  1657. #==============================================================================
  1658.  
  1659. class Window_Help < Window_Base
  1660.   #--------------------------------------------------------------------------
  1661.   # ● エネミー設定
  1662.   #     enemy : 名前とステートを表示するエネミー
  1663.   #--------------------------------------------------------------------------
  1664.   def set_enemy(enemy)
  1665.     text = enemy.name.sub(/\\[Ff]\[([0-9]+)\]/) {""}
  1666.     state_text = make_battler_state_text(enemy, 112, false)
  1667.     if state_text != ""
  1668.       text += "  " + state_text
  1669.     end
  1670.     set_text(text, 1)
  1671.   end
  1672. end
  1673.  
  1674. #==============================================================================
  1675. # ■ Window_BattleStatus
  1676. #------------------------------------------------------------------------------
  1677. #  バトル画面でパーティメンバーのステータスを表示するウィンドウです。
  1678. #==============================================================================
  1679.  
  1680. class Window_BattleStatus < Window_Base
  1681.   #--------------------------------------------------------------------------
  1682.   # ● オブジェクト初期化
  1683.   #--------------------------------------------------------------------------
  1684.   def initialize
  1685.     x = (4 - $game_party.actors.size) * 80
  1686.     width = $game_party.actors.size * 160
  1687.     super(x, 320, width, 160)
  1688.     self.back_opacity = 160
  1689.     @actor_window = []
  1690.     for i in 0...$game_party.actors.size
  1691.       @actor_window.push(Window_ActorStatus.new(i, x + i * 160))
  1692.     end
  1693.     @level_up_flags = [false, false, false, false]
  1694.     refresh
  1695.   end
  1696.   #--------------------------------------------------------------------------
  1697.   # ● 解放
  1698.   #--------------------------------------------------------------------------
  1699.   def dispose
  1700.     for window in @actor_window
  1701.       window.dispose
  1702.     end
  1703.     super
  1704.   end
  1705.   #--------------------------------------------------------------------------
  1706.   # ● リフレッシュ
  1707.   #--------------------------------------------------------------------------
  1708.   def refresh(number = 0)
  1709.     if number == 0
  1710.       cnt = 0
  1711.       for window in @actor_window
  1712.         window.refresh(@level_up_flags[cnt])
  1713.         cnt += 1
  1714.       end
  1715.     else
  1716.       @actor_window[number - 1].refresh(@level_up_flags[number - 1])
  1717.     end
  1718.   end
  1719.   #--------------------------------------------------------------------------
  1720.   # ● ATゲージリフレッシュ
  1721.   #--------------------------------------------------------------------------
  1722.   def at_refresh(number = 0)
  1723.     if number == 0
  1724.       for window in @actor_window
  1725.         window.at_refresh
  1726.       end
  1727.     else
  1728.       @actor_window[number - 1].at_refresh
  1729.     end
  1730.   end
  1731.   #--------------------------------------------------------------------------
  1732.   # ● フレーム更新
  1733.   #--------------------------------------------------------------------------
  1734.   def update
  1735.     super
  1736.     if self.x != (4 - $game_party.actors.size) * 80
  1737.       self.x = (4 - $game_party.actors.size) * 80
  1738.       self.width = $game_party.actors.size * 160
  1739.       for window in @actor_window
  1740.         window.dispose
  1741.       end
  1742.       @actor_window = []
  1743.       for i in 0...$game_party.actors.size
  1744.         @actor_window.push(Window_ActorStatus.new(i, x + i * 160))
  1745.       end
  1746.       refresh
  1747.     end
  1748.     for window in @actor_window
  1749.       window.update
  1750.     end
  1751.   end
  1752. end
  1753.  
  1754. #==============================================================================
  1755. # ■ Window_ActorStatus
  1756. #------------------------------------------------------------------------------
  1757. #  バトル画面でパーティメンバーのステータスをそれぞれ表示するウィンドウです。
  1758. #==============================================================================
  1759.  
  1760. class Window_ActorStatus < Window_Base
  1761.   #--------------------------------------------------------------------------
  1762.   # ● オブジェクト初期化
  1763.   #--------------------------------------------------------------------------
  1764.   def initialize(id, x)
  1765.     @actor_num = id
  1766.     super(x, 320, 160, 160)
  1767.     self.contents = Bitmap.new(width - 32, height - 32)
  1768.     self.opacity = 255
  1769.     self.back_opacity = 255
  1770.     actor = $game_party.actors[@actor_num]
  1771.     @actor_nm = actor.name
  1772.     @actor_mhp = actor.maxhp
  1773.     @actor_msp = actor.maxsp
  1774.     @actor_hp = actor.hp
  1775.     @actor_sp = actor.sp
  1776.     @actor_st = make_battler_state_text(actor, 120, true)
  1777.     @status_window = []
  1778.     for i in 0...5
  1779.       @status_window.push(Window_DetailsStatus.new(actor, i, x))
  1780.     end
  1781.     refresh(false)
  1782.   end
  1783.   #--------------------------------------------------------------------------
  1784.   # ● 解放
  1785.   #--------------------------------------------------------------------------
  1786.   def dispose
  1787.     for i in 0...5
  1788.       @status_window[i].dispose
  1789.     end
  1790.     super
  1791.   end
  1792.   #--------------------------------------------------------------------------
  1793.   # ● リフレッシュ
  1794.   #--------------------------------------------------------------------------
  1795.   def refresh(level_up_flags)
  1796.     self.contents.clear
  1797.     actor = $game_party.actors[@actor_num]
  1798.     @status_window[0].refresh(actor) if @actor_nm != actor.name
  1799.     @status_window[1].refresh(actor) if
  1800.       @actor_mhp != actor.maxhp or @actor_hp != actor.hp
  1801.     @status_window[2].refresh(actor) if
  1802.       @actor_msp != actor.maxsp or @actor_sp != actor.sp
  1803.     @status_window[3].refresh(actor, level_up_flags) if
  1804.       @actor_st != make_battler_state_text(actor, 120, true) or level_up_flags
  1805.     @actor_nm = actor.name
  1806.     @actor_mhp = actor.maxhp
  1807.     @actor_msp = actor.maxsp
  1808.     @actor_hp = actor.hp
  1809.     @actor_sp = actor.sp
  1810.     @actor_st = make_battler_state_text(actor, 120, true)
  1811.   end
  1812.   #--------------------------------------------------------------------------
  1813.   # ● ATゲージリフレッシュ
  1814.   #--------------------------------------------------------------------------
  1815.   def at_refresh
  1816.     @status_window[4].refresh($game_party.actors[@actor_num])
  1817.   end
  1818.   #--------------------------------------------------------------------------
  1819.   # ● フレーム更新
  1820.   #--------------------------------------------------------------------------
  1821.   def update
  1822.     for window in @status_window
  1823.       window.update
  1824.     end
  1825.   end
  1826. end
  1827.  
  1828. #==============================================================================
  1829. # ■ Window_ActorStatus
  1830. #------------------------------------------------------------------------------
  1831. #  バトル画面でパーティメンバーのステータスをそれぞれ表示するウィンドウです。
  1832. #==============================================================================
  1833.  
  1834. class Window_ActorStatus < Window_Base
  1835.   #--------------------------------------------------------------------------
  1836.   # ● オブジェクト初期化
  1837.   #--------------------------------------------------------------------------
  1838.   def initialize(id, x)
  1839.     @actor_num = id
  1840.     super(x, 320, 180, 180)
  1841.     self.contents = Bitmap.new(width - 32, height - 32)
  1842.     self.opacity = 0
  1843.     self.back_opacity = 0
  1844.    @w = []
  1845.    for i in 0..$game_party.actors.size-1
  1846.      @w[i] = Window_Base.new(320 - $game_party.actors.size*80 + i*160,340,160,140)
  1847.      @w[i].contents = Bitmap.new(width , height )  
  1848.      @w[i].opacity = 0
  1849.      @w[i].z = 99
  1850.      bitmap = RPG::Cache.title("hud#{i+1}.png")
  1851. #     @w[i].contents.blt(0, 10, bitmap, Rect.new(0, 0, 140, 102))   
  1852.      @w[i].contents.blt(0, 13, bitmap, Rect.new(0, 0, 160, 102))   
  1853.    end
  1854.     actor = $game_party.actors[@actor_num]
  1855.     @actor_nm = actor.name
  1856.     @actor_mhp = actor.maxhp
  1857.     @actor_msp = actor.maxsp
  1858.     @actor_hp = actor.hp
  1859.     @actor_sp = actor.sp
  1860.     @actor_st = make_battler_state_text(actor, 120, true)
  1861.     @status_window = []
  1862.     for i in 0...5
  1863.       @status_window.push(Window_DetailsStatus.new(actor, i, x))
  1864.     end
  1865.     refresh(false)
  1866.   end
  1867.   #--------------------------------------------------------------------------
  1868.   # ● 解放
  1869.   #--------------------------------------------------------------------------
  1870.   def dispose
  1871.     for i in 0...5
  1872.       @status_window[i].dispose
  1873.     end
  1874.    super
  1875.        for w in @w
  1876.       w.dispose
  1877.     end
  1878.   end
  1879.   #--------------------------------------------------------------------------
  1880.   # ● リフレッシュ
  1881.   #--------------------------------------------------------------------------
  1882.   def refresh(level_up_flags)
  1883.     self.contents.clear
  1884.     actor = $game_party.actors[@actor_num]
  1885.     @status_window[0].refresh(actor) if @actor_nm != actor.name
  1886.     @status_window[1].refresh(actor) if
  1887.       @actor_mhp != actor.maxhp or @actor_hp != actor.hp
  1888.     @status_window[2].refresh(actor) if
  1889.       @actor_msp != actor.maxsp or @actor_sp != actor.sp
  1890.     @status_window[3].refresh(actor, level_up_flags) if
  1891.       @actor_st != make_battler_state_text(actor, 120, true) or level_up_flags
  1892.     @actor_nm = actor.name
  1893.     @actor_mhp = actor.maxhp
  1894.     @actor_msp = actor.maxsp
  1895.     @actor_hp = actor.hp
  1896.     @actor_sp = actor.sp
  1897.     @actor_st = make_battler_state_text(actor, 120, true)
  1898.   end
  1899.   #--------------------------------------------------------------------------
  1900.   # ● ATゲージリフレッシュ
  1901.   #--------------------------------------------------------------------------
  1902.   def at_refresh
  1903.     @status_window[4].refresh($game_party.actors[@actor_num])
  1904.   end
  1905.   #--------------------------------------------------------------------------
  1906.   # ● フレーム更新
  1907.   #--------------------------------------------------------------------------
  1908.   def update
  1909.     for window in @status_window
  1910.       window.update
  1911.     end
  1912.   end
  1913. end
  1914. #==============================================================================
  1915. # ■ Window_DetailsStatus
  1916. #------------------------------------------------------------------------------
  1917. #  バトル画面でアクターのステータスを個々に表示するウィンドウです。
  1918. #==============================================================================
  1919.  
  1920. class Window_DetailsStatus < Window_Base
  1921.   #--------------------------------------------------------------------------
  1922.   # ● オブジェクト初期化
  1923.   #--------------------------------------------------------------------------
  1924.   def initialize(actor, id, x)
  1925.     @status_id = id
  1926.     super(x, 320 + id * 26, 160, 180)
  1927.     self.contents = Bitmap.new(width - 32, height - 32)
  1928.     self.opacity = 0
  1929.     self.back_opacity = 0
  1930.     refresh(actor, false)
  1931.   end
  1932.   #--------------------------------------------------------------------------
  1933.   # ● 解放
  1934.   #--------------------------------------------------------------------------
  1935.   def dispose
  1936.     super
  1937.   end
  1938.   #--------------------------------------------------------------------------
  1939.   # ● リフレッシュ
  1940.   #--------------------------------------------------------------------------
  1941.   def refresh(actor, level_up_flags = false)
  1942.     self.contents.clear
  1943.     case @status_id
  1944.    when 0
  1945.      self.contents.font.size = 18
  1946.      draw_actor_name(actor, 24, 63)
  1947.     when 1
  1948.       draw_actor_hp(actor, 4, 25, 120)
  1949.     when 2
  1950.       draw_actor_sp(actor, 4, 20, 120)
  1951.     when 3
  1952.       #if level_up_flags
  1953.      #   self.contents.font.color = normal_color
  1954.     #    self.contents.draw_text(4, 0, 120, 32, "LEVEL UP!")
  1955.     #  else
  1956.         draw_actor_state(actor, 105, 30)
  1957.       #end
  1958.     when 4
  1959.       draw_actor_atg(actor, 4, 10, 100)
  1960.     end
  1961.   end
  1962.   #--------------------------------------------------------------------------
  1963.   # ● フレーム更新
  1964.   #--------------------------------------------------------------------------
  1965.   def update
  1966.     # メインフェーズのときは不透明度をやや下げる
  1967.     if $game_temp.battle_main_phase
  1968.       self.contents_opacity -= 4 if self.contents_opacity > 191
  1969.     else
  1970.       self.contents_opacity += 4 if self.contents_opacity < 255
  1971.     end
  1972.   end
  1973. end
  1974.  
  1975.  
  1976. #==============================================================================
  1977. # ■ Arrow_Base
  1978. #------------------------------------------------------------------------------
  1979. #  バトル画面で使用するアローカーソル表示用のスプライトです。このクラスは
  1980. # Arrow_Enemy クラスと Arrow_Actor クラスのスーパークラスとして使用されます。
  1981. #==============================================================================
  1982.  
  1983. class Arrow_Base < Sprite
  1984.   #--------------------------------------------------------------------------
  1985.   # ● オブジェクト初期化
  1986.   #     viewport : ビューポート
  1987.   #--------------------------------------------------------------------------
  1988.   def initialize(viewport)
  1989.     super(viewport)
  1990.     self.bitmap = RPG::Cache.windowskin($game_system.windowskin_name)
  1991.     self.ox = 16
  1992.     self.oy = 32
  1993.     self.z = 2500
  1994.     @blink_count = 0
  1995.     @index = 0
  1996.     @help_window = nil
  1997.     update
  1998.   end
  1999. end

RUBY 代码复制
  1. #==============================================================================
  2. # ■ Arrow_Enemy
  3. #------------------------------------------------------------------------------
  4. #  エネミーを選択させるためのアローカーソルです。このクラスは Arrow_Base クラ
  5. # スを継承します。
  6. #==============================================================================
  7.  
  8. class Arrow_Enemy < Arrow_Base
  9.   #--------------------------------------------------------------------------
  10.   # ● フレーム更新
  11.   #--------------------------------------------------------------------------
  12.   def update
  13.     super
  14.     # 存在しないエネミーを指していたら飛ばす
  15.     $game_troop.enemies.size.times do
  16.       break if self.enemy.exist?
  17.       @index += 1
  18.       @index %= $game_troop.enemies.size
  19.     end
  20.     # カーソル右
  21.     if Input.repeat?(Input::RIGHT)
  22.       $game_system.se_play($data_system.cursor_se)
  23.       $game_troop.enemies.size.times do
  24.         @index += 1
  25.         @index %= $game_troop.enemies.size
  26.         break if self.enemy.exist?
  27.       end
  28.       $scene.camera = "select"
  29.       zoom = 1 / self.enemy.zoom
  30.       $scene.spriteset.screen_target(self.enemy.attack_x(zoom) * 0.75,
  31.                                       self.enemy.attack_y(zoom) * 0.75, zoom)
  32.     end
  33.     # カーソル左
  34.     if Input.repeat?(Input::LEFT)
  35.       $game_system.se_play($data_system.cursor_se)
  36.       $game_troop.enemies.size.times do
  37.         @index += $game_troop.enemies.size - 1
  38.         @index %= $game_troop.enemies.size
  39.         break if self.enemy.exist?
  40.       end
  41.       $scene.camera = "select"
  42.       zoom = 1 / self.enemy.zoom
  43.       $scene.spriteset.screen_target(self.enemy.attack_x(zoom) * 0.75,
  44.                                       self.enemy.attack_y(zoom) * 0.75, zoom)
  45.     end
  46.     # スプライトの座標を設定
  47.     if self.enemy != nil
  48.       self.x = self.enemy.screen_x
  49.       self.y = self.enemy.screen_y
  50.     end
  51.   end
  52. end
  53.  
  54. #==============================================================================
  55. # ■ Interpreter
  56. #------------------------------------------------------------------------------
  57. #  イベントコマンドを実行するインタプリタです。このクラスは Game_System クラ
  58. # スや Game_Event クラスの内部で使用されます。
  59. #==============================================================================
  60.  
  61. class Interpreter
  62.   #--------------------------------------------------------------------------
  63.   # ● アクターの入れ替え
  64.   #--------------------------------------------------------------------------
  65.   def command_129
  66.     # アクターを取得
  67.     actor = $game_actors[@parameters[0]]
  68.     # アクターが有効の場合
  69.     if actor != nil
  70.       # 操作で分岐
  71.       if @parameters[1] == 0
  72.         if @parameters[2] == 1
  73.           $game_actors[@parameters[0]].setup(@parameters[0])
  74.         end
  75.         $game_party.add_actor(@parameters[0])
  76.         if $game_temp.in_battle
  77.           $game_actors[@parameters[0]].at = 0
  78.           $game_actors[@parameters[0]].atp = 0
  79.           $scene.spell_reset($game_actors[@parameters[0]])
  80.           $game_actors[@parameters[0]].damage_pop = {}
  81.           $game_actors[@parameters[0]].damage = {}
  82.           $game_actors[@parameters[0]].damage_sp = {}
  83.           $game_actors[@parameters[0]].critical = {}
  84.           $game_actors[@parameters[0]].recover_hp = {}
  85.           $game_actors[@parameters[0]].recover_sp = {}
  86.           $game_actors[@parameters[0]].state_p = {}
  87.           $game_actors[@parameters[0]].state_m = {}
  88.           $game_actors[@parameters[0]].animation = []
  89.         end
  90.       else
  91.         $game_party.remove_actor(@parameters[0])
  92.       end
  93.     end
  94.     if $game_temp.in_battle
  95.       $scene.status_window.update
  96.     end
  97.     # 継続
  98.     return true
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # ● HP の増減
  102.   #--------------------------------------------------------------------------
  103.   alias :command_311_rtab :command_311
  104.   def command_311
  105.     command_311_rtab
  106.     if $game_temp.in_battle
  107.       $scene.status_window.refresh
  108.     end
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # ● SP の増減
  112.   #--------------------------------------------------------------------------
  113.   alias :command_312_rtab :command_312
  114.   def command_312
  115.     command_312_rtab
  116.     if $game_temp.in_battle
  117.       $scene.status_window.refresh
  118.     end
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● ステートの変更
  122.   #--------------------------------------------------------------------------
  123.   alias :command_313_rtab :command_313
  124.   def command_313
  125.     command_313_rtab
  126.     if $game_temp.in_battle
  127.       $scene.status_window.refresh
  128.     end
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # ● 全回復
  132.   #--------------------------------------------------------------------------
  133.   alias :command_314_rtab :command_314
  134.   def command_314
  135.     command_314_rtab
  136.     if $game_temp.in_battle
  137.       $scene.status_window.refresh
  138.     end
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # ● EXP の増減
  142.   #--------------------------------------------------------------------------
  143.   alias :command_315_rtab :command_315
  144.   def command_315
  145.     command_315_rtab
  146.     if $game_temp.in_battle
  147.       $scene.status_window.refresh
  148.     end
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   # ● レベルの増減
  152.   #--------------------------------------------------------------------------
  153.   alias :command_316_rtab :command_316
  154.   def command_316
  155.     command_316_rtab
  156.     if $game_temp.in_battle
  157.       $scene.status_window.refresh
  158.     end
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # ● パラメータの増減
  162.   #--------------------------------------------------------------------------
  163.   alias :command_317_rtab :command_317
  164.   def command_317
  165.     command_317_rtab
  166.     if $game_temp.in_battle
  167.       $scene.status_window.refresh
  168.     end
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # ● 装備の変更
  172.   #--------------------------------------------------------------------------
  173.   alias :command_319_rtab :command_319
  174.   def command_319
  175.     command_319_rtab
  176.     if $game_temp.in_battle
  177.       $scene.status_window.refresh
  178.     end
  179.   end
  180.   #--------------------------------------------------------------------------
  181.   # ● アクターの名前変更
  182.   #--------------------------------------------------------------------------
  183.   alias :command_320_rtab :command_320
  184.   def command_320
  185.     command_320_rtab
  186.     if $game_temp.in_battle
  187.       $scene.status_window.refresh
  188.     end
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # ● アクターのクラス変更
  192.   #--------------------------------------------------------------------------
  193.   alias :command_321_rtab :command_321
  194.   def command_321
  195.     command_321_rtab
  196.     if $game_temp.in_battle
  197.       $scene.status_window.refresh
  198.     end
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # ● アニメーションの表示
  202.   #--------------------------------------------------------------------------
  203.   def command_337
  204.     # イテレータで処理
  205.     iterate_battler(@parameters[0], @parameters[1]) do |battler|
  206.       # バトラーが存在する場合
  207.       if battler.exist?
  208.         # アニメーション ID を設定
  209.         battler.animation.push([@parameters[2], true])
  210.       end
  211.     end
  212.     # 継続
  213.     return true
  214.   end
  215.   #--------------------------------------------------------------------------
  216.   # ● ダメージの処理
  217.   #--------------------------------------------------------------------------
  218.   def command_338
  219.     # 操作する値を取得
  220.     value = operate_value(0, @parameters[2], @parameters[3])
  221.     # イテレータで処理
  222.     iterate_battler(@parameters[0], @parameters[1]) do |battler|
  223.       # バトラーが存在する場合
  224.       if battler.exist?
  225.         # HP を変更
  226.         battler.hp -= value
  227.         # 戦闘中なら
  228.         if $game_temp.in_battle
  229.           # ダメージを設定
  230.           battler.damage["event"] = value
  231.           battler.damage_pop["event"] = true
  232.         end
  233.       end
  234.     end
  235.     if $game_temp.in_battle
  236.       $scene.status_window.refresh
  237.     end
  238.     # 継続
  239.     return true
  240.   end
  241.   #--------------------------------------------------------------------------
  242.   # ● アクションの強制
  243.   #--------------------------------------------------------------------------
  244.   def command_339
  245.     # 戦闘中でなければ無視
  246.     unless $game_temp.in_battle
  247.       return true
  248.     end
  249.     # ターン数が 0 なら無視
  250.     if $game_temp.battle_turn == 0
  251.       return true
  252.     end
  253.     # イテレータで処理 (便宜的なもので、複数になることはない)
  254.     iterate_battler(@parameters[0], @parameters[1]) do |battler|
  255.       # バトラーが存在する場合
  256.       if battler.exist?
  257.         # アクションを設定
  258.         battler.current_action.force_kind = @parameters[2]
  259.         if battler.current_action.force_kind == 0
  260.           battler.current_action.force_basic = @parameters[3]
  261.         else
  262.           battler.current_action.force_skill_id = @parameters[3]
  263.         end
  264.         # 行動対象を設定
  265.         if @parameters[4] == -2
  266.           if battler.is_a?(Game_Enemy)
  267.             battler.current_action.decide_last_target_for_enemy
  268.           else
  269.             battler.current_action.decide_last_target_for_actor
  270.           end
  271.         elsif @parameters[4] == -1
  272.           if battler.is_a?(Game_Enemy)
  273.             battler.current_action.decide_random_target_for_enemy
  274.           else
  275.             battler.current_action.decide_random_target_for_actor
  276.           end
  277.         elsif @parameters[4] >= 0
  278.           battler.current_action.target_index = @parameters[4]
  279.         end
  280.         # アクションが有効かつ [すぐに実行] の場合
  281.         if battler.current_action.valid? and @parameters[5] == 1
  282.           # 強制対象のバトラーを設定
  283.           $game_temp.forcing_battler = battler
  284.           # インデックスを進める
  285.           @index += 1
  286.           # 終了
  287.           return false
  288.         elsif battler.current_action.valid? and @parameters[5] == 0
  289.           battler.current_action.forcing = true
  290.         end
  291.       end
  292.     end
  293.     # 継続
  294.     return true
  295.   end
  296. end
  297.  
  298. #==============================================================================
  299. # ■ Spriteモジュール
  300. #------------------------------------------------------------------------------
  301. #  アニメーションの管理を行うモジュールです。
  302. #==============================================================================
  303.  
  304. module RPG
  305.   class Sprite < ::Sprite
  306.     def initialize(viewport = nil)
  307.       super(viewport)
  308.       @_whiten_duration = 0
  309.       @_appear_duration = 0
  310.       @_escape_duration = 0
  311.       @_collapse_duration = 0
  312.       @_damage = []
  313.       @_animation = []
  314.       @_animation_duration = 0
  315.       @_blink = false
  316.     end
  317.     def damage(value, critical, type = 0)
  318.       if value.is_a?(Numeric)
  319.         damage_string = value.abs.to_s
  320.       else
  321.         damage_string = value.to_s
  322.       end
  323.       bitmap = Bitmap.new(160, 48)
  324.       bitmap.font.name = "Arial Black"
  325.       bitmap.font.size = 32
  326.       bitmap.font.color.set(0, 0, 0)
  327.       bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  328.       bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  329.       bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  330.       bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  331.       if value.is_a?(Numeric) and value < 0
  332.         if type == 0
  333.           bitmap.font.color.set(176, 255, 144)
  334.         else
  335.           bitmap.font.color.set(176, 144, 255)
  336.         end
  337.       else
  338.         if type == 0
  339.           bitmap.font.color.set(255, 255, 255)
  340.         else
  341.           bitmap.font.color.set(255, 176, 144)
  342.         end
  343.       end
  344.       if type == 2
  345.         bitmap.font.color.set(255, 224, 128)
  346.       end
  347.       bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  348.       if critical
  349.         string = "CRITICAL"
  350.         bitmap.font.size = 20
  351.         bitmap.font.color.set(0, 0, 0)
  352.         bitmap.draw_text(-1, -1, 160, 20, string, 1)
  353.         bitmap.draw_text(+1, -1, 160, 20, string, 1)
  354.         bitmap.draw_text(-1, +1, 160, 20, string, 1)
  355.         bitmap.draw_text(+1, +1, 160, 20, string, 1)
  356.         bitmap.font.color.set(255, 255, 255)
  357.         bitmap.draw_text(0, 0, 160, 20, string, 1)
  358.       end
  359.       num = @_damage.size
  360.       if type != 2
  361.         @_damage.push([::Sprite.new, 40, 0, rand(40) - 20, rand(30) + 50])
  362.       else
  363.         @_damage.push([::Sprite.new, 40, 0, rand(20) - 10, rand(20) + 60])
  364.       end
  365.       @_damage[num][0].bitmap = bitmap
  366.       @_damage[num][0].ox = 80 + self.viewport.ox
  367.       @_damage[num][0].oy = 20 + self.viewport.oy
  368.       if self.battler.is_a?(Game_Actor)
  369.         @_damage[num][0].x = self.x
  370.         @_damage[num][0].y = self.y - self.oy / 2
  371.       else
  372.         @_damage[num][0].x = self.x + self.viewport.rect.x -
  373.                             self.ox + self.src_rect.width / 2
  374.         @_damage[num][0].y = self.y - self.oy * self.zoom_y / 2 +
  375.                             self.viewport.rect.y
  376.         @_damage[num][0].zoom_x = self.zoom_x
  377.         @_damage[num][0].zoom_y = self.zoom_y
  378.         @_damage[num][0].z = 3000
  379.       end
  380.     end
  381.     def animation(animation, hit)
  382.       return if animation == nil
  383.       num = @_animation.size
  384.       @_animation.push([animation, hit, animation.frame_max, []])
  385.       bitmap = RPG::Cache.animation(animation.animation_name,
  386.                                     animation.animation_hue)
  387.       if @@_reference_count.include?(bitmap)
  388.         @@_reference_count[bitmap] += 1
  389.       else
  390.         @@_reference_count[bitmap] = 1
  391.       end
  392.       if @_animation[num][0].position != 3 or
  393.           not @@_animations.include?(animation)
  394.         for i in 0..15
  395.           sprite = ::Sprite.new
  396.           sprite.bitmap = bitmap
  397.           sprite.visible = false
  398.           @_animation[num][3].push(sprite)
  399.         end
  400.         unless @@_animations.include?(animation)
  401.           @@_animations.push(animation)
  402.         end
  403.       end
  404.       update_animation(@_animation[num])
  405.     end
  406.     def loop_animation(animation)
  407.       return if animation == @_loop_animation
  408.       dispose_loop_animation
  409.       @_loop_animation = animation
  410.       return if @_loop_animation == nil
  411.       @_loop_animation_index = 0
  412.       animation_name = @_loop_animation.animation_name
  413.       animation_hue = @_loop_animation.animation_hue
  414.       bitmap = RPG::Cache.animation(animation_name, animation_hue)
  415.       if @@_reference_count.include?(bitmap)
  416.         @@_reference_count[bitmap] += 1
  417.       else
  418.         @@_reference_count[bitmap] = 1
  419.       end
  420.       @_loop_animation_sprites = []
  421.       for i in 0..15
  422.         sprite = ::Sprite.new
  423.         sprite.bitmap = bitmap
  424.         sprite.visible = false
  425.         @_loop_animation_sprites.push(sprite)
  426.       end
  427.       # update_loop_animation
  428.     end
  429.     def dispose_damage
  430.       for damage in @_damage.reverse
  431.         damage[0].bitmap.dispose
  432.         damage[0].dispose
  433.         @_damage.delete(damage)
  434.       end
  435.     end
  436.     def dispose_animation
  437.       for anime in @_animation.reverse
  438.         sprite = anime[3][0]
  439.         if sprite != nil
  440.           @@_reference_count[sprite.bitmap] -= 1
  441.           if @@_reference_count[sprite.bitmap] == 0
  442.             sprite.bitmap.dispose
  443.           end
  444.         end
  445.         for sprite in anime[3]
  446.           sprite.dispose
  447.         end
  448.         @_animation.delete(anime)
  449.       end
  450.     end
  451.     def effect?
  452.       @_whiten_duration > 0 or
  453.       @_appear_duration > 0 or
  454.       @_escape_duration > 0 or
  455.       @_collapse_duration > 0 or
  456.       @_damage.size == 0 or
  457.       @_animation.size == 0
  458.     end
  459.     def update
  460.       super
  461.       if @_whiten_duration > 0
  462.         @_whiten_duration -= 1
  463.         self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  464.       end
  465.       if @_appear_duration > 0
  466.         @_appear_duration -= 1
  467.         self.opacity = (16 - @_appear_duration) * 16
  468.       end
  469.       if @_escape_duration > 0
  470.         @_escape_duration -= 1
  471.         self.opacity = 256 - (32 - @_escape_duration) * 10
  472.       end
  473.       if @_collapse_duration > 0
  474.         @_collapse_duration -= 1
  475.         self.opacity = 256 - (48 - @_collapse_duration) * 6
  476.       end
  477.       for damage in @_damage
  478.         if damage[1] > 0
  479.           damage[1] -= 1
  480.           damage[4] -= 3
  481.           damage[2] -= damage[4]
  482.           if self.battler.is_a?(Game_Actor)
  483.             damage[0].x = self.x + (40 - damage[1]) * damage[3] / 10
  484.             damage[0].y = self.y - self.oy / 2 + damage[2] / 10
  485.           else
  486.             damage[0].x = self.x + self.viewport.rect.x -
  487.                           self.ox + self.src_rect.width / 2 +
  488.                           (40 - damage[1]) * damage[3] / 10
  489.             damage[0].y = self.y - self.oy * self.zoom_y / 2 +
  490.                           self.viewport.rect.y + damage[2] / 10
  491.             damage[0].zoom_x = self.zoom_x
  492.             damage[0].zoom_y = self.zoom_y
  493.           end
  494.           damage[0].z = 2960 + damage[1]
  495.           damage[0].opacity = 256 - (12 - damage[1]) * 32
  496.           if damage[1] == 0
  497.             damage[0].bitmap.dispose
  498.             damage[0].dispose
  499.             @_damage.delete(damage)
  500.           end
  501.         end
  502.       end
  503.       for anime in @_animation
  504.         if (Graphics.frame_count % 2 == 0)
  505.           anime[2] -= 1
  506.           update_animation(anime)
  507.         end
  508.       end
  509.       if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  510.         update_loop_animation
  511.         @_loop_animation_index += 1
  512.         @_loop_animation_index %= @_loop_animation.frame_max
  513.       end
  514.       if @_blink
  515.         @_blink_count = (@_blink_count + 1) % 32
  516.         if @_blink_count < 16
  517.           alpha = (16 - @_blink_count) * 6
  518.         else
  519.           alpha = (@_blink_count - 16) * 6
  520.         end
  521.         self.color.set(255, 255, 255, alpha)
  522.       end
  523.       @@_animations.clear
  524.     end
  525.     def update_animation(anime)
  526.       if anime[2] > 0
  527.         frame_index = anime[0].frame_max - anime[2]
  528.         cell_data = anime[0].frames[frame_index].cell_data
  529.         position = anime[0].position
  530.         animation_set_sprites(anime[3], cell_data, position)
  531.         for timing in anime[0].timings
  532.           if timing.frame == frame_index
  533.             animation_process_timing(timing, anime[1])
  534.           end
  535.         end
  536.       else
  537.         @@_reference_count[anime[3][0].bitmap] -= 1
  538.         if @@_reference_count[anime[3][0].bitmap] == 0
  539.             anime[3][0].bitmap.dispose
  540.         end
  541.         for sprite in anime[3]
  542.           sprite.dispose
  543.         end
  544.         @_animation.delete(anime)
  545.       end
  546.     end
  547.     def animation_set_sprites(sprites, cell_data, position)
  548.       for i in 0..15
  549.         sprite = sprites[i]
  550.         pattern = cell_data[i, 0]
  551.         if sprite == nil or pattern == nil or pattern == -1
  552.           sprite.visible = false if sprite != nil
  553.           next
  554.         end
  555.         sprite.visible = true
  556.         sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  557.         if position == 3
  558.           if self.viewport != nil
  559.             sprite.x = self.viewport.rect.width / 2
  560.             if $game_temp.in_battle and self.battler.is_a?(Game_Enemy)
  561.               sprite.y = self.viewport.rect.height - 320
  562.             else
  563.               sprite.y = self.viewport.rect.height - 160
  564.             end
  565.           else
  566.             sprite.x = 320
  567.             sprite.y = 240
  568.           end
  569.         else
  570.           sprite.x = self.x + self.viewport.rect.x -
  571.                       self.ox + self.src_rect.width / 2
  572.           if $game_temp.in_battle and self.battler.is_a?(Game_Enemy)
  573.             sprite.y = self.y - self.oy * self.zoom_y / 2 +
  574.                         self.viewport.rect.y
  575.             if position == 0
  576.               sprite.y -= self.src_rect.height * self.zoom_y / 4
  577.             elsif position == 2
  578.               sprite.y += self.src_rect.height * self.zoom_y / 4
  579.             end
  580.           else
  581.             sprite.y = self.y + self.viewport.rect.y -
  582.                         self.oy + self.src_rect.height / 2
  583.             sprite.y -= self.src_rect.height / 4 if position == 0
  584.             sprite.y += self.src_rect.height / 4 if position == 2
  585.           end
  586.         end
  587.         sprite.x += cell_data[i, 1]
  588.         sprite.y += cell_data[i, 2]
  589.         sprite.z = 2000
  590.         sprite.ox = 96
  591.         sprite.oy = 96
  592.         sprite.zoom_x = cell_data[i, 3] / 100.0
  593.         sprite.zoom_y = cell_data[i, 3] / 100.0
  594.         if position != 3
  595.           sprite.zoom_x *= self.zoom_x
  596.           sprite.zoom_y *= self.zoom_y
  597.         end
  598.         sprite.angle = cell_data[i, 4]
  599.         sprite.mirror = (cell_data[i, 5] == 1)
  600.         sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  601.         sprite.blend_type = cell_data[i, 7]
  602.       end
  603.     end
  604.     def x=(x)
  605.       sx = x - self.x
  606.       if sx != 0
  607.         for anime in @_animation
  608.           if anime[3] != nil
  609.             for i in 0..15
  610.               anime[3][i].x += sx
  611.             end
  612.           end
  613.         end
  614.         if @_loop_animation_sprites != nil
  615.           for i in 0..15
  616.             @_loop_animation_sprites[i].x += sx
  617.           end
  618.         end
  619.       end
  620.       super
  621.     end
  622.     def y=(y)
  623.       sy = y - self.y
  624.       if sy != 0
  625.         for anime in @_animation
  626.           if anime[3] != nil
  627.             for i in 0..15
  628.               anime[3][i].y += sy
  629.             end
  630.           end
  631.         end
  632.         if @_loop_animation_sprites != nil
  633.           for i in 0..15
  634.             @_loop_animation_sprites[i].y += sy
  635.           end
  636.         end
  637.       end
  638.       super
  639.     end
  640.   end
  641. end
  642.  
  643. #------------------------------------------------------------------------------
  644. #  Bitmapクラスに新たな機能を追加します。
  645. #==============================================================================
  646.  
  647. class Bitmap
  648.   #--------------------------------------------------------------------------
  649.   # ● 矩形をグラデーション表示
  650.   #     color1 : スタートカラー
  651.   #     color2 : エンドカラー
  652.   #     align  :  0:横にグラデーション
  653.   #               1:縦にグラデーション
  654.   #               2:斜めにグラデーション(激重につき注意)
  655.   #--------------------------------------------------------------------------
  656.   def gradation_rect(x, y, width, height, color1, color2, align = 0)
  657.     if align == 0
  658.       for i in x...x + width
  659.         red   = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
  660.         green = color1.green +
  661.                 (color2.green - color1.green) * (i - x) / (width - 1)
  662.         blue  = color1.blue +
  663.                 (color2.blue - color1.blue) * (i - x) / (width - 1)
  664.         alpha = color1.alpha +
  665.                 (color2.alpha - color1.alpha) * (i - x) / (width - 1)
  666.         color = Color.new(red, green, blue, alpha)
  667.         fill_rect(i, y, 1, height, color)
  668.       end
  669.     elsif align == 1
  670.       for i in y...y + height
  671.         red   = color1.red +
  672.                 (color2.red - color1.red) * (i - y) / (height - 1)
  673.         green = color1.green +
  674.                 (color2.green - color1.green) * (i - y) / (height - 1)
  675.         blue  = color1.blue +
  676.                 (color2.blue - color1.blue) * (i - y) / (height - 1)
  677.         alpha = color1.alpha +
  678.                 (color2.alpha - color1.alpha) * (i - y) / (height - 1)
  679.         color = Color.new(red, green, blue, alpha)
  680.         fill_rect(x, i, width, 1, color)
  681.       end
  682.     elsif align == 2
  683.       for i in x...x + width
  684.         for j in y...y + height
  685.           red   = color1.red + (color2.red - color1.red) *
  686.                   ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  687.           green = color1.green + (color2.green - color1.green) *
  688.                   ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  689.           blue  = color1.blue + (color2.blue - color1.blue) *
  690.                   ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  691.           alpha = color1.alpha + (color2.alpha - color1.alpha) *
  692.                   ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  693.           color = Color.new(red, green, blue, alpha)
  694.           set_pixel(i, j, color)
  695.         end
  696.       end
  697.     elsif align == 3
  698.       for i in x...x + width
  699.         for j in y...y + height
  700.           red   = color1.red + (color2.red - color1.red) *
  701.               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  702.           green = color1.green + (color2.green - color1.green) *
  703.               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  704.           blue  = color1.blue + (color2.blue - color1.blue) *
  705.               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  706.           alpha = color1.alpha + (color2.alpha - color1.alpha) *
  707.               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  708.           color = Color.new(red, green, blue, alpha)
  709.           set_pixel(i, j, color)
  710.         end
  711.       end
  712.     end
  713.   end
  714. end
舊坑被棄了
開新坑~
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-30 11:33

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表