Author Id: 28105
Author Name: PimPam
Post Content: tengo el pokemon essentials v13 y tengo el super following character, tengo el script de following character pero no se como ponerloy si alguien sabe como ponerlo puede decirme como ponerlo el script es:
[SPOILER="Script"]#==============================================================================
#  Pokemon Following Character es original de Help-14.
#  Versión "super" por Rafael-animal.
#  LOS CRÉDITOS HACIA LOS DOS SON NECESARIOS.
#==============================================================================

#==============================================================================
#   Configuración inicial
#==============================================================================

Default_Following_Pokemon_Number = 0 # Pokémon que te siguen
Common_Event = 3 # Evento común del Pokémon
Current_Following_Variable = 28 # Variable del Pokémon(no modificar si no sabes que es)
Walking_Time_Variable = 29 # Variable de Tiempo(no modificar si no sabes que es)
Happier_After = 60 # Feliz después de "tales" pasos.
Animation_Come_Out = 22 # Animación al salir de la Ball
Animation_Come_In = 23 # Animación al entrar en la Ball
Emo_Happy = 24 # Animación "feliz"
Emo_Normal = 25 # Animación "normal"
Emo_Hate = 26 # Animación "enfadado"

#==============================================================================
#   Funciones útiles por Rafael-animal
#==============================================================================


  def MoveFollowingPokemon(commands,waitComplete=false)
    $PokemonTemp.dependentEvents.SetMoveRoute(commands,waitComplete)
  end
  
  def pbRemoveFollowingPokemon
      $PokemonTemp.dependentEvents.remove_sprite(true)
  end

  def pbVisibleFollowingPokemon
      $PokemonTemp.dependentEvents.change_following_pokemon
    end

def pbDarPrimerPokemon(pokemon,level=nil,idevento=4,idcomun=4)
  return if !pokemon || !$Trainer 
  if pbBoxesFull?
    Kernel.pbMessage(_INTL("There's no more room for Pokémon!\1"))
    Kernel.pbMessage(_INTL("The Pokémon Boxes are full and can't accept any more!"))
    return false
  end
  if pokemon.is_a?(Integer) && level.is_a?(Integer)
    pokemon=PokeBattle_Pokemon.new(pokemon,level,$Trainer)
  end
  speciesname=PBSpecies.getName(pokemon.species)
  Kernel.pbMessage(_INTL("{1} obtained {2}!\\se[itemlevel]\1",$Trainer.name,speciesname))
  pbNicknameAndStore(pokemon)
  Kernel.pbAddDependency2(idevento, "Following", idcomun)
$PokemonTemp.dependentEvents.refresh_sprite
  return true
end

#==============================================================================
#   Script modificado.
#   Original por Help-14.
#   Mejorado por Rafael-animal.
#==============================================================================

