#============================================================================ # # ■メニューで使用効果アニメ □Ver2.05 □製作者:月紳士 # ・RPGツクールVX用 RGSS2スクリプト # # ●…書き換えメソッド(競合注意) ◎…メソッドのエイリアス ○…新規メソッド # # ※二次配布禁止!配布元には利用規約があります。必ずそちらを見てください。 #---------------------------------------------------------------------------- # 更新履歴 # Ver.2.05 アニメーション無しのオブジェクト使用時の不具合を修正。 # Ver.2.04 味方以外効果アイテムのアニメが表示されてしまう不具合を修正。 # Ver.2.03 使用後SE「スキルその他」がアイテム使用時音になっていたので微修正。 # Ver.2.02 対象が使用者の場合にアニメが表示されなかったことの修正。 # Ver.2.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/Down", 80, 100) end end #============================================================================== # ■ Window_Base #------------------------------------------------------------------------------ #  ゲーム中のすべてのウィンドウのスーパークラスです。 #============================================================================== class Window_Base < Window #-------------------------------------------------------------------------- # ◎ オブジェクト初期化 # x : ウィンドウの X 座標 # y : ウィンドウの Y 座標 # width : ウィンドウの幅 # height : ウィンドウの高さ #-------------------------------------------------------------------------- alias tig_fs_initialize initialize def initialize(x, y, width, height) tig_fs_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 tig_fs_draw_face draw_face def draw_face(face_name, face_index, x, y, size = 96) tig_fs_draw_face(face_name, face_index, x, y, size) rect = Rect.new(x, y, size, size) index = @drew_face_rect.index(rect) if index # 取得済みなら書き直し(データの変更)とみなして再取得 @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 = 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 = @drew_face_rect[index].x + 16 + self.x sprite.y = @drew_face_rect[index].y + 16 + self.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? # 敵対象アイテムのメニュー使用 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.each do |sprite| unless sprite.nil? sprite.start_animation(animation) 10.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) if obj.is_a?(RPG::Item) if obj.hp_recovery_rate > 0 or obj.hp_recovery > 0 or obj.mp_recovery_rate > 0 or obj.mp_recovery > 0 or obj.base_damage < 0 Sound.play_recovery elsif obj.hp_recovery_rate < 0 or obj.hp_recovery < 0 or obj.base_damage > 0 Sound.play_actor_damage elsif obj.mp_recovery_rate < 0 or obj.mp_recovery < 0 Sound.play_mp_down elsif not obj.plus_state_set.empty? Sound.play_add_state elsif not obj.minus_state_set.empty? Sound.play_remove_state else Sound.play_use_item end elsif obj.is_a?(RPG::Skill) if obj.base_damage < 0 Sound.play_recovery elsif obj.base_damage > 0 and not obj.damage_to_mp Sound.play_actor_damage elsif obj.base_damage > 0 and obj.damage_to_mp Sound.play_mp_down elsif not obj.plus_state_set.empty? Sound.play_add_state elsif not obj.minus_state_set.empty? Sound.play_remove_state else Sound.play_use_skill end end end end #============================================================================== # ■ Window_Selectable #------------------------------------------------------------------------------ #  カーソルの移動やスクロールの機能を持つウィンドウクラスです。 #============================================================================== class Window_Selectable < Window_Base #-------------------------------------------------------------------------- # ◎ ウィンドウ内容の作成 #-------------------------------------------------------------------------- alias tig_fs_create_contents create_contents def create_contents clear_drew_face_data tig_fs_create_contents end end #============================================================================== # ■ Scene_Item #------------------------------------------------------------------------------ #  アイテム画面の処理を行うクラスです。 #============================================================================== class Scene_Item < Scene_Base #-------------------------------------------------------------------------- # ● アイテムの使用 (味方対象以外の使用効果を適用) #-------------------------------------------------------------------------- def use_item_nontarget @target_window.display_use_animation(@item) # 変更箇所 # Sound.play_use_item と差し替えてるだけ $game_party.consume_item(@item) @item_window.draw_item(@item_window.index) @target_window.refresh if $game_party.all_dead? $scene = Scene_Gameover.new elsif @item.common_event_id > 0 $game_temp.common_event_id = @item.common_event_id $scene = Scene_Map.new end end end #============================================================================== # ■ Scene_Skill #------------------------------------------------------------------------------ #  スキル画面の処理を行うクラスです。 #============================================================================== class Scene_Skill < Scene_Base #-------------------------------------------------------------------------- # ● スキルの使用 (味方対象以外の使用効果を適用) #-------------------------------------------------------------------------- def use_skill_nontarget @target_window.display_use_animation(@skill) # 変更箇所 # Sound.play_use_skill と差し替えてるだけ @actor.mp -= @actor.calc_mp_cost(@skill) @status_window.refresh @skill_window.refresh @target_window.refresh if $game_party.all_dead? $scene = Scene_Gameover.new elsif @skill.common_event_id > 0 $game_temp.common_event_id = @skill.common_event_id $scene = Scene_Map.new end end end