• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
Animated Sprites for vanilla Essentials

Resource Animated Sprites for vanilla Essentials 2.0

fncjinta

Novice
Member
Joined
Sep 30, 2023
Posts
24
1705571206516.png
"@bitmap=BitmapCache.load_bitmap(file)" It doesn't appear anywhere.
1705571473577.png
and essentials does not recognize the script
 

Willøw

Mew and Slither Wing Fan
Member
Joined
Nov 1, 2023
Posts
98
View attachment 24120"@bitmap=BitmapCache.load_bitmap(file)" It doesn't appear anywhere.
View attachment 24121and essentials does not recognize the script
Well, you can't expect Essentials to work properly, you're using outdated plugins, they use functions that no longer exist or have changed their name.

Here the same thing happens, it is necessary to update the script to be compatible with the current version of Essentials, So it's obvious that it won't recognize the Script
 

AenaonDogsky

Arbiter of Doggos
Member
Joined
Dec 12, 2017
Posts
510
It's possible to do this with some modifications, unfortunately I don't have the time to put those up rn, but I'll try to next week.
 

AenaonDogsky

Arbiter of Doggos
Member
Joined
Dec 12, 2017
Posts
510
Ooops. Sorry, I had a head injury and I'm my brain is not as it used to be, I'm much slower.
Can you please try using the scripts I will leave here? If they work I'll make a separate thread linking to this one so people can find it easier.

1. Replace your Animated Pokemon script that you got from Tenshi with this one:

Ruby:
Expand Collapse Copy
#===============================================================================
#
#  New animation methods for Pokemon sprites
#    by Luka S.J.. Small edit for v21 by Dusky
#
#  supports both animated, and static sprites
#  does not support the usage of GIFs
#  any one frame of sprite needs to be of equal width and height
#  all sprites need to be in 1*1 px resolution
#  use my GIF to PNG converter to properly format your sprites
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Dusky's edit note: There's also Dragonite's Converter, I'll include it
#  In the thread
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 
#  allows the use of custom looping points
#
#===============================================================================
#
#  Original script by Luka S.J.
#  Updated to Pokémon Essentials 18 and 18.1 by Tenshi of War
#  (Actually I only added the PluginManager register and resized the sprites)
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Dusky's edit note:
#  Replaced the animated method with the v21 one
#  Adjusted speed for a 60fps game, added more speed options
#  Modified install instructions
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#  How to install:
# 
#  1. Insert this script in a new page above main and below its dependencies
#  2. Go to "Species_Files" and search for
#     "AnimatedPokemonBitmap.new(filename) : nil"
#  3. Replace all instances of the former with
#     "AnimatedBitmap.new(filename) : nil"
#     On the following script lines: 73, 78, 83, 173, 178
#  4. Be sure to use EBS Battlers sprites.
#     If not, your sprites should be 96p x 96p.
#
#  Original thread: https://www.pokecommunity.com/showthread.php?t=342564
#
#===============================================================================

if defined?(PluginManager)
  PluginManager.register({
    :name => "New Animation Methods",
    :version => "2.0",
    :link => "https://luka-sj.com/res/admt",
    :credits => ["Luka S.J."]
  })
end

