• 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!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll 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] Terrain OnlyBike

  • 13
    Posts
    2
    Years
    • Seen Sep 17, 2022
    I have created a new terrain where you can only pass if you have a bicycle on. Too bad he knows how to declare and I therefore only have the ground created which does nothing.

    Code:
    module GameData
      class TerrainTag
        attr_reader :only_bike
        def initialize(hash)
          @only_bike              = hash[:only_bike]     || false
        end
      end
    end
    
    GameData::TerrainTag.register({
      :id                     => :OnlyBike,
      :id_number              => 18,
      :bridge                 => true,
      :only_bike              => true
    })

    Anyone so kind who can take a few minutes to help me? if you want I pay you :(
     
    Are you on version 20? The steps would be basically the same regardless, since the trick is copying the must_walk terrain tag property.
    Also great work doing some of the job by yourself! Learning scripting is a lot of experimenting, and I'm glad you gave it a fair shake before asking for help. :)

    Our first step is heading to def playerPassable? in Script section Game_Map. You should already see the bit of code that prevents cycling on tags that force you to walk.
    Code:
            # Prevent cycling in really tall grass/on ice
            return false if $PokemonGlobal.bicycle && terrain.must_walk
    We just need to make a copy, that prevents you from going on a bike only tile without being on a bike.
    Code:
            # Prevent walking on a bike only tile
            return false if !$PokemonGlobal.bicycle && terrain.only_bike
    We also need to edit def pbBikeCheck to prevent you from dismounting on a bike only tile.
    Code:
      if $PokemonGlobal.bicycle
        if map_metadata&.always_bicycle || $game_player.pbTerrainTag.only_bike # edit this line
          pbMessage(_INTL("You can't dismount your Bike here."))
          return false
        end
        return true
      end
    If you ended up doing a full section search (CTRL+SHIFT+F) for must_walk, you may see I ignored a spot, the run check. It's not relevant, because you can't run on a bike anyways.
     
    Are you on version 20? The steps would be basically the same regardless, since the trick is copying the must_walk terrain tag property.
    Also great work doing some of the job by yourself! Learning scripting is a lot of experimenting, and I'm glad you gave it a fair shake before asking for help. :)

    Our first step is heading to def playerPassable? in Script section Game_Map. You should already see the bit of code that prevents cycling on tags that force you to walk.
    Code:
            # Prevent cycling in really tall grass/on ice
            return false if $PokemonGlobal.bicycle && terrain.must_walk
    We just need to make a copy, that prevents you from going on a bike only tile without being on a bike.
    Code:
            # Prevent walking on a bike only tile
            return false if !$PokemonGlobal.bicycle && terrain.only_bike
    We also need to edit def pbBikeCheck to prevent you from dismounting on a bike only tile.
    Code:
      if $PokemonGlobal.bicycle
        if map_metadata&.always_bicycle || $game_player.pbTerrainTag.only_bike # edit this line
          pbMessage(_INTL("You can't dismount your Bike here."))
          return false
        end
        return true
      end
    If you ended up doing a full section search (CTRL+SHIFT+F) for must_walk, you may see I ignored a spot, the run check. It's not relevant, because you can't run on a bike anyways.

    I am a newbie on pokemon essentials and I had never dealt with ruby, very difficult as a language but I would like to understand more. Yes, I am with essentials 20.1.

    Thank you very much for helping. For an hour I was going crazy because it didn't work for me ... while I was about to send a message after making several attempts I tried to remove
    Code:
    :bridge => true
    from the terrain registration and it worked perfectly. If I may ask how can I do the same for the bridge if I wanted to create "OnlyBikeBridge" terrain?

    P.S I am using your "Deep Marsh Tiles" scripts (even if it is the updated version) and it is really great, it really deserves a lot and I would also make a donation if I could.
     
    Back
    Top