class DependentEvents
  
  def change_following_pokemon
    $game_variables[33]=0
    if $game_variables[Current_Following_Variable]+1==$Trainer.party.length+1 
      $game_variables[Current_Following_Variable]=0
    else
      $game_variables[Current_Following_Variable]+=1
    end
    if $game_variables[Current_Following_Variable]==$Trainer.party.length
      remove_sprite(true)
    else
      if $Trainer.party[$game_variables[Current_Following_Variable]].isShiny?
        shiny=true
      else
        shiny=false
      end
      change_sprite($Trainer.party[$game_variables[Current_Following_Variable]].species, shiny, true)
    end
  end
  
  def refresh_sprite(menu=nil)
    if $Trainer.party.length!=$game_variables[Current_Following_Variable]
      if $Trainer.party.length-1<$game_variables[Current_Following_Variable]
        $game_variables[Current_Following_Variable]=0
      end
      if $Trainer.party[$game_variables[Current_Following_Variable]].isShiny?
        shiny=true
      else
        shiny=false
      end
      change_sprite($Trainer.party[$game_variables[Current_Following_Variable]].species, shiny, false)
    end
  end

  def change_sprite(id, shiny=nil, animation=nil)
    events=$PokemonGlobal.dependentEvents
    MoveFollowingPokemon([PBMoveRoute::StepAnimeOn])
    for i in 0...events.length
      
      if events && events[8]=="Following"
        
        if shiny==true
          events[6]=sprintf("%03ds",id)
          @realEvents.character_name=sprintf("%03ds",id)
        else
          events[6]=sprintf("%03d",id)
          @realEvents.character_name=sprintf("%03d",id)
        end
        
        if animation==true
          $scene.spriteset.addUserAnimation(Animation_Come_Out,@realEvents.x,@realEvents.y)
        end
        
        $game_variables[Walking_Time_Variable]=0
        
      end
      
    end
    
  end
  

  def remove_sprite(animation=nil)
    events=$PokemonGlobal.dependentEvents
    for i in 0...events.length
      if events && events[8]=="Following"
          events[6]=sprintf("nil")
          @realEvents.character_name=sprintf("nil")
        if animation==true
          $scene.spriteset.addUserAnimation(Animation_Come_In,@realEvents.x,@realEvents.y)
        end
        $game_variables[Current_Following_Variable]=$Trainer.party.length
        $game_variables[Walking_Time_Variable]=0
        $game_variables[33]=1
      end
    end
  end
  
  def check_surf(animation=nil)
      remove_sprite(true)
    end
  
  def check_faint
    if $Trainer.party[$game_variables[Current_Following_Variable]].hp<=0
      for i in 0..$Trainer.party.length-1
        if $Trainer.party.hp>0
          found=true
          $game_variables[Current_Following_Variable]=i
          refresh_sprite(true)
          break
        end
      end
      if !found
        remove_sprite
      end
    end
  end
  
  def talk_pokemon
    events=$PokemonGlobal.dependentEvents
    for i in 0...events.length
      if events && events[8]=="Following"
          pos_x=@realEvents.x
          pos_y=@realEvents.y
      end
    end
    pbPlayCry($Trainer.party[$game_variables[Current_Following_Variable]].species)
    if $game_variables[Current_Following_Variable]!=6
      if $Trainer.party[$game_variables[Current_Following_Variable]].happiness>0 &&
              $Trainer.party[$game_variables[Current_Following_Variable]].happiness<=50
        $scene.spriteset.addUserAnimation(Emo_Hate, pos_x, pos_y)
        Kernel.pbMessage(_INTL("{1} odia estar con {2}",$Trainer.party[$game_variables[Current_Following_Variable]].name,$Trainer.name))
      elsif $Trainer.party[$game_variables[Current_Following_Variable]].happiness>50 &&
              $Trainer.party[$game_variables[Current_Following_Variable]].happiness<=150
        $scene.spriteset.addUserAnimation(Emo_Normal, pos_x, pos_y)
        Kernel.pbMessage(_INTL("{1} no está feliz de estar junto a {2}",$Trainer.party[$game_variables[Current_Following_Variable]].name,$Trainer.name))
      else
        $scene.spriteset.addUserAnimation(Emo_Happy, pos_x, pos_y)
        Kernel.pbMessage(_INTL("{1} está feliz de estar junto a {2}",$Trainer.party[$game_variables[Current_Following_Variable]].name,$Trainer.name))
      end
    end
  end
  
    def SetMoveRoute(commands,waitComplete=false)
    events=$PokemonGlobal.dependentEvents
    for i in 0...events.length
      if events && events[8]=="Following"
        pbMoveRoute(@realEvents,commands,waitComplete)
      end
    end
  end
    
end


