Infinite Use TMs - pret/pokered GitHub Wiki

This tutorial will show how to have TMs be infinite use in game.

First we need to go into where using TMs are stored. Go into Engine/Items/Item_Effects.asm.

Around line 2298 you should see .checkIfAlreadyLearnedMove. This is showing a portion of the code that allows the Pokemon to learn the move. After it learns the move, it removes it. So we need to remove the code that checks for it next. Remove the lines and just "ret" it instead.

.checkIfAlreadyLearnedMove
    callfar CheckIfMoveIsKnown ; check if the pokemon already knows the move
    jr c, .chooseMon
    predef LearnMove ; teach move
    pop af
    ld [wCurItem], a
    pop af
    ld [wWhichPokemon], a
-   ld a, b
-   and a
-   ret z
-   ld a, [wCurItem]
-   call IsItemHM
-   ret c
-   jp RemoveUsedItem
+   ret

And now you should have infinite TM use in game.

OPTIONAL: Making TMs Key Items.

NOTE: It's not recommended doing this without increasing both Bag and PC item capacity first. Without modifications item capacity is 70 between both bag and PC. Making all TMs key items would made them not be allowed to be thrown so at some point the player will only be holding key items and be unable to pick anything else up.

Credit: Vortiene for helping Bowser288 with this

Around line 2616 you should see IsKeyItem_::. This is showing a portion of the code that is defining how most items being defined as Key Items. TMs and HMs are included in a portion of this. Make these changes to have TMs be Key Items..

IsKeyItem_::
    ld a, $01
    ld [wIsKeyItem], a
    ld a, [wCurItem]
    cp HM01 ; is the item an HM or TM?
-   jr nc, .checkIfItemIsHM
+   ret nc
; if the item is not an HM or TM
    push af
    ld hl, KeyItemFlags
    ld de, wBuffer
    ld bc, 15 ; only 11 bytes are actually used
    ASSERT 15 >= (NUM_ITEMS + 7) / 8
    rst _CopyData
    pop af
    dec a
    ld c, a
    ld hl, wBuffer
    ld b, FLAG_TEST
    predef FlagActionPredef
    ld a, c
    and a
    ret nz
-.checkIfItemIsHM
-   ld a, [wCurItem]
-   call IsItemHM
-   ret c
    xor a
    ld [wIsKeyItem], a
    ret