From f046a25ce036e7af01efafdb22dade424ca7bd7b Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 5 Jan 2021 21:15:21 -0700 Subject: [PATCH] ripen & hp restoring berries --- data/battle_scripts_1.s | 10 ++++++++++ src/battle_util.c | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 3eb1f5cbe6..f892e26117 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7461,6 +7461,11 @@ BattleScript_WhiteHerbRet:: return BattleScript_ItemHealHP_RemoveItemRet:: + jumpifability BS_SCRIPTING, ABILITY_RIPEN, BattleScript_ItemHealHP_RemoveItemRet_AbilityPopUp + goto BattleScript_ItemHealHP_RemoveItemRet_Anim +BattleScript_ItemHealHP_RemoveItemRet_AbilityPopUp: + call BattleScript_AbilityPopUp +BattleScript_ItemHealHP_RemoveItemRet_Anim: playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, NULL printstring STRINGID_PKMNSITEMRESTOREDHEALTH waitmessage 0x40 @@ -7470,6 +7475,11 @@ BattleScript_ItemHealHP_RemoveItemRet:: removeitem BS_SCRIPTING return BattleScript_ItemHealHP_RemoveItemEnd2:: + jumpifability BS_ATTACKER, ABILITY_RIPEN BattleScript_ItemHealHP_RemoveItemEnd2_AbilityPopUp + goto BattleScript_ItemHealHP_RemoveItemEnd2_Anim +BattleScript_ItemHealHP_RemoveItemEnd2_AbilityPopUp: + call BattleScript_AbilityPopUp +BattleScript_ItemHealHP_RemoveItemEnd2_Anim: playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL printstring STRINGID_PKMNSITEMRESTOREDHEALTH waitmessage 0x40 diff --git a/src/battle_util.c b/src/battle_util.c index aeeefa7347..aff3a1c53b 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4980,7 +4980,7 @@ enum static bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId) { bool32 isBerry = (ItemId_GetPocket(itemId) == POCKET_BERRIES); - + if (gBattleMons[battlerId].hp == 0) return FALSE; // Unnerve prevents consumption of opponents' berries. @@ -5073,6 +5073,7 @@ static u8 RandomStatRaiseBerry(u32 battlerId, u32 itemId) return 0; } +// berries, berry juice static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal) { if (HasEnoughHpToEatBerry(battlerId, 2, itemId)) @@ -5081,7 +5082,12 @@ static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal) gBattleMoveDamage = (gBattleMons[battlerId].maxHP * GetBattlerHoldEffectParam(battlerId) / 100) * -1; else gBattleMoveDamage = GetBattlerHoldEffectParam(battlerId) * -1; - + + // check ripen + if (ItemId_GetPocket(itemId) == POCKET_BERRIES && GetBattlerAbility(battlerId) == ABILITY_RIPEN) + gBattleMoveDamage *= 2; + + gBattlerAbility = battlerId; // in SWSH, berry juice shows ability pop up but has no effect. This is mimicked here if (end2) { BattleScriptExecute(BattleScript_ItemHealHP_RemoveItemEnd2);