전투중에 시점이동 효과를 가지는 스크립트입니다. 적을 안쪽에 배치하는 경우는 무리설정 화면에서 적을 위에 배치해 주시면 됩니다. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ #_/ ◆전투 카메라 - KGC_BattleCamera◆ #_/---------------------------------------------------------------------------- #_/ 전투중의 시점 이동 기능을 도입합니다. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ #============================================================================== # ★ 커스터마이즈 항목 ★ #============================================================================== module KGC # ◆카메라 이동 속도 초기치 BC_SPEED_INIT = 24 end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ $imported["BattleCamera"] = true #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Game_Enemy #============================================================================== class Game_Enemy < Game_Battler attr_reader :origin_x, :origin_y #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_KGC_BattleCamera initialize def initialize(troop_id, member_index) # 元の処理を実行 initialize_KGC_BattleCamera(troop_id, member_index) @origin_x = $data_troops[@troop_id].members[@member_index].x @origin_y = $data_troops[@troop_id].members[@member_index].y end #-------------------------------------------------------------------------- # ● バトル画面 X 座標の取得 #-------------------------------------------------------------------------- def screen_x return @origin_x - $scene.camera.x * self.zoom end #-------------------------------------------------------------------------- # ● バトル画面 Y 座標の取得 #-------------------------------------------------------------------------- def screen_y return @origin_y - $scene.camera.y * self.zoom end #-------------------------------------------------------------------------- # ● 倍率の取得 #-------------------------------------------------------------------------- def zoom n = (1.00 + $scene.camera.z / 512.00) * ((@origin_y - 304) / 256.00 + 1) return n end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Sprite_Battler #============================================================================== class Sprite_Battler < RPG::Sprite #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias update_KGC_BattleCamera update def update # 元の処理を実行 update_KGC_BattleCamera return if @battler == nil if @battler.is_a?(Game_Enemy) # 倍率調整 self.zoom_x = self.zoom_y = @battler.zoom end end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Spriteset_Battle #============================================================================== class Spriteset_Battle #-------------------------------------------------------------------------- # ● 更新 #-------------------------------------------------------------------------- alias update_KGC_BattleCamera update def update # 元の処理を実行 update_KGC_BattleCamera =begin if Input::trigger?(Input::Z) c = $scene.camera zoom = c.z / 512.00 + 1 p "#{c.x}, #{c.y}, #{c.z}" p "#{@battleback_sprite.x + 320}, #{@battleback_sprite.y + 304}, #{zoom}" end =end # カメラ移動判定 cx, cy, cz = $scene.camera.x, $scene.camera.y, $scene.camera.z bx, by = @battleback_sprite.x + 320, @battleback_sprite.y + 304 if bx != cx || by != cy || @bz != cz # 倍率調整 zoom = cz / 512.00 + 1 @battleback_sprite.zoom_x = zoom * 2 @battleback_sprite.zoom_y = zoom * 2 # 全体化判定 if $imported["Base Reinforce"] && KGC::BR_BATTLEBACK_FULL @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2 @battleback_sprite.oy = @battleback_sprite.bitmap.height / 2 mag_x = 640.0 / @battleback_sprite.bitmap.width mag_y = 480.0 / @battleback_sprite.bitmap.height @battleback_sprite.zoom_x *= mag_x @battleback_sprite.zoom_y *= mag_y end # 座標調整 @battleback_sprite.x = -cx * zoom / 2 - 320 + @battleback_sprite.ox * 2 @battleback_sprite.y = -cy * zoom / 2 - 144 + @battleback_sprite.oy * 2 @bz = cz end end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Camera #------------------------------------------------------------------------------ # 戦闘中のカメラを扱うクラスです。 #============================================================================== class Camera #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :x, :y, :z attr_accessor :move_speed #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize @x, @y, @z = 0, 0, 0 @move_x = @move_y = @move_z = 0 @move_speed = KGC::BC_SPEED_INIT end #-------------------------------------------------------------------------- # ● 移動 #-------------------------------------------------------------------------- def move(x, y, z) @move_x, @move_y, @move_z = x - @x - 320, y - @y - 160, z - @z end #-------------------------------------------------------------------------- # ● 対象エネミーへ移動 #-------------------------------------------------------------------------- def move_target(target) return if target == nil || !target.is_a?(Game_Enemy) tx, ty = target.origin_x, target.origin_y - 144 tz = (304 - target.origin_y) * 4.5 move(tx, ty, tz) end #-------------------------------------------------------------------------- # ● 中央へ移動 #-------------------------------------------------------------------------- def centering @move_x, @move_y, @move_z = -@x, -@y, -@z end #-------------------------------------------------------------------------- # ● 更新 #-------------------------------------------------------------------------- def update # X座標移動 mv = [[@move_x.abs * @move_speed / 160, 1].max, @move_speed].min if @move_x > 0 @x += mv @move_x = [@move_x - mv, 0].max elsif @move_x < 0 @x -= mv @move_x = [@move_x + mv, 0].min end # Y座標移動 mv = [[@move_y.abs * @move_speed / 160, 1].max, @move_speed].min if @move_y > 0 @y += mv @move_y = [@move_y - mv, 0].max elsif @move_y < 0 @y -= mv @move_y = [@move_y + mv, 0].min end # Z座標移動 mv = [[@move_z.abs * @move_speed / 96, 1].max, @move_speed * 2].min if @move_z > 0 @z += mv @move_z = [@move_z - mv, 0].max elsif @move_z < 0 @z -= mv @move_z = [@move_z + mv, 0].min end end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Scene_Battle (分割定義 1) #============================================================================== class Scene_Battle attr_reader :camera #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- alias main_KGC_BattleCamera main def main # カメラ作成 @camera = Camera.new # 元の処理を実行 main_KGC_BattleCamera end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias update_KGC_BattleCamera update def update @camera.update # 元の処理を実行 update_KGC_BattleCamera end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Scene_Battle (分割定義 3) #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : エネミー選択) #-------------------------------------------------------------------------- alias update_phase3_enemy_select_KGC_BattleCamera update_phase3_enemy_select def update_phase3_enemy_select # 選択対象をズームアップ if !$imported["ActiveCountBattle"] || @action_battler == nil @camera.move_target(@enemy_arrow.enemy) end # 元の処理を実行 update_phase3_enemy_select_KGC_BattleCamera end #-------------------------------------------------------------------------- # ● エネミー選択終了 #-------------------------------------------------------------------------- alias end_enemy_select_KGC_BattleCamera end_enemy_select def end_enemy_select # カメラを中央へ戻す if !$imported["ActiveCountBattle"] || @action_battler == nil @camera.move(320, 160, 0) end # 元の処理を実行 end_enemy_select_KGC_BattleCamera end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Scene_Battle (分割定義 4) #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 3 : 行動側アニメーション) #-------------------------------------------------------------------------- alias update_phase4_step3_KGC_BattleCamera update_phase4_step3 def update_phase4_step3 # カメラ移動 if @active_battler.is_a?(Game_Actor) && @target_battlers != [] if @target_battlers.size > 1 @camera.move(320, 160, -96) else @camera.move_target(@target_battlers[0]) end elsif @active_battler.is_a?(Game_Enemy) @camera.move_target(@active_battler) end # 元の処理を実行 update_phase4_step3_KGC_BattleCamera end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ) #-------------------------------------------------------------------------- alias update_phase4_step6_KGC_BattleCamera update_phase4_step6 def update_phase4_step6 # カメラを初期位置へ移動 @camera.centering # 元の処理を実行 update_phase4_step6_KGC_BattleCamera end end