#==============================================================================
# +++ MOG - Animation (1.5) +++
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# By Moghunter
# [url]http://www.atelier-rgss.com/RGSS/RGSS_VX_ACE.html[/url]
#==============================================================================
# 使数据库中的动画用途更广
#==============================================================================
# 写在技能、物品、状态的备注中 ID = 动画ID
# ----------------------------------------
# ● 命中动画 ●
# <Hit Animation = ID> 当攻击命中目标后的动画
# ----------------------------------------
# ● 启动动画① ●
# <Use Animation = ID> 攻击前的动画 可以理解为准备动作
# 此动画以使用者自己为目标 可以设计成攻击动作
# ----------------------------------------
# ● 启动动画② ●
# <Wait Use Animation = ID> 播放完启动动画后才会显示技能动画
# ----------------------------------------
# ● 状态动画<循环> ●
# <Loop Animation = ID> 写在状态备注中 当附加了此状态后会循环播放的动画
# ----------------------------------------
# ● 死亡动画 ●
# <Death Animation = ID> 濒死时播放的动画
#==============================================================================
module MOG_ANIMATION_PLUS
# 忽略等待时间的动画ID。
IGNORE_WAIT_TIME_ANIMATION_ID = [
1, 3, 21, 50,
999]
# 状态动画循环速度
STATES_LOOP_SPEED = 30
# 升级动画
LEVEL_UP_ANIMATION = 2
end
#==============================================================================
$imported = {} if $imported.nil?
$imported[:mog_animation_plus] = true
#==============================================================================
# ■ Game Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
attr_accessor :animation_loop
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_animation_plus_initialize initialize
def initialize
mog_animation_plus_initialize
@animation_loop = []
end
#--------------------------------------------------------------------------
# ● Add New State
#--------------------------------------------------------------------------
alias mog_animation_plus_add_new_state add_new_state
def add_new_state(state_id)
mog_animation_plus_add_new_state(state_id)
check_loop_animation
end
#--------------------------------------------------------------------------
# ● Erase State
#--------------------------------------------------------------------------
alias mog_animation_plus_erase_state erase_state
def erase_state(state_id)
mog_animation_plus_erase_state(state_id)
check_loop_animation
end
#--------------------------------------------------------------------------
# ● Check Loop Animation
#--------------------------------------------------------------------------
def check_loop_animation
@animation_loop.clear
self.states.each_with_index do |i, index|
if i.note =~ /<Loop Animation = (\d+)>/i
@animation_loop.push([$1.to_i,0, index + 1, true])
end
end
end
#--------------------------------------------------------------------------
# ● Item Apply
#--------------------------------------------------------------------------
alias mog_animation_plus_item_apply item_apply
def item_apply(user, item)
mog_animation_plus_item_apply(user, item)
execute_animation_plus_hit(item) if @result.success
end
#--------------------------------------------------------------------------
# ● Execute Animation Plus Hit
#--------------------------------------------------------------------------
def execute_animation_plus_hit(item)
return if item == nil
return if !SceneManager.scene_is?(Scene_Battle)
self.animation_id = $1.to_i if item.note =~ /<Hit Animation = (\d+)>/i
if self.dead?
if self.is_a?(Game_Enemy)
battler = $data_enemies[self.enemy_id]
else
battler = $data_actors[self.id]
end
self.animation_id = $1.to_i if
battler.note =~ /<Death Animation = (\d+)>/i
end
end
end
#==============================================================================
# ■ Sprite_Base
#==============================================================================
class Sprite_Base < Sprite
#--------------------------------------------------------------------------
# ● Battle Animation?
#--------------------------------------------------------------------------
def battle_animation?
if @animation != nil
if MOG_ANIMATION_PLUS::
IGNORE_WAIT_TIME_ANIMATION_ID.include?(@animation.id)
return false
end
return true
end
return false
end
end
#==============================================================================
# ■ Sprite Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# ● Update Position
#--------------------------------------------------------------------------
alias mog_animation_plus_update_position update_position
def update_position
mog_animation_plus_update_position
update_loop_animation if can_loop_animation?
end
#--------------------------------------------------------------------------
# ● Can Loop Animation?
#--------------------------------------------------------------------------
def can_loop_animation?
return false if BattleManager.in_turn?
return false if self.animation?
return false if @battler.animation_loop.empty? or @battler.dead?
if $imported[:mog_battle_hud_ex]
return false if
$game_message.visible and MOG_BATTLE_HUD_EX::MESSAGE_WINDOW_FADE_HUD
return false if !$game_temp.battle_hud_visible
end
return true
end
#--------------------------------------------------------------------------
# ● Update Loop Animation
#--------------------------------------------------------------------------
def update_loop_animation
for i in @battler.animation_loop
next if !i[3]
i[1] += 1
if i[1] >= MOG_ANIMATION_PLUS::STATES_LOOP_SPEED
i[1] = 0 ; @battler.animation_id = i[0] ; i[3] = false
if i[2] >= @battler.animation_loop.size
for i in @battler.animation_loop
i[1] = 0 ; i[3] = true
end
end
end
break
end
end
#--------------------------------------------------------------------------
# ● Update Z Correction
#--------------------------------------------------------------------------
def update_z_correction
return if !@animation
@ani_sprites.each do |sprite| sprite.z = self.z + 1 end
end
end
#==============================================================================
# ■ Spriteset_Battle
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# ● Animation?
#--------------------------------------------------------------------------
def animation?
battler_sprites.any? {|sprite| sprite.battle_animation? }
end
end
#==============================================================================
# ■ Scene Battle
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● Start
#--------------------------------------------------------------------------
alias mog_animation_plus_start start
def start
$game_party.members.each {|actor| actor.check_loop_animation }
mog_animation_plus_start
end
#--------------------------------------------------------------------------
# ● Use Item
#--------------------------------------------------------------------------
alias mog_animation_plus_use_item use_item
def use_item
execute_cast_animation
mog_animation_plus_use_item
end
#--------------------------------------------------------------------------
# ● Execute Cast Animation
#--------------------------------------------------------------------------
def execute_cast_animation
return if @subject.current_action.item == nil rescue return
item = @subject.current_action.item
if item.note =~ /<Use Animation = (\d+)>/i
execute_animation(@subject, $1.to_i,false)
elsif item.note =~ /<Wait Use Animation = (\d+)>/i
execute_animation(@subject, $1.to_i,true)
end
end
#--------------------------------------------------------------------------
# ● Execute Animation
#--------------------------------------------------------------------------
def execute_animation(subject , anime_id = 0, wait_animation = false)
return if anime_id <= 0 or subject == nil
subject.animation_id = anime_id rescue nil
if wait_animation
duration = ($data_animations[anime_id].frame_max * 4) + 1
for i in 0..duration
@spriteset.update ; Graphics.update
end
end
end
end
#==============================================================================
# ■ Game Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● Level UP
#--------------------------------------------------------------------------
alias mog_animation_plus_level_up level_up
def level_up
mog_animation_plus_level_up
self.animation_id = MOG_ANIMATION_PLUS::LEVEL_UP_ANIMATION if
can_lvup_animation?
end
#--------------------------------------------------------------------------
# ● Can Lvup Animation
#--------------------------------------------------------------------------
def can_lvup_animation?
return false if !use_sprite?
return false if !SceneManager.scene_is?(Scene_Battle)
if $imported[:mog_battle_hud_ex]
return false if $game_message.visible and
MOG_BATTLE_HUD_EX::MESSAGE_WINDOW_FADE_HUD
return false if !$game_temp.battle_hud_visible
end
return true
end
end