#============================================================================== # ■ RPG::Sprite #------------------------------------------------------------------------------ #  アニメーションの管理を行うクラスです。 #============================================================================== module RPG class Sprite < ::Sprite def animation(animation, hit, critical = false) dispose_animation @_animation = animation return if @_animation == nil @_animation_hit = hit @_animation_critical = critical @_animation_duration = @_animation.frame_max animation_name = @_animation.animation_name animation_hue = @_animation.animation_hue bitmap = RPG::Cache.animation(animation_name, animation_hue) if @@_reference_count.include?(bitmap) @@_reference_count[bitmap] += 1 else @@_reference_count[bitmap] = 1 end @_animation_sprites = [] if @_animation.position != 3 or not @@_animations.include?(animation) for i in 0..15 sprite = ::Sprite.new(self.viewport) sprite.bitmap = bitmap sprite.visible = false @_animation_sprites.push(sprite) end unless @@_animations.include?(animation) @@_animations.push(animation) end end update_animation end def update_animation if @_animation_duration > 0 frame_index = @_animation.frame_max - @_animation_duration cell_data = @_animation.frames[frame_index].cell_data position = @_animation.position animation_set_sprites(@_animation_sprites, cell_data, position) for timing in @_animation.timings if timing.frame == frame_index animation_process_timing(timing, @_animation_hit, @_animation_critical) end end else dispose_animation end end def animation_process_timing(timing, hit, critical) if (timing.condition == 0) or (timing.condition == 1 and hit == true) or (timing.condition == 2 and critical == true) if timing.se.name != "" se = timing.se Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch) end case timing.flash_scope when 1 self.flash(timing.flash_color, timing.flash_duration * 2) when 2 if self.viewport != nil self.viewport.flash(timing.flash_color, timing.flash_duration * 2) end when 3 self.flash(nil, timing.flash_duration * 2) end end end end end #============================================================================== # ■ Game_Battler #------------------------------------------------------------------------------ #  バトラーを扱うクラスです。このクラスは Game_Actor クラスと Game_Enemy クラ # スのスーパークラスとして使用されます。 #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :animation_critical # アニメーション クリティカルフラグ #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias :critical_initialize :initialize def initialize critical_initialize @animation_critical = false end end #============================================================================== # ■ Sprite_Battler #------------------------------------------------------------------------------ #  バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、 # スプライトの状態を自動的に変化させます。 #============================================================================== class Sprite_Battler < RPG::Sprite #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # バトラーが nil の場合 if @battler == nil self.bitmap = nil loop_animation(nil) return end # ファイル名か色相が現在のものと異なる場合 if @battler.battler_name != @battler_name or @battler.battler_hue != @battler_hue # ビットマップを取得、設定 @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 # 戦闘不能または隠れ状態なら不透明度を 0 にする if @battler.dead? or @battler.hidden self.opacity = 0 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 end end # 可視の場合 if @battler_visible # 逃走 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_critical) @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 collapse @battler_visible = false end end # スプライトの座標を設定 self.x = @battler.screen_x self.y = @battler.screen_y self.z = @battler.screen_z end end #============================================================================== # ■ Scene_Battle #------------------------------------------------------------------------------ #  バトル画面の処理を行うクラスです。 #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 4 : 対象側アニメーション) #-------------------------------------------------------------------------- alias :base_update_phase4_step4 :update_phase4_step4 def update_phase4_step4 for target in @target_battlers target.animation_critical = target.critical end base_update_phase4_step4 end end