From 27661e02ebb64ae80efb71e64d13f2819aa5e9f3 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 19 Jan 2023 15:09:26 -0500 Subject: [PATCH 01/15] add battle pyramid wild reqs --- include/constants/wild_encounter.h | 2 + src/battle_pyramid.c | 207 ++++++++++++++- .../battle_pyramid_wild_requirements.h | 236 ++++++++++++++++++ 3 files changed, 443 insertions(+), 2 deletions(-) create mode 100644 src/data/battle_frontier/battle_pyramid_wild_requirements.h diff --git a/include/constants/wild_encounter.h b/include/constants/wild_encounter.h index a78cd126f33d..d1bbb61e9b00 100644 --- a/include/constants/wild_encounter.h +++ b/include/constants/wild_encounter.h @@ -8,4 +8,6 @@ #define NUM_ALTERING_CAVE_TABLES 9 +#define BATTLE_PYRAMID_RANDOM_ENCOUNTERS // If defined, battle pyramid Pokemon will be generated randomly based on the round's challenge instead of hardcoded in src/data/battle_frontier/battle_pyramid_level_50_wild_mons.h (or open_level_wild_mons.h) + #endif // GUARD_CONSTANTS_WILD_ENCOUNTER_H diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index 336582ba5935..2baf481272cf 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -27,6 +27,7 @@ #include "overworld.h" #include "event_scripts.h" #include "graphics.h" +#include "wild_encounter.h" #include "constants/battle_frontier.h" #include "constants/battle_pyramid.h" #include "constants/event_objects.h" @@ -99,8 +100,13 @@ static bool8 TrySetPyramidObjectEventPositionAtCoords(bool8, u8, u8, u8 *, u8, u // Const rom data. #define ABILITY_RANDOM 2 // For wild mons data. -#include "data/battle_frontier/battle_pyramid_level_50_wild_mons.h" -#include "data/battle_frontier/battle_pyramid_open_level_wild_mons.h" +#ifdef BATTLE_PYRAMID_RANDOM_ENCOUNTERS + #include "data/battle_frontier/battle_pyramid_wild_requirements.h" +#else + #include "data/battle_frontier/battle_pyramid_level_50_wild_mons.h" + #include "data/battle_frontier/battle_pyramid_open_level_wild_mons.h" +#endif + static const struct PyramidFloorTemplate sPyramidFloorTemplates[] = { @@ -1338,6 +1344,202 @@ static void MarkPyramidTrainerAsBattled(u16 trainerId) gObjectEvents[gSelectedObjectEvent].initialCoords.y = gObjectEvents[gSelectedObjectEvent].currentCoords.y; } +#ifdef BATTLE_PYRAMID_RANDOM_ENCOUNTERS +// check if given species evolved from a specific evolutionary stone +// if nItems is passed as 0, it will check for any EVO_ITEM case +static bool32 CheckBattlePyramidEvoRequirement(u16 species, u16 *evoItems, int nItems) +{ + u32 i, j, k; + for (i = 0; i < NUM_SPECIES; i++) + { + for (j = 0; j < EVOS_PER_MON; j++) + { + if (gEvolutionTable[i][j].species == species + && (gEvolutionTable[i][j].method == EVO_ITEM || gEvolutionTable[i][j].method == EVO_ITEM_MALE || gEvolutionTable[i][j].method == EVO_ITEM_FEMALE)) + if (nItems == 0) + { + // Any EVO_ITEM case will do + return TRUE; + } + else + { + // Otherwise, need to match specific set provided + for (k = 0; k < nItems; k++) { + if (gEvolutionTable[i][j].param == evoItems[k]) { + return TRUE; + } + } + } + } + } + } + return FALSE; +} + + +void GenerateBattlePyramidWildMon(void) +{ + u8 name[POKEMON_NAME_LENGTH + 1]; + int i, j; + u32 id; + u32 lvl = gSaveBlock2Ptr->frontier.lvlMode; + u16 round = (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvl] / 7) % TOTAL_ROUNDS; + const struct BattlePyramidRequirement *reqs = &sBattlePyramidRequirementsByRound[round]; + u16 species; + u32 bstLim; + u16 *moves = NULL; + u16 *abilities = NULL; + int moveCount, abilityCount; + + if (reqs->nMoves != 0) + moves = AllocZeroed(sizeof(u16) * reqs->nMoves); + + if (reqs->nAbilities != 0) + abilities = AllocZeroed(sizeof(u16) * reqs->nAbilities); + + if (round >= TOTAL_ROUNDS) + round = TOTAL_ROUNDS - 1; + + id = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, NULL) - 1; // index in table (0-11) -> higher index is lower probability + bstLim = 450 + (25*round) + (5*id); // higher BST limit for 'rarer' wild mon rolls + + while (1) + { + species = Random() % FORMS_START; + // check type + if (reqs->type != TYPE_MYSTERY && !IsOfBaseType(species, reqs->type)) + continue; + + // check base stat total + if (GetTotalBaseStat(species) > bstLim) + continue; + + // check moves + if (reqs->nMoves != 0) + { + moveCount = 0; + // get list of moves that can be learned + for (i = 0; i < reqs->nMoves; i++) + { + if (CanTeachMove(species, reqs->moves[i])) + { + moves[moveCount] = reqs->moves[i]; + moveCount++; + } + } + if (moveCount == 0) + continue; + } + + // check abilities + if (reqs->nAbilities != 0) + { + abilityCount = 0; + // get list of moves that can be learned + for (i = 0; i < reqs->nAbilities; i++) + { + for (j = 0; j < NUM_ABILITY_SLOTS; j++) + { + if (gSpeciesInfo[species].abilities[j] == reqs->abilities[i]) + { + abilities[abilityCount] = reqs->abilities[i]; + abilityCount++; + break; + } + } + } + if (abilityCount == 0) + continue; + } + // check evos + if (reqs->evos[0] != 0 && !CheckBattlePyramidEvoRequirement(species, reqs->evos)) + continue; + + // we found a species we can use! + break; + } + + // Set species, name + SetMonData(&gEnemyParty[0], MON_DATA_SPECIES, &species); + CopySpeciesName(name, species); + SetMonData(&gEnemyParty[0], MON_DATA_NICKNAME, &name); + + // set level + if (lvl != FRONTIER_LVL_50) + { + lvl = SetFacilityPtrsGetLevel(); + lvl -= (5 + (Random() % (TOTAL_ROUNDS - round)/2)); + } + else + { + lvl = 50 - (5 + (Random() % (TOTAL_ROUNDS - round)/4)); + } + SetMonData(&gEnemyParty[0], + MON_DATA_EXP, + &gExperienceTables[gSpeciesInfo[species].growthRate][lvl]); + + // Give initial moves and replace one with desired move + GiveBoxMonInitialMoveset(&gEnemyParty[0].box); + if (moves != NULL) + { + // get a random move to give + i = 0; + while (1) + { + id = moves[Random() % moveCount]; + if (!MonKnowsMove(&gEnemyParty[0], id)) + { + // replace random move + SetMonData(&gEnemyParty[0], MON_DATA_MOVE1 + Random() % MAX_MON_MOVES, &id); + break; + } + i++; + if (i == 20) + break; + } + free(moves); + } + + // Initialize a random ability num + if (gSpeciesInfo[wildMons[id].species].abilities[1]) + { + i = GetMonData(&gEnemyParty[0], MON_DATA_PERSONALITY, NULL) % 2; + SetMonData(&gEnemyParty[0], MON_DATA_ABILITY_NUM, &i); + } + else + { + i = 0; + SetMonData(&gEnemyParty[0], MON_DATA_ABILITY_NUM, &i); + } + + // Try to replace with desired ability + if (abilities != NULL) + { + i = 0; + while (1) + { + id = abilities[Random() % abilityCount]; + for (j = 0; j < NUM_ABILITY_SLOTS; j++) + { + if (id == gSpeciesInfo[species].abilities[j]) + { + // Set this ability num + SetMonData(&gEnemyParty[0], MON_DATA_ABILITY_NUM, &id); + } + } + } + } + + if (gSaveBlock2Ptr->frontier.pyramidWinStreaks[gSaveBlock2Ptr->frontier.lvlMode] >= 140) + { + id = (Random() % 17) + 15; + for (i = 0; i < NUM_STATS; i++) + SetMonData(&gEnemyParty[0], MON_DATA_HP_IV + i, &id); + } + + CalculateMonStats(&gEnemyParty[0]); +} +#else void GenerateBattlePyramidWildMon(void) { u8 name[POKEMON_NAME_LENGTH + 1]; @@ -1410,6 +1612,7 @@ void GenerateBattlePyramidWildMon(void) } CalculateMonStats(&gEnemyParty[0]); } +#endif u8 GetPyramidRunMultiplier(void) { diff --git a/src/data/battle_frontier/battle_pyramid_wild_requirements.h b/src/data/battle_frontier/battle_pyramid_wild_requirements.h new file mode 100644 index 000000000000..6bfe13d74fa1 --- /dev/null +++ b/src/data/battle_frontier/battle_pyramid_wild_requirements.h @@ -0,0 +1,236 @@ + +#include "constants/abilities.h" +#include "constants/battle_move_effects.h" + +struct BattlePyramidRequirement { + const u16 *moves; /* use moves instead of effects so we don't need to find moves with said effect in our loop */ + u16 abilities[10]; + u8 nAbilities; + u8 type; + u8 nMoves; + u16 evoItems[3]; + u8 nEvoItems; +}; + +// EFFECT_PARALYZE, EFFECT_PARALYZE_HIT (30% or more) +static const u16 sParalyzingMoves[] = { + //MOVE_THUNDER_PUNCH, + MOVE_BODY_SLAM, + MOVE_STUN_SPORE, + //MOVE_THUNDER_SHOCK, + //MOVE_THUNDERBOLT, + MOVE_THUNDER_WAVE, + MOVE_LICK, + MOVE_GLARE, + MOVE_ZAP_CANNON, + MOVE_SPARK, + MOVE_DRAGON_BREATH, + MOVE_FORCE_PALM, + MOVE_DISCHARGE, + //MOVE_BOLT_STRIKE, + MOVE_NUZZLE, + MOVE_SPLISHY_SPLASH, + MOVE_BUZZY_BUZZ, + MOVE_COMBAT_TORQUE, +}; + +// EFFECT_POISON_HIT (30% or more), EFFECT_POISON, EFFECT_POISON_FANG, EFFECT_TOXIC, EFFECT_TOXIC_THREAD +static const u16 sPoisoningMoves[] = { + MOVE_POISON_STING, + //MOVE_TWINEEDLE, + MOVE_SMOG, + MOVE_SLUDGE, + MOVE_SLUDGE_BOMB, + //MOVE_POISON_TAIL, + MOVE_POISON_JAB, + //MOVE_CROSS_POISON, + MOVE_GUNK_SHOT, + //MOVE_SLUDGE_WAVE, + MOVE_NOXIOUS_TORQUE, + //MOVE_ACID, + MOVE_POISON_POWDER, + MOVE_TOXIC, + MOVE_POISON_GAS, + MOVE_POISON_FANG, + MOVE_BANEFUL_BUNKER, + MOVE_TOXIC_THREAD, +}; + +// EFFECT_BURN_HIT, EFFECT_WILL_O_WISP +static const u16 sBurningMoves[] = { + //MOVE_EMBER, + //MOVE_FLAMETHROWER, + //MOVE_FIRE_BLAST, + //MOVE_HEAT_WAVE, + //MOVE_BLAZE_KICK, + MOVE_LAVA_PLUME, + MOVE_SCALD, + MOVE_INFERNO, + MOVE_SEARING_SHOT, + MOVE_BLUE_FLARE, + MOVE_STEAM_ERUPTION, + MOVE_SIZZLY_SLIDE, + //MOVE_PYRO_BALL, + MOVE_BURNING_JEALOUSY, + MOVE_SCORCHING_SANDS, + MOVE_SANDSEAR_STORM, + MOVE_BLAZING_TORQUE, + MOVE_BURN_POWDER, + MOVE_WILL_O_WISP, +}; + +// EFFECT_FREEZE, EFFECT_FREEZE_HIT +static const u16 sFrostbiteMoves[] = { + MOVE_ICE_PUNCH, + MOVE_ICE_BEAM, + MOVE_BLIZZARD, + MOVE_POWDER_SNOW, + MOVE_FREEZING_GLARE, +}; + +// EFFECT_GRUDGE, EFFECT_SPITE, EFFECT_EERIE_SPELL +static const u16 sPPReducingMoves[] = { + MOVE_GRUDGE, + MOVE_SPITE, + MOVE_EERIE_SPELL, +}; + +// EFFECT_EXPLOSION +static const u16 sExplosionMoves[] = { + MOVE_SELF_DESTRUCT, + MOVE_EXPLOSION, + MOVE_MISTY_EXPLOSION, +}; + +// { EFFECT_RAIN_DANCE, EFFECT_SANDSTORM, EFFECT_HAIL, EFFECT_SUNNY_DAY, EFFECT_HEAT_WAVE, EFFECT_SOLAR_WIND, EFFECT_THICK_FOG, EFFECT_ACID_RAIN, EFFECT_THUNDERSTORM }, +static const u16 sWeatherChangingMoves[] = { + MOVE_RAIN_DANCE, + MOVE_SANDSTORM, + MOVE_HAIL, + MOVE_SUNNY_DAY, +}; + +// EFFECT_RECHARGE, EFFECT_RECOIL_33 +static const u16 sPowerfulNormalMoves[] = { + MOVE_HYPER_BEAM, + MOVE_GIGA_IMPACT, + MOVE_THRASH, + MOVE_BODY_SLAM, + MOVE_DOUBLE_EDGE, +}; + +static const struct BattlePyramidRequirement sBattlePyramidRequirementsByRound[] = { + [0] = /* pokemon with moves that paraylze */ + { + .type = TYPE_MYSTERY, // no type limitation + .moves = sParalyzingMoves, + .nMoves = NELEMS(sParalyzingMoves), + .abilities = { ABILITY_STATIC }, + .nAbilities = 1, + }, + [1] = /* pokemon with moves that poison */ + { + .type = TYPE_MYSTERY, + .moves = sPoisoningMoves, + .nMoves = NELEMS(sPoisoningMoves), + .abilities = { ABILITY_POISON_POINT }, + }, + [2] = /* Pokemon with moves that burn */ + { + .type = TYPE_MYSTERY, + .moves = sBurningMoves, + .nMoves = NELEMS(sBurningMoves), + .abilities = { ABILITY_FLAME_BODY }, + .nAbilities = 1, + }, + [3] = /* pokemon that frostbite -> NOTE used to be ice types in round 7 */ + { + .type = TYPE_MYSTERY, + .moves = sFrostbiteMoves, + .nMoves = NELEMS(sFrostbiteMoves), + .abilities = { ABILITY_FROZEN_BODY }, + .nAbilities = 1, + }, + [4] = /* pokemon with moves that waste PP */ + { + .type = TYPE_MYSTERY, + .moves = sPPReducingMoves, + .nMoves = NELEMS(sPPReducingMoves), + .abilities = { ABILITY_PRESSURE }, + .nAbilities = 1, + }, + [5] = /* pokemon with Levitate */ + { + .type = TYPE_MYSTERY, + .abilities = { ABILITY_LEVITATE }, + .nAbilities = 1, + }, + [6] = /* pokemon with trapping abilities */ + { + .type = TYPE_MYSTERY, + .abilities = { ABILITY_SHADOW_TAG, ABILITY_ARENA_TRAP }, // TODO magnet pull? + .nAbilities = 2, + }, + [7] = /* pokemon with explosion effects */ + { + .type = TYPE_MYSTERY, + .moves = sExplosionMoves, + .nMoves = NELEMS(sExplosionMoves), + }, + [8] = /* psychic types */ + { + .type = TYPE_PSYCHIC, + }, + [9] = /* rock types */ + { + .type = TYPE_ROCK, + }, + [10] = /* fighting types */ + { + .type = TYPE_FIGHTING, + }, + [11] = /* pokemon with weather-altering effects */ + { + .type = TYPE_MYSTERY, + .moves = sWeatherChangingMoves, + .nMoves = NELEMS(sWeatherChangingMoves), + .abilities = { ABILITY_SAND_SPIT, ABILITY_DRIZZLE, ABILITY_SNOW_WARNING, ABILITY_DROUGHT, ABILITY_SAND_STREAM }, + .nAbilities = 5, + }, + [12] = /* bug types */ + { + .type = TYPE_BUG, + }, + [13] = /* dark types */ + { + .type = TYPE_DARK, + }, + [14] = /* water types */ + { + .type = TYPE_WATER, + }, + [15] = /* ghost types */ + { + .type = TYPE_GHOST, + }, + [16] = /* steel types */ + { + .type = TYPE_STEEL, + }, + [17] = /* flying/dragon types */ + { + .type = TYPE_DRAGON, + }, + [18] = /* evolve via water/thunder/fire stone */ + { + .type = TYPE_MYSTERY, + .evoItems = {ITEM_WATER_STONE, ITEM_THUNDER_STONE, ITEM_FIRE_STONE}, + .nEvoItems = 3, + }, + [19] = /* normal with powerful moves */ + { + .type = TYPE_NORMAL, + .moves = sPowerfulNormalMoves, + .nMoves = NELEMS(sPowerfulNormalMoves), + }, +}; From a9146a05ab7419163054eebfb6c54d22ecec9cee Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 19 Jan 2023 15:10:25 -0500 Subject: [PATCH 02/15] fix comment --- src/data/battle_frontier/battle_pyramid_wild_requirements.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/battle_frontier/battle_pyramid_wild_requirements.h b/src/data/battle_frontier/battle_pyramid_wild_requirements.h index 6bfe13d74fa1..b9784b752efd 100644 --- a/src/data/battle_frontier/battle_pyramid_wild_requirements.h +++ b/src/data/battle_frontier/battle_pyramid_wild_requirements.h @@ -102,7 +102,7 @@ static const u16 sExplosionMoves[] = { MOVE_MISTY_EXPLOSION, }; -// { EFFECT_RAIN_DANCE, EFFECT_SANDSTORM, EFFECT_HAIL, EFFECT_SUNNY_DAY, EFFECT_HEAT_WAVE, EFFECT_SOLAR_WIND, EFFECT_THICK_FOG, EFFECT_ACID_RAIN, EFFECT_THUNDERSTORM }, +// EFFECT_RAIN_DANCE, EFFECT_SANDSTORM, EFFECT_HAIL, EFFECT_SUNNY_DAY, static const u16 sWeatherChangingMoves[] = { MOVE_RAIN_DANCE, MOVE_SANDSTORM, From 2283c0b7c00d3c9c59b818a9c5c8cb63132aa12c Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 19 Jan 2023 15:19:32 -0500 Subject: [PATCH 03/15] fix ice type round to match vanilla. move config to overworld --- include/config/overworld.h | 2 ++ include/constants/wild_encounter.h | 2 -- .../battle_pyramid_wild_requirements.h | 19 ++++++++----------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/include/config/overworld.h b/include/config/overworld.h index fb438431b326..d75e54fc2f94 100644 --- a/include/config/overworld.h +++ b/include/config/overworld.h @@ -10,4 +10,6 @@ #define OW_FLAG_NO_ENCOUNTER 0 // If this flag is set, wild encounters will be disabled. #define OW_FLAG_NO_TRAINER_SEE 0 // If this flag is set, trainers will not battle the player unless they're talked to. +#define BATTLE_PYRAMID_RANDOM_ENCOUNTERS // If defined, battle pyramid Pokemon will be generated randomly based on the round's challenge instead of hardcoded in src/data/battle_frontier/battle_pyramid_level_50_wild_mons.h (or open_level_wild_mons.h) + #endif // GUARD_CONFIG_OVERWORLD_H diff --git a/include/constants/wild_encounter.h b/include/constants/wild_encounter.h index d1bbb61e9b00..a78cd126f33d 100644 --- a/include/constants/wild_encounter.h +++ b/include/constants/wild_encounter.h @@ -8,6 +8,4 @@ #define NUM_ALTERING_CAVE_TABLES 9 -#define BATTLE_PYRAMID_RANDOM_ENCOUNTERS // If defined, battle pyramid Pokemon will be generated randomly based on the round's challenge instead of hardcoded in src/data/battle_frontier/battle_pyramid_level_50_wild_mons.h (or open_level_wild_mons.h) - #endif // GUARD_CONSTANTS_WILD_ENCOUNTER_H diff --git a/src/data/battle_frontier/battle_pyramid_wild_requirements.h b/src/data/battle_frontier/battle_pyramid_wild_requirements.h index b9784b752efd..da98d66c5d63 100644 --- a/src/data/battle_frontier/battle_pyramid_wild_requirements.h +++ b/src/data/battle_frontier/battle_pyramid_wild_requirements.h @@ -143,15 +143,7 @@ static const struct BattlePyramidRequirement sBattlePyramidRequirementsByRound[] .abilities = { ABILITY_FLAME_BODY }, .nAbilities = 1, }, - [3] = /* pokemon that frostbite -> NOTE used to be ice types in round 7 */ - { - .type = TYPE_MYSTERY, - .moves = sFrostbiteMoves, - .nMoves = NELEMS(sFrostbiteMoves), - .abilities = { ABILITY_FROZEN_BODY }, - .nAbilities = 1, - }, - [4] = /* pokemon with moves that waste PP */ + [3] = /* pokemon with moves that waste PP */ { .type = TYPE_MYSTERY, .moves = sPPReducingMoves, @@ -159,18 +151,23 @@ static const struct BattlePyramidRequirement sBattlePyramidRequirementsByRound[] .abilities = { ABILITY_PRESSURE }, .nAbilities = 1, }, - [5] = /* pokemon with Levitate */ + [4] = /* pokemon with Levitate */ { .type = TYPE_MYSTERY, .abilities = { ABILITY_LEVITATE }, .nAbilities = 1, }, - [6] = /* pokemon with trapping abilities */ + [5] = /* pokemon with trapping abilities */ { .type = TYPE_MYSTERY, .abilities = { ABILITY_SHADOW_TAG, ABILITY_ARENA_TRAP }, // TODO magnet pull? .nAbilities = 2, }, + [6] = /* ice types */ + { + .type = TYPE_ICE, + }, + [7] = /* pokemon with explosion effects */ { .type = TYPE_MYSTERY, From 55c7221b65fbd646bc36caea3fb8bb980fc051b6 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 19 Jan 2023 15:40:08 -0500 Subject: [PATCH 04/15] some fixes --- src/battle_pyramid.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index 2baf481272cf..84f53c44dcbd 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -1347,15 +1347,17 @@ static void MarkPyramidTrainerAsBattled(u16 trainerId) #ifdef BATTLE_PYRAMID_RANDOM_ENCOUNTERS // check if given species evolved from a specific evolutionary stone // if nItems is passed as 0, it will check for any EVO_ITEM case +extern struct Evolution gEvolutionTable[][EVOS_PER_MON]; static bool32 CheckBattlePyramidEvoRequirement(u16 species, u16 *evoItems, int nItems) { u32 i, j, k; for (i = 0; i < NUM_SPECIES; i++) { for (j = 0; j < EVOS_PER_MON; j++) - { + { if (gEvolutionTable[i][j].species == species && (gEvolutionTable[i][j].method == EVO_ITEM || gEvolutionTable[i][j].method == EVO_ITEM_MALE || gEvolutionTable[i][j].method == EVO_ITEM_FEMALE)) + { if (nItems == 0) { // Any EVO_ITEM case will do @@ -1407,7 +1409,7 @@ void GenerateBattlePyramidWildMon(void) { species = Random() % FORMS_START; // check type - if (reqs->type != TYPE_MYSTERY && !IsOfBaseType(species, reqs->type)) + if (reqs->type != TYPE_MYSTERY && gSpeciesInfo[species].type1 != reqs->type && gSpeciesInfo[species].type2 != reqs->type) continue; // check base stat total @@ -1421,7 +1423,7 @@ void GenerateBattlePyramidWildMon(void) // get list of moves that can be learned for (i = 0; i < reqs->nMoves; i++) { - if (CanTeachMove(species, reqs->moves[i])) + if (CanLearnTeachableMove(species, reqs->moves[i])) { moves[moveCount] = reqs->moves[i]; moveCount++; From 52c9744bf036ea2400fc73c1f13f6f3f0ab4afac Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 19 Jan 2023 15:40:40 -0500 Subject: [PATCH 05/15] BATTLE_PYRAMID_RANDOM_ENCOUNTERS define to FALSE defualt --- include/config/overworld.h | 2 +- src/battle_pyramid.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/config/overworld.h b/include/config/overworld.h index d75e54fc2f94..d9f1dc7cac0e 100644 --- a/include/config/overworld.h +++ b/include/config/overworld.h @@ -10,6 +10,6 @@ #define OW_FLAG_NO_ENCOUNTER 0 // If this flag is set, wild encounters will be disabled. #define OW_FLAG_NO_TRAINER_SEE 0 // If this flag is set, trainers will not battle the player unless they're talked to. -#define BATTLE_PYRAMID_RANDOM_ENCOUNTERS // If defined, battle pyramid Pokemon will be generated randomly based on the round's challenge instead of hardcoded in src/data/battle_frontier/battle_pyramid_level_50_wild_mons.h (or open_level_wild_mons.h) +#define BATTLE_PYRAMID_RANDOM_ENCOUNTERS FALSE // If defined, battle pyramid Pokemon will be generated randomly based on the round's challenge instead of hardcoded in src/data/battle_frontier/battle_pyramid_level_50_wild_mons.h (or open_level_wild_mons.h) #endif // GUARD_CONFIG_OVERWORLD_H diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index 84f53c44dcbd..7a7048b8c07a 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -100,7 +100,7 @@ static bool8 TrySetPyramidObjectEventPositionAtCoords(bool8, u8, u8, u8 *, u8, u // Const rom data. #define ABILITY_RANDOM 2 // For wild mons data. -#ifdef BATTLE_PYRAMID_RANDOM_ENCOUNTERS +#if BATTLE_PYRAMID_RANDOM_ENCOUNTERS == TRUE #include "data/battle_frontier/battle_pyramid_wild_requirements.h" #else #include "data/battle_frontier/battle_pyramid_level_50_wild_mons.h" @@ -1344,7 +1344,7 @@ static void MarkPyramidTrainerAsBattled(u16 trainerId) gObjectEvents[gSelectedObjectEvent].initialCoords.y = gObjectEvents[gSelectedObjectEvent].currentCoords.y; } -#ifdef BATTLE_PYRAMID_RANDOM_ENCOUNTERS +#ifdef BATTLE_PYRAMID_RANDOM_ENCOUNTERS == TRUE // check if given species evolved from a specific evolutionary stone // if nItems is passed as 0, it will check for any EVO_ITEM case extern struct Evolution gEvolutionTable[][EVOS_PER_MON]; From f18abc469313970675c0d26f720c932a86425677 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 19 Jan 2023 15:41:43 -0500 Subject: [PATCH 06/15] fix GetSpeciesName --- src/battle_pyramid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index 7a7048b8c07a..0c3033b47e30 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -1463,7 +1463,7 @@ void GenerateBattlePyramidWildMon(void) // Set species, name SetMonData(&gEnemyParty[0], MON_DATA_SPECIES, &species); - CopySpeciesName(name, species); + GetSpeciesName(name, species); SetMonData(&gEnemyParty[0], MON_DATA_NICKNAME, &name); // set level From 962f629852280d597cb5697e29c86c95d8401276 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 19 Jan 2023 15:46:17 -0500 Subject: [PATCH 07/15] fix GetTotalBaseStat define, gEvolutionTable targetSpecies call --- include/config/overworld.h | 2 +- src/battle_pyramid.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/config/overworld.h b/include/config/overworld.h index d9f1dc7cac0e..1c183a4b5911 100644 --- a/include/config/overworld.h +++ b/include/config/overworld.h @@ -10,6 +10,6 @@ #define OW_FLAG_NO_ENCOUNTER 0 // If this flag is set, wild encounters will be disabled. #define OW_FLAG_NO_TRAINER_SEE 0 // If this flag is set, trainers will not battle the player unless they're talked to. -#define BATTLE_PYRAMID_RANDOM_ENCOUNTERS FALSE // If defined, battle pyramid Pokemon will be generated randomly based on the round's challenge instead of hardcoded in src/data/battle_frontier/battle_pyramid_level_50_wild_mons.h (or open_level_wild_mons.h) +#define BATTLE_PYRAMID_RANDOM_ENCOUNTERS TRUE // If defined, battle pyramid Pokemon will be generated randomly based on the round's challenge instead of hardcoded in src/data/battle_frontier/battle_pyramid_level_50_wild_mons.h (or open_level_wild_mons.h) #endif // GUARD_CONFIG_OVERWORLD_H diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index 0c3033b47e30..3c14afedc7d1 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -1344,7 +1344,7 @@ static void MarkPyramidTrainerAsBattled(u16 trainerId) gObjectEvents[gSelectedObjectEvent].initialCoords.y = gObjectEvents[gSelectedObjectEvent].currentCoords.y; } -#ifdef BATTLE_PYRAMID_RANDOM_ENCOUNTERS == TRUE +#if BATTLE_PYRAMID_RANDOM_ENCOUNTERS == TRUE // check if given species evolved from a specific evolutionary stone // if nItems is passed as 0, it will check for any EVO_ITEM case extern struct Evolution gEvolutionTable[][EVOS_PER_MON]; @@ -1355,7 +1355,7 @@ static bool32 CheckBattlePyramidEvoRequirement(u16 species, u16 *evoItems, int n { for (j = 0; j < EVOS_PER_MON; j++) { - if (gEvolutionTable[i][j].species == species + if (gEvolutionTable[i][j].targetSpecies == species && (gEvolutionTable[i][j].method == EVO_ITEM || gEvolutionTable[i][j].method == EVO_ITEM_MALE || gEvolutionTable[i][j].method == EVO_ITEM_FEMALE)) { if (nItems == 0) @@ -1378,7 +1378,7 @@ static bool32 CheckBattlePyramidEvoRequirement(u16 species, u16 *evoItems, int n return FALSE; } - +extern u32 GetTotalBaseStat(u32 species); void GenerateBattlePyramidWildMon(void) { u8 name[POKEMON_NAME_LENGTH + 1]; From 668b021aa50e3998e0b8e287718cfbbf07abe2e9 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 19 Jan 2023 15:52:03 -0500 Subject: [PATCH 08/15] fix wildMons call --- src/battle_pyramid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index 3c14afedc7d1..34a1e17c5b91 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -1503,7 +1503,7 @@ void GenerateBattlePyramidWildMon(void) } // Initialize a random ability num - if (gSpeciesInfo[wildMons[id].species].abilities[1]) + if (gSpeciesInfo[species].abilities[1]) { i = GetMonData(&gEnemyParty[0], MON_DATA_PERSONALITY, NULL) % 2; SetMonData(&gEnemyParty[0], MON_DATA_ABILITY_NUM, &i); From 8d27065eca5efccadf42b09184a3bf2b886c1846 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 19 Jan 2023 16:02:56 -0500 Subject: [PATCH 09/15] fix call to CheckBattlePyramidEvoRequirement --- src/battle_pyramid.c | 2 +- src/data/battle_frontier/battle_pyramid_wild_requirements.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index 34a1e17c5b91..351423217c7a 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -1454,7 +1454,7 @@ void GenerateBattlePyramidWildMon(void) continue; } // check evos - if (reqs->evos[0] != 0 && !CheckBattlePyramidEvoRequirement(species, reqs->evos)) + if (reqs->evoItems[0] != 0 && !CheckBattlePyramidEvoRequirement(species, reqs->evoItems, reqs->nEvoItems)) continue; // we found a species we can use! diff --git a/src/data/battle_frontier/battle_pyramid_wild_requirements.h b/src/data/battle_frontier/battle_pyramid_wild_requirements.h index da98d66c5d63..98732348aafb 100644 --- a/src/data/battle_frontier/battle_pyramid_wild_requirements.h +++ b/src/data/battle_frontier/battle_pyramid_wild_requirements.h @@ -1,3 +1,4 @@ +#if BATTLE_PYRAMID_RANDOM_ENCOUNTERS == TRUE #include "constants/abilities.h" #include "constants/battle_move_effects.h" @@ -231,3 +232,5 @@ static const struct BattlePyramidRequirement sBattlePyramidRequirementsByRound[] .nMoves = NELEMS(sPowerfulNormalMoves), }, }; + +#endif From 9e09f2f4dec85c282c7d7c84924fe0ca9d878f2a Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 19 Jan 2023 18:19:20 -0500 Subject: [PATCH 10/15] fix arg 2 in CheckBattlePyramidEvoRequirement --- src/battle_pyramid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index 351423217c7a..2022259e51c9 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -1454,7 +1454,7 @@ void GenerateBattlePyramidWildMon(void) continue; } // check evos - if (reqs->evoItems[0] != 0 && !CheckBattlePyramidEvoRequirement(species, reqs->evoItems, reqs->nEvoItems)) + if (reqs->evoItems[0] != 0 && !CheckBattlePyramidEvoRequirement(species, &reqs->evoItems, reqs->nEvoItems)) continue; // we found a species we can use! From a31249fcaf2c347b4b78dddbff9e4a43aa5b654d Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 19 Jan 2023 19:13:26 -0500 Subject: [PATCH 11/15] free->Free and fix evoItems ptr --- src/battle_pyramid.c | 7 ++++--- .../battle_frontier/battle_pyramid_wild_requirements.h | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index 2022259e51c9..e1e347e0fd4f 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -1348,7 +1348,7 @@ static void MarkPyramidTrainerAsBattled(u16 trainerId) // check if given species evolved from a specific evolutionary stone // if nItems is passed as 0, it will check for any EVO_ITEM case extern struct Evolution gEvolutionTable[][EVOS_PER_MON]; -static bool32 CheckBattlePyramidEvoRequirement(u16 species, u16 *evoItems, int nItems) +static bool32 CheckBattlePyramidEvoRequirement(u16 species, const u16 *evoItems, u8 nItems) { u32 i, j, k; for (i = 0; i < NUM_SPECIES; i++) @@ -1454,7 +1454,7 @@ void GenerateBattlePyramidWildMon(void) continue; } // check evos - if (reqs->evoItems[0] != 0 && !CheckBattlePyramidEvoRequirement(species, &reqs->evoItems, reqs->nEvoItems)) + if (reqs->evoItems[0] != 0 && !CheckBattlePyramidEvoRequirement(species, reqs->evoItems, reqs->nEvoItems)) continue; // we found a species we can use! @@ -1499,7 +1499,7 @@ void GenerateBattlePyramidWildMon(void) if (i == 20) break; } - free(moves); + Free(moves); } // Initialize a random ability num @@ -1530,6 +1530,7 @@ void GenerateBattlePyramidWildMon(void) } } } + Free(abilities); } if (gSaveBlock2Ptr->frontier.pyramidWinStreaks[gSaveBlock2Ptr->frontier.lvlMode] >= 140) diff --git a/src/data/battle_frontier/battle_pyramid_wild_requirements.h b/src/data/battle_frontier/battle_pyramid_wild_requirements.h index 98732348aafb..33cd2b539bc5 100644 --- a/src/data/battle_frontier/battle_pyramid_wild_requirements.h +++ b/src/data/battle_frontier/battle_pyramid_wild_requirements.h @@ -9,7 +9,7 @@ struct BattlePyramidRequirement { u8 nAbilities; u8 type; u8 nMoves; - u16 evoItems[3]; + const u16 *evoItems; u8 nEvoItems; }; @@ -120,6 +120,8 @@ static const u16 sPowerfulNormalMoves[] = { MOVE_DOUBLE_EDGE, }; +static const u16 sEvoItems[] = {ITEM_FIRE_STONE, ITEM_WATER_STONE, ITEM_THUNDER_STONE}; + static const struct BattlePyramidRequirement sBattlePyramidRequirementsByRound[] = { [0] = /* pokemon with moves that paraylze */ { @@ -222,7 +224,7 @@ static const struct BattlePyramidRequirement sBattlePyramidRequirementsByRound[] [18] = /* evolve via water/thunder/fire stone */ { .type = TYPE_MYSTERY, - .evoItems = {ITEM_WATER_STONE, ITEM_THUNDER_STONE, ITEM_FIRE_STONE}, + .evoItems = sEvoItems, .nEvoItems = 3, }, [19] = /* normal with powerful moves */ From 6f6b76372d2c3ae5c084b0c18b99eccdb14d0b40 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 19 Jan 2023 19:17:30 -0500 Subject: [PATCH 12/15] move sBurningMoves --- src/data/battle_frontier/battle_pyramid_wild_requirements.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/data/battle_frontier/battle_pyramid_wild_requirements.h b/src/data/battle_frontier/battle_pyramid_wild_requirements.h index 33cd2b539bc5..1b9e359f1f03 100644 --- a/src/data/battle_frontier/battle_pyramid_wild_requirements.h +++ b/src/data/battle_frontier/battle_pyramid_wild_requirements.h @@ -59,6 +59,7 @@ static const u16 sPoisoningMoves[] = { // EFFECT_BURN_HIT, EFFECT_WILL_O_WISP static const u16 sBurningMoves[] = { + MOVE_WILL_O_WISP, //MOVE_EMBER, //MOVE_FLAMETHROWER, //MOVE_FIRE_BLAST, @@ -76,8 +77,6 @@ static const u16 sBurningMoves[] = { MOVE_SCORCHING_SANDS, MOVE_SANDSEAR_STORM, MOVE_BLAZING_TORQUE, - MOVE_BURN_POWDER, - MOVE_WILL_O_WISP, }; // EFFECT_FREEZE, EFFECT_FREEZE_HIT From 875617254bab5eb07242f9ccd4edbea960d8387a Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 19 Jan 2023 15:10:25 -0500 Subject: [PATCH 13/15] fix comment fix ice type round to match vanilla. move config to overworld some fixes BATTLE_PYRAMID_RANDOM_ENCOUNTERS define to FALSE defualt fix GetSpeciesName fix GetTotalBaseStat define, gEvolutionTable targetSpecies call fix wildMons call fix call to CheckBattlePyramidEvoRequirement fix arg 2 in CheckBattlePyramidEvoRequirement free->Free and fix evoItems ptr move sBurningMoves BATTLE_PYRAMID_RANDOM_ENCOUNTERS defaults to false --- include/config/overworld.h | 2 ++ include/constants/wild_encounter.h | 2 -- src/battle_pyramid.c | 27 ++++++++------- .../battle_pyramid_wild_requirements.h | 33 ++++++++++--------- 4 files changed, 34 insertions(+), 30 deletions(-) diff --git a/include/config/overworld.h b/include/config/overworld.h index fb438431b326..fd37550bb8ec 100644 --- a/include/config/overworld.h +++ b/include/config/overworld.h @@ -10,4 +10,6 @@ #define OW_FLAG_NO_ENCOUNTER 0 // If this flag is set, wild encounters will be disabled. #define OW_FLAG_NO_TRAINER_SEE 0 // If this flag is set, trainers will not battle the player unless they're talked to. +#define BATTLE_PYRAMID_RANDOM_ENCOUNTERS FALSE // If set to TRUE, battle pyramid Pokemon will be generated randomly based on the round's challenge instead of hardcoded in src/data/battle_frontier/battle_pyramid_level_50_wild_mons.h (or open_level_wild_mons.h) + #endif // GUARD_CONFIG_OVERWORLD_H diff --git a/include/constants/wild_encounter.h b/include/constants/wild_encounter.h index d1bbb61e9b00..a78cd126f33d 100644 --- a/include/constants/wild_encounter.h +++ b/include/constants/wild_encounter.h @@ -8,6 +8,4 @@ #define NUM_ALTERING_CAVE_TABLES 9 -#define BATTLE_PYRAMID_RANDOM_ENCOUNTERS // If defined, battle pyramid Pokemon will be generated randomly based on the round's challenge instead of hardcoded in src/data/battle_frontier/battle_pyramid_level_50_wild_mons.h (or open_level_wild_mons.h) - #endif // GUARD_CONSTANTS_WILD_ENCOUNTER_H diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index 2baf481272cf..e1e347e0fd4f 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -100,7 +100,7 @@ static bool8 TrySetPyramidObjectEventPositionAtCoords(bool8, u8, u8, u8 *, u8, u // Const rom data. #define ABILITY_RANDOM 2 // For wild mons data. -#ifdef BATTLE_PYRAMID_RANDOM_ENCOUNTERS +#if BATTLE_PYRAMID_RANDOM_ENCOUNTERS == TRUE #include "data/battle_frontier/battle_pyramid_wild_requirements.h" #else #include "data/battle_frontier/battle_pyramid_level_50_wild_mons.h" @@ -1344,18 +1344,20 @@ static void MarkPyramidTrainerAsBattled(u16 trainerId) gObjectEvents[gSelectedObjectEvent].initialCoords.y = gObjectEvents[gSelectedObjectEvent].currentCoords.y; } -#ifdef BATTLE_PYRAMID_RANDOM_ENCOUNTERS +#if BATTLE_PYRAMID_RANDOM_ENCOUNTERS == TRUE // check if given species evolved from a specific evolutionary stone // if nItems is passed as 0, it will check for any EVO_ITEM case -static bool32 CheckBattlePyramidEvoRequirement(u16 species, u16 *evoItems, int nItems) +extern struct Evolution gEvolutionTable[][EVOS_PER_MON]; +static bool32 CheckBattlePyramidEvoRequirement(u16 species, const u16 *evoItems, u8 nItems) { u32 i, j, k; for (i = 0; i < NUM_SPECIES; i++) { for (j = 0; j < EVOS_PER_MON; j++) - { - if (gEvolutionTable[i][j].species == species + { + if (gEvolutionTable[i][j].targetSpecies == species && (gEvolutionTable[i][j].method == EVO_ITEM || gEvolutionTable[i][j].method == EVO_ITEM_MALE || gEvolutionTable[i][j].method == EVO_ITEM_FEMALE)) + { if (nItems == 0) { // Any EVO_ITEM case will do @@ -1376,7 +1378,7 @@ static bool32 CheckBattlePyramidEvoRequirement(u16 species, u16 *evoItems, int n return FALSE; } - +extern u32 GetTotalBaseStat(u32 species); void GenerateBattlePyramidWildMon(void) { u8 name[POKEMON_NAME_LENGTH + 1]; @@ -1407,7 +1409,7 @@ void GenerateBattlePyramidWildMon(void) { species = Random() % FORMS_START; // check type - if (reqs->type != TYPE_MYSTERY && !IsOfBaseType(species, reqs->type)) + if (reqs->type != TYPE_MYSTERY && gSpeciesInfo[species].type1 != reqs->type && gSpeciesInfo[species].type2 != reqs->type) continue; // check base stat total @@ -1421,7 +1423,7 @@ void GenerateBattlePyramidWildMon(void) // get list of moves that can be learned for (i = 0; i < reqs->nMoves; i++) { - if (CanTeachMove(species, reqs->moves[i])) + if (CanLearnTeachableMove(species, reqs->moves[i])) { moves[moveCount] = reqs->moves[i]; moveCount++; @@ -1452,7 +1454,7 @@ void GenerateBattlePyramidWildMon(void) continue; } // check evos - if (reqs->evos[0] != 0 && !CheckBattlePyramidEvoRequirement(species, reqs->evos)) + if (reqs->evoItems[0] != 0 && !CheckBattlePyramidEvoRequirement(species, reqs->evoItems, reqs->nEvoItems)) continue; // we found a species we can use! @@ -1461,7 +1463,7 @@ void GenerateBattlePyramidWildMon(void) // Set species, name SetMonData(&gEnemyParty[0], MON_DATA_SPECIES, &species); - CopySpeciesName(name, species); + GetSpeciesName(name, species); SetMonData(&gEnemyParty[0], MON_DATA_NICKNAME, &name); // set level @@ -1497,11 +1499,11 @@ void GenerateBattlePyramidWildMon(void) if (i == 20) break; } - free(moves); + Free(moves); } // Initialize a random ability num - if (gSpeciesInfo[wildMons[id].species].abilities[1]) + if (gSpeciesInfo[species].abilities[1]) { i = GetMonData(&gEnemyParty[0], MON_DATA_PERSONALITY, NULL) % 2; SetMonData(&gEnemyParty[0], MON_DATA_ABILITY_NUM, &i); @@ -1528,6 +1530,7 @@ void GenerateBattlePyramidWildMon(void) } } } + Free(abilities); } if (gSaveBlock2Ptr->frontier.pyramidWinStreaks[gSaveBlock2Ptr->frontier.lvlMode] >= 140) diff --git a/src/data/battle_frontier/battle_pyramid_wild_requirements.h b/src/data/battle_frontier/battle_pyramid_wild_requirements.h index 6bfe13d74fa1..1b9e359f1f03 100644 --- a/src/data/battle_frontier/battle_pyramid_wild_requirements.h +++ b/src/data/battle_frontier/battle_pyramid_wild_requirements.h @@ -1,3 +1,4 @@ +#if BATTLE_PYRAMID_RANDOM_ENCOUNTERS == TRUE #include "constants/abilities.h" #include "constants/battle_move_effects.h" @@ -8,7 +9,7 @@ struct BattlePyramidRequirement { u8 nAbilities; u8 type; u8 nMoves; - u16 evoItems[3]; + const u16 *evoItems; u8 nEvoItems; }; @@ -58,6 +59,7 @@ static const u16 sPoisoningMoves[] = { // EFFECT_BURN_HIT, EFFECT_WILL_O_WISP static const u16 sBurningMoves[] = { + MOVE_WILL_O_WISP, //MOVE_EMBER, //MOVE_FLAMETHROWER, //MOVE_FIRE_BLAST, @@ -75,8 +77,6 @@ static const u16 sBurningMoves[] = { MOVE_SCORCHING_SANDS, MOVE_SANDSEAR_STORM, MOVE_BLAZING_TORQUE, - MOVE_BURN_POWDER, - MOVE_WILL_O_WISP, }; // EFFECT_FREEZE, EFFECT_FREEZE_HIT @@ -102,7 +102,7 @@ static const u16 sExplosionMoves[] = { MOVE_MISTY_EXPLOSION, }; -// { EFFECT_RAIN_DANCE, EFFECT_SANDSTORM, EFFECT_HAIL, EFFECT_SUNNY_DAY, EFFECT_HEAT_WAVE, EFFECT_SOLAR_WIND, EFFECT_THICK_FOG, EFFECT_ACID_RAIN, EFFECT_THUNDERSTORM }, +// EFFECT_RAIN_DANCE, EFFECT_SANDSTORM, EFFECT_HAIL, EFFECT_SUNNY_DAY, static const u16 sWeatherChangingMoves[] = { MOVE_RAIN_DANCE, MOVE_SANDSTORM, @@ -119,6 +119,8 @@ static const u16 sPowerfulNormalMoves[] = { MOVE_DOUBLE_EDGE, }; +static const u16 sEvoItems[] = {ITEM_FIRE_STONE, ITEM_WATER_STONE, ITEM_THUNDER_STONE}; + static const struct BattlePyramidRequirement sBattlePyramidRequirementsByRound[] = { [0] = /* pokemon with moves that paraylze */ { @@ -143,15 +145,7 @@ static const struct BattlePyramidRequirement sBattlePyramidRequirementsByRound[] .abilities = { ABILITY_FLAME_BODY }, .nAbilities = 1, }, - [3] = /* pokemon that frostbite -> NOTE used to be ice types in round 7 */ - { - .type = TYPE_MYSTERY, - .moves = sFrostbiteMoves, - .nMoves = NELEMS(sFrostbiteMoves), - .abilities = { ABILITY_FROZEN_BODY }, - .nAbilities = 1, - }, - [4] = /* pokemon with moves that waste PP */ + [3] = /* pokemon with moves that waste PP */ { .type = TYPE_MYSTERY, .moves = sPPReducingMoves, @@ -159,18 +153,23 @@ static const struct BattlePyramidRequirement sBattlePyramidRequirementsByRound[] .abilities = { ABILITY_PRESSURE }, .nAbilities = 1, }, - [5] = /* pokemon with Levitate */ + [4] = /* pokemon with Levitate */ { .type = TYPE_MYSTERY, .abilities = { ABILITY_LEVITATE }, .nAbilities = 1, }, - [6] = /* pokemon with trapping abilities */ + [5] = /* pokemon with trapping abilities */ { .type = TYPE_MYSTERY, .abilities = { ABILITY_SHADOW_TAG, ABILITY_ARENA_TRAP }, // TODO magnet pull? .nAbilities = 2, }, + [6] = /* ice types */ + { + .type = TYPE_ICE, + }, + [7] = /* pokemon with explosion effects */ { .type = TYPE_MYSTERY, @@ -224,7 +223,7 @@ static const struct BattlePyramidRequirement sBattlePyramidRequirementsByRound[] [18] = /* evolve via water/thunder/fire stone */ { .type = TYPE_MYSTERY, - .evoItems = {ITEM_WATER_STONE, ITEM_THUNDER_STONE, ITEM_FIRE_STONE}, + .evoItems = sEvoItems, .nEvoItems = 3, }, [19] = /* normal with powerful moves */ @@ -234,3 +233,5 @@ static const struct BattlePyramidRequirement sBattlePyramidRequirementsByRound[] .nMoves = NELEMS(sPowerfulNormalMoves), }, }; + +#endif From bdbd04289d3531edf3ded73bd7a725732d92f1c3 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Fri, 17 Nov 2023 09:03:15 -0500 Subject: [PATCH 14/15] fix errors --- src/battle_pyramid.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index 0be9c70f4995..21ddf0128302 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -1387,7 +1387,7 @@ void GenerateBattlePyramidWildMon(void) int i, j; u32 id; u32 lvl = gSaveBlock2Ptr->frontier.lvlMode; - u16 round = (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvl] / 7) % TOTAL_ROUNDS; + u16 round = (gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvl] / 7) % TOTAL_PYRAMID_ROUNDS; const struct BattlePyramidRequirement *reqs = &sBattlePyramidRequirementsByRound[round]; u16 species; u32 bstLim; @@ -1401,8 +1401,8 @@ void GenerateBattlePyramidWildMon(void) if (reqs->nAbilities != 0) abilities = AllocZeroed(sizeof(u16) * reqs->nAbilities); - if (round >= TOTAL_ROUNDS) - round = TOTAL_ROUNDS - 1; + if (round >= TOTAL_PYRAMID_ROUNDS) + round = TOTAL_PYRAMID_ROUNDS - 1; id = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, NULL) - 1; // index in table (0-11) -> higher index is lower probability bstLim = 450 + (25*round) + (5*id); // higher BST limit for 'rarer' wild mon rolls @@ -1411,7 +1411,7 @@ void GenerateBattlePyramidWildMon(void) { species = Random() % FORMS_START; // check type - if (reqs->type != TYPE_MYSTERY && gSpeciesInfo[species].type1 != reqs->type && gSpeciesInfo[species].type2 != reqs->type) + if (reqs->type != TYPE_MYSTERY && gSpeciesInfo[species].types[0] != reqs->type && gSpeciesInfo[species].types[1] != reqs->type) continue; // check base stat total @@ -1465,18 +1465,18 @@ void GenerateBattlePyramidWildMon(void) // Set species, name SetMonData(&gEnemyParty[0], MON_DATA_SPECIES, &species); - GetSpeciesName(name, species); + StringCopy(name, gSpeciesNames[species]); SetMonData(&gEnemyParty[0], MON_DATA_NICKNAME, &name); // set level if (lvl != FRONTIER_LVL_50) { lvl = SetFacilityPtrsGetLevel(); - lvl -= (5 + (Random() % (TOTAL_ROUNDS - round)/2)); + lvl -= (5 + (Random() % (TOTAL_PYRAMID_ROUNDS - round)/2)); } else { - lvl = 50 - (5 + (Random() % (TOTAL_ROUNDS - round)/4)); + lvl = 50 - (5 + (Random() % (TOTAL_PYRAMID_ROUNDS - round)/4)); } SetMonData(&gEnemyParty[0], MON_DATA_EXP, From 68df16a47d32fc926b90c7a7b0307c17445837b1 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Fri, 17 Nov 2023 09:04:19 -0500 Subject: [PATCH 15/15] initial movesCount, abilitiesCount --- src/battle_pyramid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index 21ddf0128302..1f73ac5a9dd5 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -1393,7 +1393,7 @@ void GenerateBattlePyramidWildMon(void) u32 bstLim; u16 *moves = NULL; u16 *abilities = NULL; - int moveCount, abilityCount; + int moveCount = 0, abilityCount = 0; if (reqs->nMoves != 0) moves = AllocZeroed(sizeof(u16) * reqs->nMoves);