Auto-position backsprite on demand
This tutorial was written by -FL-. Please give credit.
Click here for more tutorials!

Many Essentials users know about the BattlerPlayerY property in pokemon PBS. This property defines the backsprite altitude. In the editor, there's a command that auto-position a single sprite or ALL pokémon sprites. The problem is that this may mess with some variation sprites, especially the form sprites. So I create a function that auto-position the backsprite every time that this sprite is used, ignoring the BattlerPlayerY.

At PokemonSprite script section, change line 'ret+=(metrics[0][species] || 0)*2' to 'ret+=adjustBitmapPlayerY(sprite.bitmap)*2 if (sprite.bitmap && !sprite.bitmap.disposed?)'. Changle line 'ret+=getBattleSpriteMetricOffset(species,index,metrics)' to 'ret+=getBattleSpriteMetricOffset(species,index,metrics,sprite)'. Change line 'def getBattleSpriteMetricOffset(species,index,metrics=nil)' to

def adjustBitmapPlayerY(bitmap)
  return ret/2

def findBottom(bitmap)
  return 0 if !bitmap
  for i in 1..bitmap.height
    for j in 0..bitmap.width-1
      return bitmap.height-i if bitmap.get_pixel(j,bitmap.height-i).alpha>0
  return 0

def getBattleSpriteMetricOffset(species,index,metrics=nil,sprite=nil)

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.