FANDOM


VS. animation for event Pokémon encounters
This tutorial was written by Videomixer, with the script by Luka S.J. and tweaked by Maruno and tweaked more by ShadowFiendZX to work with Pokémon. Please give credit.
Click here for more tutorials!


As many of you know, adding a VS. animation for trainers is outlined here. This tutorial will explain how to do this with event encounters using a switch. For the tutorial, we will use switch 80, but this is editable. This script was made possible by ShadowFiendZX .

Editing PokemonField (Part 1)

Around line 811 in the script PokemonField, you will find this area of code:

# End
    fade.dispose
    overlay.dispose
    bar1.dispose
    bar2.dispose
    player.dispose
    trainer.dispose
    vs.dispose
    flash.dispose
    viewplayer.dispose
    viewopp.dispose
    viewvs.dispose
    handled=true
  end
  if

Once you find the code, add this directly beneath the final "end" and before the next "if", add this code:

################################################################################
# VS animation, by Luka S.J.
# Tweaked by Maruno
# Tweaked by ShadowFiendZX to work for Pokémon
################################################################################
id=pbGet(1)
if $game_switches[80] 
  id=pbGet(1)
  species=sprintf("%03d",id)
  if FileTest.image_exist?(sprintf("Graphics/Transitions/vsBarPokémon#{species}")) &&
     FileTest.image_exist?(sprintf("Graphics/Transitions/vsPokémon#{species}"))
    # Set up
    name=pbGet(2)
    viewplayer=Viewport.new(0,Graphics.height/3,Graphics.width/2,128)
    viewplayer.z=viewport.z
    viewopp=Viewport.new(Graphics.width/2,Graphics.height/3,Graphics.width/2,128)
    viewopp.z=viewport.z
    viewvs=Viewport.new(0,0,Graphics.width,Graphics.height)
    viewvs.z=viewport.z
    xoffset=(Graphics.width/2)/10
    xoffset=xoffset.round
    xoffset=xoffset*10
    fade=Sprite.new(viewport)
    fade.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsFlash")
    fade.tone=Tone.new(-255,-255,-255)
    fade.opacity=100
    overlay=Sprite.new(viewport)
    overlay.bitmap=Bitmap.new(Graphics.width,Graphics.height)
    pbSetSystemFont(overlay.bitmap)
    bar1=Sprite.new(viewplayer)
    bar1.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsBar#{$Trainer.trainertype}")
    bar1.x=-xoffset
    bar2=Sprite.new(viewopp)
    bar2.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsBarPokémon#{species}")
    bar2.x=xoffset
    vs=Sprite.new(viewvs)
    vs.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vs")
    vs.ox=vs.bitmap.width/2
    vs.oy=vs.bitmap.height/2
    vs.x=Graphics.width/2
    vs.y=Graphics.height/1.5
    vs.visible=false
    flash=Sprite.new(viewvs)
    flash.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsFlash")
    flash.opacity=0
    # Animation
    10.times do
      bar1.x+=xoffset/10
      bar2.x-=xoffset/10
      pbWait(1)
    end
    pbSEPlay("Flash2")
    pbSEPlay("Sword2")
    flash.opacity=255
    bar1=AnimatedPlane.new(viewplayer)
    bar1.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsBar#{$Trainer.trainertype}")
    player=Sprite.new(viewplayer)
    player.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsTrainer#{$Trainer.trainertype}")
    player.x=-xoffset
    bar2=AnimatedPlane.new(viewopp)
    bar2.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsBarPokémon#{species}")
    trainer=Sprite.new(viewopp)
    trainer.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsPokémon#{species}")
    trainer.x=xoffset
    trainer.tone=Tone.new(-255,-255,-255)
    25.times do
      flash.opacity-=51 if flash.opacity>0
      bar1.ox-=16
      bar2.ox+=16
      pbWait(1)
    end
    11.times do
      bar1.ox-=16
      bar2.ox+=16
      player.x+=xoffset/10
      trainer.x-=xoffset/10
      pbWait(1)
    end
    2.times do
      bar1.ox-=16
      bar2.ox+=16
      player.x-=xoffset/20
      trainer.x+=xoffset/20
      pbWait(1)
    end
    10.times do
      bar1.ox-=16
      bar2.ox+=16
      pbWait(1)
    end
    val=2
    flash.opacity=255
    vs.visible=true
    trainer.tone=Tone.new(0,0,0)
    textpos=[
       [_INTL("{1}",$Trainer.name),Graphics.width/4,(Graphics.height/1.5)+10,2,
          Color.new(248,248,248),Color.new(12*6,12*6,12*6)],
       [_INTL("{1}",name),(Graphics.width/4)+(Graphics.width/2),(Graphics.height/1.5)+10,2,
          Color.new(248,248,248),Color.new(12*6,12*6,12*6)]
    ]
    pbDrawTextPositions(overlay.bitmap,textpos)
    pbSEPlay("Sword2")
    70.times do
      bar1.ox-=16
      bar2.ox+=16
      flash.opacity-=25.5 if flash.opacity>0
      vs.x+=val
      vs.y-=val
      val=2 if vs.x<=(Graphics.width/2)-2
      val=-2 if vs.x>=(Graphics.width/2)+2
      pbWait(1)
    end
    30.times do
      bar1.ox-=16
      bar2.ox+=16
      vs.zoom_x+=0.2
      vs.zoom_y+=0.2
      pbWait(1)
    end
    flash.tone=Tone.new(-255,-255,-255)
    10.times do
      bar1.ox-=16
      bar2.ox+=16
      flash.opacity+=25.5
      pbWait(1)
    end
    # End
    fade.dispose
    overlay.dispose
    bar1.dispose
    bar2.dispose
    player.dispose
    trainer.dispose
    vs.dispose
    flash.dispose
    viewplayer.dispose
    viewopp.dispose
    viewvs.dispose
    handled=true
  end
  end

