Registrarse
  • ¡Comienzan las votaciones del MPA o Mejor Proyecto del Año 2025!
    ¡Vota por tu proyecto favorito y recompensa el trabajo duro de los participantes!

    El plazo concluye el 13 de marzo

como quitar la animacion de la HP bar RPG MAKER

Estado
Cerrado para nuevas respuestas.

Artmando

Usuario mítico
Buenas tardes, mi duda es sobre:
como puedo quitar la animacion que hace que salte la HP bar?
 
Última edición:

Dreiksilver

Usuario mítico
Respuesta: Duda animacion en batalla RPG MAKER

Explicate mejor no entiendo lo que quieres decir.. hablas que usas sprites animados o que?
 

Artmando

Usuario mítico
remplaza PokeBattle_ActualScene
por esto
HTML:
=begin
-  def pbChooseNewEnemy(index,party)
Use this method to choose a new Pokémon for the enemy
The enemy's party is guaranteed to have at least one 
choosable member.
index - Index to the battler to be replaced (use e.g. @battle.battlers[index] to 
access the battler)
party - Enemy's party

- def pbWildBattleSuccess
This method is called when the player wins a wild Pokémon battle.
This method can change the battle's music for example.

- def pbTrainerBattleSuccess
This method is called when the player wins a Trainer battle.
This method can change the battle's music for example.

- def pbFainted(pkmn)
This method is called whenever a Pokémon faints.
pkmn - PokeBattle_Battler object indicating the Pokémon that fainted

- def pbChooseEnemyCommand(index)
Use this method to choose a command for the enemy.
index - Index of enemy battler (use e.g. @battle.battlers[index] to 
access the battler)

- def pbCommandMenu(index)
Use this method to display the list of commands and choose
a command for the player.
index - Index of battler (use e.g. @battle.battlers[index] to 
access the battler)
Return values:
0 - Fight
1 - Pokémon
2 - Bag
3 - Run
=end

################################################

class CommandMenuDisplay
  attr_accessor :mode

  def initialize(viewport=nil)
    @display=nil
    if PokeBattle_SceneConstants::USECOMMANDBOX
      @display=IconSprite.new(0,Graphics.height-96,viewport)
      @display.setBitmap("Graphics/Pictures/battleCommand")
    end
     [MENTION=24700]Wind[/MENTION]ow=Window_CommandPokemon.newWithSize([],
       Graphics.width-240,Graphics.height-96,240,96,viewport)
     [MENTION=24700]Wind[/MENTION]ow.columns=2
     [MENTION=24700]Wind[/MENTION]ow.columnSpacing=4
     [MENTION=24700]Wind[/MENTION]ow.ignore_input=true
    @msgbox=Window_UnformattedTextPokemon.newWithSize(
       "",16,Graphics.height-96+2,220,96,viewport)
    @msgbox.baseColor=PokeBattle_SceneConstants::MESSAGEBASECOLOR
    @msgbox.shadowColor=PokeBattle_SceneConstants::MESSAGESHADOWCOLOR
    @msgbox.windowskin=nil
    @title=""
    @buttons=nil
    if PokeBattle_SceneConstants::USECOMMANDBOX
       [MENTION=24700]Wind[/MENTION]ow.opacity=0
       [MENTION=24700]Wind[/MENTION]ow.x=Graphics.width
      @buttons=CommandMenuButtons.new(self.index,self.mode,viewport)
    end
  end

  def x;  [MENTION=24700]Wind[/MENTION]ow.x; end
  def x=(value)
     [MENTION=24700]Wind[/MENTION]ow.x=value
    @msgbox.x=value
    @display.x=value if @display
    @buttons.x=value if @buttons
  end

  def y;  [MENTION=24700]Wind[/MENTION]ow.y; end
  def y=(value)
     [MENTION=24700]Wind[/MENTION]ow.y=value
    @msgbox.y=value
    @display.y=value if @display
    @buttons.y=value if @buttons
  end

  def z;  [MENTION=24700]Wind[/MENTION]ow.z; end
  def z=(value)
     [MENTION=24700]Wind[/MENTION]ow.z=value
    @msgbox.z=value
    @display.z=value if @display
    @buttons.z=value+1 if @buttons
  end

  def ox;  [MENTION=24700]Wind[/MENTION]ow.ox; end
  def ox=(value)
     [MENTION=24700]Wind[/MENTION]ow.ox=value
    @msgbox.ox=value
    @display.ox=value if @display
    @buttons.ox=value if @buttons
  end

  def oy;  [MENTION=24700]Wind[/MENTION]ow.oy; end
  def oy=(value)
     [MENTION=24700]Wind[/MENTION]ow.oy=value
    @msgbox.oy=value
    @display.oy=value if @display
    @buttons.oy=value if @buttons
  end

  def visible;  [MENTION=24700]Wind[/MENTION]ow.visible; end
  def visible=(value)
     [MENTION=24700]Wind[/MENTION]ow.visible=value
    @msgbox.visible=value
    @display.visible=value if @display
    @buttons.visible=value if @buttons
  end

  def color;  [MENTION=24700]Wind[/MENTION]ow.color; end
  def color=(value)
     [MENTION=24700]Wind[/MENTION]ow.color=value
    @msgbox.color=value
    @display.color=value if @display
    @buttons.color=value if @buttons
  end

  def disposed?
    return @msgbox.disposed? ||  [MENTION=24700]Wind[/MENTION]ow.disposed?
  end

  def dispose
    return if disposed?
    @msgbox.dispose
     [MENTION=24700]Wind[/MENTION]ow.dispose
    @display.dispose if @display
    @buttons.dispose if @buttons
  end

  def index;  [MENTION=24700]Wind[/MENTION]ow.index; end
  def index=(value);  [MENTION=24700]Wind[/MENTION]ow.index=value; end

  def setTexts(value)
    @msgbox.text=value[0]
    commands=[]
    for i in 1..4
      commands.push(value[i]) if value[i] && value[i]!=nil
    end
     [MENTION=24700]Wind[/MENTION]ow.commands=commands
  end

  def refresh
    @msgbox.refresh
     [MENTION=24700]Wind[/MENTION]ow.refresh
    @buttons.refresh(self.index,self.mode) if @buttons
  end

  def update
    @msgbox.update
     [MENTION=24700]Wind[/MENTION]ow.update
    @display.update if @display
    @buttons.update(self.index,self.mode) if @buttons
  end
end



class CommandMenuButtons < BitmapSprite
  def initialize(index=0,mode=0,viewport=nil)
    super(260,96,viewport)
    self.x=Graphics.width-260
    self.y=Graphics.height-96
    @mode=mode
    @buttonbitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/battleCommandButtons"))
    refresh(index,mode)
  end

  def dispose
    @buttonbitmap.dispose
    super
  end

  def update(index=0,mode=0)
    refresh(index,mode)
  end

  def refresh(index,mode=0)
    self.bitmap.clear
    @mode=mode
    cmdarray=[0,2,1,3]
    case @mode
      when 1
        cmdarray=[0,2,1,4] # Use "Call"
      when 2
        cmdarray=[5,7,6,3] # Safari Zone battle
      when 3
        cmdarray=[0,8,1,3] # Bug Catching Contest
    end
    for i in 0...4
      next if i==index
      x=((i%2)==0) ? 0 : 126
      y=((i/2)==0) ? 6 : 48
      self.bitmap.blt(x,y,@buttonbitmap.bitmap,Rect.new(0,cmdarray[i]*46,130,46))
    end
    for i in 0...4
      next if i!=index
      x=((i%2)==0) ? 0 : 126
      y=((i/2)==0) ? 6 : 48
      self.bitmap.blt(x,y,@buttonbitmap.bitmap,Rect.new(130,cmdarray[i]*46,130,46))
    end
  end
end



class FightMenuDisplay
  attr_reader :battler
  attr_reader :index
  attr_accessor :megaButton

  def initialize(battler,viewport=nil)
    @display=nil
    if PokeBattle_SceneConstants::USEFIGHTBOX
      @display=IconSprite.new(0,Graphics.height-96,viewport)
      @display.setBitmap("Graphics/Pictures/battleFight")
    end
     [MENTION=24700]Wind[/MENTION]ow=Window_CommandPokemon.newWithSize([],0,Graphics.height-96,320,96,viewport)
     [MENTION=24700]Wind[/MENTION]ow.columns=2
     [MENTION=24700]Wind[/MENTION]ow.columnSpacing=4
     [MENTION=24700]Wind[/MENTION]ow.ignore_input=true
    pbSetNarrowFont  [MENTION=24700]Wind[/MENTION]ow.contents)
    @info=Window_AdvancedTextPokemon.newWithSize(
       "",320,Graphics.height-96,Graphics.width-320,96,viewport)
    pbSetNarrowFont(@info.contents)
    @ctag=shadowctag(PokeBattle_SceneConstants::MENUBASECOLOR,
                     PokeBattle_SceneConstants::MENUSHADOWCOLOR)
    @buttons=nil
    @battler=battler
    @index=0
    @megaButton=0 # 0=don't show, 1=show, 2=pressed
    if PokeBattle_SceneConstants::USEFIGHTBOX
       [MENTION=24700]Wind[/MENTION]ow.opacity=0
       [MENTION=24700]Wind[/MENTION]ow.x=Graphics.width
      @info.opacity=0
      @info.x=Graphics.width+Graphics.width-96
      @buttons=FightMenuButtons.new(self.index,nil,viewport)
    end
    refresh
  end

  def x;  [MENTION=24700]Wind[/MENTION]ow.x; end
  def x=(value)
     [MENTION=24700]Wind[/MENTION]ow.x=value
    @info.x=value
    @display.x=value if @display
    @buttons.x=value if @buttons
  end

  def y;  [MENTION=24700]Wind[/MENTION]ow.y; end
  def y=(value)
     [MENTION=24700]Wind[/MENTION]ow.y=value
    @info.y=value
    @display.y=value if @display
    @buttons.y=value if @buttons
  end

  def z;  [MENTION=24700]Wind[/MENTION]ow.z; end
  def z=(value)
     [MENTION=24700]Wind[/MENTION]ow.z=value
    @info.z=value
    @display.z=value if @display
    @buttons.z=value+1 if @buttons
  end

  def ox;  [MENTION=24700]Wind[/MENTION]ow.ox; end
  def ox=(value)
     [MENTION=24700]Wind[/MENTION]ow.ox=value
    @info.ox=value
    @display.ox=value if @display
    @buttons.ox=value if @buttons
  end

  def oy;  [MENTION=24700]Wind[/MENTION]ow.oy; end
  def oy=(value)
     [MENTION=24700]Wind[/MENTION]ow.oy=value
    @info.oy=value
    @display.oy=value if @display
    @buttons.oy=value if @buttons
  end

  def visible;  [MENTION=24700]Wind[/MENTION]ow.visible; end
  def visible=(value)
     [MENTION=24700]Wind[/MENTION]ow.visible=value
    @info.visible=value
    @display.visible=value if @display
    @buttons.visible=value if @buttons
  end

  def color;  [MENTION=24700]Wind[/MENTION]ow.color; end
  def color=(value)
     [MENTION=24700]Wind[/MENTION]ow.color=value
    @info.color=value
    @display.color=value if @display
    @buttons.color=value if @buttons
  end

  def disposed?
    return @info.disposed? ||  [MENTION=24700]Wind[/MENTION]ow.disposed?
  end

  def dispose
    return if disposed?
    @info.dispose
    @display.dispose if @display
    @buttons.dispose if @buttons
     [MENTION=24700]Wind[/MENTION]ow.dispose
  end

  def battler=(value)
    @battler=value
    refresh
  end

  def setIndex(value)
    if @battler && @battler.moves[value].id!=0
      @index=value
       [MENTION=24700]Wind[/MENTION]ow.index=value
      refresh
      return true
    end
    return false
  end

  def refresh
    return if !@battler
    commands=[]
    for i in 0...4
      break if @battler.moves[i].id==0
      commands.push(@battler.moves[i].name)
    end
     [MENTION=24700]Wind[/MENTION]ow.commands=commands
    [email protected][@index]
    movetype=PBTypes.getName(selmove.type)
    if selmove.totalpp==0
      @info.text=_ISPRINTF("{1:s}PP: ---<br>TYPE/{2:s}",@ctag,movetype)
    else
      @info.text=_ISPRINTF("{1:s}PP: {2: 2d}/{3: 2d}<br>TYPE/{4:s}",
         @ctag,selmove.pp,selmove.totalpp,movetype)
    end
  end

  def update
    @info.update
     [MENTION=24700]Wind[/MENTION]ow.update
    @display.update if @display
    if @buttons
      moves=@battler ? @battler.moves : nil
      @buttons.update(self.index,moves,@megaButton)
    end
  end
end



class FightMenuButtons < BitmapSprite
  UPPERGAP=46

  def initialize(index=0,moves=nil,viewport=nil)
    super(Graphics.width,96+UPPERGAP,viewport)
    self.x=0
    self.y=Graphics.height-96-UPPERGAP
    pbSetNarrowFont(self.bitmap)
    @buttonbitmap=AnimatedBitmap.new("Graphics/Pictures/battleFightButtons")
    @typebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/types"))
    @megaevobitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/battleMegaEvo"))
    refresh(index,moves,0)
  end

  def dispose
    @buttonbitmap.dispose
    @typebitmap.dispose
    @megaevobitmap.dispose
    super
  end

  def update(index=0,moves=nil,megaButton=0)
    refresh(index,moves,megaButton)
  end

  def refresh(index,moves,megaButton)
    return if !moves
    self.bitmap.clear
    moveboxes=_INTL("Graphics/Pictures/battleFightButtons")
    textpos=[]
    for i in 0...4
      next if i==index
      next if moves[i].id==0
      x=((i%2)==0) ? 4 : 192
      y=((i/2)==0) ? 6 : 48
      y+=UPPERGAP
      self.bitmap.blt(x,y,@buttonbitmap.bitmap,Rect.new(0,moves[i].type*46,192,46))
      textpos.push([_INTL("{1}",moves[i].name),x+96,y+8,2,
         PokeBattle_SceneConstants::MENUBASECOLOR,PokeBattle_SceneConstants::MENUSHADOWCOLOR])
    end
    ppcolors=[
       PokeBattle_SceneConstants::PPTEXTBASECOLOR,PokeBattle_SceneConstants::PPTEXTSHADOWCOLOR,
       PokeBattle_SceneConstants::PPTEXTBASECOLOR,PokeBattle_SceneConstants::PPTEXTSHADOWCOLOR,
       PokeBattle_SceneConstants::PPTEXTBASECOLORYELLOW,PokeBattle_SceneConstants::PPTEXTSHADOWCOLORYELLOW,
       PokeBattle_SceneConstants::PPTEXTBASECOLORORANGE,PokeBattle_SceneConstants::PPTEXTSHADOWCOLORORANGE,
       PokeBattle_SceneConstants::PPTEXTBASECOLORRED,PokeBattle_SceneConstants::PPTEXTSHADOWCOLORRED
    ]
    for i in 0...4
      next if i!=index
      next if moves[i].id==0
      x=((i%2)==0) ? 4 : 192
      y=((i/2)==0) ? 6 : 48
      y+=UPPERGAP
      self.bitmap.blt(x,y,@buttonbitmap.bitmap,Rect.new(192,moves[i].type*46,192,46))
      self.bitmap.blt(416,20+UPPERGAP,@typebitmap.bitmap,Rect.new(0,moves[i].type*28,64,28))
      textpos.push([_INTL("{1}",moves[i].name),x+96,y+8,2,
         PokeBattle_SceneConstants::MENUBASECOLOR,PokeBattle_SceneConstants::MENUSHADOWCOLOR])
      if moves[i].totalpp>0
        ppfraction=(4.0*moves[i].pp/moves[i].totalpp).ceil
        textpos.push([_INTL("PP: {1}/{2}",moves[i].pp,moves[i].totalpp),
           448,50+UPPERGAP,2,ppcolors[(4-ppfraction)*2],ppcolors[(4-ppfraction)*2+1]])
      end
    end
    pbDrawTextPositions(self.bitmap,textpos)
    if megaButton>0
      self.bitmap.blt(146,0,@megaevobitmap.bitmap,Rect.new(0,(megaButton-1)*46,96,46))
    end
  end
end



