From 3a25bce185635b9887de6eb91a9803b8e9dbb1aa Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 15 Oct 2021 06:00:24 -0300 Subject: [PATCH] Turned Retaliate's effect into a side status --- include/battle.h | 2 -- include/constants/battle.h | 1 + src/battle_main.c | 5 ----- src/battle_script_commands.c | 4 ++-- src/battle_util.c | 8 +++----- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/include/battle.h b/include/battle.h index 7958c40f5..826a0929e 100644 --- a/include/battle.h +++ b/include/battle.h @@ -908,7 +908,5 @@ extern u8 gBattleControllerData[MAX_BATTLERS_COUNT]; extern bool8 gHasFetchedBall; extern u8 gLastUsedBall; extern u16 gLastThrownBall; -extern bool8 gCanPlayerRetaliate; -extern bool8 gCanOpponentRetaliate; #endif // GUARD_BATTLE_H diff --git a/include/constants/battle.h b/include/constants/battle.h index a59ea2f1a..39994a049 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -220,6 +220,7 @@ #define SIDE_STATUS_WIDE_GUARD (1 << 19) #define SIDE_STATUS_CRAFTY_SHIELD (1 << 20) #define SIDE_STATUS_MAT_BLOCK (1 << 21) +#define SIDE_STATUS_RETALIATE (1 << 22) #define SIDE_STATUS_HAZARDS_ANY (SIDE_STATUS_SPIKES | SIDE_STATUS_STICKY_WEB | SIDE_STATUS_TOXIC_SPIKES | SIDE_STATUS_STEALTH_ROCK) #define SIDE_STATUS_SCREEN_ANY (SIDE_STATUS_REFLECT | SIDE_STATUS_LIGHTSCREEN | SIDE_STATUS_AURORA_VEIL) diff --git a/src/battle_main.c b/src/battle_main.c index ffb33da10..055ec9bbe 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -231,8 +231,6 @@ EWRAM_DATA struct TotemBoost gTotemBoosts[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA bool8 gHasFetchedBall = FALSE; EWRAM_DATA u8 gLastUsedBall = 0; EWRAM_DATA u16 gLastThrownBall = 0; -EWRAM_DATA bool8 gCanPlayerRetaliate = FALSE; -EWRAM_DATA bool8 gCanOpponentRetaliate = FALSE; // IWRAM common vars void (*gPreBattleCallback1)(void); @@ -2878,9 +2876,6 @@ static void BattleStartClearSetData(void) gHasFetchedBall = FALSE; gLastUsedBall = 0; - gCanPlayerRetaliate = FALSE; - gCanOpponentRetaliate = FALSE; - gBattlerAttacker = 0; gBattlerTarget = 0; gBattleWeather = 0; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 132a434cb..b301047aa 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3499,14 +3499,14 @@ static void Cmd_tryfaintmon(void) if (gBattleResults.playerFaintCounter < 0xFF) gBattleResults.playerFaintCounter++; AdjustFriendshipOnBattleFaint(gActiveBattler); - gCanPlayerRetaliate = TRUE; + gSideStatuses[0] |= SIDE_STATUS_RETALIATE; } else { if (gBattleResults.opponentFaintCounter < 0xFF) gBattleResults.opponentFaintCounter++; gBattleResults.lastOpponentSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES, NULL); - gCanOpponentRetaliate = TRUE; + gSideStatuses[1] |= SIDE_STATUS_RETALIATE; } if ((gHitMarker & HITMARKER_DESTINYBOND) && gBattleMons[gBattlerAttacker].hp != 0) { diff --git a/src/battle_util.c b/src/battle_util.c index 689a846d6..e3bec3508 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7681,6 +7681,7 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe u16 basePower = CalcMoveBasePower(move, battlerAtk, battlerDef); u16 holdEffectModifier; u16 modifier = UQ_4_12(1.0); + u32 atkSide = GET_BATTLER_SIDE(battlerAtk); // attacker's abilities switch (GetBattlerAbility(battlerAtk)) @@ -7933,13 +7934,10 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe MulModifier(&modifier, UQ_4_12(2.0)); break; case EFFECT_RETALIATE: - if (gCanPlayerRetaliate || gCanOpponentRetaliate) + if (gSideStatuses[atkSide] & SIDE_STATUS_RETALIATE) { MulModifier(&modifier, UQ_4_12(2.0)); - if (gCanPlayerRetaliate) - gCanPlayerRetaliate = FALSE; - else if (gCanOpponentRetaliate) - gCanOpponentRetaliate = FALSE; + gSideStatuses[atkSide] &= ~SIDE_STATUS_RETALIATE; } break; case EFFECT_SOLARBEAM: