helper function to get the species type based on personality
This commit is contained in:
parent
3b9b24312a
commit
d767211c4a
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -7057,3 +7057,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];
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user