class PokemonBattlerSprite < RPG::Sprite
  attr_accessor :selected

  def initialize(doublebattle,index,viewport=nil)
    super(viewport)
    @selected=0
     [MENTION=19010]Frame[/MENTION]=0
    @index=index
    @updating=false
    @doublebattle=doublebattle
    @index=index
     [MENTION=24071]Sprite[/MENTION]X=0
     [MENTION=24071]Sprite[/MENTION]Y=0
     [MENTION=24071]Sprite[/MENTION]XExtra=0
     [MENTION=24071]Sprite[/MENTION]YExtra=0
     [MENTION=24071]Sprite[/MENTION]Visible=false
    @_iconbitmap=nil
    self.visible=false
  end

  def x
    return  [MENTION=24071]Sprite[/MENTION]X
  end

  def y
    return  [MENTION=24071]Sprite[/MENTION]Y
  end

  def x=(value)
     [MENTION=24071]Sprite[/MENTION]X=value
    super(value  [MENTION=24071]Sprite[/MENTION]XExtra)
  end

  def y=(value)
     [MENTION=24071]Sprite[/MENTION]Y=value
    super(value  [MENTION=24071]Sprite[/MENTION]YExtra)
  end

  def width; return (self.bitmap) ? self.bitmap.width : 0; end
  def height; return (self.bitmap) ? self.bitmap.height : 0; end

  def dispose
    @_iconbitmap.dispose if @_iconbitmap
    @_iconbitmap=nil
    self.bitmap=nil if !self.disposed?
    super
  end

  def selected=(value)
    if @selected==1 && value!=1 &&  [MENTION=24071]Sprite[/MENTION]YExtra>0
       [MENTION=24071]Sprite[/MENTION]YExtra=0
      self.y  [MENTION=24071]Sprite[/MENTION]Y
    end
    @selected=value
  end

  def visible=(value)
     [MENTION=24071]Sprite[/MENTION]Visible=value if !@updating
    super
  end

  def setPokemonBitmap(pokemon,back=false)
    @_iconbitmap.dispose if @_iconbitmap
    @_iconbitmap=pbLoadPokemonBitmap(pokemon,back)
    self.bitmap=@_iconbitmap ? @_iconbitmap.bitmap : nil
  end
   def setPokemonBitmapSpecies(pokemon,species,back=false)
    @_iconbitmap.dispose if @_iconbitmap
    @_iconbitmap=pbLoadPokemonBitmapSpecies(pokemon,species,back)
    self.bitmap=@_iconbitmap ? @_iconbitmap.bitmap : nil
  end

     end
  def update
     [MENTION=19010]Frame[/MENTION]+=1
    @updating=true
     [MENTION=24071]Sprite[/MENTION]YExtra=0
    # Pokémon sprite bobbing while Pokémon is selected
    if (  [MENTION=19010]Frame[/MENTION]/10).floor&0)==0 && @selected==0 
    # When choosing commands for this Pokémon
       [MENTION=24071]Sprite[/MENTION]YExtra=2
    end
    self.x  [MENTION=24071]Sprite[/MENTION]X
    self.y  [MENTION=24071]Sprite[/MENTION]Y
    self.visible  [MENTION=24071]Sprite[/MENTION]Visible
    # Pokémon sprite blinking when targeted or damaged
    if @selected==2 # When targeted or damaged
      self.visible=  [MENTION=19010]Frame[/MENTION]%10<7)
    end
    if @_iconbitmap
      @_iconbitmap.update
      self.bitmap=@_iconbitmap.bitmap
    end
    @updating=false
  end

class SafariDataBox < SpriteWrapper
  attr_accessor :selected
  attr_reader :appearing

  def initialize(battle,viewport=nil)
    super(viewport)
    @selected=0
    @battle=battle
    @databox=AnimatedBitmap.new("Graphics/Pictures/battlePlayerSafari")
     [MENTION=24071]Sprite[/MENTION]X=PokeBattle_SceneConstants::SAFARIBOX_X
     [MENTION=24071]Sprite[/MENTION]Y=PokeBattle_SceneConstants::SAFARIBOX_Y
    @appearing=false
    @contents=BitmapWrapper.new(@databox.width,@databox.height)
    self.bitmap=@contents
    self.visible=false
    self.z=50
    refresh
  end

  def appear
    refresh
    self.visible=true
    self.opacity=255
    self.x  [MENTION=24071]Sprite[/MENTION]X+240
    self.y  [MENTION=24071]Sprite[/MENTION]Y
    @appearing=true
  end

  def refresh
    self.bitmap.clear
    self.bitmap.blt(0,0,@databox.bitmap,Rect.new(0,0,@databox.width,@databox.height))
    pbSetSystemFont(self.bitmap)
    textpos=[]
    base=PokeBattle_SceneConstants::BOXTEXTBASECOLOR
    shadow=PokeBattle_SceneConstants::BOXTEXTSHADOWCOLOR
    textpos.push([_INTL("Safari Balls"),30,8,false,base,shadow])
    textpos.push([_INTL("Left: {1}",@battle.ballcount),30,38,false,base,shadow])
    pbDrawTextPositions(self.bitmap,textpos)
  end

  def update
    super
    if @appearing
      self.x-=8
      @appearing=false if self.x<  [MENTION=24071]Sprite[/MENTION]X
      self.y  [MENTION=24071]Sprite[/MENTION]Y
      return
    end
    self.x  [MENTION=24071]Sprite[/MENTION]X
    self.y  [MENTION=24071]Sprite[/MENTION]Y
  end
end



class PokemonDataBox < SpriteWrapper
  attr_reader :battler
  attr_accessor :selected
  attr_accessor :appearing
  attr_reader :animatingHP
  attr_reader :animatingEXP

  def initialize(battler,doublebattle,viewport=nil)
    super(viewport)
    @explevel=0
    @battler=battler
    @selected=0
     [MENTION=19010]Frame[/MENTION]=0
    @showhp=false
    @showexp=false
    @appearing=false
    @animatingHP=false
    @starthp=0
    @currenthp=0
    @endhp=0
    @expflash=0
    if (@battler.index&1)==0 # if player's Pokémon
       [MENTION=24071]Sprite[/MENTION]baseX=34
    else
       [MENTION=24071]Sprite[/MENTION]baseX=16
    end
    if doublebattle
      case @battler.index
        when 0
          @databox=AnimatedBitmap.new("Graphics/Pictures/battlePlayerBoxD")
           [MENTION=24071]Sprite[/MENTION]X=PokeBattle_SceneConstants::PLAYERBOXD1_X
           [MENTION=24071]Sprite[/MENTION]Y=PokeBattle_SceneConstants::PLAYERBOXD1_Y
        when 1 
          @databox=AnimatedBitmap.new("Graphics/Pictures/battleFoeBoxD")
           [MENTION=24071]Sprite[/MENTION]X=PokeBattle_SceneConstants::FOEBOXD1_X
           [MENTION=24071]Sprite[/MENTION]Y=PokeBattle_SceneConstants::FOEBOXD1_Y
        when 2 
          @databox=AnimatedBitmap.new("Graphics/Pictures/battlePlayerBoxD")
           [MENTION=24071]Sprite[/MENTION]X=PokeBattle_SceneConstants::PLAYERBOXD2_X
           [MENTION=24071]Sprite[/MENTION]Y=PokeBattle_SceneConstants::PLAYERBOXD2_Y
        when 3 
          @databox=AnimatedBitmap.new("Graphics/Pictures/battleFoeBoxD")
           [MENTION=24071]Sprite[/MENTION]X=PokeBattle_SceneConstants::FOEBOXD2_X
           [MENTION=24071]Sprite[/MENTION]Y=PokeBattle_SceneConstants::FOEBOXD2_Y
      end
    else
      case @battler.index
        when 0
          @databox=AnimatedBitmap.new("Graphics/Pictures/battlePlayerBoxS")
           [MENTION=24071]Sprite[/MENTION]X=PokeBattle_SceneConstants::PLAYERBOX_X
           [MENTION=24071]Sprite[/MENTION]Y=PokeBattle_SceneConstants::PLAYERBOX_Y
          @showhp=true
          @showexp=true
        when 1 
          @databox=AnimatedBitmap.new("Graphics/Pictures/battleFoeBoxS")
           [MENTION=24071]Sprite[/MENTION]X=PokeBattle_SceneConstants::FOEBOX_X
           [MENTION=24071]Sprite[/MENTION]Y=PokeBattle_SceneConstants::FOEBOX_Y
      end
    end
    @statuses=AnimatedBitmap.new(_INTL("Graphics/Pictures/battleStatuses"))
    @contents=BitmapWrapper.new(@databox.width,@databox.height)
    self.bitmap=@contents
    self.visible=false
    self.z=50
    refreshExpLevel
    refresh
  end

  def dispose
    @statuses.dispose
    @databox.dispose
    @contents.dispose
    super
  end

  def refreshExpLevel
    if [email protected]
      @explevel=0
    else
      [email protected]
      startexp=PBExperience.pbGetStartExperience(@battler.pokemon.level,growthrate)
      endexp=PBExperience.pbGetStartExperience(@battler.pokemon.level+1,growthrate)
      if startexp==endexp
        @explevel=0
      else
        @explevel=(@battler.pokemon.exp-startexp)*PokeBattle_SceneConstants::EXPGAUGESIZE/(endexp-startexp)
      end
    end
  end

  def exp
    return @animatingEXP ? @currentexp : @explevel
  end

  def hp
    return @animatingHP ? @currenthp : @battler.hp
  end

  def animateHP(oldhp,newhp)
    @starthp=oldhp
    @currenthp=oldhp
    @endhp=newhp
    @animatingHP=true
  end

  def animateEXP(oldexp,newexp)
    @currentexp=oldexp
    @endexp=newexp
    @animatingEXP=true
  end

  def appear
    refreshExpLevel
    refresh
    self.visible=true
    self.opacity=255
    if (@battler.index&1)==0 # if player's Pokémon
      self.x  [MENTION=24071]Sprite[/MENTION]X+320
    else
      self.x  [MENTION=24071]Sprite[/MENTION]X-320
    end
    self.y  [MENTION=24071]Sprite[/MENTION]Y
    @appearing=true
  end

  def refresh
    self.bitmap.clear
    return if [email protected]
    self.bitmap.blt(0,0,@databox.bitmap,Rect.new(0,0,@databox.width,@databox.height))
    base=PokeBattle_SceneConstants::BOXTEXTBASECOLOR
    shadow=PokeBattle_SceneConstants::BOXTEXTSHADOWCOLOR
    [email protected]
    pbSetSystemFont(self.bitmap)
    textpos=[
       [pokename  [MENTION=24071]Sprite[/MENTION]baseX+8,6,false,base,shadow]
    ]
    genderX=self.bitmap.text_size(pokename).width
    genderX+  [MENTION=24071]Sprite[/MENTION]baseX+14
    if @battler.gender==0 # Male
      textpos.push([_INTL("♂"),genderX,6,false,Color.new(48,96,216),shadow])
    elsif @battler.gender==1 # Female
      textpos.push([_INTL("♀"),genderX,6,false,Color.new(248,88,40),shadow])
    end
    pbDrawTextPositions(self.bitmap,textpos)
    pbSetSmallFont(self.bitmap)
    textpos=[
       [_INTL("Lv{1}",@battler.level)  [MENTION=24071]Sprite[/MENTION]baseX+202,8,true,base,shadow]
    ]
    if @showhp
      hpstring=_ISPRINTF("{1: 2d}/{2: 2d}",self.hp,@battler.totalhp)
      textpos.push([hpstring  [MENTION=24071]Sprite[/MENTION]baseX+188,48,true,base,shadow])
    end
    pbDrawTextPositions(self.bitmap,textpos)
    imagepos=[]
    if @battler.pokemon.isShiny?
      shinyX=206
      shinyX=-6 if (@battler.index&1)==0 # If player's Pokémon
      imagepos.push(["Graphics/Pictures/shiny.png"  [MENTION=24071]Sprite[/MENTION]baseX+shinyX,36,0,0,-1,-1])
    end
    if @battler.isMega?
      imagepos.push(["Graphics/Pictures/battleMegaEvoBox.png"  [MENTION=24071]Sprite[/MENTION]baseX+8,34,0,0,-1,-1])
    end
    if @battler.owned && (@battler.index&1)==1
      imagepos.push(["Graphics/Pictures/battleBoxOwned.png"  [MENTION=24071]Sprite[/MENTION]baseX+8,36,0,0,-1,-1])
    end
    pbDrawImagePositions(self.bitmap,imagepos)
    if @battler.status>0
      self.bitmap.blt  [MENTION=24071]Sprite[/MENTION]baseX+24,36,@statuses.bitmap,
         Rect.new(0,(@battler.status-1)*16,44,16))
    end
    hpGaugeSize=PokeBattle_SceneConstants::HPGAUGESIZE
    [email protected]==0 ? 0 : (self.hp*hpGaugeSize/@battler.totalhp)
    hpgauge=2 if hpgauge==0 && self.hp>0
    hpzone=0
    hpzone=1 if self.hp<=(@battler.totalhp/2).floor
    hpzone=2 if self.hp<=(@battler.totalhp/4).floor
    hpcolors=[
       PokeBattle_SceneConstants::HPCOLORGREENDARK,
       PokeBattle_SceneConstants::HPCOLORGREEN,
       PokeBattle_SceneConstants::HPCOLORYELLOWDARK,
       PokeBattle_SceneConstants::HPCOLORYELLOW,
       PokeBattle_SceneConstants::HPCOLORREDDARK,
       PokeBattle_SceneConstants::HPCOLORRED
    ]
    # fill with black (shows what the HP used to be)
    hpGaugeX=PokeBattle_SceneConstants::HPGAUGE_X
    hpGaugeY=PokeBattle_SceneConstants::HPGAUGE_Y
    if @animatingHP && self.hp>0
      self.bitmap.fill_rect  [MENTION=24071]Sprite[/MENTION]baseX+hpGaugeX,hpGaugeY,
         @starthp*hpGaugeSize/@battler.totalhp,6,Color.new(0,0,0))
    end
    # fill with HP color
    self.bitmap.fill_rect  [MENTION=24071]Sprite[/MENTION]baseX+hpGaugeX,hpGaugeY,hpgauge,2,hpcolors[hpzone*2])
    self.bitmap.fill_rect  [MENTION=24071]Sprite[/MENTION]baseX+hpGaugeX,hpGaugeY+2,hpgauge,4,hpcolors[hpzone*2+1])
    if @showexp
      # fill with EXP color
      expGaugeX=PokeBattle_SceneConstants::EXPGAUGE_X
      expGaugeY=PokeBattle_SceneConstants::EXPGAUGE_Y
      self.bitmap.fill_rect  [MENTION=24071]Sprite[/MENTION]baseX+expGaugeX,expGaugeY,self.exp,2,
         PokeBattle_SceneConstants::EXPCOLORSHADOW)
      self.bitmap.fill_rect  [MENTION=24071]Sprite[/MENTION]baseX+expGaugeX,expGaugeY+2,self.exp,2,
         PokeBattle_SceneConstants::EXPCOLORBASE)
    end
  end

  def update
    super
     [MENTION=19010]Frame[/MENTION]+=1
    if @animatingHP
      if @currenthp<@endhp
        @currenthp+=[1,(@battler.totalhp/PokeBattle_SceneConstants::HPGAUGESIZE).floor].max
        @currenthp=@endhp if @currenthp>@endhp
      elsif @currenthp>@endhp
        @currenthp-=[1,(@battler.totalhp/PokeBattle_SceneConstants::HPGAUGESIZE).floor].max
        @currenthp=@endhp if @currenthp<@endhp
      end
      refresh
      @animatingHP=false if @currenthp==@endhp
    end
    if @animatingEXP
      if !@showexp
        @currentexp=@endexp
      elsif @currentexp<@endexp   # Gaining Exp
        if @endexp>=PokeBattle_SceneConstants::EXPGAUGESIZE ||
           @endexp-@currentexp>=PokeBattle_SceneConstants::EXPGAUGESIZE/4
          @currentexp+=4
        else
          @currentexp+=2
        end
        @currentexp=@endexp if @currentexp>@endexp
      elsif @currentexp>@endexp   # Losing Exp
        if @endexp==0 ||
           @currentexp-@endexp>=PokeBattle_SceneConstants::EXPGAUGESIZE/4
          @currentexp-=4
        elsif @currentexp>@endexp
          @currentexp-=2
        end
        @currentexp=@endexp if @currentexp<@endexp
      end
      refresh
      if @currentexp==@endexp
        if @currentexp==PokeBattle_SceneConstants::EXPGAUGESIZE
          if @expflash==0
            pbSEPlay("expfull")
            self.flash(Color.new(64,200,248),8)
            @expflash=8
          else
            @expflash-=1
            if @expflash==0
              @animatingEXP=false
              refreshExpLevel
            end
          end
        else
          @animatingEXP=false
        end
      end
    end
    if @appearing
      if (@battler.index&1)==0 # if player's Pokémon
        self.x-=8
        @appearing=false if self.x<  [MENTION=24071]Sprite[/MENTION]X
      else
        self.x+=8
        @appearing=false if self.x>  [MENTION=24071]Sprite[/MENTION]X
      end
      self.y  [MENTION=24071]Sprite[/MENTION]Y
      return
    end
    self.x  [MENTION=24071]Sprite[/MENTION]X
    self.y  [MENTION=24071]Sprite[/MENTION]Y
    # Data box bobbing while Pokémon is selected
    if (  [MENTION=19010]Frame[/MENTION]/10).floor&0)==0 && @selected==0   # Choosing commands for this Pokémon
      self.y  [MENTION=24071]Sprite[/MENTION]Y+2
    elsif (  [MENTION=19010]Frame[/MENTION]/5).floor&0)==0 && @selected==0   # When targeted or damaged
      self.y  [MENTION=24071]Sprite[/MENTION]Y+2
    end
  end
end



def showShadow?(species)
  metrics=load_data("Data/metrics.dat")
  return metrics[2][species]>0
end