class AnimatedPokemonBitmap
  attr_reader :width
  attr_reader :height
  attr_reader :totalFrames
  attr_reader :currentIndex
  attr_accessor :speed
 
  def initialize(file)
    raise "filename is nil" if file==nil
    @width = 0
    @height = 0
    @frame = 0
    @direction = +1
    @totalFrames = 0
    @currentIndex = 0
    @speed = 2
      # 0 - not moving at all
      # 1 - normal speed
      # 2 - medium speed
      # 3 - slow speed
    @bitmap=RPG::Cache.load_bitmap("", file)
      # initializes full Pokemon bitmap
    @width=@bitmap.height*2
    @height=@bitmap.height*2
    
    @totalFrames=@bitmap.width/@bitmap.height
      # calculates total number of frames
    @loop_points=[0,@totalFrames]
      # first value is start, second is end
    
    @actualBitmap=Bitmap.new(@width,@height)
    @actualBitmap.clear
    @actualBitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmap,Rect.new(@currentIndex*(@width/2),0,@width/2,@height/2))
  end
    
  def length; @totalFrames; end
  def disposed?; @actualBitmap.disposed?; end
  def dispose; @actualBitmap.dispose; end
  def copy; @actualBitmap.clone; end
  def bitmap; @actualBitmap; end
 
  def reverse
    if @direction>0
      @direction=-1
    elsif @direction<0
      @direction=+1
    end
  end
 
  def setLoop(start, finish)
    @loop_points=[start,finish]
  end
 
  def toFrame(frame)
    if frame.is_a?(String)
      if frame=="last"
        frame=@totalFrames-1
      else
        frame=0
      end
    end
    frame=@totalFrames if frame>@totalFrames
    frame=0 if frame<0
    @currentIndex=frame
    @actualBitmap.clear
    @actualBitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmap,Rect.new(@currentIndex*(@width/2),0,@width/2,@height/2))
  end
 
  def update
    return false if @speed<1
    case @speed
    # frame skip
    when 1
      frames=1
    when 2
      frames=2
    when 3
      frames=3
    end
    @frame+=1
    
    if @frame>=frames
      # processes animation speed
      @currentIndex+=@direction
      @currentIndex=@loop_points[0] if @currentIndex>=@loop_points[1]
      @currentIndex=@loop_points[1]-1 if @currentIndex<@loop_points[0]
      @frame=0
    end
    @actualBitmap.clear
    @actualBitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmap,Rect.new(@currentIndex*(@width/2),0,@width/2,@height/2))
      # updates the actual bitmap
  end
    
  # returns bitmap to original state
  def deanimate
    @frame=0
    @currentIndex=0
    @actualBitmap.clear
    @actualBitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmap,Rect.new(@currentIndex*(@width/2),0,@width/2,@height/2))
  end
end

#======================================================
class AnimatedPortraitBitmap
  attr_reader :width
  attr_reader :height
  attr_reader :totalFrames
  attr_reader :currentIndex
  attr_accessor :speed
 
  def initialize(file)
    raise "filename is nil" if file==nil
    @width = 0
    @height = 0
    @frame = 0
    @direction = +1
    @totalFrames = 0
    @currentIndex = 0
    @speed = 6
      # 0 - not moving at all
      # 1 - normal speed
      # 2 - medium speed
      # 3 - slow speed
    @bitmap=RPG::Cache.load_bitmap("", file)
      # initializes full Pokemon bitmap
    @width=@bitmap.height*2
    @height=@bitmap.height*2
    
    @totalFrames=@bitmap.width/@bitmap.height
      # calculates total number of frames
    @loop_points=[0,@totalFrames]
      # first value is start, second is end
    
    @actualBitmap=Bitmap.new(@width,@height)
    @actualBitmap.clear
    @actualBitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmap,Rect.new(@currentIndex*(@width/2),0,@width/2,@height/2))
  end
    
  def length; @totalFrames; end
  def disposed?; @actualBitmap.disposed?; end
  def dispose; @actualBitmap.dispose; end
  def copy; @actualBitmap.clone; end
  def bitmap; @actualBitmap; end
 
  def reverse
    if @direction>0
      @direction=-1
    elsif @direction<0
      @direction=+1
    end
  end
 
  def setLoop(start, finish)
    @loop_points=[start,finish]
  end
 
  def toFrame(frame)
    if frame.is_a?(String)
      if frame=="last"
        frame=@totalFrames-1
      else
        frame=0
      end
    end
    frame=@totalFrames if frame>@totalFrames
    frame=0 if frame<0
    @currentIndex=frame
    @actualBitmap.clear
    @actualBitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmap,Rect.new(@currentIndex*(@width/2),0,@width/2,@height/2))
  end
 
  def update
    return false if @speed<1
    case @speed
    # frame skip
    when 1
      frames=1
    when 2
      frames=2
    when 3
      frames=3
    when 4
      frames=4
    when 5
      frames=5
    when 6
      frames=6
    when 7
      frames=7
    when 8
      frames=8
    when 9
      frames=9
  end
    @frame+=1
    
    if @frame>=frames
      # processes animation speed
      @currentIndex+=@direction
      @currentIndex=@loop_points[0] if @currentIndex>=@loop_points[1]
      @currentIndex=@loop_points[1]-1 if @currentIndex<@loop_points[0]
      @frame=0
    end
    @actualBitmap.clear
    @actualBitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmap,Rect.new(@currentIndex*(@width/2),0,@width/2,@height/2))
      # updates the actual bitmap
  end
    
  # returns bitmap to original state
  def deanimate
    @frame=0
    @currentIndex=0
    @actualBitmap.clear
    @actualBitmap.stretch_blt(Rect.new(0,0,@width,@height),@bitmap,Rect.new(@currentIndex*(@width/2),0,@width/2,@height/2))
  end
