checkteratype setteratype (#4460)

This commit is contained in:
Bassoonian 2024-04-30 00:12:34 +02:00 committed by GitHub
parent 8d175ebe89
commit c5552f53da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 48 additions and 0 deletions

View file

@ -2172,3 +2172,16 @@
.2byte \status1
.2byte \slot
.endm
@ Sets VAR_RESULT to the Pokémon in \slot's Tera Type
.macro checkteratype slot:req
callnative CheckTeraType
.2byte \slot
.endm
@ Sets the Pokémon in \slot's Tera Type
.macro setteratype type:req, slot:req
callnative SetTeraType
.byte \type
.2byte \slot
.endm

View file

@ -294,6 +294,25 @@ void ToggleGigantamaxFactor(struct ScriptContext *ctx)
}
}
void CheckTeraType(struct ScriptContext *ctx)
{
u32 partyIndex = VarGet(ScriptReadHalfword(ctx));
gSpecialVar_Result = TYPE_NONE;
if (partyIndex < PARTY_SIZE)
gSpecialVar_Result = GetMonData(&gPlayerParty[partyIndex], MON_DATA_TERA_TYPE);
}
void SetTeraType(struct ScriptContext *ctx)
{
u32 type = ScriptReadByte(ctx);
u32 partyIndex = VarGet(ScriptReadHalfword(ctx));
if (type < NUMBER_OF_MON_TYPES && partyIndex < PARTY_SIZE)
SetMonData(&gPlayerParty[partyIndex], MON_DATA_TERA_TYPE, &type);
}
u32 ScriptGiveMonParameterized(u16 species, u8 level, u16 item, u8 ball, u8 nature, u8 abilityNum, u8 gender, u8 *evs, u8 *ivs, u16 *moves, bool8 isShiny, bool8 ggMaxFactor, u8 teraType)
{
u16 nationalDexNum;

View file

@ -307,3 +307,19 @@ TEST("givemon [vars]")
EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_GIGANTAMAX_FACTOR), TRUE);
EXPECT_EQ(GetMonData(&gPlayerParty[0], MON_DATA_TERA_TYPE), TYPE_FIRE);
}
TEST("checkteratype/setteratype work")
{
CreateMon(&gPlayerParty[0], SPECIES_WOBBUFFET, 100, 0, FALSE, 0, OT_ID_PRESET, 0);
RUN_OVERWORLD_SCRIPT(
checkteratype 0;
);
EXPECT(VarGet(VAR_RESULT) == TYPE_PSYCHIC);
RUN_OVERWORLD_SCRIPT(
setteratype TYPE_FIRE, 0;
checkteratype 0;
);
EXPECT(VarGet(VAR_RESULT) == TYPE_FIRE);
}