• 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.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Cyndy, May, Hero (Conquest), or Wes - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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.

[Script] How to tell if player is riding a bicycle? [SOLVED]

If you're hacking FR, you can tell whether the player is on a bike by using the speed value assigned to the player, detailed here by knizz. Here's a simple script will take the speed value and place it into variable 0x8000, allowing you to check it without having to make a custom ASM routine:

Code:
#dynamic 0x800000

#org @start
setvar 0x8000 0x0
copybyte 0x020370B8 0x02037078
compare 0x8000 0x2
if 0x1 goto @OnBicycle
compare 0x8000 0x22
if 0x1 goto @OnBicycle
goto @Walking

We're checking for values of 0x2 and 0x22 as its the second halfbyte that determines how fast you're going. If you use the bike via the bag or enter a new map the speed value will be set to 0x22, but change to 0x2 after a single step. If you use the bike via the select button it will automatically be set to 0x2.

There's probably an easier way to check whether the player is on a bike, but this method works just fine.
 
Thanks a lot, tested your code and it works.

Do you know if there's a way to dismount the bike with code? I did a little bit of research and special 0x157 is used to get on the bicycle, but it doesn't work other way around (can't call that special to get off the bike).

GOT IT TO WORK!

#org @OnBike
writebytetooffset 0x1 0x02037079
playsong 0x135 0x0
release
end

This seems to work like just a regular dismount. Without the playsong, the bike music still plays.
However, the dismount doesn't seem to happen until after the script ends, so it can't happen mid-script. Maybe there's some way around this idk.
 
Last edited:
Back
Top