#============================================================================== # ■ XP-RGSS-44-V2 サイドビュー戦闘[Ver.2.1.0] by Claimh #------------------------------------------------------------------------------ # アクターの動作制御をする場所です。 # スキルの移動攻撃条件: 効果範囲が敵単体 & 攻撃力Fが50以上 & 魔力Fが50未満 #------------------------------------------------------------------------------ #【再定義】 # Sprite_Battler : initialize # update #============================================================================== module SideView #---------------------------------------------------------------------------- # [画像設定] # アクターの戦闘不能時の画像ファイル(Graphic/Characters) CORPSE_F = { # CORPSE_F[アクターID] = "ファイル名", 左からの位置, 上からの位置] 1 => ["189-Down01", 0, 0], 2 => ["189-Down01", 1, 2], 3 => ["189-Down01", 0, 3], 4 => ["190-Down02", 2, 0], 5 => ["190-Down02", 1, 1], 6 => ["190-Down02", 2, 1], 7 => ["190-Down02", 0, 3], 8 => ["191-Down03", 3, 1] } #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- # モーションコントロールモード M_MODE_WAIT = 0 # 待機 M_MODE_MAGI = 1 # 関接攻撃 M_MODE_DAMG = 2 # 非ダメージ M_MODE_WIN = 3 # 勝利 M_MODE_ATK1 = 4 # 直接攻撃(行き) M_MODE_ATK2 = 5 # 直接攻撃(攻撃) M_MODE_ATK3 = 6 # 直接攻撃(帰り) module_function #-------------------------------------------------------------------------- # ● 移動位置計算 #-------------------------------------------------------------------------- def set_target_point(attacker, target) case target when Game_Actor bits = RPG::Cache.character(target.character_name, target.character_hue) attacker.target_x = target.screen_x + (bits.width / 8) attacker.target_y = target.screen_y when Game_Enemy bits = RPG::Cache.battler(target.battler_name, target.battler_hue) attacker.target_x = target.screen_x + (bits.width / 2) attacker.target_y = target.screen_y end end #-------------------------------------------------------------------------- # ● スキルの直接攻撃判定 #-------------------------------------------------------------------------- def skill_is_direct?(skill) return (skill.scope == 1 and skill.atk_f >= 50 and skill.int_f < 50) end end #============================================================================== # ■ Sprite_Battler #============================================================================== class Sprite_Battler < RPG::Sprite #-------------------------------------------------------------------------- # ● オブジェクト初期化 [再定義] # viewport : ビューポート # battler : バトラー (Game_Battler) #-------------------------------------------------------------------------- def initialize(viewport, battler = nil) super(viewport) @battler = battler @battler_visible = false @battler_corpse = false @first_dead = false @pattern = 0 @direction = 0 @moving_mode = 0 init_direct_attack end #-------------------------------------------------------------------------- # ● 近接攻撃設定値初期化 #-------------------------------------------------------------------------- def init_direct_attack @direct_attack_cnt = 0 @direct_attack_phase = 0 @direct_move_cnt = 0 @battler_x_plus = 0 @battler_y_plus = 0 end #-------------------------------------------------------------------------- # ● スプライト動作中? #-------------------------------------------------------------------------- def effect? ret = super return ret if @battler.nil? if @direct_attack_phase == 0 return ret else return false end end #-------------------------------------------------------------------------- # ● フレーム更新 [再定義] #-------------------------------------------------------------------------- def update super # バトラーが nil の場合 if @battler == nil self.bitmap = nil loop_animation(nil) return end # 戦闘不能でない unless @battler_corpse # ファイル名か色相が現在のものと異なる場合 if @battler.battler_name != @battler_name or @battler.battler_hue != @battler_hue or @battler.move_mode != @moving_mode # 動作制御 motion_control # 戦闘不能または隠れ状態なら不透明度を 0 にする if (@battler.dead? or @battler.hidden) and !@battler.dead_delay self.opacity = 0 end end end # アニメーション ID が現在のものと異なる場合 if @battler.damage == nil and @battler.state_animation_id != @state_animation_id @state_animation_id = @battler.state_animation_id loop_animation($data_animations[@state_animation_id]) end # # 表示されるべきアクターの場合 # if @battler.is_a?(Game_Actor) and @battler_visible # # メインフェーズでないときは不透明度をやや下げる # if $game_temp.battle_main_phase # self.opacity += 3 if self.opacity < 255 # else # self.opacity -= 3 if self.opacity > 207 # end # end # 明滅 if @battler.blink blink_on else blink_off end # 不可視の場合 unless @battler_visible # 出現 if not @battler.hidden and not @battler.dead? and (@battler.damage == nil or @battler.damage_pop) appear @battler_visible = true @battler.dead_delay = true end if @battler.dead? and (@battler.damage == nil or @battler.damage_pop) if @battler.is_a?(Game_Actor) appear update_dead @battler_visible = true @battler_corpse = true end @battler.dead_delay = true @battler.revive_delay = false end end # 可視の場合 if @battler_visible and !@battler_corpse # 逃走 if @battler.hidden $game_system.se_play($data_system.escape_se) escape @battler_visible = false end # 白フラッシュ if @battler.white_flash whiten @battler.white_flash = false end # アニメーション if @battler.animation_id != 0 animation = $data_animations[@battler.animation_id] animation(animation, @battler.animation_hit) @battler.animation_id = 0 end # ダメージ if @battler.damage_pop damage(@battler.damage, @battler.critical) @battler.damage = nil @battler.critical = false @battler.damage_pop = false end # コラプス if @battler.damage == nil and @battler.dead? if @battler.is_a?(Game_Enemy) $game_system.se_play($data_system.enemy_collapse_se) else $game_system.se_play($data_system.actor_collapse_se) end if @battler.dead_delay if @battler.is_a?(Game_Actor) unless @first_dead appear update_dead @battler_corpse = true else @first_daed = false end else @battler_corpse = true @first_daed = false collapse end else collapse end end end # 蘇生処置 if !@battler.dead? and @battler_corpse and @battler.revive_delay appear case @battler when Game_Actor draw_pre_character draw_character when Game_Enemy draw_battler end @battler.dead_delay = true @battler.revive_delay = false @battler_corpse = false end # スプライトの座標を設定 self.x = @battler.screen_x + @battler_x_plus self.y = @battler.screen_y + @battler_y_plus self.z = @battler.screen_z end #-------------------------------------------------------------------------- # ● 戦闘不能描画 #-------------------------------------------------------------------------- def update_dead self.bitmap = RPG::Cache.character(SideView::CORPSE_F[@battler.id][0], @battler.character_hue) cw = self.bitmap.width / 4 ch = self.bitmap.height / 4 x_index = cw * (SideView::CORPSE_F[@battler.id][1]) y_index = ch * (SideView::CORPSE_F[@battler.id][2]) @width = cw @height = ch # 転送元の矩形を設定 self.src_rect.set(x_index, y_index, cw, ch) self.ox = @width / 2 self.oy = @height end #-------------------------------------------------------------------------- # ● バトラー描画 #-------------------------------------------------------------------------- def draw_battler # ビットマップを取得、設定 @battler_name = @battler.battler_name @battler_hue = @battler.battler_hue self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue) @width = bitmap.width @height = bitmap.height self.ox = @width / 2 self.oy = @height end #-------------------------------------------------------------------------- # ● ホコグラ描画準備 [共通] #-------------------------------------------------------------------------- def draw_pre_character # ビットマップを取得、設定 @battler_name = @battler.character_name @battler_hue = @battler.character_hue # 歩行グラフィックを描画 self.bitmap = RPG::Cache.character(@battler_name, @battler_hue) @width = self.bitmap.width / 4 @height = self.bitmap.height / 4 self.ox = @width / 2 self.oy = @height end #-------------------------------------------------------------------------- # ● ホコグラ描画 [共通] #-------------------------------------------------------------------------- def draw_character # 転送元の矩形を設定 sx = @pattern * @width sy = (@direction - 2) / 2 * @height self.src_rect.set(sx, sy, @width, @height) end #-------------------------------------------------------------------------- # ● モーションコントロール #-------------------------------------------------------------------------- def motion_control # 動作モード記憶 @moving_mode = @battler.move_mode # バトラー描画 case @battler when Game_Actor # アクター actor_motion_control when Game_Enemy # エネミー enemy_motion_control end end #-------------------------------------------------------------------------- # ● モーションコントロール(Actor) #-------------------------------------------------------------------------- def actor_motion_control draw_pre_character # 動作チェンジ case @moving_mode when SideView::M_MODE_WAIT # 待機 init_direct_attack @battler_x_plus = 0 @direction = 4 @pattern = 1 when SideView::M_MODE_MAGI # 攻撃 @battler_x_plus = -10 @direction = 4 @pattern = 3 when SideView::M_MODE_DAMG # 非ダメージ @battler_x_plus = 10 @direction = 4 @pattern = 3 when SideView::M_MODE_WIN # 勝利 @direction = 2 @pattern = 1 when SideView::M_MODE_ATK1 # 近接攻撃開始 exe_moving_attack_start @moving_mode = 10 @end_pos_x = @battler_x_plus when SideView::M_MODE_ATK2 # 近接攻撃 @battler_x_plus = @end_pos_x - 10 when SideView::M_MODE_ATK3 # 近接攻撃終了 exe_moving_attack_end @moving_mode = 10 else p "error:Sprite_Battler>> @moving_mode" end draw_character end #-------------------------------------------------------------------------- # ● モーションコントロール(Enemy) #-------------------------------------------------------------------------- def enemy_motion_control # 動作チェンジ case @moving_mode when SideView::M_MODE_WAIT # 待機 init_direct_attack when SideView::M_MODE_MAGI # 攻撃 @battler_x_plus = 10 when SideView::M_MODE_DAMG # 非ダメージ @battler_x_plus = -10 @shake_flg = true when SideView::M_MODE_ATK1 # 近接攻撃開始 exe_moving_attack_start @moving_mode = 10 @end_pos_x = @battler_x_plus when SideView::M_MODE_ATK2 # 近接攻撃 @battler_x_plus = @end_pos_x + 10 when SideView::M_MODE_ATK3 # 近接攻撃終了 exe_moving_attack_end @moving_mode = 10 else p "error:Sprite_Battler>> @moving_mode", @moving_mode end draw_battler end #-------------------------------------------------------------------------- # ● 近接攻撃実行メソッド #-------------------------------------------------------------------------- def exe_moving_attack_start return unless @battler.motion_stop case @direct_attack_phase when 0 # 動作開始準備 diratk_start when 1 # 移動動作(行き) diratk_move when 2 # 移動後ウェイト diratk_wait end end def exe_moving_attack_end case @direct_attack_phase when 0 # 攻撃動作 diratk_attack when 1 # 移動動作(帰り) diratk_back when 2 # 動作終了 diratk_end end end #-------------------------------------------------------------------------- # ● 近接攻撃実行 [動作開始準備] #-------------------------------------------------------------------------- def diratk_start # ポーズ変更 @pattern = 1 # 現在の位置と目標位置からフレーム数を割り出す pos_x = @battler.target_x - self.x pos_y = @battler.target_y - self.y # フレーム数算出 @direct_move_cnt = @direct_attack_cnt = (pos_x.abs / 40).round # NEXTフェーズ @direct_attack_phase += 1 end #-------------------------------------------------------------------------- # ● 近接攻撃実行 [移動動作(行き)] #-------------------------------------------------------------------------- def diratk_move case @battler when Game_Actor x_plus = 20 y_plus = 0 when Game_Enemy bitmap = RPG::Cache.battler(@battler_name, @battler_hue) x_plus = -(bitmap.width/2 + 25) y_plus = 20 end # 現在の位置と目標位置から次の移動位置を割り出す pos_x = @battler.target_x - self.x + x_plus pos_y = @battler.target_y - self.y + y_plus @battler_x_plus += pos_x / @direct_attack_cnt if @direct_attack_cnt != 0 @battler_y_plus += pos_y / @direct_attack_cnt if @direct_attack_cnt != 0 # 終了カウント @direct_attack_cnt -= 1 # 最終移動(保険:最終補正) if @direct_attack_cnt <= 0 @battler_x_plus = @battler.target_x - @battler.screen_x + x_plus @battler_y_plus = @battler.target_y - @battler.screen_y + y_plus # NEXTフェーズ @direct_attack_cnt = 5 @direct_attack_phase += 1 end end #-------------------------------------------------------------------------- # ● 近接攻撃実行 [攻撃動作からの復帰] #-------------------------------------------------------------------------- def diratk_wait # 終了カウント @direct_attack_cnt -= 1 # 最終移動 if @direct_attack_cnt <= 0 # ポーズ変更 @pattern = 3 # ENDフェーズ @direct_attack_phase = 0 @battler.motion_stop = false end end #-------------------------------------------------------------------------- # ● 近接攻撃実行 [攻撃動作からの復帰] #-------------------------------------------------------------------------- def diratk_attack # ポーズ変更 @pattern = 1 # 終了ウェイトカウント @direct_attack_cnt = (@direct_move_cnt/2).round # NEXTフェーズ @direct_attack_phase += 1 end #-------------------------------------------------------------------------- # ● 近接攻撃実行 [移動動作(帰り)] #-------------------------------------------------------------------------- def diratk_back # 現在の位置と目標位置から次の移動位置を割り出す pos_x = @battler.screen_x - self.x pos_y = @battler.screen_y - self.y @battler_x_plus += pos_x / @direct_attack_cnt if @direct_attack_cnt != 0 @battler_y_plus += pos_y / @direct_attack_cnt if @direct_attack_cnt != 0 # 終了カウント @direct_attack_cnt -= 1 # 最終移動 if @direct_attack_cnt <= 0 @battler_x_plus = 0 @battler_y_plus = 0 # NEXTフェーズ @direct_attack_phase += 1 end end #-------------------------------------------------------------------------- # ● 近接攻撃実行 [動作終了] #-------------------------------------------------------------------------- def diratk_end init_direct_attack # ENDフェーズ @direct_attack_phase = 0 end end class Game_Battler attr_accessor :dead_delay # 戦闘不能効果遅延フラグ attr_accessor :revive_delay # 蘇生効果遅延フラグ attr_accessor :move_mode # 動作モード # 0:待機 1:攻撃 2:非ダメ 3:勝利 attr_accessor :motion_stop # 動作停止フラグ(移動中フラグ) attr_accessor :target_x # 移動先位置(x) attr_accessor :target_y # 移動先位置(y) #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_sdva_corpse initialize def initialize initialize_sdva_corpse @dead_delay = false @revive_delay = false @move_mode = 0 end end class Scene_Battle #-------------------------------------------------------------------------- # ● プレバトルフェーズ開始 #-------------------------------------------------------------------------- alias start_phase1_sidew start_phase1 def start_phase1 for battler in $game_party.actors + $game_troop.enemies battler.move_mode = SideView::M_MODE_WAIT end start_phase1_sidew end #-------------------------------------------------------------------------- # ● アフターバトルフェーズ開始 #-------------------------------------------------------------------------- alias start_phase5_sidew start_phase5 def start_phase5 for actor in $game_party.actors actor.move_mode = SideView::M_MODE_WIN end start_phase5_sidew end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始) #-------------------------------------------------------------------------- alias update_phase4_step2_sidew update_phase4_step2 def update_phase4_step2 update_phase4_step2_sidew @motion_flag = false @active_battler.motion_stop = false @active_battler.move_mode = SideView::M_MODE_WAIT end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 3 : 行動側アニメーション) #-------------------------------------------------------------------------- alias update_phase4_step3_sidew update_phase4_step3 def update_phase4_step3 if @motion_flag unless @active_battler.motion_stop @motion_flag = false @phase4_step = 4 return end @active_battler.move_mode = SideView::M_MODE_ATK1 return end update_phase4_step3_sidew # 通常攻撃 case @active_battler.current_action.kind when 0 # 通常攻撃 if @active_battler.current_action.basic == 0 SideView.set_target_point(@active_battler, @target_battlers[0]) @active_battler.motion_stop = true @motion_flag = true @phase4_step = 3 end when 1 # スキル if SideView.skill_is_direct?(@skill) SideView.set_target_point(@active_battler, @target_battlers[0]) @active_battler.motion_stop = true @motion_flag = true @phase4_step = 3 end end end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 4 : 対象側アニメーション) #-------------------------------------------------------------------------- alias update_phase4_step4_sidew update_phase4_step4 def update_phase4_step4 update_phase4_step4_sidew case @active_battler.current_action.kind when 0 # 通常攻撃 if @active_battler.current_action.basic == 0 @active_battler.move_mode = SideView::M_MODE_ATK2 end when 1 # スキル if SideView.skill_is_direct?(@skill) @active_battler.move_mode = SideView::M_MODE_ATK2 else @active_battler.move_mode = SideView::M_MODE_MAGI end when 2 # アイテム @active_battler.move_mode = SideView::M_MODE_MAGI end for target in @target_battlers if target.damage.is_a?(Numeric) target.move_mode = SideView::M_MODE_DAMG if target.damage > 0 end end end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示) #-------------------------------------------------------------------------- alias update_phase4_step5_sdva_corpse update_phase4_step5 def update_phase4_step5 update_phase4_step5_sdva_corpse if @active_battler.move_mode == SideView::M_MODE_ATK2 @active_battler.move_mode = SideView::M_MODE_ATK3 end for target in @target_battlers target.move_mode = SideView::M_MODE_WAIT if target.dead? target.dead_delay = true target.revive_delay = false elsif !target.revive_delay and !target.dead? # 蘇生効果遅延 target.revive_delay = true end end end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ) #-------------------------------------------------------------------------- alias update_phase4_step6_sidew update_phase4_step6 def update_phase4_step6 @active_battler.move_mode = SideView::M_MODE_WAIT for target in @target_battlers target.move_mode = 0 end update_phase4_step6_sidew end end