2017-10-06 17:06:45 +02:00
|
|
|
#ifndef GUARD_BATTLE_UTIL_H
|
|
|
|
#define GUARD_BATTLE_UTIL_H
|
|
|
|
|
|
|
|
#define MOVE_LIMITATION_ZEROMOVE (1 << 0)
|
|
|
|
#define MOVE_LIMITATION_PP (1 << 1)
|
|
|
|
#define MOVE_LIMITATION_DISABLED (1 << 2)
|
|
|
|
#define MOVE_LIMITATION_TORMENTED (1 << 3)
|
|
|
|
#define MOVE_LIMITATION_TAUNT (1 << 4)
|
2019-03-31 21:38:58 +02:00
|
|
|
#define MOVE_LIMITATION_IMPRISON (1 << 5)
|
2022-08-24 04:40:04 +02:00
|
|
|
#define MOVE_LIMITATION_ENCORE (1 << 6)
|
|
|
|
#define MOVE_LIMITATION_CHOICE_ITEM (1 << 7)
|
|
|
|
#define MOVE_LIMITATION_ASSAULT_VEST (1 << 8)
|
|
|
|
#define MOVE_LIMITATION_GRAVITY (1 << 9)
|
|
|
|
#define MOVE_LIMITATION_HEAL_BLOCK (1 << 10)
|
|
|
|
#define MOVE_LIMITATION_BELCH (1 << 11)
|
|
|
|
#define MOVE_LIMITATION_THROAT_CHOP (1 << 12)
|
|
|
|
#define MOVE_LIMITATION_STUFF_CHEEKS (1 << 13)
|
2023-09-15 16:18:47 +02:00
|
|
|
#define MOVE_LIMITATION_GIGATON_HAMMER (1 << 14)
|
2022-08-24 06:30:49 +02:00
|
|
|
|
|
|
|
#define MOVE_LIMITATION_PLACEHOLDER (1 << 15)
|
2022-08-24 04:40:04 +02:00
|
|
|
#define MOVE_LIMITATIONS_ALL 0xFFFF
|
2017-10-06 17:06:45 +02:00
|
|
|
|
2021-10-30 04:32:19 +02:00
|
|
|
#define ABILITYEFFECT_ON_SWITCHIN 0
|
|
|
|
#define ABILITYEFFECT_ENDTURN 1
|
|
|
|
#define ABILITYEFFECT_MOVES_BLOCK 2
|
|
|
|
#define ABILITYEFFECT_ABSORBING 3
|
|
|
|
#define ABILITYEFFECT_MOVE_END_ATTACKER 4
|
|
|
|
#define ABILITYEFFECT_MOVE_END 5
|
|
|
|
#define ABILITYEFFECT_IMMUNITY 6
|
2023-01-09 17:41:48 +01:00
|
|
|
#define ABILITYEFFECT_SYNCHRONIZE 7
|
|
|
|
#define ABILITYEFFECT_ATK_SYNCHRONIZE 8
|
|
|
|
#define ABILITYEFFECT_TRACE1 9
|
|
|
|
#define ABILITYEFFECT_TRACE2 10
|
|
|
|
#define ABILITYEFFECT_MOVE_END_OTHER 11
|
|
|
|
#define ABILITYEFFECT_NEUTRALIZINGGAS 12
|
|
|
|
#define ABILITYEFFECT_FIELD_SPORT 13 // Only used if B_SPORT_TURNS < GEN_6
|
|
|
|
#define ABILITYEFFECT_ON_WEATHER 14
|
|
|
|
#define ABILITYEFFECT_ON_TERRAIN 15
|
2023-07-03 10:03:50 +02:00
|
|
|
#define ABILITYEFFECT_SWITCH_IN_TERRAIN 16
|
|
|
|
#define ABILITYEFFECT_SWITCH_IN_WEATHER 17
|
2021-10-30 04:32:19 +02:00
|
|
|
// Special cases
|
2021-12-20 00:42:15 +01:00
|
|
|
#define ABILITYEFFECT_MUD_SPORT 252 // Only used if B_SPORT_TURNS < GEN_6
|
|
|
|
#define ABILITYEFFECT_WATER_SPORT 253 // Only used if B_SPORT_TURNS < GEN_6
|
2017-10-06 17:06:45 +02:00
|
|
|
|
2021-10-04 16:21:03 +02:00
|
|
|
// For the first argument of ItemBattleEffects, to deteremine which block of item effects to try
|
|
|
|
#define ITEMEFFECT_ON_SWITCH_IN 0
|
|
|
|
#define ITEMEFFECT_NORMAL 1
|
|
|
|
#define ITEMEFFECT_DUMMY 2 // Unused, empty
|
|
|
|
#define ITEMEFFECT_MOVE_END 3
|
2021-11-21 19:40:26 +01:00
|
|
|
#define ITEMEFFECT_KINGSROCK 4
|
|
|
|
#define ITEMEFFECT_TARGET 5
|
|
|
|
#define ITEMEFFECT_ORBS 6
|
|
|
|
#define ITEMEFFECT_LIFEORB_SHELLBELL 7
|
2022-05-13 22:21:41 +02:00
|
|
|
#define ITEMEFFECT_USE_LAST_ITEM 8 // move end effects for just the battler, not whole field
|
2017-10-06 17:06:45 +02:00
|
|
|
|
2019-03-31 21:38:58 +02:00
|
|
|
#define WEATHER_HAS_EFFECT ((!IsAbilityOnField(ABILITY_CLOUD_NINE) && !IsAbilityOnField(ABILITY_AIR_LOCK)))
|
2017-10-06 17:06:45 +02:00
|
|
|
|
2023-09-05 09:21:14 +02:00
|
|
|
#define IS_WHOLE_SIDE_ALIVE(battler) ((IsBattlerAlive(battler) && IsBattlerAlive(BATTLE_PARTNER(battler))))
|
|
|
|
#define IS_ALIVE_AND_PRESENT(battler) (IsBattlerAlive(battler) && IsBattlerSpritePresent(battler))
|
2019-03-06 12:09:34 +01:00
|
|
|
|
2019-05-20 12:03:00 +02:00
|
|
|
// for Natural Gift and Fling
|
|
|
|
struct TypePower
|
|
|
|
{
|
|
|
|
u8 type;
|
|
|
|
u8 power;
|
|
|
|
u16 effect;
|
|
|
|
};
|
|
|
|
|
2023-02-17 14:55:51 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
CANCELLER_FLAGS,
|
|
|
|
CANCELLER_SKY_DROP,
|
|
|
|
CANCELLER_ASLEEP,
|
|
|
|
CANCELLER_FROZEN,
|
|
|
|
CANCELLER_TRUANT,
|
|
|
|
CANCELLER_RECHARGE,
|
|
|
|
CANCELLER_FLINCH,
|
|
|
|
CANCELLER_DISABLED,
|
|
|
|
CANCELLER_GRAVITY,
|
|
|
|
CANCELLER_HEAL_BLOCKED,
|
|
|
|
CANCELLER_TAUNTED,
|
|
|
|
CANCELLER_IMPRISONED,
|
|
|
|
CANCELLER_CONFUSED,
|
|
|
|
CANCELLER_PARALYSED,
|
|
|
|
CANCELLER_IN_LOVE,
|
|
|
|
CANCELLER_BIDE,
|
|
|
|
CANCELLER_THAW,
|
|
|
|
CANCELLER_POWDER_MOVE,
|
|
|
|
CANCELLER_POWDER_STATUS,
|
|
|
|
CANCELLER_THROAT_CHOP,
|
|
|
|
CANCELLER_MULTIHIT_MOVES,
|
|
|
|
CANCELLER_Z_MOVES,
|
|
|
|
CANCELLER_END,
|
|
|
|
CANCELLER_PSYCHIC_TERRAIN,
|
|
|
|
CANCELLER_END2,
|
|
|
|
};
|
|
|
|
|
2019-05-20 12:03:00 +02:00
|
|
|
extern const struct TypePower gNaturalGiftTable[];
|
|
|
|
|
2021-06-25 21:37:59 +02:00
|
|
|
void HandleAction_ThrowBall(void);
|
2021-07-25 16:22:05 +02:00
|
|
|
bool32 IsAffectedByFollowMe(u32 battlerAtk, u32 defSide, u32 move);
|
2020-09-08 22:44:04 +02:00
|
|
|
void HandleAction_UseMove(void);
|
|
|
|
void HandleAction_Switch(void);
|
|
|
|
void HandleAction_UseItem(void);
|
2023-09-13 00:02:26 +02:00
|
|
|
bool32 TryRunFromBattle(u32 battler);
|
2020-09-08 22:44:04 +02:00
|
|
|
void HandleAction_Run(void);
|
|
|
|
void HandleAction_WatchesCarefully(void);
|
|
|
|
void HandleAction_SafariZoneBallThrow(void);
|
|
|
|
void HandleAction_ThrowPokeblock(void);
|
|
|
|
void HandleAction_GoNear(void);
|
|
|
|
void HandleAction_SafariZoneRun(void);
|
|
|
|
void HandleAction_WallyBallThrow(void);
|
|
|
|
void HandleAction_TryFinish(void);
|
|
|
|
void HandleAction_NothingIsFainted(void);
|
|
|
|
void HandleAction_ActionFinished(void);
|
2018-02-08 11:17:41 +01:00
|
|
|
u8 GetBattlerForBattleScript(u8 caseId);
|
2019-01-19 22:32:25 +01:00
|
|
|
void PressurePPLose(u8 target, u8 attacker, u16 move);
|
|
|
|
void PressurePPLoseOnUsingPerishSong(u8 attacker);
|
2019-03-02 23:40:38 +01:00
|
|
|
void PressurePPLoseOnUsingImprison(u8 attacker);
|
2023-09-13 00:02:26 +02:00
|
|
|
bool32 IsBattlerMarkedForControllerExec(u32 battler);
|
|
|
|
void MarkBattlerForControllerExec(u32 battler);
|
|
|
|
void MarkBattlerReceivedLinkData(u32 battler);
|
|
|
|
void CancelMultiTurnMoves(u32 battler);
|
|
|
|
bool32 WasUnableToUseMove(u32 battler);
|
|
|
|
void PrepareStringBattle(u16 stringId, u32 battler);
|
2017-10-06 17:06:45 +02:00
|
|
|
void ResetSentPokesToOpponentValue(void);
|
2023-09-13 00:02:26 +02:00
|
|
|
void OpponentSwitchInResetSentPokesToOpponentValue(u32 battler);
|
|
|
|
void UpdateSentPokesToOpponentValue(u32 battler);
|
2022-07-29 16:17:58 +02:00
|
|
|
void BattleScriptPush(const u8 *bsPtr);
|
2017-10-06 17:06:45 +02:00
|
|
|
void BattleScriptPushCursor(void);
|
|
|
|
void BattleScriptPop(void);
|
2023-08-30 10:18:31 +02:00
|
|
|
u32 TrySetCantSelectMoveBattleScript(u32 battler);
|
2023-09-13 00:02:26 +02:00
|
|
|
u8 CheckMoveLimitations(u32 battler, u8 unusableMoves, u16 check);
|
2023-08-30 10:18:31 +02:00
|
|
|
bool32 AreAllMovesUnusable(u32 battler);
|
2023-09-13 00:02:26 +02:00
|
|
|
u8 GetImprisonedMovesCount(u32 battler, u16 move);
|
2018-07-21 12:10:08 +02:00
|
|
|
u8 DoFieldEndTurnEffects(void);
|
2020-04-13 15:00:17 +02:00
|
|
|
s32 GetDrainedBigRootHp(u32 battler, s32 hp);
|
2018-07-18 22:07:48 +02:00
|
|
|
u8 DoBattlerEndTurnEffects(void);
|
2023-09-13 00:02:26 +02:00
|
|
|
bool32 HandleWishPerishSongOnTurnEnd(void);
|
|
|
|
bool32 HandleFaintedMonActions(void);
|
2018-08-11 12:16:00 +02:00
|
|
|
void TryClearRageAndFuryCutter(void);
|
2023-07-30 16:50:51 +02:00
|
|
|
u8 AtkCanceller_UnableToUseMove(u32 moveType);
|
2023-07-15 14:00:55 +02:00
|
|
|
void SetAtkCancellerForCalledMove(void);
|
2018-12-01 11:35:49 +01:00
|
|
|
u8 AtkCanceller_UnableToUseMove2(void);
|
2023-09-13 00:02:26 +02:00
|
|
|
bool32 HasNoMonsToSwitch(u32 battler, u8 r1, u8 r2);
|
|
|
|
bool32 TryChangeBattleWeather(u32 battler, u32 weatherEnumId, bool32 viaAbility);
|
|
|
|
u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32 moveArg);
|
|
|
|
bool32 TryPrimalReversion(u32 battler);
|
2022-08-12 06:48:36 +02:00
|
|
|
bool32 IsNeutralizingGasOnField(void);
|
2023-09-13 00:02:26 +02:00
|
|
|
u32 GetBattlerAbility(u32 battler);
|
2023-08-30 10:18:31 +02:00
|
|
|
u32 IsAbilityOnSide(u32 battler, u32 ability);
|
|
|
|
u32 IsAbilityOnOpposingSide(u32 battler, u32 ability);
|
2019-03-31 21:38:58 +02:00
|
|
|
u32 IsAbilityOnField(u32 ability);
|
2023-08-30 10:18:31 +02:00
|
|
|
u32 IsAbilityOnFieldExcept(u32 battler, u32 ability);
|
|
|
|
u32 IsAbilityPreventingEscape(u32 battler);
|
2023-09-13 00:02:26 +02:00
|
|
|
bool32 IsBattlerProtected(u32 battler, u32 move);
|
2023-08-30 10:18:31 +02:00
|
|
|
bool32 CanBattlerEscape(u32 battler); // no ability check
|
2022-07-29 16:17:58 +02:00
|
|
|
void BattleScriptExecute(const u8 *BS_ptr);
|
|
|
|
void BattleScriptPushCursorAndCallback(const u8 *BS_ptr);
|
2023-09-13 00:02:26 +02:00
|
|
|
u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn);
|
|
|
|
void ClearFuryCutterDestinyBondGrudge(u32 battler);
|
2017-10-06 17:06:45 +02:00
|
|
|
void HandleAction_RunBattleScript(void);
|
2023-08-30 10:18:31 +02:00
|
|
|
u32 SetRandomTarget(u32 battler);
|
2021-10-16 22:10:45 +02:00
|
|
|
u32 GetMoveTarget(u16 move, u8 setTarget);
|
2017-12-02 14:08:55 +01:00
|
|
|
u8 IsMonDisobedient(void);
|
2023-09-12 23:20:09 +02:00
|
|
|
u32 GetBattlerHoldEffect(u32 battler, bool32 checkNegating);
|
2023-09-13 00:02:26 +02:00
|
|
|
u32 GetBattlerHoldEffectParam(u32 battler);
|
|
|
|
bool32 IsMoveMakingContact(u32 move, u32 battlerAtk);
|
|
|
|
bool32 IsBattlerGrounded(u32 battler);
|
|
|
|
bool32 IsBattlerAlive(u32 battler);
|
2023-09-13 13:23:19 +02:00
|
|
|
u32 GetMoveSlot(u16 *moves, u32 move);
|
2023-09-13 00:02:26 +02:00
|
|
|
u32 GetBattlerWeight(u32 battler);
|
2023-07-06 13:41:16 +02:00
|
|
|
u32 CalcRolloutBasePower(u32 battlerAtk, u32 basePower, u32 rolloutTimer);
|
|
|
|
u32 CalcFuryCutterBasePower(u32 basePower, u32 furyCutterCounter);
|
2023-09-12 23:20:09 +02:00
|
|
|
s32 CalculateMoveDamage(u32 move, u32 battlerAtk, u32 battlerDef, u32 moveType, s32 fixedBasePower, bool32 isCrit, bool32 randomFactor, bool32 updateFlags);
|
2023-09-14 00:07:41 +02:00
|
|
|
s32 CalculateMoveDamageVars(u32 move, u32 battlerAtk, u32 battlerDef, u32 moveType, s32 fixedBasePower, uq4_12_t typeEffectivenessModifier,
|
|
|
|
u32 weather, bool32 isCrit, u32 holdEffectAtk, u32 holdEffectDef, u32 abilityAtk, u32 abilityDef);
|
2023-09-14 11:05:00 +02:00
|
|
|
uq4_12_t CalcTypeEffectivenessMultiplier(u32 move, u32 moveType, u32 battlerAtk, u32 battlerDef, u32 defAbility, bool32 recordAbilities);
|
2023-07-07 14:11:49 +02:00
|
|
|
uq4_12_t CalcPartyMonTypeEffectivenessMultiplier(u16 move, u16 speciesDef, u16 abilityDef);
|
2023-09-12 23:20:09 +02:00
|
|
|
uq4_12_t GetTypeModifier(u32 atkType, u32 defType);
|
2023-09-13 00:02:26 +02:00
|
|
|
s32 GetStealthHazardDamage(u8 hazardType, u32 battler);
|
2022-05-02 05:04:16 +02:00
|
|
|
s32 GetStealthHazardDamageByTypesAndHP(u8 hazardType, u8 type1, u8 type2, u32 maxHp);
|
2023-09-13 00:02:26 +02:00
|
|
|
bool32 CanMegaEvolve(u32 battler);
|
|
|
|
bool32 CanUltraBurst(u32 battler);
|
|
|
|
bool32 IsBattlerMegaEvolved(u32 battler);
|
|
|
|
bool32 IsBattlerPrimalReverted(u32 battler);
|
|
|
|
bool32 IsBattlerUltraBursted(u32 battler);
|
|
|
|
u16 GetBattleFormChangeTargetSpecies(u32 battler, u16 method);
|
|
|
|
bool32 TryBattleFormChange(u32 battler, u16 method);
|
2018-09-29 15:43:56 +02:00
|
|
|
bool32 DoBattlersShareType(u32 battler1, u32 battler2);
|
2023-09-13 00:02:26 +02:00
|
|
|
bool32 CanBattlerGetOrLoseItem(u32 battler, u16 itemId);
|
2023-08-30 10:18:31 +02:00
|
|
|
u32 GetIllusionMonSpecies(u32 battler);
|
|
|
|
struct Pokemon *GetIllusionMonPtr(u32 battler);
|
|
|
|
void ClearIllusionMon(u32 battler);
|
|
|
|
bool32 SetIllusionMon(struct Pokemon *mon, u32 battler);
|
2023-09-13 00:02:26 +02:00
|
|
|
bool32 ShouldGetStatBadgeBoost(u16 flagId, u32 battler);
|
2020-10-15 05:16:50 +02:00
|
|
|
u8 GetBattleMoveSplit(u32 moveId);
|
2023-09-07 20:13:06 +02:00
|
|
|
bool32 CanFling(u32 battler);
|
2020-12-13 23:02:21 +01:00
|
|
|
bool32 IsTelekinesisBannedSpecies(u16 species);
|
|
|
|
bool32 IsHealBlockPreventingMove(u32 battler, u32 move);
|
2023-08-30 10:18:31 +02:00
|
|
|
bool32 HasEnoughHpToEatBerry(u32 battler, u32 hpFraction, u32 itemId);
|
2023-09-13 00:02:26 +02:00
|
|
|
bool32 IsPartnerMonFromSameTrainer(u32 battler);
|
|
|
|
u8 GetSplitBasedOnStats(u32 battler);
|
|
|
|
bool32 TestSheerForceFlag(u32 battler, u16 move);
|
2023-04-20 15:08:42 +02:00
|
|
|
void TryRestoreHeldItems(void);
|
2023-09-13 00:02:26 +02:00
|
|
|
bool32 CanStealItem(u32 battlerStealing, u32 battlerItem, u16 item);
|
|
|
|
void TrySaveExchangedItem(u32 battler, u16 stolenItem);
|
|
|
|
bool32 IsPartnerMonFromSameTrainer(u32 battler);
|
|
|
|
u8 TryHandleSeed(u32 battler, u32 terrainFlag, u8 statId, u16 itemId, bool32 execute);
|
|
|
|
bool32 IsBattlerAffectedByHazards(u32 battler, bool32 toxicSpikes);
|
|
|
|
void SortBattlersBySpeed(u8 *battlers, bool32 slowToFast);
|
|
|
|
bool32 CompareStat(u32 battler, u8 statId, u8 cmpTo, u8 cmpKind);
|
|
|
|
bool32 TryRoomService(u32 battler);
|
|
|
|
void BufferStatChange(u32 battler, u8 statId, u8 stringId);
|
|
|
|
bool32 BlocksPrankster(u16 move, u32 battlerPrankster, u32 battlerDef, bool32 checkTarget);
|
|
|
|
u16 GetUsedHeldItem(u32 battler);
|
|
|
|
bool32 IsBattlerWeatherAffected(u32 battler, u32 weatherFlags);
|
|
|
|
u32 GetBattlerMoveTargetType(u32 battler, u32 move);
|
2023-09-12 23:20:09 +02:00
|
|
|
bool32 CanTargetBattler(u32 battlerAtk, u32 battlerDef, u16 move);
|
2022-11-02 03:50:26 +01:00
|
|
|
void CopyMonLevelAndBaseStatsToBattleMon(u32 battler, struct Pokemon *mon);
|
|
|
|
void CopyMonAbilityAndTypesToBattleMon(u32 battler, struct Pokemon *mon);
|
2022-10-21 07:08:37 +02:00
|
|
|
void RecalcBattlerStats(u32 battler, struct Pokemon *mon);
|
2023-06-21 19:19:54 +02:00
|
|
|
bool32 IsAlly(u32 battlerAtk, u32 battlerDef);
|
2023-09-08 04:18:18 +02:00
|
|
|
bool32 IsGen6ExpShareEnabled(void);
|
2023-06-21 19:19:54 +02:00
|
|
|
|
2021-10-24 07:49:17 +02:00
|
|
|
// Ability checks
|
2020-12-13 23:02:21 +01:00
|
|
|
bool32 IsRolePlayBannedAbilityAtk(u16 ability);
|
|
|
|
bool32 IsRolePlayBannedAbility(u16 ability);
|
|
|
|
bool32 IsSkillSwapBannedAbility(u16 ability);
|
|
|
|
bool32 IsWorrySeedBannedAbility(u16 ability);
|
|
|
|
bool32 IsGastroAcidBannedAbility(u16 ability);
|
|
|
|
bool32 IsEntrainmentBannedAbilityAttacker(u16 ability);
|
|
|
|
bool32 IsEntrainmentTargetOrSimpleBeamBannedAbility(u16 ability);
|
2017-10-06 17:06:45 +02:00
|
|
|
|
2023-09-13 00:02:26 +02:00
|
|
|
bool32 CanSleep(u32 battler);
|
|
|
|
bool32 CanBePoisoned(u32 battlerAttacker, u32 battlerTarget);
|
|
|
|
bool32 CanBeBurned(u32 battler);
|
|
|
|
bool32 CanBeParalyzed(u32 battler);
|
|
|
|
bool32 CanBeFrozen(u32 battler);
|
|
|
|
bool32 CanGetFrostbite(u32 battler);
|
|
|
|
bool32 CanBeConfused(u32 battler);
|
|
|
|
bool32 IsBattlerTerrainAffected(u32 battler, u32 terrainFlag);
|
|
|
|
u32 GetBattlerFriendshipScore(u32 battler);
|
|
|
|
u32 CountBattlerStatIncreases(u32 battler, bool32 countEvasionAcc);
|
2022-12-06 10:18:18 +01:00
|
|
|
bool32 IsMyceliumMightOnField(void);
|
2023-09-13 00:02:26 +02:00
|
|
|
bool32 ChangeTypeBasedOnTerrain(u32 battler);
|
|
|
|
void RemoveConfusionStatus(u32 battler);
|
|
|
|
u8 GetBattlerGender(u32 battler);
|
|
|
|
bool32 AreBattlersOfOppositeGender(u32 battler1, u32 battler2);
|
|
|
|
u32 CalcSecondaryEffectChance(u32 battler, u8 secondaryEffectChance);
|
2017-10-06 17:06:45 +02:00
|
|
|
|
|
|
|
#endif // GUARD_BATTLE_UTIL_H
|