pokeemerald/include/battle.h

945 lines
31 KiB
C
Raw Normal View History

#ifndef GUARD_BATTLE_H
#define GUARD_BATTLE_H
2017-10-06 17:06:45 +02:00
// should they be included here or included individually by every file?
2018-02-08 00:35:13 +01:00
#include "constants/battle.h"
2018-02-26 15:56:59 +01:00
#include "battle_main.h"
2018-06-30 15:35:54 +02:00
#include "battle_message.h"
2017-10-06 17:06:45 +02:00
#include "battle_util.h"
#include "battle_script_commands.h"
2017-10-10 21:45:07 +02:00
#include "battle_ai_switch_items.h"
2017-11-04 16:11:13 +01:00
#include "battle_gfx_sfx_util.h"
2017-11-12 16:39:21 +01:00
#include "battle_util2.h"
2017-12-17 20:10:57 +01:00
#include "battle_bg.h"
#include "pokeball.h"
2018-07-13 23:00:56 +02:00
#include "battle_debug.h"
2017-10-06 17:06:45 +02:00
2018-02-06 02:46:59 +01:00
#define GET_BATTLER_POSITION(battler) (gBattlerPositions[battler])
#define GET_BATTLER_SIDE(battler) (GetBattlerPosition(battler) & BIT_SIDE)
#define GET_BATTLER_SIDE2(battler) (GET_BATTLER_POSITION(battler) & BIT_SIDE)
2018-01-16 22:12:38 +01:00
// Used to exclude moves learned temporarily by Transform or Mimic
#define MOVE_IS_PERMANENT(battler, moveSlot) \
(!(gBattleMons[battler].status2 & STATUS2_TRANSFORMED) \
&& !(gDisableStructs[battler].mimickedMoves & gBitTable[moveSlot]))
2018-02-06 23:09:39 +01:00
// Battle Actions
// These determine what each battler will do in a turn
#define B_ACTION_USE_MOVE 0
#define B_ACTION_USE_ITEM 1
#define B_ACTION_SWITCH 2
#define B_ACTION_RUN 3
#define B_ACTION_SAFARI_WATCH_CAREFULLY 4
#define B_ACTION_SAFARI_BALL 5
#define B_ACTION_SAFARI_POKEBLOCK 6
#define B_ACTION_SAFARI_GO_NEAR 7
#define B_ACTION_SAFARI_RUN 8
2018-10-14 18:37:52 +02:00
#define B_ACTION_WALLY_THROW 9
2019-02-02 11:32:00 +01:00
#define B_ACTION_EXEC_SCRIPT 10
#define B_ACTION_TRY_FINISH 11
#define B_ACTION_FINISHED 12
2018-02-06 23:09:39 +01:00
#define B_ACTION_CANCEL_PARTNER 12 // when choosing an action
#define B_ACTION_NOTHING_FAINTED 13 // when choosing an action
2018-07-13 23:00:56 +02:00
#define B_ACTION_DEBUG 20
2021-06-25 21:37:59 +02:00
#define B_ACTION_THROW_BALL 21 // R to throw last used ball
2018-02-06 23:09:39 +01:00
#define B_ACTION_NONE 0xFF
2017-10-04 19:25:14 +02:00
2018-02-07 23:21:51 +01:00
#define BATTLE_BUFFER_LINK_SIZE 0x1000
2019-04-04 23:53:06 +02:00
struct ResourceFlags
2017-09-04 21:43:13 +02:00
{
2022-01-20 16:25:48 +01:00
u32 flags[MAX_BATTLERS_COUNT];
2017-09-04 21:43:13 +02:00
};
2021-10-30 04:32:19 +02:00
#define RESOURCE_FLAG_FLASH_FIRE 0x1
#define RESOURCE_FLAG_ROOST 0x2
#define RESOURCE_FLAG_UNBURDEN 0x4
#define RESOURCE_FLAG_INTIMIDATED 0x8
#define RESOURCE_FLAG_TRACED 0x10
#define RESOURCE_FLAG_EMERGENCY_EXIT 0x20
#define RESOURCE_FLAG_NEUTRALIZING_GAS 0x40
2017-09-04 21:43:13 +02:00
struct DisableStruct
{
u32 transformedMonPersonality;
u16 disabledMove;
u16 encoredMove;
u8 protectUses;
u8 stockpileCounter;
s8 stockpileDef;
s8 stockpileSpDef;
s8 stockpileBeforeDef;
s8 stockpileBeforeSpDef;
u8 substituteHP;
u8 disableTimer:4;
u8 disableTimerStartValue:4;
u8 encoredMovePos;
u8 encoreTimer:4;
u8 encoreTimerStartValue:4;
u8 perishSongTimer:4;
u8 perishSongTimerStartValue:4;
u8 furyCutterCounter;
u8 rolloutTimer:4;
u8 rolloutTimerStartValue:4;
u8 chargeTimer:4;
u8 chargeTimerStartValue:4;
u8 tauntTimer:4;
u8 tauntTimer2:4;
u8 battlerPreventingEscape;
u8 battlerWithSureHit;
u8 isFirstTurn;
u8 truantCounter:1;
u8 truantSwitchInHack:1;
u8 mimickedMoves:4;
u8 rechargeTimer;
u8 autotomizeCount;
2018-10-14 20:51:34 +02:00
u8 slowStartTimer;
2018-07-18 22:07:48 +02:00
u8 embargoTimer;
u8 magnetRiseTimer;
u8 telekinesisTimer;
u8 healBlockTimer;
2018-07-23 21:36:05 +02:00
u8 laserFocusTimer;
u8 throatChopTimer;
u8 usedMoves:4;
u8 wrapTurns;
u8 noRetreat:1;
u8 tarShot:1;
u8 octolock:1;
2017-09-04 21:43:13 +02:00
};
2017-09-17 14:10:32 +02:00
struct ProtectStruct
{
u32 protected:1;
2018-10-14 20:51:34 +02:00
u32 spikyShielded:1;
u32 kingsShielded:1;
u32 banefulBunkered:1;
u32 obstructed:1;
2017-09-17 14:10:32 +02:00
u32 endured:1;
2018-07-07 19:57:09 +02:00
u32 noValidMoves:1;
2017-09-17 14:10:32 +02:00
u32 helpingHand:1;
u32 bounceMove:1;
u32 stealMove:1;
u32 prlzImmobility:1;
u32 confusionSelfDmg:1;
u32 targetAffected:1;
2017-09-17 14:10:32 +02:00
u32 chargingTurn:1;
2021-10-04 16:21:03 +02:00
u32 fleeType:2; // 0: Normal, 1: FLEE_ITEM, 2: FLEE_ABILITY
u32 usedImprisonedMove:1;
2017-09-17 14:10:32 +02:00
u32 loveImmobility:1;
u32 usedDisabledMove:1;
2018-10-14 18:10:54 +02:00
u32 usedTauntedMove:1;
2019-01-29 22:22:02 +01:00
u32 flag2Unknown:1; // Only set to 0 once. Checked in 'WasUnableToUseMove' function.
2018-10-14 18:10:54 +02:00
u32 flinchImmobility:1;
u32 notFirstStrike:1;
2019-01-29 22:22:02 +01:00
u32 palaceUnableToUseMove:1;
2018-10-14 20:51:34 +02:00
u32 usesBouncedMove:1;
u32 usedHealBlockedMove:1;
u32 usedGravityPreventedMove:1;
2018-12-03 12:50:32 +01:00
u32 powderSelfDmg:1;
u32 usedThroatChopPreventedMove:1;
u32 statRaised:1;
u32 usedMicleBerry:1;
u32 usedCustapBerry:1; // also quick claw
u32 touchedProtectLike:1;
// End of 32-bit bitfield
u16 disableEjectPack:1;
u16 statFell:1;
u16 pranksterElevated:1;
u16 quickDraw:1;
u16 beakBlastCharge:1;
u32 physicalDmg;
u32 specialDmg;
2018-10-14 18:10:54 +02:00
u8 physicalBattlerId;
u8 specialBattlerId;
2017-09-17 14:10:32 +02:00
};
struct SpecialStatus
{
2018-10-14 18:10:54 +02:00
u8 statLowered:1;
u8 lightningRodRedirected:1;
u8 restoredBattlerSprite: 1;
u8 intimidatedMon:1;
u8 traced:1;
u8 ppNotAffectedByPressure:1;
u8 faintedHasReplacement:1;
2018-06-20 23:07:51 +02:00
u8 focusBanded:1;
2018-07-14 22:56:03 +02:00
u8 focusSashed:1;
2018-07-21 15:11:13 +02:00
u8 sturdied:1;
2018-07-22 19:34:13 +02:00
u8 stormDrainRedirected:1;
2018-07-22 22:21:47 +02:00
u8 switchInAbilityDone:1;
2019-05-20 12:20:49 +02:00
u8 switchInItemDone:1;
u8 instructedChosenTarget:3;
2019-05-07 15:26:58 +02:00
u8 berryReduced:1;
u8 gemBoost:1;
2021-09-16 16:24:32 +02:00
u8 rototillerAffected:1; // to be affected by rototiller
2019-05-07 15:26:58 +02:00
u8 gemParam;
2019-05-10 11:03:33 +02:00
u8 damagedMons:4; // Mons that have been damaged directly by using a move, includes substitute.
u8 dancerUsedMove:1;
u8 dancerOriginalTarget:3;
2021-11-01 18:50:57 +01:00
u8 announceNeutralizingGas:1; // See Cmd_switchineffects
u8 neutralizingGasRemoved:1; // See VARIOUS_TRY_END_NEUTRALIZING_GAS
2018-02-07 22:53:40 +01:00
s32 dmg;
s32 physicalDmg;
s32 specialDmg;
u8 physicalBattlerId;
u8 specialBattlerId;
2019-03-23 17:21:14 +01:00
u8 changedStatsBattlerId; // Battler that was responsible for the latest stat change. Can be self.
2017-09-17 14:10:32 +02:00
};
struct SideTimer
{
2018-10-14 18:10:54 +02:00
u8 reflectTimer;
u8 reflectBattlerId;
u8 lightscreenTimer;
u8 lightscreenBattlerId;
u8 mistTimer;
u8 mistBattlerId;
u8 safeguardTimer;
u8 safeguardBattlerId;
u8 spikesAmount;
2018-07-21 12:10:08 +02:00
u8 toxicSpikesAmount;
2018-07-24 21:47:00 +02:00
u8 stealthRockAmount;
2018-07-24 22:09:55 +02:00
u8 stickyWebAmount;
u8 stickyWebBattlerSide; // Used for Court Change
2018-07-21 12:10:08 +02:00
u8 auroraVeilTimer;
u8 auroraVeilBattlerId;
u8 tailwindTimer;
u8 tailwindBattlerId;
2018-07-21 12:56:07 +02:00
u8 luckyChantTimer;
u8 luckyChantBattlerId;
// Timers below this point are not swapped by Court Change
u8 followmeTimer;
u8 followmeTarget:3;
u8 followmePowder:1; // Rage powder, does not affect grass type pokemon.
2021-10-16 10:41:50 +02:00
u8 retaliateTimer;
2017-09-17 14:10:32 +02:00
};
2018-07-14 13:17:10 +02:00
struct FieldTimer
{
u8 mudSportTimer;
u8 waterSportTimer;
u8 wonderRoomTimer;
u8 magicRoomTimer;
u8 trickRoomTimer;
2021-11-06 23:46:52 +01:00
u8 terrainTimer;
u8 gravityTimer;
2020-04-20 19:41:07 +02:00
u8 fairyLockTimer;
2017-09-17 14:10:32 +02:00
};
struct WishFutureKnock
{
2018-02-06 02:46:59 +01:00
u8 futureSightCounter[MAX_BATTLERS_COUNT];
u8 futureSightAttacker[MAX_BATTLERS_COUNT];
u16 futureSightMove[MAX_BATTLERS_COUNT];
u8 wishCounter[MAX_BATTLERS_COUNT];
2021-11-20 22:49:04 +01:00
u8 wishPartyId[MAX_BATTLERS_COUNT];
2017-09-17 14:10:32 +02:00
u8 weatherDuration;
2018-10-14 18:37:52 +02:00
u8 knockedOffMons[2]; // Each battler is represented by a bit. The array entry is dependent on the battler's side.
2017-09-17 14:10:32 +02:00
};
2018-07-15 18:07:01 +02:00
struct AI_SavedBattleMon
{
u16 ability;
2020-07-15 21:30:24 +02:00
u16 moves[MAX_MON_MOVES];
2018-07-15 18:07:01 +02:00
u16 heldItem;
u16 species;
};
struct AiLogicData
{
2022-01-13 17:28:27 +01:00
u16 abilities[MAX_BATTLERS_COUNT];
u16 items[MAX_BATTLERS_COUNT];
u16 holdEffects[MAX_BATTLERS_COUNT];
u8 holdEffectParams[MAX_BATTLERS_COUNT];
u16 predictedMoves[MAX_BATTLERS_COUNT];
u8 hpPercents[MAX_BATTLERS_COUNT];
u16 partnerMove;
2022-01-13 17:28:27 +01:00
s32 simulatedDmg[MAX_BATTLERS_COUNT][MAX_BATTLERS_COUNT][MAX_MON_MOVES]; // attacker, target, moveIndex
u8 effectiveness[MAX_BATTLERS_COUNT][MAX_BATTLERS_COUNT][MAX_MON_MOVES]; // attacker, target, moveIndex
u8 moveLimitations[MAX_BATTLERS_COUNT];
};
2017-09-04 21:43:13 +02:00
struct AI_ThinkingStruct
{
u8 aiState;
u8 movesetIndex;
u16 moveConsidered;
2019-09-08 17:53:48 +02:00
s8 score[MAX_MON_MOVES];
2017-09-04 21:43:13 +02:00
u32 funcResult;
u32 aiFlags;
u8 aiAction;
u8 aiLogicId;
2018-07-15 18:07:01 +02:00
struct AI_SavedBattleMon saved[4];
bool8 switchMon; // Because all available moves have no/little effect.
2017-09-04 21:43:13 +02:00
};
2020-07-15 21:30:24 +02:00
#define AI_MOVE_HISTORY_COUNT 3
2017-09-04 21:43:13 +02:00
struct BattleHistory
{
u16 abilities[MAX_BATTLERS_COUNT];
2018-02-06 02:46:59 +01:00
u8 itemEffects[MAX_BATTLERS_COUNT];
2020-07-15 21:30:24 +02:00
u16 usedMoves[MAX_BATTLERS_COUNT][MAX_MON_MOVES];
u16 moveHistory[MAX_BATTLERS_COUNT][AI_MOVE_HISTORY_COUNT]; // 3 last used moves for each battler
u8 moveHistoryIndex[MAX_BATTLERS_COUNT];
2018-02-06 02:46:59 +01:00
u16 trainerItems[MAX_BATTLERS_COUNT];
2017-09-05 09:41:48 +02:00
u8 itemsNo;
u16 heldItems[MAX_BATTLERS_COUNT];
2017-09-04 21:43:13 +02:00
};
struct BattleScriptsStack
{
2017-09-17 14:10:32 +02:00
const u8 *ptr[8];
2017-09-04 21:43:13 +02:00
u8 size;
};
2017-09-17 17:14:32 +02:00
struct BattleCallbacksStack
{
void (*function[8])(void);
u8 size;
};
2017-09-22 21:33:49 +02:00
struct StatsArray
{
2019-04-04 21:24:21 +02:00
u16 stats[NUM_STATS];
2017-09-22 21:33:49 +02:00
};
2017-09-04 21:43:13 +02:00
struct BattleResources
{
2019-04-05 23:11:24 +02:00
struct SecretBase* secretBase;
2019-04-04 23:53:06 +02:00
struct ResourceFlags *flags;
2017-09-04 21:43:13 +02:00
struct BattleScriptsStack* battleScriptsStack;
2017-09-17 17:14:32 +02:00
struct BattleCallbacksStack* battleCallbackStack;
2019-04-04 21:24:21 +02:00
struct StatsArray* beforeLvlUp;
2017-09-04 21:43:13 +02:00
struct AI_ThinkingStruct *ai;
2022-01-13 17:28:27 +01:00
struct AiLogicData *aiData;
2017-09-04 21:43:13 +02:00
struct BattleHistory *battleHistory;
u8 bufferA[MAX_BATTLERS_COUNT][0x200];
u8 bufferB[MAX_BATTLERS_COUNT][0x200];
2017-09-04 21:43:13 +02:00
};
2020-12-11 16:05:00 +01:00
#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(gBattleResources->ai))
2022-01-13 17:28:27 +01:00
#define AI_DATA ((struct AiLogicData *)(gBattleResources->aiData))
2020-12-11 16:05:00 +01:00
#define BATTLE_HISTORY ((struct BattleHistory *)(gBattleResources->battleHistory))
2017-09-05 09:41:48 +02:00
struct BattleResults
{
u8 playerFaintCounter; // 0x0
u8 opponentFaintCounter; // 0x1
2017-09-25 00:09:13 +02:00
u8 playerSwitchesCounter; // 0x2
u8 numHealingItemsUsed; // 0x3
u8 numRevivesUsed; // 0x4
2018-12-24 00:02:29 +01:00
u8 playerMonWasDamaged:1; // 0x5
Decompile TV (#80) * ClearTVShowData * special_0x44 * DoTVShow (nonmatching because align) * DoTVShowBravoTrainerPokemonProfile * Update field names * DoTVShowBravoTrainerBattleTower * Renaming of struct fields * sub_80EBFF4 and UpdateTVScreensOnMap * SetTVMetatilesOnMap * Power buttons for the TV screens on the map * special_0x45 * sub_80EC18C * special_0x4a * ResetGabbyAndTy * GabbyAndTyBeforeInterview * GabbyAndTyAfterInterview * Through IsTVShowInSearchOfTrainersAiring * GabbyAndTyGetLastQuote * GabbyAndTyGetLastBattleTrivia * GabbyAndTySetScriptVarsToFieldObjectLocalIds * InterviewAfter; use TVShow as a precursor for making the individual show structs anonymous * Make TV structs anonymous within the union * Move the TV union to its own subheader * Move TV show enums to the global.tv.h subheader * Funcion renaming * Apply static attributes where able * PutPokemonTodayCaughtOnAir * sub_80EC8A4 * PutPokemonTodayFailedOnTheAir * sub_80EC9E8, sub_80ECA10 * sub_80ECA38 * sub_80ECB00 * Put3CheersForPokeblocksOnTheAir * PutFanClubSpecialOnTheAir * ContestLiveUpdates_BeforeInterview * Other before-interview Contest Live Updates functions * ContestLiveUpdates_BeforeInterview_5 * InterviewAfter_BravoTrainerPokemonProfile * BravoTrainerPokemonProfile_BeforeInterview1 * BravoTrainerPokemonProfile_BeforeInterview2 * Disassemble TV data * Decompile TV data * InterviewAfter_BravoTrainerBattleTowerProfile * SaveRecordedItemPurchasesForTVShow * PutNameRaterShowOnTheAir * StartMassOutbreak * PutLilycoveContestLadyShowOnTheAir * InterviewAfter_FanClubLetter * Rip TV strings * InterviewAfter_RecentHappenings * InterviewAfter_PkmnFanClubOpinions * sub_80ED718 * EndMassOutbreak * sub_80ED888 * sub_80ED8B4 * UpdateMassOutbreakTimeLeft * sub_80ED950 * PutFishingAdviceShowOnTheAir * through sub_80EDA80 * ewram and common syms are now fetched from the object files * BSS symbols are taken from the tv.o file * through sub_80EDC60 * sub_80EDCE8 * sub_80EDD78 * through sub_80EDE84 * nomatching sub_80EDE98 * sub_80EDFB4 * sub_80EE104 * sub_80EE104 * sub_80EE184 * sub_80EE2CC * sub_80EE35C * sub_80EE44C * sub_80EE4DC * sub_80EE5A4 * sub_80EE69C * sub_80EE72C * sub_80EE7C0 * sub_80EE818 * sub_80EE8C8 * sub_80EEA70 * sub_80EEB98 * sub_80EEBF4 * through sub_80EED60 * Functions relating to Pokemon News * sub_80EEF6C * GetPriceReduction * IsPriceDiscounted * sub_80EF120 * through sub_80EF370 * sub_80EF40C * HasMixableShowAlreadyBeenSpawnedWithPlayerID * TV_SortPurchasesByQuantity * FindActiveBroadcastByShowType_SetScriptResult * InterviewBefore * through sub_80EF88C * through sub_80EF93C * through sub_80EFA24 * through TV_BernoulliTrial * sub_80EFB58 * sub_80EFBA4 * sub_80EFBDC * through sub_80EFD98 * ChangePokemonNickname * ChangeBoxPokemonNickname * sub_80EFF9C * through player_id_to_dword * CheckForBigMovieOrEmergencyNewsOnTV * GetMomOrDadStringForTVMessage * sub_80F01E8 * sub_80F0358 * sub_80F049C * TV record mixing functions * sub_80F06D0 * sub_80F0708 nonmatching * through sub_80F0B24 * sub_80F0B64 * through sub_80F0C04 * sub_80F0C7C * sub_80F0D60 * sub_80F0E58 * sub_80F0E84 * through sub_80F0F24 * sub_80F0F64 * sub_80F1208 * sub_80F1254 * sub_80F1290 * sub_80F12A4 * sub_80F14F8 * DoTVShowTodaysSmartShopper * DoTVShowTheNameRaterShow * DoTVShowPokemonTodaySuccessfulCapture * DoTVShowPokemonTodayFailedCapture * DoTVShowPokemonFanClubLetter * DoTVShowRecentHappenings * DoTVShowPokemonFanClubOpinions * DoTVShowPokemonNewsMassOutbreak * DoTVShowPokemonContestLiveUpdates * DoTVShowPokemonBattleUpdate * DoTVShow3CheersForPokeblocks * DoTVShowInSearchOfTrainers * Label GabbyAndTyData fields; remove ddump comments from data/text/tv.inc * DoTVShowPokemonAngler * DoTVShowTheWorldOfMasters; update RAM symbols and field names * Decorate static functions * DoTVShowTodaysRivalTrainer; region map enums * TVDewfordTrendWatcherNetworkTextGroup * DoTVShowHoennTreasureInvestigators * DoTVShowFindThatGamer * DoTVShowBreakingNewsTV * DoTVShowSecretBaseVisit * DoTVShowPokemonLotterWinnerFlashReport * DoTVShowThePokemonBattleSeminar * DoTVShowTrainerFanClubSpecial, DoTVShowTrainerFanClub * DoTVShowSpotTheCuties * DoTVShowPokemonNewsBattleFrontier * DoTVShowWhatsNo1InHoennToday * Helpers for DoTVShowSecretBaseSecrets * DoTVShowSecretBaseSecrets * DoTVShowSafariFanClub * Finish decompilation of tv.s * Some renaming * Rename text group pointers * revoke statis; pokenews enums * Labels are number one * Label all TV struct fields * Make data/text/tv.inc more readable * Split data/text/tv.inc * Rename pokenews text pointers * Frontier Symbol constants; indicate static rodata objects with 's' prefix * Fix leading spaces/tabs F*** CLion sometimes * Fix inconsequential warning
2017-10-13 17:09:36 +02:00
u8 usedMasterBall:1; // 0x5
u8 caughtMonBall:4; // 0x5
2018-06-28 21:06:32 +02:00
u8 shinyWildMon:1; // 0x5
2017-10-06 00:12:01 +02:00
u16 playerMon1Species; // 0x6
2018-06-28 21:06:32 +02:00
u8 playerMon1Name[POKEMON_NAME_LENGTH + 1]; // 0x8
2017-09-05 09:41:48 +02:00
u8 battleTurnCounter; // 0x13
2018-06-28 21:06:32 +02:00
u8 playerMon2Name[POKEMON_NAME_LENGTH + 1]; // 0x14
u8 pokeblockThrows; // 0x1F
2017-09-05 09:41:48 +02:00
u16 lastOpponentSpecies; // 0x20
2017-10-06 00:12:01 +02:00
u16 lastUsedMovePlayer; // 0x22
u16 lastUsedMoveOpponent; // 0x24
u16 playerMon2Species; // 0x26
2017-09-28 15:34:21 +02:00
u16 caughtMonSpecies; // 0x28
2018-06-28 21:06:32 +02:00
u8 caughtMonNick[POKEMON_NAME_LENGTH + 1]; // 0x2A
u8 filler35; // 0x35
u8 catchAttempts[POKEBALL_COUNT - 1]; // 0x36 Doesn't include Master ball
2017-09-05 09:41:48 +02:00
};
2018-02-27 20:40:09 +01:00
struct BattleTv_Side
2018-02-27 18:13:28 +01:00
{
u32 spikesMonId:3;
u32 reflectMonId:3;
u32 lightScreenMonId:3;
u32 safeguardMonId:3;
u32 mistMonId:3;
u32 futureSightMonId:3;
u32 doomDesireMonId:3;
u32 perishSongMonId:3;
u32 wishMonId:3;
u32 grudgeMonId:3;
2018-02-27 20:40:09 +01:00
u32 usedMoveSlot:2;
2018-02-27 18:13:28 +01:00
u32 spikesMoveSlot:2;
u32 reflectMoveSlot:2;
u32 lightScreenMoveSlot:2;
u32 safeguardMoveSlot:2;
u32 mistMoveSlot:2;
u32 futureSightMoveSlot:2;
u32 doomDesireMoveSlot:2;
u32 perishSongMoveSlot:2;
u32 wishMoveSlot:2;
u32 grudgeMoveSlot:2;
u32 destinyBondMonId:3;
u32 destinyBondMoveSlot:2;
2018-02-27 20:40:09 +01:00
u32 faintCause:4;
u32 faintCauseMonId:3;
2018-02-27 18:13:28 +01:00
u32 explosion:1;
u32 explosionMoveSlot:2;
u32 explosionMonId:3;
u32 perishSong:1;
};
2018-02-27 20:40:09 +01:00
struct BattleTv_Position
2018-02-27 18:13:28 +01:00
{
u32 curseMonId:3;
u32 leechSeedMonId:3;
u32 nightmareMonId:3;
u32 wrapMonId:3;
u32 attractMonId:3;
u32 confusionMonId:3;
u32 curseMoveSlot:2;
u32 leechSeedMoveSlot:2;
u32 nightmareMoveSlot:2;
u32 wrapMoveSlot:2;
u32 attractMoveSlot:2;
u32 confusionMoveSlot:2;
u32 waterSportMoveSlot:2;
u32 waterSportMonId:3;
u32 mudSportMonId:3;
u32 mudSportMoveSlot:2;
u32 ingrainMonId:3;
u32 ingrainMoveSlot:2;
2018-02-27 20:40:09 +01:00
u32 attackedByMonId:3;
u32 attackedByMoveSlot:2;
2018-02-27 18:13:28 +01:00
};
2018-02-27 20:40:09 +01:00
struct BattleTv_Mon
2018-02-27 18:13:28 +01:00
{
u32 psnMonId:3;
u32 badPsnMonId:3;
u32 brnMonId:3;
u32 prlzMonId:3;
u32 slpMonId:3;
u32 frzMonId:3;
u32 psnMoveSlot:2;
u32 badPsnMoveSlot:2;
u32 brnMoveSlot:2;
u32 prlzMoveSlot:2;
u32 slpMoveSlot:2;
u32 frzMoveSlot:2;
};
2018-02-27 20:40:09 +01:00
struct BattleTv
2018-02-27 18:13:28 +01:00
{
2018-07-01 11:15:42 +02:00
struct BattleTv_Mon mon[2][PARTY_SIZE]; // [side][partyId]
2018-02-27 20:40:09 +01:00
struct BattleTv_Position pos[2][2]; // [side][flank]
struct BattleTv_Side side[2]; // [side]
2018-02-27 18:13:28 +01:00
};
2018-02-27 20:40:09 +01:00
struct BattleTvMovePoints
2018-02-27 18:13:28 +01:00
{
2018-02-27 20:40:09 +01:00
s16 points[2][PARTY_SIZE * 4];
2018-02-27 18:13:28 +01:00
};
2021-03-15 20:22:41 +01:00
struct LinkBattlerHeader
{
2021-03-12 22:55:58 +01:00
u8 versionSignatureLo;
u8 versionSignatureHi;
u8 vsScreenHealthFlagsLo;
u8 vsScreenHealthFlagsHi;
struct BattleEnigmaBerry battleEnigmaBerry;
};
struct MegaEvolutionData
{
u8 toEvolve; // As flags using gBitTable.
u8 evolvedPartyIds[2]; // As flags using gBitTable;
bool8 alreadyEvolved[4]; // Array id is used for mon position.
u16 evolvedSpecies[MAX_BATTLERS_COUNT];
u16 playerEvolvedSpecies;
2021-08-25 08:35:21 +02:00
u8 primalRevertedPartyIds[2]; // As flags using gBitTable;
u16 primalRevertedSpecies[MAX_BATTLERS_COUNT];
u16 playerPrimalRevertedSpecies;
u8 battlerId;
bool8 playerSelect;
u8 triggerSpriteId;
2020-11-07 13:53:34 +01:00
bool8 isWishMegaEvo;
};
2019-08-08 13:06:55 +02:00
struct Illusion
{
u8 on;
u8 set;
u8 broken;
u8 partyId;
2019-08-08 13:06:55 +02:00
struct Pokemon *mon;
};
2020-11-26 21:56:18 +01:00
struct ZMoveData
{
2020-12-01 22:36:44 +01:00
u8 viable:1; // current move can become a z move
u8 viewing:1; // if player is viewing the z move name instead of regular moves
u8 active:1; // is z move being used this turn
u8 zStatusActive:1;
u8 healReplacement:1;
u8 activeSplit:2; // active z move split
u8 zUnused:1;
u8 triggerSpriteId;
u8 possibleZMoves[MAX_BATTLERS_COUNT];
u16 chosenZMove; // z move of move cursor is on
u8 effect;
u8 used[MAX_BATTLERS_COUNT]; //one per bank for multi-battles
u16 toBeUsed[MAX_BATTLERS_COUNT]; // z moves per battler to be used
u16 baseMoves[MAX_BATTLERS_COUNT];
u8 splits[MAX_BATTLERS_COUNT];
2020-12-01 19:43:15 +01:00
};
2020-11-26 21:56:18 +01:00
struct StolenItem
{
u16 originalItem:15;
u16 stolen:1;
};
2017-09-05 09:41:48 +02:00
struct BattleStruct
{
2017-09-17 14:10:32 +02:00
u8 turnEffectsTracker;
2018-02-07 22:53:40 +01:00
u8 turnEffectsBattlerId;
u8 turnCountersTracker;
2019-01-27 13:52:02 +01:00
u16 wrappedMove[MAX_BATTLERS_COUNT];
2021-10-16 22:10:45 +02:00
u16 moveTarget[MAX_BATTLERS_COUNT];
2018-02-07 22:53:40 +01:00
u8 expGetterMonId;
2017-09-05 09:41:48 +02:00
u8 wildVictorySong;
u8 dynamicMoveType;
2018-10-14 18:10:54 +02:00
u8 wrappedBy[MAX_BATTLERS_COUNT];
u16 assistPossibleMoves[PARTY_SIZE * MAX_MON_MOVES]; // Each of mons can know max 4 moves.
2018-02-07 22:53:40 +01:00
u8 focusPunchBattlerId;
2018-07-07 19:57:09 +02:00
u8 battlerPreventingSwitchout;
u8 moneyMultiplier:6;
u8 moneyMultiplierItem:1;
u8 moneyMultiplierMove:1;
u8 savedTurnActionNumber;
2017-10-02 23:32:39 +02:00
u8 switchInAbilitiesCounter;
2017-12-02 14:08:55 +01:00
u8 faintedActionsState;
2018-02-07 22:53:40 +01:00
u8 faintedActionsBattlerId;
2021-06-03 23:17:44 +02:00
u32 expValue;
2017-09-11 14:42:13 +02:00
u8 field_52;
2017-09-22 21:33:49 +02:00
u8 sentInPokes;
2018-02-06 02:46:59 +01:00
bool8 selectionScriptFinished[MAX_BATTLERS_COUNT];
u8 battlerPartyIndexes[MAX_BATTLERS_COUNT];
2018-02-06 02:46:59 +01:00
u8 monToSwitchIntoId[MAX_BATTLERS_COUNT];
u8 battlerPartyOrders[MAX_BATTLERS_COUNT][PARTY_SIZE / 2];
2017-10-06 00:12:01 +02:00
u8 runTries;
2018-10-14 18:10:54 +02:00
u8 caughtMonNick[POKEMON_NAME_LENGTH + 1];
2018-07-01 11:15:42 +02:00
u8 safariGoNearCounter;
u8 safariPkblThrowCounter;
u8 safariEscapeFactor;
u8 safariCatchFactor;
u8 linkBattleVsSpriteId_V; // The letter "V"
u8 linkBattleVsSpriteId_S; // The letter "S"
u8 formToChangeInto;
2018-02-06 02:46:59 +01:00
u8 chosenMovePositions[MAX_BATTLERS_COUNT];
u8 stateIdAfterSelScript[MAX_BATTLERS_COUNT];
2021-01-23 02:03:21 +01:00
u8 prevSelectedPartySlot;
2017-10-07 15:15:47 +02:00
u8 stringMoveType;
2018-02-07 22:53:40 +01:00
u8 expGetterBattlerId;
u8 absentBattlerFlags;
2020-07-17 02:12:12 +02:00
u8 palaceFlags; // First 4 bits are "is < 50% HP and not asleep" for each battler, last 4 bits are selected moves to pass to AI
2018-12-24 00:02:29 +01:00
u8 field_93; // related to choosing pokemon?
2017-10-24 21:45:41 +02:00
u8 wallyBattleState;
u8 wallyMovesState;
u8 wallyWaitFrames;
u8 wallyMoveFrames;
2019-01-27 13:52:02 +01:00
u16 lastTakenMove[MAX_BATTLERS_COUNT]; // Last move that a battler was hit with.
2017-10-01 01:12:42 +02:00
u16 hpOnSwitchout[2];
u32 savedBattleTypeFlags;
u16 abilityPreventingSwitchout;
u8 hpScale;
2019-06-25 13:04:14 +02:00
u16 synchronizeMoveEffect;
2018-02-27 20:40:09 +01:00
bool8 anyMonHasTransformed;
2017-10-01 01:12:42 +02:00
void (*savedCallback)(void);
2021-10-28 23:52:52 +02:00
u16 usedHeldItems[PARTY_SIZE][2]; // For each party member and side. For harvest, recycle
2019-01-27 13:52:02 +01:00
u16 chosenItem[MAX_BATTLERS_COUNT];
2017-10-11 12:49:42 +02:00
u8 AI_itemType[2];
u8 AI_itemFlags[2];
2018-02-06 02:46:59 +01:00
u16 choicedMove[MAX_BATTLERS_COUNT];
u16 changedItems[MAX_BATTLERS_COUNT];
2018-07-01 11:15:42 +02:00
u8 intimidateBattler;
2017-10-02 23:32:39 +02:00
u8 switchInItemsCounter;
2018-12-07 23:50:56 +01:00
u8 arenaTurnCounter;
2017-09-17 14:10:32 +02:00
u8 turnSideTracker;
2018-12-07 23:50:56 +01:00
u8 givenExpMons; // Bits for enemy party's pokemon that gave exp to player's party.
2019-01-27 13:52:02 +01:00
u16 lastTakenMoveFrom[MAX_BATTLERS_COUNT][MAX_BATTLERS_COUNT]; // a 2-D array [target][attacker]
2021-10-04 16:21:03 +02:00
u16 castformPalette[NUM_CASTFORM_FORMS][16];
union {
2021-03-15 20:22:41 +01:00
struct LinkBattlerHeader linkBattlerHeader;
u32 battleVideo[2];
} multiBuffer;
2017-12-02 14:08:55 +01:00
u8 wishPerishSongState;
2018-02-07 22:53:40 +01:00
u8 wishPerishSongBattlerId;
2017-10-02 23:32:39 +02:00
bool8 overworldWeatherDone;
2020-12-14 03:42:48 +01:00
bool8 terrainDone;
2017-09-17 14:10:32 +02:00
u8 atkCancellerTracker;
2018-02-27 20:40:09 +01:00
struct BattleTvMovePoints tvMovePoints;
struct BattleTv tv;
2018-02-06 02:46:59 +01:00
u8 AI_monToSwitchIntoId[MAX_BATTLERS_COUNT];
2018-11-11 18:33:16 +01:00
s8 arenaMindPoints[2];
s8 arenaSkillPoints[2];
u16 arenaStartHp[2];
u8 arenaLostPlayerMons; // Bits for party member, lost as in referee's decision, not by fainting.
u8 arenaLostOpponentMons;
u8 alreadyStatusedMoveAttempt; // As bits for battlers; For example when using Thunder Wave on an already paralyzed pokemon.
2018-07-13 23:00:56 +02:00
u8 debugBattler;
2018-07-14 22:56:03 +02:00
u8 magnitudeBasePower;
u8 presentBasePower;
2018-07-19 21:18:20 +02:00
u8 roostTypes[MAX_BATTLERS_COUNT][3];
2018-07-24 22:09:55 +02:00
u8 savedBattlerTarget;
2018-07-28 18:41:57 +02:00
bool8 ateBoost[MAX_BATTLERS_COUNT];
2018-09-29 12:47:35 +02:00
u8 activeAbilityPopUps; // as bits for each battler
2020-12-06 05:04:12 +01:00
u8 abilityPopUpSpriteIds[MAX_BATTLERS_COUNT][2]; // two per battler
bool8 throwingPokeBall;
struct MegaEvolutionData mega;
2020-11-26 21:56:18 +01:00
struct ZMoveData zmove;
2018-11-03 01:17:16 +01:00
const u8 *trainerSlideMsg;
bool8 trainerSlideLowHpMsgDone;
u8 introState;
2019-02-01 14:17:24 +01:00
u8 ateBerry[2]; // array id determined by side, each party pokemon as bit
2019-02-14 12:15:53 +01:00
u8 stolenStats[NUM_BATTLE_STATS]; // hp byte is used for which stats to raise, other inform about by how many stages
u8 lastMoveFailed; // as bits for each battler, for the sake of Stomping Tantrum
u8 lastMoveTarget[MAX_BATTLERS_COUNT]; // The last target on which each mon used a move, for the sake of Instruct
2019-04-13 14:56:26 +02:00
u8 debugHoldEffects[MAX_BATTLERS_COUNT]; // These override actual items' hold effects.
u16 tracedAbility[MAX_BATTLERS_COUNT];
2020-04-12 12:41:26 +02:00
u16 hpBefore[MAX_BATTLERS_COUNT]; // Hp of battlers before using a move. For Berserk
2019-08-08 13:06:55 +02:00
bool8 spriteIgnore0Hp;
struct Illusion illusion[MAX_BATTLERS_COUNT];
2020-04-14 13:40:27 +02:00
s8 aiFinalScore[MAX_BATTLERS_COUNT][MAX_BATTLERS_COUNT][MAX_MON_MOVES]; // AI, target, moves to make debugging easier
u8 aiMoveOrAction[MAX_BATTLERS_COUNT];
u8 aiChosenTarget[MAX_BATTLERS_COUNT];
2020-04-18 19:59:09 +02:00
u8 soulheartBattlerId;
u8 friskedBattler; // Frisk needs to identify 2 battlers in double battles.
bool8 friskedAbility; // If identifies two mons, show the ability pop-up only once.
2020-04-22 12:49:25 +02:00
u8 sameMoveTurns[MAX_BATTLERS_COUNT]; // For Metronome, number of times the same moves has been SUCCESFULLY used.
2020-06-25 16:15:11 +02:00
u16 moveEffect2; // For Knock Off
2020-07-16 15:40:56 +02:00
u16 changedSpecies[PARTY_SIZE]; // For Zygarde or future forms when multiple mons can change into the same pokemon.
u8 quickClawBattlerId;
2021-08-12 07:26:13 +02:00
struct StolenItem itemStolen[PARTY_SIZE]; // Player's team that had items stolen (two bytes per party member)
2021-09-02 21:33:42 +02:00
u8 blunderPolicy:1; // should blunder policy activate
2021-06-25 21:37:59 +02:00
u8 ballSpriteIds[2]; // item gfx, window gfx
u8 stickyWebUser;
u8 appearedInBattle; // Bitfield to track which Pokemon appeared in battle. Used for Burmy's form change
2021-11-20 20:44:48 +01:00
u8 skyDropTargets[MAX_BATTLERS_COUNT]; // For Sky Drop, to account for if multiple Pokemon use Sky Drop in a double battle.
2017-09-05 09:41:48 +02:00
};
2021-10-04 16:21:03 +02:00
#define F_DYNAMIC_TYPE_1 (1 << 6)
#define F_DYNAMIC_TYPE_2 (1 << 7)
#define DYNAMIC_TYPE_MASK (F_DYNAMIC_TYPE_1 - 1)
#define GET_MOVE_TYPE(move, typeArg) \
{ \
if (gBattleStruct->dynamicMoveType) \
typeArg = gBattleStruct->dynamicMoveType & DYNAMIC_TYPE_MASK; \
else \
typeArg = gBattleMoves[move].type; \
}
#define IS_MOVE_PHYSICAL(move)(GetBattleMoveSplit(move) == SPLIT_PHYSICAL)
#define IS_MOVE_SPECIAL(move)(GetBattleMoveSplit(move) == SPLIT_SPECIAL)
#define IS_MOVE_STATUS(move)(gBattleMoves[move].split == SPLIT_STATUS)
2018-02-08 11:17:41 +01:00
2018-07-14 22:56:03 +02:00
#define BATTLER_MAX_HP(battlerId)(gBattleMons[battlerId].hp == gBattleMons[battlerId].maxHP)
2018-03-01 00:59:52 +01:00
#define TARGET_TURN_DAMAGED ((gSpecialStatuses[gBattlerTarget].physicalDmg != 0 || gSpecialStatuses[gBattlerTarget].specialDmg != 0))
#define BATTLER_DAMAGED(battlerId) ((gSpecialStatuses[battlerId].physicalDmg != 0 || gSpecialStatuses[battlerId].specialDmg != 0))
2018-03-01 00:59:52 +01:00
#define IS_BATTLER_OF_TYPE(battlerId, type)((gBattleMons[battlerId].type1 == type || gBattleMons[battlerId].type2 == type || (gBattleMons[battlerId].type3 != TYPE_MYSTERY && gBattleMons[battlerId].type3 == type)))
2018-11-17 12:10:24 +01:00
#define SET_BATTLER_TYPE(battlerId, type) \
{ \
gBattleMons[battlerId].type1 = type; \
gBattleMons[battlerId].type2 = type; \
gBattleMons[battlerId].type3 = TYPE_MYSTERY; \
2018-03-01 00:59:52 +01:00
}
#define IS_BATTLER_PROTECTED(battlerId)(gProtectStructs[battlerId].protected \
|| gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_WIDE_GUARD \
|| gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_QUICK_GUARD \
|| gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_CRAFTY_SHIELD \
|| gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_MAT_BLOCK \
|| gProtectStructs[battlerId].spikyShielded \
|| gProtectStructs[battlerId].kingsShielded \
|| gProtectStructs[battlerId].banefulBunkered \
|| gProtectStructs[battlerId].obstructed) \
#define GET_STAT_BUFF_ID(n)((n & 7)) // first three bits 0x1, 0x2, 0x4
#define GET_STAT_BUFF_VALUE_WITH_SIGN(n)((n & 0xF8))
#define GET_STAT_BUFF_VALUE(n)(((n >> 3) & 0xF)) // 0x8, 0x10, 0x20, 0x40
2017-09-22 21:33:49 +02:00
#define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit
#define SET_STAT_BUFF_VALUE(n)((((n) << 3) & 0xF8))
2019-03-23 16:33:08 +01:00
#define SET_STATCHANGER(statId, stage, goesDown)(gBattleScripting.statChanger = (statId) + ((stage) << 3) + (goesDown << 7))
2020-04-19 15:44:44 +02:00
#define SET_STATCHANGER2(dst, statId, stage, goesDown)(dst = (statId) + ((stage) << 3) + (goesDown << 7))
2017-11-26 11:55:17 +01:00
2021-10-13 22:39:21 +02:00
// NOTE: The members of this struct have hard-coded offsets
// in include/constants/battle_script_commands.h
2017-09-05 09:41:48 +02:00
struct BattleScripting
{
2017-09-26 22:39:59 +02:00
s32 painSplitHp;
s32 bideDmg;
u8 multihitString[6];
2018-08-03 18:01:14 +02:00
bool8 expOnCatch;
u8 twoTurnsMoveStringId;
2017-09-17 14:10:32 +02:00
u8 animArg1;
u8 animArg2;
u16 tripleKickPower;
2019-08-23 14:46:21 +02:00
u8 moveendState;
2020-04-19 15:44:44 +02:00
u8 savedStatChanger; // For further use, if attempting to change stat two times(ex. Moody)
u8 shiftSwitched; // When the game tells you the next enemy's pokemon and you switch. Option for noobs but oh well.
2018-02-06 02:46:59 +01:00
u8 battler;
2017-09-20 00:28:00 +02:00
u8 animTurn;
u8 animTargetsHit;
2017-09-17 17:14:32 +02:00
u8 statChanger;
2018-07-29 15:33:16 +02:00
bool8 statAnimPlayed;
2019-08-23 14:46:21 +02:00
u8 getexpState;
2017-10-02 23:32:39 +02:00
u8 battleStyle;
2019-08-23 14:46:21 +02:00
u8 drawlvlupboxState;
2017-09-25 00:09:13 +02:00
u8 learnMoveState;
u8 savedBattler;
2017-10-09 18:18:40 +02:00
u8 reshowMainState;
u8 reshowHelperState;
u8 levelUpHP;
2021-10-04 16:21:03 +02:00
u8 windowsType; // B_WIN_TYPE_*
2017-10-01 01:12:42 +02:00
u8 multiplayerId;
2018-10-21 20:13:12 +02:00
u8 specialTrainerBattleType;
2018-08-03 18:01:14 +02:00
bool8 monCaught;
s32 savedDmg;
2019-02-14 13:17:27 +01:00
u16 savedMoveEffect; // For moves hitting multiple targets.
u16 moveEffect;
u16 multihitMoveEffect;
u8 illusionNickHack; // To properly display nick in STRINGID_ENEMYABOUTTOSWITCHPKMN.
2021-09-02 21:33:42 +02:00
bool8 fixedPopup; // Force ability popup to stick until manually called back
u16 abilityPopupOverwrite;
2021-09-02 21:33:42 +02:00
u8 switchCase; // Special switching conditions, eg. red card
2021-07-25 22:55:52 +02:00
u8 overrideBerryRequirements;
u8 stickyWebStatDrop; // To prevent Defiant activating on a Court Change'd Sticky Web
2017-09-05 09:41:48 +02:00
};
2017-10-01 18:54:01 +02:00
struct BattleSpriteInfo
{
2018-06-20 23:07:51 +02:00
u16 invisible:1; // 0x1
u16 lowHpSong:1; // 0x2
u16 behindSubstitute:1; // 0x4
u16 flag_x8:1; // 0x8
u16 hpNumbersNoBars:1; // 0x10
2017-10-01 18:54:01 +02:00
u16 transformSpecies;
};
struct BattleAnimationInfo
{
2017-11-04 16:11:13 +01:00
u16 animArg; // to fill up later
2017-10-18 21:42:00 +02:00
u8 field_2;
u8 field_3;
u8 field_4;
u8 field_5;
u8 field_6;
u8 field_7;
u8 ballThrowCaseId:6;
u8 isCriticalCapture:1;
u8 criticalCaptureSuccess:1;
2021-01-23 02:03:21 +01:00
u8 introAnimActive:1;
u8 wildMonInvisible:1;
2018-06-20 23:07:51 +02:00
u8 field_9_x1C:3;
u8 field_9_x20:1;
u8 field_9_x40:1;
u8 field_9_x80:1;
u8 numBallParticles;
2017-11-02 18:19:49 +01:00
u8 field_B;
s16 ballSubpx;
2017-11-02 18:19:49 +01:00
u8 field_E;
u8 field_F;
2017-10-01 18:54:01 +02:00
};
2017-10-02 23:32:39 +02:00
struct BattleHealthboxInfo
{
2018-06-28 21:06:32 +02:00
u8 partyStatusSummaryShown:1;
2018-06-20 23:07:51 +02:00
u8 healthboxIsBouncing:1;
u8 battlerIsBouncing:1;
u8 ballAnimActive:1; // 0x8
u8 statusAnimActive:1; // x10
u8 animFromTableActive:1; // x20
2018-06-28 21:06:32 +02:00
u8 specialAnimActive:1; // x40
2020-08-30 21:11:44 +02:00
u8 triedShinyMonAnim:1;
u8 finishedShinyMonAnim:1;
2018-06-20 23:07:51 +02:00
u8 field_1_x1E:4;
2021-01-23 02:03:21 +01:00
u8 bgmRestored:1;
u8 waitForCry:1;
u8 healthboxSlideInStarted:1;
2018-06-20 23:07:51 +02:00
u8 healthboxBounceSpriteId;
u8 battlerBounceSpriteId;
2017-10-22 18:43:15 +02:00
u8 animationState;
2021-01-23 02:03:21 +01:00
u8 partyStatusDelayTimer;
2018-12-18 05:08:08 +01:00
u8 matrixNum;
2017-11-04 16:11:13 +01:00
u8 shadowSpriteId;
2021-01-23 02:03:21 +01:00
u8 soundTimer;
u8 introEndDelay;
2017-10-02 23:32:39 +02:00
u8 field_A;
u8 field_B;
};
2017-10-16 18:12:27 +02:00
struct BattleBarInfo
{
u8 healthboxSpriteId;
2017-10-19 15:28:41 +02:00
s32 maxValue;
2018-06-19 00:43:15 +02:00
s32 oldValue;
2017-10-22 18:43:15 +02:00
s32 receivedValue;
2018-06-19 00:43:15 +02:00
s32 currValue;
2017-10-16 18:12:27 +02:00
};
2017-10-01 18:54:01 +02:00
struct BattleSpriteData
{
2018-02-06 23:09:39 +01:00
struct BattleSpriteInfo *battlerData;
2017-10-02 23:32:39 +02:00
struct BattleHealthboxInfo *healthBoxesData;
2017-10-01 18:54:01 +02:00
struct BattleAnimationInfo *animationData;
2017-10-16 18:12:27 +02:00
struct BattleBarInfo *battleBars;
2017-10-01 18:54:01 +02:00
};
2017-09-11 18:27:54 +02:00
#include "sprite.h"
2017-10-01 01:12:42 +02:00
struct MonSpritesGfx
2017-09-11 11:35:41 +02:00
{
void* firstDecompressed; // ptr to the decompressed sprite of the first pokemon
2021-10-03 05:47:59 +02:00
union {
2022-01-20 16:25:48 +01:00
void* ptr[MAX_BATTLERS_COUNT];
u8* byte[MAX_BATTLERS_COUNT];
} sprites;
2021-10-03 05:47:59 +02:00
struct SpriteTemplate templates[MAX_BATTLERS_COUNT];
struct SpriteFrameImage frameImages[MAX_BATTLERS_COUNT][4];
u8 unusedArr[0x80];
2017-11-04 16:11:13 +01:00
u8 *barFontGfx;
2021-10-03 05:47:59 +02:00
void *unusedPtr;
2020-02-20 06:04:42 +01:00
u16 *buffer;
2017-09-11 11:35:41 +02:00
};
2020-11-19 18:35:37 +01:00
struct TotemBoost
{
u8 stats; // bitfield for each battle stat that is set if the stat changes
s8 statChanges[NUM_BATTLE_STATS - 1]; // highest bit being set decreases the stat
2020-11-19 18:35:37 +01:00
}; /* size = 8 */
2018-06-30 15:35:54 +02:00
// All battle variables are declared in battle_main.c
2018-11-19 17:36:39 +01:00
extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y;
extern u16 gBattle_BG1_X;
extern u16 gBattle_BG1_Y;
extern u16 gBattle_BG2_X;
extern u16 gBattle_BG2_Y;
extern u16 gBattle_BG3_X;
extern u16 gBattle_BG3_Y;
extern u16 gBattle_WIN0H;
extern u16 gBattle_WIN0V;
extern u16 gBattle_WIN1H;
extern u16 gBattle_WIN1V;
2018-12-01 11:12:31 +01:00
extern u8 gDisplayedStringBattle[400];
2018-06-30 15:35:54 +02:00
extern u8 gBattleTextBuff1[TEXT_BUFF_ARRAY_COUNT];
extern u8 gBattleTextBuff2[TEXT_BUFF_ARRAY_COUNT];
2020-12-01 22:36:44 +01:00
extern u8 gBattleTextBuff3[30]; //to handle stupidly large z move names
Decompile TV (#80) * ClearTVShowData * special_0x44 * DoTVShow (nonmatching because align) * DoTVShowBravoTrainerPokemonProfile * Update field names * DoTVShowBravoTrainerBattleTower * Renaming of struct fields * sub_80EBFF4 and UpdateTVScreensOnMap * SetTVMetatilesOnMap * Power buttons for the TV screens on the map * special_0x45 * sub_80EC18C * special_0x4a * ResetGabbyAndTy * GabbyAndTyBeforeInterview * GabbyAndTyAfterInterview * Through IsTVShowInSearchOfTrainersAiring * GabbyAndTyGetLastQuote * GabbyAndTyGetLastBattleTrivia * GabbyAndTySetScriptVarsToFieldObjectLocalIds * InterviewAfter; use TVShow as a precursor for making the individual show structs anonymous * Make TV structs anonymous within the union * Move the TV union to its own subheader * Move TV show enums to the global.tv.h subheader * Funcion renaming * Apply static attributes where able * PutPokemonTodayCaughtOnAir * sub_80EC8A4 * PutPokemonTodayFailedOnTheAir * sub_80EC9E8, sub_80ECA10 * sub_80ECA38 * sub_80ECB00 * Put3CheersForPokeblocksOnTheAir * PutFanClubSpecialOnTheAir * ContestLiveUpdates_BeforeInterview * Other before-interview Contest Live Updates functions * ContestLiveUpdates_BeforeInterview_5 * InterviewAfter_BravoTrainerPokemonProfile * BravoTrainerPokemonProfile_BeforeInterview1 * BravoTrainerPokemonProfile_BeforeInterview2 * Disassemble TV data * Decompile TV data * InterviewAfter_BravoTrainerBattleTowerProfile * SaveRecordedItemPurchasesForTVShow * PutNameRaterShowOnTheAir * StartMassOutbreak * PutLilycoveContestLadyShowOnTheAir * InterviewAfter_FanClubLetter * Rip TV strings * InterviewAfter_RecentHappenings * InterviewAfter_PkmnFanClubOpinions * sub_80ED718 * EndMassOutbreak * sub_80ED888 * sub_80ED8B4 * UpdateMassOutbreakTimeLeft * sub_80ED950 * PutFishingAdviceShowOnTheAir * through sub_80EDA80 * ewram and common syms are now fetched from the object files * BSS symbols are taken from the tv.o file * through sub_80EDC60 * sub_80EDCE8 * sub_80EDD78 * through sub_80EDE84 * nomatching sub_80EDE98 * sub_80EDFB4 * sub_80EE104 * sub_80EE104 * sub_80EE184 * sub_80EE2CC * sub_80EE35C * sub_80EE44C * sub_80EE4DC * sub_80EE5A4 * sub_80EE69C * sub_80EE72C * sub_80EE7C0 * sub_80EE818 * sub_80EE8C8 * sub_80EEA70 * sub_80EEB98 * sub_80EEBF4 * through sub_80EED60 * Functions relating to Pokemon News * sub_80EEF6C * GetPriceReduction * IsPriceDiscounted * sub_80EF120 * through sub_80EF370 * sub_80EF40C * HasMixableShowAlreadyBeenSpawnedWithPlayerID * TV_SortPurchasesByQuantity * FindActiveBroadcastByShowType_SetScriptResult * InterviewBefore * through sub_80EF88C * through sub_80EF93C * through sub_80EFA24 * through TV_BernoulliTrial * sub_80EFB58 * sub_80EFBA4 * sub_80EFBDC * through sub_80EFD98 * ChangePokemonNickname * ChangeBoxPokemonNickname * sub_80EFF9C * through player_id_to_dword * CheckForBigMovieOrEmergencyNewsOnTV * GetMomOrDadStringForTVMessage * sub_80F01E8 * sub_80F0358 * sub_80F049C * TV record mixing functions * sub_80F06D0 * sub_80F0708 nonmatching * through sub_80F0B24 * sub_80F0B64 * through sub_80F0C04 * sub_80F0C7C * sub_80F0D60 * sub_80F0E58 * sub_80F0E84 * through sub_80F0F24 * sub_80F0F64 * sub_80F1208 * sub_80F1254 * sub_80F1290 * sub_80F12A4 * sub_80F14F8 * DoTVShowTodaysSmartShopper * DoTVShowTheNameRaterShow * DoTVShowPokemonTodaySuccessfulCapture * DoTVShowPokemonTodayFailedCapture * DoTVShowPokemonFanClubLetter * DoTVShowRecentHappenings * DoTVShowPokemonFanClubOpinions * DoTVShowPokemonNewsMassOutbreak * DoTVShowPokemonContestLiveUpdates * DoTVShowPokemonBattleUpdate * DoTVShow3CheersForPokeblocks * DoTVShowInSearchOfTrainers * Label GabbyAndTyData fields; remove ddump comments from data/text/tv.inc * DoTVShowPokemonAngler * DoTVShowTheWorldOfMasters; update RAM symbols and field names * Decorate static functions * DoTVShowTodaysRivalTrainer; region map enums * TVDewfordTrendWatcherNetworkTextGroup * DoTVShowHoennTreasureInvestigators * DoTVShowFindThatGamer * DoTVShowBreakingNewsTV * DoTVShowSecretBaseVisit * DoTVShowPokemonLotterWinnerFlashReport * DoTVShowThePokemonBattleSeminar * DoTVShowTrainerFanClubSpecial, DoTVShowTrainerFanClub * DoTVShowSpotTheCuties * DoTVShowPokemonNewsBattleFrontier * DoTVShowWhatsNo1InHoennToday * Helpers for DoTVShowSecretBaseSecrets * DoTVShowSecretBaseSecrets * DoTVShowSafariFanClub * Finish decompilation of tv.s * Some renaming * Rename text group pointers * revoke statis; pokenews enums * Labels are number one * Label all TV struct fields * Make data/text/tv.inc more readable * Split data/text/tv.inc * Rename pokenews text pointers * Frontier Symbol constants; indicate static rodata objects with 's' prefix * Fix leading spaces/tabs F*** CLion sometimes * Fix inconsequential warning
2017-10-13 17:09:36 +02:00
extern u32 gBattleTypeFlags;
2018-02-07 23:21:51 +01:00
extern u8 gBattleTerrain;
extern u32 gUnusedFirstBattleVar1;
2021-10-04 16:21:03 +02:00
extern u8 *gBattleAnimBgTileBuffer;
extern u8 *gBattleAnimBgTilemapBuffer;
2018-02-07 23:21:51 +01:00
extern u8 gActiveBattler;
extern u32 gBattleControllerExecFlags;
extern u8 gBattlersCount;
extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gBattlerPositions[MAX_BATTLERS_COUNT];
extern u8 gActionsByTurnOrder[MAX_BATTLERS_COUNT];
2018-06-28 21:06:32 +02:00
extern u8 gBattlerByTurnOrder[MAX_BATTLERS_COUNT];
2018-02-07 23:21:51 +01:00
extern u8 gCurrentTurnActionNumber;
extern u8 gCurrentActionFuncId;
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern u8 gBattlerSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gCurrMovePos;
2018-02-08 11:17:41 +01:00
extern u8 gChosenMovePos;
2018-02-07 23:21:51 +01:00
extern u16 gCurrentMove;
extern u16 gChosenMove;
2018-09-22 18:41:00 +02:00
extern u16 gCalledMove;
2018-02-07 23:21:51 +01:00
extern s32 gBattleMoveDamage;
extern s32 gHpDealt;
extern s32 gTakenDmg[MAX_BATTLERS_COUNT];
extern u16 gLastUsedItem;
extern u16 gLastUsedAbility;
2018-02-07 23:21:51 +01:00
extern u8 gBattlerAttacker;
extern u8 gBattlerTarget;
2018-02-08 11:17:41 +01:00
extern u8 gBattlerFainted;
extern u8 gEffectBattler;
2018-02-08 12:13:29 +01:00
extern u8 gPotentialItemEffectBattler;
2018-02-07 23:21:51 +01:00
extern u8 gAbsentBattlerFlags;
2018-07-14 22:56:03 +02:00
extern u8 gIsCriticalHit;
2018-02-07 23:21:51 +01:00
extern u8 gMultiHitCounter;
extern const u8 *gBattlescriptCurrInstr;
extern u8 gChosenActionByBattler[MAX_BATTLERS_COUNT];
extern const u8 *gSelectionBattleScripts[MAX_BATTLERS_COUNT];
extern const u8 *gPalaceSelectionBattleScripts[MAX_BATTLERS_COUNT];
extern u16 gLastPrintedMoves[MAX_BATTLERS_COUNT];
extern u16 gLastMoves[MAX_BATTLERS_COUNT];
extern u16 gLastLandedMoves[MAX_BATTLERS_COUNT];
extern u16 gLastHitByType[MAX_BATTLERS_COUNT];
extern u16 gLastResultingMoves[MAX_BATTLERS_COUNT];
extern u16 gLockedMoves[MAX_BATTLERS_COUNT];
2018-09-22 18:37:03 +02:00
extern u16 gLastUsedMove;
2018-02-07 23:21:51 +01:00
extern u8 gLastHitBy[MAX_BATTLERS_COUNT];
extern u16 gChosenMoveByBattler[MAX_BATTLERS_COUNT];
2018-07-21 15:11:13 +02:00
extern u16 gMoveResultFlags;
2018-02-07 23:21:51 +01:00
extern u32 gHitMarker;
extern u8 gTakenDmgByBattler[MAX_BATTLERS_COUNT];
extern u8 gUnusedFirstBattleVar2;
2018-07-24 20:13:02 +02:00
extern u32 gSideStatuses[2];
2018-02-07 23:21:51 +01:00
extern struct SideTimer gSideTimers[2];
extern u32 gStatuses3[MAX_BATTLERS_COUNT];
2021-10-10 06:13:23 +02:00
extern u32 gStatuses4[MAX_BATTLERS_COUNT];
2018-02-07 23:21:51 +01:00
extern struct DisableStruct gDisableStructs[MAX_BATTLERS_COUNT];
extern u16 gPauseCounterBattle;
extern u16 gPaydayMoney;
extern u16 gRandomTurnNumber;
extern u8 gBattleCommunication[BATTLE_COMMUNICATION_ENTRIES_COUNT];
extern u8 gBattleOutcome;
extern struct ProtectStruct gProtectStructs[MAX_BATTLERS_COUNT];
extern struct SpecialStatus gSpecialStatuses[MAX_BATTLERS_COUNT];
extern u16 gBattleWeather;
extern struct WishFutureKnock gWishFutureKnock;
2018-02-08 11:17:41 +01:00
extern u16 gIntroSlideFlags;
2018-02-07 23:21:51 +01:00
extern u8 gSentPokesToOpponent[2];
extern u16 gExpShareExp;
extern struct BattleEnigmaBerry gEnigmaBerries[MAX_BATTLERS_COUNT];
extern struct BattleScripting gBattleScripting;
extern struct BattleStruct *gBattleStruct;
extern u8 *gLinkBattleSendBuffer;
extern u8 *gLinkBattleRecvBuffer;
extern struct BattleResources *gBattleResources;
extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT];
extern u8 gMoveSelectionCursor[MAX_BATTLERS_COUNT];
2018-02-08 11:17:41 +01:00
extern u8 gBattlerStatusSummaryTaskId[MAX_BATTLERS_COUNT];
2018-02-07 23:21:51 +01:00
extern u8 gBattlerInMenuId;
extern bool8 gDoingBattleAnim;
extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
extern u8 gPlayerDpadHoldFrames;
extern struct BattleSpriteData *gBattleSpritesDataPtr;
extern struct MonSpritesGfx *gMonSpritesGfxPtr;
2021-01-23 03:35:16 +01:00
extern struct BattleHealthboxInfo *gBattleControllerOpponentHealthboxData;
extern struct BattleHealthboxInfo *gBattleControllerOpponentFlankHealthboxData;
2018-02-07 23:21:51 +01:00
extern u16 gBattleMovePower;
extern u16 gMoveToLearn;
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
2018-07-14 13:17:10 +02:00
extern u32 gFieldStatuses;
extern struct FieldTimer gFieldTimers;
2018-09-29 13:36:33 +02:00
extern u8 gBattlerAbility;
2018-11-24 01:02:02 +01:00
extern u16 gPartnerSpriteId;
2020-11-19 18:35:37 +01:00
extern struct TotemBoost gTotemBoosts[MAX_BATTLERS_COUNT];
2018-02-07 23:21:51 +01:00
extern void (*gPreBattleCallback1)(void);
extern void (*gBattleMainFunc)(void);
extern struct BattleResults gBattleResults;
extern u8 gLeveledUpInBattle;
extern void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void);
extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gMultiUsePlayerCursor;
extern u8 gNumberOfMovesToChoose;
2021-01-23 02:03:21 +01:00
extern u8 gBattleControllerData[MAX_BATTLERS_COUNT];
2020-12-03 03:09:35 +01:00
extern bool8 gHasFetchedBall;
extern u8 gLastUsedBall;
extern u16 gLastThrownBall;
extern bool8 gSwapDamageCategory; // Photon Geyser, Shell Side Arm, Light That Burns the Sky
2022-05-06 00:54:33 +02:00
extern u8 gPartyCriticalHits[PARTY_SIZE];
2017-09-11 11:35:41 +02:00
#endif // GUARD_BATTLE_H