#============================================================================== # ■ VX-RGSS2-6 サイドビュー戦闘[MotionExe] [Ver.1.2.0] by Claimh #------------------------------------------------------------------------------ # アクターのモーションを実行をする場所です。 #------------------------------------------------------------------------------ # スキルの移動攻撃条件: 効果範囲が敵単体 & 打撃関係度が50以上 & 精神関係度が50未満 #============================================================================== module SideView #---------------------------------------------------------------------------- #-----[動作設定]----- # 動作スピード MOTION_SPEED = 20 #-----[アニメーション設定]----- # エネミーの通常攻撃アニメーション設定 E_ANIME = { # エネミーID => [通常攻撃のアニメーション, 追加攻撃のアニメーション] 1 => [1, 0] } #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- # モーションコントロールモード 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 = Cache.character(target.character_name) attacker.target_x = target.screen_x + (bits.width / 8) attacker.target_y = target.screen_y when Game_Enemy bits = 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 false if skill.scope != 1 and skill.scope != 3 and skill.scope != 4 return (skill.atk_f >= 50 and skill.spi_f < 50) end end class Game_Battler 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 @move_mode = 0 @motion_stop = false @target_x = 0 @target_y = 0 end end #============================================================================== # ■ Game_Enemy #============================================================================== class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ● 通常攻撃 アニメーション ID の取得 #-------------------------------------------------------------------------- def atk_animation_id return 0 if SideView::E_ANIME[@enemy_id].nil? return SideView::E_ANIME[@enemy_id][0] end #-------------------------------------------------------------------------- # ● 通常攻撃 アニメーション ID の取得 (二刀流:武器2) #-------------------------------------------------------------------------- def atk_animation_id2 return 0 if SideView::E_ANIME[@enemy_id].nil? return SideView::E_ANIME[@enemy_id][1] end end #============================================================================== # ■ Sprite_Battler #============================================================================== class Sprite_Battler < Sprite_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート # battler : バトラー (Game_Battler) #-------------------------------------------------------------------------- alias initialize_sideview initialize def initialize(viewport, battler = nil) initialize_sideview(viewport, battler) 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 @moving_mode = 0 @pattern = 0 @direction = 0 end #-------------------------------------------------------------------------- # ● フレーム更新 [再定義] #-------------------------------------------------------------------------- def update super if @battler == nil self.bitmap = nil else @use_sprite = @battler.use_sprite? if @use_sprite self.x = @battler.screen_x + @battler_x_plus self.y = @battler.screen_y + @battler_y_plus self.z = @battler.screen_z update_battler_bitmap end setup_new_effect update_effect end end #-------------------------------------------------------------------------- # ● 転送元ビットマップの更新 #-------------------------------------------------------------------------- alias update_battler_bitmap_sideview update_battler_bitmap def update_battler_bitmap case @battler when Game_Actor if @battler.character_name != @battler_name or @battler.character_index != @battler_hue @battler_name = @battler.character_name @battler_hue = @battler.character_index draw_pre_character draw_character if (@battler.dead? or @battler.hidden) self.opacity = 0 end end when Game_Enemy if @battler.battler_name != @battler_name or @battler.battler_hue != @battler_hue @battler_name = @battler.battler_name @battler_hue = @battler.battler_hue draw_battler if (@battler.dead? or @battler.hidden) self.opacity = 0 end end end motion_control end #-------------------------------------------------------------------------- # ● バトラー描画 #-------------------------------------------------------------------------- def draw_battler self.bitmap = Cache.battler(@battler_name, @battler_hue) @width = bitmap.width @height = bitmap.height self.ox = @width / 2 self.oy = @height end #-------------------------------------------------------------------------- # ● ホコグラ描画準備 [共通] #-------------------------------------------------------------------------- def draw_pre_character self.bitmap = Cache.character(@battler_name) sign = @battler_name[/^[\!\$]./] if sign != nil and sign.include?('$') @width = bitmap.width / 3 @height = bitmap.height / 4 else @width = bitmap.width / 12 @height = bitmap.height / 8 end self.ox = @width / 2 self.oy = @height end #-------------------------------------------------------------------------- # ● ホコグラ描画 [共通] #-------------------------------------------------------------------------- def draw_character index = @battler_hue pattern = @pattern < 3 ? @pattern : 1 sx = (index % 4 * 3 + pattern) * @width sy = (index / 4 * 4 + (@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 # 動作チェンジ 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 @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 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 @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 else p "error:Sprite_Battler>> @moving_mode", @moving_mode end 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 / SideView::MOTION_SPEED).round # NEXTフェーズ @direct_attack_phase += 1 end #-------------------------------------------------------------------------- # ● 近接攻撃実行 [移動動作(行き)] #-------------------------------------------------------------------------- def diratk_move case @battler when Game_Actor x_plus = @width y_plus = -@height / 4 when Game_Enemy x_plus = -@width - 10 y_plus = @height / 4 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 # 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 @battler.motion_stop = false # ENDフェーズ @direct_attack_phase = 0 end end