Help - Search - Members - Calendar
Full Version: Enemy battler animation
RPG RPG Revolution Forums > Scripting > Script Development and Support > Script Requests
TheCretanHound
Hi I want to add attack animations to the enemy battlers in the standard or yanfly style battle system. Can someone send me to the right place or forward me the script? Thanks!
Night_Runner
For anyone looking for the back story see the topic here

CODE
#==============================================================================
# ** VXAce: Animated Enemy Battlers
#------------------------------------------------------------------------------
# History:
#  Date Created: 13/Apr/2012
#  Created for: TheCretanHound
#   @> http://www.rpgrevolution.com/forums/index.php?showtopic=56171
#
# Description:
#  This script is designed to animate the enemy battlers in the default
#   RMVX Ace battle system.
#
# How to Install:
#  Copy this entire script. In your game editor select Tools >> Script Editor.
#   Along the left, scroll down to the bottom, right click on 'Main', and
#   select 'Insert'. Paste the code on the right.
#
# How to Use:
#  Please see below for the default number of frames per step, and the
#   default number of steps per graphic.
#  To set the number of frames per step and the number of steps per graphic
#   for an individual battler, change their name to:
#      Slime[100, 2].png
#   Where Slime is their normal name, 100 is the number of frames to wait
#   per animation, and 2 is the number of frames per graphic.
#==============================================================================



#==============================================================================
# ** Customisation
#==============================================================================

module NR_AnimEnemies
  DEFAULT_FRAMES = 20
  DEFAULT_STEPS = 4
end



#==============================================================================
# ** Sprite_Battler
#------------------------------------------------------------------------------
#  Edited to have animated battlers.
#==============================================================================

class Sprite_Battler
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias nr_animEnemy_update_bitmap  update_bitmap  unless $@
  #--------------------------------------------------------------------------
  # * Update Transfer Origin Bitmap
  #--------------------------------------------------------------------------
  def update_bitmap(*args)
    # Restore the bitmap to the whole bitmap (if it exists)
    self.bitmap = @whole_bitmap unless @last_bitmap.nil?
    # Run the original update_bitmap
    nr_animEnemy_update_bitmap(*args)
    # Return if appropriate
    return if self.bitmap.nil?
    return if @battler.is_a? Game_Actor
    # If the bitmap name has changed
    if @old_bitmap_name != @battler.battler_name or
        @old_battler_hue != @battler.battler_hue
      # Backup their name & hue
      @old_bitmap_name = @battler.battler_name
      @old_battler_hue = @battler.battler_hue
      # Get the note for this enemy
      notebox = $data_enemies[@battler.enemy_id].note.to_s
      # Read the number of frames
      frames = @battler.battler_name.match( /\[(.*)\]$/ )
      if frames.nil?
        @animation_frames = NR_AnimEnemies::DEFAULT_FRAMES
        @animation_steps = NR_AnimEnemies::DEFAULT_STEPS
      else
        @animation_frames, @animation_steps = eval(frames[0])
      end
      # Reset the frames_since_anim
      @frames_since_anim = -1
      @current_anim_index = -1
      # Backup the un-segmented battler
      @whole_bitmap = self.bitmap.clone
    # If the battler hasn't changed
    else
      # Restore the bitmap to the segmented battler
      self.bitmap = @segmented_bitmap
    end
    # If it's time for an update
    if @frames_since_anim == -1 or @frames_since_anim > @animation_frames
      # Update the current anim index
      @current_anim_index = (@current_anim_index + 1) % @animation_steps
      # Reset the update counter
      @frames_since_anim = 0
      # Get the dimensions of the whole bitmap
      r = Rect.new(0, 0, @whole_bitmap.width, @whole_bitmap.height)
      # Create a rect to get the segmented battler
      x = @current_anim_index * r.width / @animation_steps
      source_x = Rect.new(x, r.y, r.width, r.height)
      # Create the bitmap with the segmented battler and set it as active
      a_bitmap = Bitmap.new(r.width / @animation_steps, r.height)
      a_bitmap.blt(0, 0, @whole_bitmap, source_x)
      self.bitmap = a_bitmap
      @segmented_bitmap = self.bitmap.clone
    end
    # Increment the frames since an animation
    @frames_since_anim += 1
  end
end



#==============================================================================
# ** End of Script.
#==============================================================================


And since you like my scripts so much, have a fresh one ^_^
TheCretanHound

Thanks Night Runner! You = Kick ass!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.