Rage fist fix (#9405)
Some checks are pending
CI / build (push) Waiting to run
CI / docs_validate (push) Waiting to run
CI / allcontributors (push) Waiting to run
Docs / deploy (push) Waiting to run

This commit is contained in:
Maxime Gr 2026-03-08 02:00:06 +01:00 committed by GitHub
parent 7139ebd19d
commit 48b29169ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 4 deletions

View File

@ -41,13 +41,15 @@ static u32 GetSwitchinHitsToKO(s32 damageTaken, enum BattlerId battler, const st
static void GetIncomingHealInfo(enum BattlerId battler, struct IncomingHealInfo *healInfo);
static u32 GetWishHealAmountForBattler(enum BattlerId battler);
static void InitializeSwitchinCandidate(enum BattlerId switchinBattler, struct Pokemon *mon)
static void InitializeSwitchinCandidate(enum BattlerId switchinBattler, u32 monIndex, struct Pokemon *mon)
{
u32 storeCurrBattlerPartyIndex = gBattlerPartyIndexes[switchinBattler]; // Rage Fist fix
PokemonToBattleMon(mon, &gBattleMons[switchinBattler]);
// Setup switchin battler data
gAiThinkingStruct->saved[switchinBattler].saved = TRUE;
SetBattlerAiData(switchinBattler, gAiLogicData);
SetBattlerFieldStatusForSwitchin(switchinBattler);
gBattlerPartyIndexes[switchinBattler] = monIndex;
for (enum BattlerId battlerIndex = 0; battlerIndex < gBattlersCount; battlerIndex++)
{
if (switchinBattler == battlerIndex || !IsBattlerAlive(battlerIndex))
@ -57,6 +59,7 @@ static void InitializeSwitchinCandidate(enum BattlerId switchinBattler, struct P
CalcBattlerAiMovesData(gAiLogicData, battlerIndex, switchinBattler, AI_GetSwitchinWeather(switchinBattler), AI_GetSwitchinFieldStatus(switchinBattler));
}
gBattlerPartyIndexes[switchinBattler] = storeCurrBattlerPartyIndex;
gAiThinkingStruct->saved[switchinBattler].saved = FALSE;
}
@ -2139,7 +2142,7 @@ static u32 GetBestMonIntegrated(struct Pokemon *party, int firstId, int lastId,
validMonIds |= (1u << monIndex);
}
InitializeSwitchinCandidate(battler, &party[monIndex]);
InitializeSwitchinCandidate(battler, monIndex, &party[monIndex]);
u32 originalHp = gBattleMons[battler].hp;
@ -2395,7 +2398,7 @@ static u32 GetBestMonVanilla(struct Pokemon *party, int firstId, int lastId, enu
{
validMonIds |= (1u << monIndex);
}
InitializeSwitchinCandidate(battler, &party[monIndex]);
InitializeSwitchinCandidate(battler, monIndex, &party[monIndex]);
// While not really invalid per se, not really wise to switch into this mon
if (gAiLogicData->abilities[battler] == ABILITY_TRUANT && IsTruantMonVulnerable(battler, opposingBattler))
@ -2547,7 +2550,7 @@ u32 AI_SelectRevivalBlessingMon(enum BattlerId battler)
bool32 isAceMon = IsAceMon(battler, monIndex);
InitializeSwitchinCandidate(battler, &party[monIndex]);
InitializeSwitchinCandidate(battler, monIndex, &party[monIndex]);
gBattleMons[battler].hp = gBattleMons[battler].maxHP / 2; // Revival Blessing restores half HP
gBattleMons[battler].status1 = 0;

View File

@ -2212,3 +2212,16 @@ AI_MULTI_BATTLE_TEST("AI will not switch out if the opposite battler is absent a
}
}
}
AI_SINGLE_BATTLE_TEST("Rage Fist stacks are seen properly for switch logic")
{
GIVEN {
AI_FLAGS(AI_FLAG_CHECK_BAD_MOVE | AI_FLAG_CHECK_VIABILITY | AI_FLAG_TRY_TO_FAINT | AI_FLAG_SMART_SWITCHING | AI_FLAG_SMART_MON_CHOICES | AI_FLAG_OMNISCIENT);
PLAYER(SPECIES_VICTINI) { Level(70); Speed(2); Ability(ABILITY_VICTORY_STAR); Moves(MOVE_V_CREATE, MOVE_PSYCHIC); }
OPPONENT(SPECIES_ZIGZAGOON) { Level(1); Speed(1); HP(1); Moves(MOVE_TACKLE); }
OPPONENT(SPECIES_GROUDON) { Level(85); Speed(3); Moves(MOVE_PRECIPICE_BLADES); }
OPPONENT(SPECIES_ANNIHILAPE) { Level(85); Speed(3); Moves(MOVE_RAGE_FIST); }
} WHEN {
TURN { MOVE(player, MOVE_PSYCHIC); EXPECT_SEND_OUT(opponent, 1); }
}
}