#◆◇◆◇◆ ☆ 追尾アニメーション ver 1.01 ◇◆◇◆◇ # ☆ マスタースクリプト ver 2.00 以降専用 # サポート掲示板 http://www2.ezbbs.net/21/minto-aaa/ # by みんと =begin 更新履歴 ver 1.01 特定の条件下でエラー落ちするミスを修正 セクション指定上下関係 反転表示バトラー ↓ 多重追加アニメーション ↓ このスクリプト ほとんど他サイトさんのサイドビュー専用です。 アニメーション名に 追尾 の名前がある場合、 使用者から、対象者に向かって移動するアニメになります。 追尾の開始には各色が 0 で強さが 2 の対象のフラッシュを設定してください。 フラッシュの時間が追尾に掛ける時間です。 追尾を開始するまでは、アニメの基本座標は発動者の位置になります。 アニメの表示自体は通常通り行われますので、 上下に動くアニメを追尾させた場合は、 上下に動きながら対象に向けて追尾します。 多段攻撃βとACAシステムも動作しますが、 ACAシステムとフラッシュは、 タイミングを調節しないと スクリプトの性質上、おかしく見えるかもしれません。 設定例 名前 追尾アニメ フラッシュの範囲 対象 フラッシュの色 赤 0 青 0 緑 0 強さ 2 時間 任意 このフラッシュが実行された瞬間から追尾します。 尚、マップには非対応です。 =end #============================================================================== # ☆ MINTO #------------------------------------------------------------------------------ # 様々なフラグを扱うメインモジュールです。 #============================================================================== module MINTO # 多重追加アニメーションを有効化( true で有効 / false で無効 ) RGSS["Homing_Anima"] = true end if MINTO::RGSS["Homing_Anima"] == true then #============================================================================== # ■ RPG::Animation #------------------------------------------------------------------------------ # ゲームで使用されるアニメーションを管理するクラスです。 #============================================================================== module RPG class Animation #------------------------------------------------------------------------ # ● 公開インスタンス変数 #------------------------------------------------------------------------ attr_accessor :homing # ホーミングフラグ end end #============================================================================== # ■ Sprite_Battler #------------------------------------------------------------------------------ #  バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、 # スプライトの状態を自動的に変化させます。 #============================================================================== class Sprite_Battler < RPG::Sprite #-------------------------------------------------------------------------- # ● アニメーション作成 # animation : 渡されたアニメーション # hit : ヒットフラグ #-------------------------------------------------------------------------- def animation(animation, hit) # ACAシステムが有効な場合 if MINTO::RGSS["A・C・A・システム"] == true then # アニメのIDを保存 $game_temp.animation_id = @battler.animation_id # アニメ表示フラグをオンにする $game_temp.now_animation = true end # アクティブバトラーが無効な場合 if $scene.active_battler == nil then # スーパークラスを実行 super(animation, hit) # メソッドを返す return end # 行動者の座標を記録 @ori_x = $scene.active_battler.screen_x @ori_y = $scene.active_battler.screen_y # 補正座標を初期化 @homing_x_plus = 0 @homing_y_plus = 0 # 目標座標を初期化 @target_x = 0 @target_y = 0 # 追尾カウントを初期化 @homing_duration = 0 @homing_duration_base = 0 # アニメーション名に 追尾 が含まれる場合 if animation.name.include?("追尾") == true then # 追尾アニメフラグをオンにする animation.homing = true end # スーパークラスを実行 super(animation, hit) end #-------------------------------------------------------------------------- # ● アニメーション・セットスプライト # sprites : アニメのスプライト # cell_data : アニメセルのデータ # position : アニメの位置 #-------------------------------------------------------------------------- def animation_set_sprites(sprites, cell_data, position) # スーパークラスを実行 super(sprites, cell_data, position) # 通常アニメーションが無効な場合 if @_animation == nil then # メソッドを返す return end # アニメの追尾フラグがオンの場合 if @_animation.homing == true then # スプライトの数だけ繰り返す (0...16).each do |i| # スプライトを取得 sprite = sprites[i] # アニメのパターンを取得 pattern = cell_data[i, 0] # 無効なスプライトの場合 if sprite == nil or pattern == nil or pattern == -1 then # 次の処理へ以降 next end # スプライトを可視状態にする sprite.visible = true # 位置が 画面 の場合 if position == 3 then # ビューポートが存在する場合 if self.viewport != nil then # ビューポートから基本座標を設定 sprite.x = self.viewport.rect.width / 2 sprite.y = self.viewport.rect.height - 160 # ビューポートが存在しない場合 else # 基本座標を設定 sprite.x = 320 sprite.y = 240 end # 位置が 画面 以外の場合 else # アニメの 位置 から基本座標を設定 sprite.x = @ori_x - self.ox + self.src_rect.width / 2 sprite.y = @ori_y - self.oy + self.src_rect.height / 2 # 位置が 上 の場合 if position == 0 then # Y座標を減算修正 sprite.y -= self.src_rect.height / 4 end # 位置が 下 の場合 if position == 2 then # Y座標を加算修正 sprite.y += self.src_rect.height / 4 end end # スプライトの座標を補正 sprite.x += cell_data[i, 1] - @homing_x_plus sprite.y += cell_data[i, 2] - @homing_y_plus end # 追尾カウントが 1 以上の場合 if @homing_duration >= 1 then # 追尾カウントを取得 duration = @homing_duration # 追尾先の座標を残りカウントに応じて計算 @homing_x_plus += (@ori_x - @target_x) / @homing_duration_base @homing_y_plus += (@ori_y - @target_y) / @homing_duration_base # 追尾カウントを減らす @homing_duration -= 1 end end end #-------------------------------------------------------------------------- # ● アニメーション・プロセスタイミング # timing : SEなどのデータ # hit : ヒットフラグ #-------------------------------------------------------------------------- def animation_process_timing(timing, hit) # 追尾アニメの移動開始判定 homing_anima_movable?(timing, hit) # 多重追加アニメーションが有効な場合 if MINTO::RGSS["Array_Anima"] == true then # 追加アニメ判定 abb_anima_effect(timing, hit) end # スーパークラスメソッドを実行 super(timing, hit) # アクティブ・アニメシェイクが有効ではない場合 if not MINTO::RGSS["Active_Shake"] then # 処理を返す return end # 条件が ヒット で攻撃がヒットした場合か、 # 条件が ミス で攻撃がミスだった場合、 # もしくは条件が なし だった場合 if (timing.condition == 0) or (timing.condition == 1 and hit == true) or (timing.condition == 2 and hit == false) then # 対象無しのフラッシュが設定されている場合 if timing.flash_scope == 0 then # フラッシュの赤と緑が0の場合 if timing.flash_color.red == 0 and timing.flash_color.green == 0 then # シェイクの強さ(フラッシュの強さ) s_alpha = [timing.flash_color.alpha.to_i, 9].min # シェイクの早さ(フラッシュの青) s_speed = [timing.flash_color.blue.to_i, 9].min # シェイクの時間(フラッシュの時間) s_thyme = timing.flash_duration.to_i * 2 # 画面をシェイク $game_screen.start_shake(s_alpha, s_speed, s_thyme) end end end end #------------------------------------------------------------------------ # ● 追尾アニメの移動開始判定 # timing : SEなどのタイミングデータ # hit : アニメのヒットフラグ #------------------------------------------------------------------------ def homing_anima_movable?(timing, hit) # フラッシュの範囲が 対象 でない場合 unless timing.flash_scope == 1 then # 処理を終了 return end # 条件が ヒット で攻撃がヒットした場合か、 # 条件が ミス で攻撃がミスだった場合、 # もしくは条件が なし だった場合 if (timing.condition == 0) or (timing.condition == 1 and hit == true) or (timing.condition == 2 and hit == false) then # フラッシュの各色が 0 且つ、強さが2の場合 if timing.flash_color.red == 0 and timing.flash_color.green == 0 and timing.flash_color.blue == 0 and timing.flash_color.alpha == 2 then # 対象者の座標を取得 @target_x = @battler.screen_x @target_y = @battler.screen_y # 追尾カウントを設定 @homing_duration = timing.flash_duration @homing_duration_base = timing.flash_duration end end end #-------------------------------------------------------------------------- # ● 攻撃判定の取得 # cell_data : 実行中のアニメのデータ # i : セルのインデックス #-------------------------------------------------------------------------- def get_attack_check(cell_data, i) # アニメの追尾フラグがオンの場合 if @_animation.homing == true then # セルの現在座標を割り出す cell_x = @ori_x - self.ox + self.src_rect.width / 2 cell_y = @ori_y - self.oy + self.src_rect.height / 2 # セルの座標に、セルの座標修正を加算 cell_x += cell_data[i, 1] - @homing_x_plus cell_y += cell_data[i, 2] - @homing_y_plus else # セルの現在座標を割り出す cell_x = @battler.screen_x - self.ox + self.src_rect.width / 2 cell_y = @battler.screen_y - self.oy + self.src_rect.height / 2 # セルの座標に、セルの座標修正を加算 cell_x += cell_data[i, 1] cell_y += cell_data[i, 2] end # セルの座標に拡大率/2を±した値が攻撃判定となる attack_check = [ cell_x + (cell_data[i, 3] - 20) / 2, cell_x - (cell_data[i, 3] - 20) / 2, cell_y + (cell_data[i, 3] - 20) / 2, cell_y - (cell_data[i, 3] - 20) / 2] # 攻撃判定を返す return attack_check end end #============================================================================== # ■ Scene_Battle (分割定義 1) #------------------------------------------------------------------------------ #  バトル画面の処理を行うクラスです。 #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :active_battler # アクティブバトラー end end