diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index b2e6f6012..152edce38 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6606,15 +6606,26 @@ BattleScript_ReceiverActivates:: waitmessage 0x40 settracedability BS_ABILITY_BATTLER return - -BattleScript_RainDishActivates:: + +BattleScript_AbilityHpHeal: call BattleScript_AbilityPopUp printstring STRINGID_PKMNSXRESTOREDHPALITTLE2 waitmessage 0x40 orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER + return + +BattleScript_RainDishActivates:: + call BattleScript_AbilityHpHeal end3 + +BattleScript_CheekPouchActivates:: + copybyte sSAVED_BATTLER, gBattlerAttacker + copybyte gBattlerAttacker, gBattlerAbility + call BattleScript_AbilityHpHeal + copybyte gBattlerAttacker, sSAVED_BATTLER + return BattleScript_HarvestActivates:: pause 0x5 diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 4ad35f108..bcbf68cb4 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -347,5 +347,6 @@ extern const u8 BattleScript_EmergencyExit[]; extern const u8 BattleScript_EmergencyExitNoPopUp[]; extern const u8 BattleScript_EmergencyExitWild[]; extern const u8 BattleScript_EmergencyExitWildNoPopUp[]; +extern const u8 BattleScript_CheekPouchActivates[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 54412d8df..055ba2f2f 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6247,21 +6247,42 @@ static void Cmd_setgravity(void) } else { - u32 i; - gFieldStatuses |= STATUS_FIELD_GRAVITY; gFieldTimers.gravityTimer = 5; gBattlescriptCurrInstr += 5; } } +static bool32 TryCheekPouch(u32 battlerId, u32 itemId) +{ + if (ItemId_GetPocket(itemId) == POCKET_BERRIES + && GetBattlerAbility(battlerId) == ABILITY_CHEEK_POUCH + && !(gStatuses3[battlerId] & STATUS3_HEAL_BLOCK) + && gBattleStruct->ateBerry[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]] + && !BATTLER_MAX_HP(battlerId)) + { + gBattleMoveDamage = gBattleMons[battlerId].maxHP / 3; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + gBattleMoveDamage *= -1; + gBattlerAbility = battlerId; + BattleScriptPush(gBattlescriptCurrInstr + 2); + gBattlescriptCurrInstr = BattleScript_CheekPouchActivates; + return TRUE; + } + return FALSE; +} + static void Cmd_removeitem(void) { + u16 itemId = 0; + gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); + itemId = gBattleMons[gActiveBattler].item; // Popped Air Balloon cannot be restored by no means. if (GetBattlerHoldEffect(gActiveBattler, TRUE) != HOLD_EFFECT_AIR_BALLOON) - gBattleStruct->usedHeldItems[gActiveBattler] = gBattleMons[gActiveBattler].item; + gBattleStruct->usedHeldItems[gActiveBattler] = itemId; gBattleMons[gActiveBattler].item = 0; CheckSetUnburden(gActiveBattler); @@ -6270,8 +6291,8 @@ static void Cmd_removeitem(void) MarkBattlerForControllerExec(gActiveBattler); ClearBattlerItemEffectHistory(gActiveBattler); - - gBattlescriptCurrInstr += 2; + if (!TryCheekPouch(gActiveBattler, itemId)) + gBattlescriptCurrInstr += 2; } static void Cmd_atknameinbuff1(void) diff --git a/src/battle_util.c b/src/battle_util.c index 86ba3b52a..8bc8863ee 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4322,7 +4322,7 @@ static u8 RandomStatRaiseBerry(u32 battlerId, u32 itemId) static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal) { - if (HasEnoughHpToEatBerry(battlerId, 2, gLastUsedItem)) + if (HasEnoughHpToEatBerry(battlerId, 2, itemId)) { if (percentHeal) gBattleMoveDamage = (gBattleMons[battlerId].maxHP * GetBattlerHoldEffectParam(battlerId) / 100) * -1;