From 40ac21476433c9d8ca37df10d70f6c8ae81ddfd6 Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Thu, 7 Sep 2023 17:10:25 -0500 Subject: [PATCH] Fix enigma berry --- src/battle_util.c | 23 +++++++++++++++-------- src/data/items.h | 1 - 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 87f93389d..94437dca2 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6802,6 +6802,21 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect) case HOLD_EFFECT_SP_DEFENSE_UP: effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPDEF, FALSE); break; + case HOLD_EFFECT_ENIGMA_BERRY: // consume and heal if hit by super effective move + if (IsBattlerAlive(battlerId) + && TARGET_TURN_DAMAGED + && (gBattleScripting.overrideBerryRequirements + || (!DoesSubstituteBlockMove(gBattlerAttacker, battlerId, gCurrentMove) && (gMoveResultFlags & MOVE_RESULT_SUPER_EFFECTIVE)))) + { + gBattleMoveDamage = (gBattleMons[battlerId].maxHP * 25 / 100) * -1; + if (GetBattlerAbility(battlerId) == ABILITY_RIPEN) + gBattleMoveDamage *= 2; + + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_ItemHealHP_RemoveItemRet; + return ITEM_HP_CHANGE; + } + break; case HOLD_EFFECT_KEE_BERRY: // consume and boost defense if used physical move effect = DamagedStatBoostBerryEffect(battlerId, STAT_DEF, SPLIT_PHYSICAL); break; @@ -7761,14 +7776,6 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) gBattleScripting.statChanger = SET_STATCHANGER(STAT_SPATK, 1, FALSE); } break; - case HOLD_EFFECT_ENIGMA_BERRY: // consume and heal if hit by super effective move - if (IsBattlerAlive(battlerId) - && TARGET_TURN_DAMAGED - && gMoveResultFlags & MOVE_RESULT_SUPER_EFFECTIVE) - { - effect = ItemHealHp(battlerId, gLastUsedItem, TRUE, TRUE); - } - break; case HOLD_EFFECT_JABOCA_BERRY: // consume and damage attacker if used physical move if (IsBattlerAlive(battlerId) && TARGET_TURN_DAMAGED diff --git a/src/data/items.h b/src/data/items.h index 98940277b..5e15b2734 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -7630,7 +7630,6 @@ const struct Item gItems[] = .itemId = ITEM_ENIGMA_BERRY, .price = 20, .holdEffect = HOLD_EFFECT_ENIGMA_BERRY, - .holdEffectParam = 25, .description = sEnigmaBerryDesc, .pocket = POCKET_BERRIES, .type = ITEM_USE_BAG_MENU,