Save-Point
Help editing Animation Resizer - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Games Development (https://www.save-point.org/forum-4.html)
+--- Forum: Code Support (https://www.save-point.org/forum-20.html)
+--- Thread: Help editing Animation Resizer (/thread-4424.html)



Help editing Animation Resizer - MechanicalPen - 11-02-2012

I found this script that can resize animations at runtime. I want to use it to make Skill animations smaller when they are applied on Actor battlers (they are several times smaller than Enemy battlers) but I am not sure where to make the change.

Could someone more familiar with RPG Maker XP's battle/animation systems assist?

The script:
Code:
#===============================================================================
# Animation Resizer
# Author game_guy
# Version 1.0
#-------------------------------------------------------------------------------
# Intro:
# Want to reduce or increase the size of certain animations? Don't wanna go
# through all the tedious work to do it in the database? This script
# can resize any animation for you.
#
# Features:
# Increase animation size
# Decrease animation size
# Use only on specific animations
# Use custom size value
#
# Instructions:
# Note the animations also resize on events.
# Go down to config below.
# Default_Increase - This is the default amount that is used to resize an
#   animation that isn't configured.
# Configure Sizes - This is the config for setting up sizes for specific
#   animations only. If an animation isn't defined here then it uses
#   Default_Increase
#
# Don't want an animation resized on events? Simply use the following
# $game_system.anim_event = false
# Set it to true to have animations resized on events.
#
# Compatibility:
# Not tested with SDK.
# Should work where ever an animation is used.
#
# Credits:
# game_guy ~ For making it
# Jek ~ For requesting it
#===============================================================================
module GGHAN
  #==============================================
  # Config
  #==============================================
  # Default animation increase/decrease
  # Positive values = increase
  # Negative values = decrease
  Default_Increase = 0
  def self.zoom(id)
    case id
    #========================
    # Configure Sizes
    # Do:
    # when animation_id then return resize_amount_in_percent
    # Example:
    # when 67 then return 300
    # It increases the animation by 300 percent
    # Use negative values to decrease an animation.
    #
    # Note: When decreasing an animation size it can
    # only decrease it as much as possible before making
    # the animation dissappear.
    #========================
    when 67 then return 300
    when 1 then return -90
    end
    return 0
  end
  #==============================================
  # End Config
  #==============================================
end
class Game_System
  attr_accessor :anim_event
  attr_accessor :is_event
  alias gg_init_anim_resize_lat initialize
  def initialize
    @anim_event = true
    @is_event = false
    gg_init_anim_resize_lat
  end
end
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
        sprite.x += cell_data[i, 1]
        sprite.y += cell_data[i, 2]
        sprite.z = 2000
        sprite.ox = 96
        sprite.oy = 96
        if $scene.is_a?(Scene_Map) && $game_system.anim_event
          zoom = GGHAN.zoom(@_animation.id)
          if zoom < 0
            c = -zoom
            if cell_data[i, 3] <= c
              c = cell_data[i, 3] - 1
              cc = cell_data[i, 3] - c
              #p cc.to_s + " IF " + cell_data[i, 3].to_s
            else
              cc = cell_data[i, 3] - c
              #p cc.to_s + " ELSE " + cell_data[i, 3].to_s
            end
          else
            cc = cell_data[i, 3] + zoom
          end
          sprite.zoom_x = cc / 100.0
          sprite.zoom_y = cc / 100.0
        elsif $scene.is_a?(Scene_Map) && !$game_system.anim_event
          cc = cell_data[i, 3]
          sprite.zoom_x = cc / 100.0
          sprite.zoom_y = cc / 100.0
        elsif $scene.is_a?(Scene_Battle)
          zoom = GGHAN.zoom(@_animation.id)
          cc = cell_data[i, 3] + zoom
          sprite.zoom_x = cc / 100.0
          sprite.zoom_y = cc / 100.0
        end
        sprite.angle = cell_data[i, 4]
        sprite.mirror = (cell_data[i, 5] == 1)
        sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
        sprite.blend_type = cell_data[i, 7]
      end
    end
  end
end



RE: Help editing Animation Resizer - kyonides - 11-02-2012

Well, what I think that I understood about the inner working of this script is that it is supposed to work like this:

GGHAN.zoom(animation_id)

In order to include as many animations as you may need to increase or to decrease, you need to edit the case statement

case id
when 67 then return 300
when 1 then return -90
### another when ID then return (+ / -) percentage
end

But as you may have already noticed after a few attempts to get the script work the way you want, the script doesn't include such a feature and might need to be (partially or entirely) rewritten before it allows you to change the animations size while being focused on any event. So be patient and check every so often in case that any scripter may have posted some specific solution for your scripting issue.


RE: Help editing Animation Resizer - MechanicalPen - 11-06-2012

I understand how the script works, I am just not sure how to tell if an animation is being applied to an Actor and not an Enemy. Once I figure that out it is a simple change;
from:
elsif $scene.is_a?(Scene_Battle)
to :
elsif $scene.is_a?(Scene_Battle) && (sprite is on top of Actor)


RE: Help editing Animation Resizer - MechanicalPen - 11-22-2012

I figured it out! Using Battle Animation 'Flip' Control http://save-point.org/thread-2584.html as a base, one can simply edit the flip effect into a zoom effect.