08-26-2024, 10:16 PM
(This post was last modified: 09-02-2024, 05:19 PM by DerVVulfman.)
Quickie Battler Animation
Version: 1.0
Version: 1.0
Introduction
This is a very simple script that allows a game developer to use battlers that are customized to show minimalstic animations. The battlers will not display different actions based on attacks, but merely renders one series of animation frames for any defined combatant's sprite.
Script
Quickie Battler Animation
Code:
#==============================================================================
# Quickie Battler Animation
# -------------------------------------------------------------------------
# version 1.0
# by DerVVulfman
# 08-26-2024 (MM-DD-YYYY)
# RGSS / RPGMaker XP
#==============================================================================
#
# INTRODUCTION:
# =============
#
# This is a very simple script that allows a game developer to use battlers
# that are customized to show minimalstic animations. The battlers will not
# display different actions based on attacks, but merely renders one series
# of animation frames for any defined combatant's sprite.
#
#------------------------------------------------------------------------------
#
# INSTALLATION:
# =============
#
# Paste below Scene Debug and above main.
#
# There is only one configuration value in the Quickie_Battler module, and it
# controls how fast or slow the animation frames are displayed. The higher the
# setting, the faster the animations are performed. A setting of 1 is the low-
# est setting possible, any value below 1 is thus treated as 1. A setting of
# 7 is relatively fast. And setting the value above the game's framerate will
# set the animations to run as fast as the framerate itself. This value will
# never go beyond the game's framerate.
#
#
#------------------------------------------------------------------------------
#
# BATTLER GRAPHICS:
# =================
#
# The system has no issue with default graphics, but is designed to handle
# animation with custom graphics. To identify these graphics, their filenames
# must follow a specific format such as the pair shown below:
#
# $Franklin_3 $ArchVillain04_05
#
# The first symbol for the filename of any custom graphic's filename must be a
# dollar sign ('$'), and the very end of the filename must be the number of
# animation frames preceded by an underscore ('_'). If a battler filename has
# more than one underscore, the system will always consider the last one used.
#
# In the above examples, the first filename defines a battler as having three
# frames of animation while the second battler has five frames of animation.
#
# +-----------+-----------+-----------+-----------+
# | | __// | | |
# | __// | /.__.\ | __// | |
# | /.__.\ | \ \/ / | /.__.\ | __// |
# | \ \/ / | __/ \ | \ \/ / | /.__.\ |
# | __/ \ | \- ) | __/ \ | \ \/ / |
# | \- ) | \_____/ | \- ) | __/ \ |
# | \_____/ | | | | \_____/ | \- ) |
# | | | | | | | | | | \_____/ |
# | " " | " " | " " | " " |
# +-----------+-----------+-----------+-----------+
#
# And assuming the above bit of Ascii Art is a custom battler, it would be a
# graphic with four(4) frames of animation and could have a filename such as:
# "$chicken_dance_4"
#
# That's really all there is to it.
#
#
#==============================================================================
#
# COMPATABILITY:
# ==============
#
# Designed for RPGMaker XP.
# Not for use with other systems that animate battler graphics.
# Compatible with Brenda's Paperdoll Battlers.
# May need to go below some custom battlesystems to function.
#
#
#==============================================================================
#
# TERMS and CONDITIONS:
# =====================
#
# Free for use, even in commercial scripts. Due credit to all involved is
# the only requirement.
#
#
#==============================================================================
module Quickie_Battler
#--------------------------------------------------------------------------
A_SPEED, E_SPEED = {},{} # Do Not Touch
#--------------------------------------------------------------------------
# SYSTEM ANIMTION SPEED
# =====================
# This defines the basic speed of all animations. 1 is slowest. The game's
# framerate setting is the highest.
# -------------------------------------------------------------------------
#
SPEED = 8
# ACTOR AND ENEMY SPEEDS
# ======================
# Here, you define how fast the animation is for actor or enemy battlers,
# using their database ID as the identifying key.
# -------------------------------------------------------------------------
#
A_SPEED[2] = 9 # Actor ID 2 (Basil) is marginally faster than default
E_SPEED[1] = 5 # Enemy ID 1 (Ghost) is a bit slower than the default
end
#==============================================================================
# ** Sprite_Battler
#------------------------------------------------------------------------------
# This sprite is used to display the battler.It observes the Game_Character
# class and automatically changes sprite conditions.
#==============================================================================
class Sprite_Battler < RPG::Sprite
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias sprite_battler_quickie_animation_initialize initialize
alias sprite_battler_quickie_animation_update update
#--------------------------------------------------------------------------
# * Object Initialization
# viewport : viewport
# battler : battler (Game_Battler)
#--------------------------------------------------------------------------
def initialize(viewport, battler = nil)
#
# Perform the original method
sprite_battler_quickie_animation_initialize(viewport, battler)
# Include the new values at setup
quickie_battler_animation_setup
#
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
#
# Perform the original method
sprite_battler_quickie_animation_update
# Reset the battler sprite if contents changed
update_quickie_battler_reset if update_quickie_battler_changed?
# Animate if actually animated
update_quickie_battler_animation if @battler_anim
#
end
#--------------------------------------------------------------------------
# * Object Initialization : when setting up additional animation values
#--------------------------------------------------------------------------
def quickie_battler_animation_setup
#
@battler_anim = false
@battler_frame = 0
@battler_frames = 1
@battler_time = 0
#
end
#--------------------------------------------------------------------------
# * Object Initialization : when setting/ensuring animation speed
#--------------------------------------------------------------------------
def quickie_battler_speed
#
# Acquire default configured speed
speed = Quickie_Battler::SPEED
# Determine actor/enemy list
list = Quickie_Battler::A_SPEED
list = Quickie_Battler::E_SPEED if @battler.is_a?(Game_Enemy)
# Substitute speed with battler's unique speed if exists
speed = list[@battler.id] if list.has_key?(@battler.id)
# Keep within range and exit with result
speed = 1 if speed < 1
speed = Graphics.frame_rate if speed > Graphics.frame_rate
return speed
#
end
#--------------------------------------------------------------------------
# * Frame Update : when determining if battler sprite contents changed
#--------------------------------------------------------------------------
def update_quickie_battler_changed?
#
return false if @battler.nil?
effective = false
effective = true if @battler.battler_name != @battler_name
effective = true if @battler.battler_hue != @battler_hue
is_animate = update_quickie_battler_animated?
effective = true if @battler_anim != is_animate
@battler_anim = is_animate
return effective
#
end
#--------------------------------------------------------------------------
# * Frame Update : when determining if battler is animated
#--------------------------------------------------------------------------
def update_quickie_battler_animated?
#
return false unless @battler_name[0,1] == "$" # No dollar sign?
return false unless @battler_name.include?("_") # No underscore?
tmp_a = @battler_name.split('_') # Make it an array
tmp_i = (tmp_a[tmp_a.size-1]).to_i # Get frame count
return false unless tmp_i > 1 # Exit unless 2+
@battler_frames = tmp_i # Set frame count
return true # Exit with success
#
end
#--------------------------------------------------------------------------
# * Frame Update : when actively changing loaded battler contents
#--------------------------------------------------------------------------
def update_quickie_battler_reset
#
@battler_name = @battler.battler_name
@battler_hue = @battler.battler_hue
self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
@width = bitmap.width / @battler_frames
@height = bitmap.height
@battler_frame = 0
@battler_a_speed = quickie_battler_speed
self.ox = @width / 2
self.oy = @height
self.opacity = 0 if @battler.dead? or @battler.hidden
#
end
#--------------------------------------------------------------------------
# * Frame Update : when actively animating the battler
#--------------------------------------------------------------------------
def update_quickie_battler_animation
#
# Define and update frame used by battler
sx = @width * @battler_frame
self.src_rect.set(sx, 0, @width, @height)
# Process timer mechanics
update_quickie_battler_timer
#
end
#--------------------------------------------------------------------------
# * Frame Update : when advancing battler frames
#--------------------------------------------------------------------------
def update_quickie_battler_timer
#
# Determine current time (number of frames changed divided by speed)
time = Graphics.frame_count / (Graphics.frame_rate / @battler_a_speed)
# Advance frame if time had changed
if @battler_time < time
@battler_frame = (@battler_frame + 1) % @battler_frames
end
# Update last time used by battler
@battler_time = time
#
end
end
Instructions
Instructions on installation and the filename structure of battler graphics meant for animation are in the script.
Compatibility
Designed for RPGMaker XP.
Not for use with other systems that animate battler graphics.
Compatible with Brenda's Paperdoll Battlers.
May need to go below some custom battlesystems to function.
Terms and Conditions
Free for use, even in commercial scripts. Due credit to all involved is the only requirement.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
Above are clickable links