#===============================================================================
#  Termina el script de Pokémon Following
#  A partir de aquí hace que se modifiquen otros scripts
#  para añadir compatibilidad.
#===============================================================================

  #----------------------------------------------------------------------------
  #   Game_System
  #----------------------------------------------------------------------------
  
    class Game_System
      alias up update
      
      def update
        add_following_time
        

      up
      end
      
      def add_following_time
        if $game_variables[2]==true
          $game_variables[Walking_Time_Variable]+=1 if $game_variables[Walking_Time_Variable]!=$Trainer.party.length
          if $game_variables[Walking_Time_Variable]==Happier_After*Graphics.frame_rate
            $Trainer.party[$game_variables[Current_Following_Variable]].happiness+=1
            $game_variables[Walking_Time_Variable]=0
          end
        end
      end
      
    end
    
  #----------------------------------------------------------------------------
  #    Cambia el sprite cuando el Pokémon se queda sin PS.
  #----------------------------------------------------------------------------
  
  def pbEndBattle(result)
    @abortable=false
    pbShowWindow(BLANK)
    # Fade out all sprites
    $game_system.bgm_fade(1.0)
    pbFadeOutAndHide [MENTION=24071]Sprite[/MENTION]s)
    [MENTION=24071]Sprite[/MENTION]skin.dispose
    pbDisposeSprites
    #Pokemon Following Character
    $PokemonTemp.dependentEvents.check_faint
  end

  #----------------------------------------------------------------------------
  #    Cambia el sprite cuando cambias la posición del equipo.
  #----------------------------------------------------------------------------
  
  class PokemonScreen
    
    def pbPokemonScreen
 @scene.pbStartScene(@party,_INTL(""),false,nil)
 loop do
  @scene.pbSetHelpText(_INTL(""))
  pkmnid=@scene.pbChoosePokemon
  if pkmnid<0
   break
  end
  pkmn=@party[pkmnid]
  commands=[]
  cmdSummary=-1
  cmdSwitch=-1
  cmdItem=-1
  cmdDebug=-1
  cmdMail=-1
  # Build the commands
  commands[cmdSummary=commands.length]=_INTL("SUMMARY")
  if $DEBUG
   # Commands for debug mode only
   commands[cmdDebug=commands.length]=_INTL("DEBUG")
  end
  cmdMoves=[-1,-1,-1,-1]
  for i in 0...pkmn.moves.length
   move=pkmn.moves
   # Check for hidden moves and add any that were found
   if !pkmn.egg? && (move.id==PBMoves::FLY||
      move.id==PBMoves::CUT||
      move.id==PBMoves::SURF||
      move.id==PBMoves::STRENGTH||
      move.id==PBMoves::FLASH||
      move.id==PBMoves::ROCKSMASH||
      move.id==PBMoves::WATERFALL||
      move.id==PBMoves::TELEPORT||
      move.id==PBMoves::HEADBUTT||
      move.id==PBMoves::DIVE||
      move.id==PBMoves::DIG||
      move.id==PBMoves::MILKDRINK||
      move.id==PBMoves::SOFTBOILED||
      move.id==PBMoves::SWEETSCENT||
      HiddenMoveHandlers.hasHandler(move.id)
    )
    commands[cmdMoves=commands.length]=PBMoves.getName(move.id)
   end
  end
  commands[cmdSwitch=commands.length]=_INTL("SWITCH") if @party.length>1
  if !pkmn.egg?
   if pkmn.mail
    commands[cmdMail=commands.length]=_INTL("MAIL")
   else
    commands[cmdItem=commands.length]=_INTL("ITEM")
   end
  end
  commands[commands.length]=_INTL("CANCEL")
  command=@scene.pbShowCommands(_INTL("Do what with {1}?",pkmn.name),commands)
  havecommand=false
  for i in 0...4
   if cmdMoves>=0 && command==cmdMoves
    havecommand=true
    if pkmn.moves.id==PBMoves::SOFTBOILED||
       pkmn.moves.id==PBMoves::MILKDRINK
     if pkmn.hp<=pkmn.totalhp/5
      pbDisplay(_INTL("Not enough HP..."))
      break
     end
     @scene.pbSetHelpText(_INTL("Use on which Pokémon?"))
     oldpkmnid=pkmnid
     loop do
      @scene.pbPreSelect(oldpkmnid)
      pkmnid=@scene.pbChoosePokemon(true)
      break if pkmnid<0
      newpkmn=@party[pkmnid]
      if newpkmn.egg? || newpkmn.hp==0 || newpkmn.hp==newpkmn.totalhp || pkmnid==oldpkmnid
       pbDisplay(_INTL("This item can't be used on that Pokémon."))
      else
       pkmn.hp-=pkmn.totalhp/5
       hpgain=pbItemRestoreHP(newpkmn,pkmn.totalhp/5)
       @scene.pbDisplay(_INTL("{1}'s HP was restored by {2} points.",newpkmn.name,hpgain))
       pbRefresh
      end
     end
     break
    elsif Kernel.pbCanUseHiddenMove?(pkmn,pkmn.moves.id)
     @scene.pbEndScene
     if pkmn.moves.id==PBMoves::FLY
      scene=PokemonRegionMapScene.new
      screen=PokemonRegionMap.new(scene)
      ret=screen.pbStartFlyScreen
      if ret
       return [pkmn,pkmn.moves.id,ret]
      end
      @scene.pbStartScene(@party,_INTL(""))
      break
     end
     return [pkmn,pkmn.moves.id,nil]
    else
     break
    end
   end
  end
  next if havecommand
  if cmdSummary>=0 && command==cmdSummary
   @scene.pbSummary(pkmnid)
  elsif cmdSwitch>=0 && command==cmdSwitch
   @scene.pbSetHelpText(_INTL("Move to where?"))
   oldpkmnid=pkmnid
   pkmnid=@scene.pbChoosePokemon(true)
   if pkmnid>=0 && pkmnid!=oldpkmnid
    pbSwitch(oldpkmnid,pkmnid)
   end
   #Pokemon Following Character
   $PokemonTemp.dependentEvents.refresh_sprite(true)
  elsif cmdDebug>=0 && command==cmdDebug
   command=@scene.pbShowCommands(_INTL("Do what with {1}?",pkmn.name),[
     _INTL("SHOW VALUES"),
     _INTL("CHEAT CODES"),
     _INTL("SET LEVEL"),
     _INTL("SET SPECIES"),
     _INTL("SET NATURE"),
     _INTL("SET GENDER"),
     _INTL("DUPLICATE"),
     _INTL("DELETE"),
     _INTL("TEACH MOVE"),
     _INTL("CANCEL")
   ])
   case command
   when 0
    pbDisplay(_INTL("Individual Values (Sp.Def last):\r\n{1}, {2}, {3}, {4}, {5}, {6}",pkmn.iv[0],pkmn.iv[1],pkmn.iv[2],pkmn.iv[3],pkmn.iv[4],pkmn.iv[5]))
    pbDisplay(_INTL("Effort Values (Sp.Def last):\r\n{1}, {2}, {3}, {4}, {5}, {6}",pkmn.ev[0],pkmn.ev[1],pkmn.ev[2],pkmn.ev[3],pkmn.ev[4],pkmn.ev[5]))
    persid=sprintf("0x%08X",pkmn.personalID)
    pbDisplay(_INTL("Personal ID: {1}\r\nHappiness: {2}",persid,pkmn.happiness))
   when 1 # Cheat Codes
    pkmn.genCodes("codes.txt")
    pbDisplay(_INTL("Codes for this Pokémon were saved in codes.txt."))
   when 2 # Set Level
    level=Kernel.pbMessageChooseNumberEx(
         _INTL("Set the Pokémon's level."),pkmn.level,1,PBExperience::MAXLEVEL,pkmn.level)
    if level!=pkmn.level
     pkmn.level=level
     pkmn.calcStats
     pbDisplay(_INTL("{1}'s level was set to {2}.",pkmn.name,pkmn.level))
     pbRefreshSingle(pkmnid)
    end
   when 3 # Change Species
    species=pbChooseSpecies(pkmn.species)
    if species!=0
     oldspeciesname=PBSpecies.getName(pkmn.species)
     pkmn.species=species
     pkmn.calcStats
     oldname=pkmn.name
     pkmn.name=PBSpecies.getName(pkmn.species) if pkmn.name==oldspeciesname
     pbDisplay(_INTL("{1}'s species was changed to {2}.",oldname,PBSpecies.getName(pkmn.species)))
     pbRefreshSingle(pkmnid)
    end
   when 4 # Set Nature
    commands=[]
    25.times do |i|
     commands.push(PBNatures.getName(i))
    end
    command=@scene.pbShowCommands(_INTL("Choose a nature."),commands)
    if command>=0
     oldgender=pkmn.gender
     2000.times do
      pkmn.personalID&=0xFFFF0000
      pkmn.personalID|=rand(65536)
      pkmn.personalID-=pkmn.personalID%25
      pkmn.personalID+=command
      break if pkmn.gender==oldgender
     end
     pkmn.calcStats
     if pkmn.nature!=command
       pbDisplay(_INTL("The Pokémon's nature couldn't be changed."))
     else
       pbDisplay(_INTL("The Pokémon's nature was changed."))
       pbRefreshSingle(pkmnid)
     end
    end
   when 5 # Set Gender
    if pkmn.gender==2
     pbDisplay(_INTL("This Pokémon's gender can't be set."))
    elsif pkmn.gender==0
     if pbConfirm(_INTL("Make this Pokémon female?"))
      oldnature=pkmn.nature
      2000.times do
       pkmn.setGender(true)
       break if pkmn.nature==oldnature
      end
      if pkmn.gender==0
       pbDisplay(_INTL("The Pokémon's gender couldn't be changed."))
      else
       pbDisplay(_INTL("The Pokémon's gender was changed."))
       pbRefreshSingle(pkmnid)
      end
     end
    elsif pkmn.gender==1
     if pbConfirm(_INTL("Make this Pokémon male?"))
      oldnature=pkmn.nature
      2000.times do 
       pkmn.setGender(false)
       break if pkmn.nature==oldnature
      end
      if pkmn.gender==1
       pbDisplay(_INTL("The Pokémon's gender couldn't be changed."))
      else
       pbDisplay(_INTL("The Pokémon's gender was changed."))
       pbRefreshSingle(pkmnid)
      end
     end
    end
   when 6 # Duplicate
     clonedpkmn=pkmn.clone
     clonedpkmn.iv=pkmn.iv.clone
     clonedpkmn.ev=pkmn.ev.clone
     pbStorePokemon(clonedpkmn)
     @scene.pbHardRefresh
   when 7 # Delete
     if pbConfirm(_INTL("Are you sure you want to delete this Pokémon?"))
      @party[pkmnid]=nil
      @party.compact!
      pbDisplay(_INTL("The Pokémon was deleted."))
      @scene.pbHardRefresh
     end
   when 8
    move=pbChooseMoveList
    if move!=0
      pbLearnMove(pkmn,move)
      pbRefreshSingle(pkmnid)
    end
   end
  elsif cmdMail>=0 && command==cmdMail
   command=@scene.pbShowCommands(_INTL("Do what with the mail?"),[_INTL("READ"),_INTL("TAKE"),_INTL("CANCEL")])
   case command
    when 0 # Read
     pbFadeOutIn(99999){
      pbDisplayMail(pkmn.mail,pkmn)
     }
    when 1 # Take
     pbTakeMail(pkmn)
     pbRefreshSingle(pkmnid)
   end
  elsif cmdItem>=0 && command==cmdItem
   command=@scene.pbShowCommands(_INTL("Do what with an item?"),[_INTL("GIVE"),_INTL("TAKE"),_INTL("CANCEL")])
   case command
    when 0 # Give
     item=@scene.pbChooseItem($PokemonBag)
     if item>0
      pbGiveMail(item,pkmn)
      pbRefreshSingle(pkmnid)
     end
    when 1 # Take
     pbTakeMail(pkmn)
     pbRefreshSingle(pkmnid)
   end
  end
 end
 @scene.pbEndScene
 return nil