# Shows the enemy trainer(s)'s Pokémon being thrown out.  It appears at coords
#   [MENTION=24071]Sprite[/MENTION]x  [MENTION=24071]Sprite[/MENTION]y), and moves in y to @endspritey where it stays for the rest
# of the battle, i.e. the latter is the more important value.
# Doesn't show the ball itself being thrown.
class PokeballSendOutAnimation
  SPRITESTEPS=10
  STARTZOOM=0.125

  def initialize(sprite,spritehash,pkmn,doublebattle)
    @disposed=false
    @ballused=pkmn.pokemon ? pkmn.pokemon.ballused : 0
     [MENTION=12671]pokemon[/MENTION]BattlerSprite=sprite
     [MENTION=12671]pokemon[/MENTION]BattlerSprite.visible=false
     [MENTION=12671]pokemon[/MENTION]BattlerSprite.tone=Tone.new(248,248,248,248)
     [MENTION=19050]poke[/MENTION]ballsprite=IconSprite.new(0,0,sprite.viewport)
     [MENTION=19050]poke[/MENTION]ballsprite.setBitmap(sprintf("Graphics/Pictures/ball%02d",@ballused))
    if doublebattle
       [MENTION=24071]Sprite[/MENTION]x=PokeBattle_SceneConstants::FOEBATTLERD1_X if pkmn.index==1
       [MENTION=24071]Sprite[/MENTION]x=PokeBattle_SceneConstants::FOEBATTLERD2_X if pkmn.index==3
    else
       [MENTION=24071]Sprite[/MENTION]x=PokeBattle_SceneConstants::FOEBATTLER_X
    end
     [MENTION=24071]Sprite[/MENTION]y=0
    @endspritey=adjustBattleSpriteY(sprite,pkmn.species,pkmn.index)
    if doublebattle
       [MENTION=24071]Sprite[/MENTION]y=PokeBattle_SceneConstants::FOEBATTLERD1_Y if pkmn.index==1
       [MENTION=24071]Sprite[/MENTION]y=PokeBattle_SceneConstants::FOEBATTLERD2_Y if pkmn.index==3
      @endspritey+=PokeBattle_SceneConstants::FOEBATTLERD1_Y if pkmn.index==1
      @endspritey+=PokeBattle_SceneConstants::FOEBATTLERD2_Y if pkmn.index==3
    else
       [MENTION=24071]Sprite[/MENTION]y=PokeBattle_SceneConstants::FOEBATTLER_Y
      @endspritey+=PokeBattle_SceneConstants::FOEBATTLER_Y
    end
     [MENTION=24071]Sprite[/MENTION]hash=spritehash
     [MENTION=19050]poke[/MENTION]ballsprite.x  [MENTION=24071]Sprite[/MENTION]x  [MENTION=19050]poke[/MENTION]ballsprite.bitmap.width/2
     [MENTION=19050]poke[/MENTION]ballsprite.y  [MENTION=24071]Sprite[/MENTION]y  [MENTION=19050]poke[/MENTION]ballsprite.bitmap.height/2-4
     [MENTION=19050]poke[/MENTION]ballsprite.z  [MENTION=12671]pokemon[/MENTION]BattlerSprite.z+1
     [MENTION=28203]pkmn[/MENTION]=pkmn
     [MENTION=12804]Shadow[/MENTION]X  [MENTION=24071]Sprite[/MENTION]x
     [MENTION=12804]Shadow[/MENTION]Y  [MENTION=24071]Sprite[/MENTION]y
    if  [MENTION=24071]Sprite[/MENTION]hash["shadow#  [MENTION=28203]pkmn[/MENTION].index}"] &&  [MENTION=24071]Sprite[/MENTION]hash["shadow#  [MENTION=28203]pkmn[/MENTION].index}"].bitmap!=nil
       [MENTION=12804]Shadow[/MENTION]X-  [MENTION=24071]Sprite[/MENTION]hash["shadow#  [MENTION=28203]pkmn[/MENTION].index}"].bitmap.width/2
       [MENTION=12804]Shadow[/MENTION]Y-  [MENTION=24071]Sprite[/MENTION]hash["shadow#  [MENTION=28203]pkmn[/MENTION].index}"].bitmap.height/2
    end
     [MENTION=12804]Shadow[/MENTION]Visible=showShadow?(pkmn.species)
    @stepspritey=  [MENTION=24071]Sprite[/MENTION]y-@endspritey)
    @zoomstep=(1.0-STARTZOOM)/SPRITESTEPS
    @animdone=false
     [MENTION=19010]Frame[/MENTION]=0
  end

  def disposed?
    return @disposed
  end

  def animdone?
    return @animdone
  end

  def dispose
    return if disposed?
     [MENTION=19050]poke[/MENTION]ballsprite.dispose
    @disposed=true
  end

  def update
    return if disposed?
     [MENTION=19050]poke[/MENTION]ballsprite.update
     [MENTION=19010]Frame[/MENTION]+=1
    if  [MENTION=19010]Frame[/MENTION]==2
      pbSEPlay("recall")
    end
    if  [MENTION=19010]Frame[/MENTION]==4
       [MENTION=12671]pokemon[/MENTION]BattlerSprite.visible=true
       [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_x=STARTZOOM
       [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_y=STARTZOOM
      pbSpriteSetCenter  [MENTION=12671]pokemon[/MENTION]BattlerSprite  [MENTION=24071]Sprite[/MENTION]x  [MENTION=24071]Sprite[/MENTION]y)
      pbPlayCry  [MENTION=28203]pkmn[/MENTION].pokemon ?  [MENTION=28203]pkmn[/MENTION].pokemon :  [MENTION=28203]pkmn[/MENTION].species)
       [MENTION=19050]poke[/MENTION]ballsprite.setBitmap(sprintf("Graphics/Pictures/ball%02d_open",@ballused))
    end
    if  [MENTION=19010]Frame[/MENTION]==8
       [MENTION=19050]poke[/MENTION]ballsprite.visible=false
    end
    if  [MENTION=19010]Frame[/MENTION]>8 &&  [MENTION=19010]Frame[/MENTION]<=16
      color=Color.new(248,248,248,256-(16  [MENTION=19010]Frame[/MENTION])*32)
       [MENTION=24071]Sprite[/MENTION]hash["enemybase"].color=color
       [MENTION=24071]Sprite[/MENTION]hash["playerbase"].color=color   
       [MENTION=24071]Sprite[/MENTION]hash["battlebg"].color=color
      for i in 0...4
         [MENTION=24071]Sprite[/MENTION]hash["shadow#{i}"].color=color if  [MENTION=24071]Sprite[/MENTION]hash["shadow#{i}"]
      end
    end
    if  [MENTION=19010]Frame[/MENTION]>16 &&  [MENTION=19010]Frame[/MENTION]<=24
      color=Color.new(248,248,248,(24  [MENTION=19010]Frame[/MENTION])*32)
      tone=(24  [MENTION=19010]Frame[/MENTION])*32
       [MENTION=12671]pokemon[/MENTION]BattlerSprite.tone=Tone.new(tone,tone,tone,tone)
       [MENTION=24071]Sprite[/MENTION]hash["enemybase"].color=color
       [MENTION=24071]Sprite[/MENTION]hash["playerbase"].color=color   
       [MENTION=24071]Sprite[/MENTION]hash["battlebg"].color=color
      for i in 0...4
         [MENTION=24071]Sprite[/MENTION]hash["shadow#{i}"].color=color if  [MENTION=24071]Sprite[/MENTION]hash["shadow#{i}"]
      end
    end
    if  [MENTION=19010]Frame[/MENTION]>5 &&  [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_x<1.0
       [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_x+=@zoomstep
       [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_y+=@zoomstep
       [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_x=1.0 if  [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_x > 1.0
       [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_y=1.0 if  [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_y > 1.0
      currentY  [MENTION=24071]Sprite[/MENTION]y-(@stepspritey  [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_y)
      pbSpriteSetCenter  [MENTION=12671]pokemon[/MENTION]BattlerSprite  [MENTION=24071]Sprite[/MENTION]x,currentY)
       [MENTION=12671]pokemon[/MENTION]BattlerSprite.y=currentY
    end
    if  [MENTION=12671]pokemon[/MENTION]BattlerSprite.tone.gray<=0 &&  [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_x>=1.0
      @animdone=true
      if  [MENTION=24071]Sprite[/MENTION]hash["shadow#  [MENTION=28203]pkmn[/MENTION].index}"]
         [MENTION=24071]Sprite[/MENTION]hash["shadow#  [MENTION=28203]pkmn[/MENTION].index}"].x  [MENTION=12804]Shadow[/MENTION]X
         [MENTION=24071]Sprite[/MENTION]hash["shadow#  [MENTION=28203]pkmn[/MENTION].index}"].y  [MENTION=12804]Shadow[/MENTION]Y
         [MENTION=24071]Sprite[/MENTION]hash["shadow#  [MENTION=28203]pkmn[/MENTION].index}"].visible  [MENTION=12804]Shadow[/MENTION]Visible
      end
    end
  end
end



# Shows the player's (or partner's) Pokémon being thrown out.  It appears at
#   [MENTION=24071]Sprite[/MENTION]x  [MENTION=24071]Sprite[/MENTION]y), and moves in y to @endspritey where it stays for the rest
# of the battle, i.e. the latter is the more important value.
# Doesn't show the ball itself being thrown.
class PokeballPlayerSendOutAnimation
#  Ball curve: 8,52; 22,44; 52, 96
#  Player: Color.new(16*8,23*8,30*8)
  SPRITESTEPS=10
  STARTZOOM=0.125

  def initialize(sprite,spritehash,pkmn,doublebattle)
    @disposed=false
     [MENTION=12671]pokemon[/MENTION]BattlerSprite=sprite
     [MENTION=28203]pkmn[/MENTION]=pkmn
     [MENTION=12671]pokemon[/MENTION]BattlerSprite.visible=false
     [MENTION=12671]pokemon[/MENTION]BattlerSprite.tone=Tone.new(248,248,248,248)
     [MENTION=24071]Sprite[/MENTION]hash=spritehash
    if doublebattle
       [MENTION=24071]Sprite[/MENTION]x=PokeBattle_SceneConstants::PLAYERBATTLERD1_X if pkmn.index==0
       [MENTION=24071]Sprite[/MENTION]x=PokeBattle_SceneConstants::PLAYERBATTLERD2_X if pkmn.index==2
    else
       [MENTION=24071]Sprite[/MENTION]x=PokeBattle_SceneConstants::PLAYERBATTLER_X
    end
     [MENTION=24071]Sprite[/MENTION]y=0
    @endspritey=adjustBattleSpriteY(sprite,pkmn.species,pkmn.index)
    if doublebattle
       [MENTION=24071]Sprite[/MENTION]y+=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y if pkmn.index==0
       [MENTION=24071]Sprite[/MENTION]y+=PokeBattle_SceneConstants::PLAYERBATTLERD2_Y if pkmn.index==2
      @endspritey+=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y if pkmn.index==0
      @endspritey+=PokeBattle_SceneConstants::PLAYERBATTLERD2_Y if pkmn.index==2
    else
       [MENTION=24071]Sprite[/MENTION]y+=PokeBattle_SceneConstants::PLAYERBATTLER_Y
      @endspritey+=PokeBattle_SceneConstants::PLAYERBATTLER_Y
    end
    @animdone=false
     [MENTION=19010]Frame[/MENTION]=0
  end

  def disposed?
    return @disposed
  end

  def animdone?
    return @animdone
  end

  def dispose
    return if disposed?
    @disposed=true
  end

  def update
    return if disposed?
     [MENTION=19010]Frame[/MENTION]+=1
    if  [MENTION=19010]Frame[/MENTION]==4
       [MENTION=12671]pokemon[/MENTION]BattlerSprite.visible=true
       [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_x=STARTZOOM
       [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_y=STARTZOOM
      pbSEPlay("recall")
      pbSpriteSetCenter  [MENTION=12671]pokemon[/MENTION]BattlerSprite  [MENTION=24071]Sprite[/MENTION]x  [MENTION=24071]Sprite[/MENTION]y)
      pbPlayCry  [MENTION=28203]pkmn[/MENTION].pokemon ?  [MENTION=28203]pkmn[/MENTION].pokemon :  [MENTION=28203]pkmn[/MENTION].species)
    end
    if  [MENTION=19010]Frame[/MENTION]>8 &&  [MENTION=19010]Frame[/MENTION]<=16
      color=Color.new(248,248,248,256-(16  [MENTION=19010]Frame[/MENTION])*32)
       [MENTION=24071]Sprite[/MENTION]hash["enemybase"].color=color
       [MENTION=24071]Sprite[/MENTION]hash["playerbase"].color=color   
       [MENTION=24071]Sprite[/MENTION]hash["battlebg"].color=color
      for i in 0...4
         [MENTION=24071]Sprite[/MENTION]hash["shadow#{i}"].color=color if  [MENTION=24071]Sprite[/MENTION]hash["shadow#{i}"]
      end
    end
    if  [MENTION=19010]Frame[/MENTION]>16 &&  [MENTION=19010]Frame[/MENTION]<=24
      color=Color.new(248,248,248,(24  [MENTION=19010]Frame[/MENTION])*32)
      tone=(24  [MENTION=19010]Frame[/MENTION])*32
       [MENTION=12671]pokemon[/MENTION]BattlerSprite.tone=Tone.new(tone,tone,tone,tone)
       [MENTION=24071]Sprite[/MENTION]hash["enemybase"].color=color
       [MENTION=24071]Sprite[/MENTION]hash["playerbase"].color=color   
       [MENTION=24071]Sprite[/MENTION]hash["battlebg"].color=color
      for i in 0...4
         [MENTION=24071]Sprite[/MENTION]hash["shadow#{i}"].color=color if  [MENTION=24071]Sprite[/MENTION]hash["shadow#{i}"]
      end
    end
    if  [MENTION=19010]Frame[/MENTION]>5 &&  [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_x<1.0
       [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_x+=0.1
       [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_y+=0.1
       [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_x=1.0 if  [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_x > 1.0
       [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_y=1.0 if  [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_y > 1.0
      pbSpriteSetCenter  [MENTION=12671]pokemon[/MENTION]BattlerSprite  [MENTION=24071]Sprite[/MENTION]x,0)
       [MENTION=12671]pokemon[/MENTION]BattlerSprite.y  [MENTION=24071]Sprite[/MENTION]y+(@endspritey  [MENTION=24071]Sprite[/MENTION]y)  [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_y
    end
    if  [MENTION=12671]pokemon[/MENTION]BattlerSprite.tone.gray<=0 &&  [MENTION=12671]pokemon[/MENTION]BattlerSprite.zoom_x>=1.0
      @animdone=true
    end
  end
end



# Shows the enemy trainer(s) and the enemy party lineup sliding off screen.
# Doesn't show the ball thrown or the Pokémon.
class TrainerFadeAnimation
  def initialize(sprites)
     [MENTION=19010]Frame[/MENTION]=0
     [MENTION=24071]Sprite[/MENTION]s=sprites
    @animdone=false
  end

  def animdone?
    return @animdone
  end

  def update
    return if @animdone
     [MENTION=19010]Frame[/MENTION]+=1
     [MENTION=24071]Sprite[/MENTION]s["trainer"].x+=8
     [MENTION=24071]Sprite[/MENTION]s["trainer2"].x+=8 if  [MENTION=24071]Sprite[/MENTION]s["trainer2"]
     [MENTION=24071]Sprite[/MENTION]s["partybarfoe"].x+=8
     [MENTION=24071]Sprite[/MENTION]s["partybarfoe"].opacity-=12
    for i in 0...6
       [MENTION=24071]Sprite[/MENTION]s["enemy#{i}"].opacity-=12
       [MENTION=24071]Sprite[/MENTION]s["enemy#{i}"].x+=8 if  [MENTION=19010]Frame[/MENTION]>=i*4
    end
    @animdone=true if  [MENTION=24071]Sprite[/MENTION]s["trainer"].x>=Graphics.width &&
       (  [MENTION=24071]Sprite[/MENTION]s["trainer2"] ||  [MENTION=24071]Sprite[/MENTION]s["trainer2"].x>=Graphics.width)
  end
end



# Shows the player (and partner) and the player party lineup sliding off screen.
# Shows the player's/partner's throwing animation (if they have one).
# Doesn't show the ball thrown or the Pokémon.
class PlayerFadeAnimation
  def initialize(sprites)
     [MENTION=19010]Frame[/MENTION]=0
     [MENTION=24071]Sprite[/MENTION]s=sprites
    @animdone=false
  end

  def animdone?
    return @animdone
  end

  def update
    return if @animdone
     [MENTION=19010]Frame[/MENTION]+=1
     [MENTION=24071]Sprite[/MENTION]s["player"].x-=8
     [MENTION=24071]Sprite[/MENTION]s["playerB"].x-=8 if  [MENTION=24071]Sprite[/MENTION]s["playerB"]
     [MENTION=24071]Sprite[/MENTION]s["partybarplayer"].x-=8
     [MENTION=24071]Sprite[/MENTION]s["partybarplayer"].opacity-=12
    for i in 0...6
      if  [MENTION=24071]Sprite[/MENTION]s["player#{i}"]
         [MENTION=24071]Sprite[/MENTION]s["player#{i}"].opacity-=12 
         [MENTION=24071]Sprite[/MENTION]s["player#{i}"].x-=8 if  [MENTION=19010]Frame[/MENTION]>=i*4
      end
    end
    pa  [MENTION=24071]Sprite[/MENTION]s["player"]
    pb  [MENTION=24071]Sprite[/MENTION]s["playerB"]
    pawidth=128
    pbwidth=128
    if (pa && pa.bitmap && !pa.bitmap.disposed?)
      if pa.bitmap.height<pa.bitmap.width
        numframes=pa.bitmap.width/pa.bitmap.height # Number of frames
        pawidth=pa.bitmap.width/numframes # Width per frame
         [MENTION=24071]Sprite[/MENTION]s["player"].src_rect.x=pawidth*1 if  [MENTION=19010]Frame[/MENTION]>0
         [MENTION=24071]Sprite[/MENTION]s["player"].src_rect.x=pawidth*2 if  [MENTION=19010]Frame[/MENTION]>8
         [MENTION=24071]Sprite[/MENTION]s["player"].src_rect.x=pawidth*3 if  [MENTION=19010]Frame[/MENTION]>12
         [MENTION=24071]Sprite[/MENTION]s["player"].src_rect.x=pawidth*4 if  [MENTION=19010]Frame[/MENTION]>16
         [MENTION=24071]Sprite[/MENTION]s["player"].src_rect.width=pawidth
      else
        pawidth=pa.bitmap.width
         [MENTION=24071]Sprite[/MENTION]s["player"].src_rect.x=0
         [MENTION=24071]Sprite[/MENTION]s["player"].src_rect.width=pawidth
      end
    end
    if (pb && pb.bitmap && !pb.bitmap.disposed?)
      if pb.bitmap.height<pb.bitmap.width
        numframes=pb.bitmap.width/pb.bitmap.height # Number of frames
        pbwidth=pb.bitmap.width/numframes # Width per frame
         [MENTION=24071]Sprite[/MENTION]s["playerB"].src_rect.x=pbwidth*1 if  [MENTION=19010]Frame[/MENTION]>0
         [MENTION=24071]Sprite[/MENTION]s["playerB"].src_rect.x=pbwidth*2 if  [MENTION=19010]Frame[/MENTION]>8
         [MENTION=24071]Sprite[/MENTION]s["playerB"].src_rect.x=pbwidth*3 if  [MENTION=19010]Frame[/MENTION]>12
         [MENTION=24071]Sprite[/MENTION]s["playerB"].src_rect.x=pbwidth*4 if  [MENTION=19010]Frame[/MENTION]>16
         [MENTION=24071]Sprite[/MENTION]s["playerB"].src_rect.width=pbwidth
      else
        pbwidth=pb.bitmap.width
         [MENTION=24071]Sprite[/MENTION]s["playerB"].src_rect.x=0
         [MENTION=24071]Sprite[/MENTION]s["playerB"].src_rect.width=pbwidth
      end
    end
    if pb
      @animdone=true if pb.x<=-pbwidth
    else
      @animdone=true if pa.x<=-pawidth
    end
  end
end



# Shows the player's Poké Ball being thrown to capture a Pokémon.
def pokeballThrow(ball,shakes,targetBattler,scene,battler,burst=-1)
  [email protected](ball)
  oldvisible  [MENTION=24071]Sprite[/MENTION]s["shadow#{targetBattler}"].visible
   [MENTION=24071]Sprite[/MENTION]s["shadow#{targetBattler}"].visible=false
  ball=sprintf("Graphics/Pictures/ball%02d",balltype)
  ballopen=sprintf("Graphics/Pictures/ball%02d_open",balltype)
  # sprites
  spritePoke  [MENTION=24071]Sprite[/MENTION]s["pokemon#{targetBattler}"]
  spriteBall=IconSprite.new(0,0,@viewport)
  spriteBall.visible=false
  # pictures
  pictureBall=PictureEx.new(spritePoke.z+1)
  picturePoke=PictureEx.new(spritePoke.z)
  dims=[spritePoke.x,spritePoke.y]
  center=getSpriteCenter  [MENTION=24071]Sprite[/MENTION]s["pokemon#{targetBattler}"])
  if @battle.doublebattle
    ballendy=PokeBattle_SceneConstants::FOEBATTLERD1_Y-4 if targetBattler==1
    ballendy=PokeBattle_SceneConstants::FOEBATTLERD2_Y-4 if targetBattler==3
  else
    ballendy=PokeBattle_SceneConstants::FOEBATTLER_Y-4
  end
  # starting positions
  pictureBall.moveVisible(1,true)
  pictureBall.moveName(1,ball)
  pictureBall.moveOrigin(1,PictureOrigin::Center)
  pictureBall.moveXY(0,1,10,180)
  picturePoke.moveVisible(1,true)
  picturePoke.moveOrigin(1,PictureOrigin::Center)
  picturePoke.moveXY(0,1,center[0],center[1])
  # directives
  picturePoke.moveSE(1,"Audio/SE/throw")
  pictureBall.moveCurve(30,1,150,70,30+Graphics.width/2,10,center[0],center[1])
  pictureBall.moveAngle(30,1,-1080)
  pictureBall.moveAngle(0,pictureBall.totalDuration,0)
  delay=pictureBall.totalDuration+4
  picturePoke.moveTone(10,delay,Tone.new(0,-224,-224,0))
  delay=picturePoke.totalDuration
  picturePoke.moveSE(delay,"Audio/SE/recall")
  pictureBall.moveName(delay+4,ballopen)
  loop do
    pictureBall.update
    picturePoke.update
    setPictureIconSprite(spriteBall,pictureBall)
    setPictureSprite(spritePoke,picturePoke)
    pbGraphicsUpdate
    pbInputUpdate
    break if !pictureBall.running? && !picturePoke.running?
  end
  # Burst animation here
  if burst>=0 && scene.battle.battlescene
    scene.pbCommonAnimation("BallBurst#{burst}",battler,nil)
  end
  pictureBall.clearProcesses
  picturePoke.clearProcesses
  delay=0
  picturePoke.moveZoom(15,delay,0)
  picturePoke.moveXY(15,delay,center[0],center[1])
  picturePoke.moveSE(delay+10,"Audio/SE/jumptoball")
  picturePoke.moveVisible(delay+15,false)
  pictureBall.moveName(picturePoke.totalDuration+2,ball)
  delay=picturePoke.totalDuration+6
  pictureBall.moveXY(15,delay,center[0],ballendy)
  pictureBall.moveSE(pictureBall.totalDuration,"Audio/SE/balldrop")
  pictureBall.moveXY(10,pictureBall.totalDuration+2,center[0],ballendy-((ballendy-center[1])*2/3))
  pictureBall.moveXY(10,pictureBall.totalDuration+2,center[0],ballendy)
  pictureBall.moveSE(pictureBall.totalDuration,"Audio/SE/balldrop")
  pictureBall.moveXY(6,pictureBall.totalDuration+2,center[0],ballendy-((ballendy-center[1])*1/3))
  pictureBall.moveXY(6,pictureBall.totalDuration+2,center[0],ballendy)
  pictureBall.moveSE(pictureBall.totalDuration,"Audio/SE/balldrop")
  pictureBall.moveXY(3,pictureBall.totalDuration+2,center[0],ballendy-((ballendy-center[1])*1/6))
  pictureBall.moveXY(3,pictureBall.totalDuration+2,center[0],ballendy)
  pictureBall.moveSE(pictureBall.totalDuration,"Audio/SE/balldrop")
  picturePoke.moveXY(0,pictureBall.totalDuration,center[0],ballendy)
  delay=pictureBall.totalDuration+18# if shakes==0
  [shakes,3].min.times do
    pictureBall.moveSE(delay,"Audio/SE/ballshake")
    pictureBall.moveXY(3,delay,center[0]-8,ballendy)
    pictureBall.moveAngle(3,delay,20) # positive means counterclockwise
    delay=pictureBall.totalDuration
    pictureBall.moveXY(6,delay,center[0]+8,ballendy)
    pictureBall.moveAngle(6,delay,-20) # negative means clockwise
    delay=pictureBall.totalDuration
    pictureBall.moveXY(3,delay,center[0],ballendy)
    pictureBall.moveAngle(3,delay,0)
    delay=pictureBall.totalDuration+18
  end
  if shakes<4
    picturePoke.moveSE(delay,"Audio/SE/recall")
    pictureBall.moveName(delay,ballopen)
    pictureBall.moveVisible(delay+10,false)
    picturePoke.moveVisible(delay,true)
    picturePoke.moveZoom(15,delay,100)
    picturePoke.moveXY(15,delay,center[0],center[1])
    picturePoke.moveTone(0,delay,Tone.new(248,248,248,248))
    picturePoke.moveTone(24,delay,Tone.new(0,0,0,0))
    delay=picturePoke.totalDuration
  end
  pictureBall.moveXY(0,delay,center[0],ballendy)
  picturePoke.moveOrigin(picturePoke.totalDuration,PictureOrigin::TopLeft)
  picturePoke.moveXY(0,picturePoke.totalDuration,dims[0],dims[1])
  loop do
    pictureBall.update
    picturePoke.update
    setPictureIconSprite(spriteBall,pictureBall)
    setPictureSprite(spritePoke,picturePoke)
    pbGraphicsUpdate
    pbInputUpdate
    break if !pictureBall.running? && !picturePoke.running?
  end
  if shakes<4
     [MENTION=24071]Sprite[/MENTION]s["shadow#{targetBattler}"].visible=oldvisible
    spriteBall.dispose
  else
    spriteBall.tone=Tone.new(-64,-64,-64,128)
    pbSEPlay("balldrop",100,150)
     [MENTION=24071]Sprite[/MENTION]s["capture"]=spriteBall
    spritePoke.visible=false
  end
end



####################################################

class PokeBattle_Scene
  attr_accessor :abortable
  attr_reader :viewport
  attr_reader :sprites
  BLANK      = 0
  MESSAGEBOX = 1
  COMMANDBOX = 2
  FIGHTBOX   = 3

  def initialize
    @battle=nil
    @lastcmd=[0,0,0,0]
    @lastmove=[0,0,0,0]
     [MENTION=28203]pkmn[/MENTION]windows=[nil,nil,nil,nil]
     [MENTION=24071]Sprite[/MENTION]s={}
    @battlestart=true
    @messagemode=false
    @abortable=false
    @aborted=false
  end

  def pbUpdate
    partyAnimationUpdate
     [MENTION=24071]Sprite[/MENTION]s["battlebg"].update if  [MENTION=24071]Sprite[/MENTION]s["battlebg"].respond_to?("update")
  end

  def pbGraphicsUpdate
    partyAnimationUpdate
     [MENTION=24071]Sprite[/MENTION]s["battlebg"].update if  [MENTION=24071]Sprite[/MENTION]s["battlebg"].respond_to?("update")
    Graphics.update
  end

  def pbInputUpdate
    Input.update
    if Input.trigger?(Input::B) && @abortable && !@aborted
      @aborted=true
      @battle.pbAbort
    end
  end

  def pbShowWindow(windowtype)
     [MENTION=24071]Sprite[/MENTION]s["messagebox"].visible = (windowtype==MESSAGEBOX ||
                                      windowtype==COMMANDBOX ||
                                      windowtype==FIGHTBOX ||
                                      windowtype==BLANK )
     [MENTION=24071]Sprite[/MENTION]s["messagewindow"].visible = (windowtype==MESSAGEBOX)
     [MENTION=24071]Sprite[/MENTION]s["commandwindow"].visible = (windowtype==COMMANDBOX)
     [MENTION=24071]Sprite[/MENTION]s["fightwindow"].visible = (windowtype==FIGHTBOX)
  end

  def pbSetMessageMode(mode)
    @messagemode=mode
    msgwindow  [MENTION=24071]Sprite[/MENTION]s["messagewindow"]
    if mode # Within Pokémon command
      msgwindow.baseColor=PokeBattle_SceneConstants::MENUBASECOLOR
      msgwindow.shadowColor=PokeBattle_SceneConstants::MENUSHADOWCOLOR
      msgwindow.opacity=255
      msgwindow.x=16
      msgwindow.width=Graphics.width
      msgwindow.height=96
      msgwindow.y=Graphics.height-msgwindow.height+2
    else
      msgwindow.baseColor=PokeBattle_SceneConstants::MESSAGEBASECOLOR
      msgwindow.shadowColor=PokeBattle_SceneConstants::MESSAGESHADOWCOLOR
      msgwindow.opacity=0
      msgwindow.x=16
      msgwindow.width=Graphics.width-32
      msgwindow.height=96
      msgwindow.y=Graphics.height-msgwindow.height+2
    end
  end

  def pbWaitMessage
    if @briefmessage
      pbShowWindow(MESSAGEBOX)
      cw  [MENTION=24071]Sprite[/MENTION]s["messagewindow"]
      60.times do
        pbGraphicsUpdate
        pbInputUpdate
      end
      cw.text=""
      cw.visible=false
      @briefmessage=false
    end
  end

  def pbDisplay(msg,brief=false)
    pbDisplayMessage(msg,brief)
  end

  def pbDisplayMessage(msg,brief=false)
    pbWaitMessage
    pbRefresh
    pbShowWindow(MESSAGEBOX)
    cw  [MENTION=24071]Sprite[/MENTION]s["messagewindow"]
    cw.text=msg
    i=0
    loop do
      pbGraphicsUpdate
      pbInputUpdate
      cw.update
      if i==40
        cw.text=""
        cw.visible=false
        return
      end
      if Input.trigger?(Input::C) || @abortable
        if cw.pausing?
          pbPlayDecisionSE() if !@abortable
          cw.resume
        end
      end
      if !cw.busy?
        if brief
          @briefmessage=true
          return
        end
        i+=1
      end
    end
  end

  def pbDisplayPausedMessage(msg)
    pbWaitMessage
    pbRefresh
    pbShowWindow(MESSAGEBOX)
    if @messagemode
      @switchscreen.pbDisplay(msg)
      return
    end
    cw  [MENTION=24071]Sprite[/MENTION]s["messagewindow"]
    cw.text=_ISPRINTF("{1:s}\1",msg)
    loop do
      pbGraphicsUpdate
      pbInputUpdate
      if Input.trigger?(Input::C) || @abortable
        if cw.busy?
          pbPlayDecisionSE() if cw.pausing? && !@abortable
          cw.resume
        elsif !inPartyAnimation?
          cw.text=""
          pbPlayDecisionSE()
          cw.visible=false if @messagemode
          return
        end
      end
      cw.update
    end
  end

  def pbDisplayConfirmMessage(msg)
    return pbShowCommands(msg,[_INTL("Yes"),_INTL("No")],1)==0
  end

  def pbShowCommands(msg,commands,defaultValue)
    pbWaitMessage
    pbRefresh
    pbShowWindow(MESSAGEBOX)
    dw  [MENTION=24071]Sprite[/MENTION]s["messagewindow"]
    dw.text=msg
    cw = Window_CommandPokemon.new(commands)
    cw.x=Graphics.width-cw.width
    cw.y=Graphics.height-cw.height-dw.height
    cw.index=0
    cw.viewport=@viewport
    pbRefresh
    loop do
      cw.visible=!dw.busy?
      pbGraphicsUpdate
      pbInputUpdate
      pbFrameUpdate(cw)
      dw.update
      if Input.trigger?(Input::B) && defaultValue>=0
        if dw.busy?
          pbPlayDecisionSE() if dw.pausing?
          dw.resume
        else
          cw.dispose
          dw.text=""
          return defaultValue
        end
      end
      if Input.trigger?(Input::C)
        if dw.busy?
          pbPlayDecisionSE() if dw.pausing?
          dw.resume
        else
          cw.dispose
          dw.text=""
          return cw.index
        end
      end
    end
  end

  def pbFrameUpdate(cw)
    cw.update if cw
    for i in 0...4
      if  [MENTION=24071]Sprite[/MENTION]s["battlebox#{i}"]
         [MENTION=24071]Sprite[/MENTION]s["battlebox#{i}"].update
      end
      if  [MENTION=24071]Sprite[/MENTION]s["pokemon#{i}"]
         [MENTION=24071]Sprite[/MENTION]s["pokemon#{i}"].update
      end
    end
  end

  def pbRefresh
    for i in 0...4
      if  [MENTION=24071]Sprite[/MENTION]s["battlebox#{i}"]
         [MENTION=24071]Sprite[/MENTION]s["battlebox#{i}"].refresh
      end
    end
  end

  def pbAddSprite(id,x,y,filename,viewport)
    sprite=IconSprite.new(x,y,viewport)
    if filename
      sprite.setBitmap(filename) rescue nil
    end
     [MENTION=24071]Sprite[/MENTION]s[id]=sprite
    return sprite
  end

  def pbAddPlane(id,filename,viewport)
    sprite=AnimatedPlane.new(viewport)
    if filename
      sprite.setBitmap(filename)
    end
     [MENTION=24071]Sprite[/MENTION]s[id]=sprite
    return sprite
  end

  def pbDisposeSprites
    pbDisposeSpriteHash  [MENTION=24071]Sprite[/MENTION]s)
  end

  def pbBeginCommandPhase
    # Called whenever a new round begins.
    @battlestart=false
  end

  def pbShowOpponent(index)
    if @battle.opponent
      if @battle.opponent.is_a?(Array)
        trainerfile=pbTrainerSpriteFile(@battle.opponent[index].trainertype)
      else
        trainerfile=pbTrainerSpriteFile(@battle.opponent.trainertype)
      end
    else
      trainerfile="Graphics/Characters/trfront"
    end
    pbAddSprite("trainer",Graphics.width,PokeBattle_SceneConstants::FOETRAINER_Y,
       trainerfile,@viewport)
    if  [MENTION=24071]Sprite[/MENTION]s["trainer"].bitmap
       [MENTION=24071]Sprite[/MENTION]s["trainer"].y-  [MENTION=24071]Sprite[/MENTION]s["trainer"].bitmap.height
       [MENTION=24071]Sprite[/MENTION]s["trainer"].z=8
    end
    20.times do
      pbGraphicsUpdate
      pbInputUpdate
       [MENTION=24071]Sprite[/MENTION]s["trainer"].x-=6
    end
  end

  def pbHideOpponent
    20.times do
      pbGraphicsUpdate
      pbInputUpdate
       [MENTION=24071]Sprite[/MENTION]s["trainer"].x+=6
    end
  end

  def pbShowHelp(text)
     [MENTION=24071]Sprite[/MENTION]s["helpwindow"].resizeToFit(text,Graphics.width)
     [MENTION=24071]Sprite[/MENTION]s["helpwindow"].y=0
     [MENTION=24071]Sprite[/MENTION]s["helpwindow"].x=0
     [MENTION=24071]Sprite[/MENTION]s["helpwindow"].text=text
     [MENTION=24071]Sprite[/MENTION]s["helpwindow"].visible=true
  end

  def pbHideHelp
     [MENTION=24071]Sprite[/MENTION]s["helpwindow"].visible=false
  end

  def pbBackdrop
    [email protected]
    # Choose backdrop
    backdrop="Field"
    if environ==PBEnvironment::Cave
      backdrop="Cave"
    elsif environ==PBEnvironment::MovingWater || environ==PBEnvironment::StillWater
      backdrop="Water"
    elsif environ==PBEnvironment::Underwater
      backdrop="Underwater"
    elsif environ==PBEnvironment::Rock
      backdrop="Mountain"
    else
      if !$game_map || !pbGetMetadata($game_map.map_id,MetadataOutdoor)
        backdrop="IndoorA"
      end
    end
    if $game_map
      back=pbGetMetadata($game_map.map_id,MetadataBattleBack)
      if back && back!=""
        backdrop=back
      end
    end
    if $PokemonGlobal && $PokemonGlobal.nextBattleBack
      backdrop=$PokemonGlobal.nextBattleBack
    end
    # Choose bases
    base=""
    trialname=""
    if environ==PBEnvironment::Grass || environ==PBEnvironment::TallGrass
      trialname="Grass"
    elsif environ==PBEnvironment::Sand
      trialname="Sand"
    elsif $PokemonGlobal.surfing
      trialname="Water"
    end
    if pbResolveBitmap(sprintf("Graphics/Battlebacks/playerbase"+backdrop+trialname))
      base=trialname
    end
    # Choose time of day
    time=""
    trialname=""
    timenow=pbGetTimeNow
    if PBDayNight.isNight?(timenow)
      trialname="Night"
    elsif PBDayNight.isEvening?(timenow)
      trialname="Eve"
    end
    if pbResolveBitmap(sprintf("Graphics/Battlebacks/battlebg"+backdrop+trialname))
      time=trialname
    end
    # Apply graphics
    battlebg="Graphics/Battlebacks/battlebg"+backdrop+time
    enemybase="Graphics/Battlebacks/enemybase"+backdrop+base+time
    playerbase="Graphics/Battlebacks/playerbase"+backdrop+base+time
    pbAddPlane("battlebg",battlebg,@viewport)
    pbAddSprite("playerbase",
       PokeBattle_SceneConstants::PLAYERBASEX,
       PokeBattle_SceneConstants::PLAYERBASEY,playerbase,@viewport)
     [MENTION=24071]Sprite[/MENTION]s["playerbase"].x-  [MENTION=24071]Sprite[/MENTION]s["playerbase"].bitmap.width/2 if  [MENTION=24071]Sprite[/MENTION]s["playerbase"].bitmap!=nil
     [MENTION=24071]Sprite[/MENTION]s["playerbase"].y-  [MENTION=24071]Sprite[/MENTION]s["playerbase"].bitmap.height if  [MENTION=24071]Sprite[/MENTION]s["playerbase"].bitmap!=nil
    pbAddSprite("enemybase",
       PokeBattle_SceneConstants::FOEBASEX,
       PokeBattle_SceneConstants::FOEBASEY,enemybase,@viewport)
     [MENTION=24071]Sprite[/MENTION]s["enemybase"].x-  [MENTION=24071]Sprite[/MENTION]s["enemybase"].bitmap.width/2 if  [MENTION=24071]Sprite[/MENTION]s["enemybase"].bitmap!=nil
     [MENTION=24071]Sprite[/MENTION]s["enemybase"].y-  [MENTION=24071]Sprite[/MENTION]s["enemybase"].bitmap.height/2 if  [MENTION=24071]Sprite[/MENTION]s["enemybase"].bitmap!=nil
     [MENTION=24071]Sprite[/MENTION]s["battlebg"].z=0
     [MENTION=24071]Sprite[/MENTION]s["playerbase"].z=1
     [MENTION=24071]Sprite[/MENTION]s["enemybase"].z=1
  end

  # Returns whether the party line-ups are currently appearing on-screen
  def inPartyAnimation?
    return @enablePartyAnim && @partyAnimPhase<3
  end

  # Shows the party line-ups appearing on-screen
  def partyAnimationUpdate
    return if !inPartyAnimation?
    ballmovedist=16 # How far a ball moves each frame
    # Bar slides on
    if @partyAnimPhase==0
       [MENTION=24071]Sprite[/MENTION]s["partybarfoe"].x+=16
       [MENTION=24071]Sprite[/MENTION]s["partybarplayer"].x-=16
      if  [MENTION=24071]Sprite[/MENTION]s["partybarfoe"].x  [MENTION=24071]Sprite[/MENTION]s["partybarfoe"].bitmap.width>=PokeBattle_SceneConstants::FOEPARTYBAR_X
         [MENTION=24071]Sprite[/MENTION]s["partybarfoe"].x=PokeBattle_SceneConstants::FOEPARTYBAR_X  [MENTION=24071]Sprite[/MENTION]s["partybarfoe"].bitmap.width
         [MENTION=24071]Sprite[/MENTION]s["partybarplayer"].x=PokeBattle_SceneConstants::PLAYERPARTYBAR_X
        @partyAnimPhase=1
      end
      return
    end
    # Set up all balls ready to slide on
    if @partyAnimPhase==1
      @xposplayer=PokeBattle_SceneConstants::PLAYERPARTYBALL1_X
      counter=0
      # Make sure the ball starts off-screen
      while @xposplayer<Graphics.width
        counter+=1; @xposplayer+=ballmovedist
      end
      @xposenemy=PokeBattle_SceneConstants::FOEPARTYBALL1_X-counter*ballmovedist
      for i in 0...6
        # Choose the ball's graphic (player's side)
        ballgraphic="Graphics/Pictures/ballempty"
        if i<@battle.party1.length && @battle.party1[i]
          if @battle.party1[i].hp<=0 || @battle.party1[i].egg?
            ballgraphic="Graphics/Pictures/ballfainted"
          elsif @battle.party1[i].status>0
            ballgraphic="Graphics/Pictures/ballstatus"
          else
            ballgraphic="Graphics/Pictures/ballnormal"
          end
        end
        pbAddSprite("player#{i}",
           @xposplayer+i*ballmovedist*6,PokeBattle_SceneConstants::PLAYERPARTYBALL1_Y,
           ballgraphic,@viewport)
         [MENTION=24071]Sprite[/MENTION]s["player#{i}"].z=41
        # Choose the ball's graphic (opponent's side)
        ballgraphic="Graphics/Pictures/ballempty"
        if i<@battle.party2.length && @battle.party2[i]
          if @battle.party2[i].hp<=0 || @battle.party2[i].egg?
            ballgraphic="Graphics/Pictures/ballfainted"
          elsif @battle.party2[i].status>0
            ballgraphic="Graphics/Pictures/ballstatus"
          else
            ballgraphic="Graphics/Pictures/ballnormal"
          end
        end
        pbAddSprite("enemy#{i}",
           @xposenemy-i*ballmovedist*6,PokeBattle_SceneConstants::FOEPARTYBALL1_Y,
           ballgraphic,@viewport)
         [MENTION=24071]Sprite[/MENTION]s["enemy#{i}"].z=41
      end
      @partyAnimPhase=2
    end
    # Balls slide on
    if @partyAnimPhase==2
      for i in 0...6
        if  [MENTION=24071]Sprite[/MENTION]s["enemy#{i}"].x<PokeBattle_SceneConstants::FOEPARTYBALL1_X-i*PokeBattle_SceneConstants::FOEPARTYBALL_GAP
           [MENTION=24071]Sprite[/MENTION]s["enemy#{i}"].x+=ballmovedist
           [MENTION=24071]Sprite[/MENTION]s["player#{i}"].x-=ballmovedist
          if  [MENTION=24071]Sprite[/MENTION]s["enemy#{i}"].x>=PokeBattle_SceneConstants::FOEPARTYBALL1_X-i*PokeBattle_SceneConstants::FOEPARTYBALL_GAP
             [MENTION=24071]Sprite[/MENTION]s["enemy#{i}"].x=PokeBattle_SceneConstants::FOEPARTYBALL1_X-i*PokeBattle_SceneConstants::FOEPARTYBALL_GAP
             [MENTION=24071]Sprite[/MENTION]s["player#{i}"].x=PokeBattle_SceneConstants::PLAYERPARTYBALL1_X+i*PokeBattle_SceneConstants::PLAYERPARTYBALL_GAP
            if i==5
              @partyAnimPhase=3
            end
          end
        end
      end
    end
  end

  def pbStartBattle(battle)
    # Called whenever the battle begins
    @battle=battle
    @lastcmd=[0,0,0,0]
    @lastmove=[0,0,0,0]
    @showingplayer=true
    @showingenemy=true
     [MENTION=24071]Sprite[/MENTION]s.clear
    @viewport=Viewport.new(0,Graphics.height/2,Graphics.width,0)
    @viewport.z=99999
     [MENTION=20076]trainer[/MENTION]yoffset=(Graphics.height-320) # Adjust player's side for screen size
    @foeyoffset=  [MENTION=20076]trainer[/MENTION]yoffset*3/4).floor  # Adjust foe's side for screen size
    pbBackdrop
    pbAddSprite("partybarfoe",
       PokeBattle_SceneConstants::FOEPARTYBAR_X,
       PokeBattle_SceneConstants::FOEPARTYBAR_Y,
       "Graphics/Pictures/battleLineup",@viewport)
    pbAddSprite("partybarplayer",
       PokeBattle_SceneConstants::PLAYERPARTYBAR_X,
       PokeBattle_SceneConstants::PLAYERPARTYBAR_Y,
       "Graphics/Pictures/battleLineup",@viewport)
     [MENTION=24071]Sprite[/MENTION]s["partybarfoe"].x-  [MENTION=24071]Sprite[/MENTION]s["partybarfoe"].bitmap.width
     [MENTION=24071]Sprite[/MENTION]s["partybarplayer"].mirror=true
     [MENTION=24071]Sprite[/MENTION]s["partybarfoe"].z=40
     [MENTION=24071]Sprite[/MENTION]s["partybarplayer"].z=40
     [MENTION=24071]Sprite[/MENTION]s["partybarfoe"].visible=false
     [MENTION=24071]Sprite[/MENTION]s["partybarplayer"].visible=false
    if @battle.player.is_a?(Array)
      trainerfile=pbPlayerSpriteBackFile(@battle.player[0].trainertype)
      pbAddSprite("player",
           PokeBattle_SceneConstants::PLAYERTRAINERD1_X,
           PokeBattle_SceneConstants::PLAYERTRAINERD1_Y,trainerfile,@viewport)
      trainerfile=pbTrainerSpriteBackFile(@battle.player[1].trainertype)
      pbAddSprite("playerB",
           PokeBattle_SceneConstants::PLAYERTRAINERD2_X,
           PokeBattle_SceneConstants::PLAYERTRAINERD2_Y,trainerfile,@viewport)
      if  [MENTION=24071]Sprite[/MENTION]s["player"].bitmap
        if  [MENTION=24071]Sprite[/MENTION]s["player"].bitmap.width  [MENTION=24071]Sprite[/MENTION]s["player"].bitmap.height
           [MENTION=24071]Sprite[/MENTION]s["player"].src_rect.x=0
           [MENTION=24071]Sprite[/MENTION]s["player"].src_rect.width  [MENTION=24071]Sprite[/MENTION]s["player"].bitmap.width/5
        end
         [MENTION=24071]Sprite[/MENTION]s["player"].x-=  [MENTION=24071]Sprite[/MENTION]s["player"].src_rect.width/2)
         [MENTION=24071]Sprite[/MENTION]s["player"].y-  [MENTION=24071]Sprite[/MENTION]s["player"].bitmap.height
         [MENTION=24071]Sprite[/MENTION]s["player"].z=30
      end
      if  [MENTION=24071]Sprite[/MENTION]s["playerB"].bitmap
        if  [MENTION=24071]Sprite[/MENTION]s["playerB"].bitmap.width  [MENTION=24071]Sprite[/MENTION]s["playerB"].bitmap.height
           [MENTION=24071]Sprite[/MENTION]s["playerB"].src_rect.x=0
           [MENTION=24071]Sprite[/MENTION]s["playerB"].src_rect.width  [MENTION=24071]Sprite[/MENTION]s["playerB"].bitmap.width/5
        end
         [MENTION=24071]Sprite[/MENTION]s["playerB"].x-=  [MENTION=24071]Sprite[/MENTION]s["playerB"].src_rect.width/2)
         [MENTION=24071]Sprite[/MENTION]s["playerB"].y-  [MENTION=24071]Sprite[/MENTION]s["playerB"].bitmap.height
         [MENTION=24071]Sprite[/MENTION]s["playerB"].z=31
      end
    else
      trainerfile=pbPlayerSpriteBackFile(@battle.player.trainertype)
      pbAddSprite("player",
           PokeBattle_SceneConstants::PLAYERTRAINER_X,
           PokeBattle_SceneConstants::PLAYERTRAINER_Y,trainerfile,@viewport)
      if  [MENTION=24071]Sprite[/MENTION]s["player"].bitmap
        if  [MENTION=24071]Sprite[/MENTION]s["player"].bitmap.width  [MENTION=24071]Sprite[/MENTION]s["player"].bitmap.height
           [MENTION=24071]Sprite[/MENTION]s["player"].src_rect.x=0
           [MENTION=24071]Sprite[/MENTION]s["player"].src_rect.width  [MENTION=24071]Sprite[/MENTION]s["player"].bitmap.width/5
        end
         [MENTION=24071]Sprite[/MENTION]s["player"].x-=  [MENTION=24071]Sprite[/MENTION]s["player"].src_rect.width/2)
         [MENTION=24071]Sprite[/MENTION]s["player"].y-  [MENTION=24071]Sprite[/MENTION]s["player"].bitmap.height
         [MENTION=24071]Sprite[/MENTION]s["player"].z=30
      end
    end
    if @battle.opponent
      if @battle.opponent.is_a?(Array)
        trainerfile=pbTrainerSpriteFile(@battle.opponent[1].trainertype)
        pbAddSprite("trainer2",
           PokeBattle_SceneConstants::FOETRAINERD2_X,
           PokeBattle_SceneConstants::FOETRAINERD2_Y,trainerfile,@viewport)
        trainerfile=pbTrainerSpriteFile(@battle.opponent[0].trainertype)
        pbAddSprite("trainer",
           PokeBattle_SceneConstants::FOETRAINERD1_X,
           PokeBattle_SceneConstants::FOETRAINERD1_Y,trainerfile,@viewport)
      else
        trainerfile=pbTrainerSpriteFile(@battle.opponent.trainertype)
        pbAddSprite("trainer",
           PokeBattle_SceneConstants::FOETRAINER_X,
           PokeBattle_SceneConstants::FOETRAINER_Y,trainerfile,@viewport)
      end
    else
      trainerfile="Graphics/Characters/trfront"
      pbAddSprite("trainer",
           PokeBattle_SceneConstants::FOETRAINER_X,
           PokeBattle_SceneConstants::FOETRAINER_Y,trainerfile,@viewport)
    end
    if  [MENTION=24071]Sprite[/MENTION]s["trainer"].bitmap
       [MENTION=24071]Sprite[/MENTION]s["trainer"].x-=  [MENTION=24071]Sprite[/MENTION]s["trainer"].bitmap.width/2)
       [MENTION=24071]Sprite[/MENTION]s["trainer"].y-  [MENTION=24071]Sprite[/MENTION]s["trainer"].bitmap.height
       [MENTION=24071]Sprite[/MENTION]s["trainer"].z=8
    end
    if  [MENTION=24071]Sprite[/MENTION]s["trainer2"] &&  [MENTION=24071]Sprite[/MENTION]s["trainer2"].bitmap
       [MENTION=24071]Sprite[/MENTION]s["trainer2"].x-=  [MENTION=24071]Sprite[/MENTION]s["trainer2"].bitmap.width/2)
       [MENTION=24071]Sprite[/MENTION]s["trainer2"].y-  [MENTION=24071]Sprite[/MENTION]s["trainer2"].bitmap.height
       [MENTION=24071]Sprite[/MENTION]s["trainer2"].z=7
    end
     [MENTION=24071]Sprite[/MENTION]s["shadow0"]=IconSprite.new(0,0,@viewport)
     [MENTION=24071]Sprite[/MENTION]s["shadow0"].z=3
    pbAddSprite("shadow1",0,0,"Graphics/Pictures/battleShadow",@viewport)
     [MENTION=24071]Sprite[/MENTION]s["shadow1"].z=3
     [MENTION=24071]Sprite[/MENTION]s["shadow1"].visible=false
     [MENTION=24071]Sprite[/MENTION]s["pokemon0"]=PokemonBattlerSprite.new(battle.doublebattle,0,@viewport)
     [MENTION=24071]Sprite[/MENTION]s["pokemon0"].z=21
     [MENTION=24071]Sprite[/MENTION]s["pokemon1"]=PokemonBattlerSprite.new(battle.doublebattle,1,@viewport)
     [MENTION=24071]Sprite[/MENTION]s["pokemon1"].z=16
    if battle.doublebattle
       [MENTION=24071]Sprite[/MENTION]s["shadow2"]=IconSprite.new(0,0,@viewport)
       [MENTION=24071]Sprite[/MENTION]s["shadow2"].z=3
      pbAddSprite("shadow3",0,0,"Graphics/Pictures/battleShadow",@viewport)
       [MENTION=24071]Sprite[/MENTION]s["shadow3"].z=3
       [MENTION=24071]Sprite[/MENTION]s["shadow3"].visible=false
       [MENTION=24071]Sprite[/MENTION]s["pokemon2"]=PokemonBattlerSprite.new(battle.doublebattle,2,@viewport)
       [MENTION=24071]Sprite[/MENTION]s["pokemon2"].z=26
       [MENTION=24071]Sprite[/MENTION]s["pokemon3"]=PokemonBattlerSprite.new(battle.doublebattle,3,@viewport)
       [MENTION=24071]Sprite[/MENTION]s["pokemon3"].z=11
    end
     [MENTION=24071]Sprite[/MENTION]s["battlebox0"]=PokemonDataBox.new(battle.battlers[0],battle.doublebattle,@viewport)
     [MENTION=24071]Sprite[/MENTION]s["battlebox1"]=PokemonDataBox.new(battle.battlers[1],battle.doublebattle,@viewport)
    if battle.doublebattle
       [MENTION=24071]Sprite[/MENTION]s["battlebox2"]=PokemonDataBox.new(battle.battlers[2],battle.doublebattle,@viewport)
       [MENTION=24071]Sprite[/MENTION]s["battlebox3"]=PokemonDataBox.new(battle.battlers[3],battle.doublebattle,@viewport)
    end
    pbAddSprite("messagebox",0,Graphics.height-96,"Graphics/Pictures/battleMessage",@viewport)
     [MENTION=24071]Sprite[/MENTION]s["messagebox"].z=90
     [MENTION=24071]Sprite[/MENTION]s["helpwindow"]=Window_UnformattedTextPokemon.newWithSize("",0,0,32,32,@viewport)
     [MENTION=24071]Sprite[/MENTION]s["helpwindow"].visible=false
     [MENTION=24071]Sprite[/MENTION]s["helpwindow"].z=90
     [MENTION=24071]Sprite[/MENTION]s["messagewindow"]=Window_AdvancedTextPokemon.new("")
     [MENTION=24071]Sprite[/MENTION]s["messagewindow"].letterbyletter=true
     [MENTION=24071]Sprite[/MENTION]s["messagewindow"].viewport=@viewport
     [MENTION=24071]Sprite[/MENTION]s["messagewindow"].z=100
     [MENTION=24071]Sprite[/MENTION]s["commandwindow"]=CommandMenuDisplay.new(@viewport)
     [MENTION=24071]Sprite[/MENTION]s["commandwindow"].z=100
     [MENTION=24071]Sprite[/MENTION]s["fightwindow"]=FightMenuDisplay.new(nil,@viewport)
     [MENTION=24071]Sprite[/MENTION]s["fightwindow"].z=100
    pbShowWindow(MESSAGEBOX)
    pbSetMessageMode(false)
    trainersprite1  [MENTION=24071]Sprite[/MENTION]s["trainer"]
    trainersprite2  [MENTION=24071]Sprite[/MENTION]s["trainer2"]
    if [email protected]
       [MENTION=24071]Sprite[/MENTION]s["trainer"].visible=false
      if @battle.party2.length>=1
        if @battle.party2.length==1
          [email protected][0].species
           [MENTION=24071]Sprite[/MENTION]s["pokemon1"].setPokemonBitmap(@battle.party2[0],false)
           [MENTION=24071]Sprite[/MENTION]s["pokemon1"].tone=Tone.new(-128,-128,-128,-128)
           [MENTION=24071]Sprite[/MENTION]s["pokemon1"].x=PokeBattle_SceneConstants::FOEBATTLER_X
           [MENTION=24071]Sprite[/MENTION]s["pokemon1"].x-  [MENTION=24071]Sprite[/MENTION]s["pokemon1"].width/2
           [MENTION=24071]Sprite[/MENTION]s["pokemon1"].y=PokeBattle_SceneConstants::FOEBATTLER_Y
           [MENTION=24071]Sprite[/MENTION]s["pokemon1"].y+=adjustBattleSpriteY  [MENTION=24071]Sprite[/MENTION]s["pokemon1"],species,1)
           [MENTION=24071]Sprite[/MENTION]s["pokemon1"].visible=true
           [MENTION=24071]Sprite[/MENTION]s["shadow1"].x=PokeBattle_SceneConstants::FOEBATTLER_X
           [MENTION=24071]Sprite[/MENTION]s["shadow1"].y=PokeBattle_SceneConstants::FOEBATTLER_Y
           [MENTION=24071]Sprite[/MENTION]s["shadow1"].x-  [MENTION=24071]Sprite[/MENTION]s["shadow1"].bitmap.width/2 if  [MENTION=24071]Sprite[/MENTION]s["shadow1"].bitmap!=nil
           [MENTION=24071]Sprite[/MENTION]s["shadow1"].y-  [MENTION=24071]Sprite[/MENTION]s["shadow1"].bitmap.height/2 if  [MENTION=24071]Sprite[/MENTION]s["shadow1"].bitmap!=nil
           [MENTION=24071]Sprite[/MENTION]s["shadow1"].visible=showShadow?(species)
          trainersprite1  [MENTION=24071]Sprite[/MENTION]s["pokemon1"]
        elsif @battle.party2.length==2
          [email protected][0].species
           [MENTION=24071]Sprite[/MENTION]s["pokemon1"].setPokemonBitmap(@battle.party2[0],false)
           [MENTION=24071]Sprite[/MENTION]s["pokemon1"].tone=Tone.new(-128,-128,-128,-128)
           [MENTION=24071]Sprite[/MENTION]s["pokemon1"].x=PokeBattle_SceneConstants::FOEBATTLERD1_X
           [MENTION=24071]Sprite[/MENTION]s["pokemon1"].x-  [MENTION=24071]Sprite[/MENTION]s["pokemon1"].width/2
           [MENTION=24071]Sprite[/MENTION]s["pokemon1"].y=PokeBattle_SceneConstants::FOEBATTLERD1_Y
           [MENTION=24071]Sprite[/MENTION]s["pokemon1"].y+=adjustBattleSpriteY  [MENTION=24071]Sprite[/MENTION]s["pokemon1"],species,1)
           [MENTION=24071]Sprite[/MENTION]s["pokemon1"].visible=true
           [MENTION=24071]Sprite[/MENTION]s["shadow1"].x=PokeBattle_SceneConstants::FOEBATTLERD1_X
           [MENTION=24071]Sprite[/MENTION]s["shadow1"].y=PokeBattle_SceneConstants::FOEBATTLERD1_Y
           [MENTION=24071]Sprite[/MENTION]s["shadow1"].x-  [MENTION=24071]Sprite[/MENTION]s["shadow1"].bitmap.width/2 if  [MENTION=24071]Sprite[/MENTION]s["shadow1"].bitmap!=nil
           [MENTION=24071]Sprite[/MENTION]s["shadow1"].y-  [MENTION=24071]Sprite[/MENTION]s["shadow1"].bitmap.height/2 if  [MENTION=24071]Sprite[/MENTION]s["shadow1"].bitmap!=nil
           [MENTION=24071]Sprite[/MENTION]s["shadow1"].visible=showShadow?(species)
          trainersprite1  [MENTION=24071]Sprite[/MENTION]s["pokemon1"]
          [email protected][1].species
           [MENTION=24071]Sprite[/MENTION]s["pokemon3"].setPokemonBitmap(@battle.party2[1],false)
           [MENTION=24071]Sprite[/MENTION]s["pokemon3"].tone=Tone.new(-128,-128,-128,-128)
           [MENTION=24071]Sprite[/MENTION]s["pokemon3"].x=PokeBattle_SceneConstants::FOEBATTLERD2_X
           [MENTION=24071]Sprite[/MENTION]s["pokemon3"].x-  [MENTION=24071]Sprite[/MENTION]s["pokemon3"].width/2
           [MENTION=24071]Sprite[/MENTION]s["pokemon3"].y=PokeBattle_SceneConstants::FOEBATTLERD2_Y
           [MENTION=24071]Sprite[/MENTION]s["pokemon3"].y+=adjustBattleSpriteY  [MENTION=24071]Sprite[/MENTION]s["pokemon3"],species,3)
           [MENTION=24071]Sprite[/MENTION]s["pokemon3"].visible=true
           [MENTION=24071]Sprite[/MENTION]s["shadow3"].x=PokeBattle_SceneConstants::FOEBATTLERD2_X
           [MENTION=24071]Sprite[/MENTION]s["shadow3"].y=PokeBattle_SceneConstants::FOEBATTLERD2_Y
           [MENTION=24071]Sprite[/MENTION]s["shadow3"].x-  [MENTION=24071]Sprite[/MENTION]s["shadow3"].bitmap.width/2 if  [MENTION=24071]Sprite[/MENTION]s["shadow3"].bitmap!=nil
           [MENTION=24071]Sprite[/MENTION]s["shadow3"].y-  [MENTION=24071]Sprite[/MENTION]s["shadow3"].bitmap.height/2 if  [MENTION=24071]Sprite[/MENTION]s["shadow3"].bitmap!=nil
           [MENTION=24071]Sprite[/MENTION]s["shadow3"].visible=showShadow?(species)
          trainersprite2  [MENTION=24071]Sprite[/MENTION]s["pokemon3"]
        end
      end
    end
    #################
    # Move trainers/bases/etc. off-screen
     [MENTION=24071]Sprite[/MENTION]s["playerbase"].x+=Graphics.width
     [MENTION=24071]Sprite[/MENTION]s["player"].x+=Graphics.width
     [MENTION=24071]Sprite[/MENTION]s["playerB"].x+=Graphics.width if  [MENTION=24071]Sprite[/MENTION]s["playerB"]
     [MENTION=24071]Sprite[/MENTION]s["enemybase"].x-=Graphics.width
    trainersprite1.x-=Graphics.width
    trainersprite2.x-=Graphics.width if trainersprite2
     [MENTION=24071]Sprite[/MENTION]s["shadow1"].x-=Graphics.width
     [MENTION=24071]Sprite[/MENTION]s["shadow3"].x-=Graphics.width if  [MENTION=24071]Sprite[/MENTION]s["shadow3"]
     [MENTION=24071]Sprite[/MENTION]s["partybarfoe"].x-=PokeBattle_SceneConstants::FOEPARTYBAR_X
     [MENTION=24071]Sprite[/MENTION]s["partybarplayer"].x+=Graphics.width-PokeBattle_SceneConstants::PLAYERPARTYBAR_X
    #################
    appearspeed=8
    (Graphics.width/appearspeed).times do
      if @viewport.rect.y>0
        @viewport.rect.y-=4
        @viewport.rect.y=0 if @viewport.rect.y<0
        @viewport.rect.height+=8
        @viewport.rect.height=Graphics.height if @viewport.rect.height>Graphics.height
      end
      for i in  [MENTION=24071]Sprite[/MENTION]s
        i[1][email protected]
        i[1][email protected]
      end
       [MENTION=24071]Sprite[/MENTION]s["playerbase"].x-=appearspeed
       [MENTION=24071]Sprite[/MENTION]s["player"].x-=appearspeed
       [MENTION=24071]Sprite[/MENTION]s["playerB"].x-=appearspeed  if  [MENTION=24071]Sprite[/MENTION]s["playerB"]
       [MENTION=24071]Sprite[/MENTION]s["enemybase"].x+=appearspeed
      trainersprite1.x+=appearspeed
      trainersprite2.x+=appearspeed if trainersprite2
       [MENTION=24071]Sprite[/MENTION]s["shadow1"].x+=appearspeed
       [MENTION=24071]Sprite[/MENTION]s["shadow3"].x+=appearspeed if  [MENTION=24071]Sprite[/MENTION]s["shadow3"]
      pbGraphicsUpdate
      pbInputUpdate
    end
    # Play cry for wild Pokémon
    if [email protected]
      pbPlayCry(@battle.party2[0])
    end
    if @battle.opponent
      @enablePartyAnim=true
      @partyAnimPhase=0
       [MENTION=24071]Sprite[/MENTION]s["partybarfoe"].visible=true
       [MENTION=24071]Sprite[/MENTION]s["partybarplayer"].visible=true
    else
       [MENTION=24071]Sprite[/MENTION]s["battlebox1"].appear
       [MENTION=24071]Sprite[/MENTION]s["battlebox3"].appear if @battle.party2.length==2 
      appearing=true
      begin
        pbGraphicsUpdate
        pbInputUpdate
         [MENTION=24071]Sprite[/MENTION]s["battlebox1"].update
         [MENTION=24071]Sprite[/MENTION]s["pokemon1"].tone.red+=8 if  [MENTION=24071]Sprite[/MENTION]s["pokemon1"].tone.red<0
         [MENTION=24071]Sprite[/MENTION]s["pokemon1"].tone.blue+=8 if  [MENTION=24071]Sprite[/MENTION]s["pokemon1"].tone.blue<0
         [MENTION=24071]Sprite[/MENTION]s["pokemon1"].tone.green+=8 if  [MENTION=24071]Sprite[/MENTION]s["pokemon1"].tone.green<0
         [MENTION=24071]Sprite[/MENTION]s["pokemon1"].tone.gray+=8 if  [MENTION=24071]Sprite[/MENTION]s["pokemon1"].tone.gray<0
        appearing  [MENTION=24071]Sprite[/MENTION]s["battlebox1"].appearing
        if @battle.party2.length==2 
           [MENTION=24071]Sprite[/MENTION]s["battlebox3"].update
           [MENTION=24071]Sprite[/MENTION]s["pokemon3"].tone.red+=8 if  [MENTION=24071]Sprite[/MENTION]s["pokemon3"].tone.red<0
           [MENTION=24071]Sprite[/MENTION]s["pokemon3"].tone.blue+=8 if  [MENTION=24071]Sprite[/MENTION]s["pokemon3"].tone.blue<0
           [MENTION=24071]Sprite[/MENTION]s["pokemon3"].tone.green+=8 if  [MENTION=24071]Sprite[/MENTION]s["pokemon3"].tone.green<0
           [MENTION=24071]Sprite[/MENTION]s["pokemon3"].tone.gray+=8 if  [MENTION=24071]Sprite[/MENTION]s["pokemon3"].tone.gray<0
          appearing=(appearing ||  [MENTION=24071]Sprite[/MENTION]s["battlebox3"].appearing)
        end
      end while appearing
      # Show shiny animation for wild Pokémon
      if @battle.party2[0].isShiny? && @battle.battlescene
        pbCommonAnimation("Shiny",@battle.battlers[1],nil)
      end
      if @battle.party2.length==2
        if @battle.party2[1].isShiny? && @battle.battlescene
          pbCommonAnimation("Shiny",@battle.battlers[3],nil)
        end
      end
    end
  end

  def pbEndBattle(result)
    @abortable=false
    pbShowWindow(BLANK)
    # Fade out all sprites
    pbBGMFade(1.0)
    pbFadeOutAndHide  [MENTION=24071]Sprite[/MENTION]s)
    pbDisposeSprites
  end

  def pbRecall(battlerindex)
    @briefmessage=false
    if @battle.pbIsOpposing?(battlerindex)
      origin=PokeBattle_SceneConstants::FOEBATTLER_Y
      if @battle.doublebattle
        origin=PokeBattle_SceneConstants::FOEBATTLERD1_Y if battlerindex==1
        origin=PokeBattle_SceneConstants::FOEBATTLERD2_Y if battlerindex==3
      end
       [MENTION=24071]Sprite[/MENTION]s["shadow#{battlerindex}"].visible=false
    else
      origin=PokeBattle_SceneConstants::PLAYERBATTLER_Y
      if @battle.doublebattle
        origin=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y if battlerindex==0
        origin=PokeBattle_SceneConstants::PLAYERBATTLERD2_Y if battlerindex==2
      end
    end
    spritePoke  [MENTION=24071]Sprite[/MENTION]s["pokemon#{battlerindex}"]
    picturePoke=PictureEx.new(spritePoke.z)
    dims=[spritePoke.x,spritePoke.y]
    center=getSpriteCenter(spritePoke)
    # starting positions
    picturePoke.moveVisible(1,true)
    picturePoke.moveOrigin(1,PictureOrigin::Center)
    picturePoke.moveXY(0,1,center[0],center[1])
    # directives
#    picturePoke.moveTone(10,1,Tone.new(0,-224,-224,0))
    picturePoke.moveTone(10,1,Tone.new(248,248,248,248))
    delay=picturePoke.totalDuration
    picturePoke.moveSE(delay,"Audio/SE/recall")
    picturePoke.moveZoom(15,delay,0)
    picturePoke.moveXY(15,delay,center[0],origin)
    picturePoke.moveVisible(picturePoke.totalDuration,false)
    picturePoke.moveTone(0,picturePoke.totalDuration,Tone.new(0,0,0,0))
    picturePoke.moveOrigin(picturePoke.totalDuration,PictureOrigin::TopLeft)
    loop do
      picturePoke.update
      setPictureSprite(spritePoke,picturePoke)
      pbGraphicsUpdate
      pbInputUpdate
      break if !picturePoke.running?
    end
  end

  def pbTrainerSendOut(battlerindex,pkmn)
    @briefmessage=false
    fadeanim=nil
    while inPartyAnimation?; end
    if @showingenemy
      fadeanim=TrainerFadeAnimation.new  [MENTION=24071]Sprite[/MENTION]s)
    end
    frame=0
     [MENTION=24071]Sprite[/MENTION]s["pokemon#{battlerindex}"].setPokemonBitmap(pkmn,false)
    sendout=PokeballSendOutAnimation.new  [MENTION=24071]Sprite[/MENTION]s["pokemon#{battlerindex}"],
        [MENTION=24071]Sprite[/MENTION]s,@battle.battlers[battlerindex],@battle.doublebattle)
    loop do
      pbGraphicsUpdate
      pbInputUpdate
      fadeanim.update if fadeanim
      frame+=1    
      if frame==1
         [MENTION=24071]Sprite[/MENTION]s["battlebox#{battlerindex}"].appear
      end
      if frame>=10
        sendout.update
      end
       [MENTION=24071]Sprite[/MENTION]s["battlebox#{battlerindex}"].update
      break if (!fadeanim || fadeanim.animdone?) && sendout.animdone? &&
           [MENTION=24071]Sprite[/MENTION]s["battlebox#{battlerindex}"].appearing
    end
    if @battle.battlers[battlerindex].pokemon.isShiny? && @battle.battlescene
      pbCommonAnimation("Shiny",@battle.battlers[battlerindex],nil)
    end
    sendout.dispose
    if @showingenemy
      @showingenemy=false
      pbDisposeSprite  [MENTION=24071]Sprite[/MENTION]s,"trainer")
      pbDisposeSprite  [MENTION=24071]Sprite[/MENTION]s,"partybarfoe")
      for i in 0...6
        pbDisposeSprite  [MENTION=24071]Sprite[/MENTION]s,"enemy#{i}")
      end
    end
    pbRefresh
  end

  def pbSendOut(battlerindex,pkmn) # Player sending out Pokémon
    while inPartyAnimation?; end
    balltype=pkmn.ballused
    ballbitmap=sprintf("Graphics/Pictures/ball%02d",balltype)
    pictureBall=PictureEx.new(32)
    delay=1
    pictureBall.moveVisible(delay,true)
    pictureBall.moveName(delay,ballbitmap)
    pictureBall.moveOrigin(delay,PictureOrigin::Center)
    # Setting the ball's movement path
    path=[[0,   146], [10,  134], [21,  122], [30,  112], 
          [39,  104], [46,   99], [53,   95], [61,   93], 
          [68,   93], [75,   96], [82,  102], [89,  111], 
          [94,  121], [100, 134], [106, 150], [111, 166], 
          [116, 183], [120, 199], [124, 216], [127, 238]]
    spriteBall=IconSprite.new(0,0,@viewport)
    spriteBall.visible=false
    angle=0
    multiplier=1.0
    if @battle.doublebattle
      multiplier=(battlerindex==0) ? 0.7 : 1.3
    end
    for coord in path
      delay=pictureBall.totalDuration
      pictureBall.moveAngle(0,delay,angle)
      pictureBall.moveXY(1,delay,coord[0]*multiplier,coord[1])
      angle+=40
      angle%=360
    end
    pictureBall.adjustPosition(0  [MENTION=20076]trainer[/MENTION]yoffset)
     [MENTION=24071]Sprite[/MENTION]s["battlebox#{battlerindex}"].visible=false
    @briefmessage=false
    fadeanim=nil
    if @showingplayer
      fadeanim=PlayerFadeAnimation.new  [MENTION=24071]Sprite[/MENTION]s)
    end
    frame=0
     [MENTION=24071]Sprite[/MENTION]s["pokemon#{battlerindex}"].setPokemonBitmap(pkmn,true)
    sendout=PokeballPlayerSendOutAnimation.new  [MENTION=24071]Sprite[/MENTION]s["pokemon#{battlerindex}"],
        [MENTION=24071]Sprite[/MENTION]s,@battle.battlers[battlerindex],@battle.doublebattle)
    loop do
      fadeanim.update if fadeanim
      frame+=1
      if frame>1 && !pictureBall.running? &&   [MENTION=24071]Sprite[/MENTION]s["battlebox#{battlerindex}"].appearing
         [MENTION=24071]Sprite[/MENTION]s["battlebox#{battlerindex}"].appear
      end
      if frame>=3 && !pictureBall.running?
        sendout.update
      end
      if (frame>=10 || !fadeanim) && pictureBall.running?
        pictureBall.update
        setPictureIconSprite(spriteBall,pictureBall)
      end
       [MENTION=24071]Sprite[/MENTION]s["battlebox#{battlerindex}"].update
      pbGraphicsUpdate
      pbInputUpdate
      break if (!fadeanim || fadeanim.animdone?) && sendout.animdone? &&
           [MENTION=24071]Sprite[/MENTION]s["battlebox#{battlerindex}"].appearing
    end
    spriteBall.dispose
    sendout.dispose
    if @battle.battlers[battlerindex].pokemon.isShiny? && @battle.battlescene
      pbCommonAnimation("Shiny",@battle.battlers[battlerindex],nil)
    end
    if @showingplayer
      @showingplayer=false
      pbDisposeSprite  [MENTION=24071]Sprite[/MENTION]s,"player")
      pbDisposeSprite  [MENTION=24071]Sprite[/MENTION]s,"partybarplayer")
      for i in 0...6
        pbDisposeSprite  [MENTION=24071]Sprite[/MENTION]s,"player#{i}")
      end
    end
    pbRefresh
  end

  def pbTrainerWithdraw(battle,pkmn)
    pbRefresh
  end

  def pbWithdraw(battle,pkmn)
    pbRefresh
  end

  def pbMoveString(move)
    ret=_INTL("{1}",move.name)
    typename=PBTypes.getName(move.type)
    if move.id>0
      ret+=_INTL(" ({1}) PP: {2}/{3}",typename,move.pp,move.totalpp)
    end
    return ret
  end

  def pbBeginAttackPhase
    pbSelectBattler(-1)
  end

  def pbSafariStart
    @briefmessage=false
     [MENTION=24071]Sprite[/MENTION]s["battlebox0"]=SafariDataBox.new(@battle,@viewport)
     [MENTION=24071]Sprite[/MENTION]s["battlebox0"].appear
    loop do
       [MENTION=24071]Sprite[/MENTION]s["battlebox0"].update
      pbGraphicsUpdate
      pbInputUpdate
      break if   [MENTION=24071]Sprite[/MENTION]s["battlebox0"].appearing
    end
    pbRefresh
  end

  def pbResetCommandIndices
    @lastcmd=[0,0,0,0]
  end

  def pbResetMoveIndex(index)
    @lastmove[index]=0
  end

  def pbSafariCommandMenu(index)
    pbCommandMenuEx(index,[
       _INTL("What will\n{1} throw?",@battle.pbPlayer.name),
       _INTL("Ball"),
       _INTL("Bait"),
       _INTL("Rock"),
       _INTL("Run")
    ],2)
  end

