Skip to content

Commit

Permalink
Merge remote-tracking branch 'pokeemerald-expansion-/master' into mer…
Browse files Browse the repository at this point in the history
…ge-dx
  • Loading branch information
Fervstheone committed Jan 5, 2024
2 parents 7f0b8ef + f9c21af commit dbaaaea
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 173 deletions.
6 changes: 6 additions & 0 deletions include/birch_pc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef GUARD_BIRCH_PC_H
#define GUARD_BIRCH_PC_H

const u8 *GetPokedexRatingText(u16 count);

#endif // GUARD_BIRCH_PC_H
96 changes: 41 additions & 55 deletions src/birch_pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,66 +20,52 @@ bool16 ScriptGetPokedexInfo(void)
return IsNationalPokedexEnabled();
}

// Species in this array are ignored in the progress towards a full regional dex
static const u16 sRegionalNotCountedList[] = {
SPECIES_JIRACHI,
SPECIES_DEOXYS,
SPECIES_NONE
};

#define BIRCH_DEX_STRINGS 21

static const u8 *const sBirchDexRatingTexts[BIRCH_DEX_STRINGS] =
{
gBirchDexRatingText_LessThan10,
gBirchDexRatingText_LessThan20,
gBirchDexRatingText_LessThan30,
gBirchDexRatingText_LessThan40,
gBirchDexRatingText_LessThan50,
gBirchDexRatingText_LessThan60,
gBirchDexRatingText_LessThan70,
gBirchDexRatingText_LessThan80,
gBirchDexRatingText_LessThan90,
gBirchDexRatingText_LessThan100,
gBirchDexRatingText_LessThan110,
gBirchDexRatingText_LessThan120,
gBirchDexRatingText_LessThan130,
gBirchDexRatingText_LessThan140,
gBirchDexRatingText_LessThan150,
gBirchDexRatingText_LessThan160,
gBirchDexRatingText_LessThan170,
gBirchDexRatingText_LessThan180,
gBirchDexRatingText_LessThan190,
gBirchDexRatingText_LessThan200,
gBirchDexRatingText_DexCompleted,
};

// This shows your Hoenn Pokedex rating and not your National Dex.
const u8 *GetPokedexRatingText(u16 count)
{
if (count < 10)
return gBirchDexRatingText_LessThan10;
if (count < 20)
return gBirchDexRatingText_LessThan20;
if (count < 30)
return gBirchDexRatingText_LessThan30;
if (count < 40)
return gBirchDexRatingText_LessThan40;
if (count < 50)
return gBirchDexRatingText_LessThan50;
if (count < 60)
return gBirchDexRatingText_LessThan60;
if (count < 70)
return gBirchDexRatingText_LessThan70;
if (count < 80)
return gBirchDexRatingText_LessThan80;
if (count < 90)
return gBirchDexRatingText_LessThan90;
if (count < 100)
return gBirchDexRatingText_LessThan100;
if (count < 110)
return gBirchDexRatingText_LessThan110;
if (count < 120)
return gBirchDexRatingText_LessThan120;
if (count < 130)
return gBirchDexRatingText_LessThan130;
if (count < 140)
return gBirchDexRatingText_LessThan140;
if (count < 150)
return gBirchDexRatingText_LessThan150;
if (count < 160)
return gBirchDexRatingText_LessThan160;
if (count < 170)
return gBirchDexRatingText_LessThan170;
if (count < 180)
return gBirchDexRatingText_LessThan180;
if (count < 190)
return gBirchDexRatingText_LessThan190;
if (count < 200)
return gBirchDexRatingText_LessThan200;
if (count == 200)
{
if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), FLAG_GET_CAUGHT)
|| GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), FLAG_GET_CAUGHT)) // Jirachi or Deoxys is not counted towards the dex completion. If either of these flags are enabled, it means the actual count is less than 200.
return gBirchDexRatingText_LessThan200;
return gBirchDexRatingText_DexCompleted;
}
if (count == HOENN_DEX_COUNT - 1)
u32 i;
u16 maxDex = HOENN_DEX_COUNT - 1;
for(i = 0; sRegionalNotCountedList[i] != SPECIES_NONE; i++)
{
if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), FLAG_GET_CAUGHT)
&& GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), FLAG_GET_CAUGHT)) // If both of these flags are enabled, it means the actual count is less than 200.
return gBirchDexRatingText_LessThan200;
return gBirchDexRatingText_DexCompleted;
if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(sRegionalNotCountedList[i]), FLAG_GET_CAUGHT))
count--;
maxDex--;
}
if (count == HOENN_DEX_COUNT)
return gBirchDexRatingText_DexCompleted;
return gBirchDexRatingText_LessThan10;
return sBirchDexRatingTexts[(count * (BIRCH_DEX_STRINGS - 1)) / maxDex];
}

void ShowPokedexRatingMessage(void)
Expand Down
28 changes: 15 additions & 13 deletions src/data/pokemon/species_info/gen_1.h
Original file line number Diff line number Diff line change
Expand Up @@ -3723,19 +3723,21 @@ const struct SpeciesInfo gSpeciesInfoGen1[] =
.formSpeciesIdTable = sDiglettFormSpeciesIdTable, \
DIGLETT_FAMILY_MISC_INFO

