Advertiser Content

Catching Tutorial

Started by mej71 August 16th, 2014 12:41 AM
  • 3034 views
  • 4 replies
Male
Omnipresence
Seen May 11th, 2019
Posted May 7th, 2019
1,220 posts
5.6 Years
Working on recreating a catching tutorial, by manually creating most of the battle scene. Mildly rudimentary, but it mostly seems to work. Only problem is, the ball thrown to catch the pokemon does not show up, and I can't figure out why. I recreated the pokeballThrow method in this class to suit my needs, and that's where it should be appearing.

Have a look and let me know if you see what's wrong.

class LearnToScene
  BLANK      = 0
  MESSAGEBOX = 1
  COMMANDBOX = 2
  FIGHTBOX   = 3
  
  def update
    pbUpdateSpriteHash(@sprites)
  end
  
  def pbMiddleScene
    loop do
      Graphics.update
      Input.update
        #if @sceneover==true
        if Input.trigger?(Input::C)
          break
        end
     end
  end
  
  def pbEndScene ##This ends everything
    $game_map.autoplay
    pbFadeOutAndHide(@sprites) { update }
    pbDisposeSpriteHash(@sprites)
    @viewport.dispose
    $scene = Scene_Map.new 
  end
  
 
def initialize
  @sprites={}
    @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
    @viewport.z=50
    @viewport2=Viewport.new(0,0,Graphics.width,Graphics.height)
    @viewport2.z=9999
    @sprites["background"]=IconSprite.new(0,0,@viewport2)
    @sprites["background"].setBitmap("Graphics/Battlebacks/battlebgField")
    @sprites["commandwindow"]=CommandMenuDisplay.new(@viewport2)
    @sprites["fightwindow"]=FightMenuDisplay.new(nil,@viewport2)
    @sprites["fightwindow"].visible=false
    @sprites["playerbase"]=IconSprite.new(-100,Graphics.height-160,@viewport2)
    @sprites["playerbase"].setBitmap("Graphics/Battlebacks/playerbaseField")
    @sprites["opponentbase"]=IconSprite.new(300,65,@viewport2)
    @sprites["opponentbase"].setBitmap("Graphics/Battlebacks/enemybaseField")
    @sprites["player"]=AnimatedSprite.create("Graphics/Characters/trback000",5,128,@viewport2)
    @sprites["player"].x=50
    @sprites["player"].y=Graphics.height-224
    @sprites["player"].visible=true
    @opponentpoke=PokeBattle_Pokemon.new(PBSpecies::WEEDLE,5,$Trainer)
    @playerpoke=PokeBattle_Pokemon.new(PBSpecies::PIDGEY,10,$Trainer)
    @sprites["opponent"]=PokemonSprite.new(@viewport2)
    @sprites["opponent"].setPokemonBitmap(@opponentpoke)
    @sprites["opponent"].mirror=false
    @sprites["opponent"].color=Color.new(0,0,0,0)
    @sprites["shadow1"]=IconSprite.new(Graphics.width - 120,(Graphics.height * 3/4)-158,@viewport2)
    @sprites["shadow1"].setBitmap("Graphics/Pictures/battleShadow")
    @sprites["shadow1"].z-=2
    pbPositionPokemonSprite(@sprites["opponent"],Graphics.width - 142,(Graphics.height * 3/4) - 250)
    Kernel.pbMessage("A wild Weedle appeared!")
    Kernel.pbMessage("Go Pidgey!")
    @sprites["playerpoke"]=PokemonSprite.new(@viewport2)
    @sprites["playerpoke"].setPokemonBitmap(@playerpoke,true)
    @sprites["playerpoke"].mirror=false
    @sprites["playerpoke"].color=Color.new(0,0,0,0)
    @sprites["playerpoke"].x=50
    @sprites["playerpoke"].y=Graphics.height-256
    @sprites["playerpoke"].visible=false
    @sprites["ball"]=IconSprite.new(50,Graphics.height-160,@viewport2)
    @sprites["ball"].setBitmap("Graphics/Pictures/ball00")
    @sprites["ball"].visible=false
    for i in 1..20
       @sprites["player"].x-=4
       sleep(1/5)
       @sprites["player"].frame=(i/4).floor
       @sprites["ball"].visible=true if i==5
       if i%2==0
         if i<11
           @sprites["ball"].y-=20
         else
           @sprites["ball"].y+=20
         end
       end
       @sprites["ball"].x+=5
       Graphics.update
    end
    @sprites["ball"].visible=false
    @sprites["playerpoke"].visible=true
    Graphics.update
    textpos=[
     ["What will",20,306,0,Color.new(64,64,64),Color.new(176,176,176)],
     [(_INTL("Pidgey do?")),20,336,0,Color.new(64,64,64),Color.new(176,176,176)],
    ]
    @sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport2) 
    pbSetSystemFont(@sprites["overlay"].bitmap)
    pbDrawTextPositions(@sprites["overlay"].bitmap,textpos)
    Graphics.update
    sleep(3/2)
    pbSEPlay("Choose")
    @sprites["commandwindow"].index=2
    @sprites["commandwindow"].refresh
    Graphics.update
    sleep(3/2)
    pbSEPlay("Choose")
    @sprites["commandwindow"].index=0
    @sprites["commandwindow"].refresh
    Graphics.update
    sleep(3/2)
    pbSEPlay("Choose")
    @sprites["commandwindow"].index=1
    @sprites["commandwindow"].refresh
    Graphics.update
    sleep(3/2)
    pbSEPlay("Select")
    @sprites["background2"]=IconSprite.new(0,0,@viewport2)
    @sprites["background2select"]=IconSprite.new(184,5,@viewport2)
    @sprites["background2pocket"]=IconSprite.new(30,20,@viewport2)
    @sprites["background2icon"]=IconSprite.new(24,Graphics.height-72,@viewport2)
    @sprites["background2select"].setBitmap("Graphics/Pictures/bagSel")
    @sprites["background2pocket"].setBitmap("Graphics/Pictures/bag1")
    @sprites["background2icon"].setBitmap("Graphics/Icons/itemBack")
    @sprites["background2"].setBitmap("Graphics/Pictures/bagbg1")
    @sprites["overlay2"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport2) 
    pbSetSystemFont(@sprites["overlay2"].bitmap)
    @sprites["overlay2"].bitmap.font.size=35
    textpos2=[
    ["CLOSE BAG",200,10,0,Color.new(88,88,80),Color.new(168,184,184)]
    ]
    pbDrawTextPositions(@sprites["overlay2"].bitmap,textpos2)
    Graphics.update
    sleep(3/2)
    pbSEPlay("Choose")
    @sprites["background2"].setBitmap("Graphics/Pictures/bagbg2")
    Graphics.update
    sleep(3/2)
    pbSEPlay("Choose")
    @sprites["overlay2"].bitmap.clear
    textpos2=[
    ["Pokeball",200,10,0,Color.new(88,88,80),Color.new(168,184,184)],
    ["CLOSE BAG",200,45,0,Color.new(88,88,80),Color.new(168,184,184)]
    ]
    pbDrawTextPositions(@sprites["overlay2"].bitmap,textpos2)
    @sprites["background2"].setBitmap("Graphics/Pictures/bagbg3")
    @sprites["background2icon"].setBitmap("Graphics/Icons/item267")
    Graphics.update
    sleep(3/2)
    pbSEPlay("Select")
    pbDisposeSprite(@sprites,"overlay2")
    pbDisposeSprite(@sprites,"background2")
    pbDisposeSprite(@sprites,"background2select")
    pbDisposeSprite(@sprites,"background2pocket")
    pbDisposeSprite(@sprites,"background2icon")
    Graphics.update
    sleep(3/2)
    pbDisposeSprite(@sprites,"overlay")
    @sprites["playerpoke"].visible=false
    @sprites["player"].frame=1
    10.times do
      @sprites["player"].x+=5
      Graphics.update
    end
    #@sprites["ball"].visible=true
    pokeballThrow2(4,@sprites["shadow1"],@sprites["opponent"],self)
    10.times do
      @sprites["player"].x-=5
      Graphics.update
    end
    Kernel.pbMessage("Congratulations!  Weedle was caught!")
    #for i in 1..20
    #   sleep(1/5)
    #   @sprites["player"].frame=(i/4).floor
    #   @sprites["player"].frame=4 if @sprites["player"].frame>4
    #   if i%2==0
    #     if i<11
    #       @sprites["ball"].y-=40
    #     else
    #      @sprites["ball"].y+=15
    #     end
    #   end
    #   @sprites["ball"].x+=13
    #   Graphics.update
    #end
    
    
    
    
  end  
