diff --git a/include/battle.h b/include/battle.h index 931b13b2f4d0..d2fc93f657da 100644 --- a/include/battle.h +++ b/include/battle.h @@ -147,6 +147,7 @@ struct ProtectStruct u16 pranksterElevated:1; u16 quickDraw:1; u16 beakBlastCharge:1; + u16 quash:1; u32 physicalDmg; u32 specialDmg; u8 physicalBattlerId; @@ -669,7 +670,7 @@ struct BattleStruct #define SET_STATCHANGER(statId, stage, goesDown)(gBattleScripting.statChanger = (statId) + ((stage) << 3) + (goesDown << 7)) #define SET_STATCHANGER2(dst, statId, stage, goesDown)(dst = (statId) + ((stage) << 3) + (goesDown << 7)) -// NOTE: The members of this struct have hard-coded offsets +// NOTE: The members of this struct have hard-coded offsets // in include/constants/battle_script_commands.h struct BattleScripting { diff --git a/src/battle_main.c b/src/battle_main.c index 5c03a18b466a..86a1fd075ff2 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -2981,10 +2981,10 @@ static void BattleStartClearSetData(void) gBattleStruct->arenaLostOpponentMons = 0; gBattleStruct->mega.triggerSpriteId = 0xFF; - + gBattleStruct->stickyWebUser = 0xFF; gBattleStruct->appearedInBattle = 0; - + for (i = 0; i < PARTY_SIZE; i++) { gBattleStruct->usedHeldItems[i][0] = 0; @@ -3084,7 +3084,7 @@ void SwitchInClearSetData(void) gBattleStruct->lastTakenMoveFrom[gActiveBattler][3] = 0; gBattleStruct->lastMoveFailed &= ~(gBitTable[gActiveBattler]); gBattleStruct->palaceFlags &= ~(gBitTable[gActiveBattler]); - + if (gActiveBattler == gBattleStruct->stickyWebUser) gBattleStruct->stickyWebUser = 0xFF; // Switched into sticky web user slot so reset it @@ -3100,7 +3100,7 @@ void SwitchInClearSetData(void) gBattleResources->flags->flags[gActiveBattler] = 0; gCurrentMove = MOVE_NONE; gBattleStruct->arenaTurnCounter = 0xFF; - + // Reset damage to prevent things like red card activating if the switched-in mon is holding it gSpecialStatuses[gActiveBattler].physicalDmg = 0; gSpecialStatuses[gActiveBattler].specialDmg = 0; @@ -3140,6 +3140,7 @@ void FaintClearSetData(void) gProtectStructs[gActiveBattler].spikyShielded = FALSE; gProtectStructs[gActiveBattler].kingsShielded = FALSE; gProtectStructs[gActiveBattler].banefulBunkered = FALSE; + gProtectStructs[gActiveBattler].quash = FALSE; gProtectStructs[gActiveBattler].obstructed = FALSE; gProtectStructs[gActiveBattler].endured = FALSE; gProtectStructs[gActiveBattler].noValidMoves = FALSE; @@ -3184,7 +3185,7 @@ void FaintClearSetData(void) gBattleStruct->lastTakenMoveFrom[gActiveBattler][3] = 0; gBattleStruct->palaceFlags &= ~(gBitTable[gActiveBattler]); - + if (gActiveBattler == gBattleStruct->stickyWebUser) gBattleStruct->stickyWebUser = 0xFF; // User of sticky web fainted, so reset the stored battler ID @@ -3696,7 +3697,7 @@ static void TryDoEventsBeforeFirstTurn(void) gMoveResultFlags = 0; gRandomTurnNumber = Random(); - + GetAiLogicData(); // get assumed abilities, hold effects, etc of all battlers if (gBattleTypeFlags & BATTLE_TYPE_ARENA) @@ -3904,7 +3905,7 @@ static void HandleTurnActionSelectionState(void) case STATE_TURN_START_RECORD: // Recorded battle related action on start of every turn. RecordedBattle_CopyBattlerMoves(); gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN; - + // Do AI score computations here so we can use them in AI_TrySwitchOrUseItem if ((gBattleTypeFlags & BATTLE_TYPE_HAS_AI || IsWildMonSmart()) && IsBattlerAIControlled(gActiveBattler)) { gBattleStruct->aiMoveOrAction[gActiveBattler] = ComputeBattleAiScores(gActiveBattler); @@ -4516,6 +4517,9 @@ s8 GetMovePriority(u32 battlerId, u16 move) } } + if (gProtectStructs[battlerId].quash) + priority = -8; + return priority; } @@ -4564,7 +4568,7 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) // QUICK CLAW / CUSTAP - always first // LAGGING TAIL - always last // STALL - always last - + if (gProtectStructs[battler1].quickDraw && !gProtectStructs[battler2].quickDraw) strikesFirst = 0; else if (!gProtectStructs[battler1].quickDraw && gProtectStructs[battler2].quickDraw) @@ -4736,6 +4740,7 @@ static void TurnValuesCleanUp(bool8 var0) gProtectStructs[gActiveBattler].spikyShielded = FALSE; gProtectStructs[gActiveBattler].kingsShielded = FALSE; gProtectStructs[gActiveBattler].banefulBunkered = FALSE; + gProtectStructs[gActiveBattler].quash = FALSE; } else { diff --git a/src/battle_message.c b/src/battle_message.c index 688a48f25674..c19ca75638f3 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -625,7 +625,7 @@ static const u8 sText_PkmnBlewAwayToxicSpikes[] = _("{B_ATK_NAME_WITH_PREFIX} bl static const u8 sText_PkmnBlewAwayStickyWeb[] = _("{B_ATK_NAME_WITH_PREFIX} blew away\nSticky Web!"); static const u8 sText_PkmnBlewAwayStealthRock[] = _("{B_ATK_NAME_WITH_PREFIX} blew away\nStealth Rock!"); static const u8 sText_StickyWebUsed[] = _("A sticky web spreads out on the\nground around {B_DEF_TEAM2} team!"); -static const u8 sText_QuashSuccess[] = _("The opposing {B_ATK_NAME_WITH_PREFIX}'s move was postponed!"); +static const u8 sText_QuashSuccess[] = _("The opposing {B_DEF_NAME_WITH_PREFIX}'s\nmove was postponed!"); static const u8 sText_IonDelugeOn[] = _("A deluge of ions showers\nthe battlefield!"); static const u8 sText_TopsyTurvySwitchedStats[] = _("{B_DEF_NAME_WITH_PREFIX}'s stat changes were\nall reversed!"); static const u8 sText_TerrainBecomesMisty[] = _("Mist swirled about\nthe battlefield!"); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 420d5790ceca..f71bbb1c33e5 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1422,7 +1422,7 @@ static void Cmd_attackcanceler(void) return; if (AbilityBattleEffects(ABILITYEFFECT_MOVES_BLOCK, gBattlerTarget, 0, 0, 0)) return; - if (!gBattleMons[gBattlerAttacker].pp[gCurrMovePos] && gCurrentMove != MOVE_STRUGGLE + if (!gBattleMons[gBattlerAttacker].pp[gCurrMovePos] && gCurrentMove != MOVE_STRUGGLE && !(gHitMarker & (HITMARKER_ALLOW_NO_PP | HITMARKER_NO_ATTACKSTRING | HITMARKER_NO_PPDEDUCT)) && !(gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)) { @@ -1622,7 +1622,7 @@ static bool32 AccuracyCalcHelper(u16 move) RecordAbilityBattle(gBattlerTarget, ABILITY_NO_GUARD); return TRUE; } - + if (gBattleStruct->zmove.active && !(gStatuses3[gBattlerTarget] & STATUS3_SEMI_INVULNERABLE)) { JumpIfMoveFailed(7, move); @@ -1765,7 +1765,7 @@ static void Cmd_accuracycheck(void) gMoveResultFlags |= MOVE_RESULT_MISSED; if (GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_BLUNDER_POLICY) gBattleStruct->blunderPolicy = TRUE; // Only activates from missing through acc/evasion checks - + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && (moveTarget == MOVE_TARGET_BOTH || moveTarget == MOVE_TARGET_FOES_AND_ALLY)) gBattleCommunication[MISS_TYPE] = B_MSG_AVOIDED_ATK; @@ -2596,14 +2596,14 @@ static void CheckSetUnburden(u8 battlerId) // battlerStealer steals the item of battlerItem void StealTargetItem(u8 battlerStealer, u8 battlerItem) -{ +{ gLastUsedItem = gBattleMons[battlerItem].item; gBattleMons[battlerItem].item = 0; - + RecordItemEffectBattle(battlerItem, 0); RecordItemEffectBattle(battlerStealer, ItemId_GetHoldEffect(gLastUsedItem)); gBattleMons[battlerStealer].item = gLastUsedItem; - + CheckSetUnburden(battlerItem); gBattleResources->flags->flags[battlerStealer] &= ~RESOURCE_FLAG_UNBURDEN; @@ -2614,9 +2614,9 @@ void StealTargetItem(u8 battlerStealer, u8 battlerItem) gActiveBattler = battlerItem; BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[gBattlerTarget].item), &gBattleMons[battlerItem].item); // remove target item MarkBattlerForControllerExec(battlerItem); - + gBattleStruct->choicedMove[battlerItem] = 0; - + TrySaveExchangedItem(battlerItem, gLastUsedItem); } @@ -2640,7 +2640,7 @@ void SetMoveEffect(bool32 primary, u32 certain) bool32 mirrorArmorReflected = (GetBattlerAbility(gBattlerTarget) == ABILITY_MIRROR_ARMOR); u32 flags = 0; u16 battlerAbility; - + switch (gBattleScripting.moveEffect) // Set move effects which happen later on { case MOVE_EFFECT_KNOCK_OFF: @@ -2749,7 +2749,7 @@ void SetMoveEffect(bool32 primary, u32 certain) case STATUS1_BURN: if (gCurrentMove == MOVE_BURNING_JEALOUSY && !gProtectStructs[gEffectBattler].statRaised) break; - + if ((battlerAbility == ABILITY_WATER_VEIL || battlerAbility == ABILITY_WATER_BUBBLE) && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)) { @@ -2944,7 +2944,7 @@ void SetMoveEffect(bool32 primary, u32 certain) else { gBattleMons[gEffectBattler].status2 |= STATUS2_CONFUSION_TURN(((Random()) % 4) + 2); // 2-5 turns - + // If the confusion is activating due to being released from Sky Drop, go to "confused due to fatigue" script. // Otherwise, do normal confusion script. if(gCurrentMove == MOVE_SKY_DROP) @@ -2956,7 +2956,7 @@ void SetMoveEffect(bool32 primary, u32 certain) else { BattleScriptPush(gBattlescriptCurrInstr + 1); - gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleScripting.moveEffect]; + gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleScripting.moveEffect]; } } break; @@ -3091,7 +3091,7 @@ void SetMoveEffect(bool32 primary, u32 certain) flags = affectsUser; if (mirrorArmorReflected && !affectsUser) flags |= STAT_CHANGE_ALLOW_PTR; - + if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(1) | STAT_BUFF_NEGATIVE, gBattleScripting.moveEffect - MOVE_EFFECT_ATK_MINUS_1 + 1, flags | STAT_CHANGE_UPDATE_MOVE_EFFECT, gBattlescriptCurrInstr + 1)) @@ -3482,14 +3482,14 @@ void SetMoveEffect(bool32 primary, u32 certain) gBattleMons[gEffectBattler].item = 0; CheckSetUnburden(gEffectBattler); gActiveBattler = gEffectBattler; - + BtlController_EmitSetMonData(BUFFER_A, REQUEST_HELDITEM_BATTLE, 0, sizeof(gBattleMons[gEffectBattler].item), &gBattleMons[gEffectBattler].item); MarkBattlerForControllerExec(gActiveBattler); - + // attacker temporarily gains their item gBattleStruct->changedItems[gBattlerAttacker] = gBattleMons[gBattlerAttacker].item; gBattleMons[gBattlerAttacker].item = gLastUsedItem; - + BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_MoveEffectBugBite; } @@ -5257,13 +5257,13 @@ static void Cmd_moveend(void) if (gBattleStruct->skyDropTargets[targetId] == i) break; } - + // Set gBattlerAttacker to the battler id of the target gBattlerAttacker = targetId; - + // Jump to "confused due to fatigue" script gBattlescriptCurrInstr = BattleScript_ThrashConfuses; - + // Clear skyDropTargets data gBattleStruct->skyDropTargets[i] = 0xFF; gBattleStruct->skyDropTargets[targetId] = 0xFF; @@ -5380,7 +5380,7 @@ static void Cmd_moveend(void) if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) gProtectStructs[gBattlerAttacker].targetAffected = TRUE; - + if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) && gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !gProtectStructs[gBattlerAttacker].chargingTurn @@ -5482,7 +5482,7 @@ static void Cmd_moveend(void) && GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_RED_CARD && (gSpecialStatuses[battler].physicalDmg != 0 || gSpecialStatuses[battler].specialDmg != 0) && CanBattlerSwitch(gBattlerAttacker)) - { + { gLastUsedItem = gBattleMons[battler].item; gActiveBattler = gBattleStruct->savedBattlerTarget = gBattleScripting.battler = battler; // Battler with red card gEffectBattler = gBattlerAttacker; @@ -5554,7 +5554,7 @@ static void Cmd_moveend(void) // Battle scripting is super brittle so we shall do the item exchange now (if possible) if (GetBattlerAbility(gBattlerAttacker) != ABILITY_STICKY_HOLD) StealTargetItem(gBattlerTarget, gBattlerAttacker); // Target takes attacker's item - + gEffectBattler = gBattlerAttacker; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_Pickpocket; // Includes sticky hold check to print separate string @@ -7109,7 +7109,7 @@ static void Cmd_removeitem(void) // Popped Air Balloon cannot be restored by any means. if (GetBattlerHoldEffect(gActiveBattler, TRUE) != HOLD_EFFECT_AIR_BALLOON) gBattleStruct->usedHeldItems[gBattlerPartyIndexes[gActiveBattler]][GetBattlerSide(gActiveBattler)] = itemId; // Remember if switched out - + gBattleMons[gActiveBattler].item = ITEM_NONE; CheckSetUnburden(gActiveBattler); @@ -8103,7 +8103,7 @@ static void Cmd_various(void) break; case VARIOUS_ARENA_JUDGMENT_WINDOW: i = BattleArena_ShowJudgmentWindow(&gBattleCommunication[0]); - + // BattleArena_ShowJudgmentWindow's last state was an intermediate step. // Return without advancing the current instruction so that it will be called again. if (i == ARENA_RESULT_RUNNING) @@ -8454,28 +8454,14 @@ static void Cmd_various(void) } return; case VARIOUS_TRY_QUASH: - if (GetBattlerTurnOrderNum(gBattlerAttacker) > GetBattlerTurnOrderNum(gBattlerTarget)) + if (GetBattlerTurnOrderNum(gBattlerAttacker) > GetBattlerTurnOrderNum(gBattlerTarget)) // It's true if foe is faster, has a bigger priority, or switches { - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); // This replaces the current battlescript with the "fail" script. } - else + else // If the condition is not true, it means we are faster than the foe, so we can set the quash bit { - for (i = 0; i < gBattlersCount; i++) - data[i] = gBattlerByTurnOrder[i]; - for (i = 0; i < gBattlersCount; i++) - { - if (data[i] == gBattlerTarget) - { - for (j = i + 1; j < gBattlersCount; j++) - data[i++] = data[j]; - } - else - { - gBattlerByTurnOrder[i] = data[i]; - } - } - gBattlerByTurnOrder[gBattlersCount - 1] = gBattlerTarget; - gBattlescriptCurrInstr += 7; + gProtectStructs[gBattlerTarget].quash = TRUE; + gBattlescriptCurrInstr += 7; // and then we proceed with the rest of our battlescript } return; case VARIOUS_INVERT_STAT_STAGES: @@ -8568,7 +8554,7 @@ static void Cmd_various(void) } return; case VARIOUS_TRY_SOAK: - if (gBattleMons[gBattlerTarget].type1 == gBattleMoves[gCurrentMove].type + if (gBattleMons[gBattlerTarget].type1 == gBattleMoves[gCurrentMove].type && gBattleMons[gBattlerTarget].type2 == gBattleMoves[gCurrentMove].type) { gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); @@ -9096,7 +9082,7 @@ static void Cmd_various(void) case VARIOUS_MAKE_INVISIBLE: if (gBattleControllerExecFlags) break; - + BtlController_EmitSpriteInvisibility(BUFFER_A, TRUE); MarkBattlerForControllerExec(gActiveBattler); break; @@ -9137,10 +9123,10 @@ static void Cmd_various(void) BtlController_EmitSetMonData(BUFFER_A, REQUEST_PPMOVE1_BATTLE + i, 0, sizeof(gBattleMons[gActiveBattler].pp[i]), &gBattleMons[gActiveBattler].pp[i]); MarkBattlerForControllerExec(gActiveBattler); } - + if (gBattleMons[gActiveBattler].pp[i] == 0 && gBattleStruct->skyDropTargets[gActiveBattler] == 0xFF) CancelMultiTurnMoves(gActiveBattler); - + gBattlescriptCurrInstr += 7; // continue } else @@ -9214,19 +9200,19 @@ static void Cmd_various(void) return; case VARIOUS_SET_SKY_DROP: gStatuses3[gBattlerTarget] |= (STATUS3_SKY_DROPPED | STATUS3_ON_AIR); - /* skyDropTargets holds the information of who is in a particular instance of Sky Drop. + /* skyDropTargets holds the information of who is in a particular instance of Sky Drop. This is needed in the case that multiple Pokemon use Sky Drop in the same turn or if the target of a Sky Drop faints while in the air.*/ gBattleStruct->skyDropTargets[gBattlerAttacker] = gBattlerTarget; gBattleStruct->skyDropTargets[gBattlerTarget] = gBattlerAttacker; - + // End any multiturn effects caused by the target except STATUS2_LOCK_CONFUSE gBattleMons[gBattlerTarget].status2 &= ~(STATUS2_MULTIPLETURNS); gBattleMons[gBattlerTarget].status2 &= ~(STATUS2_UPROAR); gBattleMons[gBattlerTarget].status2 &= ~(STATUS2_BIDE); gDisableStructs[gBattlerTarget].rolloutTimer = 0; gDisableStructs[gBattlerTarget].furyCutterCounter = 0; - + // End any Follow Me/Rage Powder effects caused by the target if (gSideTimers[GetBattlerSide(gBattlerTarget)].followmeTimer != 0 && gSideTimers[GetBattlerSide(gBattlerTarget)].followmeTarget == gBattlerTarget) gSideTimers[GetBattlerSide(gBattlerTarget)].followmeTimer = 0; @@ -9239,12 +9225,12 @@ static void Cmd_various(void) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); else { - gBattleStruct->skyDropTargets[gBattlerAttacker] = 0xFF; + gBattleStruct->skyDropTargets[gBattlerAttacker] = 0xFF; gBattleStruct->skyDropTargets[gBattlerTarget] = 0xFF; gStatuses3[gBattlerTarget] &= ~(STATUS3_SKY_DROPPED | STATUS3_ON_AIR); gBattlescriptCurrInstr += 7; } - + // Confuse target if they were in the middle of Petal Dance/Outrage/Thrash when targeted. if (gBattleMons[gBattlerTarget].status2 & STATUS2_LOCK_CONFUSE) gBattleScripting.moveEffect = (MOVE_EFFECT_CONFUSION | MOVE_EFFECT_CERTAIN); @@ -9258,7 +9244,7 @@ static void Cmd_various(void) // Clear skyDropTargets data gBattleStruct->skyDropTargets[gBattleStruct->skyDropTargets[gEffectBattler]] = 0xFF; gBattleStruct->skyDropTargets[gEffectBattler] = 0xFF; - + // If the target was in the middle of Outrage/Thrash/etc. when targeted by Sky Drop, confuse them on release and do proper animation if (gBattleMons[gEffectBattler].status2 & STATUS2_LOCK_CONFUSE && CanBeConfused(gEffectBattler)) { @@ -9331,7 +9317,7 @@ static void Cmd_various(void) count++; } } - + if (count == 0) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); // Rototiller fails else @@ -9368,19 +9354,19 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 4; return; } - + gBattleScripting.battler = gEffectBattler = gBattlerTarget = gActiveBattler; // Cover all berry effect battlerId cases. e.g. ChangeStatBuffs uses target ID // Do move end berry effects for just a single battler, instead of looping through all battlers if (ItemBattleEffects(ITEMEFFECT_BATTLER_MOVE_END, gActiveBattler, FALSE)) return; - + if (gBattlescriptCurrInstr[3]) { gBattleMons[gActiveBattler].item = gBattleStruct->changedItems[gActiveBattler]; gBattleStruct->changedItems[gActiveBattler] = ITEM_NONE; gBattleResources->flags->flags[gActiveBattler] &= ~RESOURCE_FLAG_UNBURDEN; } - + gBattlescriptCurrInstr += 4; return; case VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL: @@ -9552,7 +9538,7 @@ static void Cmd_various(void) return; case VARIOUS_CAN_TAR_SHOT_WORK: // Tar Shot will fail if it's already been used on the target and its speed can't be lowered further - if (!gDisableStructs[gActiveBattler].tarShot + if (!gDisableStructs[gActiveBattler].tarShot && CompareStat(gActiveBattler, STAT_SPEED, MAX_STAT_STAGE, CMP_LESS_THAN)) gBattlescriptCurrInstr += 7; else @@ -9650,7 +9636,7 @@ static void Cmd_various(void) case VARIOUS_BATTLER_ITEM_TO_LAST_USED_ITEM: gBattleMons[gActiveBattler].item = gLastUsedItem; break; - case VARIOUS_SET_BEAK_BLAST: + case VARIOUS_SET_BEAK_BLAST: gProtectStructs[gBattlerAttacker].beakBlastCharge = TRUE; break; case VARIOUS_SWAP_SIDE_STATUSES: @@ -10268,7 +10254,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr gActiveBattler = gBattlerAttacker; else gActiveBattler = gBattlerTarget; - + activeBattlerAbility = GetBattlerAbility(gActiveBattler); gSpecialStatuses[gActiveBattler].changedStatsBattlerId = gBattlerAttacker; @@ -10432,7 +10418,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr gBattleTextBuff2[index++] = STRINGID_STATFELL; gBattleTextBuff2[index++] = STRINGID_STATFELL >> 8; gBattleTextBuff2[index] = B_BUFF_EOS; - + if (gBattleMons[gActiveBattler].statStages[statId] == MIN_STAT_STAGE) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STAT_WONT_DECREASE; @@ -10619,9 +10605,9 @@ static void Cmd_forcerandomswitch(void) struct Pokemon *party = NULL; s32 validMons = 0; s32 minNeeded; - + bool32 redCardForcedSwitch = FALSE; - + // Red card checks against wild pokemon. If we have reached here, the player has a mon to switch into // Red card swaps attacker with target to get the animation correct, so here we check attacker which is really the target. Thanks GF... if (gBattleScripting.switchCase == B_SWITCH_RED_CARD @@ -10664,7 +10650,7 @@ static void Cmd_forcerandomswitch(void) && GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER) || redCardForcedSwitch ) - { + { if (GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER) party = gPlayerParty; else @@ -12189,7 +12175,7 @@ static void Cmd_maxattackhalvehp(void) if (!(gBattleMons[gBattlerAttacker].maxHP / 2)) halfHp = 1; - + // Belly Drum fails if the user's current HP is less than half its maximum, or if the user's Attack is already at +6 (even if the user has Contrary). if (gBattleMons[gBattlerAttacker].statStages[STAT_ATK] < MAX_STAT_STAGE && gBattleMons[gBattlerAttacker].hp > halfHp) @@ -12685,7 +12671,7 @@ static void Cmd_tryswapitems(void) gBattleMons[gBattlerAttacker].item = ITEM_NONE; gBattleMons[gBattlerTarget].item = oldItemAtk; - + RecordItemEffectBattle(gBattlerAttacker, 0); RecordItemEffectBattle(gBattlerTarget, ItemId_GetHoldEffect(oldItemAtk)); @@ -12704,7 +12690,7 @@ static void Cmd_tryswapitems(void) PREPARE_ITEM_BUFFER(gBattleTextBuff1, *newItemAtk) PREPARE_ITEM_BUFFER(gBattleTextBuff2, oldItemAtk) - + if (!(sideAttacker == sideTarget && IsPartnerMonFromSameTrainer(gBattlerAttacker))) { // if targeting your own side and you aren't in a multi battle, don't save items as stolen @@ -12781,7 +12767,7 @@ static void Cmd_trywish(void) #else gBattleMoveDamage = max(1, gBattleMons[gBattlerTarget].maxHP / 2); #endif - + gBattleMoveDamage *= -1; if (gBattleMons[gBattlerTarget].hp == gBattleMons[gBattlerTarget].maxHP) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 2); @@ -13177,7 +13163,7 @@ u16 GetSecretPowerMoveEffect(void) } } else - { + { switch (gBattleTerrain) { case BATTLE_TERRAIN_GRASS: @@ -13400,7 +13386,7 @@ static void Cmd_settypebasedhalvers(void) gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WEAKEN_ELECTRIC; worked = TRUE; } - #else + #else if (!(gStatuses4[gBattlerAttacker] & STATUS4_MUD_SPORT)) { gStatuses4[gBattlerAttacker] |= STATUS4_MUD_SPORT; @@ -13575,20 +13561,20 @@ static void Cmd_removelightscreenreflect(void) { u8 side; bool32 failed; - + #if B_BRICK_BREAK >= GEN_4 // From Gen 4 onwards, Brick Break can remove screens on the user's side if used on an ally side = GetBattlerSide(gBattlerTarget); #else side = GetBattlerSide(gBattlerAttacker) ^ BIT_SIDE; #endif - + #if B_BRICK_BREAK >= GEN_5 failed = (gMoveResultFlags & MOVE_RESULT_NO_EFFECT); #else failed = FALSE; #endif - + if (!failed && (gSideTimers[side].reflectTimer || gSideTimers[side].lightscreenTimer @@ -13647,7 +13633,7 @@ static void Cmd_handleballthrow(void) { u32 odds, i; u8 catchRate; - + gLastThrownBall = gLastUsedItem; if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) catchRate = gBattleStruct->safariCatchFactor * 1275 / 100;