sovereignx/test/battle/move_effect/knock_off.c

208 lines
7 KiB
C
Raw Normal View History

2023-11-01 13:47:31 +00:00
#include "global.h"
#include "test/battle.h"
ASSUMPTIONS
{
Move data unification (#3999) * Made gBattleMoves handle the InGame name and description of battle moves No more multiple arrays in separate, individual files. Note: -Keep an eye on Task_LearnedMove. * Reintroduced move names Misc: -Fixed Trick-or-Treat and Light of Ruin's expanded names. -Introduced a new field for Z-Move names, and a constant for their name length. -Added a few TODOs to GetBattleMoveName. -Updated GetMaxMoveName and GetZMoveName. There's no reason not to let GetBattleMoveName handle everything on its own. * Updated GetBattleMoveName to handle Z-Move Names Misc: -Removed pointless TODO about MOVE_NAME_LENGTH. -The compiler doesn't allow to have a move name with a value higher than MOVE_NAME_LENGTH, therefore it's pointless to worry about it. * Fixed a couple of expanded move names * Removed zMoveName variable of struct BattleMove and extended the name variable's size * Ditched no longer used MOVE_NAME_LENGTH constant * Corrected the names of the max moves I should have done this after updating the size of the name variable of the struct BattleMove, but I didn't think about it at all until Cancer Fairy indirectly gave me the idea. * Fixed U-turn's name * Brought back MOVE_NAME_LENGTH I think it doesn't make sense to have a Z_MOVE_NAME_LENGTH because the length in question is used for all battle moves, not just the Z-Moves. * Introduced a union for Move/Z-Move names in the struct BattleMove * Fixed the union for gBattleMoves move names Also updated GetBattleMoveName to properly handle Max Move names. Also also renamed the "zMoveName" variable to "bigMoveName" which better reflects its purpose. Z-Move names weren't the only thing it covered, since it also handles Max Move names. * Removed deprecated GetZMoveName and GetMaxMoveName * Reintroduced mention to gMoveNames in sGFRomHeader * Fixed move names and ported move descriptions * Fused the struct ContestMove into the struct BattleMove * Removed no longer used Z_MOVE_NAME_LENGTH constant * Renamed the struct BattleMove's bigMoveName variable and introduced macros to prettify move names * Reintroduced the contest parameters for Pokémon moves * Renamed gBattleMoves to gMovesInfo This is consistent with gSpeciesInfo, the array that contains most of the species data. * Renamed the BattleMove struct to MovesInfo This is consistent with the struct SpeciesInfo, which contains the variables used by the gSpeciesInfo array. * Removed empty lines separating battle params from contest params in gMovesInfo * Renamed MovesInfo to MoveInfo * Added Cancer Fairy's HANDLE_EXPANDED_MOVE_NAME macro Used to handle moves with expanded names in a more comfortable manner. Also fixed Trick-or-Treat's expanded name. * Renamed GetBattleMoveName to GetMoveName * Added a comment pointing out that the shared move descriptions are shared move descriptions * Re-aligned one of the escape characters of CHECK_MOVE_FLAG * Renamed the battle_moves.h file to moves_info.h instead for consistency's sake * Applied Eduardo's adjustments * Using compound string for regular move names as well, saving 1180 bytes and making their use consistent * Move description formatting * Updated Pursuit test after merge * Renamed the BATTLE_CATEGORY constants to DAMAGE_CATEGORY --------- Co-authored-by: Nephrite <thechurchofcage@gmail.com> Co-authored-by: Bassoonian <iasperbassoonian@gmail.com> Co-authored-by: Eduardo Quezada D'Ottone <eduardo602002@gmail.com>
2024-01-29 11:51:32 +00:00
ASSUME(gMovesInfo[MOVE_KNOCK_OFF].effect == EFFECT_KNOCK_OFF);
2023-11-01 13:47:31 +00:00
}
SINGLE_BATTLE_TEST("Knock Off knocks a healing berry before it has the chance to activate")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_SITRUS_BERRY); MaxHP(500); HP(255); }
} WHEN {
TURN { MOVE(player, MOVE_KNOCK_OFF); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_KNOCK_OFF, player);
NONE_OF {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent);
MESSAGE("Foe Wobbuffet's Sitrus Berry restored health!");
}
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_ITEM_KNOCKOFF);
MESSAGE("Wobbuffet knocked off Foe Wobbuffet's Sitrus Berry!");
} THEN {
EXPECT(opponent->item == ITEM_NONE);
2023-11-01 13:47:31 +00:00
}
}
SINGLE_BATTLE_TEST("Knock Off activates after Rocky Helmet and Weakness Policy")
{
u16 item = 0;
PARAMETRIZE { item = ITEM_WEAKNESS_POLICY; }
PARAMETRIZE { item = ITEM_ROCKY_HELMET; }
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET) { Item(item); }
} WHEN {
TURN { MOVE(player, MOVE_KNOCK_OFF); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_KNOCK_OFF, player);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, opponent);
if (item == ITEM_WEAKNESS_POLICY) {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE);
MESSAGE("Using Weakness Policy, the Attack of Foe Wobbuffet sharply rose!");
MESSAGE("Using Weakness Policy, the Sp. Atk of Foe Wobbuffet sharply rose!");
2023-11-01 13:47:31 +00:00
} else if (item == ITEM_ROCKY_HELMET) {
HP_BAR(player);
MESSAGE("Wobbuffet was hurt by Foe Wobbuffet's Rocky Helmet!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_ITEM_KNOCKOFF);
MESSAGE("Wobbuffet knocked off Foe Wobbuffet's Rocky Helmet!");
}
} THEN {
EXPECT(opponent->item == ITEM_NONE);
}
}
SINGLE_BATTLE_TEST("Knock Off deals additional damage to opponents holding an item in Gen 6+", s16 damage)
{
u16 item = 0;
PARAMETRIZE { item = ITEM_NONE; }
PARAMETRIZE { item = ITEM_LEFTOVERS; }
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET) { Item(item); };
} WHEN {
TURN { MOVE(player, MOVE_KNOCK_OFF); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_KNOCK_OFF, player);
HP_BAR(opponent, captureDamage: &results[i].damage);
if (item != ITEM_NONE)
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_ITEM_KNOCKOFF);
} FINALLY {
if (B_KNOCK_OFF_DMG >= GEN_6)
EXPECT_MUL_EQ(results[0].damage, UQ_4_12(1.5), results[1].damage);
else
EXPECT_EQ(results[0].damage, results[1].damage);
} THEN {
EXPECT(opponent->item == ITEM_NONE);
}
}
SINGLE_BATTLE_TEST("Knock Off does not remove items through Substitute")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_LEFTOVERS); };
} WHEN {
TURN { MOVE(opponent, MOVE_SUBSTITUTE);
MOVE(player, MOVE_KNOCK_OFF); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_KNOCK_OFF, player);
NOT { ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_ITEM_KNOCKOFF); }
} THEN {
EXPECT(opponent->item == ITEM_NONE);
}
}
SINGLE_BATTLE_TEST("Recycle cannot recover an item removed by Knock Off")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_LEFTOVERS); }
} WHEN {
TURN { MOVE(player, MOVE_KNOCK_OFF);
MOVE(opponent, MOVE_RECYCLE); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_KNOCK_OFF, player);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_ITEM_KNOCKOFF);
MESSAGE("Wobbuffet knocked off Foe Wobbuffet's Leftovers!");
MESSAGE("Foe Wobbuffet used Recycle!");
MESSAGE("But it failed!");
} THEN {
EXPECT(opponent->item == ITEM_NONE);
}
}
SINGLE_BATTLE_TEST("Knock Off does not prevent targets from receiving another item in Gen 5+")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_LEFTOVERS); }
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_LEFTOVERS); }
} WHEN {
TURN { MOVE(player, MOVE_KNOCK_OFF); }
TURN { MOVE(player, MOVE_BESTOW); }
} SCENE {
// turn 1
ANIMATION(ANIM_TYPE_MOVE, MOVE_KNOCK_OFF, player);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_ITEM_KNOCKOFF);
MESSAGE("Wobbuffet knocked off Foe Wobbuffet's Leftovers!");
// turn 2
if (B_KNOCK_OFF_REMOVAL >= GEN_5) {
ANIMATION(ANIM_TYPE_MOVE, MOVE_BESTOW, player);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT);
MESSAGE("Foe Wobbuffet's Leftovers restored its HP a little!");
} else {
NOT { ANIMATION(ANIM_TYPE_MOVE, MOVE_BESTOW, player); }
MESSAGE("But it failed!");
}
} THEN {
if (B_KNOCK_OFF_REMOVAL >= GEN_5)
EXPECT(opponent->item == ITEM_LEFTOVERS);
else
EXPECT(opponent->item == ITEM_NONE);
}
}
// Knock Off triggers Unburden regardless of whether the item is fully removed (Gen 5+) or not.
SINGLE_BATTLE_TEST("Knock Off triggers Unburden")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Speed(60); }
OPPONENT(SPECIES_WOBBUFFET) { Ability(ABILITY_UNBURDEN); Item(ITEM_LEFTOVERS); Speed(50); }
} WHEN {
TURN { MOVE(player, MOVE_KNOCK_OFF); }
TURN { MOVE(player, MOVE_CELEBRATE); }
} SCENE {
// turn 1
ANIMATION(ANIM_TYPE_MOVE, MOVE_KNOCK_OFF, player);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_ITEM_KNOCKOFF);
MESSAGE("Wobbuffet knocked off Foe Wobbuffet's Leftovers!");
// turn 2
MESSAGE("Foe Wobbuffet used Celebrate!");
MESSAGE("Wobbuffet used Celebrate!");
} THEN {
EXPECT(opponent->item == ITEM_NONE);
}
}
DOUBLE_BATTLE_TEST("Knock Off does not trigger the opposing ally's Symbiosis")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_LEFTOVERS); }
PLAYER(SPECIES_FLORGES) { Item(ITEM_LEFTOVERS); }
OPPONENT(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponentLeft, MOVE_KNOCK_OFF, target: playerLeft); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_KNOCK_OFF, opponentLeft);
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_ITEM_KNOCKOFF);
MESSAGE("Foe Wobbuffet knocked off Wobbuffet's Leftovers!");
NONE_OF {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT);
MESSAGE("Wobbuffet's Leftovers restored health!");
}
} THEN {
EXPECT(playerLeft->item == ITEM_NONE);
2023-11-01 13:47:31 +00:00
}
}
Fixed some moves' on-hit effects bypassing Substitutes where they shouldn't and some other things discovered along the way (#4558) * Fixed some moves' on-hit effects bypassing Substitutes where they shouldn't. Fixed Sparkling Aria interaction with Shield Dust in Singles vs Doubles. Fixed Wake-Up Slap and Smelling Salts getting boosted damage where they shouldn't vs Substitutes. * Cleaned up check for Sparkling Aria+Shield Dust interaction and fixed for agbcc. Fixed logic for checking if moves should do extra damage on statused targets. Wrote tests for Wake-Up Slap and Smelling Salts receicing extra damage on statused targets. Wrote tests to check Thousand Arrows type effectiveness vs ungrounded Flying types. * Update src/battle_util.c Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com> * Update src/battle_script_commands.c Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com> * Update src/battle_script_commands.c Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com> * Update test/battle/ability/shield_dust.c Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com> * Update test/battle/item_effect/covert_cloak.c Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com> * Update test/battle/item_effect/covert_cloak.c Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com> * Update test/battle/item_effect/covert_cloak.c Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com> * Update test/battle/move_effect/smelling_salts.c Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com> * Update test/battle/move_effect/thousand_arrows.c Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com> * Update test/battle/move_effect/wake_up_slap.c Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com> * Update test/battle/move_effect/wake_up_slap.c Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com> * Update test/battle/move_effect/wake_up_slap.c Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com> --------- Co-authored-by: Hedara <hedara90@gmail.com> Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com>
2024-05-13 12:33:04 +01:00
SINGLE_BATTLE_TEST("Knock Off doesn't knock off items from Pokemon behind substitutes")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_POKE_BALL); }
} WHEN {
TURN { MOVE(opponent, MOVE_SUBSTITUTE); MOVE(player, MOVE_KNOCK_OFF); }
} SCENE {
NOT MESSAGE("Wobbuffet knocked off Foe Wobbuffet's Poké Ball");
}
}