2017-10-06 16:06:45 +01: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 20:38:58 +01:00
|
|
|
#define MOVE_LIMITATION_IMPRISON (1 << 5)
|
2021-10-04 15:21:03 +01:00
|
|
|
#define MOVE_LIMITATIONS_ALL 0xFF
|
2017-10-06 16:06:45 +01:00
|
|
|
|
2021-10-30 03:32:19 +01: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
|
|
|
|
#define ABILITYEFFECT_FORECAST 7
|
|
|
|
#define ABILITYEFFECT_SYNCHRONIZE 8
|
|
|
|
#define ABILITYEFFECT_ATK_SYNCHRONIZE 9
|
|
|
|
#define ABILITYEFFECT_INTIMIDATE1 10
|
|
|
|
#define ABILITYEFFECT_INTIMIDATE2 11
|
|
|
|
#define ABILITYEFFECT_TRACE1 12
|
|
|
|
#define ABILITYEFFECT_TRACE2 13
|
|
|
|
#define ABILITYEFFECT_MOVE_END_OTHER 14
|
|
|
|
#define ABILITYEFFECT_NEUTRALIZINGGAS 15
|
2021-11-24 02:20:32 +00:00
|
|
|
#define ABILITYEFFECT_FIELD_SPORT 16 // Only used if B_SPORT_TURNS < GEN_6
|
2021-10-30 03:32:19 +01:00
|
|
|
// Special cases
|
2021-12-19 23:42:15 +00: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
|
2021-11-21 18:40:26 +00:00
|
|
|
#define ABILITYEFFECT_SWITCH_IN_TERRAIN 254
|
2021-10-04 15:21:03 +01:00
|
|
|
#define ABILITYEFFECT_SWITCH_IN_WEATHER 255
|
2017-10-06 16:06:45 +01:00
|
|
|
|
2021-10-04 15:21:03 +01: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 18:40:26 +00:00
|
|
|
#define ITEMEFFECT_KINGSROCK 4
|
|
|
|
#define ITEMEFFECT_TARGET 5
|
|
|
|
#define ITEMEFFECT_ORBS 6
|
|
|
|
#define ITEMEFFECT_LIFEORB_SHELLBELL 7
|
|
|
|
#define ITEMEFFECT_BATTLER_MOVE_END 8 // move end effects for just the battler, not whole field
|
2017-10-06 16:06:45 +01:00
|
|
|
|
2019-03-31 20:38:58 +01:00
|
|
|
#define WEATHER_HAS_EFFECT ((!IsAbilityOnField(ABILITY_CLOUD_NINE) && !IsAbilityOnField(ABILITY_AIR_LOCK)))
|
2017-10-06 16:06:45 +01:00
|
|
|
|
2019-03-06 11:09:34 +00:00
|
|
|
#define IS_WHOLE_SIDE_ALIVE(battler)((IsBattlerAlive(battler) && IsBattlerAlive(BATTLE_PARTNER(battler))))
|
|
|
|
|
2019-05-20 11:03:00 +01:00
|
|
|
// for Natural Gift and Fling
|
|
|
|
struct TypePower
|
|
|
|
{
|
|
|
|
u8 type;
|
|
|
|
u8 power;
|
|
|
|
u16 effect;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct TypePower gNaturalGiftTable[];
|
|
|
|
|
2021-06-25 20:37:59 +01:00
|
|
|
void HandleAction_ThrowBall(void);
|
2021-07-25 15:22:05 +01:00
|
|
|
bool32 IsAffectedByFollowMe(u32 battlerAtk, u32 defSide, u32 move);
|
2020-09-08 21:44:04 +01:00
|
|
|
void HandleAction_UseMove(void);
|
|
|
|
void HandleAction_Switch(void);
|
|
|
|
void HandleAction_UseItem(void);
|
|
|
|
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 10:17:41 +00:00
|
|
|
u8 GetBattlerForBattleScript(u8 caseId);
|
2019-01-19 21:32:25 +00:00
|
|
|
void PressurePPLose(u8 target, u8 attacker, u16 move);
|
|
|
|
void PressurePPLoseOnUsingPerishSong(u8 attacker);
|
2019-03-02 22:40:38 +00:00
|
|
|
void PressurePPLoseOnUsingImprison(u8 attacker);
|
2018-02-06 19:48:02 +00:00
|
|
|
void MarkAllBattlersForControllerExec(void); // unused
|
2018-12-23 17:47:00 +00:00
|
|
|
bool32 IsBattlerMarkedForControllerExec(u8 battlerId);
|
2018-02-28 23:59:52 +00:00
|
|
|
void MarkBattlerForControllerExec(u8 battlerId);
|
2021-01-22 07:48:22 +00:00
|
|
|
void MarkBattlerReceivedLinkData(u8 arg0);
|
2018-02-28 23:59:52 +00:00
|
|
|
void CancelMultiTurnMoves(u8 battlerId);
|
|
|
|
bool8 WasUnableToUseMove(u8 battlerId);
|
|
|
|
void PrepareStringBattle(u16 stringId, u8 battlerId);
|
2017-10-06 16:06:45 +01:00
|
|
|
void ResetSentPokesToOpponentValue(void);
|
2020-07-28 03:22:16 +01:00
|
|
|
void OpponentSwitchInResetSentPokesToOpponentValue(u8 battlerId);
|
2020-07-27 23:10:42 +01:00
|
|
|
void UpdateSentPokesToOpponentValue(u8 battlerId);
|
2017-10-06 16:06:45 +01:00
|
|
|
void BattleScriptPush(const u8* bsPtr);
|
|
|
|
void BattleScriptPushCursor(void);
|
|
|
|
void BattleScriptPop(void);
|
|
|
|
u8 TrySetCantSelectMoveBattleScript(void);
|
2018-02-28 23:59:52 +00:00
|
|
|
u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check);
|
2017-10-06 16:06:45 +01:00
|
|
|
bool8 AreAllMovesUnusable(void);
|
2018-02-28 23:59:52 +00:00
|
|
|
u8 GetImprisonedMovesCount(u8 battlerId, u16 move);
|
2018-07-21 11:10:08 +01:00
|
|
|
u8 DoFieldEndTurnEffects(void);
|
2020-04-13 14:00:17 +01:00
|
|
|
s32 GetDrainedBigRootHp(u32 battler, s32 hp);
|
2018-07-18 21:07:48 +01:00
|
|
|
u8 DoBattlerEndTurnEffects(void);
|
2017-12-02 13:08:55 +00:00
|
|
|
bool8 HandleWishPerishSongOnTurnEnd(void);
|
|
|
|
bool8 HandleFaintedMonActions(void);
|
2018-08-11 11:16:00 +01:00
|
|
|
void TryClearRageAndFuryCutter(void);
|
2017-10-06 16:06:45 +01:00
|
|
|
u8 AtkCanceller_UnableToUseMove(void);
|
2018-12-01 10:35:49 +00:00
|
|
|
u8 AtkCanceller_UnableToUseMove2(void);
|
2018-07-01 10:15:42 +01:00
|
|
|
bool8 HasNoMonsToSwitch(u8 battlerId, u8 r1, u8 r2);
|
2019-06-15 13:46:35 +01:00
|
|
|
u8 TryWeatherFormChange(u8 battlerId);
|
2018-07-27 22:40:10 +01:00
|
|
|
bool32 TryChangeBattleWeather(u8 battler, u32 weatherEnumId, bool32 viaAbility);
|
2020-05-18 22:54:12 +01:00
|
|
|
u8 AbilityBattleEffects(u8 caseID, u8 battlerId, u16 ability, u8 special, u16 moveArg);
|
2019-03-31 20:38:58 +01:00
|
|
|
u32 GetBattlerAbility(u8 battlerId);
|
|
|
|
u32 IsAbilityOnSide(u32 battlerId, u32 ability);
|
|
|
|
u32 IsAbilityOnOpposingSide(u32 battlerId, u32 ability);
|
|
|
|
u32 IsAbilityOnField(u32 ability);
|
|
|
|
u32 IsAbilityOnFieldExcept(u32 battlerId, u32 ability);
|
2020-02-08 13:20:02 +00:00
|
|
|
u32 IsAbilityPreventingEscape(u32 battlerId);
|
2021-11-13 12:38:07 +00:00
|
|
|
bool32 IsBattlerProtected(u8 battlerId, u16 move);
|
2020-04-28 10:14:20 +01:00
|
|
|
bool32 CanBattlerEscape(u32 battlerId); // no ability check
|
2017-10-06 16:06:45 +01:00
|
|
|
void BattleScriptExecute(const u8* BS_ptr);
|
|
|
|
void BattleScriptPushCursorAndCallback(const u8* BS_ptr);
|
2018-02-28 23:59:52 +00:00
|
|
|
u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn);
|
|
|
|
void ClearFuryCutterDestinyBondGrudge(u8 battlerId);
|
2017-10-06 16:06:45 +01:00
|
|
|
void HandleAction_RunBattleScript(void);
|
2019-08-27 17:29:34 +01:00
|
|
|
u32 SetRandomTarget(u32 battlerId);
|
2021-10-16 21:10:45 +01:00
|
|
|
u32 GetMoveTarget(u16 move, u8 setTarget);
|
2017-12-02 13:08:55 +00:00
|
|
|
u8 IsMonDisobedient(void);
|
2018-07-14 15:41:14 +01:00
|
|
|
u32 GetBattlerHoldEffect(u8 battlerId, bool32 checkNegating);
|
|
|
|
u32 GetBattlerHoldEffectParam(u8 battlerId);
|
|
|
|
bool32 IsMoveMakingContact(u16 move, u8 battlerAtk);
|
|
|
|
bool32 IsBattlerGrounded(u8 battlerId);
|
2018-07-22 14:08:32 +01:00
|
|
|
bool32 IsBattlerAlive(u8 battlerId);
|
2018-07-14 15:41:14 +01:00
|
|
|
u8 GetBattleMonMoveSlot(struct BattlePokemon *battleMon, u16 move);
|
|
|
|
u32 GetBattlerWeight(u8 battlerId);
|
2019-04-01 23:14:01 +01:00
|
|
|
s32 CalculateMoveDamage(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, s32 fixedBasePower, bool32 isCrit, bool32 randomFactor, bool32 updateFlags);
|
2018-07-14 21:56:03 +01:00
|
|
|
u16 CalcTypeEffectivenessMultiplier(u16 move, u8 moveType, u8 battlerAtk, u8 battlerDef, bool32 recordAbilities);
|
2020-05-18 22:54:12 +01:00
|
|
|
u16 CalcPartyMonTypeEffectivenessMultiplier(u16 move, u16 speciesDef, u16 abilityDef);
|
2018-07-15 11:39:07 +01:00
|
|
|
u16 GetTypeModifier(u8 atkType, u8 defType);
|
2018-07-24 20:47:00 +01:00
|
|
|
s32 GetStealthHazardDamage(u8 hazardType, u8 battlerId);
|
2018-09-20 10:23:12 +01:00
|
|
|
u16 GetMegaEvolutionSpecies(u16 preEvoSpecies, u16 heldItemId);
|
2020-11-07 12:53:34 +00:00
|
|
|
u16 GetWishMegaEvolutionSpecies(u16 preEvoSpecies, u16 moveId1, u16 moveId2, u16 moveId3, u16 moveId4);
|
2018-09-16 17:55:32 +01:00
|
|
|
bool32 CanMegaEvolve(u8 battlerId);
|
2019-12-31 18:11:53 +00:00
|
|
|
void UndoMegaEvolution(u32 monId);
|
2021-07-16 06:56:53 +01:00
|
|
|
void UndoFormChange(u32 monId, u32 side, bool32 isSwitchingOut);
|
2018-09-29 14:43:56 +01:00
|
|
|
bool32 DoBattlersShareType(u32 battler1, u32 battler2);
|
2018-09-30 11:27:51 +01:00
|
|
|
bool32 CanBattlerGetOrLoseItem(u8 battlerId, u16 itemId);
|
2019-08-08 12:06:55 +01:00
|
|
|
struct Pokemon *GetIllusionMonPtr(u32 battlerId);
|
|
|
|
void ClearIllusionMon(u32 battlerId);
|
|
|
|
bool32 SetIllusionMon(struct Pokemon *mon, u32 battlerId);
|
2020-10-21 19:30:20 +01:00
|
|
|
bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 battlerId);
|
2020-10-15 04:16:50 +01:00
|
|
|
u8 GetBattleMoveSplit(u32 moveId);
|
2020-12-13 22:02:21 +00:00
|
|
|
bool32 TestMoveFlags(u16 move, u32 flag);
|
|
|
|
struct Pokemon *GetBattlerPartyData(u8 battlerId);
|
|
|
|
bool32 CanFling(u8 battlerId);
|
|
|
|
bool32 IsTelekinesisBannedSpecies(u16 species);
|
|
|
|
bool32 IsHealBlockPreventingMove(u32 battler, u32 move);
|
2021-01-06 16:37:31 +00:00
|
|
|
bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId);
|
2020-11-13 06:30:00 +00:00
|
|
|
void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast);
|
|
|
|
bool32 TestSheerForceFlag(u8 battler, u16 move);
|
2020-11-13 18:00:44 +00:00
|
|
|
void TryRestoreStolenItems(void);
|
2020-12-09 17:28:18 +00:00
|
|
|
bool32 CanStealItem(u8 battlerStealing, u8 battlerItem, u16 item);
|
|
|
|
void TrySaveExchangedItem(u8 battlerId, u16 stolenItem);
|
|
|
|
bool32 IsPartnerMonFromSameTrainer(u8 battlerId);
|
2021-01-07 03:22:05 +00:00
|
|
|
u8 TryHandleSeed(u8 battler, u32 terrainFlag, u8 statId, u16 itemId, bool32 execute);
|
2021-01-07 03:53:48 +00:00
|
|
|
bool32 IsBattlerAffectedByHazards(u8 battlerId, bool32 toxicSpikes);
|
2021-01-08 02:33:39 +00:00
|
|
|
void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast);
|
2021-09-03 18:13:02 +01:00
|
|
|
bool32 CompareStat(u8 battlerId, u8 statId, u8 cmpTo, u8 cmpKind);
|
2021-09-14 17:50:36 +01:00
|
|
|
bool32 TryRoomService(u8 battlerId);
|
2021-09-14 20:07:15 +01:00
|
|
|
void BufferStatChange(u8 battlerId, u8 statId, u8 stringId);
|
2021-08-07 09:56:10 +01:00
|
|
|
void DoBurmyFormChange(u32 monId);
|
2021-10-11 00:54:17 +01:00
|
|
|
bool32 BlocksPrankster(u16 move, u8 battlerPrankster, u8 battlerDef, bool32 checkTarget);
|
2021-10-28 22:52:52 +01:00
|
|
|
u16 GetUsedHeldItem(u8 battler);
|
2021-05-24 16:52:45 +01:00
|
|
|
bool32 IsBattlerWeatherAffected(u8 battlerId, u32 weatherFlags);
|
2021-10-31 00:40:05 +01:00
|
|
|
void TryToApplyMimicry(u8 battlerId, bool8 various);
|
2021-11-04 15:20:31 +00:00
|
|
|
void TryToRevertMimicry(void);
|
2021-10-31 00:40:05 +01:00
|
|
|
void RestoreBattlerOriginalTypes(u8 battlerId);
|
2020-12-13 22:02:21 +00:00
|
|
|
|
2021-10-24 06:49:17 +01:00
|
|
|
// Ability checks
|
2020-12-13 22:02:21 +00: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 16:06:45 +01:00
|
|
|
|
2021-01-16 18:40:02 +00:00
|
|
|
bool32 CanSleep(u8 battlerId);
|
2021-11-03 22:08:37 +00:00
|
|
|
bool32 CanBePoisoned(u8 battlerAttacker, u8 battlerTarget);
|
2021-01-16 18:40:02 +00:00
|
|
|
bool32 CanBeBurned(u8 battlerId);
|
|
|
|
bool32 CanBeParalyzed(u8 battlerId);
|
|
|
|
bool32 CanBeFrozen(u8 battlerId);
|
2021-01-16 19:21:04 +00:00
|
|
|
bool32 CanBeConfused(u8 battlerId);
|
2021-01-16 19:05:51 +00:00
|
|
|
bool32 IsBattlerTerrainAffected(u8 battlerId, u32 terrainFlag);
|
2017-10-06 16:06:45 +01:00
|
|
|
|
|
|
|
#endif // GUARD_BATTLE_UTIL_H
|