#==============================================================================
# ■ 画面动画只播放一次 By:Akahara
#------------------------------------------------------------------------------
#
# 由于进行了重定义建议放在插件脚本位置较前的地方
#
# 解决了多个敌人播放画面动画会重叠好几次的问题
# 第一个目标不变
# 其他目标时“闪烁目标”,“隐藏目标”会照常播放
# “播放se”,“闪烁画面”不会播放
#
#------------------------------------------------------------------------------
class Game_Battler < Game_BattlerBase
attr_accessor :hide_animation
alias akahara_hidea_initialize initialize
def initialize
@hide_animation = false
akahara_hidea_initialize
end
end
class Sprite_Base < Sprite
def start_animation(animation, mirror = false, hide = false)
dispose_animation
@hide = hide
@animation = animation
if @animation
@ani_mirror = mirror
set_animation_rate
@ani_duration = @animation.frame_max * @ani_rate + 1
load_animation_bitmap
make_animation_sprites
set_animation_origin
end
end
def update_animation
return unless animation?
@ani_duration -= 1
if @ani_duration % @ani_rate == 0
if @ani_duration > 0
frame_index = @animation.frame_max
frame_index -= (@ani_duration + @ani_rate - 1) / @ani_rate
animation_set_sprites(@animation.frames[frame_index]) unless @hide == true
@animation.timings.each do |timing|
animation_process_timing(timing, @hide) if timing.frame == frame_index
end
else
end_animation
end
end
end
def animation_process_timing(timing, hide = false)
timing.se.play unless hide == true || @ani_duplicated
case timing.flash_scope
when 1
self.flash(timing.flash_color, timing.flash_duration * @ani_rate)
when 2
if viewport && !@ani_duplicated
viewport.flash(timing.flash_color, timing.flash_duration * @ani_rate) unless hide == true
end
when 3
self.flash(nil, timing.flash_duration * @ani_rate)
end
end
end
class Sprite_Battler < Sprite_Base
def setup_new_animation
if @battler.animation_id > 0
animation = $data_animations[@battler.animation_id]
mirror = @battler.animation_mirror
hide = @battler.hide_animation
start_animation(animation, mirror, hide)
@battler.hide_animation = false
@battler.animation_id = 0
end
end
end
class Scene_Battle < Scene_Base
def show_normal_animation(targets, animation_id, mirror = false)
animation = $data_animations[animation_id]
if animation
targets.each_with_index do |target,index|
target.hide_animation = true if animation.to_screen? && target != targets[0]
target.animation_id = animation_id
target.animation_mirror = mirror
abs_wait_short unless animation.to_screen?
end
abs_wait_short if animation.to_screen?
end
end
end