diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 8482716f5b55..e699cb977fbe 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -1707,7 +1707,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score) || !IsBattlerAlive(BATTLE_PARTNER(battlerAtk)) || PartnerHasSameMoveEffectWithoutTarget(BATTLE_PARTNER(battlerAtk), move, aiData->partnerMove) || (aiData->partnerMove != MOVE_NONE && IsBattleMoveStatus(aiData->partnerMove)) - || *(gBattleStruct->monToSwitchIntoId + BATTLE_PARTNER(battlerAtk)) != PARTY_SIZE) //Partner is switching out. + || gBattleStruct->monToSwitchIntoId[BATTLE_PARTNER(battlerAtk)] != PARTY_SIZE) //Partner is switching out. ADJUST_SCORE(-10); break; case EFFECT_TRICK: diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 93148d8b837d..6e7288f95c82 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -1120,7 +1120,7 @@ void AI_TrySwitchOrUseItem(u32 battler) gBattleStruct->AI_monToSwitchIntoId[battler] = monToSwitchId; } - *(gBattleStruct->monToSwitchIntoId + battler) = gBattleStruct->AI_monToSwitchIntoId[battler]; + gBattleStruct->monToSwitchIntoId[battler] = gBattleStruct->AI_monToSwitchIntoId[battler]; AI_DATA->monToSwitchInId[battler] = gBattleStruct->AI_monToSwitchIntoId[battler]; return; } @@ -1984,8 +1984,8 @@ u32 GetMostSuitableMonToSwitchInto(u32 battler, bool32 switchAfterMonKOd) s32 lastId = 0; // + 1 struct Pokemon *party; - if (*(gBattleStruct->monToSwitchIntoId + battler) != PARTY_SIZE) - return *(gBattleStruct->monToSwitchIntoId + battler); + if (gBattleStruct->monToSwitchIntoId[battler] != PARTY_SIZE) + return gBattleStruct->monToSwitchIntoId[battler]; if (gBattleTypeFlags & BATTLE_TYPE_ARENA) return gBattlerPartyIndexes[battler] + 1; diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 1e5996f780ee..e759bb9953be 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -2043,7 +2043,7 @@ static void PlayerHandleChooseAction(u32 battler) if (B_SHOW_PARTNER_TARGET && gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && IsBattlerAlive(B_POSITION_PLAYER_RIGHT)) { StringCopy(gStringVar1, COMPOUND_STRING("Partner will use:\n")); - u32 move = gBattleMons[B_POSITION_PLAYER_RIGHT].moves[*(gBattleStruct->chosenMovePositions + B_POSITION_PLAYER_RIGHT)]; + u32 move = gBattleMons[B_POSITION_PLAYER_RIGHT].moves[gBattleStruct->chosenMovePositions[B_POSITION_PLAYER_RIGHT]]; StringAppend(gStringVar1, GetMoveName(move)); u32 moveTarget = GetBattlerMoveTargetType(B_POSITION_PLAYER_RIGHT, move); if (moveTarget == MOVE_TARGET_SELECTED) @@ -2107,7 +2107,7 @@ void HandleChooseMoveAfterDma3(u32 battler) static void PlayerChooseMoveInBattlePalace(u32 battler) { - if (--*(gBattleStruct->arenaMindPoints + battler) == 0) + if (--gBattleStruct->arenaMindPoints[battler] == 0) { gBattlePalaceMoveSelectionRngValue = gRngValue; BtlController_EmitTwoReturnValues(battler, BUFFER_B, 10, ChooseMoveAndTargetInBattlePalace(battler)); @@ -2119,7 +2119,7 @@ void PlayerHandleChooseMove(u32 battler) { if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - *(gBattleStruct->arenaMindPoints + battler) = 8; + gBattleStruct->arenaMindPoints[battler] = 8; gBattlerControllerFuncs[battler] = PlayerChooseMoveInBattlePalace; } else diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 1fcc4fbef744..4c3163dd9ad3 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -405,7 +405,7 @@ static void PlayerPartnerHandleChoosePokemon(u32 battler) } } } - *(gBattleStruct->monToSwitchIntoId + battler) = chosenMonId; + gBattleStruct->monToSwitchIntoId[battler] = chosenMonId; } else // Mon to switch out has been already chosen. { diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index 7cffc5fd5b4f..da6dc9f13390 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -484,9 +484,9 @@ static void RecordedOpponentHandleChooseItem(u32 battler) static void RecordedOpponentHandleChoosePokemon(u32 battler) { - *(gBattleStruct->monToSwitchIntoId + battler) = RecordedBattle_GetBattlerAction(RECORDED_PARTY_INDEX, battler); + gBattleStruct->monToSwitchIntoId[battler] = RecordedBattle_GetBattlerAction(RECORDED_PARTY_INDEX, battler); gSelectedMonPartyId = gBattleStruct->monToSwitchIntoId[battler]; // Revival Blessing - BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, *(gBattleStruct->monToSwitchIntoId + battler), NULL); + BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, gBattleStruct->monToSwitchIntoId[battler], NULL); RecordedOpponentBufferExecCompleted(battler); } diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 568051bd8c60..2ca57d7af859 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -477,9 +477,9 @@ static void RecordedPlayerHandleChooseItem(u32 battler) static void RecordedPlayerHandleChoosePokemon(u32 battler) { - *(gBattleStruct->monToSwitchIntoId + battler) = RecordedBattle_GetBattlerAction(RECORDED_PARTY_INDEX, battler); + gBattleStruct->monToSwitchIntoId[battler] = RecordedBattle_GetBattlerAction(RECORDED_PARTY_INDEX, battler); gSelectedMonPartyId = gBattleStruct->monToSwitchIntoId[battler]; // Revival Blessing - BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, *(gBattleStruct->monToSwitchIntoId + battler), NULL); + BtlController_EmitChosenMonReturnValue(battler, BUFFER_B, gBattleStruct->monToSwitchIntoId[battler], NULL); RecordedPlayerBufferExecCompleted(battler); } diff --git a/src/battle_main.c b/src/battle_main.c index 5c1b999ab95b..b47df2fb2f1c 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3198,9 +3198,9 @@ void SwitchInClearSetData(u32 battler) { if (gBattleMons[i].status2 & STATUS2_INFATUATED_WITH(battler)) gBattleMons[i].status2 &= ~STATUS2_INFATUATED_WITH(battler); - if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && *(gBattleStruct->wrappedBy + i) == 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) + if ((gStatuses4[i] & STATUS4_SYRUP_BOMB) && gBattleStruct->stickySyrupdBy[i] == battler) gStatuses4[i] &= ~STATUS4_SYRUP_BOMB; } @@ -3313,9 +3313,9 @@ const u8* FaintClearSetData(u32 battler) gBattleMons[i].status2 &= ~STATUS2_ESCAPE_PREVENTION; if (gBattleMons[i].status2 & STATUS2_INFATUATED_WITH(battler)) gBattleMons[i].status2 &= ~STATUS2_INFATUATED_WITH(battler); - if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && *(gBattleStruct->wrappedBy + i) == 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) + if ((gStatuses4[i] & STATUS4_SYRUP_BOMB) && gBattleStruct->stickySyrupdBy[i] == battler) gStatuses4[i] &= ~STATUS4_SYRUP_BOMB; } @@ -3931,7 +3931,7 @@ static void TryDoEventsBeforeFirstTurn(void) case FIRST_TURN_EVENTS_END: for (i = 0; i < MAX_BATTLERS_COUNT; i++) { - *(gBattleStruct->monToSwitchIntoId + i) = PARTY_SIZE; + gBattleStruct->monToSwitchIntoId[i] = PARTY_SIZE; gChosenActionByBattler[i] = B_ACTION_NONE; gChosenMoveByBattler[i] = MOVE_NONE; gBattleStruct->battlerState[i].absentBattlerFlags = gAbsentBattlerFlags & (1u << i); @@ -4052,10 +4052,15 @@ void BattleTurnPassed(void) gChosenActionByBattler[i] = B_ACTION_NONE; gChosenMoveByBattler[i] = MOVE_NONE; gBattleStruct->battlerState[i].absentBattlerFlags = gAbsentBattlerFlags & (1u << i); + gBattleStruct->monToSwitchIntoId[i] = PARTY_SIZE; } - for (i = 0; i < MAX_BATTLERS_COUNT; i++) - *(gBattleStruct->monToSwitchIntoId + i) = PARTY_SIZE; + for (i = 0; i < NUM_BATTLE_SIDES; i++) + { + if (gSideTimers[i].retaliateTimer > 0) + gSideTimers[i].retaliateTimer--; + + } BattlePutTextOnWindow(gText_EmptyString3, B_WIN_MSG); AssignUsableGimmicks(); @@ -4063,11 +4068,6 @@ void BattleTurnPassed(void) SetAiLogicDataForTurn(AI_DATA); // get assumed abilities, hold effects, etc of all battlers gBattleMainFunc = HandleTurnActionSelectionState; - if (gSideTimers[B_SIDE_PLAYER].retaliateTimer > 0) - gSideTimers[B_SIDE_PLAYER].retaliateTimer--; - if (gSideTimers[B_SIDE_OPPONENT].retaliateTimer > 0) - gSideTimers[B_SIDE_OPPONENT].retaliateTimer--; - if (gBattleTypeFlags & BATTLE_TYPE_PALACE) BattleScriptExecute(BattleScript_PalacePrintFlavorText); else if (gBattleTypeFlags & BATTLE_TYPE_ARENA && gBattleStruct->arenaTurnCounter == 0) @@ -4168,7 +4168,7 @@ void SwitchPartyOrder(u32 battler) gBattlePartyCurrentOrder[i] = *(battler * 3 + i + (u8 *)(gBattleStruct->battlerPartyOrders)); partyId1 = GetPartyIdFromBattlePartyId(gBattlerPartyIndexes[battler]); - partyId2 = GetPartyIdFromBattlePartyId(*(gBattleStruct->monToSwitchIntoId + battler)); + partyId2 = GetPartyIdFromBattlePartyId(gBattleStruct->monToSwitchIntoId[battler]); SwitchPartyMonSlots(partyId1, partyId2); if (IsDoubleBattle()) @@ -4204,7 +4204,7 @@ enum void SetupAISwitchingData(u32 battler, bool32 isAiRisky) { s32 opposingBattler = GetBattlerAtPosition(BATTLE_OPPOSITE(GetBattlerPosition(battler))); - + // AI's data AI_DATA->mostSuitableMonId[battler] = GetMostSuitableMonToSwitchInto(battler, isAiRisky); if (ShouldSwitch(battler)) @@ -4219,7 +4219,7 @@ void SetupAISwitchingData(u32 battler, bool32 isAiRisky) if (ShouldSwitch(opposingBattler)) AI_DATA->shouldSwitch |= (1u << opposingBattler); AI_DATA->aiSwitchPredictionInProgress = FALSE; - + // Determine whether AI will use predictions this turn AI_DATA->predictingSwitch = RandomPercentage(RNG_AI_PREDICT_SWITCH, 50); } @@ -4257,7 +4257,7 @@ static void HandleTurnActionSelectionState(void) } // fallthrough case STATE_BEFORE_ACTION_CHOSEN: // Choose an action. - *(gBattleStruct->monToSwitchIntoId + battler) = PARTY_SIZE; + gBattleStruct->monToSwitchIntoId[battler] = PARTY_SIZE; if (gBattleTypeFlags & BATTLE_TYPE_MULTI || (position & BIT_FLANK) == B_FLANK_LEFT || gBattleStruct->battlerState[GetBattlerAtPosition(BATTLE_PARTNER(position))].absentBattlerFlags @@ -4310,15 +4310,15 @@ static void HandleTurnActionSelectionState(void) if (AreAllMovesUnusable(battler)) { gBattleCommunication[battler] = STATE_SELECTION_SCRIPT; - *(gBattleStruct->selectionScriptFinished + battler) = FALSE; - *(gBattleStruct->stateIdAfterSelScript + battler) = STATE_WAIT_ACTION_CONFIRMED_STANDBY; - *(gBattleStruct->moveTarget + battler) = gBattleResources->bufferB[battler][3]; + gBattleStruct->selectionScriptFinished[battler] = FALSE; + gBattleStruct->stateIdAfterSelScript[battler] = STATE_WAIT_ACTION_CONFIRMED_STANDBY; + gBattleStruct->moveTarget[battler] = gBattleResources->bufferB[battler][3]; return; } else if (gDisableStructs[battler].encoredMove != 0) { gChosenMoveByBattler[battler] = gDisableStructs[battler].encoredMove; - *(gBattleStruct->chosenMovePositions + battler) = gDisableStructs[battler].encoredMovePos; + gBattleStruct->chosenMovePositions[battler] = gDisableStructs[battler].encoredMovePos; gBattleCommunication[battler] = STATE_WAIT_ACTION_CONFIRMED_STANDBY; return; } @@ -4352,8 +4352,8 @@ static void HandleTurnActionSelectionState(void) RecordedBattle_ClearBattlerAction(battler, 1); gSelectionBattleScripts[battler] = BattleScript_ActionSelectionItemsCantBeUsed; gBattleCommunication[battler] = STATE_SELECTION_SCRIPT; - *(gBattleStruct->selectionScriptFinished + battler) = FALSE; - *(gBattleStruct->stateIdAfterSelScript + battler) = STATE_BEFORE_ACTION_CHOSEN; + gBattleStruct->selectionScriptFinished[battler] = FALSE; + gBattleStruct->stateIdAfterSelScript[battler] = STATE_BEFORE_ACTION_CHOSEN; return; } @@ -4368,8 +4368,8 @@ static void HandleTurnActionSelectionState(void) RecordedBattle_ClearBattlerAction(battler, 1); gSelectionBattleScripts[battler] = BattleScript_ActionSelectionItemsCantBeUsed; gBattleCommunication[battler] = STATE_SELECTION_SCRIPT; - *(gBattleStruct->selectionScriptFinished + battler) = FALSE; - *(gBattleStruct->stateIdAfterSelScript + battler) = STATE_BEFORE_ACTION_CHOSEN; + gBattleStruct->selectionScriptFinished[battler] = FALSE; + gBattleStruct->stateIdAfterSelScript[battler] = STATE_BEFORE_ACTION_CHOSEN; return; } else @@ -4379,7 +4379,7 @@ static void HandleTurnActionSelectionState(void) } break; case B_ACTION_SWITCH: - *(gBattleStruct->battlerPartyIndexes + battler) = gBattlerPartyIndexes[battler]; + gBattleStruct->battlerPartyIndexes[battler] = gBattlerPartyIndexes[battler]; if (gBattleTypeFlags & BATTLE_TYPE_ARENA || !CanBattlerEscape(battler)) { @@ -4393,9 +4393,9 @@ static void HandleTurnActionSelectionState(void) else { if (battler == 2 && gChosenActionByBattler[0] == B_ACTION_SWITCH) - BtlController_EmitChoosePokemon(battler, BUFFER_A, PARTY_ACTION_CHOOSE_MON, *(gBattleStruct->monToSwitchIntoId + 0), ABILITY_NONE, gBattleStruct->battlerPartyOrders[battler]); + BtlController_EmitChoosePokemon(battler, BUFFER_A, PARTY_ACTION_CHOOSE_MON, gBattleStruct->monToSwitchIntoId[0], ABILITY_NONE, gBattleStruct->battlerPartyOrders[battler]); else if (battler == 3 && gChosenActionByBattler[1] == B_ACTION_SWITCH) - BtlController_EmitChoosePokemon(battler, BUFFER_A, PARTY_ACTION_CHOOSE_MON, *(gBattleStruct->monToSwitchIntoId + 1), ABILITY_NONE, gBattleStruct->battlerPartyOrders[battler]); + BtlController_EmitChoosePokemon(battler, BUFFER_A, PARTY_ACTION_CHOOSE_MON, gBattleStruct->monToSwitchIntoId[1], ABILITY_NONE, gBattleStruct->battlerPartyOrders[battler]); else BtlController_EmitChoosePokemon(battler, BUFFER_A, PARTY_ACTION_CHOOSE_MON, PARTY_SIZE, ABILITY_NONE, gBattleStruct->battlerPartyOrders[battler]); } @@ -4406,8 +4406,8 @@ static void HandleTurnActionSelectionState(void) { gSelectionBattleScripts[battler] = BattleScript_PrintFullBox; gBattleCommunication[battler] = STATE_SELECTION_SCRIPT; - *(gBattleStruct->selectionScriptFinished + battler) = FALSE; - *(gBattleStruct->stateIdAfterSelScript + battler) = STATE_BEFORE_ACTION_CHOSEN; + gBattleStruct->selectionScriptFinished[battler] = FALSE; + gBattleStruct->stateIdAfterSelScript[battler] = STATE_BEFORE_ACTION_CHOSEN; return; } break; @@ -4467,8 +4467,8 @@ static void HandleTurnActionSelectionState(void) { gSelectionBattleScripts[battler] = BattleScript_AskIfWantsToForfeitMatch; gBattleCommunication[battler] = STATE_SELECTION_SCRIPT_MAY_RUN; - *(gBattleStruct->selectionScriptFinished + battler) = FALSE; - *(gBattleStruct->stateIdAfterSelScript + battler) = STATE_BEFORE_ACTION_CHOSEN; + gBattleStruct->selectionScriptFinished[battler] = FALSE; + gBattleStruct->stateIdAfterSelScript[battler] = STATE_BEFORE_ACTION_CHOSEN; return; } else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER @@ -4484,8 +4484,8 @@ static void HandleTurnActionSelectionState(void) { gSelectionBattleScripts[battler] = BattleScript_PrintCantEscapeFromBattle; gBattleCommunication[battler] = STATE_SELECTION_SCRIPT; - *(gBattleStruct->selectionScriptFinished + battler) = FALSE; - *(gBattleStruct->stateIdAfterSelScript + battler) = STATE_BEFORE_ACTION_CHOSEN; + gBattleStruct->selectionScriptFinished[battler] = FALSE; + gBattleStruct->stateIdAfterSelScript[battler] = STATE_BEFORE_ACTION_CHOSEN; return; } else @@ -4526,9 +4526,9 @@ static void HandleTurnActionSelectionState(void) { RecordedBattle_ClearBattlerAction(battler, 1); gBattleCommunication[battler] = STATE_SELECTION_SCRIPT; - *(gBattleStruct->selectionScriptFinished + battler) = FALSE; + gBattleStruct->selectionScriptFinished[battler] = FALSE; gBattleResources->bufferB[battler][1] = B_ACTION_USE_MOVE; - *(gBattleStruct->stateIdAfterSelScript + battler) = STATE_WAIT_ACTION_CHOSEN; + gBattleStruct->stateIdAfterSelScript[battler] = STATE_WAIT_ACTION_CHOSEN; return; } else @@ -4657,9 +4657,9 @@ static void HandleTurnActionSelectionState(void) } break; case STATE_SELECTION_SCRIPT: - if (*(gBattleStruct->selectionScriptFinished + battler)) + if (gBattleStruct->selectionScriptFinished[battler]) { - gBattleCommunication[battler] = *(gBattleStruct->stateIdAfterSelScript + battler); + gBattleCommunication[battler] = gBattleStruct->stateIdAfterSelScript[battler]; } else { @@ -4679,7 +4679,7 @@ static void HandleTurnActionSelectionState(void) } break; case STATE_SELECTION_SCRIPT_MAY_RUN: - if (*(gBattleStruct->selectionScriptFinished + battler)) + if (gBattleStruct->selectionScriptFinished[battler]) { if (gBattleResources->bufferB[battler][1] == B_ACTION_NOTHING_FAINTED) { @@ -4690,7 +4690,7 @@ static void HandleTurnActionSelectionState(void) else { RecordedBattle_ClearBattlerAction(battler, 1); - gBattleCommunication[battler] = *(gBattleStruct->stateIdAfterSelScript + battler); + gBattleCommunication[battler] = gBattleStruct->stateIdAfterSelScript[battler]; } } else @@ -4732,7 +4732,7 @@ static void HandleTurnActionSelectionState(void) for (i = 0; i < gBattlersCount; i++) { if (gChosenActionByBattler[i] == B_ACTION_SWITCH) - SwitchPartyOrderInGameMulti(i, *(gBattleStruct->monToSwitchIntoId + i)); + SwitchPartyOrderInGameMulti(i, gBattleStruct->monToSwitchIntoId[battler]); } } } @@ -4862,7 +4862,7 @@ s8 GetChosenMovePriority(u32 battler) if (gProtectStructs[battler].noValidMoves) move = MOVE_STRUGGLE; else - move = gBattleMons[battler].moves[*(gBattleStruct->chosenMovePositions + battler)]; + move = gBattleMons[battler].moves[gBattleStruct->chosenMovePositions[battler]]; return GetBattleMovePriority(battler, move); } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index f88be3a36f14..34a5a83ed971 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4507,7 +4507,7 @@ static void Cmd_tryfaintmon(void) && IsBattlerAlive(gBattlerAttacker) && gCurrentMove != MOVE_STRUGGLE) { - u8 moveIndex = *(gBattleStruct->chosenMovePositions + gBattlerAttacker); + u8 moveIndex = gBattleStruct->chosenMovePositions[gBattlerAttacker]; gBattleMons[gBattlerAttacker].pp[moveIndex] = 0; BattleScriptPush(gBattlescriptCurrInstr); @@ -6950,9 +6950,9 @@ static void Cmd_moveend(void) break; case MOVEEND_CLEAR_BITS: // Clear/Set bits for things like using a move for all targets and all hits. if (gSpecialStatuses[gBattlerAttacker].instructedChosenTarget) - *(gBattleStruct->moveTarget + gBattlerAttacker) = gSpecialStatuses[gBattlerAttacker].instructedChosenTarget & 0x3; + gBattleStruct->moveTarget[gBattlerAttacker] = gSpecialStatuses[gBattlerAttacker].instructedChosenTarget & 0x3; if (gSpecialStatuses[gBattlerAttacker].dancerOriginalTarget) - *(gBattleStruct->moveTarget + gBattlerAttacker) = gSpecialStatuses[gBattlerAttacker].dancerOriginalTarget & 0x3; + gBattleStruct->moveTarget[gBattlerAttacker] = gSpecialStatuses[gBattlerAttacker].dancerOriginalTarget & 0x3; if (B_RAMPAGE_CANCELLING >= GEN_5 && MoveHasAdditionalEffectSelf(gCurrentMove, MOVE_EFFECT_THRASH) // If we're rampaging @@ -7027,7 +7027,7 @@ static void Cmd_moveend(void) if (SetTargetToNextPursuiter(gBattlerTarget)) { ChangeOrderTargetAfterAttacker(); - *(gBattleStruct->moveTarget + gBattlerTarget) = storedTarget; + gBattleStruct->moveTarget[gBattlerTarget] = storedTarget; gBattlerTarget = storedTarget; } else if (IsBattlerAlive(gBattlerTarget)) @@ -7037,7 +7037,7 @@ static void Cmd_moveend(void) gBattlescriptCurrInstr = BattleScript_MoveSwitchOpenPartyScreen; else gBattlescriptCurrInstr = BattleScript_DoSwitchOut; - *(gBattleStruct->monToSwitchIntoId + gBattlerTarget) = gBattleStruct->pursuitStoredSwitch; + gBattleStruct->monToSwitchIntoId[gBattlerTarget] = gBattleStruct->pursuitStoredSwitch; ClearPursuitValues(); effect = TRUE; } @@ -7562,11 +7562,11 @@ static void Cmd_openpartyscreen(void) } else { - *(gBattleStruct->battlerPartyIndexes + battler) = gBattlerPartyIndexes[battler]; - *(gBattleStruct->monToSwitchIntoId + battler) = PARTY_SIZE; + gBattleStruct->battlerPartyIndexes[battler] = gBattlerPartyIndexes[battler]; + gBattleStruct->monToSwitchIntoId[battler] = PARTY_SIZE; gBattleStruct->field_93 &= ~(1u << battler); - BtlController_EmitChoosePokemon(battler, BUFFER_A, hitmarkerFaintBits, *(gBattleStruct->monToSwitchIntoId + BATTLE_PARTNER(battler)), ABILITY_NONE, gBattleStruct->battlerPartyOrders[battler]); + BtlController_EmitChoosePokemon(battler, BUFFER_A, hitmarkerFaintBits, gBattleStruct->monToSwitchIntoId[BATTLE_PARTNER(battler)], ABILITY_NONE, gBattleStruct->battlerPartyOrders[battler]); MarkBattlerForControllerExec(battler); gBattlescriptCurrInstr = cmd->nextInstr; @@ -7619,7 +7619,7 @@ static void Cmd_switchhandleorder(void) { if (gBattleResources->bufferB[i][0] == CONTROLLER_CHOSENMONRETURNVALUE) { - *(gBattleStruct->monToSwitchIntoId + i) = gBattleResources->bufferB[i][1]; + gBattleStruct->monToSwitchIntoId[i] = gBattleResources->bufferB[i][1]; if (!(gBattleStruct->field_93 & (1u << i))) { RecordedBattle_SetBattlerAction(i, gBattleResources->bufferB[i][1]); @@ -7641,7 +7641,7 @@ static void Cmd_switchhandleorder(void) // fall through case 3: gBattleCommunication[0] = gBattleResources->bufferB[battler][1]; - *(gBattleStruct->monToSwitchIntoId + battler) = gBattleResources->bufferB[battler][1]; + gBattleStruct->monToSwitchIntoId[battler] = gBattleResources->bufferB[battler][1]; if (gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & BATTLE_TYPE_MULTI) { @@ -7655,7 +7655,7 @@ static void Cmd_switchhandleorder(void) } else if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) { - SwitchPartyOrderInGameMulti(battler, *(gBattleStruct->monToSwitchIntoId + battler)); + SwitchPartyOrderInGameMulti(battler, gBattleStruct->monToSwitchIntoId[battler]); } else { @@ -9054,7 +9054,7 @@ static void Cmd_hpthresholds2(void) { u32 battler = GetBattlerForBattleScript(cmd->battler); u32 opposingBattler = BATTLE_OPPOSITE(battler); - u8 hpSwitchout = *(gBattleStruct->hpOnSwitchout + GetBattlerSide(opposingBattler)); + u8 hpSwitchout = gBattleStruct->hpOnSwitchout[GetBattlerSide(opposingBattler)]; s32 result = (hpSwitchout - gBattleMons[opposingBattler].hp) * 100 / hpSwitchout; if (gBattleMons[opposingBattler].hp >= hpSwitchout) @@ -10504,7 +10504,7 @@ static void Cmd_various(void) } else { - gSpecialStatuses[gBattlerTarget].instructedChosenTarget = *(gBattleStruct->moveTarget + gBattlerTarget) | 0x4; + gSpecialStatuses[gBattlerTarget].instructedChosenTarget = gBattleStruct->moveTarget[gBattlerTarget] | 0x4; gCalledMove = move; for (i = 0; i < MAX_MON_MOVES; i++) { @@ -12488,10 +12488,10 @@ static void Cmd_forcerandomswitch(void) } else { - *(gBattleStruct->battlerPartyIndexes + gBattlerTarget) = gBattlerPartyIndexes[gBattlerTarget]; + gBattleStruct->battlerPartyIndexes[gBattlerTarget] = gBattlerPartyIndexes[gBattlerTarget]; gBattlescriptCurrInstr = BattleScript_RoarSuccessSwitch; gBattleStruct->battlerState[gBattlerTarget].forcedSwitch = TRUE; - *(gBattleStruct->monToSwitchIntoId + gBattlerTarget) = validMons[RandomUniform(RNG_FORCE_RANDOM_SWITCH, 0, validMonsCount - 1)]; + gBattleStruct->monToSwitchIntoId[gBattlerTarget] = validMons[RandomUniform(RNG_FORCE_RANDOM_SWITCH, 0, validMonsCount - 1)]; if (!IsMultiBattle()) SwitchPartyOrder(gBattlerTarget); @@ -14004,7 +14004,7 @@ static bool32 SetTargetToNextPursuiter(u32 battlerDef) && IsBattlerAlive(battlerDef) && IsBattlerAlive(battler) && GetBattlerSide(battler) != GetBattlerSide(battlerDef) - && (B_PURSUIT_TARGET >= GEN_4 || *(gBattleStruct->moveTarget + battler) == battlerDef) + && (B_PURSUIT_TARGET >= GEN_4 || gBattleStruct->moveTarget[battler] == battlerDef) && !IsGimmickSelected(battler, GIMMICK_Z_MOVE) && !IsGimmickSelected(battler, GIMMICK_DYNAMAX) && GetActiveGimmick(battler) != GIMMICK_DYNAMAX) @@ -14028,7 +14028,7 @@ static void Cmd_jumpifnopursuitswitchdmg(void) gBattleStruct->battlerState[gBattlerAttacker].pursuitTarget = TRUE; gBattleStruct->pursuitSwitchByMove = gActionsByTurnOrder[gCurrentTurnActionNumber] == B_ACTION_USE_MOVE; gBattleStruct->pursuitStoredSwitch = gBattleStruct->monToSwitchIntoId[gBattlerAttacker]; - *(gBattleStruct->moveTarget + gBattlerTarget) = gBattlerAttacker; + gBattleStruct->moveTarget[gBattlerTarget] = gBattlerAttacker; gBattlerTarget = savedTarget; gBattlescriptCurrInstr = cmd->nextInstr; } @@ -14091,7 +14091,7 @@ static void Cmd_rapidspinfree(void) { gBattleScripting.battler = gBattlerTarget; gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_WRAPPED; - gBattlerTarget = *(gBattleStruct->wrappedBy + gBattlerAttacker); + gBattlerTarget = gBattleStruct->wrappedBy[gBattlerAttacker]; PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleStruct->wrappedMove[gBattlerAttacker]); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_WrapFree; @@ -15084,7 +15084,7 @@ static void Cmd_switchoutabilities(void) gBattleMons[battler].status1 = 0; BtlController_EmitSetMonData(battler, BUFFER_A, REQUEST_STATUS_BATTLE, - 1u << *(gBattleStruct->battlerPartyIndexes + battler), + 1u << gBattleStruct->battlerPartyIndexes[battler], sizeof(gBattleMons[battler].status1), &gBattleMons[battler].status1); MarkBattlerForControllerExec(battler); @@ -15096,7 +15096,7 @@ static void Cmd_switchoutabilities(void) if (regenerate > gBattleMons[battler].maxHP) regenerate = gBattleMons[battler].maxHP; BtlController_EmitSetMonData(battler, BUFFER_A, REQUEST_HP_BATTLE, - 1u << *(gBattleStruct->battlerPartyIndexes + battler), + 1u << gBattleStruct->battlerPartyIndexes[battler], sizeof(regenerate), ®enerate); MarkBattlerForControllerExec(battler); diff --git a/src/battle_util.c b/src/battle_util.c index 19c9f5c4db11..1764c5ee4d9f 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -253,7 +253,7 @@ void HandleAction_UseMove(void) gBattleScripting.savedDmg = 0; gBattleCommunication[MISS_TYPE] = 0; gBattleScripting.savedMoveEffect = 0; - gCurrMovePos = gChosenMovePos = *(gBattleStruct->chosenMovePositions + gBattlerAttacker); + gCurrMovePos = gChosenMovePos = gBattleStruct->chosenMovePositions[gBattlerAttacker]; // choose move if (gProtectStructs[gBattlerAttacker].noValidMoves) @@ -261,7 +261,7 @@ void HandleAction_UseMove(void) gProtectStructs[gBattlerAttacker].noValidMoves = FALSE; gCurrentMove = gChosenMove = MOVE_STRUGGLE; gHitMarker |= HITMARKER_NO_PPDEDUCT; - *(gBattleStruct->moveTarget + gBattlerAttacker) = GetBattleMoveTarget(MOVE_STRUGGLE, NO_TARGET_OVERRIDE); + gBattleStruct->moveTarget[gBattlerAttacker] = GetBattleMoveTarget(MOVE_STRUGGLE, NO_TARGET_OVERRIDE); } else if (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS || gBattleMons[gBattlerAttacker].status2 & STATUS2_RECHARGE) { @@ -273,7 +273,7 @@ void HandleAction_UseMove(void) { gCurrentMove = gChosenMove = gDisableStructs[gBattlerAttacker].encoredMove; gCurrMovePos = gChosenMovePos = gDisableStructs[gBattlerAttacker].encoredMovePos; - *(gBattleStruct->moveTarget + gBattlerAttacker) = GetBattleMoveTarget(gCurrentMove, NO_TARGET_OVERRIDE); + gBattleStruct->moveTarget[gBattlerAttacker] = GetBattleMoveTarget(gCurrentMove, NO_TARGET_OVERRIDE); } // check if the encored move wasn't overwritten else if (GetActiveGimmick(gBattlerAttacker) != GIMMICK_Z_MOVE && gDisableStructs[gBattlerAttacker].encoredMove != MOVE_NONE @@ -284,12 +284,12 @@ void HandleAction_UseMove(void) gDisableStructs[gBattlerAttacker].encoredMove = MOVE_NONE; gDisableStructs[gBattlerAttacker].encoredMovePos = 0; gDisableStructs[gBattlerAttacker].encoreTimer = 0; - *(gBattleStruct->moveTarget + gBattlerAttacker) = GetBattleMoveTarget(gCurrentMove, NO_TARGET_OVERRIDE); + gBattleStruct->moveTarget[gBattlerAttacker] = GetBattleMoveTarget(gCurrentMove, NO_TARGET_OVERRIDE); } else if (gBattleMons[gBattlerAttacker].moves[gCurrMovePos] != gChosenMoveByBattler[gBattlerAttacker]) { gCurrentMove = gChosenMove = gBattleMons[gBattlerAttacker].moves[gCurrMovePos]; - *(gBattleStruct->moveTarget + gBattlerAttacker) = GetBattleMoveTarget(gCurrentMove, NO_TARGET_OVERRIDE); + gBattleStruct->moveTarget[gBattlerAttacker] = GetBattleMoveTarget(gCurrentMove, NO_TARGET_OVERRIDE); } else { @@ -335,7 +335,7 @@ void HandleAction_UseMove(void) } else if (IsDoubleBattle() && gSideTimers[side].followmeTimer == 0 - && !gBattleStruct->battlerState[*(gBattleStruct->moveTarget + gBattlerAttacker)].pursuitTarget + && !gBattleStruct->battlerState[gBattleStruct->moveTarget[gBattlerAttacker]].pursuitTarget && (!IsBattleMoveStatus(gCurrentMove) || (moveTarget != MOVE_TARGET_USER && moveTarget != MOVE_TARGET_ALL_BATTLERS)) && ((ability != ABILITY_LIGHTNING_ROD && moveType == TYPE_ELECTRIC) || (ability != ABILITY_STORM_DRAIN && moveType == TYPE_WATER))) @@ -376,7 +376,7 @@ void HandleAction_UseMove(void) } else { - gBattlerTarget = *(gBattleStruct->moveTarget + gBattlerAttacker); + gBattlerTarget = gBattleStruct->moveTarget[gBattlerAttacker]; } if (!IsBattlerAlive(gBattlerTarget) && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget)) @@ -426,7 +426,7 @@ void HandleAction_UseMove(void) } else { - gBattlerTarget = *(gBattleStruct->moveTarget + gBattlerAttacker); + gBattlerTarget = gBattleStruct->moveTarget[gBattlerAttacker]; if (!IsBattlerAlive(gBattlerTarget) && moveTarget != MOVE_TARGET_OPPONENTS_FIELD && (GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget))) @@ -486,7 +486,7 @@ void HandleAction_Switch(void) gActionSelectionCursor[gBattlerAttacker] = 0; gMoveSelectionCursor[gBattlerAttacker] = 0; - PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBattlerAttacker, *(gBattleStruct->battlerPartyIndexes + gBattlerAttacker)) + PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBattlerAttacker, gBattleStruct->battlerPartyIndexes[gBattlerAttacker]); gBattleScripting.battler = gBattlerAttacker; gBattlescriptCurrInstr = BattleScript_ActionSwitch; @@ -788,7 +788,7 @@ void HandleAction_ActionFinished(void) { u32 i, j, moveType; bool32 afterYouActive = gSpecialStatuses[gBattlerByTurnOrder[gCurrentTurnActionNumber + 1]].afterYou; - *(gBattleStruct->monToSwitchIntoId + gBattlerByTurnOrder[gCurrentTurnActionNumber]) = gSelectedMonPartyId = PARTY_SIZE; + gBattleStruct->monToSwitchIntoId[gBattlerByTurnOrder[gCurrentTurnActionNumber]] = gSelectedMonPartyId = PARTY_SIZE; gCurrentTurnActionNumber++; gCurrentActionFuncId = gActionsByTurnOrder[gCurrentTurnActionNumber]; SpecialStatusesClear(); @@ -3901,7 +3901,7 @@ bool32 HasNoMonsToSwitch(u32 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2 { if (IsValidForBattle(&party[i]) && i != partyIdBattlerOn1 && i != partyIdBattlerOn2 - && i != *(gBattleStruct->monToSwitchIntoId + flankId) && i != playerId[gBattleStruct->monToSwitchIntoId]) + && i != gBattleStruct->monToSwitchIntoId[flankId] && i != playerId[gBattleStruct->monToSwitchIntoId]) break; } return (i == PARTY_SIZE); @@ -3923,7 +3923,7 @@ bool32 HasNoMonsToSwitch(u32 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2 { if (IsValidForBattle(&party[i]) && i != partyIdBattlerOn1 && i != partyIdBattlerOn2 - && i != *(gBattleStruct->monToSwitchIntoId + flankId) && i != playerId[gBattleStruct->monToSwitchIntoId]) + && i != gBattleStruct->monToSwitchIntoId[flankId] && i != playerId[gBattleStruct->monToSwitchIntoId]) break; } return (i == PARTY_SIZE); @@ -4012,7 +4012,7 @@ bool32 HasNoMonsToSwitch(u32 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2 { if (IsValidForBattle(&party[i]) && i != partyIdBattlerOn1 && i != partyIdBattlerOn2 - && i != *(gBattleStruct->monToSwitchIntoId + flankId) && i != playerId[gBattleStruct->monToSwitchIntoId]) + && i != gBattleStruct->monToSwitchIntoId[flankId] && i != playerId[gBattleStruct->monToSwitchIntoId]) break; } return (i == PARTY_SIZE); @@ -6298,7 +6298,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32 { // Set bit and save Dancer mon's original target gSpecialStatuses[battler].dancerUsedMove = TRUE; - gSpecialStatuses[battler].dancerOriginalTarget = *(gBattleStruct->moveTarget + battler) | 0x4; + gSpecialStatuses[battler].dancerOriginalTarget = gBattleStruct->moveTarget[battler] | 0x4; gBattleStruct->atkCancellerTracker = 0; gBattlerAttacker = gBattlerAbility = battler; gCalledMove = gCurrentMove; @@ -8611,7 +8611,7 @@ u32 GetBattleMoveTarget(u16 move, u8 setTarget) break; } - *(gBattleStruct->moveTarget + gBattlerAttacker) = targetBattler; + gBattleStruct->moveTarget[gBattlerAttacker] = targetBattler; return targetBattler; } diff --git a/src/recorded_battle.c b/src/recorded_battle.c index 5e1ff63bbe1c..6a1587930d73 100644 --- a/src/recorded_battle.c +++ b/src/recorded_battle.c @@ -778,7 +778,7 @@ void RecordedBattle_CheckMovesetChanges(u8 mode) SetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_PP_BONUSES, &ppBonusSet); } - gChosenMoveByBattler[battlerId] = gBattleMons[battlerId].moves[*(gBattleStruct->chosenMovePositions + battlerId)]; + gChosenMoveByBattler[battlerId] = gBattleMons[battlerId].moves[gBattleStruct->chosenMovePositions[battlerId]]; } } }