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 Sleep Talk, Toxic Debris and Jaboca/Rowap Berry issues; Adds Sleep Talk tests #5009

Merged
merged 2 commits into from
Jul 21, 2024
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
2 changes: 1 addition & 1 deletion src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -13041,7 +13041,7 @@ static void Cmd_trychoosesleeptalkmove(void)
}
}

unusableMovesBits = CheckMoveLimitations(gBattlerAttacker, unusableMovesBits, ~MOVE_LIMITATION_PP);
unusableMovesBits = CheckMoveLimitations(gBattlerAttacker, unusableMovesBits, ~(MOVE_LIMITATION_PP | MOVE_LIMITATION_CHOICE_ITEM));
if (unusableMovesBits == ALL_MOVES_MASK) // all 4 moves cannot be chosen
{
gBattlescriptCurrInstr = cmd->nextInstr;
Expand Down
6 changes: 3 additions & 3 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -5771,7 +5771,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& IS_MOVE_PHYSICAL(gCurrentMove)
&& TARGET_TURN_DAMAGED
&& (gSideTimers[gBattlerAttacker].toxicSpikesAmount != 2))
&& (gSideTimers[GetBattlerSide(gBattlerAttacker)].toxicSpikesAmount != 2))
{
SWAP(gBattlerAttacker, gBattlerTarget, i);
BattleScriptPushCursor();
Expand Down Expand Up @@ -7915,7 +7915,7 @@ u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn)
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_JabocaRowapBerryActivates;
PREPARE_ITEM_BUFFER(gBattleTextBuff1, gLastUsedItem);
RecordItemEffectBattle(battler, HOLD_EFFECT_ROCKY_HELMET);
RecordItemEffectBattle(battler, HOLD_EFFECT_JABOCA_BERRY);
}
break;
case HOLD_EFFECT_ROWAP_BERRY: // consume and damage attacker if used special move
Expand All @@ -7935,7 +7935,7 @@ u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn)
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_JabocaRowapBerryActivates;
PREPARE_ITEM_BUFFER(gBattleTextBuff1, gLastUsedItem);
RecordItemEffectBattle(battler, HOLD_EFFECT_ROCKY_HELMET);
RecordItemEffectBattle(battler, HOLD_EFFECT_ROWAP_BERRY);
}
break;
case HOLD_EFFECT_KEE_BERRY: // consume and boost defense if used physical move
Expand Down
93 changes: 93 additions & 0 deletions test/battle/move_effect/sleep_talk.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#include "global.h"
#include "test/battle.h"

ASSUMPTIONS
{
ASSUME(gMovesInfo[MOVE_SLEEP_TALK].effect == EFFECT_SLEEP_TALK);
ASSUME(gMovesInfo[MOVE_RAZOR_WIND].sleepTalkBanned == TRUE);
ASSUME(gMovesInfo[MOVE_FLY].sleepTalkBanned == TRUE);
ASSUME(gMovesInfo[MOVE_DIG].sleepTalkBanned == TRUE);
}

SINGLE_BATTLE_TEST("Sleep Talk fails if not asleep")
{
u32 status;
PARAMETRIZE { status = STATUS1_SLEEP; }
PARAMETRIZE { status = STATUS1_NONE; }

GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Status1(status); Moves(MOVE_SLEEP_TALK, MOVE_TACKLE, MOVE_POUND, MOVE_SCRATCH); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_SLEEP_TALK); }
} SCENE {
if (status == STATUS1_SLEEP) {
ANIMATION(ANIM_TYPE_MOVE, MOVE_SLEEP_TALK, player);
NOT MESSAGE("But it failed!");
}
else {
NOT ANIMATION(ANIM_TYPE_MOVE, MOVE_SLEEP_TALK, player);
MESSAGE("But it failed!");
}
}
}


SINGLE_BATTLE_TEST("Sleep Talk works if user has Comatose")
{

GIVEN {
PLAYER(SPECIES_KOMALA) { Moves(MOVE_SLEEP_TALK, MOVE_TACKLE, MOVE_POUND, MOVE_SCRATCH); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_SLEEP_TALK); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_SLEEP_TALK, player);
NOT MESSAGE("But it failed!");
}
}

SINGLE_BATTLE_TEST("Sleep Talk fails if no moves work")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_SLEEP); Moves(MOVE_SLEEP_TALK, MOVE_RAZOR_WIND, MOVE_FLY, MOVE_DIG); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_SLEEP_TALK); }
} SCENE {
NOT ANIMATION(ANIM_TYPE_MOVE, MOVE_SLEEP_TALK, player);
MESSAGE("But it failed!");
}
}

SINGLE_BATTLE_TEST("Sleep Talk can still use moves with no PP")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Status1(STATUS1_SLEEP); MovesWithPP({MOVE_SLEEP_TALK, 10}, {MOVE_TACKLE, 0}, {MOVE_FLY, 10}, {MOVE_DIG, 10}); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_SLEEP_TALK); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_SLEEP_TALK, player);
NOT MESSAGE("But it failed!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE);
}
}

SINGLE_BATTLE_TEST("Sleep Talk can use moves while choiced into Sleep Talk")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_CHOICE_BAND); Status1(STATUS1_SLEEP); Moves(MOVE_SLEEP_TALK, MOVE_TACKLE, MOVE_FLY, MOVE_DIG); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_SLEEP_TALK); }
TURN { MOVE(player, MOVE_SLEEP_TALK); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, MOVE_SLEEP_TALK, player);
NOT MESSAGE("But it failed!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE);
ANIMATION(ANIM_TYPE_MOVE, MOVE_SLEEP_TALK, player);
NOT MESSAGE("But it failed!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE);
}
}
Loading