- 13
- Posts
- 11
- Years
- Seen Feb 8, 2024
Hello, fellow essentials user. First off, I would like to confirm that I am using the latest version of essentials (12.2). Now, on to my question. Around line 668 in PokemonField, I found the VS. script by Luka S.J. and edited by Maruno.
By changing the "if trainerid >= 0" to "if switch_id=80", I was able to trigger the event when ever switch 80 was on. I would like to know how to tweak this script to allow a V.S. sprite in a non-trainer battle. More specifically, an event Pokemon battle. I want to know which parts to modify that will change the opponent sprite without altering the player sprite as I accidentally did in the past. I realize I must modify some of the graphics pointers but not which ones.
Thank you for taking the time to read my question.
Spoiler:
Code:
################################################################################
# VS animation, by Luka S.J.
# Tweaked by Maruno.
################################################################################
if trainerid>=0 &&
(FileTest.image_exist?(sprintf("Graphics/Transitions/vsBar#{getConstantName(PBTrainers,trainerid)}")) ||
FileTest.image_exist?(sprintf("Graphics/Transitions/vsBar#{trainerid}")) ) &&
(FileTest.image_exist?(sprintf("Graphics/Transitions/vsTrainer#{getConstantName(PBTrainers,trainerid)}")) ||
FileTest.image_exist?(sprintf("Graphics/Transitions/vsTrainer#{trainerid}")) )
# Set up
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)
if FileTest.image_exist?(sprintf("Graphics/Transitions/vsBar#{getConstantName(PBTrainers,$Trainer.trainertype)}"))
bar1.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsBar#{getConstantName(PBTrainers,$Trainer.trainertype)}")
else
bar1.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsBar#{$Trainer.trainertype}")
end
bar1.x=-xoffset
bar2=Sprite.new(viewopp)
if FileTest.image_exist?(sprintf("Graphics/Transitions/vsBar#{getConstantName(PBTrainers,trainerid)}"))
bar2.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsBar#{getConstantName(PBTrainers,trainerid)}")
else
bar2.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsBar#{trainerid}")
end
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)
if FileTest.image_exist?(sprintf("Graphics/Transitions/vsBar#{getConstantName(PBTrainers,$Trainer.trainertype)}"))
bar1.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsBar#{getConstantName(PBTrainers,$Trainer.trainertype)}")
else
bar1.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsBar#{$Trainer.trainertype}")
end
player=Sprite.new(viewplayer)
if FileTest.image_exist?(sprintf("Graphics/Transitions/vsTrainer#{getConstantName(PBTrainers,$Trainer.trainertype)}"))
player.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsTrainer#{getConstantName(PBTrainers,$Trainer.trainertype)}")
else
player.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsTrainer#{$Trainer.trainertype}")
end
player.x=-xoffset
bar2=AnimatedPlane.new(viewopp)
if FileTest.image_exist?(sprintf("Graphics/Transitions/vsBar#{getConstantName(PBTrainers,trainerid)}"))
bar2.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsBar#{getConstantName(PBTrainers,trainerid)}")
else
bar2.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsBar#{trainerid}")
end
trainer=Sprite.new(viewopp)
if FileTest.image_exist?(sprintf("Graphics/Transitions/vsTrainer#{getConstantName(PBTrainers,trainerid)}"))
trainer.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsTrainer#{getConstantName(PBTrainers,trainerid)}")
else
trainer.bitmap=BitmapCache.load_bitmap("Graphics/Transitions/vsTrainer#{trainerid}")
end
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}",trainername),(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
Thank you for taking the time to read my question.