From bdbdd0564fe9e3aaf3d15139e6260d371c939923 Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Fri, 12 Nov 2021 21:05:42 +1300 Subject: [PATCH] Fix Knock Off, add config Added a config for Knock Off's damage boost. Also fixed the conditions it checks to do bonus damage. --- include/constants/battle_config.h | 1 + src/battle_util.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index aaf02a37f1..62bd7e447f 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -114,6 +114,7 @@ #define B_PAYBACK_SWITCH_BOOST GEN_7 // In Gen5+, if the opponent switches out, Payback's damage will no longer be doubled. #define B_HIDDEN_POWER_DMG GEN_7 // In Gen6+, Hidden Power's base power was set to always be 60. Before, it was determined by the mon's IVs. #define B_ROUGH_SKIN_DMG GEN_7 // In Gen4+, Rough Skin contact damage is 1/8th of max HP instead of 1/16th. This will also affect Iron Barbs. +#define B_KNOCK_OFF_DMG GEN_8 // In Gen6+, Knock Off deals 50% more damage when knocking off an item // Type settings #define B_GHOSTS_ESCAPE GEN_7 // In Gen6+, abilities like Shadow Tag or moves like Mean Look fail on Ghost-type Pokémon. They can also escape any Wild Battle. diff --git a/src/battle_util.c b/src/battle_util.c index 4b3fc11aa9..7f01891bdd 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8191,8 +8191,11 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe MulModifier(&modifier, UQ_4_12(0.5)); break; case EFFECT_KNOCK_OFF: - if (gBattleMons[battlerDef].item != ITEM_NONE && GetBattlerAbility(battlerDef) != ABILITY_STICKY_HOLD) + #if B_KNOCK_OFF_DMG >= GEN_6 + if (gBattleMons[battlerDef].item != ITEM_NONE + && CanBattlerGetOrLoseItem(battlerDef, gBattleMons[battlerDef].item)) MulModifier(&modifier, UQ_4_12(1.5)); + #endif break; }