Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Toxic Debris + CanTargetFaintAi index issue #3306

Merged
merged 2 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -7333,6 +7333,9 @@ BattleScript_ToxicDebrisActivates::
printstring STRINGID_POISONSPIKESSCATTERED
waitmessage B_WAIT_TIME_LONG
BattleScript_ToxicDebrisRet:
copybyte sBATTLER, gBattlerTarget
copybyte gBattlerTarget, gBattlerAttacker
copybyte gBattlerAttacker, sBATTLER
return

BattleScript_EarthEaterActivates::
Expand Down
2 changes: 1 addition & 1 deletion src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ bool32 CanTargetFaintAi(u8 battlerDef, u8 battlerAtk)
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (moves[i] != MOVE_NONE && moves[i] != 0xFFFF && !(unusable & gBitTable[i])
&& AI_DATA->simulatedDmg[battlerDef][battlerAtk][moves[i]] >= gBattleMons[battlerAtk].hp)
&& AI_DATA->simulatedDmg[battlerDef][battlerAtk][i] >= gBattleMons[battlerAtk].hp)
{
return TRUE;
}
Expand Down
4 changes: 2 additions & 2 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -5710,10 +5710,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& IS_MOVE_PHYSICAL(gCurrentMove)
&& TARGET_TURN_DAMAGED
&& !(gSideStatuses[GetBattlerSide(gBattlerAttacker)] & SIDE_STATUS_TOXIC_SPIKES)
&& (gSideTimers[gBattlerAttacker].toxicSpikesAmount != 2)
&& IsBattlerAlive(gBattlerTarget))
{
gBattlerTarget = gBattlerAttacker;
SWAP(gBattlerAttacker, gBattlerTarget, i);
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_ToxicDebrisActivates;
effect++;
Expand Down
96 changes: 96 additions & 0 deletions test/battle/ability/toxic_debris.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include "global.h"
#include "test/battle.h"

SINGLE_BATTLE_TEST("Toxic Debris sets Toxic Spikes on the opposing side if hit by a physical attack")
{
u32 move;

PARAMETRIZE { move = MOVE_TACKLE;}
PARAMETRIZE { move = MOVE_SWIFT;}

GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Ability(ABILITY_TOXIC_DEBRIS); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, move); }
} SCENE {
if (move == MOVE_TACKLE) {
ABILITY_POPUP(player, ABILITY_TOXIC_DEBRIS);
MESSAGE("Poison Spikes were scattered all around the opposing team's feet!");
}
else {
NOT ABILITY_POPUP(player, ABILITY_TOXIC_DEBRIS);
NOT MESSAGE("Poison Spikes were scattered all around the opposing team's feet!");
}
}
}

SINGLE_BATTLE_TEST("Toxic Debris does not activate if two layers of Toxic Spikes are already up")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Ability(ABILITY_TOXIC_DEBRIS); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_TACKLE); }
TURN { MOVE(opponent, MOVE_TACKLE); }
TURN { MOVE(opponent, MOVE_TACKLE); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent);
ABILITY_POPUP(player, ABILITY_TOXIC_DEBRIS);
MESSAGE("Poison Spikes were scattered all around the opposing team's feet!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent);
ABILITY_POPUP(player, ABILITY_TOXIC_DEBRIS);
MESSAGE("Poison Spikes were scattered all around the opposing team's feet!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent);
NOT ABILITY_POPUP(player, ABILITY_TOXIC_DEBRIS);
NOT MESSAGE("Poison Spikes were scattered all around the opposing team's feet!");
}
}

SINGLE_BATTLE_TEST("If a Substitute is hit, Toxic Debris does not set Toxic Spikes")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Ability(ABILITY_TOXIC_DEBRIS); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_SUBSTITUTE); }
TURN { MOVE(opponent, MOVE_TACKLE); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_SUBSTITUTE, player);
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent);
NOT ABILITY_POPUP(player, ABILITY_TOXIC_DEBRIS);
NOT MESSAGE("Poison Spikes were scattered all around the opposing team's feet!");
}
}

SINGLE_BATTLE_TEST("Each hit of a Multi Hit move activates Toxic Debris")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Ability(ABILITY_TOXIC_DEBRIS); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_FURY_SWIPES); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_FURY_SWIPES, opponent);
ABILITY_POPUP(player, ABILITY_TOXIC_DEBRIS);
MESSAGE("Poison Spikes were scattered all around the opposing team's feet!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_FURY_SWIPES, opponent);
ABILITY_POPUP(player, ABILITY_TOXIC_DEBRIS);
MESSAGE("Poison Spikes were scattered all around the opposing team's feet!");
}
}

SINGLE_BATTLE_TEST("Air Balloon is popped after Toxic Debris activates")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Ability(ABILITY_TOXIC_DEBRIS); Item(ITEM_AIR_BALLOON); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, MOVE_TACKLE); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent);
ABILITY_POPUP(player, ABILITY_TOXIC_DEBRIS);
MESSAGE("Poison Spikes were scattered all around the opposing team's feet!");
MESSAGE("Wobbuffet's Air Balloon popped!");
}
}