diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 3eb1f5cbe..28da6de0e 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7714,3 +7714,18 @@ BattleScript_AnnounceAirLockCloudNine:: waitmessage 0x40 call BattleScript_WeatherFormChanges end3 + +BattleScript_QuickClawActivation:: + playanimation BS_ATTACKER, B_ANIM_FOCUS_PUNCH_SETUP, NULL + waitanimation + printstring STRINGID_CANACTFASTERTHANKSTO + waitmessage 0x40 + end2 + +BattleScript_CustapBerryActivation:: + playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL + waitanimation + printstring STRINGID_CANACTFASTERTHANKSTO + waitmessage 0x40 + removeitem BS_ATTACKER + end2 diff --git a/include/battle.h b/include/battle.h index 488e0fc51..a7e8f5212 100644 --- a/include/battle.h +++ b/include/battle.h @@ -427,6 +427,13 @@ struct Illusion struct Pokemon *mon; }; +struct PinchBerry +{ + u8 micleBerry:1; + u8 custap:1; // also quick claw + +}; + struct BattleStruct { u8 turnEffectsTracker; @@ -542,6 +549,8 @@ struct BattleStruct u8 sameMoveTurns[MAX_BATTLERS_COUNT]; // For Metronome, number of times the same moves has been SUCCESFULLY used. u16 moveEffect2; // For Knock Off u16 changedSpecies[PARTY_SIZE]; // For Zygarde or future forms when multiple mons can change into the same pokemon. + struct PinchBerry pinchBerry[MAX_BATTLERS_COUNT]; + u8 quickClawBattlerId; }; #define GET_MOVE_TYPE(move, typeArg) \ diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 3566a1c4d..a5548791a 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -350,5 +350,7 @@ extern const u8 BattleScript_EmergencyExitWild[]; extern const u8 BattleScript_EmergencyExitWildNoPopUp[]; extern const u8 BattleScript_CheekPouchActivates[]; extern const u8 BattleScript_AnnounceAirLockCloudNine[]; +extern const u8 BattleScript_QuickClawActivation[]; +extern const u8 BattleScript_CustapBerryActivation[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/battle_util.h b/include/battle_util.h index f7699fced..06256aa77 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -130,5 +130,6 @@ void ClearIllusionMon(u32 battlerId); bool32 SetIllusionMon(struct Pokemon *mon, u32 battlerId); bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 battlerId); u8 GetBattleMoveSplit(u32 moveId); +bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId); #endif // GUARD_BATTLE_UTIL_H diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 9348d67d5..bcb3e8678 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -558,8 +558,9 @@ #define STRINGID_AURABREAKENTERS 554 #define STRINGID_COMATOSEENTERS 555 #define STRINGID_SCREENCLEANERENTERS 556 +#define STRINGID_CANACTFASTERTHANKSTO 557 -#define BATTLESTRINGS_COUNT 557 +#define BATTLESTRINGS_COUNT 558 //// multichoice message IDs // switch in ability message diff --git a/include/constants/hold_effects.h b/include/constants/hold_effects.h index 85017cb40..3de2e7b43 100644 --- a/include/constants/hold_effects.h +++ b/include/constants/hold_effects.h @@ -104,6 +104,9 @@ #define HOLD_EFFECT_RESIST_BERRY 98 #define HOLD_EFFECT_POWER_ITEM 99 #define HOLD_EFFECT_RESTORE_PCT_HP 100 +#define HOLD_EFFECT_MICLE_BERRY 101 +#define HOLD_EFFECT_JABOCA_BERRY 102 +#define HOLD_EFFECT_CUSTAP_BERRY 103 // Gen5 hold effects #define HOLD_EFFECT_FLOAT_STONE 115 diff --git a/src/battle_main.c b/src/battle_main.c index 48129c523..916bf20b1 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -107,6 +107,7 @@ static void sub_803CDF8(void); static bool8 AllAtActionConfirmed(void); static void CheckFocusPunch_ClearVarsBeforeTurnStarts(void); static void CheckMegaEvolutionBeforeTurn(void); +static void CheckQuickClaw_CustapBerryActivation(void); static void FreeResetData_ReturnToOvOrDoEvolutions(void); static void ReturnFromBattleToOverworld(void); static void TryEvolvePokemon(void); @@ -4324,20 +4325,23 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) u8 strikesFirst = 0; u32 speedBattler1 = 0, speedBattler2 = 0; u32 holdEffectBattler1 = 0, holdEffectBattler2 = 0; - bool32 quickClawBattler1 = FALSE, quickClawBattler2 = FALSE; s8 priority1 = 0, priority2 = 0; speedBattler1 = GetBattlerTotalSpeedStat(battler1); holdEffectBattler1 = GetBattlerHoldEffect(battler1, TRUE); - if (holdEffectBattler1 == HOLD_EFFECT_QUICK_CLAW - && gRandomTurnNumber < (0xFFFF * GetBattlerHoldEffectParam(battler1)) / 100) - quickClawBattler1 = TRUE; + if ((holdEffectBattler1 == HOLD_EFFECT_QUICK_CLAW && gRandomTurnNumber < (0xFFFF * GetBattlerHoldEffectParam(battler1)) / 100) + || (!IsAbilityOnOpposingSide(battler1, ABILITY_UNNERVE) + && holdEffectBattler1 == HOLD_EFFECT_CUSTAP_BERRY + && HasEnoughHpToEatBerry(battler1, 4, gBattleMons[battler1].item))) + gBattleStruct->pinchBerry[battler1].custap = TRUE; speedBattler2 = GetBattlerTotalSpeedStat(battler2); holdEffectBattler2 = GetBattlerHoldEffect(battler2, TRUE); - if (holdEffectBattler2 == HOLD_EFFECT_QUICK_CLAW - && gRandomTurnNumber < (0xFFFF * GetBattlerHoldEffectParam(battler2)) / 100) - quickClawBattler2 = TRUE; + if ((holdEffectBattler2 == HOLD_EFFECT_QUICK_CLAW && gRandomTurnNumber < (0xFFFF * GetBattlerHoldEffectParam(battler2)) / 100) + || (!IsAbilityOnOpposingSide(battler2, ABILITY_UNNERVE) + && holdEffectBattler2 == HOLD_EFFECT_CUSTAP_BERRY + && HasEnoughHpToEatBerry(battler2, 4, gBattleMons[battler2].item))) + gBattleStruct->pinchBerry[battler2].custap = TRUE; if (!ignoreChosenMoves) { @@ -4349,13 +4353,13 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) if (priority1 == priority2) { - // QUICK CLAW - always first + // QUICK CLAW / CUSTAP - always first // LAGGING TAIL - always last // STALL - always last - if (quickClawBattler1 && !quickClawBattler2) + if (gBattleStruct->pinchBerry[battler1].custap && !gBattleStruct->pinchBerry[battler2].custap) strikesFirst = 0; - else if (quickClawBattler2 && !quickClawBattler1) + else if (gBattleStruct->pinchBerry[battler2].custap && !gBattleStruct->pinchBerry[battler1].custap) strikesFirst = 1; else if (holdEffectBattler1 == HOLD_EFFECT_LAGGING_TAIL && holdEffectBattler2 != HOLD_EFFECT_LAGGING_TAIL) strikesFirst = 1; @@ -4592,6 +4596,43 @@ static void CheckFocusPunch_ClearVarsBeforeTurnStarts(void) } } + gBattleMainFunc = CheckQuickClaw_CustapBerryActivation; + gBattleStruct->quickClawBattlerId = 0; +} + +static void CheckQuickClaw_CustapBerryActivation(void) +{ + u32 i; + + if (!(gHitMarker & HITMARKER_RUN)) + { + while (gBattleStruct->quickClawBattlerId < gBattlersCount) + { + gActiveBattler = gBattlerAttacker = gBattleStruct->quickClawBattlerId; + gBattleStruct->quickClawBattlerId++; + if (gBattleStruct->pinchBerry[gActiveBattler].custap + && !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP) + && !(gDisableStructs[gBattlerAttacker].truantCounter) + && !(gProtectStructs[gActiveBattler].noValidMoves)) + { + gBattleStruct->pinchBerry[gActiveBattler].custap = FALSE; + gLastUsedItem = gBattleMons[gActiveBattler].item; + if (GetBattlerHoldEffect(gActiveBattler, FALSE) == HOLD_EFFECT_CUSTAP_BERRY) + { + // don't record berry since its gone now + BattleScriptExecute(BattleScript_CustapBerryActivation); + } + else + { + RecordItemEffectBattle(gActiveBattler, GetBattlerHoldEffect(gActiveBattler, FALSE)); + BattleScriptExecute(BattleScript_QuickClawActivation); + } + return; + } + } + } + + // setup stuff before turns/actions TryClearRageAndFuryCutter(); gCurrentTurnActionNumber = 0; gCurrentActionFuncId = gActionsByTurnOrder[0]; diff --git a/src/battle_message.c b/src/battle_message.c index 35ccc6e26..bf52cba31 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -685,9 +685,11 @@ 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}!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_CANACTFASTERTHANKSTO - 12] = sText_CanActFaster, [STRINGID_STATWASNOTLOWERED - 12] = sText_StatWasNotLowered, [STRINGID_CLOAKEDINAFREEZINGLIGHT - 12] = sText_CloakedInAFreezingLight, [STRINGID_DESTINYKNOTACTIVATES - 12] = sText_DestinyKnotActivates, diff --git a/src/battle_util.c b/src/battle_util.c index aeeefa734..586454efb 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4977,7 +4977,7 @@ enum }; // second argument is 1/X of current hp compared to max hp -static bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId) +bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId) { bool32 isBerry = (ItemId_GetPocket(itemId) == POCKET_BERRIES);