end 
    
  end
  
  #----------------------------------------------------------------------------
  #   Cambia el sprite cuando usas el PC.
  #----------------------------------------------------------------------------

  def pbPokeCenterPC
  Kernel.pbMessage(_INTL("\\se[computeropen]{1} booted up the PC.",$Trainer.name))
  loop do
    commands=PokemonPCList.getCommandList()
    command=Kernel.pbMessage(_INTL("Which PC should be accessed?"),
       commands,commands.length)
    if !PokemonPCList.callCommand(command)
      break
    end
  end
  pbSEPlay("computerclose")
  $PokemonTemp.dependentEvents.refresh_sprite(true)
end

  #----------------------------------------------------------------------------
  #   Cambia el sprite cuando evoluciona el Pokémon.
  #----------------------------------------------------------------------------

  class PokemonEvolutionScene

    def pbEvolution(cancancel=true)
 metaplayer1=SpriteMetafilePlayer.new(@metafile1 [MENTION=24071]Sprite[/MENTION]s["rsprite1"])
 metaplayer2=SpriteMetafilePlayer.new(@metafile2 [MENTION=24071]Sprite[/MENTION]s["rsprite2"])
 metaplayer1.play
 metaplayer2.play
 $game_system.bgm_stop
 sefile=sprintf("Audio/SE/%03dCry.wav" [MENTION=12671]pokemon[/MENTION].species)
 Audio.se_play(sefile)
 Kernel.pbDisplayMessage(_INTL("What?\r\n{1} is evolving!" [MENTION=12671]pokemon[/MENTION].name))
 Audio.se_play(pbGetDecisionSE)
 oldstate=pbSaveSpriteState [MENTION=24071]Sprite[/MENTION]s["rsprite1"])
 oldstate2=pbSaveSpriteState [MENTION=24071]Sprite[/MENTION]s["rsprite2"])
 $game_system.bgm_play("evolv.mid")
 canceled=false
 begin
  metaplayer1.update
  metaplayer2.update
  Graphics.update
  Input.update
  if Input.trigger?(Input::B) && cancancel
   canceled=true
   pbRestoreSpriteState [MENTION=24071]Sprite[/MENTION]s["rsprite1"],oldstate)
   pbRestoreSpriteState [MENTION=24071]Sprite[/MENTION]s["rsprite2"],oldstate2)
   Graphics.update 
   break
  end
 end while metaplayer1.playing? && metaplayer2.playing?
 if canceled
   $game_system.bgm_stop
   Audio.se_play(pbGetDecisionSE)
   Kernel.pbDisplayMessageFancy(_INTL("Huh?\r\n{1} stopped evolving!" [MENTION=12671]pokemon[/MENTION].name))
 else
   sefile=sprintf("Audio/SE/%03dCry.wav",@newspecies)
   playtime=[0,getPlayTime(sefile)].max
   frames=(playtime*Graphics.frame_rate).ceil
   $game_system.bgm_stop
   Audio.se_play(sefile)
   frames.times do
      Graphics.update
   end
   $game_system.me_play("004-Victory04")
   newspeciesname=PBSpecies.getName(@newspecies)
   oldspeciesname=PBSpecies.getName [MENTION=12671]pokemon[/MENTION].species)
   Kernel.pbDisplayMessage(_INTL("Congratulations!  Your {1} evolved into {2}!" [MENTION=12671]pokemon[/MENTION].name,newspeciesname))
   [MENTION=24071]Sprite[/MENTION]s["msgwindow"].text=""
   removeItem=false
   createSpecies=pbCheckEvolutionEx [MENTION=12671]pokemon[/MENTION]){|pokemon,evonib,level,poke|
    if evonib==14 # Shedinja
     next poke
    elsif evonib==6 || evonib==18 || evonib==19 # Evolves if traded with item/holding item
     if poke==@newspecies
      removeItem=true  # Item is now consumed
     end
     next -1
    else
     next -1
    end
   }
   [MENTION=12671]pokemon[/MENTION].item=0 if removeItem
   [MENTION=12671]pokemon[/MENTION].species=@newspecies
   $Trainer.seen[@newspecies]=true
   $Trainer.owned[@newspecies]=true
   [MENTION=12671]pokemon[/MENTION].name=newspeciesname if [MENTION=12671]pokemon[/MENTION].name==oldspeciesname
   [MENTION=12671]pokemon[/MENTION].calcStats
   # Check moves for new species
   atkdata=pbRgssOpen("Data/attacksRS.dat","rb")
   offset=atkdata.getOffset [MENTION=12671]pokemon[/MENTION].species-1)
   length=atkdata.getLength [MENTION=12671]pokemon[/MENTION].species-1)>>1
   atkdata.pos=offset
   for k in 0..length-1
    level=atkdata.fgetw
    move=atkdata.fgetw
    if level= [MENTION=12671]pokemon[/MENTION].level
     # Learned a new move
     pbLearnMove [MENTION=12671]pokemon[/MENTION],move,true)
    end
   end
   if createSpecies>0 && $Trainer.party.length<6
    newpokemon [MENTION=12671]pokemon[/MENTION].clone
    newpokemon.iv [MENTION=12671]pokemon[/MENTION].iv.clone
    newpokemon.ev [MENTION=12671]pokemon[/MENTION].ev.clone
    newpokemon.species=createSpecies
    newpokemon.name=PBSpecies.getName(createSpecies)
    newpokemon.calcStats
    $Trainer.party.push(newpokemon)
    $Trainer.seen[createSpecies]=true
    $Trainer.owned[createSpecies]=true
   end
   atkdata.close
   #Pokemon Following Character
   $PokemonTemp.dependentEvents.refresh_sprite(true)
 end
