Skip to content

Commit

Permalink
Fixed Unnerve message and wrote tests (#6192)
Browse files Browse the repository at this point in the history
Co-authored-by: Hedara <hedara90@gmail.com>
  • Loading branch information
hedara90 and Hedara authored Feb 5, 2025
1 parent ea3b812 commit f6d1773
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -4629,6 +4629,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
case ABILITY_UNNERVE:
if (!gSpecialStatuses[battler].switchInAbilityDone)
{
gBattlerTarget = GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerAtPosition(battler)));
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_UNNERVE;
gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
Expand All @@ -4639,6 +4640,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
case ABILITY_AS_ONE_SHADOW_RIDER:
if (!gSpecialStatuses[battler].switchInAbilityDone)
{
gBattlerTarget = GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerAtPosition(battler)));
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_ASONE;
gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_ActivateAsOne);
Expand Down
72 changes: 70 additions & 2 deletions test/battle/ability/unnerve.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,73 @@
#include "test/battle.h"

// Remember to add a PARAMETRIZE for As One in the following tests:
TO_DO_BATTLE_TEST("Unnerve prevents opposing Pokémon from eating their own berries");
TO_DO_BATTLE_TEST("Unnerve doesn't prevent opposing Pokémon from using Natural Gift");
SINGLE_BATTLE_TEST("Unnerve prevents opposing Pokémon from eating their own berries")
{
u16 mon;
u16 ability;
PARAMETRIZE { mon = SPECIES_JOLTIK, ability = ABILITY_UNNERVE; }
PARAMETRIZE { mon = SPECIES_CALYREX_ICE, ability = ABILITY_AS_ONE_ICE_RIDER; }
GIVEN {
ASSUME(gItemsInfo[ITEM_RAWST_BERRY].holdEffect == HOLD_EFFECT_CURE_BRN);
PLAYER(mon) { Ability(ability); }
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_RAWST_BERRY); Status1(STATUS1_BURN); }
} WHEN {
TURN { }
} SCENE {
ABILITY_POPUP(player, ability);
NOT ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent);
HP_BAR(opponent);
}
}

SINGLE_BATTLE_TEST("Unnerve doesn't prevent opposing Pokémon from using Natural Gift")
{
u16 mon;
u16 ability;
PARAMETRIZE { mon = SPECIES_JOLTIK, ability = ABILITY_UNNERVE; }
PARAMETRIZE { mon = SPECIES_CALYREX_ICE, ability = ABILITY_AS_ONE_ICE_RIDER; }
GIVEN {
ASSUME(gMovesInfo[MOVE_NATURAL_GIFT].effect == EFFECT_NATURAL_GIFT);
PLAYER(mon) { Ability(ability); }
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_ORAN_BERRY); }
} WHEN {
TURN { MOVE(opponent, MOVE_NATURAL_GIFT); }
} SCENE {
ABILITY_POPUP(player, ability);
HP_BAR(player);
}
}

SINGLE_BATTLE_TEST("Unnerve prints the correct string (player)")
{
u16 mon;
u16 ability;
PARAMETRIZE { mon = SPECIES_JOLTIK, ability = ABILITY_UNNERVE; }
PARAMETRIZE { mon = SPECIES_CALYREX_ICE, ability = ABILITY_AS_ONE_ICE_RIDER; }
GIVEN {
PLAYER(mon) { Ability(ability); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN {}
} SCENE {
ABILITY_POPUP(player, ability);
MESSAGE("The opposing team is too nervous to eat Berries!");
}
}

SINGLE_BATTLE_TEST("Unnerve prints the correct string (opponent)")
{
u16 mon;
u16 ability;
PARAMETRIZE { mon = SPECIES_JOLTIK, ability = ABILITY_UNNERVE; }
PARAMETRIZE { mon = SPECIES_CALYREX_ICE, ability = ABILITY_AS_ONE_ICE_RIDER; }
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(mon) { Ability(ability); }
} WHEN {
TURN {}
} SCENE {
ABILITY_POPUP(opponent, ability);
MESSAGE("Your team is too nervous to eat Berries!");
}
}

0 comments on commit f6d1773

Please sign in to comment.