#define DUGTRIO_MISC_INFO \
.catchRate = 50, \
.expYield = 149, \
.evYield_Speed = 2, \
.speciesName = _("Dugtrio"), \
.cryId = CRY_DUGTRIO, \
.natDexNum = NATIONAL_DEX_DUGTRIO, \
.categoryName = _("Mole"), \
.height = 7, \
.pokemonScale = 406, \
.pokemonOffset = 18, \
.trainerScale = 256, \
.trainerOffset = 0, \
#define DUGTRIO_MISC_INFO \
.catchRate = 50, \
.expYield = 149, \
.evYield_Speed = 2, \
.speciesName = _("Dugtrio"), \
.cryId = CRY_DUGTRIO, \
.natDexNum = NATIONAL_DEX_DUGTRIO, \
.categoryName = _("Mole"), \
.height = 7, \
.pokemonScale = 406, \
.pokemonOffset = 18, \
.trainerScale = 256, \
.trainerOffset = 0, \
.footprint = gMonFootprint_Dugtrio, \
.formSpeciesIdTable = sDugtrioFormSpeciesIdTable, \
DIGLETT_FAMILY_MISC_INFO

#define DUGTRIO_ATTACK (P_UPDATED_STATS >= GEN_7 ? 100 : 80)
Expand Down
12 changes: 10 additions & 2 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -1437,8 +1437,16 @@ static void DebugTask_HandleMenuInput_FlagsVars(u8 taskId)
PlaySE(SE_SELECT);
if ((func = sDebugMenu_Actions_Flags[input]) != NULL)
{
Debug_RedrawListMenu(taskId);
func(taskId);
if (input == DEBUG_FLAGVAR_MENU_ITEM_FLAGS || input == DEBUG_FLAGVAR_MENU_ITEM_VARS)
{
Debug_RedrawListMenu(taskId);
func(taskId);
}
else
{
func(taskId);
Debug_RedrawListMenu(taskId);
}

// Remove TRUE/FALSE window for functions that haven't been assigned flags
if (gTasks[taskId].tInput == 0xFF)
Expand Down
6 changes: 6 additions & 0 deletions src/hall_of_fame.c
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,12 @@ static void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 unused1, u
dexNumber = SpeciesToPokedexNum(currMon->species);
if (dexNumber != 0xFFFF)
{
if (IsNationalPokedexEnabled())
{
stringPtr[0] = (dexNumber / 1000) + CHAR_0;
stringPtr++;
dexNumber %= 1000;
}
stringPtr[0] = (dexNumber / 100) + CHAR_0;
stringPtr++;
dexNumber %= 100;
Expand Down
84 changes: 2 additions & 82 deletions src/match_call.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "battle.h"
#include "battle_setup.h"
#include "bg.h"
#include "birch_pc.h"
#include "data.h"
#include "event_data.h"
#include "event_object_movement.h"
Expand Down Expand Up @@ -1967,90 +1968,10 @@ static u16 GetFrontierStreakInfo(u16 facilityId, u32 *topicTextId)
return streak;
}

static u8 GetPokedexRatingLevel(u16 numSeen)
{
if (numSeen < 10)
return 0;
if (numSeen < 20)
return 1;
if (numSeen < 30)
return 2;
if (numSeen < 40)
return 3;
if (numSeen < 50)
return 4;
if (numSeen < 60)
return 5;
if (numSeen < 70)
return 6;
if (numSeen < 80)
return 7;
if (numSeen < 90)
return 8;
if (numSeen < 100)
return 9;
if (numSeen < 110)
return 10;
if (numSeen < 120)
return 11;
if (numSeen < 130)
return 12;
if (numSeen < 140)
return 13;
if (numSeen < 150)
return 14;
if (numSeen < 160)
return 15;
if (numSeen < 170)
return 16;
if (numSeen < 180)
return 17;
if (numSeen < 190)
return 18;
if (numSeen < 200)
return 19;

if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), FLAG_GET_CAUGHT))
numSeen--;
if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), FLAG_GET_CAUGHT))
numSeen--;

if (numSeen < 200)
return 19;
else
return 20;
}

static const u8 *const sBirchDexRatingTexts[] =
{
gBirchDexRatingText_LessThan10,
gBirchDexRatingText_LessThan20,
gBirchDexRatingText_LessThan30,
gBirchDexRatingText_LessThan40,
gBirchDexRatingText_LessThan50,
gBirchDexRatingText_LessThan60,
gBirchDexRatingText_LessThan70,
gBirchDexRatingText_LessThan80,
gBirchDexRatingText_LessThan90,
gBirchDexRatingText_LessThan100,
gBirchDexRatingText_LessThan110,
gBirchDexRatingText_LessThan120,
gBirchDexRatingText_LessThan130,
gBirchDexRatingText_LessThan140,
gBirchDexRatingText_LessThan150,
gBirchDexRatingText_LessThan160,
gBirchDexRatingText_LessThan170,
gBirchDexRatingText_LessThan180,
gBirchDexRatingText_LessThan190,
gBirchDexRatingText_LessThan200,
gBirchDexRatingText_DexCompleted,
};

