diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 8f5177043..d8aedafed 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5984,6 +5984,11 @@ BattleScript_DazzlingProtected:: printstring STRINGID_POKEMONCANNOTUSEMOVE waitmessage 0x40 goto BattleScript_MoveEnd + +BattleScript_MoveUsedPsychicTerrainPrevents:: + printstring STRINGID_POKEMONCANNOTUSEMOVE + waitmessage 0x40 + goto BattleScript_MoveEnd BattleScript_AbilityNoSpecificStatLoss:: pause 0x20 diff --git a/include/battle_scripts.h b/include/battle_scripts.h index dd0334fce..4855d52b1 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -285,5 +285,6 @@ extern const u8 BattleScript_TrainerSlideMsgEnd2[]; extern const u8 BattleScript_MoveEffectFeint[]; extern const u8 BattleScript_ProteanActivates[]; extern const u8 BattleScript_DazzlingProtected[]; +extern const u8 BattleScript_MoveUsedPsychicTerrainPrevents[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/battle_util.h b/include/battle_util.h index ede49e10d..ad166571e 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -64,6 +64,7 @@ bool8 HandleWishPerishSongOnTurnEnd(void); bool8 HandleFaintedMonActions(void); void TryClearRageAndFuryCutter(void); u8 AtkCanceller_UnableToUseMove(void); +u8 AtkCanceller_UnableToUseMove2(void); bool8 HasNoMonsToSwitch(u8 battlerId, u8 r1, u8 r2); u8 CastformDataTypeChange(u8 battlerId); bool32 TryChangeBattleWeather(u8 battler, u32 weatherEnumId, bool32 viaAbility); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 5e57de574..f6d00e62d 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -979,6 +979,8 @@ static void atk00_attackcanceler(void) return; } + if (AtkCanceller_UnableToUseMove2()) + return; if (AbilityBattleEffects(ABILITYEFFECT_MOVES_BLOCK, gBattlerTarget, 0, 0, 0)) return; if (!gBattleMons[gBattlerAttacker].pp[gCurrMovePos] && gCurrentMove != MOVE_STRUGGLE && !(gHitMarker & (HITMARKER_x800000 | HITMARKER_NO_ATTACKSTRING)) diff --git a/src/battle_util.c b/src/battle_util.c index 0d713c9ee..065e969c1 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1986,6 +1986,8 @@ enum CANCELLER_BIDE, CANCELLER_THAW, CANCELLER_END, + CANCELLER_PSYCHIC_TERRAIN, + CANCELLER_END2, }; u8 AtkCanceller_UnableToUseMove(void) @@ -2288,6 +2290,38 @@ u8 AtkCanceller_UnableToUseMove(void) return effect; } +// After Protean Activation. +u8 AtkCanceller_UnableToUseMove2(void) +{ + u8 effect = 0; + do + { + switch (gBattleStruct->atkCancellerTracker) + { + case CANCELLER_END: + gBattleStruct->atkCancellerTracker++; + case CANCELLER_PSYCHIC_TERRAIN: + if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN + && IsBattlerGrounded(gBattlerAttacker) + && gBattleStruct->movePriorities[gBattlerAttacker] > 0 + && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget)) + { + CancelMultiTurnMoves(gBattlerAttacker); + gBattlescriptCurrInstr = BattleScript_MoveUsedPsychicTerrainPrevents; + gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; + effect = 1; + } + gBattleStruct->atkCancellerTracker++; + break; + case CANCELLER_END2: + break; + } + + } while (gBattleStruct->atkCancellerTracker != CANCELLER_END2 && effect == 0); + + return effect; +} + bool8 HasNoMonsToSwitch(u8 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2) { struct Pokemon *party;