The PokéCommunity Forums Fan Games Game Development Scripts & Tutorials
Essentials Script Lava Surfing

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.

Reply
 
Thread Tools
  #1    
Old January 12th, 2015 (1:24 PM). Edited January 12th, 2015 by mej71.
mej71's Avatar
mej71 mej71 is offline
     
    Join Date: Mar 2014
    Location: Omnipresence
    Gender: Male
    Posts: 1,222
    Note before you add this: PokeCommunity's formatting breaks scripts. To avoid unnecessary errors, please click Thread Tools and use the Show Printable Version tool. This will show the raw text data in the post, without all the formatting. If you comment on this with a syntax error after I've told you how to solve this, I will not respond.

    Follow all these instructions, and you'll be surfing on lava very soon!

    In Settings, under
    Spoiler:
    Code:
    BADGEFORWATERFALL      = 8
    add
    Code:
    # You can make this equal to whatever, I'm just using this as a default
    BADGEFORLAVASURF       = BADGEFORSURF


    In Game_Map, under
    Spoiler:
    Code:
    # Make water tiles passable if player is surfing
          elsif $PokemonGlobal.surfing &&
             pbIsPassableWaterTag?(@terrain_tags[tile_id])
            return true
    add
    Code:
    # Make lava tiles passable if player is lava surfing
          elsif $PokemonGlobal.lavasurfing &&
              pbIsPassableLavaTag?(@terrain_tags[tile_id])
            return true

    In Game_Player , add the red parts to the following methods
    Spoiler:
    Code:
    def move_down(turn_enabled = true)
        if turn_enabled
          turn_down
        end
        if passable?(@x, @y, 2)
          return if pbLedge(0,1)
          return if pbEndSurf(0,1) || pbEndLavaSurf(0,1)
          turn_down
          @y += 1
          $PokemonTemp.dependentEvents.pbMoveDependentEvents
          increase_steps
        else
          if !check_event_trigger_touch(@x, @y+1)
            if [email protected]_se || @bump_se<=0
              pbSEPlay("bump"); @bump_se=10
            end
          end
        end
      end
    
      def move_left(turn_enabled = true)
        if turn_enabled
          turn_left
        end
        if passable?(@x, @y, 4)
          return if pbLedge(-1,0)
          return if pbEndSurf(-1,0) || pbEndLavaSurf(-1,0)
          turn_left
          @x -= 1
          $PokemonTemp.dependentEvents.pbMoveDependentEvents
          increase_steps
        else
          if !check_event_trigger_touch(@x-1, @y)
            if [email protected]_se || @bump_se<=0
              pbSEPlay("bump"); @bump_se=10
            end
          end
        end
      end
    
      def move_right(turn_enabled = true)
        if turn_enabled
          turn_right
        end
        if passable?(@x, @y, 6)
          return if pbLedge(1,0)
          return if pbEndSurf(1,0) || pbEndLavaSurf(1,0)
          turn_right
          @x += 1
          $PokemonTemp.dependentEvents.pbMoveDependentEvents
          increase_steps
        else
          if !check_event_trigger_touch(@x+1, @y)
            if [email protected]_se || @bump_se<=0
              pbSEPlay("bump"); @bump_se=10
            end
          end
        end
      end
    
      def move_up(turn_enabled = true)
        if turn_enabled
          turn_up
        end
        if passable?(@x, @y, 8)
          return if pbLedge(0,-1)
          return if pbEndSurf(0,-1) || pbEndLavaSurf(0,-1)
          turn_up
          @y -= 1
          $PokemonTemp.dependentEvents.pbMoveDependentEvents
          increase_steps
        else
          if !check_event_trigger_touch(@x, @y-1)
            if [email protected]_se || @bump_se<=0
              pbSEPlay("bump"); @bump_se=10
            end
          end
        end
      end

    In Sprite_Character, in def update add the red parts
    Spoiler:
    Code:
    if @character==$game_player && @tile_id == 0
          if $PokemonGlobal.surfing || $PokemonGlobal.diving || $PokemonGlobal.lavasurfing
            bob=((Graphics.frame_count%60)/15).floor
            self.oy=(bob>=2) ? @ch-16-2 : @ch-16
          end
        end
        if @tile_id == 0
          if @character==$game_player && !$PokemonGlobal.fishing &&
             ($PokemonGlobal.surfing || $PokemonGlobal.diving || $PokemonGlobal.lavasurfing)
            sx = bob * @cw
            sy = (@character.direction - 2) / 2 * @ch
            self.src_rect.set(sx, sy, @cw, @ch)
          else
            sx = @character.pattern * @cw
            sy = (@character.direction - 2) / 2 * @ch
            self.src_rect.set(sx, sy, @cw, @ch)
          end
        end


    In Walk_Run add the red part to pbCanRun?
    Spoiler:
    Code:
    def pbCanRun?
        terrain=pbGetTerrainTag
        return Input.press?(Input::A) &&
           !pbMapInterpreterRunning? && [email protected]_route_forcing && 
           $PokemonGlobal && $PokemonGlobal.runningShoes &&
           !$PokemonGlobal.diving && !$PokemonGlobal.surfing &&
           !$PokemonGlobal.bicycle && terrain!=PBTerrain::TallGrass &&
           terrain!=PBTerrain::Ice && !$PokemonGlobal.lavasurfing
      end

    then (same section) under def character_name add the red part
    Spoiler:
    Code:
    if $PokemonGlobal.playerID>=0 && meta && 
             !$PokemonGlobal.bicycle && !$PokemonGlobal.diving && !$PokemonGlobal.surfing && !$PokemonGlobal.lavasurfing
            if meta[4] && meta[4]!="" && Input.dir4!=0 && passable?(@x,@y,Input.dir4) && pbCanRun?
              # Display running character sprite
              @character_name=pbGetPlayerCharset(meta,4)
            else
              # Display normal character sprite 
              @character_name=pbGetPlayerCharset(meta,1)
            end
          end

    In PokeBattle_ActualScene add the red part
    This just allows you to have a lava base during battles
    Spoiler:
    Code:
    elsif $PokemonGlobal.surfing
          trialname="Water"
    elsif $PokemonGlobal.lavasurfing
          trialname="Lava"


    In PokemonField, under module PBTerrain, add the red part
    Spoiler:
    Code:
    Bridge          = 15
      Lava            = 16
    16 can be a different number if you've added other tiles. As long as it's defined separately from other tiles.


    Right after this module ends, add
    Spoiler:
    Code:
    def pbIsPassableLavaTag?(tag)
      return tag==PBTerrain::Lava
    end


    Same section, add the red part to def Kernel.pbUpdateVehicle
    Spoiler:
    Code:
    def Kernel.pbUpdateVehicle
      meta=pbGetMetadata(0,MetadataPlayerA+$PokemonGlobal.playerID)
      if meta
        if $PokemonGlobal.diving
          $game_player.character_name=pbGetPlayerCharset(meta,5) # Diving graphic
        elsif $PokemonGlobal.surfing
          $game_player.character_name=pbGetPlayerCharset(meta,3) # Surfing graphic
        elsif $PokemonGlobal.bicycle
          $game_player.character_name=pbGetPlayerCharset(meta,2) # Bicycle graphic
        elsif $PokemonGlobal.lavasurfing
          $game_player.character_name=pbGetPlayerCharset(meta,8) # Lava surfing graphic
        else
          $game_player.character_name=pbGetPlayerCharset(meta,1) # Regular graphic
        end
      end
    end


    Next add the red part to def Kernel.pbCancelVehicle
    Spoiler:
    Code:
    def Kernel.pbCancelVehicles(destination=nil)
      $PokemonGlobal.surfing=false
      $PokemonGlobal.diving=false
      $PokemonGlobal.lavasurfing=false
      if !destination || !pbCanUseBike?(destination)
        $PokemonGlobal.bicycle=false
      end
      Kernel.pbUpdateVehicle
    end


    Replace def pbFishingBegin and def pbFishingEnd
    Spoiler:
    Code:
    def pbFishingBegin
      $PokemonGlobal.fishing=true
      if !pbCommonEvent(FISHINGBEGINCOMMONEVENT)
        patternb = 2*$game_player.direction - 1
        playertrainer=pbGetPlayerTrainerType
        meta=pbGetMetadata(0,MetadataPlayerA+$PokemonGlobal.playerID)
        num=($PokemonGlobal.surfing) ? 7 : ($PokemonGlobal.lavasurfing)? 9 : 6
        if meta && meta[num] && meta[num]!=""
          charset=pbGetPlayerCharset(meta,num)
          4.times do |pattern|
            $game_player.setDefaultCharName(charset,patternb-pattern)
            2.times do
              Graphics.update
              Input.update
              pbUpdateSceneMap
            end
          end
        end
      end
    end
    
    def pbFishingEnd
      if !pbCommonEvent(FISHINGENDCOMMONEVENT)
        patternb = 2*($game_player.direction - 2)
        playertrainer=pbGetPlayerTrainerType
        meta=pbGetMetadata(0,MetadataPlayerA+$PokemonGlobal.playerID)
        num=($PokemonGlobal.surfing) ? 7 : ($PokemonGlobal.lavasurfing)? 9 : 6
        if meta && meta[num] && meta[num]!=""
          charset=pbGetPlayerCharset(meta,num)
          4.times do |pattern|
            $game_player.setDefaultCharName(charset,patternb+pattern)
            2.times do
              Graphics.update
              Input.update
              pbUpdateSceneMap
            end
          end
        end
      end
      $PokemonGlobal.fishing=false
    end


    Between the sections for Surf and Waterfall in PokemonHiddenMoves, add this whole thing
    Spoiler:
    Code:
    #===============================================================================
    # Lava Surf
    #===============================================================================
    def Kernel.pbLavaSurf
      if $game_player.pbHasDependentEvents?
        return false
      end
      if $DEBUG ||
        (HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORLAVASURF : $Trainer.badges[BADGEFORLAVASURF])
        movefinder=Kernel.pbCheckMove(:LAVASURF)
        if $DEBUG || movefinder
          if Kernel.pbConfirmMessage(_INTL("The lava is a deep red...\nWould you like to surf on it?"))
            speciesname=!movefinder ? $Trainer.name : movefinder.name
            Kernel.pbMessage(_INTL("{1} used Lava Surf!",speciesname))
            pbHiddenMoveAnimation(movefinder)
            surfbgm=pbGetMetadata(0,MetadataSurfBGM)
            if surfbgm
              pbCueBGM(surfbgm,0.5)
            end
            pbStartLavaSurfing()
            return true
          end
        end
      end
      return false
    end
    
    def pbStartLavaSurfing()
      Kernel.pbCancelVehicles
      $PokemonEncounters.clearStepCount
      $PokemonGlobal.lavasurfing=true
      Kernel.pbUpdateVehicle
      Kernel.pbJumpToward
      Kernel.pbUpdateVehicle
      $game_player.check_event_trigger_here([1,2])
    end
    
    def pbEndLavaSurf(xOffset,yOffset)
      return false if !$PokemonGlobal.lavasurfing
      x=$game_player.x
      y=$game_player.y
      currentTag=$game_map.terrain_tag(x,y)
      facingTag=Kernel.pbFacingTerrainTag
      if pbIsPassableLavaTag?(currentTag) && !pbIsPassableLavaTag?(facingTag)
        if Kernel.pbJumpToward(1,false,true)
    #      Kernel.pbCancelVehicles
          $game_map.autoplayAsCue
          $game_player.increase_steps
          result=$game_player.check_event_trigger_here([1,2])
          Kernel.pbOnStepTaken(result)
        end
        return true
      end
      return false
    end
    
    def Kernel.pbTransferLavaSurfing(mapid,xcoord,ycoord,direction=$game_player.direction)
      pbFadeOutIn(99999){
         $game_temp.player_new_map_id=mapid
         $game_temp.player_new_x=xcoord
         $game_temp.player_new_y=ycoord
         $game_temp.player_new_direction=direction
         Kernel.pbCancelVehicles
         $PokemonGlobal.lavasurfing=true
         Kernel.pbUpdateVehicle
         $scene.transfer_player(false)
         $game_map.autoplay
         $game_map.refresh
      }
    end
    
    Events.onAction+=proc{|sender,e|
       terrain=Kernel.pbFacingTerrainTag
       notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
       if pbIsPassableLavaTag?(terrain) && !$PokemonGlobal.lavasurfing && 
          !pbGetMetadata($game_map.map_id,MetadataBicycleAlways) && notCliff
         Kernel.pbLavaSurf
         return
       end
    }
    
    HiddenMoveHandlers::CanUseMove.add(:LAVASURF,proc{|move,pkmn|
       terrain=Kernel.pbFacingTerrainTag
       notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
       if !$DEBUG &&
          !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORLAVASURF : $Trainer.badges[BADGEFORLAVASURF])
         Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
         return false
       end
       if $PokemonGlobal.lavasurfing
         Kernel.pbMessage(_INTL("You're already surfing."))
         return false
       end
       if $game_player.pbHasDependentEvents?
         Kernel.pbMessage(_INTL("It can't be used when you have someone with you."))
         return false
       end
       if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
         Kernel.pbMessage(_INTL("Let's enjoy cycling!"))
         return false
       end
       if !pbIsPassableLavaTag?(terrain) || !notCliff
         Kernel.pbMessage(_INTL("No surfing here!"))
         return false
       end
       return true
    })
    
    HiddenMoveHandlers::UseMove.add(:LAVASURF,proc{|move,pokemon|
       if !pbHiddenMoveAnimation(pokemon)
         Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
       end
       pbStartLavaSurfing()
       return true
    })


    In PokemonMap under class PokemonGlobalMetadata, add the red part
    Spoiler:
    Code:
    attr_accessor :surfing
      attr_accessor :lavasurfing

    Slightly lower under def initialize, add the red part
    Spoiler:
    Code:
    @surfing              = false
        @lavasurfing          = false


    Lastly, same section, under Module PokemonMetadata replace this part
    Spoiler:
    Code:
    GlobalTypes={
         "Home"=>[MetadataHome,"uuuu"],
         "WildBattleBGM"=>[MetadataWildBattleBGM,"s"],
         "TrainerBattleBGM"=>[MetadataTrainerBattleBGM,"s"],
         "WildVictoryME"=>[MetadataWildVictoryME,"s"],
         "TrainerVictoryME"=>[MetadataTrainerVictoryME,"s"],
         "SurfBGM"=>[MetadataSurfBGM,"s"],
         "BicycleBGM"=>[MetadataBicycleBGM,"s"],
         "PlayerA"=>[MetadataPlayerA,"esssssssss",:PBTrainers], 
         "PlayerB"=>[MetadataPlayerB,"esssssssss",:PBTrainers],
         "PlayerC"=>[MetadataPlayerC,"esssssssss",:PBTrainers],
         "PlayerD"=>[MetadataPlayerD,"esssssssss",:PBTrainers],
         "PlayerE"=>[MetadataPlayerE,"esssssssss",:PBTrainers],
         "PlayerF"=>[MetadataPlayerF,"esssssssss",:PBTrainers],
         "PlayerG"=>[MetadataPlayerG,"esssssssss",:PBTrainers],
         "PlayerH"=>[MetadataPlayerH,"esssssssss",:PBTrainers]
      }


    And that's all the coding part. Three other things you will need to do.
    1. Add Lava Surf as a move to moves.txt
    Spoiler:
    Code:
    560,LAVASURF,Lava Surf,075,95,FIRE,Special,100,15,0,08,0,bef,"It swamps the area around the user with a giant wave of molten rock. It can also be used for crossing lava."

    2. Add a filepath for each character in your metadata.txt (red part is the addition)
    I'm just using the default surfing graphic, you can use a special graphic or whatever
    Spoiler:
    Code:
    PlayerA=POKEMONTRAINER_Red,trchar000,boy_bike,boy_surf_offset,boy_run,boy_dive_offset,boy_fish_offset,boy_fishsurf_offset,boy_surf_offset,boy_fishsurf_offset
    PlayerB=POKEMONTRAINER_Leaf,trchar001,girl_bike,girl_surf_offset,girl_run,girl_dive_offset,girl_fish_offset,girl_fishsurf_offset,girl_surf_offset,girl_fishsurf_offset


    3. Just like with bridges, you'll have to add the terrain tag to lava tiles through the Editor. Otherwise they won't be seen as lava tags. Don't forget that the terrain tag has to be added to the tile individually on each tileset.

    4. (Optional) Make Lava Surf a tm/hm move. I didn't provide this, but you can just basically copy surf and rename it.

    I've provided a 4th gen style lava autotile you can use (credit to rayquaza_dot)


    Note that while this allows for the graphics to change and work for fishing, this does not enable fishing while lava surfing, because I think that's just silly.
    Tutorial is written for v15, untested for previous versions.
    Reply With Quote
      #2    
    Old January 12th, 2015 (1:49 PM).
    kcgcrazy kcgcrazy is offline
       
      Join Date: Nov 2013
      Location: Canada
      Gender: Male
      Posts: 119
      thank you so much for making this, i tried doing this myself but i just couldnt get it to work properly, ill deff try this out when i can!
      Reply With Quote
        #3    
      Old January 12th, 2015 (8:42 PM).
      Radical Raptr's Avatar
      Radical Raptr Radical Raptr is offline
      #BAMFPokemonNerd
         
        Join Date: Mar 2011
        Location: everywhere
        Age: 23
        Gender: Male
        Nature: Sassy
        Posts: 1,118
        That's gen 4 style lava - regardless, its a nice tutorial, I didn't realize theres so much that goes into it, hahah, good work.
        __________________

        ~My Deviantart - Litharreon Wiki - Litharreon Game Download~

        Reply With Quote
          #4    
        Old January 29th, 2015 (7:13 PM).
        Qosole Qosole is offline
           
          Join Date: Jan 2015
          Gender: Male
          Posts: 4
          What terrain tag should the lava be? Also, how do you change the surf sprite and the lava surf sprite?
          Reply With Quote
            #5    
          Old January 29th, 2015 (7:54 PM).
          mej71's Avatar
          mej71 mej71 is offline
             
            Join Date: Mar 2014
            Location: Omnipresence
            Gender: Male
            Posts: 1,222
            Quote:
            Originally Posted by Qosole View Post
            What terrain tag should the lava be? Also, how do you change the surf sprite and the lava surf sprite?
            Terrain tag can be whatever unused number, just be consistent. The sprite used will be defined in your metadata.txt. I've mentioned these in the main post, please read thoroughly before asking questions.
            Reply With Quote
              #6    
            Old January 30th, 2015 (5:36 PM).
            Qosole Qosole is offline
               
              Join Date: Jan 2015
              Gender: Male
              Posts: 4
              Quote:
              Originally Posted by mej71 View Post
              Terrain tag can be whatever unused number, just be consistent. The sprite used will be defined in your metadata.txt. I've mentioned these in the main post, please read thoroughly before asking questions.
              I found an unused terrain tag, but how do you make it for lava surfing?
              Reply With Quote
                #7    
              Old January 30th, 2015 (7:18 PM).
              Radical Raptr's Avatar
              Radical Raptr Radical Raptr is offline
              #BAMFPokemonNerd
                 
                Join Date: Mar 2011
                Location: everywhere
                Age: 23
                Gender: Male
                Nature: Sassy
                Posts: 1,118
                Quote:
                Originally Posted by Qosole View Post
                I found an unused terrain tag, but how do you make it for lava surfing?
                Did you read the OP?

                "In PokemonField, under module PBTerrain, add the red part
                Code:
                Bridge          = 15
                Lava            = 16
                16 can be a different number if you've added other tiles. As long as it's defined separately from other tiles."
                __________________

                ~My Deviantart - Litharreon Wiki - Litharreon Game Download~

                Reply With Quote
                  #8    
                Old January 31st, 2015 (5:16 PM).
                Qosole Qosole is offline
                   
                  Join Date: Jan 2015
                  Gender: Male
                  Posts: 4
                  Quote:
                  Originally Posted by Saving Raven View Post
                  Did you read the OP?

                  "In PokemonField, under module PBTerrain, add the red part
                  Code:
                  Bridge          = 15
                  Lava            = 16
                  16 can be a different number if you've added other tiles. As long as it's defined separately from other tiles."
                  Not what I meant. In the database, there are only 7 terrain tags. How do you set it to 16?
                  Reply With Quote
                    #9    
                  Old January 31st, 2015 (6:40 PM).
                  Florio's Avatar
                  Florio Florio is offline
                  Pokemon Crimson Skies Owner
                     
                    Join Date: Nov 2008
                    Location: Canada
                    Gender: Male
                    Nature: Lax
                    Posts: 392
                    Quote:
                    Originally Posted by Qosole View Post
                    Not what I meant. In the database, there are only 7 terrain tags. How do you set it to 16?
                    You have to go into the Pokemon Essentials Editor. From there you can change the Terrain Tag from 0-99
                    __________________
                    Reply With Quote
                      #10    
                    Old February 2nd, 2015 (5:58 PM).
                    Qosole Qosole is offline
                       
                      Join Date: Jan 2015
                      Gender: Male
                      Posts: 4
                      Quote:
                      Originally Posted by Florio View Post
                      You have to go into the Pokemon Essentials Editor. From there you can change the Terrain Tag from 0-99
                      I changed it, but it doesn't prompt me to lava surf.
                      Reply With Quote
                        #11    
                      Old August 11th, 2017 (9:10 PM). Edited August 12th, 2017 by Ulithium_Dragon.
                      Ulithium_Dragon's Avatar
                      Ulithium_Dragon Ulithium_Dragon is offline
                         
                        Join Date: Jul 2015
                        Gender: Male
                        Nature: Timid
                        Posts: 87
                        Thanks for the guide!

                        I had a bit of a hard time following it though since Pokemon Essentials has changed so much since it was written (and like, all of the script sections got renamed for some reason...).

                        ----
                        Anyways, I wanted some custom assets to use with lava surfing though, so I went ahead and made an autotile of the Gen III lava assets from R/S/E, as well as custom lava surf and lava fish-surf sprites for the male and female PC.

                        I'm gonna upload em here in case anyone else wants to use em! ;3

                        Attached Thumbnails
                        boy_fishlavasurf_offset.png‎   boy_lavasurf_offset.png‎   girl_fishlavasurf_offset.png‎   girl_lavasurf_offset.png‎   lava3.png‎  

                        GIF.gif‎   LavaSurf_Prev01.jpg‎  
                        Reply With Quote
                          #12    
                        Old October 16th, 2017 (4:13 PM).
                        Sulphur Alchemist Sulphur Alchemist is offline
                           
                          Join Date: Oct 2017
                          Posts: 6
                          Hi, I've 17.1 version, how can I add Lava Surf attack? Scripts are different.
                          Reply With Quote
                          Reply

                          Quick Reply

                          Join the conversation!

                          Create an account to post a reply in this thread, participate in other discussions, and more!

                          Create a PokéCommunity Account
                          Thread Tools

                          Posting Rules
                          You may not post new threads
                          You may not post replies
                          You may not post attachments
                          You may not edit your posts

                          BB code is On
                          Smilies are On
                          [IMG] code is On
                          HTML code is Off

                          Forum Jump


                          All times are GMT -8. The time now is 11:55 AM.