From f428e5e2dcbb8f03c2deed7a4a5802004206a804 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 31 Jan 2021 23:31:27 -0700 Subject: [PATCH] some quick claw/custap berry fixes --- data/battle_scripts_1.s | 4 ++++ include/battle.h | 10 ++-------- src/battle_main.c | 14 ++++++++------ src/battle_script_commands.c | 4 ++-- src/battle_util.c | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 4d3ef6c94..eab1de169 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7853,6 +7853,8 @@ BattleScript_AnnounceAirLockCloudNine:: end3 BattleScript_QuickClawActivation:: + printstring STRINGID_EMPTYSTRING3 + waitmessage 0x1 playanimation BS_ATTACKER, B_ANIM_FOCUS_PUNCH_SETUP, NULL waitanimation printstring STRINGID_CANACTFASTERTHANKSTO @@ -7860,6 +7862,8 @@ BattleScript_QuickClawActivation:: end2 BattleScript_CustapBerryActivation:: + printstring STRINGID_EMPTYSTRING3 + waitmessage 0x1 playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL waitanimation printstring STRINGID_CANACTFASTERTHANKSTO diff --git a/include/battle.h b/include/battle.h index 8e1970d46..494e92b14 100644 --- a/include/battle.h +++ b/include/battle.h @@ -140,6 +140,8 @@ struct ProtectStruct u32 usedGravityPreventedMove:1; u32 powderSelfDmg:1; u32 usedThroatChopPreventedMove:1; + u32 micle:1; + u32 custap:1; // also quick claw u32 physicalDmg; u32 specialDmg; u8 physicalBattlerId; @@ -427,13 +429,6 @@ struct Illusion struct Pokemon *mon; }; -struct PinchBerry -{ - u8 micle:1; - u8 custap:1; // also quick claw - -}; - struct BattleStruct { u8 turnEffectsTracker; @@ -549,7 +544,6 @@ 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; }; diff --git a/src/battle_main.c b/src/battle_main.c index d069c3a4e..e0ae09681 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4353,7 +4353,7 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) || (!IsAbilityOnOpposingSide(battler1, ABILITY_UNNERVE) && holdEffectBattler1 == HOLD_EFFECT_CUSTAP_BERRY && HasEnoughHpToEatBerry(battler1, 4, gBattleMons[battler1].item))) - gBattleStruct->pinchBerry[battler1].custap = TRUE; + gProtectStructs[battler1].custap = TRUE; speedBattler2 = GetBattlerTotalSpeedStat(battler2); holdEffectBattler2 = GetBattlerHoldEffect(battler2, TRUE); @@ -4361,7 +4361,7 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) || (!IsAbilityOnOpposingSide(battler2, ABILITY_UNNERVE) && holdEffectBattler2 == HOLD_EFFECT_CUSTAP_BERRY && HasEnoughHpToEatBerry(battler2, 4, gBattleMons[battler2].item))) - gBattleStruct->pinchBerry[battler2].custap = TRUE; + gProtectStructs[battler2].custap = TRUE; if (!ignoreChosenMoves) { @@ -4377,9 +4377,9 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) // LAGGING TAIL - always last // STALL - always last - if (gBattleStruct->pinchBerry[battler1].custap && !gBattleStruct->pinchBerry[battler2].custap) + if (gProtectStructs[battler1].custap && !gProtectStructs[battler2].custap) strikesFirst = 0; - else if (gBattleStruct->pinchBerry[battler2].custap && !gBattleStruct->pinchBerry[battler1].custap) + else if (gProtectStructs[battler2].custap && !gProtectStructs[battler1].custap) strikesFirst = 1; else if (holdEffectBattler1 == HOLD_EFFECT_LAGGING_TAIL && holdEffectBattler2 != HOLD_EFFECT_LAGGING_TAIL) strikesFirst = 1; @@ -4630,12 +4630,14 @@ static void CheckQuickClaw_CustapBerryActivation(void) { gActiveBattler = gBattlerAttacker = gBattleStruct->quickClawBattlerId; gBattleStruct->quickClawBattlerId++; - if (gBattleStruct->pinchBerry[gActiveBattler].custap + if (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_MOVE + && gChosenMoveByBattler[gActiveBattler] != MOVE_FOCUS_PUNCH // quick claw message doesn't need to activate here + && gProtectStructs[gActiveBattler].custap && !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP) && !(gDisableStructs[gBattlerAttacker].truantCounter) && !(gProtectStructs[gActiveBattler].noValidMoves)) { - gBattleStruct->pinchBerry[gActiveBattler].custap = FALSE; + gProtectStructs[gActiveBattler].custap = FALSE; gLastUsedItem = gBattleMons[gActiveBattler].item; if (GetBattlerHoldEffect(gActiveBattler, FALSE) == HOLD_EFFECT_CUSTAP_BERRY) { diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 450ee74eb..cd8ac212c 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1564,9 +1564,9 @@ u32 GetTotalAccuracy(u32 battlerAtk, u32 battlerDef, u32 move) else if (atkHoldEffect == HOLD_EFFECT_ZOOM_LENS && GetBattlerTurnOrderNum(battlerAtk) > GetBattlerTurnOrderNum(battlerDef)); calc = (calc * (100 + atkParam)) / 100; - if (gBattleStruct->pinchBerry[battlerAtk].micle) + if (gProtectStructs[battlerAtk].micle) { - gBattleStruct->pinchBerry[battlerAtk].micle = FALSE; + gProtectStructs[battlerAtk].micle = FALSE; if (atkAbility == ABILITY_RIPEN) calc = (calc * 140) / 100; // ripen gives 40% acc boost else diff --git a/src/battle_util.c b/src/battle_util.c index 6568ae2e4..fc9b4cab6 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5221,7 +5221,7 @@ 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 + gProtectStructs[battlerId].micle = TRUE; // battler's next attack has increased accuracy if (end2) {