From efa4fe89adeadaaf43eb1ba59b0b1ac9999c8e16 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 6 Jan 2021 10:47:07 -0700 Subject: [PATCH] micle berry --- data/battle_scripts_1.s | 25 ++++++++++++++++++++++++ include/battle.h | 2 +- include/battle_scripts.h | 2 ++ include/constants/battle_string_ids.h | 3 ++- src/battle_message.c | 4 +++- src/battle_script_commands.c | 9 +++++++++ src/battle_util.c | 28 +++++++++++++++++++++++++++ 7 files changed, 70 insertions(+), 3 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 28da6de0e1..c7f3cc663a 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7729,3 +7729,28 @@ BattleScript_CustapBerryActivation:: waitmessage 0x40 removeitem BS_ATTACKER end2 + +BattleScript_MicleBerryActivateEnd2:: + jumpifability BS_ATTACKER, ABILITY_RIPEN, BattleScript_MicleBerryActivateEnd2_Ripen + goto BattleScript_MicleBerryActivateEnd2_Anim +BattleScript_MicleBerryActivateEnd2_Ripen: + call BattleScript_AbilityPopUp +BattleScript_MicleBerryActivateEnd2_Anim: + playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL + printstring STRINGID_MICLEBERRYACTIVATES + waitmessage 0x40 + removeitem BS_ATTACKER + end2 + +BattleScript_MicleBerryActivateRet:: + jumpifability BS_SCRIPTING, ABILITY_RIPEN, BattleScript_MicleBerryActivateRet_Ripen + goto BattleScript_MicleBerryActivateRet_Anim +BattleScript_MicleBerryActivateRet_Ripen: + call BattleScript_AbilityPopUp +BattleScript_MicleBerryActivateRet_Anim: + playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, NULL + printstring STRINGID_MICLEBERRYACTIVATES + waitmessage 0x40 + removeitem BS_SCRIPTING + return + diff --git a/include/battle.h b/include/battle.h index a7e8f5212b..a108bac8ef 100644 --- a/include/battle.h +++ b/include/battle.h @@ -429,7 +429,7 @@ struct Illusion struct PinchBerry { - u8 micleBerry:1; + u8 micle:1; u8 custap:1; // also quick claw }; diff --git a/include/battle_scripts.h b/include/battle_scripts.h index a5548791a2..aec8dbc6e0 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -352,5 +352,7 @@ extern const u8 BattleScript_CheekPouchActivates[]; extern const u8 BattleScript_AnnounceAirLockCloudNine[]; extern const u8 BattleScript_QuickClawActivation[]; extern const u8 BattleScript_CustapBerryActivation[]; +extern const u8 BattleScript_MicleBerryActivateEnd2[]; +extern const u8 BattleScript_MicleBerryActivateRet[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index bcb3e86786..321411cab2 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -559,8 +559,9 @@ #define STRINGID_COMATOSEENTERS 555 #define STRINGID_SCREENCLEANERENTERS 556 #define STRINGID_CANACTFASTERTHANKSTO 557 +#define STRINGID_MICLEBERRYACTIVATES 558 -#define BATTLESTRINGS_COUNT 558 +#define BATTLESTRINGS_COUNT 559 //// multichoice message IDs // switch in ability message diff --git a/src/battle_message.c b/src/battle_message.c index bf52cba31a..078175bd24 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -685,10 +685,12 @@ static const u8 sText_FairyAuraActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} static const u8 sText_AuraBreakActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} reversed all\nother POKéMON's auras!"); static const u8 sText_ComatoseActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} is drowsing!"); static const u8 sText_ScreenCleanerActivates[] = _("All screens on the field were\ncleansed!"); -static const u8 sText_CanActFaster[] = _("{B_ATK_NAME_WITH_PREFIX} can act\nfaster, thanks to {B_LAST_ITEM}!"); +static const u8 sText_CanActFaster[] = _("{B_ATK_NAME_WITH_PREFIX} can act faster,\nthanks to {B_LAST_ITEM}!"); +static const u8 sText_MicleBerryActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} boosted the accuracy of its\nnext move using {B_LAST_ITEM}!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_MICLEBERRYACTIVATES - 12] = sText_MicleBerryActivates, [STRINGID_CANACTFASTERTHANKSTO - 12] = sText_CanActFaster, [STRINGID_STATWASNOTLOWERED - 12] = sText_StatWasNotLowered, [STRINGID_CLOAKEDINAFREEZINGLIGHT - 12] = sText_CloakedInAFreezingLight, diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index bc427698ef..48fe60aa53 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1563,6 +1563,15 @@ u32 GetTotalAccuracy(u32 battlerAtk, u32 battlerDef, u32 move) calc = (calc * (100 + atkParam)) / 100; else if (atkHoldEffect == HOLD_EFFECT_ZOOM_LENS && GetBattlerTurnOrderNum(battlerAtk) > GetBattlerTurnOrderNum(battlerDef)); calc = (calc * (100 + atkParam)) / 100; + + if (gBattleStruct->pinchBerry[battlerAtk].micle) + { + gBattleStruct->pinchBerry[battlerAtk].micle = FALSE; + if (atkAbility == ABILITY_RIPEN) + calc = (calc * 140) / 100; // ripen gives 40% acc boost + else + calc = (calc * 120) / 100; // 20% acc boost + } return calc; } diff --git a/src/battle_util.c b/src/battle_util.c index 586454efbe..54df2df63b 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5073,6 +5073,26 @@ static u8 RandomStatRaiseBerry(u32 battlerId, u32 itemId) return 0; } +static u8 TrySetMicleBerry(u32 battlerId, u32 itemId, bool32 end2) +{ + if (HasEnoughHpToEatBerry(battlerId, 4, itemId)) + { + gBattleStruct->pinchBerry[battlerId].micle = TRUE; // battler's next attack has increased accuracy + + if (end2) + { + BattleScriptExecute(BattleScript_MicleBerryActivateEnd2); + } + else + { + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_MicleBerryActivateRet; + } + return ITEM_EFFECT_OTHER; + } + return 0; +} + static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal) { if (HasEnoughHpToEatBerry(battlerId, 2, itemId)) @@ -5569,6 +5589,10 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) effect = ITEM_EFFECT_OTHER; } break; + case HOLD_EFFECT_MICLE_BERRY: + if (!moveTurn) + effect = TrySetMicleBerry(battlerId, gLastUsedItem, TRUE); + break; } if (effect) @@ -5595,6 +5619,10 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) battlerHoldEffect = GetBattlerHoldEffect(battlerId, TRUE); switch (battlerHoldEffect) { + case HOLD_EFFECT_MICLE_BERRY: + if (B_HP_BERRIES >= GEN_4) + effect = TrySetMicleBerry(battlerId, gLastUsedItem, FALSE); + break; case HOLD_EFFECT_RESTORE_HP: if (B_HP_BERRIES >= GEN_4) effect = ItemHealHp(battlerId, gLastUsedItem, FALSE, FALSE);