summaryrefslogtreecommitdiff
path: root/src/battle_ai_script_commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/battle_ai_script_commands.c')
-rw-r--r--src/battle_ai_script_commands.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c
index 4185f8017..b7679429c 100644
--- a/src/battle_ai_script_commands.c
+++ b/src/battle_ai_script_commands.c
@@ -450,7 +450,16 @@ static u8 ChooseMoveOrAction_Doubles(void)
{
s32 i;
s32 j;
+#ifndef BUGFIX
s32 scriptsToRun;
+#else
+ // the value assigned to this is a u32 (aiFlags)
+ // this becomes relevant because aiFlags can have bit 31 set
+ // and scriptsToRun is shifted
+ // this never happens in the vanilla game because bit 31 is
+ // only set when it's the first battle
+ u32 scriptsToRun;
+#endif
s16 bestMovePointsForTarget[MAX_BATTLERS_COUNT];
s8 mostViableTargetsArray[MAX_BATTLERS_COUNT];
u8 actionOrMoveIndex[MAX_BATTLERS_COUNT];
@@ -615,8 +624,8 @@ static void RecordLastUsedMoveByTarget(void)
{
if (BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] == gLastMoves[gBattlerTarget])
break;
- if (BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] != gLastMoves[gBattlerTarget] // HACK: This redundant condition is a hack to make the asm match.
- && BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] == MOVE_NONE)
+
+ if (BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] == MOVE_NONE)
{
BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] = gLastMoves[gBattlerTarget];
break;
@@ -1604,8 +1613,10 @@ static void Cmd_if_status_not_in_party(void)
if (species != SPECIES_NONE && species != SPECIES_EGG && hp != 0 && status == statusToCompareTo)
{
- gAIScriptPtr += 10; // UB: Still bugged in Emerald. Uncomment the return statement to fix.
- // return;
+ gAIScriptPtr += 10;
+ #ifdef UBFIX
+ return;
+ #endif
}
}