end


class LearnToScreen
  def initialize(scene)
    @scene=scene
  end

  def pbStartScene
    #@scene.pbStart
    @scene.pbMiddleScene
    @scene.pbEndScene
  end
end


def pbLearnToCatch
    scene=LearnToScene.new
    screen=LearnToScreen.new(scene)
    return screen.pbStartScene
end
  
  
def pokeballThrow2(shakes,targetshadow,targetpoke,scene,burst=-1)
  ball="Graphics/Pictures/ball00"
  ballopen="Graphics/Pictures/ball00_open"
  oldvisible=targetshadow.visible
  targetshadow.visible=false
  # sprites
  spritePoke=targetpoke
  spriteBall=IconSprite.new(0,0,@viewport)
  #spriteBall.setBitmap(ball)
  # pictures
  pictureBall=PictureEx.new(spriteBall.z+1)
  picturePoke=PictureEx.new(spritePoke.z)
  dims=[spritePoke.x,spritePoke.y]
  center=getSpriteCenter(targetpoke)
  ballendy=PokeBattle_SceneConstants::FOEBATTLER_Y-4
  # 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)
    Graphics.update
    Input.update
    break if !pictureBall.running? && !picturePoke.running?
  end
  # Burst animation here
  if burst>=0
    scene.pbCommonAnimation("BallBurst#{burst}",nil,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)
    Graphics.update
    Input.update
    break if !pictureBall.running? && !picturePoke.running?
  end
  if shakes<4
    targetshadow.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
Seen September 5th, 2019
Posted September 5th, 2019
1 posts
42 Days
This post is old, but as a basis this is a great script!
Is there any possiblity to adapt this to v17 of Essentials? I'm searching for such a tutorial script for my game.
The script is working without an error, but unfortunately the menu is not shown, the pokemon position is wrong and ball animation is still missing.

I am not much experienced in ruby scripting, but I will try my best. Is there anyone who is fit in scripting and might help?
Advertiser Content