From 207fcec5990f38d39d176c159bf1497c19b38b45 Mon Sep 17 00:00:00 2001 From: TheXaman Date: Sat, 25 Mar 2023 14:50:15 +0100 Subject: [PATCH] fixes teachable moves change from rhh --- include/party_menu.h | 4 ++ src/party_menu.c | 5 +++ src/pokedex.c | 96 ++++++++++++++------------------------------ 3 files changed, 39 insertions(+), 66 deletions(-) diff --git a/include/party_menu.h b/include/party_menu.h index 3a51ace84d..edb029b011 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -90,6 +90,10 @@ void BufferMoveDeleterNicknameAndMove(void); void GetNumMovesSelectedMonHas(void); void MoveDeleterChooseMoveToForget(void); +#ifndef BATTLE_ENGINE bool8 CanLearnTutorMove(u16, u8); +#else +u16 GetTMHMMoves(u16 position); +#endif #endif // GUARD_PARTY_MENU_H diff --git a/src/party_menu.c b/src/party_menu.c index b9cbe67393..71d259b5d6 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -6424,3 +6424,8 @@ void IsLastMonThatKnowsSurf(void) gSpecialVar_Result = TRUE; } } + +u16 GetTMHMMoves(u16 position) +{ + return sTMHMMoves[position]; +} diff --git a/src/pokedex.c b/src/pokedex.c index fbd6a4b805..01b3c2f4ad 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -142,7 +142,11 @@ static EWRAM_DATA u16 sLastSelectedPokemon = 0; static EWRAM_DATA u8 sPokeBallRotation = 0; static EWRAM_DATA struct PokedexListItem *sPokedexListItem = NULL; //Pokedex Plus HGSS_Ui +#ifndef BATTLE_ENGINE #define MOVES_COUNT_TOTAL (EGG_MOVES_ARRAY_COUNT + MAX_LEVEL_UP_MOVES + NUM_TECHNICAL_MACHINES + NUM_HIDDEN_MACHINES + TUTOR_MOVE_COUNT) +#else +#define MOVES_COUNT_TOTAL (EGG_MOVES_ARRAY_COUNT + MAX_LEVEL_UP_MOVES + NUM_TECHNICAL_MACHINES + NUM_HIDDEN_MACHINES + 20) +#endif EWRAM_DATA static u16 sStatsMoves[MOVES_COUNT_TOTAL] = {0}; EWRAM_DATA static u16 sStatsMovesTMHM_ID[NUM_TECHNICAL_MACHINES + NUM_HIDDEN_MACHINES] = {0}; @@ -5417,72 +5421,6 @@ static int DoPokedexSearch(u8 dexMode, u8 order, u8 abcGroup, u8 bodyColor, u8 t sPokedexView->pokemonListCount = resultsCount; } - // Search by move - if (move != 0xFFFF) - { - //Calc tutor move ID - tutorMoveId = 0xFF; - for (i = 0; i < TUTOR_MOVE_COUNT; i++) - { - if (move == gTutorMoves[i]) - { - tutorMoveId = i; - break; - } - } - //Calc tm move ID - tmMoveId = 0xFF; - for (i = 0; i < NUM_TECHNICAL_MACHINES + NUM_HIDDEN_MACHINES; i++) - { - if (move == ItemIdToBattleMoveId(ITEM_TM01_FOCUS_PUNCH + i)) - { - tmMoveId = (ITEM_TM01_FOCUS_PUNCH + i); - break; - } - } - - for (i = 0, resultsCount = 0; i < sPokedexView->pokemonListCount; i++) - { - species = NationalPokedexNumToSpecies(sPokedexView->pokedexList[i].dexNum); - - #ifdef POKEMON_EXPANSION - // Mega pokemon don't have distinct learnsets from their base form; so use base species for calculation - if (species >= SPECIES_VENUSAUR_MEGA && species <= SPECIES_GROUDON_PRIMAL) - species = GetFormSpeciesId(species, 0); - #endif - - //LevelUp - if (SpeciesCanLearnLvlUpMove(species, move)) - { - sPokedexView->pokedexList[resultsCount] = sPokedexView->pokedexList[i]; - resultsCount++; - continue; - } - //TMHM - if (CanSpeciesLearnTMHM(species, tmMoveId)) - { - sPokedexView->pokedexList[resultsCount] = sPokedexView->pokedexList[i]; - resultsCount++; - continue; - } - //Tutor - if (CanLearnTutorMove(species, tutorMoveId)) - { - sPokedexView->pokedexList[resultsCount] = sPokedexView->pokedexList[i]; - resultsCount++; - continue; - } - //EGGs - if (SpeciesCanLearnEggMove(species, move)) - { - sPokedexView->pokedexList[resultsCount] = sPokedexView->pokedexList[i]; - resultsCount++; - continue; - } - } - sPokedexView->pokemonListCount = resultsCount; - } - if (sPokedexView->pokemonListCount != 0) { for (i = sPokedexView->pokemonListCount; i < NATIONAL_DEX_COUNT; i++) @@ -6769,7 +6707,11 @@ static bool8 CalculateMoves(void) u16 statsMovesEgg[EGG_MOVES_ARRAY_COUNT] = {0}; u16 statsMovesLevelUp[MAX_LEVEL_UP_MOVES] = {0}; u16 statsMovesTMHM[NUM_TECHNICAL_MACHINES + NUM_HIDDEN_MACHINES] = {0}; + #ifndef BATTLE_ENGINE u16 statsMovesTutor[TUTOR_MOVE_COUNT] = {0}; + #else + u16 move; + #endif u8 numEggMoves = 0; u8 numLevelUpMoves = 0; @@ -6802,6 +6744,7 @@ static bool8 CalculateMoves(void) movesTotal++; } + #ifndef BATTLE_ENGINE //TMHM moves for (j = 0; j < NUM_TECHNICAL_MACHINES + NUM_HIDDEN_MACHINES; j++) { @@ -6824,6 +6767,27 @@ static bool8 CalculateMoves(void) movesTotal++; } } + #else + for (i = 0; gTeachableLearnsets[species][i] != MOVE_UNAVAILABLE; i++) + { + move = gTeachableLearnsets[species][i]; + for (j = 0; j < NUM_TECHNICAL_MACHINES + NUM_HIDDEN_MACHINES; j++) + { + if (GetTMHMMoves(j) == move) + { + sStatsMovesTMHM_ID[numTMHMMoves] = (ITEM_TM01_FOCUS_PUNCH + j); + numTMHMMoves++; + break; + } + } + if (j >= NUM_TECHNICAL_MACHINES + NUM_HIDDEN_MACHINES) + numTutorMoves++; + + sStatsMoves[movesTotal] = move; + movesTotal++; + } + + #endif sPokedexView->numEggMoves = numEggMoves; sPokedexView->numLevelUpMoves = numLevelUpMoves;