Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

RMXP Battle Animation flip/mirror system

This system could be useful for any sideview battlesystem, whether it be Trickster's ATB+CTB, Ccoa's Sideview system, or Animated Battlers.

When I refer to the Battle Animations, I refer to those animations such as the 'Hit', 'Claw', 'Fang', 'Remedy 1', 'Fire 3' or whatever. Not the sprite animations that have been worked out by scripters like Ccoa, Cybersam, etc...

The premise is this:
Most (if not all) battle animations are under the assumption that you are using the typical frontview system. So animations like the arrow ("bow") show attacks coming 'up' from the hero into the enemy battler.

It's a fair assumption that sideview systems will want battle animations that can be shown going left to right, or right to left... but no one wants to create TWO battle animations for enemies and actors.

>>>--------> <--------<<<

What I'm hoping to be made is a system that will 'flip' battle animations and adjust the 'x-position' of each frame accordingly. The 'flip' of the animation should be controlled by a true/false value in the script.
Code:
if @active_battler.is_a?(Game_Actor)
  @battle_flip = true
else
  @battle_flip = false
end
... or something to that degree. It would work well for animations such as flying arrows, fireballs, or whatever.

Additional methods to flip, such as vertical flipping (if the heroes are at the top of the screen), wouldn't be that bad an idea either. Personally, I wouldn't need it... that I know of... but I'm sure that it would be welcomed.
 
Yes indeed, I'm also trying to make this work for my FFVI SDK and it's less complicated then I thought!

We can add this to a sideview battle system and when an enemy is attacking, we just have to reverse reverse the animation with a single line of code! It will be nice with your animated battlers! ;)

That's amazing lol
 
