• 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?".
  • A reminder that our new forum software has 2FA! It can be accessed by clicking your username and then "Password and security" from the menu. We strongly suggest not reusing passwords for your online accounts and enabling 2FA if possible.
  • Welcome to PokéCommunity! Register now and join one of the best places on the 'net to talk Pokémon and more! Community members will not see the bottom screen advertisements.
  • Want to share your adventures playing Pokémon?
    Check out our new Travel Journals forum for sharing playthroughs of ROM Hacks, Fan Games, and other Pokémon content!
  • IMPORTANT: Following a takedown request, the following hacks have been delisted from PokéCommunity:

    • Pokémon Glazed
    • Pokémon: Giratina Strikes Back
    • Pokémon Flora Sky
    • Pokémon Stranded
    The downloads and discussion threads for these hacks will no longer be accessible, and staff will be unable to return questions regarding accessing this content.

[Battle✓] [pokeemerald] How Viable Is Adding New TMs and HMs Beyond TM50? (51-100)

BrandoSheriff

Has a tendency to figure things out
776
Posts
16
Years
Hi, I was experimenting with adding new TMs earlier. I noticed that the pokeemerald-expansion has skeleton data for 50 extra TM slots, so I thought to try and use them to add some new ones. I started with 10 of them, up to TM60, and they seem to work just fine for now? Game builds, and I can get them and teach them.
kOxmUJ.png

7C3tpD.png

(Don't mind the eff'd up palettes for the Pokemon icons, I'm still trying to figure out how to fix those lol)

Though I kinda want to know how possible it is to add new HMs effectively? I tried to add a new HM09 through the same method:
wU48sB.png
bF4LOV.png

But in doing so it shows in-game as a "HM No?" instead of "HM No9", plus if I give myself all TMs through debug, it doesn't display the last 5 HMs (including my added HM09) and I can't even access them either. I can't seem to find a fix for this.

Am I missing something? What makes those last few HMs not display?

EDIT: Ok since the time of making this post I found that I could go into include\constants\global.h and change the #define BAG_TMHM_COUNT from 64 to 69, and the remaining 5 missing HMs now show up. I did have to start a new save file however to see the changes. Are there any repercussions to changing this value? Also to note that the HM09 still shows up as "HM No?" and I can't figure out how to make the 9 show up.
 
Last edited:
180
Posts
6
Years
  • Age 20
  • Seen Sep 29, 2023
You'll have to check the way the TM case reads and displays the names of TMs and HMs. Usually, the way it does it, is by the following formula:
Code:
itemId - ITEM_HM01 + 1
Which basically converts the HM's item id into an HM id. Your HM's ID is 799, the HM01's ID is 682. So the actual number it's trying to display is 118. (799-682+1)
This means that you'll either have to put your HM where all HMs are in the items.h file, or create a special case like:
Code:
if (itemId >= ITEM_HM08_ROCK_CLIMB)
			ConvertIntToDecimalStringN(gStringVar1, itemId - ITEM_HM08_ROCK_CLIMB + 8, STR_CONV_MODE_LEADING_ZEROS, 2);
		else 
			ConvertIntToDecimalStringN(gStringVar1, itemId - ITEM_HM01 + 1, STR_CONV_MODE_LEADING_ZEROS, 1);
Inside of "tm_case.c" and the function "GetTMNumberAndMoveString(u8 * dest, u16 itemId)" so that any new HMs you add won't break when added.
What this will do is check if the HM's ID is equal or bigger than HM08's and then substract its ID to the itemId variable (so that way if they're the same, the result will be 0, if itemId is bigger by 2, it'll be 2, etc) and then we add 8, so that way we're still numbering the HMs where we left off.
 

Lunos

Random Uruguayan User
3,106
Posts
15
Years
Though I kinda want to know how possible it is to add new HMs effectively? I tried to add a new HM09 through the same method:
-Snip-
But in doing so it shows in-game as a "HM No?" instead of "HM No9", plus if I give myself all TMs through debug, it doesn't display the last 5 HMs (including my added HM09) and I can't even access them either. I can't seem to find a fix for this.

Am I missing something? What makes those last few HMs not display?
You should always make sure to add whatever new TM and/or HM you decide to implement consecutively. That is, after the existing ones. All TMs should be defined together, and all HM should be defined together.
The sTMHMMoves array where you're specifying the moves connected to the different TM expects TMs and HMs to be defined like that in order to work properly.
I'd suggest to do this because the solution Diego provided feels rather hacky, personally.

As for the code in the debug menu, the "Give All TMs" option performs a loop that starts with ITEM_TM01 and ends in ITEM_HM08.
That's the reason why it's not giving you all the new items.
https://github.com/rh-hideout/pokeemerald-expansion/blob/master/src/debug.c#L2005
You'll have to keep in mind the order of your HMs when you decide to fix this, if you decide to leave the HM09 you added as the 799th item in your game.
EDIT: Ok since the time of making this post I found that I could go into include\constants\global.h and change the #define BAG_TMHM_COUNT from 64 to 69, and the remaining 5 missing HMs now show up. I did have to start a new save file however to see the changes. Are there any repercussions to changing this value? Also to note that the HM09 still shows up as "HM No?" and I can't figure out how to make the 9 show up.
BAG_TMHM_COUNT is the constant that handles the number of items that the Player can store in the TM/HM pocket of the bag.
The size of this constant is directly connected to the contents of the game's savefile, more specifically, to bagPocket_TMHM which is a pointer for the struct Item sitting in the SaveBlock1.
Whenever you increase the value of that constant, you're actively making use of the space inside of the SaveBlock1.
This is also the reason why you had to start a new savefile, because by expanding the size of the pointer, everything below it inside of the savefile was shifted in terms of position.

You have to be mindful of the free space inside of the savefile's structs (the debug menu has an option to check it btw) whenever you make changes to them.

It's worth noting that you can make space in the structs stored in the savefile by removing variables or pointers related to mechanics that you may not need, and there's a little trick that gives you space for free too.
https://github.com/pret/pokeemerald/wiki/Extra-save-space-with-two-lines-of-code
https://github.com/pret/pokeemerald/compare/master...ghoulslash:pokeemerald:saveblock
 

BrandoSheriff

Has a tendency to figure things out
776
Posts
16
Years
You should always make sure to add whatever new TM and/or HM you decide to implement consecutively. That is, after the existing ones. All TMs should be defined together, and all HM should be defined together.
The sTMHMMoves array where you're specifying the moves connected to the different TM expects TMs and HMs to be defined like that in order to work properly.
I'd suggest to do this because the solution Diego provided feels rather hacky, personally.

As for the code in the debug menu, the "Give All TMs" option performs a loop that starts with ITEM_TM01 and ends in ITEM_HM08.
That's the reason why it's not giving you all the new items.
https://github.com/rh-hideout/pokeemerald-expansion/blob/master/src/debug.c#L2005
You'll have to keep in mind the order of your HMs when you decide to fix this, if you decide to leave the HM09 you added as the 799th item in your game.

Gotcha, I'll just move the new HM to be with the rest. I wasn't too sure if its position mattered, and I only really added the new HM at the bottom because I didn't wanna increment all the subsequent items lol. And upon testing it, the 9 does in fact show up perfectly now! Nice!

Thanks for the SaveBlock1 debug menu tip and for the links, I'll be having those bookmarked for when I need them!
 
Back
Top