diff --git a/include/battle_ai_util.h b/include/battle_ai_util.h index 0041f684b9..6c1434ed74 100644 --- a/include/battle_ai_util.h +++ b/include/battle_ai_util.h @@ -4,11 +4,6 @@ #include "battle_ai_main.h" #include "battle_ai_field_statuses.h" -// Left and right are determined by how they're referred to in tests and everywhere else. -// Left is battlers 0 and 1, right 2 and 3; if you assume the battler referencing them is south, left is to the northeast and right to the northwest. -#define LEFT_FOE(battler) ((BATTLE_OPPOSITE(battler)) & BIT_SIDE) -#define RIGHT_FOE(battler) (((BATTLE_OPPOSITE(battler)) & BIT_SIDE) | BIT_FLANK) - // Roll boundaries used by AI when scoring. Doesn't affect actual damage dealt. #define MAX_ROLL_PERCENTAGE DMG_ROLL_PERCENT_HI #define MIN_ROLL_PERCENTAGE DMG_ROLL_PERCENT_LO diff --git a/include/constants/battle.h b/include/constants/battle.h index 19ee13e478..33268e222a 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -45,6 +45,11 @@ enum BattlerId #define BATTLE_OPPOSITE(id) ((id) ^ BIT_SIDE) #define BATTLE_PARTNER(id) ((id) ^ BIT_FLANK) +// Left and right are determined by how they're referred to in tests and everywhere else. +// Left is battlers 0 and 1, right 2 and 3; if you assume the battler referencing them is south, left is to the northeast and right to the northwest. +#define LEFT_FOE(battler) ((BATTLE_OPPOSITE(battler)) & BIT_SIDE) +#define RIGHT_FOE(battler) (((BATTLE_OPPOSITE(battler)) & BIT_SIDE) | BIT_FLANK) + enum BattleSide { B_SIDE_PLAYER = 0, @@ -273,15 +278,14 @@ enum SemiInvulnerableExclusion #define SIDE_STATUS_REFLECT (1 << 0) #define SIDE_STATUS_LIGHTSCREEN (1 << 1) #define SIDE_STATUS_SAFEGUARD (1 << 2) -#define SIDE_STATUS_FUTUREATTACK (1 << 3) -#define SIDE_STATUS_MIST (1 << 4) -#define SIDE_STATUS_TAILWIND (1 << 5) -#define SIDE_STATUS_AURORA_VEIL (1 << 6) -#define SIDE_STATUS_LUCKY_CHANT (1 << 7) -#define SIDE_STATUS_DAMAGE_NON_TYPES (1 << 8) -#define SIDE_STATUS_RAINBOW (1 << 9) -#define SIDE_STATUS_SEA_OF_FIRE (1 << 10) -#define SIDE_STATUS_SWAMP (1 << 11) +#define SIDE_STATUS_MIST (1 << 3) +#define SIDE_STATUS_TAILWIND (1 << 4) +#define SIDE_STATUS_AURORA_VEIL (1 << 5) +#define SIDE_STATUS_LUCKY_CHANT (1 << 6) +#define SIDE_STATUS_DAMAGE_NON_TYPES (1 << 7) +#define SIDE_STATUS_RAINBOW (1 << 8) +#define SIDE_STATUS_SEA_OF_FIRE (1 << 9) +#define SIDE_STATUS_SWAMP (1 << 10) #define SIDE_STATUS_SCREEN_ANY (SIDE_STATUS_REFLECT | SIDE_STATUS_LIGHTSCREEN | SIDE_STATUS_AURORA_VEIL) #define SIDE_STATUS_PLEDGE_ANY (SIDE_STATUS_RAINBOW | SIDE_STATUS_SEA_OF_FIRE | SIDE_STATUS_SWAMP) diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 19e6e079d4..2327d80c16 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -1993,8 +1993,8 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score) ADJUST_SCORE(-10); break; case EFFECT_FUTURE_SIGHT: - if (gSideStatuses[GetBattlerSide(battlerDef)] & SIDE_STATUS_FUTUREATTACK - || gSideStatuses[GetBattlerSide(battlerAtk)] & SIDE_STATUS_FUTUREATTACK) + if (gWishFutureKnock.futureSightCounter[LEFT_FOE(battlerAtk)] > gBattleTurnCounter + || gWishFutureKnock.futureSightCounter[RIGHT_FOE(battlerAtk)] > gBattleTurnCounter) ADJUST_SCORE(-12); else ADJUST_SCORE(GOOD_EFFECT); diff --git a/src/battle_anim_effects_1.c b/src/battle_anim_effects_1.c index 05b0b9ee30..fd9e195059 100644 --- a/src/battle_anim_effects_1.c +++ b/src/battle_anim_effects_1.c @@ -6831,10 +6831,10 @@ static void TrySwapStickyWebBattlerId(u32 battlerAtk, u32 battlerPartner) static void TrySwapWishBattlerIds(u32 battlerAtk, u32 battlerPartner) { u32 i, temp; - u32 oppSide = GetBattlerSide(BATTLE_OPPOSITE(battlerAtk)); // if used future sight on opposing side, properly track who used it - if (gSideStatuses[oppSide] & SIDE_STATUS_FUTUREATTACK) + if (gWishFutureKnock.futureSightCounter[LEFT_FOE(battlerAtk)] > gBattleTurnCounter + || gWishFutureKnock.futureSightCounter[RIGHT_FOE(battlerAtk)] > gBattleTurnCounter) { for (i = 0; i < gBattlersCount; i++) { diff --git a/src/battle_end_turn.c b/src/battle_end_turn.c index 817267936b..ff52a62832 100644 --- a/src/battle_end_turn.c +++ b/src/battle_end_turn.c @@ -248,12 +248,6 @@ static bool32 HandleEndTurnFutureSight(u32 battler) if (gWishFutureKnock.futureSightCounter[battler] == gBattleTurnCounter) { - if (gWishFutureKnock.futureSightCounter[battler] == gBattleTurnCounter - && gWishFutureKnock.futureSightCounter[BATTLE_PARTNER(battler)] <= gBattleTurnCounter) - { - gSideStatuses[GetBattlerSide(battler)] &= ~SIDE_STATUS_FUTUREATTACK; - } - if (!IsBattlerAlive(battler)) return effect; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b4bc2c2b65..1f2b6a43ff 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -12348,7 +12348,6 @@ static void Cmd_setfutureattack(void) { CMD_ARGS(); - gSideStatuses[GetBattlerSide(gBattlerTarget)] |= SIDE_STATUS_FUTUREATTACK; gWishFutureKnock.futureSightMove[gBattlerTarget] = gCurrentMove; gWishFutureKnock.futureSightBattlerIndex[gBattlerTarget] = gBattlerAttacker; gWishFutureKnock.futureSightPartyIndex[gBattlerTarget] = gBattlerPartyIndexes[gBattlerAttacker];