That's an interesting and simple code, it uses a [R] or [r] on an animation's name to make it reverse on the map or battle, but if I understood the code well, this will always reverse the animation if the [R/r] is present on the animation's name, so not of much use anyways but interesting, maybe I should add this feature to my script.
eg(This follows my game's names):
Animation ID | Animation Name
0027.......... | Fire[R]
This animation is reverseable when an enemy is the user/attacker.
Animation ID | Animation Name
0052.......... | Ultima
This animation isn't reverseable in any case.
EDIT: I've made something a little effective, if the animation is a screen target, it won't invert.
But if you want a [R/r] way just tell me.
 
You can easly change it using
Code:
$data_animations[animation_id].reverse = true/false
You'll have to edit it a bit more though to put restrictions on which skill is reversable or not.
 
Yeah, maybe.
I was thinking, and realized that a default BS wouldn't need a inversion effect anyways, I'm going to remove it from the script since its useless.
Also some updates such as coordinates inversion.
 
For a default battlesystem, this would be fairly meaningless... but not only would a sideview system benefit, but an Zelda-styled ABS would if a vertical flipping feature or 180degree rotate was available.

Here's MY take on the system:
Code:
#==============================================================================
# Animation Left and Right Reversal
# by Dust Wind at the Wind Messer Website
# http://windmesser.tm.land.to/top.html
# Edit by DerVVulfman
#
#------------------------------------------------------------------------------
#
# INTRODUCTION:
# This script is used to reverse battle animations, whether on the field or in
# a custom battlesystem  where the $b_a_direction value  can be changed before
# the animation takes effect.  Only the most basic edit of his system was done
# within this script.
#
#------------------------------------------------------------------------------
#
# USAGE:
# Simply call the global value '$b_a_direction' to change the direction of the 
# battle animation... currently only 0 for the default, and 1 for horizontally
# flipped animations.
#
#------------------------------------------------------------------------------
#
# LIMITATIONS:
# Only works with simpler animations, full screen shots do not sync up so well.
#
#------------------------------------------------------------------------------
#
# Thanks goes to hugopkmn, Dargor and PirateFaafy for keeping the discussion 
# alive and finding Dust Wind's original script.
#
#==============================================================================

module RPG
  class Sprite < ::Sprite
    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
        
        #----------------------------------------------------------------------
        # INSERT GOES HERE
        #----------------------------------------------------------------------
        case $b_a_direction
        when 1  # Flipped horizontally
          sprite.x -= cell_data[i, 1]
        else    # If no case, default format
          sprite.x += cell_data[i, 1]
        end
        #----------------------------------------------------------------------
        # END OF INSERT
        #----------------------------------------------------------------------
        
        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
        
        #----------------------------------------------------------------------
        # EDITED HERE
        #----------------------------------------------------------------------
        case $b_a_direction
        when 1  # Flipped horizontally
          sprite.angle = 360 - cell_data[i, 4]
          sprite.mirror = (cell_data[i, 5] == 0)
        else    # If no case, default format
          sprite.angle = cell_data[i, 4]
          sprite.mirror = (cell_data[i, 5] == 1)
        end
        #----------------------------------------------------------------------
        # END OF EDIT
        #----------------------------------------------------------------------
        
        sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
        sprite.blend_type = cell_data[i, 7]
      end
    end    
  end
end
You were actually DAMN close, hugopkmn!

And to use it in the field map, all I did was change the global $b_a_direction from 0 to 1... BOOM... flips the next animation horizontally!

Now with this going, it's only a matter of time to get it to flip vertically and rotate 180!

* There is a bug with it flipping animations that extend away from the target, involving the distance of individual frames from the animation's center. Good for single target animations... bad for full-screen animations. Same bug inherit with the original def script by Dust Wind.
 
Well, I've edited my script for sideview battle system only, I'm going to post it at the "Submitted RGSS Scripts" forum, so I'll remove that one from here.
@DerVVulfman, u're repeating a sum and this can be bad ,look:
Code:
        #----------------------------------------------------------------------
        # INSERT GOES HERE
        #----------------------------------------------------------------------
        case $b_a_direction
        when 1  # Flipped horizontally
          sprite.x -= cell_data[i, 1]
        else    # If no case, default format
          sprite.x += cell_data[i, 1]
        end
        #----------------------------------------------------------------------
        # END OF INSERT
        #----------------------------------------------------------------------
        
        [b]sprite.x += cell_data[i, 1][/b]
This will make the sprite.x go back to it's normal position or double its coordinate, remove it for the script's proper function.
Also, if you want to reverse the y coord, do the same you've done with the x coord. Now for the angle, I've made it like this on the previous version:
Code:
@angle_change = cell_data[i, 4] + 180
sprite.angle = @angle_change > 360 ? @angle_change - 360 : 
@angle_change
This will make the sprite rotate 180°.
 
The section you say that I and Dust Wind is repeating is not an error...

The -=cell_data[i, 1] system is... was supposed to control the reversed x position of the individual frames, positioning them on opposite sides of where they are. If you compare the Ice 2 in the traditional and reversed formats, you'll see what I mean. The ice shards should move diagonally parallel to their grain.

Only problem is that it the 'reversed' frames won't stray from the sprite's central x position. I wouldn't be surprised if the same problem occurs when an attempt to vertically flip the frame positions too. This needs to be addressed.
 
I've just tried it in a clean project and the animation's x is currently 0, look it by urself:
http://img147.imageshack.us/img147/5307/screenshot1ss2.th.png[/IMG]
This is wut happens if I set $b_a_direction = 1.
If I set it to 0, the x coord of the sprites will be doubled, so the x speed is doubled too, a screenshot of the $b_a_direction = 0 won't be effective, but you can test it by urself, try using light 2 animation, the only thing that it may do is to give a 3d's z coord aspect.
 
Yep... I've seen the results. Since the frames won't reverse position (only the facing direction right now), all the frames stay aligned on top of the target's 'X' position. A 'Fire 3' effect that is supposed to encompass the entire screen has every pillar of fire and explosions crashing down into the same single spot.

Signing off for now.

G'night.
 
That's what I meant, if u set the variable to 1, the sprite.x will be subtracted by the database's sprite.x, actually this would be enough to reverse the x coordinate, but at the next line, sprite.x is summed again with the database's sprite.x, causing it to be 0 again, if you set it to 0, it will sum the sprite.x with database's sprite.x twice and will cause the doubled coordinates.
I'm going to logout too, cya tomorrow(I mean... later xD).
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top