end

    
  end
  
  #----------------------------------------------------------------------------
  #    Chequea si vas a surfear y guarda el Pokémon en la Ball.
  #----------------------------------------------------------------------------  
  
  def Kernel.pbSurf
    if $DEBUG || $Trainer.badges
      movefinder=Kernel.pbCheckMove(PBMoves::SURF)
      if $DEBUG || movefinder
        if Kernel.pbConfirmMessage(_INTL("The water is dyed a deep blue...  Would you like to surf?"))
          speciesname=!movefinder ? PBSpecies.getName(0) : movefinder.name
          Kernel.pbMessage(_INTL("{1} used Surf!",speciesname))
          pbHiddenMoveAnimation(movefinder)
          surfbgm=pbGetMetadata(0,MetadataSurfBGM)
          #Pokemon Following Character
          $PokemonTemp.dependentEvents.check_surf
          if surfbgm
            pbCueBGM(surfbgm,0.5)
          end
          Kernel.pbCancelVehicles
          $PokemonGlobal.surfing=true
          $PokemonEncounters.clearStepCount
          Kernel.pbJumpToward
          Kernel.pbUpdateVehicle
          $game_player.check_event_trigger_here([1,2])
          return true
        end
      end
    end
    return false
  end
  
  #----------------------------------------------------------------------------
  #    Vuelve a mostrar el sprite al dejar de surfear.
  #----------------------------------------------------------------------------  
  
  def pbEndSurf(xOffset,yOffset)
    return false if !$PokemonGlobal.surfing
    x=$game_player.x
    y=$game_player.y
    currentTag=$game_map.terrain_tag(x,y)
    facingTag=Kernel.pbFacingTerrainTag
    if pbIsWaterTag?(currentTag)&&!pbIsWaterTag?(facingTag)
      if Kernel.pbJumpToward
        Kernel.pbCancelVehicles
        $game_map.autoplayAsCue
        increase_steps
        result=$game_player.check_event_trigger_here([1,2])
        Kernel.pbOnStepTaken(result)
        #Pokemon Following Character
        $PokemonTemp.dependentEvents.refresh_sprite
      end
      return true
    end
    return false
  end
  
  #----------------------------------------------------------------------------
  #    Fixea la MO de Golpe Roca.
  #----------------------------------------------------------------------------  
  
  def Kernel.pbCanUseHiddenMove?(pkmn,move)
 case move
  when PBMoves::FLY
   if !$DEBUG && !$Trainer.badges
    Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
    return false
   end
   #if $game_player.pbHasDependentEvents?
   # Kernel.pbMessage(_INTL("You can't use that if you have someone with you."))
   # return false
   #end
   if !pbGetMetadata($game_map.map_id,MetadataOutdoor)
    Kernel.pbMessage(_INTL("Can't use that here."))
    return false
   end
   return true
  when PBMoves::CUT
   if !$DEBUG && !$Trainer.badges
    Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
    return false
   end
   facingEvent=$game_player.pbFacingEvent
   if !facingEvent || facingEvent.name!="Tree"
    Kernel.pbMessage(_INTL("Can't use that here."))
    return false
   end
   return true
  when PBMoves::HEADBUTT
   facingEvent=$game_player.pbFacingEvent
   if !facingEvent || facingEvent.name!="HeadbuttTree"
    Kernel.pbMessage(_INTL("Can't use that here."))
    return false
   end
   return true
  when PBMoves::SURF
   terrain=Kernel.pbFacingTerrainTag
   if !$DEBUG && !$Trainer.badges
    Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
    return false
   end
   if $PokemonGlobal.surfing
    Kernel.pbMessage(_INTL("You're already surfing."))
    return false
   end
   #if $game_player.pbHasDependentEvents?
   # Kernel.pbMessage(_INTL("You can't use that if you have someone with you."))
   # return false
   #end
   terrain=Kernel.pbFacingTerrainTag
   if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
    Kernel.pbMessage(_INTL("Let's enjoy cycling!"))
    return false
   end
   if !pbIsWaterTag?(terrain)
    Kernel.pbMessage(_INTL("No surfing here!"))
    return false
   end
   return true
  when PBMoves::STRENGTH
   if !$DEBUG && !$Trainer.badges
    Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
    return false
   end
   facingEvent=$game_player.pbFacingEvent
   if !facingEvent || facingEvent.name!="Boulder"
    Kernel.pbMessage(_INTL("Can't use that here."))
    return false
   end
   return true  
  when PBMoves::ROCKSMASH
   terrain=Kernel.pbFacingTerrainTag
   if !$DEBUG && !$Trainer.badges
    Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
    return false
   end
   facingEvent=$game_player.pbFacingEvent
   if !facingEvent || facingEvent.name!="Rock"
    Kernel.pbMessage(_INTL("Can't use that here."))
    return false
   end
   return true  
  when PBMoves::FLASH
   if !$DEBUG && !$Trainer.badges
    Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
    return false
   end
   if !pbGetMetadata($game_map.map_id,MetadataDarkMap)
    Kernel.pbMessage(_INTL("Can't use that here."))
    return false
   end
   if $PokemonGlobal.flashUsed
    Kernel.pbMessage(_INTL("This is in use already."))
    return false
   end
   return true
  when PBMoves::WATERFALL
   if !$DEBUG && !$Trainer.badges
    Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
    return false
   end
   terrain=Kernel.pbFacingTerrainTag
   if terrain!=PBTerrain::Waterfall
    Kernel.pbMessage(_INTL("Can't use that here."))
    return false
   end
   return true
  when PBMoves::DIVE
   if !$DEBUG && !$Trainer.badges
    Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
    return false
   end
   if $PokemonGlobal.diving
    return true
   end
   if $game_player.terrain_tag!=PBTerrain::DeepWater
    Kernel.pbMessage(_INTL("Can't use that here."))
    return false
   end
   if !pbGetMetadata($game_map.map_id,MetadataDiveMap)
    Kernel.pbMessage(_INTL("Can't use that here."))
    return false
   end
   return true
  when PBMoves::TELEPORT
   if !pbGetMetadata($game_map.map_id,MetadataOutdoor)
    Kernel.pbMessage(_INTL("Can't use that here."))
    return false
   end
   #if $game_player.pbHasDependentEvents?
   # Kernel.pbMessage(_INTL("You can't use that if you have someone with you."))
   # return false
   #end
   healing=$PokemonGlobal.healingSpot
   if !healing
    healing=pbGetMetadata(0,MetadataHome) # Home
   end
   if healing
    mapname=pbGetMapNameFromId(healing[0])
    if Kernel.pbConfirmMessage(_INTL("Want to return to the healing spot used last in {1}?",mapname))
     return true
    end
    return false
   else
    Kernel.pbMessage(_INTL("Can't use that here."))
    return false
   end
  when PBMoves::DIG
   escape=pbGetMetadata($game_map.map_id,MetadataEscapePoint)
   if !escape
    Kernel.pbMessage(_INTL("Can't use that here."))
    return false
   end
   if $game_player.pbHasDependentEvents?
    Kernel.pbMessage(_INTL("You can't use that if you have someone with you."))
    return false
   end
   mapname=pbGetMapNameFromId(escape[0])
   if Kernel.pbConfirmMessage(_INTL("Want to escape from here and return to {1}?",mapname))
    return true
   end
   return false
  when PBMoves::SWEETSCENT
   return true
  else
   return HiddenMoveHandlers.triggerCanUseMove(move,pkmn)
 end
 return false