end

2. Replace your vanilla Species_Files script with this one


Ruby:
Expand Collapse Copy
module GameData
  class Species
    def self.check_graphic_file(path, species, form = 0, gender = 0, shiny = false, shadow = false, subfolder = "")
      try_subfolder = sprintf("%s/", subfolder)
      try_species = species
      try_form    = (form > 0) ? sprintf("_%d", form) : ""
      try_gender  = (gender == 1) ? "_female" : ""
      try_shadow  = (shadow) ? "_shadow" : ""
      factors = []
      factors.push([4, sprintf("%s shiny/", subfolder), try_subfolder]) if shiny
      factors.push([3, try_shadow, ""]) if shadow
      factors.push([2, try_gender, ""]) if gender == 1
      factors.push([1, try_form, ""]) if form > 0
      factors.push([0, try_species, "000"])
      # Go through each combination of parameters in turn to find an existing sprite
      (2**factors.length).times do |i|
        # Set try_ parameters for this combination
        factors.each_with_index do |factor, index|
          value = ((i / (2**index)).even?) ? factor[1] : factor[2]
          case factor[0]
          when 0 then try_species   = value
          when 1 then try_form      = value
          when 2 then try_gender    = value
          when 3 then try_shadow    = value
          when 4 then try_subfolder = value   # Shininess
          end
        end
        # Look for a graphic matching this combination's parameters
        try_species_text = try_species
        ret = pbResolveBitmap(sprintf("%s%s%s%s%s%s", path, try_subfolder,
                                      try_species_text, try_form, try_gender, try_shadow))
        return ret if ret
      end
      return nil
    end

    def self.check_egg_graphic_file(path, species, form, suffix = "")
      species_data = self.get_species_form(species, form)
      return nil if species_data.nil?
      if form > 0
        ret = pbResolveBitmap(sprintf("%s%s_%d%s", path, species_data.species, form, suffix))
        return ret if ret
      end
      return pbResolveBitmap(sprintf("%s%s%s", path, species_data.species, suffix))
    end

    def self.front_sprite_filename(species, form = 0, gender = 0, shiny = false, shadow = false)
      return self.check_graphic_file("Graphics/Pokemon/", species, form, gender, shiny, shadow, "Front")
    end

    def self.back_sprite_filename(species, form = 0, gender = 0, shiny = false, shadow = false)
      return self.check_graphic_file("Graphics/Pokemon/", species, form, gender, shiny, shadow, "Back")
    end

    def self.egg_sprite_filename(species, form)
      ret = self.check_egg_graphic_file("Graphics/Pokemon/Eggs/", species, form)
      return (ret) ? ret : pbResolveBitmap("Graphics/Pokemon/Eggs/000")
    end

    def self.egg_cracks_sprite_filename(species, form)
      ret = self.check_egg_graphic_file("Graphics/Pokemon/Eggs/", species, form, "_cracks")
      return (ret) ? ret : pbResolveBitmap("Graphics/Pokemon/Eggs/000_cracks")
    end

    def self.sprite_filename(species, form = 0, gender = 0, shiny = false, shadow = false, back = false, egg = false)
      return self.egg_sprite_filename(species, form) if egg
      return self.back_sprite_filename(species, form, gender, shiny, shadow) if back
      return self.front_sprite_filename(species, form, gender, shiny, shadow)
    end
