Skip to content

Commit

Permalink
Fix Mold Breaker-like abilities, AI Move Accuracy function, Fury Cutt…
Browse files Browse the repository at this point in the history
…er with Parental Bond (#5030)

* Fix GetBattlerAbility not checking correct battler's action

* Fix Fury Cutter counter being incorrectly incremented on 2nd hit of Parental Bond + test

* Fix AI_SetMoveAccuracy only using attacker's ability

* Review
  • Loading branch information
PhallenTree authored Jul 24, 2024
1 parent 7a4df80 commit 7b2914c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/battle_ai_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ static u32 Ai_SetMoveAccuracy(struct AiLogicData *aiData, u32 battlerAtk, u32 ba
{
u32 accuracy;
u32 abilityAtk = aiData->abilities[battlerAtk];
u32 abilityDef = aiData->abilities[battlerAtk];
u32 abilityDef = aiData->abilities[battlerDef];
if (abilityAtk == ABILITY_NO_GUARD || abilityDef == ABILITY_NO_GUARD || gMovesInfo[move].accuracy == 0) // Moves with accuracy 0 or no guard ability always hit.
accuracy = 100;
else
Expand Down
2 changes: 1 addition & 1 deletion src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -13407,7 +13407,7 @@ static void Cmd_handlefurycutter(void)
max = 5;

if (gDisableStructs[gBattlerAttacker].furyCutterCounter < max
&& gSpecialStatuses[gBattlerAttacker].parentalBondState != PARENTAL_BOND_1ST_HIT) // Don't increment counter on first hit
&& gSpecialStatuses[gBattlerAttacker].parentalBondState != PARENTAL_BOND_2ND_HIT) // Don't increment counter on second hit
gDisableStructs[gBattlerAttacker].furyCutterCounter++;

gBattlescriptCurrInstr = cmd->nextInstr;
Expand Down
2 changes: 1 addition & 1 deletion src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -6242,7 +6242,7 @@ u32 GetBattlerAbility(u32 battler)
&& gAbilitiesInfo[gBattleMons[battler].ability].breakable
&& noAbilityShield
&& gBattlerByTurnOrder[gCurrentTurnActionNumber] == gBattlerAttacker
&& gActionsByTurnOrder[gBattlerByTurnOrder[gBattlerAttacker]] == B_ACTION_USE_MOVE
&& gActionsByTurnOrder[gCurrentTurnActionNumber] == B_ACTION_USE_MOVE
&& gCurrentTurnActionNumber < gBattlersCount)
return ABILITY_NONE;

Expand Down
24 changes: 24 additions & 0 deletions test/battle/move_effect/fury_cutter.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,27 @@ SINGLE_BATTLE_TEST("Fury Cutter power doubles with each use, up to 160 power")
EXPECT_EQ(damage[maxTurns - 2], damage[maxTurns - 1]);
}
}

SINGLE_BATTLE_TEST("Fury Cutter counter is the same for both hits of Parental Bond")
{
s16 damage[4];

GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Ability(ABILITY_PARENTAL_BOND); }
OPPONENT(SPECIES_REGIROCK);
} WHEN {
TURN { MOVE(player, MOVE_FURY_CUTTER); }
TURN { MOVE(player, MOVE_FURY_CUTTER); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_FURY_CUTTER, player);
HP_BAR(opponent, captureDamage: &damage[0]);
HP_BAR(opponent, captureDamage: &damage[1]);
ANIMATION(ANIM_TYPE_MOVE, MOVE_FURY_CUTTER, player);
HP_BAR(opponent, captureDamage: &damage[2]);
HP_BAR(opponent, captureDamage: &damage[3]);
} THEN {
EXPECT_MUL_EQ(damage[0], B_PARENTAL_BOND_DMG >= GEN_7 ? UQ_4_12(0.25) : UQ_4_12(0.5), damage[1]);
EXPECT_MUL_EQ(damage[2], B_PARENTAL_BOND_DMG >= GEN_7 ? UQ_4_12(0.25) : UQ_4_12(0.5), damage[3]);
EXPECT_NE(damage[0], damage[2]);
}
}

0 comments on commit 7b2914c

Please sign in to comment.