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

Help with implementing Rock Climb

28
Posts
8
Years
    • Seen yesterday
    I've been trying to implement Rock Climb. I copied Waterfall as best as I could but I still keep getting this error whenever I use it in game

    Code:
    Exception: NameError
    Message: undefined local variable or method `pbAscendRock' for Kernel:Module
    PField_HiddenMoves:423:in `pbRockClimb'
    PField_HiddenMoves:438
    PField_HiddenMoves:435:in `call'
    Event:54:in `trigger'
    Event:49:in `each'
    Event:49:in `trigger'
    Scene_Map:171:in `update'
    Scene_Map:68:in `main'
    Scene_Map:65:in `loop'
    Scene_Map:72:in `main'

    Here is the HM

    Code:
    #===============================================================================
    # Rock Climb
    #===============================================================================
    
    def Kernel.pbAscendRcok(event=nil)
      event=$game_player if !event
      return if !event
      return if event.direction!=8 # can't ascend if not facing up
      oldthrough=event.through
      oldmovespeed=event.move_speed
      terrain=Kernel.pbFacingTerrainTag
      return if terrain!=PBTerrain::RockClimb && terrain!=PBTerrain::RockCrest
      event.through=true
      event.move_speed=2
      loop do
        event.move_up
        terrain=pbGetTerrainTag(event)
        break if terrain!=PBTerrain::RockClimb && terrain!=PBTerrain::RockCrest
      end
      event.through=oldthrough
      event.move_speed=oldmovespeed
    end
    
    def Kernel.pbDescendRock(event=nil)
      event=$game_player if !event
      return if !event
      return if event.direction!=2 # Can't descend if not facing down
      oldthrough=event.through
      oldmovespeed=event.move_speed
      terrain=Kernel.pbFacingTerrainTag
      return if terrain!=PBTerrain::RockClimb && terrain!=PBTerrain::RockCrest
      event.through=true
      event.move_speed=2
      loop do
        event.move_down
        terrain=pbGetTerrainTag(event)
        break if terrain!=PBTerrain::RockClimb && terrain!=PBTerrain::RockCrest
      end
      event.through=oldthrough
      event.move_speed=oldmovespeed
    end
    
    def Kernel.pbRockClimb
      if $DEBUG ||
        (HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORROCKCLIMB : $Trainer.badges[BADGEFORROCKCLIMB])
        movefinder=Kernel.pbCheckMove(:ROCKCLIMB)
        if $DEBUG || movefinder
          if Kernel.pbConfirmMessage(_INTL("These rocks look like they can be climbed upon. Would you like to use Rock Climb?"))
            speciesname=!movefinder ? $Trainer.name : movefinder.name
            Kernel.pbMessage(_INTL("{1} used Rock Climb.",speciesname))
            pbHiddenMoveAnimation(movefinder)
            pbAscendRock
            return true
          end
        else
          Kernel.pbMessage(_INTL("A wall of Rock is in Front of you."))
        end
      else
        Kernel.pbMessage(_INTL("A wall of Rock is in Front of you."))
      end
      return false
    end
    
    Events.onAction+=proc{|sender,e|
       terrain=Kernel.pbFacingTerrainTag
       if terrain==PBTerrain::RockClimb
         Kernel.pbRockClimb
         return
       end
       if terrain==PBTerrain::RockCrest
         Kernel.pbMessage(_INTL("A wall of Rock is in Front of you."))
         return
       end
    }
    
    HiddenMoveHandlers::CanUseMove.add(:ROCKCLIMB,proc{|move,pkmn|
       if !$DEBUG &&
          !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORROCKCLIMB : $Trainer.badges[BADGEFORROCKCLIMB])
         Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
         return false
       end
       terrain=Kernel.pbFacingTerrainTag
       if terrain!=PBTerrain::RockClimb
         Kernel.pbMessage(_INTL("Can't use that here."))
         return false
       end
       return true
    })
    
    HiddenMoveHandlers::UseMove.add(:ROCKCLIMB,proc{|move,pokemon|
       if !pbHiddenMoveAnimation(pokemon)
         Kernel.pbMessage(_INTL("{1} used {2}.",pokemon.name,PBMoves.getName(move)))
       end
       Kernel.pbAscendRock
       return true
    })

    Here is Event

    Code:
    # Defines an event that procedures can subscribe to.
    class Event
      def initialize
        @callbacks=[]
      end
    
    # Sets an event handler for this event and removes all other event handlers.
      def set(method)
        @callbacks.clear
        @callbacks.push(method)
      end
    
    # Removes an event handler procedure from the event.
      def -(method)
        for i in [email protected]
          if @callbacks[i]==method
            @callbacks.delete_at(i)
            break
          end
        end
        return self
      end
    
    # Adds an event handler procedure from the event.
      def +(method)
        for i in [email protected]
          if @callbacks[i]==method
            return self
          end
        end
        @callbacks.push(method)
        return self
      end
    
    # Clears the event of event handlers.
      def clear
        @callbacks.clear
      end
    
    # Triggers the event and calls all its event handlers.  Normally called only
    # by the code where the event occurred.
    # The first argument is the sender of the event, the second argument contains
    # the event's parameters. If three or more arguments are given, this method
    # supports the following callbacks:
    # proc {|sender,params| } where params is an array of the other parameters, and
    # proc {|sender,arg0,arg1,...| }
      def trigger(*arg)
        arglist=arg[1,arg.length]
        for callback in @callbacks
          if callback.arity>2 && arg.length==callback.arity
            # Retrofitted for callbacks that take three or more arguments
            callback.call(*arg)
          else
            callback.call(arg[0],arglist)
          end
        end
      end
     
    # Triggers the event and calls all its event handlers.  Normally called only
    # by the code where the event occurred. The first argument is the sender of the
    # event, the other arguments are the event's parameters.
      def trigger2(*arg)
        for callback in @callbacks
          callback.call(*arg)
        end
      end
    end
    
    
    
    class HandlerHash
      def initialize(mod)
        @mod=mod
        @hash={}
        @addIfs=[]
        @symbolCache={}
      end
    
      def fromSymbol(sym)
        if sym.is_a?(Symbol) || sym.is_a?(String)
          mod=Object.const_get(@mod) rescue nil
          return nil if !mod
          return mod.const_get(sym.to_sym) rescue nil
        else
          return sym
        end
      end
    
      def toSymbol(sym)
        if sym.is_a?(Symbol) || sym.is_a?(String)
          return sym.to_sym
        else
          ret=@symbolCache[sym]
          return ret if ret
          mod=Object.const_get(@mod) rescue nil
          return nil if !mod
          for key in mod.constants
            if mod.const_get(key)==sym
              ret=key.to_sym
              @symbolCache[sym]=ret
              break
            end
          end
          return ret
        end
      end
    
      def addIf(condProc,handler)
        @addIfs.push([condProc,handler])
      end
    
      def add(sym,handler) # 'sym' can be an ID or symbol
        id=fromSymbol(sym)
        @hash[id]=handler if id
        symbol=toSymbol(sym)
        @hash[symbol]=handler if symbol
      end
    
      def copy(src,*dests)
        handler=self[src]
        if handler
          for dest in dests
            self.add(dest,handler)
          end
        end
      end
    
      def [](sym) # 'sym' can be an ID or symbol
        id=fromSymbol(sym)
        ret=nil
        if id && @hash[id] # Real ID from the item
          ret=@hash[id]
        end
        symbol=toSymbol(sym)
        if symbol && @hash[symbol] # Symbol or string
          ret=@hash[symbol]
        end
        if !ret
          for addif in @addIfs
            if addif[0].call(id)
              return addif[1]
            end
          end
        end
        return ret
      end
    
      def trigger(sym,*args)
        handler=self[sym]
        return handler ? handler.call(fromSymbol(sym),*args) : nil
      end
    
      def clear
        @hash.clear
      end
    end

    Here is Scene Map
    Code:
    #===============================================================================
    # ** Modified Scene_Map class for Pokémon.
    #-------------------------------------------------------------------------------
    #  
    #===============================================================================
    class Scene_Map
      def spriteset
        for i in @spritesets.values
          return i if i.map==$game_map
        end
        return @spritesets.values[0]
      end
    
      def disposeSpritesets
        return if !@spritesets
        for i in @spritesets.keys
          if @spritesets[i]
            @spritesets[i].dispose
            @spritesets[i]=nil
          end
        end
        @spritesets.clear
        @spritesets={}
      end
    
      def createSpritesets
        @spritesets={}
        for map in $MapFactory.maps
          @spritesets[map.map_id]=Spriteset_Map.new(map)
        end
        $MapFactory.setSceneStarted(self)
        updateSpritesets
      end
    
      def updateMaps
        for map in $MapFactory.maps
          map.update
        end
        $MapFactory.updateMaps(self)
      end
    
      def updateSpritesets
        @spritesets={} if !@spritesets
        [email protected]
        for i in keys
         if !$MapFactory.hasMap?(i)
           @spritesets[i].dispose if @spritesets[i]
           @spritesets[i]=nil
           @spritesets.delete(i)
         else
           @spritesets[i].update
         end
        end
        for map in $MapFactory.maps
          if !@spritesets[map.map_id]
            @spritesets[map.map_id]=Spriteset_Map.new(map)
          end
        end
        Events.onMapUpdate.trigger(self)
      end
    
      def main
        createSpritesets
        Graphics.transition
        loop do
          Graphics.update
          Input.update
          update
          if $scene != self
            break
          end
        end
        Graphics.freeze
        disposeSpritesets
        if $game_temp.to_title
          Graphics.transition
          Graphics.freeze
        end
      end
    
      def miniupdate
        $PokemonTemp.miniupdate=true if $PokemonTemp
        loop do
          updateMaps
          $game_player.update
          $game_system.update
          $game_screen.update
          unless $game_temp.player_transferring
            break
          end
          transfer_player
          if $game_temp.transition_processing
            break
          end
        end
        updateSpritesets
        $PokemonTemp.miniupdate=false if $PokemonTemp
      end
    
      def update
        loop do
          updateMaps
          pbMapInterpreter.update
          $game_player.update
          $game_system.update
          $game_screen.update
          unless $game_temp.player_transferring
            break
          end
          transfer_player
          if $game_temp.transition_processing
            break
          end
        end
        updateSpritesets
        if $game_temp.to_title
          $scene = pbCallTitle
          return
        end
        if $game_temp.transition_processing
          $game_temp.transition_processing = false
          if $game_temp.transition_name == ""
            Graphics.transition(20)
          else
            Graphics.transition(40, "Graphics/Transitions/" +
               $game_temp.transition_name)
          end
        end
        if $game_temp.message_window_showing
          return
        end
        if Input.trigger?(Input::C)
          unless pbMapInterpreterRunning?
            $PokemonTemp.hiddenMoveEventCalling=true
          end
        end      
        if Input.trigger?(Input::B)
          unless pbMapInterpreterRunning? or $game_system.menu_disabled or $game_player.moving?
            $game_temp.menu_calling = true
            $game_temp.menu_beep = true
          end
        end
        if Input.trigger?(Input::F5)
          unless pbMapInterpreterRunning? or $game_player.moving?
            $PokemonTemp.keyItemCalling = true if $PokemonTemp
          end
        end
        if $DEBUG and Input.press?(Input::F9)
          $game_temp.debug_calling = true
        end
        unless $game_player.moving?
          if $game_temp.battle_calling
            call_battle
          elsif $game_temp.shop_calling
            call_shop
          elsif $game_temp.name_calling
            call_name
          elsif $game_temp.menu_calling
            call_menu
          elsif $game_temp.save_calling
            call_save
          elsif $game_temp.debug_calling
            call_debug
          elsif $PokemonTemp && $PokemonTemp.keyItemCalling
            $PokemonTemp.keyItemCalling=false
            $game_player.straighten
            Kernel.pbUseKeyItem
          elsif $PokemonTemp && $PokemonTemp.hiddenMoveEventCalling
            $PokemonTemp.hiddenMoveEventCalling=false
            $game_player.straighten
            Events.onAction.trigger(self)
          end
        end
      end
    
      def call_name
        $game_temp.name_calling = false
        $game_player.straighten
        $game_map.update
      end
    
      def call_menu
        $game_temp.menu_calling = false
        $game_player.straighten
        $game_map.update
        sscene=PokemonMenu_Scene.new
        sscreen=PokemonMenu.new(sscene) 
        sscreen.pbStartPokemonMenu
      end
    
      def call_debug
        $game_temp.debug_calling = false
        pbPlayDecisionSE()
        $game_player.straighten
        $scene = Scene_Debug.new
      end
    
      def autofade(mapid)
        playingBGM=$game_system.playing_bgm
        playingBGS=$game_system.playing_bgs
        return if !playingBGM && !playingBGS
        map=pbLoadRxData(sprintf("Data/Map%03d", mapid))
        if playingBGM && map.autoplay_bgm
          if (PBDayNight.isNight?(pbGetTimeNow) rescue false)
            if playingBGM.name!=map.bgm.name && playingBGM.name!=map.bgm.name+"n"
              pbBGMFade(0.8)
            end
          else
            if playingBGM.name!=map.bgm.name
              pbBGMFade(0.8)
            end
          end
        end
        if playingBGS && map.autoplay_bgs
          if playingBGS.name!=map.bgs.name
            pbBGMFade(0.8)
          end
        end
        Graphics.frame_reset
      end
    
      def transfer_player(cancelVehicles=true)
        $game_temp.player_transferring = false
        if cancelVehicles
          Kernel.pbCancelVehicles($game_temp.player_new_map_id)
        end
        autofade($game_temp.player_new_map_id)
        pbBridgeOff
        if $game_map.map_id != $game_temp.player_new_map_id
          $MapFactory.setup($game_temp.player_new_map_id)
        end
        $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
        case $game_temp.player_new_direction
        when 2
          $game_player.turn_down
        when 4
          $game_player.turn_left
        when 6
          $game_player.turn_right
        when 8
          $game_player.turn_up
        end
        $game_player.straighten
        $game_map.update
        disposeSpritesets
        GC.start
        createSpritesets
        if $game_temp.transition_processing
          $game_temp.transition_processing = false
          Graphics.transition(20)
        end
        $game_map.autoplay
        Graphics.frame_reset
        Input.update
      end
    end

    Any Help would be appreciated. Thank You.
     
    Back
    Top