summaryrefslogtreecommitdiff
path: root/Infinite-TM-usage.md
blob: eb885f0be5610491a7973ed1ec7b48049782d95f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Credit to paccy for this tutorial in the Simple Modifications Pokecommunity thread.

This tutorial will make all TMs infinitely reusable, unholdable by Pokemon, unsellable to shops, and also removes the number from appearing in the Bag.

## Contents
1. [Don't consume TMs on use](#1-dont-consumes-tms-on-use)
2. [Treat TMs as HMs in the bag](#2-treat-tms-as-hms-in-the-bag)

## 1. Don't consume TMs on use
Normally, the game checks if the item used was a TM or an HM, and consumes the item if it was a TM. We can just simply remove this check.

Edit [src/party_menu.c](../blob/master/src/party_menu.c): 
```diff
static void Task_LearnedMove(u8 taskId)
{
    struct Pokemon *mon = &gPlayerParty[gPartyMenu.slotId];
    s16 *move = &gPartyMenu.data1;
    u16 item = gSpecialVar_ItemId;

    if (move[1] == 0)
    {
        AdjustFriendship(mon, FRIENDSHIP_EVENT_LEARN_TMHM);
-       if (item < ITEM_HM01_CUT)
-           RemoveBagItem(item, 1);
    }
    GetMonNickname(mon, gStringVar1);
    StringCopy(gStringVar2, gMoveNames[move[0]]);
    StringExpandPlaceholders(gStringVar4, gText_PkmnLearnedMove3);
    DisplayPartyMenuMessage(gStringVar4, TRUE);
    schedule_bg_copy_tilemap_to_vram(2);
    gTasks[taskId].func = Task_DoLearnedMoveFanfareAfterText;
}
```
If you were to stop here, TMs can still be given to Pokemon and you can still see the number in the bag. The next step will address this.
## 2. Treat TMs as HMs in the bag
`struct Item` has a field `importance`. If this field has a nonzero value, then the item is treated like a key item, and cannot be held, tossed, or deposited in the PC, and it will not display an item count in the bag. Furthermore, items with a price of 0 cannot be sold.

Edit [src/data/items.h](../blob/master/src/data/items.h):
```diff
    [ITEM_TM01_FOCUS_PUNCH] =
    {
        .name = _("TM01"),
        .itemId = ITEM_TM01_FOCUS_PUNCH,
-       .price = 3000,
+       .price = 0,
        .description = sTM01Desc,
+       .importance = 1,
        .pocket = POCKET_TM_HM,
        .type = 1,
        .fieldUseFunc = ItemUseOutOfBattle_TMHM,
        .secondaryId = 0,
    },
```
You will need to repeat the above for every TM.

And that's it!

![](https://i.imgur.com/KwzzUSm.png)

Notes: Pokemon will replenish their PP if a TM move is forgotten and relearned.