Fix default tera type changing upon evolution/form change (#5422)

This commit is contained in:
Bassoonian 2024-09-22 16:33:17 +02:00 committed by GitHub
parent ed005fc345
commit 918d45a623
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 15 deletions

View file

@ -545,19 +545,13 @@ static void CB2_TradeEvolutionSceneUpdate(void)
static void CreateShedinja(u16 preEvoSpecies, struct Pokemon *mon)
{
u32 data = 0;
#if P_SHEDINJA_BALL >= GEN_4
u16 ball = ITEM_POKE_BALL;
#endif
const struct Evolution *evolutions = GetSpeciesEvolutions(preEvoSpecies);
if (evolutions == NULL)
return;
if (evolutions[0].method == EVO_LEVEL_NINJASK && gPlayerPartyCount < PARTY_SIZE
#if P_SHEDINJA_BALL >= GEN_4
&& (CheckBagHasItem(ball, 1))
#endif
)
if (evolutions[0].method == EVO_LEVEL_NINJASK && gPlayerPartyCount < PARTY_SIZE && (P_SHEDINJA_BALL < GEN_4 || CheckBagHasItem(ball, 1)))
{
s32 i;
struct Pokemon *shedinja = &gPlayerParty[gPlayerPartyCount];
@ -567,10 +561,11 @@ static void CreateShedinja(u16 preEvoSpecies, struct Pokemon *mon)
SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_NICKNAME, GetSpeciesName(evolutions[1].targetSpecies));
SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_HELD_ITEM, &data);
SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_MARKINGS, &data);
#if P_SHEDINJA_BALL >= GEN_4
if (P_SHEDINJA_BALL >= GEN_4)
{
SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_POKEBALL, &ball);
RemoveBagItem(ball, 1);
#endif
}
for (i = MON_DATA_COOL_RIBBON; i < MON_DATA_COOL_RIBBON + CONTEST_CATEGORIES_COUNT; i++)
SetMonData(&gPlayerParty[gPlayerPartyCount], i, &data);

View file

@ -2791,6 +2791,8 @@ u32 GetBoxMonData3(struct BoxPokemon *boxMon, s32 field, u8 *data)
{
const u8 *types = gSpeciesInfo[substruct0->species].types;
retVal = (boxMon->personality & 0x1) == 0 ? types[0] : types[1];
// To avoid this value changing upon form change/evolution, we directly set it for future cases
SetBoxMonData(boxMon, MON_DATA_TERA_TYPE, &retVal);
}
else
{

View file

@ -325,20 +325,25 @@ TEST("givemon [vars]")
EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_TERA_TYPE), TYPE_FIRE);
}
TEST("checkteratype/setteratype work")
TEST("checkteratype works")
{
CreateMon(&gPlayerParty[0], SPECIES_WOBBUFFET, 100, 0, FALSE, 0, OT_ID_PRESET, 0);
RUN_OVERWORLD_SCRIPT(
checkteratype 0;
);
EXPECT(VarGet(VAR_RESULT) == TYPE_PSYCHIC);
EXPECT_EQ(VarGet(VAR_RESULT), TYPE_PSYCHIC);
}
TEST("setteratype works")
{
CreateMon(&gPlayerParty[0], SPECIES_WOBBUFFET, 100, 0, FALSE, 0, OT_ID_PRESET, 0);
RUN_OVERWORLD_SCRIPT(
setteratype TYPE_FIRE, 0;
checkteratype 0;
);
EXPECT(VarGet(VAR_RESULT) == TYPE_FIRE);
EXPECT_EQ(VarGet(VAR_RESULT), TYPE_FIRE);
}
TEST("createmon [simple]")