Fixes Tera Type not being carried over to during form change / evolution (#6502)

This commit is contained in:
hedara90 2025-04-01 16:52:40 +02:00 committed by GitHub
commit 4f0caf8199
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 16 additions and 4 deletions

View File

@ -809,5 +809,6 @@ u32 CheckDynamicMoveType(struct Pokemon *mon, u32 move, u32 battler);
uq4_12_t GetDynamaxLevelHPMultiplier(u32 dynamaxLevel, bool32 inverseMultiplier);
u32 GetRegionalFormByRegion(u32 species, u32 region);
bool32 IsSpeciesForeignRegionalForm(u32 species, u32 currentRegion);
u32 GetTeraTypeFromPersonality(struct Pokemon *mon);
#endif // GUARD_POKEMON_H

View File

@ -3416,8 +3416,8 @@ static void DebugAction_Give_Pokemon_ComplexCreateMon(u8 taskId) //https://githu
SetMonData(&mon, MON_DATA_DYNAMAX_LEVEL, &dmaxLevel);
// tera type
if (teraType >= NUMBER_OF_MON_TYPES)
teraType = TYPE_NONE;
if (teraType == TYPE_NONE || teraType == TYPE_MYSTERY || teraType >= NUMBER_OF_MON_TYPES)
teraType = GetTeraTypeFromPersonality(&mon);
SetMonData(&mon, MON_DATA_TERA_TYPE, &teraType);
//IVs

View File

@ -1198,6 +1198,9 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV,
SetBoxMonData(boxMon, MON_DATA_POKEBALL, &value);
SetBoxMonData(boxMon, MON_DATA_OT_GENDER, &gSaveBlock2Ptr->playerGender);
u32 teraType = (boxMon->personality & 0x1) == 0 ? gSpeciesInfo[species].types[0] : gSpeciesInfo[species].types[1];
SetBoxMonData(boxMon, MON_DATA_TERA_TYPE, &teraType);
if (fixedIV < USE_RANDOM_IVS)
{
SetBoxMonData(boxMon, MON_DATA_HP_IV, &fixedIV);
@ -7063,3 +7066,9 @@ bool32 IsSpeciesForeignRegionalForm(u32 species, u32 currentRegion)
}
return FALSE;
}
u32 GetTeraTypeFromPersonality(struct Pokemon *mon)
{
const u8 *types = gSpeciesInfo[GetMonData(mon, MON_DATA_SPECIES)].types;
return (GetMonData(mon, MON_DATA_PERSONALITY) & 0x1) == 0 ? types[0] : types[1];
}

View File

@ -373,8 +373,8 @@ static u32 ScriptGiveMonParameterized(u8 side, u8 slot, u16 species, u8 level, u
SetMonData(&mon, MON_DATA_DYNAMAX_LEVEL, &dmaxLevel);
// tera type
if (teraType >= NUMBER_OF_MON_TYPES)
teraType = TYPE_NONE;
if (teraType == TYPE_NONE || teraType == TYPE_MYSTERY || teraType >= NUMBER_OF_MON_TYPES)
teraType = GetTeraTypeFromPersonality(&mon);
SetMonData(&mon, MON_DATA_TERA_TYPE, &teraType);
// EV and IV

View File

@ -57,6 +57,8 @@ TEST("Terastallization type is reset to the default types when setting Tera Type
CreateMon(&mon, SPECIES_PIDGEY, 100, 0, FALSE, 0, OT_ID_PRESET, 0);
SetMonData(&mon, MON_DATA_TERA_TYPE, &teraType);
EXPECT_EQ(teraType, GetMonData(&mon, MON_DATA_TERA_TYPE));
if (typeNone == TYPE_NONE)
typeNone = GetTeraTypeFromPersonality(&mon);
SetMonData(&mon, MON_DATA_TERA_TYPE, &typeNone);
typeNone = GetMonData(&mon, MON_DATA_TERA_TYPE);
EXPECT(typeNone == gSpeciesInfo[SPECIES_PIDGEY].types[0]