# Use this method to display the list of commands.
# Return values: 0=Fight, 1=Bag, 2=Pokémon, 3=Run, 4=Call
  def pbCommandMenu(index)
    shadowTrainer=(hasConst?(PBTypes,:SHADOW) && @battle.opponent)
    ret=pbCommandMenuEx(index,[
       _INTL("What will\n{1} do?",@battle.battlers[index].name),
       _INTL("Fight"),
       _INTL("Bag"),
       _INTL("Pokémon"),
       shadowTrainer ? _INTL("Call") : _INTL("Run")
    ],(shadowTrainer ? 1 : 0))
    ret=4 if ret==3 && shadowTrainer   # Convert "Run" to "Call"
    return ret
  end

  def pbCommandMenuEx(index,texts,mode=0)      # Mode: 0 - regular battle
    pbShowWindow(COMMANDBOX)                   #       1 - Shadow Pokémon battle
    cw  [MENTION=24071]Sprite[/MENTION]s["commandwindow"]               #       2 - Safari Zone
    cw.setTexts(texts)                         #       3 - Bug Catching Contest
    cw.index=@lastcmd[index]
    cw.mode=mode
    pbSelectBattler(index)
    pbRefresh
    loop do
      pbGraphicsUpdate
      pbInputUpdate
      pbFrameUpdate(cw)
      # Update selected command
      if Input.trigger?(Input::LEFT) && (cw.index&1)==1
        pbPlayCursorSE()
        cw.index-=1
      elsif Input.trigger?(Input::RIGHT) &&  (cw.index&1)==0
        pbPlayCursorSE()
        cw.index+=1
      elsif Input.trigger?(Input::UP) &&  (cw.index&2)==2
        pbPlayCursorSE()
        cw.index-=2
      elsif Input.trigger?(Input::DOWN) &&  (cw.index&2)==0
        pbPlayCursorSE()
        cw.index+=2
      end
      if Input.trigger?(Input::C)   # Confirm choice
        pbPlayDecisionSE()
        ret=cw.index
        @lastcmd[index]=ret
        return ret
      elsif Input.trigger?(Input::B) && index==2 && @lastcmd[0]!=2 # Cancel
        pbPlayDecisionSE()
        return -1
      end
    end 
  end

