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

[Pokeemerald] Follow Me

239
Posts
8
Years
    • Seen Apr 15, 2024
    Follow Me
    This feature was ported from the CFRU, allowing you to add NPC followers to the player.

    sHoHjxh.gif
    TiFG6Zb.gif
    IhjXL3B.gif
    jRnha2N.gif


    Setup
    1. Pull from my branch (see spoiler for more detail)
      Spoiler:
    2. Update gFollowerAlternateSprites with graphics Ids for your followers. The general structure is:
      • normalId - the graphics Id of the regular NPC (just standing or walking around or whatever)
      • machBikeId - the mach bike sprites (if applicable - see Step 4)
      • acroBikeId - the acro bike sprites (if applicable - see Step 4)
      • surfId - surfing sprites graphics Id (if applicable - see Step 4)
      • underwaterId - diving sprites graphics Id (if applicable - see Step 4)
      • Example - May sprite in the GIFs:
        Spoiler:
    3. If you have sideways stairs implemented, set SIDEWAYS_STAIRS_IMPLEMENTED to TRUE in include/constants/global.h
    4. Four new scripting commands are added: (see asm/macros/event.inc for more info)
      • setfollower - sets up an NPC to follow you. Takes a byte argument for the NPCs local Id and 2 bytes for the follower flags (see step 4)
      • destroyfollower - stop the NPC from following you.
      • facefollower - player and follower face one another
      • checkfollower - checks if you have a follower, returns the result to VAR_RESULT
    5. Follower Flags: (see include/constants/follow_me.h)
      • FOLLOWER_FLAG_HAS_RUNNING_FRAMES - follower has specific frames used when running. Otherwise they will walk fast behind you when you run.
      • FOLLOWER_FLAG_CAN_BIKE - follower has mach/acro biking frames in gFollowerAlternateSprites. If not set, you cannot bike.
      • FOLLOWER_FLAG_CAN_LEAVE_ROUTE - you can use teleport / dig / fly / etc. The follower will follow you when you use these field moves. The follower can travel between routes even if not set.
      • FOLLOWER_FLAG_CAN_SURF - the follower has surfing graphics defined in gFollowerAlternateSprites. Otherwise, you cannot Surf.
      • FOLLOWER_FLAG_CAN_WATERFALL - the follower can follow you up waterfalls. Otherwise, you cannot use Waterfall.
      • FOLLOWER_FLAG_CAN_DIVE - the follower has a diving graphics Id defined in gFollowerAlternateSprites. It will follow you underwater. Otherwise you cannot use Dive.
      • FOLLOWER_FLAG_CAN_ROCK_CLIMB - unused (no rock climb in the base game), but similar to the previous field move defines.
      • FOLLOWER_FLAG_CLEAR_ON_WHITE_OUT - remove the follower if the player whites out.
      • FOLLOWER_FLAG_CUSTOM_FOLLOW_SCRIPT - a unique script is run when you talk to the follower whilst they are following you. Requires loading the script (via loadword) prior to the command setfollower).

    For example, here's an example for adding a follower with a new script:
    Code:
    SetFollower::
        lock
        faceplayer
        loadword 0 NewScript
        setfollower 1 0x100   @ cause NPC (local ID = 1) to follow you with a custom following script
        release
        end
    
    NewScript:
        msgbox FollowYou MSGBOX_SIGN
        end
    FollowYou:
        .string "I'll keep following you!$"
    USZcFgh.gif


    Finally, you can also use the followers in scripts using the local Id, OBJ_EVENT_ID_FOLLOWER like so:
    Code:
    EventScript_Test::
        lock
        turnobject OBJ_EVENT_ID_FOLLOWER, DIR_NORTH
        @ etc

    Known Issues:
    • If you take a follower into a map with the maximum number of event objects, your follower may inherit a different palette and/or get directionally confused. Fortunately, since we are using decomps, we can easily increase the value of OBJECT_EVENTS_COUNT. This doesn't resolve the 16 palette gba limit, though.
    • Sometimes the follower's surf blob won't appear until a menu is entered/exited

    Credits:
    Skeli / Complete Fire Red Upgrade
    Touched for original source
     
    Last edited:
    36
    Posts
    13
    Years
  • Hmm... when I save and reload my game, my follower will no longer follow me. How could I fix that?

    You'll need to start adding features to the save block for this. As a general idea to get you started, I've had success with adding members to the end of the SaveBlock2 struct (others might work just as well, but I haven't tried them yet). This is accessed through gSaveBlock2Ptr. You might want to keep the new member updated with the current follower data and – possibly the trickier bit – find a good area of game-loading code to read this follower data and re-initiate it as needed.
     
    239
    Posts
    8
    Years
    • Seen Apr 15, 2024
    Hmm... when I save and reload my game, my follower will no longer follow me. How could I fix that?

    I've fixed this saving issue (for basic testing on various maps, at least). You'll need to pull again to get the updated code.
     

    NielsM

    BSBob
    12
    Posts
    7
    Years
  • This could be a stupid question to ask, but where would I find gFollowerAlternateSprites?
    Also, I am getting this weird behaviour: imgur.com/a/4ey9VoN

    Is it possible that it could be incompatible with each other somehow or am I missing something else?

    Thanks in advance!
     
    239
    Posts
    8
    Years
    • Seen Apr 15, 2024
    This could be a stupid question to ask, but where would I find gFollowerAlternateSprites?
    Also, I am getting this weird behaviour: imgur.com/a/4ey9VoN

    Is it possible that it could be incompatible with each other somehow or am I missing something else?

    Thanks in advance!

    gAlternateSprites can be found on line 78 of src/follow_me.c

    I'm not sure what's causing the weird item description header. I'll have to look into that. Thanks for reporting the issue :)
     
    50
    Posts
    6
    Years
    • Seen Oct 20, 2023
    Looks fantastic, but there is a syntacts error in Ghoulslash follow-me branch after the update. In src/new_game.c line 210

    Code:
    memset(gSaveBlock2Ptr-follower, 0, sizeof(gSaveBlock2Ptr-follower));

    After changing '-' tot '->' the compiler says

    Code:
    src/new_game.c: In function `NewGameInitData':
    src/new_game.c:210: incompatible type for argument 1 of `memset'
    Makefile:250: recipe for target 'build/emerald/src/new_game.o' failed

    Code looks pretty consistent with other memset calls I have seen, and have no idea how to fix this. Does someone mind to take a look?
     

    NielsM

    BSBob
    12
    Posts
    7
    Years
  • I've found some more weird behaviour, so I figured to report it to you again.

    I've made two gifs visualizing the problem: https://imgur.com/a/NjpweIz

    Hopefully you'll be able to fix it with this information, and if you need more I'll try to elaborate :)
     
    239
    Posts
    8
    Years
    • Seen Apr 15, 2024
    I've found some more weird behaviour, so I figured to report it to you again.

    I've made two gifs visualizing the problem: https://imgur.com/a/NjpweIz

    Hopefully you'll be able to fix it with this information, and if you need more I'll try to elaborate :)

    The sideways stairs new movement actions need to be added, which is on my list. The odd door behavior I will look into. Thanks for reporting :)
     
    239
    Posts
    8
    Years
    • Seen Apr 15, 2024
    I've found some more weird behaviour, so I figured to report it to you again.

    I've made two gifs visualizing the problem: https://imgur.com/a/NjpweIz

    Hopefully you'll be able to fix it with this information, and if you need more I'll try to elaborate :)

    Both of these issues have been fixed with the last two commits. Note that you need SIDEWAYS_STAIRS_IMPLEMENTED in include/constants/global.h for the sideways stairs follower code to work.
     

    NielsM

    BSBob
    12
    Posts
    7
    Years
  • How would i be able to use the follower in a script?
    I can't seem to find the follower's objectId anywhere...

    Is it like a fixed value, just like the player or does it work different?
     
    239
    Posts
    8
    Years
    • Seen Apr 15, 2024
    How would i be able to use the follower in a script?
    I can't seem to find the follower's objectId anywhere...

    Is it like a fixed value, just like the player or does it work different?

    The function GetFollowerLocalId returns the local Id of the follower. I just added a special LoadFollowerLocalId to return this value to VAR_0x8005, so you could do something like:
    Code:
    special LoadFollowerLocalId
    turnobject VAR_0x8005, DIR_SOUTH

    This might only work on the map the follower originated from, though.
     
    Last edited:

    NielsM

    BSBob
    12
    Posts
    7
    Years
  • The function GetFollowerLocalId returns the local Id of the follower. I just added a special LoadFollowerLocalId to return this value to VAR_0x8005, so you could do something like:
    Code:
    special LoadFollowerLocalId
    turnobject VAR_0x8005, DIR_SOUTH

    This might only work on the map the follower originated from, though.

    The special you've made doesn't seem to work, I used the special on an NPC while having a follower and nothing happened when I interacted with the NPC.
    I simply heard the default bleep sound, but nothing more.
     
    Last edited:
    239
    Posts
    8
    Years
    • Seen Apr 15, 2024
    The special you've made doesn't seem to work, I used the special on an NPC while having a follower and nothing happened when I interacted with the NPC.
    I simply heard the default bleep sound, but nothing more.

    Hm. Alright, I'll have to look into this in more detail, then. Thanks for bringing it to my attention!
     
    239
    Posts
    8
    Years
    • Seen Apr 15, 2024
    How would i be able to use the follower in a script?
    I can't seem to find the follower's objectId anywhere...

    Is it like a fixed value, just like the player or does it work different?

    I've updated the main post to include instructions on how to include followers in scripts. Basically, the local Id in scripting commands should be OBJ_EVENT_ID_FOLLOWER
     
    3
    Posts
    3
    Years
    • Seen Nov 17, 2021
    Very cool stuff!
    I noticed an issue in Pokecenters when healing pokemon, the follower's palettes seem to be affected during the pokeball glowing animation, is there a way to prevent this from happening? Or is it just my project? thanks in advance.
     
    Back
    Top