Fix Red Card not getting consumed after Sticky Web activation (#3364)

This commit is contained in:
DizzyEggg 2023-10-01 15:35:12 +02:00 committed by GitHub
parent 10adba3af4
commit f840f7eb56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 1 deletions

View File

@ -6892,7 +6892,6 @@ BattleScript_RoarSuccessSwitch::
BattleScript_RoarSuccessSwitch_Ret: BattleScript_RoarSuccessSwitch_Ret:
swapattackerwithtarget @ continuation of RedCardActivates swapattackerwithtarget @ continuation of RedCardActivates
restoretarget restoretarget
removeitem BS_TARGET
setbyte sSWITCH_CASE, B_SWITCH_NORMAL setbyte sSWITCH_CASE, B_SWITCH_NORMAL
return return
@ -10170,6 +10169,7 @@ BattleScript_RedCardActivates::
swapattackerwithtarget swapattackerwithtarget
jumpifstatus3 BS_EFFECT_BATTLER, STATUS3_ROOTED, BattleScript_RedCardIngrain jumpifstatus3 BS_EFFECT_BATTLER, STATUS3_ROOTED, BattleScript_RedCardIngrain
jumpifability BS_EFFECT_BATTLER, ABILITY_SUCTION_CUPS, BattleScript_RedCardSuctionCups jumpifability BS_EFFECT_BATTLER, ABILITY_SUCTION_CUPS, BattleScript_RedCardSuctionCups
removeitem BS_SCRIPTING
setbyte sSWITCH_CASE, B_SWITCH_RED_CARD setbyte sSWITCH_CASE, B_SWITCH_RED_CARD
forcerandomswitch BattleScript_RedCardEnd forcerandomswitch BattleScript_RedCardEnd
@ changes the current battle script. the rest happens in BattleScript_RoarSuccessSwitch_Ret, if switch is successful @ changes the current battle script. the rest happens in BattleScript_RoarSuccessSwitch_Ret, if switch is successful

View File

@ -22,6 +22,8 @@ SINGLE_BATTLE_TEST("Red Card switches the attacker with a random non-fainted rep
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player); ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Wobbuffet held up its Red Card against Foe Wobbuffet!"); MESSAGE("Wobbuffet held up its Red Card against Foe Wobbuffet!");
MESSAGE("Foe Bulbasaur was dragged out!"); MESSAGE("Foe Bulbasaur was dragged out!");
} THEN {
EXPECT(player->item == ITEM_NONE);
} }
} }
@ -43,6 +45,8 @@ DOUBLE_BATTLE_TEST("Red Card switches the target with a random non-battler, non-
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, playerLeft); ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, playerLeft);
MESSAGE("Wobbuffet held up its Red Card against Foe Wobbuffet!"); MESSAGE("Wobbuffet held up its Red Card against Foe Wobbuffet!");
MESSAGE("Foe Bulbasaur was dragged out!"); MESSAGE("Foe Bulbasaur was dragged out!");
} THEN {
EXPECT(playerLeft->item == ITEM_NONE);
} }
} }
@ -61,6 +65,8 @@ SINGLE_BATTLE_TEST("Red Card does not activate if holder faints")
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player); ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Wobbuffet held up its Red Card against Foe Wobbuffet!"); MESSAGE("Wobbuffet held up its Red Card against Foe Wobbuffet!");
} }
} THEN {
EXPECT(player->item == ITEM_NONE);
} }
} }
@ -78,6 +84,8 @@ SINGLE_BATTLE_TEST("Red Card does not activate if target is behind a Substitute"
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player); ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Wobbuffet held up its Red Card against Foe Wobbuffet!"); MESSAGE("Wobbuffet held up its Red Card against Foe Wobbuffet!");
} }
} THEN {
EXPECT(player->item == ITEM_RED_CARD); // Not activated, so still has the item.
} }
} }
@ -95,6 +103,8 @@ SINGLE_BATTLE_TEST("Red Card activates after the last hit of a multi-hit move")
HP_BAR(player); HP_BAR(player);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player); ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Wobbuffet held up its Red Card against Foe Wobbuffet!"); MESSAGE("Wobbuffet held up its Red Card against Foe Wobbuffet!");
} THEN {
EXPECT(player->item == ITEM_NONE);
} }
} }
@ -111,6 +121,8 @@ SINGLE_BATTLE_TEST("Red Card does not activate if no replacements")
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player); ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Wobbuffet held up its Red Card against Foe Wobbuffet!"); MESSAGE("Wobbuffet held up its Red Card against Foe Wobbuffet!");
} }
} THEN {
EXPECT(player->item == ITEM_RED_CARD); // Not activated, so still has the item.
} }
} }
@ -128,6 +140,8 @@ SINGLE_BATTLE_TEST("Red Card does not activate if replacements fainted")
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player); ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Wobbuffet held up its Red Card against Foe Wobbuffet!"); MESSAGE("Wobbuffet held up its Red Card against Foe Wobbuffet!");
} }
} THEN {
EXPECT(player->item == ITEM_RED_CARD); // Not activated, so still has the item.
} }
} }
@ -145,6 +159,8 @@ SINGLE_BATTLE_TEST("Red Card does not activate if knocked off")
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player); ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, player);
MESSAGE("Wobbuffet held up its Red Card against Foe Wobbuffet!"); MESSAGE("Wobbuffet held up its Red Card against Foe Wobbuffet!");
} }
} THEN {
EXPECT(player->item == ITEM_NONE);
} }
} }
@ -173,6 +189,8 @@ SINGLE_BATTLE_TEST("Red Card does not activate if stolen by a move")
MESSAGE("Wobbuffet held up its Red Card against Foe Wobbuffet!"); MESSAGE("Wobbuffet held up its Red Card against Foe Wobbuffet!");
} }
} }
} THEN {
EXPECT(player->item == ITEM_NONE);
} }
} }
@ -201,6 +219,8 @@ SINGLE_BATTLE_TEST("Red Card does not activate if stolen by Magician")
MESSAGE("Wobbuffet held up its Red Card against Foe Fennekin!"); MESSAGE("Wobbuffet held up its Red Card against Foe Fennekin!");
} }
} }
} THEN {
EXPECT(player->item == ITEM_NONE);
} }
} }
@ -229,6 +249,9 @@ DOUBLE_BATTLE_TEST("Red Card activates for only the fastest target")
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, playerRight); ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, playerRight);
MESSAGE("Wynaut held up its Red Card against Foe Wynaut!"); MESSAGE("Wynaut held up its Red Card against Foe Wynaut!");
MESSAGE("Foe Wobbuffet was dragged out!"); MESSAGE("Foe Wobbuffet was dragged out!");
} THEN {
EXPECT(playerLeft->item == ITEM_NONE);
EXPECT(playerRight->item == ITEM_NONE);
} }
} }
@ -377,4 +400,36 @@ SINGLE_BATTLE_TEST("Red Card activates before Emergency Exit")
} }
} }
SINGLE_BATTLE_TEST("Red Card is consumed after dragged out replacement has its Speed lowered by Sticky Web")
{
GIVEN {
ASSUME(gBattleMoves[MOVE_STICKY_WEB].effect == EFFECT_STICKY_WEB);
PLAYER(SPECIES_WOBBUFFET);
PLAYER(SPECIES_WYNAUT) { Moves(MOVE_TACKLE); }
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_RED_CARD); }
} WHEN {
TURN { MOVE(opponent, MOVE_STICKY_WEB); }
TURN { MOVE(player, MOVE_TACKLE); }
TURN { MOVE(player, MOVE_TACKLE); }
} SCENE {
// 1st turn Sticky Web
ANIMATION(ANIM_TYPE_MOVE, MOVE_STICKY_WEB, opponent);
// 2nd turn Red Card activation
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, player);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent);
MESSAGE("Foe Wobbuffet held up its Red Card against Wobbuffet!");
MESSAGE("Wynaut was dragged out!");
MESSAGE("Wynaut was caught in a Sticky Web!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player);
// 3rd turn, Red Card was consumed, it can't trigger again
NONE_OF {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent);
MESSAGE("Foe Wobbuffet held up its Red Card against Wynaut!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, player);
}
} THEN {
EXPECT(opponent->item == ITEM_NONE);
}
}
// SINGLE_BATTLE_TEST("Red Card activates but fails if the attacker has Dynamaxed") // SINGLE_BATTLE_TEST("Red Card activates but fails if the attacker has Dynamaxed")