# Use this method to display the list of moves for a Pokémon
  def pbFightMenu(index)
    pbShowWindow(FIGHTBOX)
    cw =  [MENTION=24071]Sprite[/MENTION]s["fightwindow"]
    [email protected][index]
    cw.battler=battler
    lastIndex=@lastmove[index]
    if battler.moves[lastIndex].id!=0
      cw.setIndex(lastIndex)
    else
      cw.setIndex(0)
    end
    cw.megaButton=0
    cw.megaButton=1 if @battle.pbCanMegaEvolve?(index)
    pbSelectBattler(index)
    pbRefresh
    loop do
      pbGraphicsUpdate
      pbInputUpdate
      pbFrameUpdate(cw)
      # Update selected command
      if Input.trigger?(Input::LEFT) && (cw.index&1)==1
        pbPlayCursorSE() if cw.setIndex(cw.index-1)
      elsif Input.trigger?(Input::RIGHT) &&  (cw.index&1)==0
        pbPlayCursorSE() if cw.setIndex(cw.index+1)
      elsif Input.trigger?(Input::UP) &&  (cw.index&2)==2
        pbPlayCursorSE() if cw.setIndex(cw.index-2)
      elsif Input.trigger?(Input::DOWN) &&  (cw.index&2)==0
        pbPlayCursorSE() if cw.setIndex(cw.index+2)
      end
      if Input.trigger?(Input::C)   # Confirm choice
        ret=cw.index
        pbPlayDecisionSE() 
        @lastmove[index]=ret
        return ret
      elsif Input.trigger?(Input::A)   # Use Mega Evolution
        if @battle.pbCanMegaEvolve?(index)
          @battle.pbRegisterMegaEvolution(index)
          cw.megaButton=2
          pbPlayDecisionSE()
        end
      elsif Input.trigger?(Input::B)   # Cancel fight menu
        @lastmove[index]=cw.index
        pbPlayCancelSE()
        return -1
      end
    end
  end

