diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 0f6d7c7666..8f5177043e 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5975,6 +5975,15 @@ BattleScript_SoundproofProtected:: printstring STRINGID_PKMNSXBLOCKSY waitmessage 0x40 goto BattleScript_MoveEnd + +BattleScript_DazzlingProtected:: + attackstring + ppreduce + pause 0x20 + call BattleScript_AbilityPopUp + printstring STRINGID_POKEMONCANNOTUSEMOVE + waitmessage 0x40 + goto BattleScript_MoveEnd BattleScript_AbilityNoSpecificStatLoss:: pause 0x20 diff --git a/include/battle.h b/include/battle.h index cf4daf276a..fe725fffab 100644 --- a/include/battle.h +++ b/include/battle.h @@ -588,6 +588,7 @@ struct BattleStruct struct MegaEvolutionData mega; const u8 *trainerSlideMsg; bool8 trainerSlideLowHpMsgDone; + s8 movePriorities[MAX_BATTLERS_COUNT]; }; #define GET_MOVE_TYPE(move, typeArg) \ diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 42079436ba..dd0334fce7 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -284,5 +284,6 @@ extern const u8 BattleScript_TrainerSlideMsgRet[]; extern const u8 BattleScript_TrainerSlideMsgEnd2[]; extern const u8 BattleScript_MoveEffectFeint[]; extern const u8 BattleScript_ProteanActivates[]; +extern const u8 BattleScript_DazzlingProtected[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 214591ed96..6089b6aa73 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -513,6 +513,7 @@ #define STRINGID_BESTOWITEMGIVING 509 #define STRINGID_THIRDTYPEADDED 510 #define STRINGID_FELLFORFEINT 511 +#define STRINGID_POKEMONCANNOTUSEMOVE 512 #define BATTLESTRINGS_COUNT 525 diff --git a/src/battle_main.c b/src/battle_main.c index 11b86d8438..baa0f82cdd 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4726,7 +4726,6 @@ u32 GetBattlerTotalSpeedStat(u8 battlerId) static s8 GetMovePriority(u8 battlerId) { - s8 priority; u16 move; if (gProtectStructs[battlerId].noValidMoves) @@ -4734,17 +4733,17 @@ static s8 GetMovePriority(u8 battlerId) else move = gBattleMons[battlerId].moves[*(gBattleStruct->chosenMovePositions + battlerId)]; - priority = gBattleMoves[move].priority; + gBattleStruct->movePriorities[battlerId] = gBattleMoves[move].priority; if (GetBattlerAbility(battlerId) == ABILITY_GALE_WINGS && gBattleMoves[move].type == TYPE_FLYING && (B_GALE_WINGS == GEN_6 || BATTLER_MAX_HP(battlerId))) { - priority++; + gBattleStruct->movePriorities[battlerId]++; } else if (GetBattlerAbility(battlerId) == ABILITY_PRANKSTER && gBattleMoves[move].split == SPLIT_STATUS) { - priority++; + gBattleStruct->movePriorities[battlerId]++; } else if (GetBattlerAbility(battlerId) == ABILITY_TRIAGE) { @@ -4762,12 +4761,12 @@ static s8 GetMovePriority(u8 battlerId) case EFFECT_SOFTBOILED: case EFFECT_ABSORB: case EFFECT_ROOST: - priority += 3; + gBattleStruct->movePriorities[battlerId] += 3; break; } } - return priority; + return gBattleStruct->movePriorities[battlerId]; } u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) @@ -4849,7 +4848,6 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) strikesFirst = 0; // battler1's move has greater priority } - return strikesFirst; } diff --git a/src/battle_message.c b/src/battle_message.c index 1027e2e4ed..5a36b42de6 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -650,6 +650,7 @@ static const u8 sText_BurstingFlames[] = _("The bursting flames\nhit {B_SCR_ACTI static const u8 sText_BestowItemGiving[] = _("{B_DEF_NAME_WITH_PREFIX} received {B_LAST_ITEM}\nfrom {B_ATK_NAME_WITH_PREFIX}!"); static const u8 sText_ThirdTypeAdded[] = _("{B_BUFF1} type was added to\n{B_DEF_NAME_WITH_PREFIX}!"); static const u8 sText_FellForFeint[] = _("{B_DEF_NAME_WITH_PREFIX} fell for\nthe feint!"); +static const u8 sText_PokemonCannotUseMove[] = _("{B_ATK_NAME_WITH_PREFIX} cannot\nuse {B_CURRENT_MOVE}!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { @@ -1154,6 +1155,7 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = sText_BestowItemGiving, sText_ThirdTypeAdded, sText_FellForFeint, + sText_PokemonCannotUseMove, }; const u16 gTerrainStringIds[] = diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index f9847fca47..b2c9860b21 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -940,7 +940,7 @@ bool32 IsBattlerProtected(u8 battlerId, u16 move) else if (gProtectStructs[battlerId].kingsShielded && gBattleMoves[move].power != 0) return TRUE; else if ((gProtectStructs[battlerId].quickGuarded || gProtectStructs[BATTLE_PARTNER(battlerId)].quickGuarded) - && gBattleMoves[move].priority > 0) + && gBattleStruct->movePriorities[battlerId] > 0) return TRUE; else return FALSE; diff --git a/src/battle_util.c b/src/battle_util.c index 3564ca2a29..0d713c9ee6 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2846,6 +2846,17 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA gBattlescriptCurrInstr = BattleScript_SoundproofProtected; effect = 1; } + else if ((gLastUsedAbility == ABILITY_DAZZLING + || (IsBattlerAlive(battler ^= BIT_FLANK) && GetBattlerAbility(battler) == ABILITY_DAZZLING) + ) + && gBattleStruct->movePriorities[gBattlerAttacker] > 0 + && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(battler)) + { + if (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS) + gHitMarker |= HITMARKER_NO_PPDEDUCT; + gBattlescriptCurrInstr = BattleScript_DazzlingProtected; + effect = 1; + } break; case ABILITYEFFECT_ABSORBING: // 3 if (move != MOVE_NONE)