#============================================================================== # ■ アニメーションするエネミー(改 RGSS3仕様改変) 本体 #  参考: Supponの意味不明ブログ 様 #     http://supponweblog.blog88.fc2.com/blog-entry-43.html #------------------------------------------------------------------------------ # 戦闘中にエネミーをゆらゆらと動かしたり、 # キャラのようにアニメーションさせたり、音を出したりします。 (改造 By むー) #============================================================================== #============================================================================== # ★付きコメントは「Supponの意味不明ブログ」様の仕様部分です。 # 記号のないコメント部分は自作部分です。 #============================================================================== #============================================================================== # ■ Game_Enemy #------------------------------------------------------------------------------ #  敵キャラを扱うクラスです。このクラスは Game_Troop クラス($game_troop)の # 内部で使用されます。 #============================================================================== class Game_Enemy < Game_Battler attr_accessor :battler_name end #============================================================================== # ■ Sprite_Battler #------------------------------------------------------------------------------ #  バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、 # スプライトの状態を自動的に変化させます。 #============================================================================== class Sprite_Battler < Sprite_Base #============================================================================ # ○ 配列番号取得 (設定の配列構造が変わった場合は変える) #============================================================================ def animation_number(id) return 0 if id == 0 # エネミーID return 1 if id == 1 # 通常時アニメーション画像 return 2 if id == 2 # 通常時アニメーション間隔 return 3 if id == 3 # 通常時アニメーション回帰フレーム数 return 4 if id == 4 # 動けない場合の画像 return 5 if id == 5 # 通常時アニメーション中にサウンドを鳴らすフレーム位置 return 6 if id == 6 # サウンドファイル return 7 if id == 7 # サウンドボリューム return 8 if id == 8 # サウンドピッチ return 9 if id == 9 # スキル使用時アニメーション画像 end #============================================================================ # ○ アニメーション配列順取得 #============================================================================ def animation_number_action(enemy_arr, arr_index, skill_id) # スキルIDが0の場合は通常行動と見なす if skill_id == 0 # 通常行動アニメーション情報を取得 return_1 = enemy_arr[animation_number(1)] return_2 = enemy_arr[animation_number(2)] return_3 = enemy_arr[animation_number(3)][0] # 返す return [return_1, return_2, return_3] # スキル使用時 else # 対象エネミーの配列を別変数に変換 animation_index = enemy_arr # 配列検索用カウント初期化 arr_find_count = 0 # 該当スキルIDを検索するループ for arr_find in animation_index # 一致するスキルIDが合った場合 if arr_find[arr_find_count].class == Array # スキル検索用カウント初期化 skill_find_count = 0 # 該当スキルIDを検索するループ for skill_find in arr_find # 一致するスキルIDがあった場合 if skill_find == skill_id # 配列から各値を取得 return_1 = arr_find[skill_find_count + 1] return_2 = arr_find[skill_find_count + 2] return_3 = arr_find[skill_find_count + 3][0] # スキルアニメーション開始時はフレームを0にする if $action_flg != 0 and $timer_flag == true @c = 0 # 現在のフレーム数を0化 $timer_flag = false # 開始時フラグ解除 end # 返す return [return_1, return_2, return_3] break else # 次の配列要素へのカウント skill_find_count += 1 end end end arr_find_count += 1 end # 該当スキルがなかった場合は通常時のアニメーションを指定 return_1 = animation_index[animation_number(1)] return_2 = animation_index[animation_number(2)] return_3 = animation_index[animation_number(3)][0] # 返す return [return_1, return_2, return_3] end end #============================================================================ # ◎ オブジェクト初期化 #============================================================================ alias initialize_enemy_animation initialize def initialize(viewport, battler = nil) initialize_enemy_animation(viewport, battler) super(viewport) @battler = battler @battler_visible = false @effect_type = nil # エフェクトの種類 @effect_duration = 0 # エフェクトの残り時間 @t = rand(720) # ★ ゆらゆら繰り返し用時間初期値 @c = 0 # アニメーション用フラグ初期値 $attack_flg = 0 # 行動パターン用グローバル変数 end #============================================================================ # ◎ フレーム更新 #============================================================================ alias update_enemy_animation update def update super if @battler @use_sprite = @battler.use_sprite? if @use_sprite and !@battler.actor? motion #★ ゆらゆら動く位置の計算呼び出し self.bitmap = Cache.battler($data_enemies[@battler.enemy_id].battler_name, 0) self.x = @battler.screen_x + @ax #★ X座標に動作分プラス self.y = @battler.screen_y - self.bitmap.height + @ay #★ Y座標に動作分プラス self.z = @battler.screen_z end update_enemy_animation setup_new_effect setup_new_animation update_effect # 行動がアクターかエネミーか if @battler.actor? # アクターなら素通り else # 配列の順番を取得 arr_en_id = animation_number(0) # エネミーID arr_en_dn = animation_number(4) # 行動不能時画像 arr_sn_nm = animation_number(5) # 音番号 arr_sn_fl = animation_number(6) # SEファイル arr_sn_vl = animation_number(7) # 音量 arr_sn_pc = animation_number(8) # ピッチ arr_an_sk = animation_number(9) # スキルアニメーション配列 # エネミーでかつアニメーションリストが設定されている場合 if MOO_ENEMY_ANIMATION::ANIME.size > 0 # リストループ for enemyindex in MOO_ENEMY_ANIMATION::ANIME # 各値の取得 enemyid = enemyindex[arr_en_id] # エネミーID enemymove = enemyindex[arr_en_dn] # 行動不能時画像 enemysnd = enemyindex[arr_sn_nm] # 音番号配列 # 戦闘中の対象バトラーのIDがリストのエネミーIDと一致した場合 if @battler.enemy_id == enemyid # アクションによるアニメーション配列番号取得 if $action_flg == nil # 初回 s_id = 0 elsif $action_flg == 0 # 通常時 s_id = 0 elsif $action_flg >= 1 and $enemy_index == @battler.index # スキル使用時 s_id = $action_flg else # イレギュラー時 s_id = 0 end # アニメーション配列読み込み arr_en_pc = animation_number_action(enemyindex, arr_an_sk, s_id) enemypic = arr_en_pc[0] # エネミー画像配列 enemytime = arr_en_pc[1] # アニメーション間隔フレーム配列 arr_en_tl = arr_en_pc[2] # 回帰フレーム数 # 普通に動ける状態の場合 if @battler.movable? # アニメーション時間加減変数 @c += 1 # 画像を指定 if enemytime.index(@c) != nil # 画像2を指定 $game_troop.members[@battler.index].battler_name = enemypic[enemytime.index(@c)] # SEが指定されていれば鳴らす if enemysnd[enemytime.index(@c)] == 1 Audio.se_play(enemyindex[arr_sn_fl], enemyindex[arr_sn_vl], enemyindex[arr_sn_pc]) end @c = -1 * arr_en_tl if @c == enemytime.last end else # 行動不能の場合は行動不能時画像を指定 $game_troop.members[@battler.index].battler_name = enemymove end end end end end setup_new_effect update_effect else self.bitmap = nil @effect_type = nil end end #============================================================================ # ○ ゆらゆら動く #============================================================================ def motion #★ return unless @battler.movable? if @battler.enemy_id != nil # エネミーのメモ欄にキーワードがあった場合 if $data_enemies[@battler.enemy_id].note.include?(MOO_ENEMY_ANIMATION::MEMO) if @battler.movable? # エネミーが普通に動ける状態の場合はゆらゆら計算(ここを変えれば揺れ方が変わる) @ax = (Math.sin(Math::PI * @t * 2 / 360.0) * 10).ceil @ay = (Math.sin(Math::PI * @t * 1 / 360.0) * 4).ceil @t += 1 @t = 0 if @t >= 720 else # 行動不能の場合は位置を固定 @ax = 0 @ay = 0 @t += 0 end else # キーワードがない場合は位置を固定 @ax = 0 @ay = 0 @t += 0 end end end end #============================================================================== # ■ Scene_Battle #------------------------------------------------------------------------------ #  バトル画面の処理を行うクラスです。 #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● スキル/アイテムの使用 #-------------------------------------------------------------------------- def use_item item = @subject.current_action.item # ▼追加------------------------------------------------------------------ # グローバル変数初期化 clear_flg # Troopインデックスを変数へ格納 $enemy_index = @subject.index if @subject.class == Game_Enemy # スキルIDを変数へ格納 $action_flg = item.id if @subject.class == Game_Enemy # フレーム数初期化変数 $timer_flag = true # ▲追加----------------------------------------------------------------- @log_window.display_use_item(@subject, item) @subject.use_item(item) refresh_status targets = @subject.current_action.make_targets.compact show_animation(targets, item.animation_id) targets.each {|target| item.repeats.times { invoke_item(target, item) } } # ▼追加------------------------------------------------------------------ # グローバル変数クリア # ----------------------------------------------------------------------- clear_flg # ▲追加----------------------------------------------------------------- end #-------------------------------------------------------------------------- # ○ グローバル変数初期化 #-------------------------------------------------------------------------- def clear_flg $action_flg = 0 $action_flm = 0 $enemy_index = -1 $timer_flag = false end end