void BufferPokedexRatingForMatchCall(u8 *destStr)
{
int numSeen, numCaught;
u8 *str;
u8 dexRatingLevel;

u8 *buffer = Alloc(sizeof(gStringVar4));
if (!buffer)
Expand All @@ -2063,12 +1984,11 @@ void BufferPokedexRatingForMatchCall(u8 *destStr)
numCaught = GetHoennPokedexCount(FLAG_GET_CAUGHT);
ConvertIntToDecimalStringN(gStringVar1, numSeen, STR_CONV_MODE_LEFT_ALIGN, 3);
ConvertIntToDecimalStringN(gStringVar2, numCaught, STR_CONV_MODE_LEFT_ALIGN, 3);
dexRatingLevel = GetPokedexRatingLevel(numCaught);
str = StringCopy(buffer, gBirchDexRatingText_AreYouCurious);
*(str++) = CHAR_PROMPT_CLEAR;
str = StringCopy(str, gBirchDexRatingText_SoYouveSeenAndCaught);
*(str++) = CHAR_PROMPT_CLEAR;
StringCopy(str, sBirchDexRatingTexts[dexRatingLevel]);
StringCopy(str, GetPokedexRatingText(numCaught));
str = StringExpandPlaceholders(destStr, buffer);

if (IsNationalPokedexEnabled())
Expand Down
48 changes: 27 additions & 21 deletions src/pokedex_plus_hgss.c
Original file line number Diff line number Diff line change
Expand Up @@ -6481,13 +6481,37 @@ static u8 PrintPreEvolutions(u8 taskId, u16 species)
u16 preEvolutionTwo = 0;
u8 numPreEvolutions = 0;

bool8 isMega = FALSE;
u16 baseFormSpecies;
sPokedexView->sEvoScreenData.isMega = FALSE;

//Check if it's a mega
baseFormSpecies = GetFormSpeciesId(species, 0);
if (baseFormSpecies != species)
{
const struct FormChange *formChanges = GetSpeciesFormChanges(baseFormSpecies);
for (i = 0; formChanges != NULL && formChanges[i].method != FORM_CHANGE_TERMINATOR; i++)
{
if (formChanges[i].method == FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM
&& formChanges[i].targetSpecies == species)
{
preEvolutionOne = baseFormSpecies;
numPreEvolutions += 1;
sPokedexView->numPreEvolutions = numPreEvolutions;
sPokedexView->sEvoScreenData.numAllEvolutions += numPreEvolutions;
sPokedexView->sEvoScreenData.isMega = TRUE;

CopyItemName(GetSpeciesFormChanges(species)->param1, gStringVar2); //item
CreateCaughtBallEvolutionScreen(preEvolutionOne, base_x - 9 - 8, base_y + base_y_offset*(numPreEvolutions - 1), 0);
HandlePreEvolutionSpeciesPrint(taskId, preEvolutionOne, species, base_x - 8, base_y, base_y_offset, numPreEvolutions - 1);
return numPreEvolutions;
}
}
}

//Calculate previous evolution
for (i = 0; i < NUM_SPECIES; i++)
{
const struct Evolution *evolutions = GetSpeciesEvolutions(species);
const struct Evolution *evolutions = GetSpeciesEvolutions(i);
if (evolutions == NULL)
continue;

Expand All @@ -6497,35 +6521,17 @@ static u8 PrintPreEvolutions(u8 taskId, u16 species)
{
preEvolutionOne = i;
numPreEvolutions += 1;

if (GetSpeciesFormChanges(species) != NULL
&& GetSpeciesFormChanges(species)->method == FORM_CHANGE_BATTLE_MEGA_EVOLUTION_ITEM)
{
CopyItemName(GetSpeciesFormChanges(species)->param1, gStringVar2); //item
isMega = TRUE;
}
break;
}
}
}

if (isMega)
{
sPokedexView->numPreEvolutions = numPreEvolutions;
sPokedexView->sEvoScreenData.numAllEvolutions += numPreEvolutions;
sPokedexView->sEvoScreenData.isMega = isMega;

CreateCaughtBallEvolutionScreen(preEvolutionOne, base_x - 9 - 8, base_y + base_y_offset*(numPreEvolutions - 1), 0);
HandlePreEvolutionSpeciesPrint(taskId, preEvolutionOne, species, base_x - 8, base_y, base_y_offset, numPreEvolutions - 1);
return numPreEvolutions;
}

//Calculate if previous evolution also has a previous evolution
if (numPreEvolutions != 0)
{
for (i = 0; i < NUM_SPECIES; i++)
{
const struct Evolution *evolutions = GetSpeciesEvolutions(species);
const struct Evolution *evolutions = GetSpeciesEvolutions(i);
if (evolutions == NULL)
continue;

Expand Down

0 comments on commit dbaaaea

Please sign in to comment.