The PokéCommunity Forums Fan Games ROM Hacking Help
Script How to tell if player is riding a bicycle? [SOLVED]

ROM Hacking Help Need a helping hand? You can get help on any ROM Hacking-related problems or questions you have here.

Reply
 
Thread Tools
  #1    
Old May 11th, 2018 (9:46 AM). Edited May 12th, 2018 by Sakakii.
Sakakii's Avatar
Sakakii Sakakii is online now
     
    Join Date: Nov 2017
    Posts: 106
    Hello, does anyone know how to tell if the players is on their bike or not?

    This would make one of my scripts smoother.
    Reply With Quote
      #2    
    Old May 11th, 2018 (7:27 PM).
    DrFuji's Avatar
    DrFuji DrFuji is online now
    Heiki Hecchara‌‌
     
    Join Date: Sep 2009
    Location: Aussie
    Age: 25
    Gender: Male
    Nature: Jolly
    Posts: 1,467
    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.
    __________________
    Reply With Quote
      #3    
    Old May 12th, 2018 (3:22 AM). Edited May 12th, 2018 by Sakakii.
    Sakakii's Avatar
    Sakakii Sakakii is online now
       
      Join Date: Nov 2017
      Posts: 106
      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!

      Quote:
      #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.
      Reply With Quote
      Reply

      Quick Reply

      Join the conversation!

      Create an account to post a reply in this thread, participate in other discussions, and more!

      Create a PokéCommunity Account
      Thread Tools

      Posting Rules
      You may not post new threads
      You may not post replies
      You may not post attachments
      You may not edit your posts

      BB code is On
      Smilies are On
      [IMG] code is On
      HTML code is Off

      Forum Jump


      All times are GMT -8. The time now is 1:46 PM.