# Use this method to display the inventory
# The return value is the item chosen, or 0 if the choice was canceled.
  def pbItemMenu(index)
    ret=0
    retindex=-1
    pkmnid=-1
    endscene=true
    oldsprites=pbFadeOutAndHide  [MENTION=24071]Sprite[/MENTION]s)
    itemscene=PokemonBag_Scene.new
    itemscene.pbStartScene($PokemonBag)
    loop do
      item=itemscene.pbChooseItem
      break if item==0
      usetype=$ItemData[item][ITEMBATTLEUSE]
      cmdUse=-1
      commands=[]
      if usetype==0
        commands[commands.length]=_INTL("Cancel")
      else
        commands[cmdUse=commands.length]=_INTL("Use")
        commands[commands.length]=_INTL("Cancel")
      end
      itemname=PBItems.getName(item)
      command=itemscene.pbShowCommands(_INTL("{1} is selected.",itemname),commands)
      if cmdUse>=0 && command==cmdUse
        if usetype==1 || usetype==3
          modparty=[]
          for i in 0...6
            modparty.push(@battle.party1[@battle.partyorder[i]])
          end
          pkmnlist=PokemonScreen_Scene.new
          pkmnscreen=PokemonScreen.new(pkmnlist,modparty)
          itemscene.pbEndScene
          pkmnscreen.pbStartScene(_INTL("Use on which Pokémon?"),@battle.doublebattle)
          activecmd=pkmnscreen.pbChoosePokemon
          [email protected][activecmd]
          if pkmnid>=0 && ItemHandlers.hasBattleUseOnPokemon(item)
            pkmnlist.pbEndScene
            ret=item
            retindex=pkmnid
            endscene=false
            break
          end
          pkmnlist.pbEndScene
          itemscene.pbStartScene($PokemonBag)
        elsif usetype==2 || usetype==4
          if ItemHandlers.hasBattleUseOnBattler(item)
            ret=item
            retindex=index
            break
          end
        end
      end
    end
    pbConsumeItemInBattle($PokemonBag,ret)
    itemscene.pbEndScene if endscene
    pbFadeInAndShow  [MENTION=24071]Sprite[/MENTION]s,oldsprites)
    return [ret,retindex]
  end

