From 67157250efeaf5ffefc45ac1955b09f27f09788b Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Thu, 25 Apr 2024 01:38:53 -0500 Subject: [PATCH] Can't change the forced Tera Type anymore --- src/battle_main.c | 3 ++- src/battle_terastal.c | 7 ++----- src/battle_tower.c | 3 ++- src/pokemon.c | 15 +++++++-------- src/script_pokemon_util.c | 3 ++- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index d2225ff76b..c0ff2d9bb5 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -2330,7 +2330,8 @@ u8 CreateNPCTrainerPartyFromTrainer(struct Pokemon *party, const struct Trainer if (partyData[i].teraType > 0) { u32 data = partyData[i].teraType; - SetMonData(&party[i], MON_DATA_TERA_TYPE, &data); + if (gSpeciesInfo[partyData[i].species].forceTeraType == TYPE_NONE) + SetMonData(&party[i], MON_DATA_TERA_TYPE, &data); } CalculateMonStats(&party[i]); diff --git a/src/battle_terastal.c b/src/battle_terastal.c index 3960cf5219..b0db13bc07 100644 --- a/src/battle_terastal.c +++ b/src/battle_terastal.c @@ -82,13 +82,10 @@ bool32 CanTerastallize(u32 battler) // Returns a pokemon's Tera type. u32 GetTeraType(struct Pokemon *mon) { - if (GetMonData(mon, MON_DATA_TERA_TYPE) + 1 == 0) // no tera type, so generate it + if (GetMonData(mon, MON_DATA_TERA_TYPE) == -1) // no tera type, so generate it { u16 species = GetMonData(mon, MON_DATA_SPECIES); - - if (gSpeciesInfo[species].forceTeraType != TYPE_NONE) - SetMonData(mon, MON_DATA_TERA_TYPE, &gSpeciesInfo[species].forceTeraType); - else + if (gSpeciesInfo[species].forceTeraType == TYPE_NONE) SetMonData(mon, MON_DATA_TERA_TYPE, ((GetMonData(mon, MON_DATA_PERSONALITY) & 0x1) == 0 ? &(gSpeciesInfo[species].types[0]) : &(gSpeciesInfo[species].types[1]))); } diff --git a/src/battle_tower.c b/src/battle_tower.c index fd0641cc6f..2dfce950fa 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -1643,7 +1643,8 @@ void CreateFacilityMon(const struct TrainerMon *fmon, u16 level, u8 fixedIV, u32 if (fmon->teraType) { u32 data = fmon->teraType; - SetMonData(dst, MON_DATA_TERA_TYPE, &data); + if (gSpeciesInfo[fmon->species].forceTeraType == TYPE_NONE) + SetMonData(dst, MON_DATA_TERA_TYPE, &data); } diff --git a/src/pokemon.c b/src/pokemon.c index 56d5d43ca7..992c04115d 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -1020,9 +1020,7 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV, SetBoxMonData(boxMon, MON_DATA_ABILITY_NUM, &value); } - if (gSpeciesInfo[species].forceTeraType != TYPE_NONE) - SetBoxMonData(boxMon, MON_DATA_TERA_TYPE, &(gSpeciesInfo[species].forceTeraType)); - else + if (gSpeciesInfo[species].forceTeraType == TYPE_NONE) SetBoxMonData(boxMon, MON_DATA_TERA_TYPE, ((personality & 0x1) == 0 ? &(gSpeciesInfo[species].types[0]) : &(gSpeciesInfo[species].types[1]))); GiveBoxMonInitialMoveset(boxMon); @@ -2543,7 +2541,10 @@ u32 GetBoxMonData3(struct BoxPokemon *boxMon, s32 field, u8 *data) break; case MON_DATA_TERA_TYPE: { - retVal = substruct0->teraType - 1; + if (gSpeciesInfo[substruct0->species].forceTeraType != TYPE_NONE) + retVal = gSpeciesInfo[substruct0->species].forceTeraType; + else + retVal = substruct0->teraType - 1; break; } case MON_DATA_EVOLUTION_TRACKER: @@ -6274,9 +6275,6 @@ u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *boxMon, u16 method, u32 } } - if (gSpeciesInfo[targetSpecies].forceTeraType != TYPE_NONE) // Doing this here seems to cover all cases - SetBoxMonData(boxMon, MON_DATA_TERA_TYPE, &gSpeciesInfo[targetSpecies].forceTeraType); - return targetSpecies; } @@ -6526,7 +6524,8 @@ void UpdateMonPersonality(struct BoxPokemon *boxMon, u32 personality) SetBoxMonData(boxMon, MON_DATA_IS_SHINY, &isShiny); SetBoxMonData(boxMon, MON_DATA_HIDDEN_NATURE, &hiddenNature); - SetBoxMonData(boxMon, MON_DATA_TERA_TYPE, &teraType); + if (gSpeciesInfo[GetBoxMonData(boxMon, MON_DATA_SPECIES)].forceTeraType == TYPE_NONE) + SetBoxMonData(boxMon, MON_DATA_TERA_TYPE, &teraType); } void HealPokemon(struct Pokemon *mon) diff --git a/src/script_pokemon_util.c b/src/script_pokemon_util.c index 763bb3f9e6..a9e716b28d 100644 --- a/src/script_pokemon_util.c +++ b/src/script_pokemon_util.c @@ -334,7 +334,8 @@ u32 ScriptGiveMonParameterized(u16 species, u8 level, u16 item, u8 ball, u8 natu // tera type if (teraType >= NUMBER_OF_MON_TYPES) teraType = gSpeciesInfo[species].types[0]; - SetMonData(&mon, MON_DATA_TERA_TYPE, &teraType); + if (gSpeciesInfo[species].forceTeraType == TYPE_NONE) + SetMonData(&mon, MON_DATA_TERA_TYPE, &teraType); // EV and IV for (i = 0; i < NUM_STATS; i++)