Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reworked TMHM into expandable list format #2233

Merged
merged 10 commits into from
Aug 29, 2022
5 changes: 3 additions & 2 deletions include/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ extern const struct BaseStats gBaseStats[];
extern const u8 *const gItemEffectTable[];
extern const u32 gExperienceTables[][MAX_LEVEL + 1];
extern const struct LevelUpMove *const gLevelUpLearnsets[];
extern const u16 *const gTMHMLearnsets[];
extern const u8 gPPUpGetMask[];
extern const u8 gPPUpClearMask[];
extern const u8 gPPUpAddValues[];
Expand Down Expand Up @@ -509,8 +510,8 @@ u8 CheckPartyHasHadPokerus(struct Pokemon *party, u8 selection);
void UpdatePartyPokerusTime(u16 days);
void PartySpreadPokerus(struct Pokemon *party);
bool8 TryIncrementMonLevel(struct Pokemon *mon);
u32 CanMonLearnTMHM(struct Pokemon *mon, u8 tm);
u32 CanSpeciesLearnTMHM(u16 species, u8 tm);
u32 CanMonLearnTMHM(struct Pokemon *mon, u16 move);
u32 CanSpeciesLearnTMHM(u16 species, u16 move);
u8 GetMoveRelearnerMoves(struct Pokemon *mon, u16 *moves);
u8 GetLevelUpMovesBySpecies(u16 species, u16 *moves);
u8 GetNumberOfRelearnableMoves(struct Pokemon *mon);
Expand Down
2 changes: 1 addition & 1 deletion src/apprentice.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ static u16 GetRandomAlternateMove(u8 monId)
do
{
id = Random() % (NUM_TECHNICAL_MACHINES + NUM_HIDDEN_MACHINES);
shouldUseMove = CanSpeciesLearnTMHM(species, id);
shouldUseMove = CanSpeciesLearnTMHM(species, ItemIdToBattleMoveId(ITEM_TM01 + id));
}
while (!shouldUseMove);

Expand Down
1,279 changes: 1,279 additions & 0 deletions src/data/pokemon/tmhm_learnset_pointers.h

Large diffs are not rendered by default.

52,858 changes: 28,111 additions & 24,747 deletions src/data/pokemon/tmhm_learnsets.h

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/daycare.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,8 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru
{
for (j = 0; j < NUM_TECHNICAL_MACHINES + NUM_HIDDEN_MACHINES; j++)
{
if (sHatchedEggFatherMoves[i] == ItemIdToBattleMoveId(ITEM_TM01_FOCUS_PUNCH + j) && CanMonLearnTMHM(egg, j))
u16 moveId = ItemIdToBattleMoveId(ITEM_TM01_FOCUS_PUNCH + j);
gruxor marked this conversation as resolved.
Show resolved Hide resolved
if (sHatchedEggFatherMoves[i] == moveId && CanMonLearnTMHM(egg, moveId))
{
if (GiveMoveToMon(egg, sHatchedEggFatherMoves[i]) == MON_HAS_MAX_MOVES)
DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggFatherMoves[i]);
Expand Down
2 changes: 1 addition & 1 deletion src/party_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2038,7 +2038,7 @@ static u8 CanMonLearnTMTutor(struct Pokemon *mon, u16 item, u8 tutor)

if (item >= ITEM_TM01)
{
if (!CanMonLearnTMHM(mon, item - ITEM_TM01 - ((item > ITEM_TM100) ? 50 : 0)))
if (!CanMonLearnTMHM(mon, ItemIdToBattleMoveId(item)))
return CANNOT_LEARN_MOVE;
else
move = ItemIdToBattleMoveId(item);
Expand Down
42 changes: 23 additions & 19 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1890,17 +1890,18 @@ const s8 gNatureStatTable[NUM_NATURES][NUM_NATURE_STATS] =
[NATURE_QUIRKY] = { 0, 0, 0, 0, 0},
};

#include "data/pokemon/tmhm_learnsets.h"
#include "data/pokemon/trainer_class_lookups.h"
#include "data/pokemon/experience_tables.h"
#include "data/pokemon/base_stats.h"
#include "data/pokemon/level_up_learnsets.h"
#include "data/pokemon/tmhm_learnsets.h"
gruxor marked this conversation as resolved.
Show resolved Hide resolved
#if P_NEW_POKEMON == TRUE
#include "data/pokemon/evolution.h"
#else
#include "data/pokemon/evolution_old.h"
#endif
#include "data/pokemon/level_up_learnset_pointers.h"
#include "data/pokemon/tmhm_learnset_pointers.h"
#include "data/pokemon/form_species_tables.h"
#include "data/pokemon/form_species_table_pointers.h"
#include "data/pokemon/form_change_tables.h"
Expand Down Expand Up @@ -7243,40 +7244,43 @@ bool8 TryIncrementMonLevel(struct Pokemon *mon)
}
}

u32 CanMonLearnTMHM(struct Pokemon *mon, u8 tm)
u32 CanMonLearnTMHM(struct Pokemon *mon, u16 move)
{
u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0);
gruxor marked this conversation as resolved.
Show resolved Hide resolved

if (species == SPECIES_EGG)
{
return 0;
}
else if (tm < 32)
{
u32 mask = 1 << tm;
return gTMHMLearnsets[species][0] & mask;
return FALSE;
}
else
{
u32 mask = 1 << (tm - 32);
return gTMHMLearnsets[species][1] & mask;
u32 i;
for (i = 0; gTMHMLearnsets[species][i] != MOVE_UNAVAILABLE; i++)
{
if (gTMHMLearnsets[species][i] == move) {
return TRUE;
}
}
return FALSE;
}
}

u32 CanSpeciesLearnTMHM(u16 species, u8 tm)
u32 CanSpeciesLearnTMHM(u16 species, u16 move)
{
if (species == SPECIES_EGG)
{
return 0;
}
else if (tm < 32)
{
u32 mask = 1 << tm;
return gTMHMLearnsets[species][0] & mask;
return FALSE;
}
else
{
u32 mask = 1 << (tm - 32);
return gTMHMLearnsets[species][1] & mask;
u32 i;
for (i = 0; gTMHMLearnsets[species][i] != MOVE_UNAVAILABLE; i++)
{
if (gTMHMLearnsets[species][i] == move) {
return TRUE;
}
}
return FALSE;
}
}

Expand Down