# 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=@sprites["shadow#{targetBattler}"].visible
@sprites["shadow#{targetBattler}"].visible=false
ball=sprintf("Graphics/Pictures/ball%02d",balltype)
ballopen=sprintf("Graphics/Pictures/ball%02d_open",balltype)
# sprites
spritePoke=@sprites["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(@sprites["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],ballendy-((ballendy-center[1])*1/3))
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.pbCommonAnimation("BallBurst#{burst}",battler,nil)
end
pictureBall.clearProcesses
picturePoke.clearProcesses
delay=0
picturePoke.moveZoom(15,delay,0)
picturePoke.moveXY(15,delay,center[0],ballendy-((ballendy-center[1])*1/3))
picturePoke.moveSE(delay+10,"Audio/SE/jumptoball")
picturePoke.moveVisible(delay+15,false)
pictureBall.moveName(picturePoke.totalDuration+2,ball)
delay=picturePoke.totalDuration+30
pictureBall.moveXY(10,delay,center[0],ballendy)
pictureBall.moveSE(pictureBall.totalDuration,"Audio/SE/balldrop")
pictureBall.moveXY(6,pictureBall.totalDuration+2,center[0],ballendy-((ballendy-center[1])*1/6))
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/9))
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(9,delay,center[0]-8,ballendy)
pictureBall.moveAngle(9,delay,30) # positive means counterclockwise
delay=pictureBall.totalDuration
pictureBall.moveXY(9,delay,center[0]+8,ballendy)
pictureBall.moveAngle(9,delay,-30) # negative means clockwise
delay=pictureBall.totalDuration
pictureBall.moveXY(9,delay,center[0],ballendy)
pictureBall.moveAngle(9,delay,0)
delay=pictureBall.totalDuration+29
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
@sprites["shadow#{targetBattler}"].visible=oldvisible
spriteBall.dispose
else
spriteBall.tone=Tone.new(-64,-64,-64,128)
pbSEPlay("balldrop",100,150)
@sprites["capture"]=spriteBall
spritePoke.visible=false
end
end