Skip to content

Commit

Permalink
Fixes Suction Cups ability popup and Red Card + Guard Dog interaction (
Browse files Browse the repository at this point in the history
  • Loading branch information
PhallenTree authored Feb 3, 2025
1 parent fe41f9e commit 5238665
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 14 deletions.
7 changes: 2 additions & 5 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -8253,15 +8253,12 @@ BattleScript_FlashFireBoost::
goto BattleScript_MoveEnd

BattleScript_AbilityPreventsPhasingOut::
pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp
printstring STRINGID_PKMNANCHORSITSELFWITH
waitmessage B_WAIT_TIME_LONG
call BattleScript_AbilityPreventsPhasingOutRet
goto BattleScript_MoveEnd

BattleScript_AbilityPreventsPhasingOutRet::
pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp
call BattleScript_AbilityPopUpTarget
printstring STRINGID_PKMNANCHORSITSELFWITH
waitmessage B_WAIT_TIME_LONG
return
Expand Down
6 changes: 3 additions & 3 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -6566,8 +6566,7 @@ static void Cmd_moveend(void)
if (redCardBattlers
&& (gMovesInfo[gCurrentMove].effect != EFFECT_HIT_SWITCH_TARGET || gBattleStruct->hitSwitchTargetFailed)
&& IsBattlerAlive(gBattlerAttacker)
&& !TestIfSheerForceAffected(gBattlerAttacker, gCurrentMove)
&& GetBattlerAbility(gBattlerAttacker) != ABILITY_GUARD_DOG)
&& !TestIfSheerForceAffected(gBattlerAttacker, gCurrentMove))
{
// Since we check if battler was damaged, we don't need to check move result.
// In fact, doing so actually prevents multi-target moves from activating red card properly
Expand All @@ -6592,7 +6591,8 @@ static void Cmd_moveend(void)
if (gMovesInfo[gCurrentMove].effect == EFFECT_HIT_ESCAPE)
gBattlescriptCurrInstr = BattleScript_MoveEnd; // Prevent user switch-in selection
BattleScriptPushCursor();
if (gBattleStruct->commanderActive[gBattlerAttacker] != SPECIES_NONE)
if (gBattleStruct->commanderActive[gBattlerAttacker] != SPECIES_NONE
|| GetBattlerAbility(gBattlerAttacker) == ABILITY_GUARD_DOG)
{
gBattlescriptCurrInstr = BattleScript_RedCardActivationNoSwitch;
}
Expand Down
38 changes: 34 additions & 4 deletions test/battle/hold_effect/red_card.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,13 @@ DOUBLE_BATTLE_TEST("Red Card activates but fails if the attacker is rooted")
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, playerLeft);
MESSAGE("Wobbuffet held up its Red Card against the opposing Wobbuffet!");
MESSAGE("The opposing Wobbuffet anchored itself with its roots!");
NOT MESSAGE("The opposing Unown was dragged out!");

// Red Card already consumed so cannot activate.
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponentRight);
NONE_OF {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, playerRight);
MESSAGE("Wynaut held up its Red Card against the opposing Wynaut!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, playerLeft);
MESSAGE("Wobbuffet held up its Red Card against the opposing Wynaut!");
}
}
}
Expand All @@ -301,12 +302,41 @@ DOUBLE_BATTLE_TEST("Red Card activates but fails if the attacker has Suction Cup
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, playerLeft);
MESSAGE("Wobbuffet held up its Red Card against the opposing Octillery!");
MESSAGE("The opposing Octillery anchors itself with Suction Cups!");
NOT MESSAGE("The opposing Unown was dragged out!");

// Red Card already consumed so cannot activate.
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponentRight);
NONE_OF {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, playerRight);
MESSAGE("Wynaut held up its Red Card against the opposing Wynaut!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, playerLeft);
MESSAGE("Wobbuffet held up its Red Card against the opposing Wynaut!");
}
}
}

DOUBLE_BATTLE_TEST("Red Card activates but fails if the attacker has Guard Dog")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_RED_CARD); }
PLAYER(SPECIES_WYNAUT);
OPPONENT(SPECIES_OKIDOGI) { Ability(ABILITY_GUARD_DOG); }
OPPONENT(SPECIES_WYNAUT);
OPPONENT(SPECIES_UNOWN);
} WHEN {
TURN {
MOVE(opponentLeft, MOVE_TACKLE, target: playerLeft);
MOVE(opponentRight, MOVE_TACKLE, target: playerLeft);
}
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponentLeft);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, playerLeft);
MESSAGE("Wobbuffet held up its Red Card against the opposing Okidogi!");
NOT MESSAGE("The opposing Unown was dragged out!");

// Red Card already consumed so cannot activate.
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponentRight);
NONE_OF {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, playerLeft);
MESSAGE("Wobbuffet held up its Red Card against the opposing Wynaut!");
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions test/battle/move_effect/hit_switch_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ SINGLE_BATTLE_TEST("Dragon Tail switches the target after Rocky Helmet and Iron
}
}

SINGLE_BATTLE_TEST("Dragon Tail effect will fails against Guard Dog ability")
SINGLE_BATTLE_TEST("Dragon Tail effect fails against target with Guard Dog")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
Expand All @@ -104,7 +104,7 @@ SINGLE_BATTLE_TEST("Dragon Tail effect will fails against Guard Dog ability")
}
}

SINGLE_BATTLE_TEST("Dragon Tail effect will fails against Suction Cups ability")
SINGLE_BATTLE_TEST("Dragon Tail effect fails against target with Suction Cups")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
Expand All @@ -114,6 +114,7 @@ SINGLE_BATTLE_TEST("Dragon Tail effect will fails against Suction Cups ability")
TURN { MOVE(player, MOVE_DRAGON_TAIL); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_DRAGON_TAIL, player);
ABILITY_POPUP(opponent, ABILITY_SUCTION_CUPS);
MESSAGE("The opposing Octillery anchors itself with Suction Cups!");
NOT MESSAGE("The opposing Charmander was dragged out!");
}
Expand Down
35 changes: 35 additions & 0 deletions test/battle/move_effect/roar.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,38 @@ SINGLE_BATTLE_TEST("Roar fails if replacements fainted")
MESSAGE("But it failed!");
}
}

SINGLE_BATTLE_TEST("Roar fails against target with Guard Dog")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_OKIDOGI) { Ability(ABILITY_GUARD_DOG); }
OPPONENT(SPECIES_CHARMANDER);
} WHEN {
TURN { MOVE(player, MOVE_ROAR); }
} SCENE {
NONE_OF {
ANIMATION(ANIM_TYPE_MOVE, MOVE_ROAR, player);
MESSAGE("The opposing Charmander was dragged out!");
}
MESSAGE("Wobbuffet used Roar!");
MESSAGE("But it failed!");
}
}

SINGLE_BATTLE_TEST("Roar fails to switch out target with Suction Cups")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_OCTILLERY) { Ability(ABILITY_SUCTION_CUPS); }
OPPONENT(SPECIES_CHARMANDER);
} WHEN {
TURN { MOVE(player, MOVE_ROAR); }
} SCENE {
MESSAGE("Wobbuffet used Roar!");
NOT ANIMATION(ANIM_TYPE_MOVE, MOVE_ROAR, player);
ABILITY_POPUP(opponent, ABILITY_SUCTION_CUPS);
MESSAGE("The opposing Octillery anchors itself with Suction Cups!");
NOT MESSAGE("The opposing Charmander was dragged out!");
}
}

0 comments on commit 5238665

Please sign in to comment.