From f6abfb424c677e289ee962b3e89760314d42908b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 30 Jun 2021 13:07:10 -0400 Subject: Expand battle struct macros inline, 2 --- src/battle_controller_opponent.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/battle_controller_opponent.c') diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index ae2082ec0..f45e80198 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -1800,8 +1800,10 @@ void OpponentHandlecmd20(void) void OpponentHandleOpenBag(void) { - // What is this? - BtlController_EmitOneReturnValue(1, ewram160D4(gActiveBattler)); + // The AI will only ever use an item whose ID fits in 8 bits. + // If you want the AI to use an item with a higher ID, uncomment the code + // in the line below. + BtlController_EmitOneReturnValue(1, gSharedMem[BSTRUCT_OFF(AI_usedItemId) + (gActiveBattler / 2) * 2]/* | (gSharedMem[BSTRUCT_OFF(AI_usedItemId) + (gActiveBattler / 2) * 2 + 1] */); OpponentBufferExecCompleted(); } @@ -1809,7 +1811,7 @@ void OpponentHandlecmd22(void) { s32 r4; - if (ewram160C8arr(GetBattlerPosition(gActiveBattler)) == 6) + if (gSharedMem[BSTRUCT_OFF(AI_monToSwitchIntoId) + (GetBattlerPosition(gActiveBattler) / 2)] == PARTY_SIZE) { u8 r6; u8 r5; @@ -1838,10 +1840,10 @@ void OpponentHandlecmd22(void) } else { - r4 = ewram160C8arr(GetBattlerPosition(gActiveBattler)); - ewram160C8arr(GetBattlerPosition(gActiveBattler)) = 6; + r4 = gSharedMem[BSTRUCT_OFF(AI_monToSwitchIntoId) + (GetBattlerPosition(gActiveBattler) / 2)]; + gSharedMem[BSTRUCT_OFF(AI_monToSwitchIntoId) + (GetBattlerPosition(gActiveBattler) / 2)] = PARTY_SIZE; } - ewram16068arr(gActiveBattler) = r4; + gSharedMem[BSTRUCT_OFF(monToSwitchIntoId) + gActiveBattler] = r4; BtlController_EmitChosenMonReturnValue(1, r4, 0); OpponentBufferExecCompleted(); } -- cgit v1.2.3