custap berry effect, custap/quick claw activation message

This commit is contained in:
Evan 2021-01-06 09:37:31 -07:00
parent 73a7800f72
commit f2e486eb0d
9 changed files with 86 additions and 12 deletions

View File

@ -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

View File

@ -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) \

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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];

View File

@ -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,

View File

@ -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);