Editing PokemonField (Part 2)

Now that you've added that new code(you should not have replaced anything yet!), look for pbWildBattle def which should be around line 1127 and replace the code with this:

def pbWildBattle(species,level,variable=nil,canescape=true,canlose=false)
  if (Input.press?(Input::CTRL) && $DEBUG) || $Trainer.pokemonCount==0
    if $Trainer.pokemonCount>0
      Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
    end
    pbSet(variable,1)
    $PokemonGlobal.nextBattleBGM=nil
    $PokemonGlobal.nextBattleME=nil
    $PokemonGlobal.nextBattleBack=nil
    return true
  end
  handled=[nil]
  Events.onWildBattleOverride.trigger(nil,species,level,handled)
  if handled[0]!=nil
    return handled[0]
  end
  currentlevels=[]
  for i in $Trainer.party
    currentlevels.push(i.level)
  end
  genwildpoke=pbGenerateWildPokemon(species,level)
  Events.onStartBattle.trigger(nil,genwildpoke)
  scene=pbNewBattleScene
  battle=PokeBattle_Battle.new(scene,$Trainer.party,[genwildpoke],$Trainer,nil)
  battle.internalbattle=true
  battle.cantescape=!canescape
  pbPrepareBattle(battle)
  decision=0
  pbSet(1,species)
  pbBattleAnimation(pbGetWildBattleBGM(species)) { 
     pbSceneStandby {
        decision=battle.pbStartBattle(canlose)
     }
     if $PokemonGlobal.partner
       pbHealAll
       for i in $PokemonGlobal.partner[3]; i.heal; end
     end
     if decision==2 || decision==5 # if loss or draw
       if canlose
         for i in $Trainer.party; i.heal; end
         for i in 0...10
           Graphics.update
         end
       else
         $game_system.bgm_unpause
         $game_system.bgs_unpause
         Kernel.pbStartOver
       end
     end
     Events.onEndBattle.trigger(nil,decision)
  }
  Input.update
  pbSet(variable,decision)
  Events.onWildBattleEnd.trigger(nil,species,level,decision)
  return (decision!=2)
end

Making the Sprites appear

Untitled2

My transitions folder for example

Now that you're done messing with the scripts, go into your transitions folder and do a similar proccess to making trainer mugshots appear. The bar should be named vsBarPokémon(insert national PokéDex number here w/o ()'s) while the mugshot should be named vsPokémon(PokéDex Number w/o ()'s).

Setting the event up

Vseventexample

How an event screen could look

We are almost done now. Create your event as normal, but turn the switch ON throw this as a Script to make the name appear under the Pokémon:

name="#insert name for PKMN#"
pbSet(2,name)

Ad blocker interference detected!


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

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