#==================================
    def self.front_sprite_bitmap(species, form = 0, gender = 0, shiny = false, shadow = false)
      filename = self.front_sprite_filename(species, form, gender, shiny, shadow)
      return (filename) ? AnimatedPokemonBitmap.new(filename) : nil
    end

    def self.back_sprite_bitmap(species, form = 0, gender = 0, shiny = false, shadow = false)
      filename = self.back_sprite_filename(species, form, gender, shiny, shadow)
      return (filename) ? AnimatedPokemonBitmap.new(filename) : nil
    end

    def self.egg_sprite_bitmap(species, form = 0)
      filename = self.egg_sprite_filename(species, form)
      return (filename) ? AnimatedPokemonBitmap.new(filename) : nil
    end
#======================================
    def self.sprite_bitmap(species, form = 0, gender = 0, shiny = false, shadow = false, back = false, egg = false)
      return self.egg_sprite_bitmap(species, form) if egg
      return self.back_sprite_bitmap(species, form, gender, shiny, shadow) if back
      return self.front_sprite_bitmap(species, form, gender, shiny, shadow)
    end

    def self.sprite_bitmap_from_pokemon(pkmn, back = false, species = nil)
      species = pkmn.species if !species
      species = GameData::Species.get(species).species   # Just to be sure it's a symbol
      return self.egg_sprite_bitmap(species, pkmn.form) if pkmn.egg?
      if back
        ret = self.back_sprite_bitmap(species, pkmn.form, pkmn.gender, pkmn.shiny?, pkmn.shadowPokemon?)
      else
        ret = self.front_sprite_bitmap(species, pkmn.form, pkmn.gender, pkmn.shiny?, pkmn.shadowPokemon?)
      end
      alter_bitmap_function = MultipleForms.getFunction(species, "alterBitmap")
      if ret && alter_bitmap_function
        new_ret = ret.copy
        ret.dispose
        new_ret.each { |bitmap| alter_bitmap_function.call(pkmn, bitmap) }
        ret = new_ret
      end
      return ret
    end

    #===========================================================================

    def self.egg_icon_filename(species, form)
      ret = self.check_egg_graphic_file("Graphics/Pokemon/Eggs/", species, form, "_icon")
      return (ret) ? ret : pbResolveBitmap("Graphics/Pokemon/Eggs/000_icon")
    end

    def self.icon_filename(species, form = 0, gender = 0, shiny = false, shadow = false, egg = false)
      return self.egg_icon_filename(species, form) if egg
      return self.check_graphic_file("Graphics/Pokemon/", species, form, gender, shiny, shadow, "Icons")
    end

    def self.icon_filename_from_pokemon(pkmn)
      return self.icon_filename(pkmn.species, pkmn.form, pkmn.gender, pkmn.shiny?, pkmn.shadowPokemon?, pkmn.egg?)
    end

    def self.egg_icon_bitmap(species, form)
      filename = self.egg_icon_filename(species, form)
      return (filename) ? AnimatedBitmap.new(filename).deanimate : nil
    end

    def self.icon_bitmap(species, form = 0, gender = 0, shiny = false, shadow = false, egg = false)
      return self.egg_icon_bitmap(species, form) if egg
      filename = self.icon_filename(species, form, gender, shiny, shadow)
      return (filename) ? AnimatedBitmap.new(filename).deanimate : nil
    end

    def self.icon_bitmap_from_pokemon(pkmn)
      return self.icon_bitmap(pkmn.species, pkmn.form, pkmn.gender, pkmn.shiny?, pkmn.shadowPokemon?, pkmn.egg?)
    end

    #===========================================================================

    def self.footprint_filename(species, form = 0)
      species_data = self.get_species_form(species, form)
      return nil if species_data.nil?
      if form > 0
        ret = pbResolveBitmap(sprintf("Graphics/Pokemon/Footprints/%s_%d", species_data.species, form))
        return ret if ret
      end
      return pbResolveBitmap(sprintf("Graphics/Pokemon/Footprints/%s", species_data.species))
    end

    #===========================================================================

    def self.shadow_filename(species, form = 0)
      species_data = self.get_species_form(species, form)
      return nil if species_data.nil?
      # Look for species-specific shadow graphic
      if form > 0
        ret = pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%s_%d", species_data.species, form))
        return ret if ret
      end
      ret = pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%s", species_data.species))
      return ret if ret
      # Use general shadow graphic
      metrics_data = GameData::SpeciesMetrics.get_species_form(species_data.species, form)
      return pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%d", metrics_data.shadow_size))
    end

    def self.shadow_bitmap(species, form = 0)
      filename = self.shadow_filename(species, form)
      #===========================================================================
      return (filename) ? AnimatedPokemonBitmap.new(filename) : nil
      #===========================================================================
    end

    def self.shadow_bitmap_from_pokemon(pkmn)
      filename = self.shadow_filename(pkmn.species, pkmn.form)
      #===========================================================================
      return (filename) ? AnimatedPokemonBitmap.new(filename) : nil
      #===========================================================================
    end

    #===========================================================================

    def self.check_cry_file(species, form, suffix = "")
      species_data = self.get_species_form(species, form)
      return nil if species_data.nil?
      if form > 0
        ret = sprintf("Cries/%s_%d%s", species_data.species, form, suffix)
        return ret if pbResolveAudioSE(ret)
      end
      ret = sprintf("Cries/%s%s", species_data.species, suffix)
      return (pbResolveAudioSE(ret)) ? ret : nil
    end

    def self.cry_filename(species, form = 0, suffix = "")
      return self.check_cry_file(species, form || 0, suffix)
    end

    def self.cry_filename_from_pokemon(pkmn, suffix = "")
      return self.check_cry_file(pkmn.species, pkmn.form, suffix)
    end

    def self.play_cry_from_species(species, form = 0, volume = 90, pitch = 100)
      filename = self.cry_filename(species, form)
      return if !filename
      pbSEPlay(RPG::AudioFile.new(filename, volume, pitch)) rescue nil
    end

    def self.play_cry_from_pokemon(pkmn, volume = 90, pitch = 100)
      return if !pkmn || pkmn.egg?
      filename = self.cry_filename_from_pokemon(pkmn)
      return if !filename
      pitch ||= 100
      pbSEPlay(RPG::AudioFile.new(filename, volume, pitch)) rescue nil
    end

    def self.play_cry(pkmn, volume = 90, pitch = 100)
      if pkmn.is_a?(Pokemon)
        self.play_cry_from_pokemon(pkmn, volume, pitch)
      else
        self.play_cry_from_species(pkmn, 0, volume, pitch)
      end
    end

    def self.cry_length(species, form = 0, pitch = 100, suffix = "")
      pitch ||= 100
      return 0 if !species || pitch <= 0
      pitch = pitch.to_f / 100
      ret = 0.0
      if species.is_a?(Pokemon)
        if !species.egg?
          filename = self.cry_filename_from_pokemon(species, suffix)
          filename = self.cry_filename_from_pokemon(species) if !filename && !nil_or_empty?(suffix)
          filename = pbResolveAudioSE(filename)
          ret = getPlayTime(filename) if filename
        end
      else
        filename = self.cry_filename(species, form, suffix)
        filename = self.cry_filename(species, form) if !filename && !nil_or_empty?(suffix)
        filename = pbResolveAudioSE(filename)
        ret = getPlayTime(filename) if filename
      end
      ret /= pitch   # Sound played at a lower pitch lasts longer
      return ret
    end
  end
end

Please report back to me if it works properly in-battle and in-summary, also make sure to open your Pokedex and check if it works there too.
 
Back
Top