end

class Scene_Map
  alias rafaupdatefollow updateMaps
  
  def updateMaps
    rafaupdatefollow
    if $Trainer
    $PokemonTemp.dependentEvents.refresh_sprite if $Trainer.party.length>0
    end
  end
  
end

def pbBikeCheck
  if $PokemonGlobal.surfing || pbGetTerrainTag()==PBTerrain::TallGrass
    Kernel.pbMessage(_INTL("Can't use that here."))
    return false
  end
  
  if $game_player.pbHasDependentEvents?
    pbRemoveFollowingPokemon
    return true
  end
  
  if $PokemonGlobal.bicycle
    if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
      Kernel.pbMessage(_INTL("You can't dismount your Bike here."))
      return false
    end
    return true
  else
    val=pbGetMetadata($game_map.map_id,MetadataBicycle)
    val=pbGetMetadata($game_map.map_id,MetadataOutdoor) if val==nil
    if !val
      Kernel.pbMessage(_INTL("Can't use that here."))
      return false
    end
    return true
  end
end

def Kernel.pbDismountBike
  return if !$PokemonGlobal.bicycle
  $PokemonGlobal.bicycle=false
  Kernel.pbUpdateVehicle
  $game_map.autoplayAsCue
  $PokemonTemp.dependentEvents.change_following_pokemon
  $PokemonTemp.dependentEvents.refresh_sprite
end[/SPOILER]