# Called whenever a Pokémon should forget a move.  It should return -1 if the
# selection is canceled, or 0 to 3 to indicate the move to forget.  The function
# should not allow HM moves to be forgotten.
  def pbForgetMove(pokemon,moveToLearn)
    ret=-1
    pbFadeOutIn(99999){
       scene=PokemonSummaryScene.new
       screen=PokemonSummary.new(scene)
       ret=screen.pbStartForgetScreen([pokemon],0,moveToLearn)
    }
    return ret
  end

# Called whenever a Pokémon needs one of its moves chosen. Used for Ether.
  def pbChooseMove(pokemon,message)
    ret=-1
    pbFadeOutIn(99999){
       scene=PokemonSummaryScene.new
       screen=PokemonSummary.new(scene)
       ret=screen.pbStartChooseMoveScreen([pokemon],0,message)
    }
    return ret
  end

  def pbNameEntry(helptext,pokemon)
    return pbEnterPokemonName(helptext,0,10,"",pokemon)
  end

  def pbSelectBattler(index,selectmode=1)
    [email protected] ? 4 : 2
    for i in 0...numwindows
      sprite  [MENTION=24071]Sprite[/MENTION]s["battlebox#{i}"]
      sprite.selected=(i==index) ? selectmode : 0
      sprite  [MENTION=24071]Sprite[/MENTION]s["pokemon#{i}"]
      sprite.selected=(i==index) ? selectmode : 0
    end
  end

  def pbFirstTarget(index)
    for i in 0...4
      if i!=index && [email protected][i].isFainted? && 
         @battle.battlers[index].pbIsOpposing?(i)
        return i
      end  
    end
    return -1
  end

  def pbUpdateSelected(index)
    [email protected] ? 4 : 2
    for i in 0...numwindows
      if i==index
         [MENTION=24071]Sprite[/MENTION]s["battlebox#{i}"].selected=2
         [MENTION=24071]Sprite[/MENTION]s["pokemon#{i}"].selected=2
      else
         [MENTION=24071]Sprite[/MENTION]s["battlebox#{i}"].selected=0
         [MENTION=24071]Sprite[/MENTION]s["pokemon#{i}"].selected=0
      end
       [MENTION=24071]Sprite[/MENTION]s["battlebox#{i}"].update
       [MENTION=24071]Sprite[/MENTION]s["pokemon#{i}"].update
    end
  end

