diff --git a/include/battle.h b/include/battle.h index 4f5af755b6a5..ea710ed79779 100644 --- a/include/battle.h +++ b/include/battle.h @@ -742,6 +742,7 @@ struct BattleStruct u8 transformZeroToHero[NUM_BATTLE_SIDES]; u8 intrepidSwordBoost[NUM_BATTLE_SIDES]; u8 dauntlessShieldBoost[NUM_BATTLE_SIDES]; + u8 stickySyrupdBy[MAX_BATTLERS_COUNT]; }; // The palaceFlags member of struct BattleStruct contains 1 flag per move to indicate which moves the AI should consider, diff --git a/src/battle_main.c b/src/battle_main.c index f647ae5569d1..d5608ec21bba 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3124,6 +3124,8 @@ void SwitchInClearSetData(u32 battler) gBattleMons[i].status2 &= ~STATUS2_INFATUATED_WITH(battler); if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && *(gBattleStruct->wrappedBy + i) == battler) gBattleMons[i].status2 &= ~STATUS2_WRAPPED; + if ((gStatuses4[i] & STATUS4_SYRUP_BOMB) && *(gBattleStruct->stickySyrupdBy + i) == battler) + gStatuses4[i] &= ~STATUS4_SYRUP_BOMB; } gActionSelectionCursor[battler] = 0; @@ -3228,6 +3230,8 @@ const u8* FaintClearSetData(u32 battler) gBattleMons[i].status2 &= ~STATUS2_INFATUATED_WITH(battler); if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && *(gBattleStruct->wrappedBy + i) == battler) gBattleMons[i].status2 &= ~STATUS2_WRAPPED; + if ((gStatuses4[i] & STATUS4_SYRUP_BOMB) && *(gBattleStruct->stickySyrupdBy + i) == battler) + gStatuses4[i] &= ~STATUS4_SYRUP_BOMB; } gActionSelectionCursor[battler] = 0; @@ -4932,7 +4936,7 @@ static void TurnValuesCleanUp(bool8 var0) gSideStatuses[B_SIDE_OPPONENT] &= ~(SIDE_STATUS_QUICK_GUARD | SIDE_STATUS_WIDE_GUARD | SIDE_STATUS_CRAFTY_SHIELD | SIDE_STATUS_MAT_BLOCK); gSideTimers[B_SIDE_PLAYER].followmeTimer = 0; gSideTimers[B_SIDE_OPPONENT].followmeTimer = 0; - + gBattleStruct->pledgeMove = FALSE; // combined pledge move may not have been used due to a canceller } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b9ff7f63c8bd..26c1ffa09a03 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1586,8 +1586,8 @@ static bool32 AccuracyCalcHelper(u16 move) if (WEATHER_HAS_EFFECT) { - if (IsBattlerWeatherAffected(gBattlerTarget, B_WEATHER_RAIN) && - (gBattleMoves[move].effect == EFFECT_THUNDER || gBattleMoves[move].effect == EFFECT_HURRICANE || + if (IsBattlerWeatherAffected(gBattlerTarget, B_WEATHER_RAIN) && + (gBattleMoves[move].effect == EFFECT_THUNDER || gBattleMoves[move].effect == EFFECT_HURRICANE || move == MOVE_BLEAKWIND_STORM || move == MOVE_WILDBOLT_STORM || move == MOVE_SANDSEAR_STORM)) { // thunder/hurricane/genie moves ignore acc checks in rain unless target is holding utility umbrella @@ -3136,7 +3136,8 @@ void SetMoveEffect(bool32 primary, u32 certain) gBattlerAbility = gEffectBattler; RecordAbilityBattle(gEffectBattler, ABILITY_INNER_FOCUS); gBattlescriptCurrInstr = BattleScript_FlinchPrevention; - } else + } + else { gBattlescriptCurrInstr++; } @@ -3144,7 +3145,7 @@ void SetMoveEffect(bool32 primary, u32 certain) else if (GetBattlerTurnOrderNum(gEffectBattler) > gCurrentTurnActionNumber && !IsDynamaxed(gEffectBattler)) { - gBattleMons[gEffectBattler].status2 |= sStatusFlagsForMoveEffects[gBattleScripting.moveEffect]; + gBattleMons[gEffectBattler].status2 |= sStatusFlagsForMoveEffects[gBattleScripting.moveEffect]; gBattlescriptCurrInstr++; } break; @@ -3683,6 +3684,7 @@ void SetMoveEffect(bool32 primary, u32 certain) gStatuses4[gEffectBattler] |= STATUS4_SYRUP_BOMB; gDisableStructs[gEffectBattler].syrupBombTimer = 3; gDisableStructs[gEffectBattler].syrupBombIsShiny = IsMonShiny(&party[gBattlerPartyIndexes[gBattlerAttacker]]); + gBattleStruct->stickySyrupdBy[gEffectBattler] = gBattlerAttacker; BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_SyrupBombActivates; } diff --git a/test/battle/move_effect/syrup_bomb.c b/test/battle/move_effect/syrup_bomb.c index f286049e1aa0..57831abb5576 100644 --- a/test/battle/move_effect/syrup_bomb.c +++ b/test/battle/move_effect/syrup_bomb.c @@ -164,3 +164,51 @@ SINGLE_BATTLE_TEST("Sticky syrup will not decrease speed further then minus six" } } } + +SINGLE_BATTLE_TEST("Sticky Syrup is removed when the user switches out") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET); + PLAYER(SPECIES_WYNAUT); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_SYRUP_BOMB); } + TURN { SWITCH(player, 1); } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_SYRUP_BOMB, player); + HP_BAR(opponent); + MESSAGE("Foe Wobbuffet got covered in sticky syrup!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_SYRUP_BOMB_SPEED_DROP, opponent); + MESSAGE("Foe Wobbuffet's Speed fell!"); + NONE_OF { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_SYRUP_BOMB_SPEED_DROP, opponent); + MESSAGE("Foe Wobbuffet's Speed fell!"); + } + } +} + +SINGLE_BATTLE_TEST("Sticky Syrup is removed when the user faints") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { HP(1); } + PLAYER(SPECIES_WYNAUT); + OPPONENT(SPECIES_WOBBUFFET); + } WHEN { + TURN { MOVE(player, MOVE_SYRUP_BOMB); + MOVE(opponent, MOVE_TACKLE); + SEND_OUT(player, 1); + } + } SCENE { + ANIMATION(ANIM_TYPE_MOVE, MOVE_SYRUP_BOMB, player); + HP_BAR(opponent); + MESSAGE("Foe Wobbuffet got covered in sticky syrup!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponent); + HP_BAR(player); + MESSAGE("Wobbuffet fainted!"); + MESSAGE("Go! Wynaut!"); + NONE_OF { + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_SYRUP_BOMB_SPEED_DROP, opponent); + MESSAGE("Foe Wobbuffet's Speed fell!"); + } + } +}