Go Back   The PokéCommunity Forums > Creative Discussions > Game Development > Scripts & Tutorials

Notices
For all updates, view the main page.

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 2 Weeks Ago (01:24 PM). Edited 2 Weeks Ago by mej71.
mej71's Avatar
mej71
 
Join Date: Mar 2014
Location: Omnipresence
Gender: Male
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 !@bump_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 !@bump_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 !@bump_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 !@bump_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? && !@move_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 2 Weeks Ago (01:49 PM).
kcgcrazy
 
Join Date: Nov 2013
Location: Canada
Gender: Male
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 2 Weeks Ago (08:42 PM).
Saving Raven's Avatar
Saving Raven
#BAMFPokemonNerd
 
Join Date: Mar 2011
Location: everywhere
Age: 20
Gender: Male
Nature: Sassy
Send a message via Skype™ to Saving Raven
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
Reply
Quick Reply

Sponsored Links
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
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 11:25 PM.