![[PokeCommunity.com] VS sequences, done right [PokeCommunity.com] VS sequences, done right](https://sjihub.nazuka.net/Downloads/vs.png)
First collect the example files I made for this VS sequence. Next extract the files in their correct folders. If you look at the files, trainer_0.png and trainer_1.png are the default files for the Player trainer, same goes with bar_0.png and bar_1.png. The numbers 0 and 1 stand for the Player's trainer ID which you have defined in the metadata.txt. If you have changed these values, change the values of the images accordingly. For ideal results the dimensions of both the bars and sprites should be (Graphics.width/2) x 128. Height of the sprites can be greater than 128, but the script will cut them to the preferred height.
Next, go to the script PokemonTrainers and look for
Code:
def pbTrainerBattle
Code:
pbBattleAnimation(trainerbgm)
Code:
pbBattleAnimation(trainerbgm,trainerid,trainername)
Now, go to the script PokemonField and look for
Code:
def pbBattleAnimation
Code:
def pbBattleAnimation(bgm=nil,trainerid=-1,trainername="")
Code:
gym=true if FileTest.exist?("Graphics/VS/trainer_#{trainerid}.png") && FileTest.exist?("Graphics/VS/bar_#{trainerid}.png") # If all graphics are present, sequence will activate
for i in RIVALNAMES
if isConst?(trainerid,PBTrainers,i[0]) && $game_variables[i[1]]!=0
trainername=$game_variables[i[1]] # Handles rival names
end
end
Next, in the same script, find
Code:
if Sprite.method_defined?(:wave_amp) && rand(15)==0
viewport.color=Color.new(0,0,0,255)
sprite = Sprite.new
bitmap=Graphics.snap_to_bitmap
bm=bitmap.clone
sprite.z=99999
sprite.bitmap = bm
sprite.wave_speed=500
for i in 0..25
sprite.opacity-=10
sprite.wave_amp+=60
sprite.update
sprite.wave_speed+=30
2.times do
Graphics.update
end
end
bitmap.dispose
bm.dispose
sprite.dispose
Code:
elsif gym==true
baseColor=Color.new(248,248,248)
shadowColor=Color.new(12*6,12*6,12*6)
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/VS/flash")
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/VS/bar_#{$Trainer.trainertype}")
bar1.x=-xoffset
bar2=Sprite.new(viewopp)
bar2.bitmap=BitmapCache.load_bitmap("Graphics/VS/bar_#{trainerid}")
bar2.x=xoffset
vs=Sprite.new(viewvs)
vs.bitmap=BitmapCache.load_bitmap("Graphics/VS/vs_gym")
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/VS/flash")
flash.opacity=0
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/VS/bar_#{$Trainer.trainertype}")
player=Sprite.new(viewplayer)
player.bitmap=BitmapCache.load_bitmap("Graphics/VS/trainer_#{$Trainer.trainertype}")
player.x=-xoffset
bar2=AnimatedPlane.new(viewopp)
bar2.bitmap=BitmapCache.load_bitmap("Graphics/VS/bar_#{trainerid}")
trainer=Sprite.new(viewopp)
trainer.bitmap=BitmapCache.load_bitmap("Graphics/VS/trainer_#{trainerid}")
trainer.x=xoffset
trainer.tone=Tone.new(-255,-255,-255)
15.times do
flash.opacity-=51
bar1.ox-=16
bar2.ox+=16
pbWait(1)
end
10.times do
bar1.ox-=16
bar2.ox+=16
pbWait(1)
end
11.times do
bar1.ox-=16
player.x+=xoffset/10
trainer.x-=xoffset/10
bar2.ox+=16
pbWait(1)
end
2.times do
bar1.ox-=16
player.x-=xoffset/20
trainer.x+=xoffset/20
bar2.ox+=16
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,baseColor,shadowColor],
[_INTL("{1}",trainername),(Graphics.width/4)+(Graphics.width/2),(Graphics.height/1.5)+10,2,baseColor,shadowColor]
]
pbDrawTextPositions(overlay.bitmap,textpos)
pbSEPlay("Sword2")
10.times do
flash.opacity-=25.5
vs.x+=val
vs.y-=val
val=2 if vs.x<=256-2
val=-2 if vs.x>=256+2
bar1.ox-=16
bar2.ox+=16
pbWait(1)
end
60.times do
vs.x+=val
vs.y-=val
val=2 if vs.x<=256-2
val=-2 if vs.x>=256+2
bar1.ox-=16
bar2.ox+=16
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
flash.opacity+=25.5
bar1.ox-=16
bar2.ox+=16
pbWait(1)
end
fade.dispose
overlay.dispose
bar1.dispose
bar2.dispose
player.dispose
trainer.dispose
vs.dispose
flash.dispose
viewplayer.dispose
viewopp.dispose
viewvs.dispose
That is all. There is no further need to externally call the script at all. Just create the corresponding images, and the script will do the rest. Every time when you battle a trainer, who's ID corresponds to one of the IDs you have included with the graphics, the game will load up a VS sequence. Unless you've done something wrong during your steps, you shouldn't experience any problems with this script. It is quite simple, and saves the user some hassle.
Perhaps if Maruno sees it and likes it, he could incorporate it in the next version of Essentials, but with it being triggered through some edits with the "trainertypes.txt" file. I already know how it can be done, but I didn't want to post that method as it requires changes to the PokemonCompiler.
Last edited: