Moved Hunger Switch to form change table.

This commit is contained in:
Eduardo Quezada 2022-11-06 17:12:34 -03:00
parent 62912f8caf
commit 2ef2134be1
5 changed files with 16 additions and 20 deletions

View File

@ -7525,6 +7525,7 @@ BattleScript_AttackerFormChangeEnd3::
BattleScript_AttackerFormChangeEnd3NoPopup:: BattleScript_AttackerFormChangeEnd3NoPopup::
call BattleScript_AttackerFormChangeNoPopup call BattleScript_AttackerFormChangeNoPopup
end3
BattleScript_AttackerFormChangeMoveEffect:: BattleScript_AttackerFormChangeMoveEffect::
waitmessage 1 waitmessage 1

View File

@ -84,3 +84,7 @@
// The battle indicator icon is based on the species, with Primal Groudon's as Omega and otherwise being Alpha. // The battle indicator icon is based on the species, with Primal Groudon's as Omega and otherwise being Alpha.
// param1: item to hold. // param1: item to hold.
#define FORM_CHANGE_BATTLE_PRIMAL_REVERSION 13 #define FORM_CHANGE_BATTLE_PRIMAL_REVERSION 13
// Form change that activates automatically when the turn ends.
// param1: ability to check.
#define FORM_CHANGE_BATTLE_TURN_END 14

View File

@ -3817,7 +3817,6 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
ProtectChecks(battlerAtk, battlerDef, move, predictedMove, &score); ProtectChecks(battlerAtk, battlerDef, move, predictedMove, &score);
break; break;
case MOVE_KINGS_SHIELD: case MOVE_KINGS_SHIELD:
#if (defined SPECIES_AEGISLASH && defined SPECIES_AEGISLASH_BLADE)
if (AI_DATA->abilities[battlerAtk] == ABILITY_STANCE_CHANGE //Special logic for Aegislash if (AI_DATA->abilities[battlerAtk] == ABILITY_STANCE_CHANGE //Special logic for Aegislash
&& gBattleMons[battlerAtk].species == SPECIES_AEGISLASH_BLADE && gBattleMons[battlerAtk].species == SPECIES_AEGISLASH_BLADE
&& !IsBattlerIncapacitated(battlerDef, AI_DATA->abilities[battlerDef])) && !IsBattlerIncapacitated(battlerDef, AI_DATA->abilities[battlerDef]))
@ -3825,7 +3824,6 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
score += 3; score += 3;
break; break;
} }
#endif
//fallthrough //fallthrough
default: // protect default: // protect
ProtectChecks(battlerAtk, battlerDef, move, predictedMove, &score); ProtectChecks(battlerAtk, battlerDef, move, predictedMove, &score);
@ -4484,7 +4482,6 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
score += 3; score += 3;
break; break;
case EFFECT_RELIC_SONG: case EFFECT_RELIC_SONG:
#if (defined SPECIES_MELOETTA && defined SPECIES_MELOETTA_PIROUETTE)
if (!(gBattleMons[battlerAtk].status2 & STATUS2_TRANSFORMED)) // Don't try to change form if it's transformed. if (!(gBattleMons[battlerAtk].status2 & STATUS2_TRANSFORMED)) // Don't try to change form if it's transformed.
{ {
if (gBattleMons[battlerAtk].species == SPECIES_MELOETTA && gBattleMons[battlerDef].defense < gBattleMons[battlerDef].spDefense) if (gBattleMons[battlerAtk].species == SPECIES_MELOETTA && gBattleMons[battlerDef].defense < gBattleMons[battlerDef].spDefense)
@ -4492,7 +4489,6 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
else if (gBattleMons[battlerAtk].species == SPECIES_MELOETTA_PIROUETTE && gBattleMons[battlerDef].spDefense < gBattleMons[battlerDef].defense) else if (gBattleMons[battlerAtk].species == SPECIES_MELOETTA_PIROUETTE && gBattleMons[battlerDef].spDefense < gBattleMons[battlerDef].defense)
score += 3; // Change to Aria if can do more damage score += 3; // Change to Aria if can do more damage
} }
#endif
break; break;
case EFFECT_ELECTRIC_TERRAIN: case EFFECT_ELECTRIC_TERRAIN:
case EFFECT_MISTY_TERRAIN: case EFFECT_MISTY_TERRAIN:

View File

@ -5019,18 +5019,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
} }
break; break;
case ABILITY_HUNGER_SWITCH: case ABILITY_HUNGER_SWITCH:
if (!(gBattleMons[battler].status2 & STATUS2_TRANSFORMED)) if (TryBattleFormChange(battler, FORM_CHANGE_BATTLE_TURN_END))
{ {
if (gBattleMons[battler].species == SPECIES_MORPEKO) BattleScriptPushCursorAndCallback(BattleScript_AttackerFormChangeEnd3NoPopup);
{
gBattleMons[battler].species = SPECIES_MORPEKO_HANGRY;
BattleScriptPushCursorAndCallback(BattleScript_AttackerFormChangeEnd3NoPopup);
}
else if (gBattleMons[battler].species == SPECIES_MORPEKO_HANGRY)
{
gBattleMons[battler].species = SPECIES_MORPEKO;
BattleScriptPushCursorAndCallback(BattleScript_AttackerFormChangeEnd3NoPopup);
}
effect++; effect++;
} }
break; break;
@ -9788,7 +9779,6 @@ u16 GetBattleFormChangeTargetSpecies(u8 battlerId, u16 method)
targetSpecies = formChanges[i].targetSpecies; targetSpecies = formChanges[i].targetSpecies;
break; break;
case FORM_CHANGE_BATTLE_HP_PERCENT: case FORM_CHANGE_BATTLE_HP_PERCENT:
{
if (formChanges[i].param1 == GetBattlerAbility(battlerId)) if (formChanges[i].param1 == GetBattlerAbility(battlerId))
{ {
// We multiply by 100 to make sure that integer division doesn't mess with the health check. // We multiply by 100 to make sure that integer division doesn't mess with the health check.
@ -9806,7 +9796,10 @@ u16 GetBattleFormChangeTargetSpecies(u8 battlerId, u16 method)
} }
} }
break; break;
} case FORM_CHANGE_BATTLE_TURN_END:
if (formChanges[i].param1 == GetBattlerAbility(battlerId))
targetSpecies = formChanges[i].targetSpecies;
break;
} }
} }
} }

View File

@ -604,9 +604,11 @@ static const struct FormChange sCramorantFormChangeTable[] = {
}; };
static const struct FormChange sMorpekoFormChangeTable[] = { static const struct FormChange sMorpekoFormChangeTable[] = {
{FORM_CHANGE_BATTLE_SWITCH, SPECIES_MORPEKO}, {FORM_CHANGE_BATTLE_TURN_END, SPECIES_MORPEKO_HANGRY, ABILITY_HUNGER_SWITCH},
{FORM_CHANGE_FAINT, SPECIES_MORPEKO}, {FORM_CHANGE_BATTLE_TURN_END, SPECIES_MORPEKO , ABILITY_HUNGER_SWITCH},
{FORM_CHANGE_END_BATTLE, SPECIES_MORPEKO}, {FORM_CHANGE_BATTLE_SWITCH, SPECIES_MORPEKO},
{FORM_CHANGE_FAINT, SPECIES_MORPEKO},
{FORM_CHANGE_END_BATTLE, SPECIES_MORPEKO},
{FORM_CHANGE_TERMINATOR}, {FORM_CHANGE_TERMINATOR},
}; };