#============================================================================== # # ■メニューで使用効果アニメ □Ver1.04 □製作者:月紳士 # ・RPGツクールVX Ace用 RGSS3スクリプト # ・アクターインベントリ互換 (to Ver3.00) # # ●…上書き ◎…エイリアス ○…新規と新規への上書き # # ※二次配布禁止!配布元には利用規約があります。必ずそちらを見てください。 #============================================================================== =begin  このスクリプトは  メニュー画面でスキルやアイテムを使用した際に、アクターの顔に  戦闘時に敵に使われる効果アニメを適用する、というスクリプトです。  特にカスタマイズを必要とする項目はありません。  導入することで適用されます。  ※ 月紳士のスクリプト【アクターインベントリ】と併用する際は    このスクリプトを【アクターインベントリ】より後に導入してください。 =end #============================================================================== # ■ Sound(効果音のカスタマイズはここを直接書き換えて下さい) #------------------------------------------------------------------------------ #  効果音を演奏するモジュールです。グローバル変数 $data_system からデータベー # スで設定された SE の内容を取得し、演奏します。 #============================================================================== module Sound # アニメーション後の効果音設定。 # これ以外は、デフォルトで設定されているものを流用しています。 # ステート付加 def self.play_add_state Audio.se_play("Audio/SE/Heal6", 80, 100) end # ステート解除 def self.play_remove_state Audio.se_play("Audio/SE/Heal7", 80, 100) end # MP減少 def self.play_mp_down Audio.se_play("Audio/SE/Down1", 80, 100) end end #============================================================================== # ■ Window_Base #------------------------------------------------------------------------------ #  ゲーム中のすべてのウィンドウのスーパークラスです。 #============================================================================== class Window_Base < Window #-------------------------------------------------------------------------- # ◎ オブジェクト初期化 # x : ウィンドウの X 座標 # y : ウィンドウの Y 座標 # width : ウィンドウの幅 # height : ウィンドウの高さ #-------------------------------------------------------------------------- alias mgs_mua_initialize initialize def initialize(x, y, width, height) mgs_mua_initialize(x, y, width, height) clear_drew_face_data end #-------------------------------------------------------------------------- # ○ 描画済み顔グラフィックデータのクリア #-------------------------------------------------------------------------- def clear_drew_face_data @drew_face_rect = [] @drew_face_name = [] @drew_face_index = [] end #-------------------------------------------------------------------------- # ◎ 顔グラフィックの描画 # ※ 描画時の情報を記憶してスプライトを作る際のデータにする。 #-------------------------------------------------------------------------- alias mgs_mua_draw_face draw_face def draw_face(face_name, face_index, x, y, enabled = true) mgs_mua_draw_face(face_name, face_index, x, y, enabled) rect = Rect.new(x, y, 96, 96) index = @drew_face_rect.index(rect) if index != nil # 矩形取得済みなら書き直し(データの変更)とみなして再取得 @drew_face_name[index] = face_name @drew_face_index[index] = face_index else @drew_face_rect.push(rect) @drew_face_name.push(face_name) @drew_face_index.push(face_index) end end #-------------------------------------------------------------------------- # ○ 顔グラアニメ用スプライトの作成 #-------------------------------------------------------------------------- def create_face_sprite(index) return nil unless @drew_face_rect[index] sprite_x = @drew_face_rect[index].x + 12 + self.x - self.ox sprite_y = @drew_face_rect[index].y + 12 + self.y - self.oy return nil if sprite_x > (self.x + self.width - standard_padding) return nil if sprite_y > (self.y + self.height - standard_padding) sprite = Sprite_Base.new sprite.bitmap = Bitmap.new(@drew_face_rect[index].width, @drew_face_rect[index].height) bitmap = Cache.face(@drew_face_name[index]) rect = Rect.new(0, 0, 0, 0) rect.x = @drew_face_index[index] % 4 * 96 + (96 - @drew_face_rect[index].width) / 2 rect.y = @drew_face_index[index] / 4 * 96 + (96 - @drew_face_rect[index].height) / 2 rect.width = @drew_face_rect[index].width rect.height = @drew_face_rect[index].height sprite.bitmap.blt(0, 0, bitmap, rect) bitmap.dispose sprite.x = sprite_x sprite.y = sprite_y sprite.z = 200 return sprite end #-------------------------------------------------------------------------- # ○ アイテム使用アニメーションの処理 #-------------------------------------------------------------------------- def display_use_animation(obj) if obj.for_all? face_animation_all(obj) elsif obj.for_user? face_animation(@index - 100, obj) # 自分自身の場合 else face_animation(@index, obj) end end #-------------------------------------------------------------------------- # ○ 顔グラフィックへのアニメーション(単体) #-------------------------------------------------------------------------- def face_animation(index, obj) return Sound.play_cancel if obj.for_opponent? # 敵対象アイテムのメニュー使用 if obj.for_friend? animation = $data_animations[obj.animation_id] sprite = create_face_sprite(index) unless animation.nil? end if sprite.nil? Sound.play_use_item if obj.is_a?(RPG::Item) Sound.play_use_skill if obj.is_a?(RPG::Skill) else sprite.start_animation(animation) while sprite.animation? sprite.update Graphics.update end sprite.dispose play_se(obj) end end #-------------------------------------------------------------------------- # ○ 顔グラフィックへのアニメーション(全体) #-------------------------------------------------------------------------- def face_animation_all(obj) return Sound.play_cancel if obj.for_opponent? # 敵対象アイテムのメニュー使用 time_lag = 15 # ↑エフェクトの時間差。調節可能。0 にするとメンバー全体同時。 if obj.for_friend? animation = $data_animations[obj.animation_id] end if animation.nil? or @drew_face_rect.compact.empty? Sound.play_use_item if obj.is_a?(RPG::Item) Sound.play_use_skill if obj.is_a?(RPG::Skill) else sprites = [] @drew_face_rect.size.times{|i|sprites.push(create_face_sprite(i))} sprites.compact! sprites.each do |sprite| unless sprite.nil? sprite.start_animation(animation) time_lag.times do sprites.compact.each{|i|i.update} Graphics.update end end end animation_end = false until animation_end animation_end = true sprites.compact.each do |i| i.update animation_end = false if i.animation? end Graphics.update end sprites.each{|i|i.dispose} play_se(obj) end end #-------------------------------------------------------------------------- # ○ 使用後SEの演奏 #-------------------------------------------------------------------------- def play_se(obj) case obj.damage.type when 1 ; Sound.play_actor_damage # HP ダメージ when 2 ; Sound.play_mp_down # MP ダメージ when 3 ; Sound.play_recovery # HP 回復 when 4 ; Sound.play_recovery # MP 回復 else if obj.effects.any?{|effect|effect.code == 21} # ステート付加 Sound.play_add_state elsif obj.effects.any?{|effect|effect.code == 22} # ステート解除 Sound.play_remove_state elsif obj.is_a?(RPG::Skill) # スキルの場合 # その他 Sound.play_use_skill else # アイテムの場合 Sound.play_use_item end end end end #============================================================================== # □ Window_ActorInventoryStatus #------------------------------------------------------------------------------ #  アクターインベントリ画面用のステータスウインドウです。 #============================================================================== class Window_ActorInventoryStatus < Window_Selectable #-------------------------------------------------------------------------- # ○ アイテム使用アニメーションの処理 #-------------------------------------------------------------------------- def display_use_animation(obj) face_animation(0, obj) end end #============================================================================== # ■ Window_Selectable #------------------------------------------------------------------------------ #  カーソルの移動やスクロールの機能を持つウィンドウクラスです。 #============================================================================== class Window_Selectable < Window_Base #-------------------------------------------------------------------------- # ◎ ウィンドウ内容の作成 #-------------------------------------------------------------------------- alias mgs_mua_create_contents create_contents def create_contents clear_drew_face_data mgs_mua_create_contents end end #============================================================================== # ■ Scene_Item #------------------------------------------------------------------------------ #  アイテム画面の処理を行うクラスです。 #============================================================================== class Scene_Item < Scene_ItemBase #-------------------------------------------------------------------------- # ● アイテム使用時の SE 演奏 #-------------------------------------------------------------------------- def play_se_for_item @actor_window.display_use_animation(item) end end #============================================================================== # ■ Scene_Skill #------------------------------------------------------------------------------ #  スキル画面の処理を行うクラスです。処理共通化の便宜上、スキルも「アイテム」 # として扱っています。 #============================================================================== class Scene_Skill < Scene_ItemBase #-------------------------------------------------------------------------- # ● アイテム使用時の SE 演奏 #-------------------------------------------------------------------------- def play_se_for_item @actor_window.display_use_animation(item) end end #============================================================================== # □ Scene_ActorInventory #------------------------------------------------------------------------------ #  アクターインベントリ画面の処理を行うクラスです。 #============================================================================== class Scene_ActorInventory < Scene_MenuBase #-------------------------------------------------------------------------- # ○ アイテム使用時の SE 演奏 #-------------------------------------------------------------------------- def play_se_for_item if item.for_user? or $game_party.members.size == 1 && item.for_friend? @status_window.display_use_animation(item.effect) elsif item.for_friend? @actor_window.display_use_animation(item.effect) else Sound.play_use_item end end end