From b4db3b6a813ea84bba39d748f3192514a7433a8d Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Thu, 7 Sep 2023 15:32:26 -0500 Subject: [PATCH 1/3] Add enigma berry effect --- src/battle_util.c | 9 +++++++++ src/data/items.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/battle_util.c b/src/battle_util.c index 1ff0a762e..cd73d4577 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7761,6 +7761,15 @@ 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 5e15b2734..98940277b 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -7630,6 +7630,7 @@ 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, From 8f8705929ac9dd94ed4d2a364a4b23a3745ab1be Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Thu, 7 Sep 2023 15:37:58 -0500 Subject: [PATCH 2/3] Update battle_util.c --- src/battle_util.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/battle_util.c b/src/battle_util.c index cd73d4577..87f93389d 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7769,7 +7769,6 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) 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 From 40ac21476433c9d8ca37df10d70f6c8ae81ddfd6 Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Thu, 7 Sep 2023 17:10:25 -0500 Subject: [PATCH 3/3] 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,