Fix Relic Song and abilities that change form based on HP from changing species of a transformed mon.

This commit is contained in:
Eduardo Quezada D'Ottone 2021-11-21 14:31:25 -03:00
parent 3404039330
commit 712a3e55ff
3 changed files with 11 additions and 5 deletions

View File

@ -4326,10 +4326,13 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
break; break;
case EFFECT_RELIC_SONG: case EFFECT_RELIC_SONG:
#if (defined SPECIES_MELOETTA && defined SPECIES_MELOETTA_PIROUETTE) #if (defined SPECIES_MELOETTA && defined SPECIES_MELOETTA_PIROUETTE)
if (AI_DATA->atkSpecies == SPECIES_MELOETTA && gBattleMons[battlerDef].defense < gBattleMons[battlerDef].spDefense) if (!(gBattleMons[battlerAtk].status2 & STATUS2_TRANSFORMED)) // Don't try to change form if it's transformed.
score += 3; // Change to pirouette if can do more damage {
else if (AI_DATA->atkSpecies == SPECIES_MELOETTA_PIROUETTE && gBattleMons[battlerDef].spDefense < gBattleMons[battlerDef].defense) if (AI_DATA->atkSpecies == SPECIES_MELOETTA && gBattleMons[battlerDef].defense < gBattleMons[battlerDef].spDefense)
score += 3; // Change to Aria if can do more damage score += 3; // Change to pirouette if can do more damage unless it
else if (AI_DATA->atkSpecies == SPECIES_MELOETTA_PIROUETTE && gBattleMons[battlerDef].spDefense < gBattleMons[battlerDef].defense)
score += 3; // Change to Aria if can do more damage
}
#endif #endif
break; break;
case EFFECT_ELECTRIC_TERRAIN: case EFFECT_ELECTRIC_TERRAIN:

View File

@ -3454,7 +3454,7 @@ void SetMoveEffect(bool32 primary, u32 certain)
} }
break; break;
case MOVE_EFFECT_RELIC_SONG: case MOVE_EFFECT_RELIC_SONG:
if (GetBattlerAbility(gBattlerAttacker) != ABILITY_SHEER_FORCE) if (GetBattlerAbility(gBattlerAttacker) != ABILITY_SHEER_FORCE && !(gBattleMons[gBattlerAttacker].status2 & STATUS2_TRANSFORMED))
{ {
if (gBattleMons[gBattlerAttacker].species == SPECIES_MELOETTA) if (gBattleMons[gBattlerAttacker].species == SPECIES_MELOETTA)
{ {

View File

@ -3877,6 +3877,9 @@ static bool32 ShouldChangeFormHpBased(u32 battler)
}; };
u32 i; u32 i;
if (gBattleMons[battler].status2 & STATUS2_TRANSFORMED)
return FALSE;
for (i = 0; i < ARRAY_COUNT(forms); i++) for (i = 0; i < ARRAY_COUNT(forms); i++)
{ {
if (GetBattlerAbility(battler) == forms[i][0]) if (GetBattlerAbility(battler) == forms[i][0])