• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

How do I modify the VS. Animation script for non-trainer events?

  • 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.
    Spoiler:
    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.
     

    ShadowFiendZX

    Gym Leader
  • 59
    Posts
    11
    Years
    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.
    Spoiler:
    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.

    I think something like this would work.
    Instead of replacing the original, I suggest adding a space and paste this in
    You'd need to in the event put a bit of code that says
    name=#name of the Pokémon(I don't know how to turn its ID into its name)#
    pbSet(2,name)
    then turn on switch 80
    And make a bar image for the Pokémon's ID in the transitions folder
    called vsBarPokémon001 (for bulbasaur)
    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/Battlers/#{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/Battlers/#{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
    also, change
    def pbWildBattle to this
    Code:
    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
    I tested it and it worked
    How do I modify the VS. Animation script for non-trainer events?

    How do I modify the VS. Animation script for non-trainer events?
     
  • 13
    Posts
    11
    Years
    • Seen Feb 8, 2024
    I think something like this would work.
    -snip-
    I was not changing the original and used a copy in case of crashes, ;). Wow! Thanks for the help! It worked like a charm. I just changed it so that it checked for mugshots rather than the actual battle sprite since I am using official artwork rather than pixelated mugshots. Maybe a tutorial could be made on this for the wiki...
     

    ShadowFiendZX

    Gym Leader
  • 59
    Posts
    11
    Years
    I was not changing the original and used a copy in case of crashes, ;). Wow! Thanks for the help! It worked like a charm. I just changed it so that it checked for mugshots rather than the actual battle sprite since I am using official artwork rather than pixelated mugshots. Maybe a tutorial could be made on this for the wiki...

    Feel free to post a tutorial. If you could say that I helped out with it and tag my pokecommunity profile that'd be great. I'd like to see how this looks in your game as a feature like this never came to mind for me.
     
  • 13
    Posts
    11
    Years
    • Seen Feb 8, 2024
    Feel free to post a tutorial. If you could say that I helped out with it and tag my pokecommunity profile that'd be great. I'd like to see how this looks in your game as a feature like this never came to mind for me.
    The tut is up under the "Battle" sections of tutorials(I would link it, but I do not have 15 posts yet).
     
    Back
    Top