From 6c550cd7490183b25caa294109da057de7824a8f Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 11 Oct 2021 03:16:59 -0300 Subject: [PATCH] Implemented Retaliate's effect --- include/battle.h | 1 + src/battle_main.c | 3 +++ src/battle_script_commands.c | 1 + src/battle_util.c | 6 +++++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/battle.h b/include/battle.h index 826a0929ec..aaecb9ea11 100644 --- a/include/battle.h +++ b/include/battle.h @@ -908,5 +908,6 @@ extern u8 gBattleControllerData[MAX_BATTLERS_COUNT]; extern bool8 gHasFetchedBall; extern u8 gLastUsedBall; extern u16 gLastThrownBall; +extern bool8 gCanRetaliate; #endif // GUARD_BATTLE_H diff --git a/src/battle_main.c b/src/battle_main.c index 055ec9bbe8..7d4ae76dda 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -231,6 +231,7 @@ 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 gCanRetaliate = FALSE; // IWRAM common vars void (*gPreBattleCallback1)(void); @@ -2876,6 +2877,8 @@ static void BattleStartClearSetData(void) gHasFetchedBall = FALSE; gLastUsedBall = 0; + gCanRetaliate = FALSE; + gBattlerAttacker = 0; gBattlerTarget = 0; gBattleWeather = 0; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2c017b2df5..b3ac598635 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3499,6 +3499,7 @@ static void Cmd_tryfaintmon(void) if (gBattleResults.playerFaintCounter < 0xFF) gBattleResults.playerFaintCounter++; AdjustFriendshipOnBattleFaint(gActiveBattler); + gCanRetaliate = TRUE; } else { diff --git a/src/battle_util.c b/src/battle_util.c index 0bca1c0e7c..d588d5b08f 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7933,7 +7933,11 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe MulModifier(&modifier, UQ_4_12(2.0)); break; case EFFECT_RETALIATE: - // todo + if (gCanRetaliate) + { + MulModifier(&modifier, UQ_4_12(2.0)); + gCanRetaliate = FALSE; + } break; case EFFECT_SOLARBEAM: if (WEATHER_HAS_EFFECT && gBattleWeather & (WEATHER_HAIL_ANY | WEATHER_SANDSTORM_ANY | WEATHER_RAIN_ANY))