• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Trading Card Game 2 protagonist in the poll by clicking here.
  • 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.

[Scripting Question] It doesn't show animation when I use rock climber

  • 13
    Posts
    2
    Years
    • Seen Sep 17, 2022
    Greetings. I edited a Bergium "Advanced Items Field Moves" scripts using only defog and rock climb. The problem is that despite putting animations.rxdata from its plugin and the actual animation in the graphics it doesn't show when I use rock climb. how to solve?

    Code:
    #===============================================================================
    # Adds Rock Climb to TerrainTag
    #===============================================================================
    
    module GameData
      class TerrainTag
        attr_reader :rockclimb   # The main part only, not the crest
        attr_reader :rockclimb_crest
        attr_reader :can_climb
    
        alias advanceditemsfieldmoves_init initialize
        def initialize(hash)
          advanceditemsfieldmoves_init(hash)
          @rockclimb              = hash[:rockclimb]              || false
          @rockclimb_crest        = hash[:rockclimb_crest]        || false
          @can_climb              = hash[:can_climb]              || false
          @whirlpool              = hash[:whirlpool]              || false
    
        end
    
        def can_surf_freely
          return @can_surf && !@waterfall && !@waterfall_crest && !@whirlpool
        end
      end
    end
    #===============================================================================
    # More TerrainTag
    #===============================================================================
    
    GameData::TerrainTag.register({
      :id                     => :"Rock Climb",
      :id_number              => 26,
      :can_climb              => true,
      :rockclimb              => true
    })
    
    GameData::TerrainTag.register({
      :id                     => :"Rock Climb Crest",
      :id_number              => 27,
      :can_climb              => true,
      :rockclimb_crest        => true
    })
    
    #===============================================================================
    #          Overwrites functions locally to add the Rock Climb section
    #===============================================================================
    
    class Game_Map
      def playerPassable?(x, y, d, self_event = nil)
        bit = (1 << ((d / 2) - 1)) & 0x0f
        [2, 1, 0].each do |i|
          tile_id = data[x, y, i]
          next if tile_id == 0
          terrain = GameData::TerrainTag.try_get(@terrain_tags[tile_id])
          passage = @passages[tile_id]
          if terrain
            # Ignore bridge tiles if not on a bridge
            next if terrain.bridge && $PokemonGlobal.bridge == 0
            # Make water tiles passable if player is surfing
            return true if $PokemonGlobal.surfing && terrain.can_surf && !terrain.waterfall && !terrain.whirlpool 
            # Prevent cycling in really tall grass/on ice
            return false if $PokemonGlobal.bicycle && terrain.must_walk
            # Depend on passability of bridge tile if on bridge
            if terrain.bridge && $PokemonGlobal.bridge > 0
              return (passage & bit == 0 && passage & 0x0f != 0x0f)
            end
          end
          next if terrain&.ignore_passability
          # Regular passability checks
          return false if passage & bit != 0 || passage & 0x0f == 0x0f
          return true if @priorities[tile_id] == 0
        end
        return true
      end
    end
    
    #===============================================================================
    # Rock Field Move
    #===============================================================================
    def fmAscendRock
      return if $game_player.direction != 8   # Can't ascend if not facing up
      terrain = $game_player.pbFacingTerrainTag
      return if !terrain.can_climb
      oldthrough   = $game_player.through
      oldmovespeed = $game_player.move_speed
      $game_player.through    = true
      $game_player.move_speed = 4
      pbJumpToward
      pbCancelVehicles
      $PokemonEncounters.reset_step_count
      $PokemonGlobal.rockclimbing = true
      pbUpdateVehicle
      loop do
        $game_player.move_up
        terrain = $game_player.pbTerrainTag
        break if !terrain.can_climb
        while $game_player.moving?
          Graphics.update
          Input.update
          pbUpdateSceneMap
        end
      end
      $PokemonGlobal.rockclimbing = false
      pbJumpToward(0)
      pbWait(16)
      $game_player.through    = oldthrough
      $game_player.move_speed = oldmovespeed
      $game_player.increase_steps
      $game_player.check_event_trigger_here([1, 2])
    end
    
    def fmDescendRock
      return if $game_player.direction != 2   # Can't descend if not facing down
      terrain = $game_player.pbFacingTerrainTag
      return if !terrain.can_climb
      oldthrough   = $game_player.through
      oldmovespeed = $game_player.move_speed
      old_always_on_top = $game_player.always_on_top
      $game_player.through = true
      $game_player.move_speed = 4
      $game_player.always_on_top = true
      pbJumpToward
      pbCancelVehicles
      $PokemonEncounters.reset_step_count
      $PokemonGlobal.rockclimbing = true
      pbUpdateVehicle
      loop do
        $game_player.move_down
        terrain = $game_player.pbTerrainTag
        break if !terrain.can_climb
        while $game_player.moving?
          Graphics.update
          Input.update
          pbUpdateSceneMap
        end
      end
      $PokemonGlobal.rockclimbing = false
      pbJumpToward(0)
      pbWait(16)
      $game_player.through = oldthrough
      $game_player.move_speed = oldmovespeed
      $game_player.always_on_top = old_always_on_top
      $game_player.increase_steps
      $game_player.check_event_trigger_here([1, 2])
    end
    
    def fmRockClimb
      move = :ROCKCLIMB
      movefinder = $player.get_pokemon_with_move(move)
      if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_ROCKCLIMB, false) || (!$DEBUG && !movefinder)
        pbMessage(_INTL("The wall is very rocky. Could be climbed with the right move"))
        return false
      end
      if pbConfirmMessage(_INTL("The wall is very rocky.\nWould you like to use the {1}", GameData::Move.get(move).name))
        speciesname = (movefinder) ? movefinder.name : $player.name
        pbMessage(_INTL("{1} used {2}!", speciesname, GameData::Move.get(move).name))
        pbHiddenMoveAnimation(movefinder)
        case $game_player.direction
        when 8 # Looking up
          fmAscendRock
        when 2 # Looking down
          fmDescendRock
        end
        return true
      end
      return false
      pbWait(16)
    end
    
    EventHandlers.add(:on_player_interact, :rockclimb,
      proc {
        terrain = $game_player.pbFacingTerrainTag
        if terrain.rockclimb
          fmRockClimb
        end
      }
    )
    
    EventHandlers.add(:on_player_interact, :rockclimb_crest,
      proc {
        terrain = $game_player.pbFacingTerrainTag
        if terrain.rockclimb_crest
          fmRockClimb
        end
      }
    )
    
    HiddenMoveHandlers::CanUseMove.add(:ROCKCLIMB, proc { |move, pkmn, showmsg|
      next false if !pbCanUseMove(Item_RockClimb)
      if !$game_player.pbFacingTerrainTag.can_climb
        pbMessage(_INTL("You can't use that here.")) if showmsg
        next false
      end
      next true
      })
    
    HiddenMoveHandlers::UseMove.add(:ROCKCLIMB, proc { |move, pokemon|
      fmRockClimb
      next true
      })
    
    #===============================================================================
    # Defog Field Move
    #===============================================================================
    # This Game $stats handle by this plugin [New from this Plugin]
    def fmDefog
      move = :DEFOG
      movefinder = $player.get_pokemon_with_move(move)
      if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_DEFOG, false) || (!$DEBUG && !movefinder)
        pbMessage(_INTL("You can't use the {1} yet.", GameData::Move.get(move).name))
        return false
      end
      if $game_screen.weather_type==:Fog
        if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_DEFOG, false) || (!$DEBUG && !movefinder)
          pbMessage(_INTL("This fog is very heavy. Could be defog with the right move"))
          return false
        end
        speciesname = (movefinder) ? movefinder.name : $player.name
        pbMessage(_INTL("{1} used {2}!", speciesname, GameData::Move.get(move).name))
        pbHiddenMoveAnimation(movefinder)
        $game_screen.weather(:None, 9, 20)
        Graphics.update
        Input.update
        pbUpdateSceneMap
        return true
      end
    end
    
    HiddenMoveHandlers::CanUseMove.add(:DEFOG, proc { |move, pkmn, showmsg|
      next false if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_DEFOG, false) || (!$DEBUG && !movefinder)
      move = :DEFOG
      if $game_screen.weather_type == :None
        pbMessage(_INTL("There is no fog to clear.")) if showmsg
        next false
      end
      if $game_screen.weather_type != :Fog
        pbMessage(_INTL("Can't use that here.")) if showmsg
        next false
      end
      next true
      })
    
    HiddenMoveHandlers::UseMove.add(:DEFOG, proc { |move, pokemon|
      fmDefog
      next true
      })
    
      #===============================================================================
    #                     Adds Rock Climbing to $PokemonGlobal
    #===============================================================================
    class PokemonGlobalMetadata
      attr_accessor :rockclimbing
    
      alias advanceditemsfieldmoves_init initialize
      def initialize
        advanceditemsfieldmoves_init
        @rockclimbing = false
      end
    end
    
    class Game_Character
      attr_accessor :always_on_top
    end
    
    def onoff?
      if $PokemonGlobal&.rockclimbing
        pbMessage(_INTL("surfing is ON!"))
        return false
      else
        pbMessage(_INTL("surfing is OFF!"))
      end
    end
    
    #===============================================================================
    #  Can Run? Rockclimb added to it
    #===============================================================================
    if PluginManager.findDirectory("v20.1 Hotfixes")
    class Game_Player < Game_Character
      def can_run?
        return @move_speed > 3 if @move_route_forcing
        return false if $game_temp.in_menu || $game_temp.in_battle ||
        $game_temp.message_window_showing || pbMapInterpreterRunning?
        return false if !$player.has_running_shoes && !$PokemonGlobal.diving &&
        !$PokemonGlobal.surfing && !$PokemonGlobal.bicycle || $PokemonGlobal.rockclimbing
        return false if jumping?
        return false if pbTerrainTag.must_walk
        return ($PokemonSystem.runstyle == 1) ^ Input.press?(Input::BACK)
      end
    
      def set_movement_type(type)
        meta = GameData::PlayerMetadata.get($player&.character_ID || 1)
        new_charset = nil
        case type
        when :fishing
          new_charset = pbGetPlayerCharset(meta.fish_charset)
        when :surf_fishing
          new_charset = pbGetPlayerCharset(meta.surf_fish_charset)
        when :diving, :diving_fast, :diving_jumping, :diving_stopped
          self.move_speed = 3 if !@move_route_forcing
          new_charset = pbGetPlayerCharset(meta.dive_charset)
        when :surfing, :surfing_fast, :surfing_jumping, :surfing_stopped
          if !@move_route_forcing
            self.move_speed = (type == :surfing_jumping) ? 3 : 4
          end
          new_charset = pbGetPlayerCharset(meta.surf_charset)
        when :rockclimbing, :rockclimbing_fast, :rockclimbing_jumping, :rockclimbing_stopped
          if !@move_route_forcing
            self.move_speed = 5
          end
          new_charset = pbGetPlayerCharset(meta.dive_charset)
        when :cycling, :cycling_fast, :cycling_jumping, :cycling_stopped
          if !@move_route_forcing
            self.move_speed = (type == :cycling_jumping) ? 3 : 5
          end
          new_charset = pbGetPlayerCharset(meta.cycle_charset)
        when :running
          self.move_speed = 4 if !@move_route_forcing
          new_charset = pbGetPlayerCharset(meta.run_charset)
        when :ice_sliding
          self.move_speed = 4 if !@move_route_forcing
          new_charset = pbGetPlayerCharset(meta.walk_charset)
        else   # :walking, :jumping, :walking_stopped
          self.move_speed = 3 if !@move_route_forcing
          new_charset = pbGetPlayerCharset(meta.walk_charset)
        end
        @character_name = new_charset if new_charset
      end
    
      def update_move
        if !@moved_last_frame || @stopped_last_frame   # Started a new step
          if pbTerrainTag.ice
            set_movement_type(:ice_sliding)
          else#if !@move_route_forcing
            faster = can_run?
            if $PokemonGlobal&.diving
              set_movement_type((faster) ? :diving_fast : :diving)
            elsif $PokemonGlobal&.surfing
              set_movement_type((faster) ? :surfing_fast : :surfing)
            elsif $PokemonGlobal&.rockclimbing
              set_movement_type((faster) ? :rockclimbing_fast : :rockclimbing)
            elsif $PokemonGlobal&.bicycle
              set_movement_type((faster) ? :cycling_fast : :cycling)
            else
              set_movement_type((faster) ? :running : :walking)
            end
          end
          if jumping?
            if $PokemonGlobal&.diving
              set_movement_type(:diving_jumping)
            elsif $PokemonGlobal&.surfing
              set_movement_type(:surfing_jumping)
            elsif $PokemonGlobal&.rockclimbing
              set_movement_type(:rockclimbing_jumping)
            elsif $PokemonGlobal&.bicycle
              set_movement_type(:cycling_jumping)
            else
              set_movement_type(:jumping)   # Walking speed/charset while jumping
            end
          end
        end
        super
      end
    
      def update_stop
        if @stopped_last_frame
          if $PokemonGlobal&.diving
            set_movement_type(:diving_stopped)
          elsif $PokemonGlobal&.surfing
            set_movement_type(:surfing_stopped)
          elsif $PokemonGlobal&.rockclimbing
            set_movement_type(:rockclimbing_stopped)
          elsif $PokemonGlobal&.bicycle
            set_movement_type(:cycling_stopped)
          else
            set_movement_type(:walking_stopped)
          end
        end
        super
      end
    
      def pbUpdateVehicle
        if $PokemonGlobal&.diving
          $game_player.set_movement_type(:diving)
        elsif $PokemonGlobal&.surfing
          $game_player.set_movement_type(:surfing)
        elsif $PokemonGlobal&.rockclimbing
          $game_player.set_movement_type(:rockclimbing)
        elsif $PokemonGlobal&.bicycle
          $game_player.set_movement_type(:cycling)
        else
          $game_player.set_movement_type(:walking)
        end
      end
    end
    end
     
    Back
    Top