# Use this method to make the player choose a target 
# for certain moves in double battles.
  def pbChooseTarget(index)
    pbShowWindow(FIGHTBOX)
    curwindow=pbFirstTarget(index)
    if curwindow==-1
      raise RuntimeError.new(_INTL("No targets somehow..."))
    end
    loop do
      pbGraphicsUpdate
      pbInputUpdate
      pbUpdateSelected(curwindow)
      if Input.trigger?(Input::C)
        pbUpdateSelected(-1)
        return curwindow
      end
      if Input.trigger?(Input::B)
        pbUpdateSelected(-1)
        return -1
      end
      if curwindow>=0
        if Input.trigger?(Input::RIGHT) || Input.trigger?(Input::DOWN)
          loop do
            newcurwindow=3 if curwindow==0
            newcurwindow=1 if curwindow==3
            newcurwindow=2 if curwindow==1
            newcurwindow=0 if curwindow==2
            curwindow=newcurwindow
            next if curwindow==index
            break if [email protected][curwindow].isFainted?
          end
        elsif Input.trigger?(Input::LEFT) || Input.trigger?(Input::UP)
          loop do 
            newcurwindow=2 if curwindow==0
            newcurwindow=1 if curwindow==2
            newcurwindow=3 if curwindow==1
            newcurwindow=0 if curwindow==3
            curwindow=newcurwindow
            next if curwindow==index
            break if [email protected][curwindow].isFainted?
          end
        end
      end
    end
  end

  def pbSwitch(index,lax,cancancel)
    [email protected](index)
    [email protected]
    ret=-1
    # Fade out and hide all sprites
    visiblesprites=pbFadeOutAndHide  [MENTION=24071]Sprite[/MENTION]s)
    pbShowWindow(BLANK)
    pbSetMessageMode(true)
    modparty=[]
    for i in 0...6
      modparty.push(party[partypos[i]])
    end
    scene=PokemonScreen_Scene.new
    @switchscreen=PokemonScreen.new(scene,modparty)
    @switchscreen.pbStartScene(_INTL("Choose a Pokémon."),
       @battle.doublebattle && [email protected])
    loop do
      scene.pbSetHelpText(_INTL("Choose a Pokémon."))
      [email protected]
      if cancancel && activecmd==-1
        ret=-1
        break
      end
      if activecmd>=0
        commands=[]
        cmdShift=-1
        cmdSummary=-1
        pkmnindex=partypos[activecmd]
        commands[cmdShift=commands.length]=_INTL("Switch In") if !party[pkmnindex].egg?
        commands[cmdSummary=commands.length]=_INTL("Summary")
        commands[commands.length]=_INTL("Cancel")
        command=scene.pbShowCommands(_INTL("Do what with {1}?",party[pkmnindex].name),commands)
        if cmdShift>=0 && command==cmdShift
          canswitch=lax ? @battle.pbCanSwitchLax?(index,pkmnindex,true) :
             @battle.pbCanSwitch?(index,pkmnindex,true)
          if canswitch
            ret=pkmnindex
            break
          end
        elsif cmdSummary>=0 && command==cmdSummary
          scene.pbSummary(activecmd)
        end
      end
    end
    @switchscreen.pbEndScene
    @switchscreen=nil
    pbShowWindow(BLANK)
    pbSetMessageMode(false)
    # back to main battle screen
    pbFadeInAndShow  [MENTION=24071]Sprite[/MENTION]s,visiblesprites)
    return ret
  end

  def pbDamageAnimation(pkmn,effectiveness)
    pkmnsprite  [MENTION=24071]Sprite[/MENTION]s["pokemon#{pkmn.index}"]
    shadowsprite  [MENTION=24071]Sprite[/MENTION]s["shadow#{pkmn.index}"]
    sprite  [MENTION=24071]Sprite[/MENTION]s["battlebox#{pkmn.index}"]
    oldshadowvisible=shadowsprite.visible
    oldvisible=sprite.visible
    sprite.selected=2
    @briefmessage=false
    6.times do
      pbGraphicsUpdate
      pbInputUpdate
    end
    case effectiveness
      when 0
        pbSEPlay("normaldamage")
      when 1
        pbSEPlay("notverydamage")
      when 2
        pbSEPlay("superdamage")
    end
    8.times do
      pkmnsprite.visible=!pkmnsprite.visible
      if oldshadowvisible
        shadowsprite.visible=!shadowsprite.visible
      end
      4.times do
        pbGraphicsUpdate
        pbInputUpdate
        sprite.update
      end
    end
    sprite.selected=0
    sprite.visible=oldvisible
  end

# This method is called whenever a Pokémon's HP changes.
# Used to animate the HP bar.
  def pbHPChanged(pkmn,oldhp,anim=false)
    @briefmessage=false
    hpchange=pkmn.hp-oldhp
    if hpchange<0
      hpchange=-hpchange
      PBDebug.log("[#{pkmn.pbThis} lost #{hpchange} HP, now has #{pkmn.hp} HP]") if @battle.debug
    else
      PBDebug.log("[#{pkmn.pbThis} gained #{hpchange} HP, now has #{pkmn.hp} HP]") if @battle.debug
    end
    if anim && @battle.battlescene
      if pkmn.hp>oldhp
        pbCommonAnimation("HealthUp",pkmn,nil)
      elsif pkmn.hp<oldhp
        pbCommonAnimation("HealthDown",pkmn,nil)
      end
    end
    sprite  [MENTION=24071]Sprite[/MENTION]s["battlebox#{pkmn.index}"]
    sprite.animateHP(oldhp,pkmn.hp)
    while sprite.animatingHP
      pbGraphicsUpdate
      pbInputUpdate
      sprite.update
    end
  end

# This method is called whenever a Pokémon faints.
  def pbFainted(pkmn)
    frames=pbCryFrameLength(pkmn.pokemon)
    pbPlayCry(pkmn.pokemon)
    frames.times do
      pbGraphicsUpdate
      pbInputUpdate
    end
     [MENTION=24071]Sprite[/MENTION]s["shadow#{pkmn.index}"].visible=false
    pkmnsprite  [MENTION=24071]Sprite[/MENTION]s["pokemon#{pkmn.index}"]
    ycoord=0
    if @battle.doublebattle
      ycoord=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y if pkmn.index==0
      ycoord=PokeBattle_SceneConstants::FOEBATTLERD1_Y if pkmn.index==1
      ycoord=PokeBattle_SceneConstants::PLAYERBATTLERD2_Y if pkmn.index==2
      ycoord=PokeBattle_SceneConstants::FOEBATTLERD2_Y if pkmn.index==3
    else
      if @battle.pbIsOpposing?(pkmn.index)
        ycoord=PokeBattle_SceneConstants::FOEBATTLER_Y
      else
        ycoord=PokeBattle_SceneConstants::PLAYERBATTLER_Y
      end
    end
    pbSEPlay("faint")
    loop do
      pkmnsprite.y+=8
      if pkmnsprite.y-pkmnsprite.oy+pkmnsprite.src_rect.height>=ycoord
        pkmnsprite.src_rect.height=ycoord-pkmnsprite.y+pkmnsprite.oy
      end
      pbGraphicsUpdate
      pbInputUpdate
      break if pkmnsprite.y>=ycoord
    end
    8.times do
       [MENTION=24071]Sprite[/MENTION]s["battlebox#{pkmn.index}"].opacity-=32
      pbGraphicsUpdate
      pbInputUpdate
    end
     [MENTION=24071]Sprite[/MENTION]s["battlebox#{pkmn.index}"].visible=false
    pkmn.pbResetForm
  end

# Use this method to choose a command for the enemy.
  def pbChooseEnemyCommand(index)
    @battle.pbDefaultChooseEnemyCommand(index)
  end

# Use this method to choose a new Pokémon for the enemy
# The enemy's party is guaranteed to have at least one choosable member.
  def pbChooseNewEnemy(index,party)
    @battle.pbDefaultChooseNewEnemy(index,party)
  end

# This method is called when the player wins a wild Pokémon battle.
# This method can change the battle's music for example.
  def pbWildBattleSuccess
    pbBGMPlay(pbGetWildVictoryME())
  end

# This method is called when the player wins a Trainer battle.
# This method can change the battle's music for example.
  def pbTrainerBattleSuccess
    pbBGMPlay(pbGetTrainerVictoryME(@battle.opponent))
  end

  def pbEXPBar(pokemon,battler,startexp,endexp,tempexp1,tempexp2)
    if battler
       [MENTION=24071]Sprite[/MENTION]s["battlebox#{battler.index}"].refreshExpLevel
      exprange=(endexp-startexp)
      startexplevel=0
      endexplevel=0
      if exprange!=0
        startexplevel=(tempexp1-startexp)*PokeBattle_SceneConstants::EXPGAUGESIZE/exprange
        endexplevel=(tempexp2-startexp)*PokeBattle_SceneConstants::EXPGAUGESIZE/exprange
      end
       [MENTION=24071]Sprite[/MENTION]s["battlebox#{battler.index}"].animateEXP(startexplevel,endexplevel)
      while  [MENTION=24071]Sprite[/MENTION]s["battlebox#{battler.index}"].animatingEXP
        pbGraphicsUpdate
        pbInputUpdate
         [MENTION=24071]Sprite[/MENTION]s["battlebox#{battler.index}"].update
      end
    end
  end

  def pbShowPokedex(species)
    pbFadeOutIn(99999){
       scene=PokemonPokedexScene.new
       screen=PokemonPokedex.new(scene)
       screen.pbDexEntry(species)
    }
  end

  def pbChangeSpecies(attacker,species)
    pkmn  [MENTION=24071]Sprite[/MENTION]s["pokemon#{attacker.index}"]
    shadow  [MENTION=24071]Sprite[/MENTION]s["shadow#{attacker.index}"]
    [email protected]?(attacker.index)
    pkmn.setPokemonBitmapSpecies(attacker.pokemon,species,back)
    pkmn.x=-pkmn.bitmap.width/2
    pkmn.y=adjustBattleSpriteY(pkmn,species,attacker.index)
    if @battle.doublebattle
      case attacker.index
        when 0
          pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLERD1_X
          pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y
        when 1
          pkmn.x+=PokeBattle_SceneConstants::FOEBATTLERD1_X
          pkmn.y+=PokeBattle_SceneConstants::FOEBATTLERD1_Y
        when 2
          pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLERD1_X
          pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y
        when 3
          pkmn.x+=PokeBattle_SceneConstants::FOEBATTLERD1_X
          pkmn.y+=PokeBattle_SceneConstants::FOEBATTLERD1_Y
      end
    else
      pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLER_X if attacker.index==0
      pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLER_Y if attacker.index==0
      pkmn.x+=PokeBattle_SceneConstants::FOEBATTLER_X if attacker.index==1
      pkmn.y+=PokeBattle_SceneConstants::FOEBATTLER_Y if attacker.index==1
    end
    if shadow && !back
      shadow.visible=showShadow?(species)
    end
  end

  def pbChangePokemon(attacker,pokemon)
    pkmn  [MENTION=24071]Sprite[/MENTION]s["pokemon#{attacker.index}"]
    shadow  [MENTION=24071]Sprite[/MENTION]s["shadow#{attacker.index}"]
    [email protected]?(attacker.index)
    pkmn.setPokemonBitmap(pokemon,back)
    pkmn.x=-pkmn.bitmap.width/2
    pkmn.y=adjustBattleSpriteY(pkmn,pokemon.species,attacker.index)
    if @battle.doublebattle
      case attacker.index
        when 0
          pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLERD1_X
          pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y
        when 1
          pkmn.x+=PokeBattle_SceneConstants::FOEBATTLERD1_X
          pkmn.y+=PokeBattle_SceneConstants::FOEBATTLERD1_Y
        when 2
          pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLERD1_X
          pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLERD1_Y
        when 3
          pkmn.x+=PokeBattle_SceneConstants::FOEBATTLERD1_X
          pkmn.y+=PokeBattle_SceneConstants::FOEBATTLERD1_Y
      end
    else
      pkmn.x+=PokeBattle_SceneConstants::PLAYERBATTLER_X if attacker.index==0
      pkmn.y+=PokeBattle_SceneConstants::PLAYERBATTLER_Y if attacker.index==0
      pkmn.x+=PokeBattle_SceneConstants::FOEBATTLER_X if attacker.index==1
      pkmn.y+=PokeBattle_SceneConstants::FOEBATTLER_Y if attacker.index==1
    end
    if shadow && !back
      shadow.visible=showShadow?(pokemon.species)
    end
  end

  def pbSaveShadows
    shadows=[]
    for i in 0...4
      s  [MENTION=24071]Sprite[/MENTION]s["shadow#{i}"]
      shadows[i]=s ? s.visible : false
      s.visible=false if s
    end
    yield
    for i in 0...4
      s  [MENTION=24071]Sprite[/MENTION]s["shadow#{i}"]
      s.visible=shadows[i] if s
    end
  end

  def pbFindAnimation(moveid,userIndex,hitnum)
    begin
      move2anim=load_data("Data/move2anim.dat")
      noflip=false
      if (userIndex&1)==0   # On player's side
        anim=move2anim[0][moveid]
      else                  # On opposing side
        anim=move2anim[1][moveid]
        noflip=true if anim
        anim=move2anim[0][moveid] if !anim
      end
      return [anim+hitnum,noflip] if anim
      if hasConst?(PBMoves,:TACKLE)
        anim=move2anim[0][getConst(PBMoves,:TACKLE)]
        return [anim,false] if anim
      end
    rescue
      return nil
    end
    return nil
  end

  def pbCommonAnimation(animname,user,target,hitnum=0)
    animations=load_data("Data/PkmnAnimations.rxdata")
    for i in 0...animations.length
      if animations[i] && animations[i].name=="Common:"+animname
        pbAnimationCore(animations[i],user,(target!=nil) ? target : user)
        return
      end
    end
  end

  def pbAnimation(moveid,user,target,hitnum=0)
    animid=pbFindAnimation(moveid,user.index,hitnum)
    return if !animid
    anim=animid[0]
    animations=load_data("Data/PkmnAnimations.rxdata")
    pbSaveShadows {
       if animid[1] # On opposing side and using OppMove animation
         pbAnimationCore(animations[anim],target,user,true)
       else         # On player's side, and/or using Move animation
         pbAnimationCore(animations[anim],user,target)
       end
    }
    if PBMoveData.new(moveid).function==0x69 && user && target # Transform
      # Change form to transformed version
      pbChangePokemon(user,target.pokemon)
    end
  end

  def pbAnimationCore(animation,user,target,oppmove=false)
    return if !animation
    @briefmessage=false
    usersprite=(user) ?  [MENTION=24071]Sprite[/MENTION]s["pokemon#{user.index}"] : nil
    targetsprite=(target) ?  [MENTION=24071]Sprite[/MENTION]s["pokemon#{target.index}"] : nil
    olduserx=usersprite ? usersprite.x : 0
    oldusery=usersprite ? usersprite.y : 0
    oldtargetx=targetsprite ? targetsprite.x : 0
    oldtargety=targetsprite ? targetsprite.y : 0
    if !targetsprite
      target=user if !target
      animplayer=PBAnimationPlayerX.new(animation,user,target,self,oppmove)
      userwidth=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.width
      userheight=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.height
      animplayer.setLineTransform(
         PokeBattle_SceneConstants::FOCUSUSER_X,PokeBattle_SceneConstants::FOCUSUSER_Y,
         PokeBattle_SceneConstants::FOCUSTARGET_X,PokeBattle_SceneConstants::FOCUSTARGET_Y,
         olduserx+(userwidth/2),oldusery+(userheight/2),
         olduserx+(userwidth/2),oldusery+(userheight/2))
    else
      animplayer=PBAnimationPlayerX.new(animation,user,target,self,oppmove)
      userwidth=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.width
      userheight=(!usersprite || !usersprite.bitmap || usersprite.bitmap.disposed?) ? 128 : usersprite.bitmap.height
      targetwidth=(!targetsprite.bitmap || targetsprite.bitmap.disposed?) ? 128 : targetsprite.bitmap.width
      targetheight=(!targetsprite.bitmap || targetsprite.bitmap.disposed?) ? 128 : targetsprite.bitmap.height
      animplayer.setLineTransform(
         PokeBattle_SceneConstants::FOCUSUSER_X,PokeBattle_SceneConstants::FOCUSUSER_Y,
         PokeBattle_SceneConstants::FOCUSTARGET_X,PokeBattle_SceneConstants::FOCUSTARGET_Y,
         olduserx+(userwidth/2),oldusery+(userheight/2),
         oldtargetx+(targetwidth/2),oldtargety+(targetheight/2))
    end
    animplayer.start
    while animplayer.playing?
      animplayer.update
      pbGraphicsUpdate
      pbInputUpdate
    end
    usersprite.ox=0 if usersprite
    usersprite.oy=0 if usersprite
    usersprite.x=olduserx if usersprite
    usersprite.y=oldusery if usersprite
    targetsprite.ox=0 if targetsprite
    targetsprite.oy=0 if targetsprite
    targetsprite.x=oldtargetx if targetsprite
    targetsprite.y=oldtargety if targetsprite
    animplayer.dispose
  end

  def pbLevelUp(pokemon,battler,oldtotalhp,oldattack,olddefense,oldspeed,
                oldspatk,oldspdef)
    pbTopRightWindow(_INTL("Max. HP<r>+{1}\r\nAttack<r>+{2}\r\nDefense<r>+{3}\r\nSp. Atk<r>+{4}\r\nSp. Def<r>+{5}\r\nSpeed<r>+{6}",
       pokemon.totalhp-oldtotalhp,
       pokemon.attack-oldattack,
       pokemon.defense-olddefense,
       pokemon.spatk-oldspatk,
       pokemon.spdef-oldspdef,
       pokemon.speed-oldspeed))
    pbTopRightWindow(_INTL("Max. HP<r>{1}\r\nAttack<r>{2}\r\nDefense<r>{3}\r\nSp. Atk<r>{4}\r\nSp. Def<r>{5}\r\nSpeed<r>{6}",
       pokemon.totalhp,pokemon.attack,pokemon.defense,pokemon.spatk,pokemon.spdef,pokemon.speed))
  end

  def pbThrowAndDeflect(ball,targetBattler)
  end

  def pbThrow(ball,shakes,targetBattler)
    @briefmessage=false
    burst=-1
    animations=load_data("Data/PkmnAnimations.rxdata")
    for i in 0...2
      t=(i==0) ? ball : 0
      for j in 0...animations.length
        if animations[j]
          if animations[j].name=="Common:BallBurst#{t}"
            burst=t if burst<0
            break
          end
        end
      end
      break if burst>=0
    end
    pokeballThrow(ball,shakes,targetBattler,self,@battle.battlers[targetBattler],burst)
  end

  def pbThrowSuccess
    if [email protected]
      @briefmessage=false
      pbMEPlay("Jingle - HMTM")
      frames=(3.5*Graphics.frame_rate).to_i
      frames.times do
        pbGraphicsUpdate
        pbInputUpdate
      end
    end
  end

  def pbHideCaptureBall
    if  [MENTION=24071]Sprite[/MENTION]s["capture"]
      loop do
        break if  [MENTION=24071]Sprite[/MENTION]s["capture"].opacity<=0
         [MENTION=24071]Sprite[/MENTION]s["capture"].opacity-=12
        pbGraphicsUpdate
        pbInputUpdate
      end
    end
  end
end
ya no estaran saltando, ahora quiero quitar el parpadeo del ataque pero luego que lo logre hacer te lo env{io por si te interesa :3
saludos
 
Última edición:
Estado
Cerrado para nuevas respuestas.
Arriba