B_STURDY config test (#8565)

This commit is contained in:
Eduardo Quezada 2025-12-18 19:24:52 -03:00 committed by GitHub
parent fe6f72ec52
commit b78fccdb66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 31 additions and 12 deletions

View File

@ -132,7 +132,7 @@
F(SYNCHRONIZE_TOXIC, synchronizeToxic, (u32, GEN_COUNT - 1)) /* TODO: use in tests */ \
F(UPDATED_INTIMIDATE, updatedIntimidate, (u32, GEN_COUNT - 1)) \
F(OBLIVIOUS_TAUNT, obliviousTaunt, (u32, GEN_COUNT - 1)) \
F(STURDY, sturdy, (u32, GEN_COUNT - 1)) /* TODO: use in tests */ \
F(STURDY, sturdy, (u32, GEN_COUNT - 1)) \
F(PLUS_MINUS_INTERACTION, plusMinusInteraction, (u32, GEN_COUNT - 1)) /* TODO: use in tests */ \
F(WEATHER_FORMS, weatherForms, (u32, GEN_COUNT - 1)) /* TODO: use in tests */ \
F(SYMBIOSIS_GEMS, symbiosisGems, (u32, GEN_COUNT - 1)) \

View File

@ -298,7 +298,7 @@ static bool32 ShouldSwitchIfHasBadOdds(u32 battler)
// Check if mon gets one shot
if (maxDamageTaken > gBattleMons[battler].hp
&& !(gItemsInfo[gBattleMons[battler].item].holdEffect == HOLD_EFFECT_FOCUS_SASH || (!IsMoldBreakerTypeAbility(opposingBattler, gAiLogicData->abilities[opposingBattler]) && B_STURDY >= GEN_5 && aiAbility == ABILITY_STURDY)))
&& !(gItemsInfo[gBattleMons[battler].item].holdEffect == HOLD_EFFECT_FOCUS_SASH || (!IsMoldBreakerTypeAbility(opposingBattler, gAiLogicData->abilities[opposingBattler]) && GetConfig(CONFIG_STURDY) >= GEN_5 && aiAbility == ABILITY_STURDY)))
{
getsOneShot = TRUE;
}
@ -1852,7 +1852,7 @@ static u32 GetSwitchinHitsToKO(s32 damageTaken, u32 battler)
currentHP = currentHP - damageTaken;
// One shot prevention effects
if (damageTaken >= maxHP && startingHP == maxHP && (heldItemEffect == HOLD_EFFECT_FOCUS_SASH || (!opponentCanBreakMold && B_STURDY >= GEN_5 && ability == ABILITY_STURDY)) && hitsToKO < 1)
if (damageTaken >= maxHP && startingHP == maxHP && (heldItemEffect == HOLD_EFFECT_FOCUS_SASH || (!opponentCanBreakMold && GetConfig(CONFIG_STURDY) >= GEN_5 && ability == ABILITY_STURDY)) && hitsToKO < 1)
currentHP = 1;
// If mon is still alive, apply weather impact first, as it might KO the mon before it can heal with its item (order is weather -> item -> status)

View File

@ -1469,7 +1469,7 @@ bool32 CanEndureHit(u32 battler, u32 battlerTarget, u32 move)
if (!DoesBattlerIgnoreAbilityChecks(battler, gAiLogicData->abilities[battler], move))
{
if (B_STURDY >= GEN_5 && gAiLogicData->abilities[battlerTarget] == ABILITY_STURDY)
if (GetConfig(CONFIG_STURDY) >= GEN_5 && gAiLogicData->abilities[battlerTarget] == ABILITY_STURDY)
return TRUE;
if (IsMimikyuDisguised(battlerTarget))
return TRUE;
@ -3351,7 +3351,7 @@ enum AIPivot ShouldPivot(u32 battlerAtk, u32 battlerDef, enum Ability defAbility
if (!IsBattleMoveStatus(move) && ((gAiLogicData->shouldSwitch & (1u << battlerAtk))
|| (AI_BattlerAtMaxHp(battlerDef) && (gAiLogicData->holdEffects[battlerDef] == HOLD_EFFECT_FOCUS_SASH
|| (B_STURDY >= GEN_5 && defAbility == ABILITY_STURDY)
|| (GetConfig(CONFIG_STURDY) >= GEN_5 && defAbility == ABILITY_STURDY)
|| defAbility == ABILITY_MULTISCALE
|| defAbility == ABILITY_SHADOW_SHIELD))))
return SHOULD_PIVOT; // pivot to break sash/sturdy/multiscale
@ -3359,7 +3359,7 @@ enum AIPivot ShouldPivot(u32 battlerAtk, u32 battlerDef, enum Ability defAbility
else if (!hasStatBoost)
{
if (!IsBattleMoveStatus(move) && (AI_BattlerAtMaxHp(battlerDef) && (gAiLogicData->holdEffects[battlerDef] == HOLD_EFFECT_FOCUS_SASH
|| (B_STURDY >= GEN_5 && defAbility == ABILITY_STURDY)
|| (GetConfig(CONFIG_STURDY) >= GEN_5 && defAbility == ABILITY_STURDY)
|| defAbility == ABILITY_MULTISCALE
|| defAbility == ABILITY_SHADOW_SHIELD)))
return SHOULD_PIVOT; // pivot to break sash/sturdy/multiscale

View File

@ -1929,7 +1929,7 @@ static void Cmd_adjustdamage(void)
gLastUsedItem = gBattleMons[battlerDef].item;
gBattleStruct->moveResultFlags[battlerDef] |= MOVE_RESULT_FOE_HUNG_ON;
}
else if (B_STURDY >= GEN_5 && GetBattlerAbility(battlerDef) == ABILITY_STURDY && IsBattlerAtMaxHp(battlerDef))
else if (GetConfig(CONFIG_STURDY) >= GEN_5 && GetBattlerAbility(battlerDef) == ABILITY_STURDY && IsBattlerAtMaxHp(battlerDef))
{
enduredHit |= 1u << battlerDef;
RecordAbilityBattle(battlerDef, ABILITY_STURDY);

View File

@ -18,18 +18,37 @@ SINGLE_BATTLE_TEST("Sturdy prevents OHKO moves")
}
}
SINGLE_BATTLE_TEST("Sturdy prevents OHKOs")
SINGLE_BATTLE_TEST("Sturdy prevents OHKOs (Gen5+)")
{
u32 config;
PARAMETRIZE { config = GEN_4; }
PARAMETRIZE { config = GEN_5; }
GIVEN {
WITH_CONFIG(CONFIG_STURDY, config);
PLAYER(SPECIES_GEODUDE) { Ability(ABILITY_STURDY); MaxHP(100); HP(100); }
PLAYER(SPECIES_GEODUDE);
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_SEISMIC_TOSS); }
TURN {
MOVE(opponent, MOVE_SEISMIC_TOSS);
if (config < GEN_5) {
SEND_OUT(player, 1);
}
}
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_SEISMIC_TOSS, opponent);
HP_BAR(player, hp: 1);
ABILITY_POPUP(player, ABILITY_STURDY);
MESSAGE("Geodude endured the hit using Sturdy!");
if (config >= GEN_5) {
HP_BAR(player, hp: 1);
ABILITY_POPUP(player, ABILITY_STURDY);
MESSAGE("Geodude endured the hit using Sturdy!");
} else {
HP_BAR(player, hp: 0);
NONE_OF {
ABILITY_POPUP(player, ABILITY_STURDY);
MESSAGE("Geodude endured the hit using Sturdy!");
}
SEND_IN_MESSAGE("Geodude");
}
}
}