diff --git a/src/battle_util.c b/src/battle_util.c index cb46689608..e70691d68d 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4474,6 +4474,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32 if (!gSpecialStatuses[battler].switchInAbilityDone) { gSpecialStatuses[battler].switchInAbilityDone = TRUE; + gBattlerAttacker = battler; BattleScriptPushCursorAndCallback(BattleScript_FriskActivates); // Try activate effect++; } diff --git a/test/battle/ability/frisk.c b/test/battle/ability/frisk.c new file mode 100644 index 0000000000..916a0eaa28 --- /dev/null +++ b/test/battle/ability/frisk.c @@ -0,0 +1,82 @@ +#include "global.h" +#include "test/battle.h" + +DOUBLE_BATTLE_TEST("Frisk does not trigger when pokemon hold no items") +{ + GIVEN { + PLAYER(SPECIES_FURRET) { Ability(ABILITY_FRISK); }; + PLAYER(SPECIES_FURRET) { Ability(ABILITY_FRISK); }; + OPPONENT(SPECIES_SENTRET) { Ability(ABILITY_FRISK); }; + OPPONENT(SPECIES_SENTRET) { Ability(ABILITY_FRISK); }; + } WHEN { + TURN { ; } + } SCENE { + NONE_OF { + ABILITY_POPUP(playerLeft, ABILITY_FRISK); + ABILITY_POPUP(playerRight, ABILITY_FRISK); + ABILITY_POPUP(opponentLeft, ABILITY_FRISK); + ABILITY_POPUP(opponentRight, ABILITY_FRISK); + } + } +} + +SINGLE_BATTLE_TEST("Frisk triggers in a Single Battle") +{ + GIVEN { + PLAYER(SPECIES_FURRET) { Ability(ABILITY_FRISK); Item(ITEM_POTION); }; + OPPONENT(SPECIES_SENTRET) { Ability(ABILITY_FRISK); Item(ITEM_POTION); }; + } WHEN { + TURN { ; } + } SCENE { + ABILITY_POPUP(player, ABILITY_FRISK); + MESSAGE("Furret frisked Foe Sentret and found its Potion!"); + ABILITY_POPUP(opponent, ABILITY_FRISK); + MESSAGE("Foe Sentret frisked Furret and found its Potion!"); + } +} + +DOUBLE_BATTLE_TEST("Frisk triggers for player in a Double Battle after switching-in after fainting") +{ + bool32 targetLeft; + PARAMETRIZE { targetLeft = TRUE; } + PARAMETRIZE { targetLeft = FALSE; } + + GIVEN { + ASSUME(gBattleMoves[MOVE_POUND].power != 0); + PLAYER(SPECIES_WOBBUFFET) { HP(1); } + PLAYER(SPECIES_WOBBUFFET) { HP(1); } + PLAYER(SPECIES_FURRET) { Ability(ABILITY_FRISK); }; + OPPONENT(SPECIES_WYNAUT) { Item(ITEM_POTION); } + OPPONENT(SPECIES_WYNAUT); + } WHEN { + TURN { MOVE(opponentLeft, MOVE_POUND, target: targetLeft ? playerLeft : playerRight); SEND_OUT(targetLeft ? playerLeft : playerRight, 2); } + } SCENE { + MESSAGE("Foe Wynaut used Pound!"); + MESSAGE("Wobbuffet fainted!"); + ABILITY_POPUP(targetLeft ? playerLeft : playerRight, ABILITY_FRISK); + MESSAGE("Furret frisked Foe Wynaut and found its Potion!"); + } +} + +DOUBLE_BATTLE_TEST("Frisk triggers for opponent in a Double Battle after switching-in after fainting") +{ + bool32 targetLeft; + PARAMETRIZE { targetLeft = TRUE; } + PARAMETRIZE { targetLeft = FALSE; } + + GIVEN { + ASSUME(gBattleMoves[MOVE_POUND].power != 0); + PLAYER(SPECIES_WYNAUT) { Item(ITEM_POTION); } + PLAYER(SPECIES_WYNAUT); + OPPONENT(SPECIES_WOBBUFFET) { HP(1); } + OPPONENT(SPECIES_WOBBUFFET) { HP(1); } + OPPONENT(SPECIES_FURRET) { Ability(ABILITY_FRISK); }; + } WHEN { + TURN { MOVE(playerLeft, MOVE_POUND, target: targetLeft ? opponentLeft : opponentRight); SEND_OUT(targetLeft ? opponentLeft : opponentRight, 2); } + } SCENE { + MESSAGE("Wynaut used Pound!"); + MESSAGE("Foe Wobbuffet fainted!"); + ABILITY_POPUP(targetLeft ? opponentLeft : opponentRight, ABILITY_FRISK); + MESSAGE("Foe Furret frisked Wynaut and found its Potion!"); + } +}