Battle Animation Reverse
Introduction
Remember the RM2K/2K3 battle animation reverse feature? Now it's back!
This scripts add this feature again to RMXP, it's designed for Sideview Battle Systems though, the demo does have a SVBS(It ISN'T mine, if you know its owner credit him!) included.
Screenshot
Screenies inside!
Spoiler
Demo
Here
Optional(4shared)
Script
The Script
Spoiler
#================================================================
# + Battle Animation Reverse System(This is a Non-RTAB Script)
# = This script is for side-view battle systems only.
# = Requested by DerVVulfman.
# = RPG::Sprite adaptation by hugopkmn.
# = Thanks to Dargor for pointing a site with the [R/r] feature.
#================================================================
# + How to setup an animation?
# = If you want an animation to reverse, the animation's name must
# have [R] or [r] in its name.
# = Remember that the screen targeted or direct target animations
# (eg. an arrow) must be directed to the enemy's screen side.
#================================================================
#================================================================
# + Scene_Battle add-on
# = The thing that was missing  ¬Ãƒâ€šÃ‚ ¬
#================================================================
class Scene_Battle
attr_reader :active_battler
end
#================================================================
# + RPG::Animation
#================================================================
module RPG
class Animation
def initialize
@id = 0
@name = ""
@animation_name = ""
@animation_hue = 0
@position = 1
@frame_max = 1
@frames = [RPG::Animation::Frame.new]
@timings = []
@reversable = false
end
attr_accessor :id
attr_accessor :name
attr_accessor :animation_name
attr_accessor :animation_hue
attr_accessor :position
attr_accessor :frame_max
attr_accessor :frames
attr_accessor :timings
attr_accessor :reversable
end
end
#================================================================
# + RPG::Sprite
#================================================================
module RPG
class Sprite < ::Sprite
def animation(animation, hit)
dispose_animation
@_animation = animation
return if @_animation == nil
if(/\[[Rr]\]\z/ =~ @_animation.name)
@_animation.reversable = true
else
@_animation.reversable = false
end
@_animation_hit = hit
@_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 loop_animation(animation)
return if animation == @_loop_animation
dispose_loop_animation
@_loop_animation = animation
return if @_loop_animation == nil
if(/\[[Rr]\]\z/ =~ @_loop_animation.name)
@_loop_animation.reversable = true
else
@_loop_animation.reversable = false
end
@_loop_animation_index = 0
animation_name = @_loop_animation.animation_name
animation_hue = @_loop_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
@_loop_animation_sprites = []
for i in 0..15
sprite = ::Sprite.new(self.viewport)
sprite.bitmap = bitmap
sprite.visible = false
@_loop_animation_sprites.push(sprite)
end
update_loop_animation
end
def dispose_damage
if @_damage_sprite != nil
@_damage_sprite.bitmap.dispose
@_damage_sprite.dispose
@_damage_sprite = nil
@_damage_duration = 0
end
end
def animation_set_sprites(sprites, cell_data, position)
for i in 0..15
sprite = sprites[i]
pattern = cell_data[i, 0]
if sprite == nil or pattern == nil or pattern == -1
sprite.visible = false if sprite != nil
next
end
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
if position == 3
if self.viewport != nil
sprite.x = self.viewport.rect.width / 2
sprite.y = self.viewport.rect.height - 160
else
sprite.x = 320
sprite.y = 240
end
else
sprite.x = self.x - self.ox + self.src_rect.width / 2
sprite.y = self.y - self.oy + self.src_rect.height / 2
sprite.y -= self.src_rect.height / 4 if position == 0
sprite.y += self.src_rect.height / 4 if position == 2
end
if $game_temp.in_battle
@abattler = $scene.active_battler
if @abattler != nil
if @abattler.current_action.kind == 0 and @abattler.current_action.basic == 0
@animation_id = @battler.animation2_id
else
@animation_id = $data_skills[@abattler.current_action.skill_id].animation2_id if
$data_skills[@abattler.current_action.skill_id] != nil
end
end
sprite.x += cell_data[i, 1]
sprite.y += cell_data[i, 2]
sprite.z = 2000
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
if @abattler != nil and @abattler.is_a?(Game_Enemy) and
$data_animations[@animation_id].reversable
sprite.x -= cell_data[i, 1] * 2
@angle_c = 0
@angle_c -= cell_data[i, 4]
sprite.angle = @angle_c < 0 ? @angle_c + 360 : @angle_c
sprite.mirror = (cell_data[i, 5] == 0)
else
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
end
else
sprite.x += cell_data[i, 1]
sprite.y += cell_data[i, 2]
sprite.z = 2000
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
end
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
sprite.blend_type = cell_data[i, 7]
end
end
end
end
# + Battle Animation Reverse System(This is a Non-RTAB Script)
# = This script is for side-view battle systems only.
# = Requested by DerVVulfman.
# = RPG::Sprite adaptation by hugopkmn.
# = Thanks to Dargor for pointing a site with the [R/r] feature.
#================================================================
# + How to setup an animation?
# = If you want an animation to reverse, the animation's name must
# have [R] or [r] in its name.
# = Remember that the screen targeted or direct target animations
# (eg. an arrow) must be directed to the enemy's screen side.
#================================================================
#================================================================
# + Scene_Battle add-on
# = The thing that was missing  ¬Ãƒâ€šÃ‚ ¬
#================================================================
class Scene_Battle
attr_reader :active_battler
end
#================================================================
# + RPG::Animation
#================================================================
module RPG
class Animation
def initialize
@id = 0
@name = ""
@animation_name = ""
@animation_hue = 0
@position = 1
@frame_max = 1
@frames = [RPG::Animation::Frame.new]
@timings = []
@reversable = false
end
attr_accessor :id
attr_accessor :name
attr_accessor :animation_name
attr_accessor :animation_hue
attr_accessor :position
attr_accessor :frame_max
attr_accessor :frames
attr_accessor :timings
attr_accessor :reversable
end
end
#================================================================
# + RPG::Sprite
#================================================================
module RPG
class Sprite < ::Sprite
def animation(animation, hit)
dispose_animation
@_animation = animation
return if @_animation == nil
if(/\[[Rr]\]\z/ =~ @_animation.name)
@_animation.reversable = true
else
@_animation.reversable = false
end
@_animation_hit = hit
@_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 loop_animation(animation)
return if animation == @_loop_animation
dispose_loop_animation
@_loop_animation = animation
return if @_loop_animation == nil
if(/\[[Rr]\]\z/ =~ @_loop_animation.name)
@_loop_animation.reversable = true
else
@_loop_animation.reversable = false
end
@_loop_animation_index = 0
animation_name = @_loop_animation.animation_name
animation_hue = @_loop_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
@_loop_animation_sprites = []
for i in 0..15
sprite = ::Sprite.new(self.viewport)
sprite.bitmap = bitmap
sprite.visible = false
@_loop_animation_sprites.push(sprite)
end
update_loop_animation
end
def dispose_damage
if @_damage_sprite != nil
@_damage_sprite.bitmap.dispose
@_damage_sprite.dispose
@_damage_sprite = nil
@_damage_duration = 0
end
end
def animation_set_sprites(sprites, cell_data, position)
for i in 0..15
sprite = sprites[i]
pattern = cell_data[i, 0]
if sprite == nil or pattern == nil or pattern == -1
sprite.visible = false if sprite != nil
next
end
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
if position == 3
if self.viewport != nil
sprite.x = self.viewport.rect.width / 2
sprite.y = self.viewport.rect.height - 160
else
sprite.x = 320
sprite.y = 240
end
else
sprite.x = self.x - self.ox + self.src_rect.width / 2
sprite.y = self.y - self.oy + self.src_rect.height / 2
sprite.y -= self.src_rect.height / 4 if position == 0
sprite.y += self.src_rect.height / 4 if position == 2
end
if $game_temp.in_battle
@abattler = $scene.active_battler
if @abattler != nil
if @abattler.current_action.kind == 0 and @abattler.current_action.basic == 0
@animation_id = @battler.animation2_id
else
@animation_id = $data_skills[@abattler.current_action.skill_id].animation2_id if
$data_skills[@abattler.current_action.skill_id] != nil
end
end
sprite.x += cell_data[i, 1]
sprite.y += cell_data[i, 2]
sprite.z = 2000
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
if @abattler != nil and @abattler.is_a?(Game_Enemy) and
$data_animations[@animation_id].reversable
sprite.x -= cell_data[i, 1] * 2
@angle_c = 0
@angle_c -= cell_data[i, 4]
sprite.angle = @angle_c < 0 ? @angle_c + 360 : @angle_c
sprite.mirror = (cell_data[i, 5] == 0)
else
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
end
else
sprite.x += cell_data[i, 1]
sprite.y += cell_data[i, 2]
sprite.z = 2000
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
end
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
sprite.blend_type = cell_data[i, 7]
end
end
end
end
Expand to see the code.
Instructions
Put this between main and your custom scripts.
To setup an animation to reverse, just add [R/r] to the animation's name, for further information, read the script's first few lines.
Compatibility
This script isn't SDK dependant but SDK compatible, this script isn't compatible with RTAB and I won't take RTAB conversion requests, so don't request.
If you are using any other animation related script, this one may cause an error.
Credits and Thanks
Credits goes for me if you are using this script and thanks goes to DerVVulfman(for requesting it), Dargor(for pointing Dust Wind's website), SephirothSpawn(for pointing the RPG::Sprite as the responsible class) and Dust Wind(for a small feature).