diff options
author | luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> | 2020-12-16 14:51:21 -0500 |
---|---|---|
committer | luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> | 2020-12-16 14:51:21 -0500 |
commit | 34fc9789c9d11464161aabf022eb270597c6778a (patch) | |
tree | d7f97e29db99b3983d2d50678dcc250da179d32d /src/battle_ai_script_commands.c | |
parent | cc5db41f30708c1cc2d33a46879c96a9404764a3 (diff) | |
parent | 49bdaeb940afc98e3f98b24c9a5afe1bb8d5d86b (diff) |
Merge branch 'master' of https://github.com/pret/pokeemerald into rebase-install-md
Diffstat (limited to 'src/battle_ai_script_commands.c')
-rw-r--r-- | src/battle_ai_script_commands.c | 19 |
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 } } |