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.

"Animation Divide" Script VX

Hello. I am looking for an ANIMATION_DIVIDE script snippet as seen in Mr.Mo's Squad Based Systems. I am currently using RPG Maker VX and Tankentai SBS 1.7. Hopefully this isn't too complicated, especially with the Tankentai SBS... Thank you very much for you effort in advance.
 
Basically the Animation Divide snippet allows you to enlarge or shrink your animations without using the Animation editor. Mr.Mo's script uses variable to enlarge or shrink animations based on a variable using

Code:
ANIMATION_DIVIDE=2

...

#--------------------------------------------------------------------------
# * Animation Divide
#--------------------------------------------------------------------------
  def ANIMATION_DIVIDE
    return ANIMATION_DIVIDE
  end

...
  
def read_data(file)
    mrmo_abs_scene_load_read_data(file)
    $ABS = Marshal.load(file)  
    # Change Animation Size
    for an in $data_animations
      next if an == nil
      frames = an.frames
      for i in 0...frames.size
        for j in 0...frames[i].cell_max
          frames[i].cell_data[j, 1] /= $ABS.ANIMATION_DIVIDE
          frames[i].cell_data[j, 2] /= $ABS.ANIMATION_DIVIDE
          frames[i].cell_data[j, 3] /= $ABS.ANIMATION_DIVIDE
        end

So the animation is reduced 50%... Gubid also uses this function in his Tactical Battle system for VX. I haven't been able to locate the coding in Gubid's system.
 

poccil

Sponsor

There's actually a better way to do that.  Use the script below for RPG Maker VX (put it after all other scripts in the Materials section of the script editor).
Code:
class Sprite_Base
    if !defined?(animationDivide_set_sprites)
      alias animationDivide_set_sprites animation_set_sprites
    end
    def animation_set_sprites(frame)
      animationDivide_set_sprites(frame)
      for i in 0..15
        sprite = @animation_sprites[i]
        next if !frame.cell_data[i, 0] || frame.cell_data[i, 0]==-1
        if sprite && sprite.is_a?(Sprite)
          #######
          # Replace 2.0 below with the desired scale.
          # Here using 2.0 reduces the animation size by half.
          scale = 2.0
          if @animation_mirror
             sprite.x += frame.cell_data[i, 1]
             sprite.x -= (frame.cell_data[i, 1] / scale)
          else
             sprite.x -= frame.cell_data[i, 1]
             sprite.x += (frame.cell_data[i, 1] / scale)
          end
          sprite.y -= frame.cell_data[i, 2]
          sprite.y += (frame.cell_data[i, 2] / scale)
          sprite.zoom_x /= scale
          sprite.zoom_y /= scale
          #######
        end
      end
    end
end
By the way it may appear that multiplying rather than dividing can be more intuitive.  In that case, replace each "/" in the code above with "*".
 
Thanks alot poccil! I'm going to test it now and ill let you know ;)

EDIT: Its works great, but I am still have an issue with some of the cell's positions being displaced... I think there is some kind of X,Y shift happening. Could it be that the sprites are being effected rather than the frame? I'm not sure this can be fixed. Do you have any other solutions? Thank you very much again, you have been a great help! :)
 

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