sovereignx/include/battle.h

1155 lines
40 KiB
C
Raw Normal View History

#ifndef GUARD_BATTLE_H
#define GUARD_BATTLE_H
2017-10-06 16:06:45 +01:00
// should they be included here or included individually by every file?
2018-02-07 23:35:13 +00:00
#include "constants/battle.h"
#include "constants/form_change_types.h"
2018-02-26 14:56:59 +00:00
#include "battle_main.h"
2018-06-30 14:35:54 +01:00
#include "battle_message.h"
2017-10-06 16:06:45 +01:00
#include "battle_util.h"
#include "battle_script_commands.h"
2017-10-10 20:45:07 +01:00
#include "battle_ai_switch_items.h"
2017-11-04 15:11:13 +00:00
#include "battle_gfx_sfx_util.h"
2017-11-12 15:39:21 +00:00
#include "battle_util2.h"
2017-12-17 19:10:57 +00:00
#include "battle_bg.h"
#include "pokeball.h"
2018-07-13 22:00:56 +01:00
#include "battle_debug.h"
2022-10-27 21:17:15 +01:00
#include "battle_dynamax.h"
#include "battle_terastal.h"
Gimmick Refactor (#4449) * consolidated gimmick checks, triggers, communication, and activation; updated test runner * fixed improper use of .usableGimmick * cleaning up battle_dynamax.c, changing function args to u32s * fixed '#ifdef TESTING' causing errors * updated z-moves to use gimmick interface, pared down redundancies; no AI/tests * added support for z-moves in tests, consolidated gimmick fields * removed ShouldUseMaxMove and .usingMaxMove * renamed TryChangeZIndicator, updated z move display * added several z-move tests and fixed various z-move interactions; fixed z-move category calc * fixed useless battler arg in GetTypeBasedZMove * added basic test check for bad Z-Move or Mega usage * reworked test runner gimmick functionality; added support for Ultra Burst + Z-Move to test Light That Burns the Sky * fixed gimmick test logic; fixed damage category override * fixed mega rayquaza test fail * consolidated gimmick indicator logic; added graphics to gGimmicksInfo * removed TeraData struct * reimplemented AI logic for Z-Moves; no changes * updated Z-Move and Ultra Burst trigger gfx * added testrunner check for multiple gimmick use * fixed duplicate z-move call in test * reorganized data/graphics/gimmicks.h * added signature Z-Move ability tests; implemented Guardian of Alola * fixed bad test update * fixed Thousand Arrows not affecting Tera Flying; clean-up * fixed -ate tests * fixed tera tests * fixed tera tests really * fixed last batch of tests * fixed -ate mega test again * code review * code review pt.2 * tweaked CanTera again * dynamax flag only required for player
2024-06-22 21:25:40 +01:00
#include "battle_gimmick.h"
#include "random.h" // for rng_value_t
2017-10-06 16:06:45 +01:00
// Helper for accessing command arguments and advancing gBattlescriptCurrInstr.
//
// For example accuracycheck is defined as:
//
// .macro accuracycheck failInstr:req, move:req
// .byte 0x1
// .4byte \failInstr
// .2byte \move
// .endm
//
// Which corresponds to:
//
// CMD_ARGS(const u8 *failInstr, u16 move);
//
// The arguments can be accessed as cmd->failInstr and cmd->move.
// gBattlescriptCurrInstr = cmd->nextInstr; advances to the next instruction.
#define CMD_ARGS(...) const struct __attribute__((packed)) { u8 opcode; RECURSIVELY(R_FOR_EACH(APPEND_SEMICOLON, __VA_ARGS__)) const u8 nextInstr[0]; } *const cmd UNUSED = (const void *)gBattlescriptCurrInstr
#define VARIOUS_ARGS(...) CMD_ARGS(u8 battler, u8 id, ##__VA_ARGS__)
#define NATIVE_ARGS(...) CMD_ARGS(void (*func)(void), ##__VA_ARGS__)
// 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 22:09:39 +00: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 17:37:52 +01:00
#define B_ACTION_WALLY_THROW 9
2019-02-02 10:32:00 +00:00
#define B_ACTION_EXEC_SCRIPT 10
#define B_ACTION_TRY_FINISH 11
#define B_ACTION_FINISHED 12
2018-02-06 22:09:39 +00:00
#define B_ACTION_CANCEL_PARTNER 12 // when choosing an action
#define B_ACTION_NOTHING_FAINTED 13 // when choosing an action
2018-07-13 22:00:56 +01:00
#define B_ACTION_DEBUG 20
2021-06-25 20:37:59 +01:00
#define B_ACTION_THROW_BALL 21 // R to throw last used ball
2018-02-06 22:09:39 +00:00
#define B_ACTION_NONE 0xFF
2017-10-04 18:25:14 +01:00
2018-02-07 22:21:51 +00:00
#define BATTLE_BUFFER_LINK_SIZE 0x1000
2023-10-20 17:46:28 +01:00
// Special indicator value for shellBellDmg in SpecialStatus
#define IGNORE_SHELL_BELL 0xFFFF
// For defining EFFECT_HIT etc. with battle TV scores and flags etc.
struct __attribute__((packed, aligned(2))) BattleMoveEffect
{
const u8 *battleScript;
u16 battleTvScore:3;
u16 encourageEncore:1;
u16 twoTurnEffect:1;
Secondary effects overhaul minor follow-up (#4062) * settwoturnstring command * Unified two-turn attacks and Meteor Beam To do: Solar Beam * Solar Beam Also fixed various function, removed EFFECT_GUST (who knows why that exists?) * Updated Solar Beam + tests * Redid two turn move + animations logic Removed pointless various function; to do: remove Skull Bash, fix AI test * Removed now-pointless flag * Removed Skull Bash And temporarily commented out failing AI tests * Removed Sky Uppercut effect Not sure when or why this was ever necessary * Removed BattleScript_EffectSemiInvulnerable Now uses BattleScript_EffectTwoTurnsAttack. Kept the effect; used the argument field to determine which STATUS3 such moves should apply but added a function to jump over weather checks in BattleScript_EffectTwoTurnsAttack if the current move is semi-invulnerable (since the instant-fire weather check and STATUS3 use the same field) * Applied review changes * Replaced VARIOUS with callnative Tried to fix test but couldn't :/ wtf is going on * Fixed one AI test Cant fix the other... * Added KNOWN_FAILING to failing AI tests Separated them out into their own test * Optimised script, overhauled charge turn string setting Condensed multiple confusing macros into one, jumpifweathercheckchargeeffects. Script now tweaked and trimmed, string ids for charge turns now added to argument along with status3 (thanks to compression macro) and instant-fire-weather for semi-invulnerable and two-turn moves respectively. Also introduced a savedStringId in gBattleScripting to make string selection work. * Unified two turn move tests + minor corrections * Added semi-invulnerable move tests Set the Razor Wind test to known failing - something to do with its animation? --------- Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com>
2024-02-04 22:02:59 +00:00
u16 semiInvulnerableEffect:1;
2024-01-30 08:54:43 +00:00
u16 usesProtectCounter:1;
2024-02-13 03:19:27 +00:00
u16 padding:9;
};
2024-02-25 09:22:21 +00:00
#define GET_MOVE_BATTLESCRIPT(move) gBattleMoveEffects[gMovesInfo[move].effect].battleScript
2019-04-04 22:53:06 +01:00
struct ResourceFlags
2017-09-04 20:43:13 +01:00
{
2022-01-20 15:25:48 +00:00
u32 flags[MAX_BATTLERS_COUNT];
2017-09-04 20:43:13 +01:00
};
2021-10-30 03:32:19 +01:00
#define RESOURCE_FLAG_FLASH_FIRE 0x1
#define RESOURCE_FLAG_ROOST 0x2
#define RESOURCE_FLAG_UNBURDEN 0x4
2022-11-08 13:10:21 +00:00
#define RESOURCE_FLAG_UNUSED 0x8
2021-10-30 03:32:19 +01:00
#define RESOURCE_FLAG_TRACED 0x10
#define RESOURCE_FLAG_EMERGENCY_EXIT 0x20
#define RESOURCE_FLAG_NEUTRALIZING_GAS 0x40
#define RESOURCE_FLAG_ICE_FACE 0x80
2017-09-04 20:43:13 +01:00
struct DisableStruct
{
u32 transformedMonPersonality;
bool8 transformedMonShininess;
u16 disabledMove;
u16 encoredMove;
u8 protectUses:4;
u8 stockpileCounter:4;
s8 stockpileDef;
s8 stockpileSpDef;
s8 stockpileBeforeDef;
s8 stockpileBeforeSpDef;
u8 substituteHP;
u8 encoredMovePos;
u8 disableTimer:4;
u8 encoreTimer:4;
u8 perishSongTimer:4;
u8 rolloutTimer:4;
u8 rolloutTimerStartValue:4;
u8 tauntTimer:4;
u8 furyCutterCounter;
u8 battlerPreventingEscape;
u8 battlerWithSureHit;
u8 isFirstTurn;
u8 mimickedMoves:4;
u8 chargeTimer:4;
u8 rechargeTimer;
u8 autotomizeCount;
2018-10-14 19:51:34 +01:00
u8 slowStartTimer;
2018-07-18 21:07:48 +01:00
u8 embargoTimer;
u8 magnetRiseTimer;
u8 telekinesisTimer;
u8 healBlockTimer;
2018-07-23 20:36:05 +01:00
u8 laserFocusTimer;
u8 throatChopTimer;
u8 wrapTurns;
u8 tormentTimer:4; // used for G-Max Meltdown
u8 usedMoves:4;
u8 truantCounter:1;
u8 truantSwitchInHack:1;
u8 noRetreat:1;
u8 tarShot:1;
u8 octolock:1;
2022-12-06 02:36:18 +00:00
u8 cudChew:1;
u8 spikesDone:1;
u8 toxicSpikesDone:1;
u8 stickyWebDone:1;
u8 stealthRockDone:1;
u8 syrupBombTimer;
u8 syrupBombIsShiny:1;
u8 steelSurgeDone:1;
u8 weatherAbilityDone:1;
u8 terrainAbilityDone:1;
u8 usedProteanLibero:1;
2017-09-04 20:43:13 +01:00
};
2017-09-17 13:10:32 +01:00
struct ProtectStruct
{
u32 protected:1;
2018-10-14 19:51:34 +01:00
u32 spikyShielded:1;
u32 kingsShielded:1;
u32 banefulBunkered:1;
u32 obstructed:1;
2017-09-17 13:10:32 +01:00
u32 endured:1;
2018-07-07 18:57:09 +01:00
u32 noValidMoves:1;
2017-09-17 13:10:32 +01:00
u32 helpingHand:1;
u32 bounceMove:1;
u32 stealMove:1;
u32 prlzImmobility:1;
u32 confusionSelfDmg:1;
u32 targetAffected:1;
2017-09-17 13:10:32 +01:00
u32 chargingTurn:1;
2021-10-04 15:21:03 +01:00
u32 fleeType:2; // 0: Normal, 1: FLEE_ITEM, 2: FLEE_ABILITY
u32 usedImprisonedMove:1;
2017-09-17 13:10:32 +01:00
u32 loveImmobility:1;
u32 usedDisabledMove:1;
2018-10-14 17:10:54 +01:00
u32 usedTauntedMove:1;
2019-01-29 21:22:02 +00:00
u32 flag2Unknown:1; // Only set to 0 once. Checked in 'WasUnableToUseMove' function.
2018-10-14 17:10:54 +01:00
u32 flinchImmobility:1;
u32 notFirstStrike:1;
2019-01-29 21:22:02 +00:00
u32 palaceUnableToUseMove:1;
2018-10-14 19:51:34 +01:00
u32 usedHealBlockedMove:1;
u32 usedGravityPreventedMove:1;
2018-12-03 11:50:32 +00:00
u32 powderSelfDmg:1;
u32 usedThroatChopPreventedMove:1;
u32 statRaised:1;
u32 usedCustapBerry:1; // also quick claw
u32 touchedProtectLike:1;
u32 unused:1;
// End of 32-bit bitfield
u16 disableEjectPack:1;
u16 statFell:1;
u16 pranksterElevated:1;
u16 quickDraw:1;
u16 beakBlastCharge:1;
2022-08-24 22:39:34 +01:00
u16 quash:1;
u16 shellTrap:1;
2023-02-22 04:16:25 +00:00
u16 maxGuarded:1;
u16 silkTrapped:1;
u16 burningBulwarked:1;
2023-03-28 20:07:37 +01:00
u16 eatMirrorHerb:1;
u16 activateOpportunist:2; // 2 - to copy stats. 1 - stats copied (do not repeat). 0 - no stats to copy
u16 usedAllySwitch:1;
u32 physicalDmg;
u32 specialDmg;
2018-10-14 17:10:54 +01:00
u8 physicalBattlerId;
u8 specialBattlerId;
2017-09-17 13:10:32 +01:00
};
struct SpecialStatus
{
2023-10-20 17:46:28 +01:00
s32 shellBellDmg;
s32 physicalDmg;
s32 specialDmg;
u8 physicalBattlerId;
u8 specialBattlerId;
u8 changedStatsBattlerId; // Battler that was responsible for the latest stat change. Can be self.
2018-10-14 17:10:54 +01:00
u8 statLowered:1;
u8 lightningRodRedirected:1;
u8 restoredBattlerSprite: 1;
u8 faintedHasReplacement:1;
2018-06-20 22:07:51 +01:00
u8 focusBanded:1;
2018-07-14 21:56:03 +01:00
u8 focusSashed:1;
u8 unused:2;
// End of byte
2018-07-21 14:11:13 +01:00
u8 sturdied:1;
2018-07-22 18:34:13 +01:00
u8 stormDrainRedirected:1;
2018-07-22 21:21:47 +01:00
u8 switchInAbilityDone:1;
2019-05-20 11:20:49 +01:00
u8 switchInItemDone:1;
u8 instructedChosenTarget:3;
2019-05-07 14:26:58 +01:00
u8 berryReduced:1;
// End of byte
u8 gemParam;
// End of byte
2019-05-07 14:26:58 +01:00
u8 gemBoost:1;
2021-09-16 15:24:32 +01:00
u8 rototillerAffected:1; // to be affected by rototiller
u8 parentalBondState:2;
u8 multiHitOn:1;
2021-11-01 17:50:57 +00:00
u8 announceNeutralizingGas:1; // See Cmd_switchineffects
u8 neutralizingGasRemoved:1; // See VARIOUS_TRY_END_NEUTRALIZING_GAS
2022-08-25 21:29:02 +01:00
u8 affectionEndured:1;
// End of byte
u8 damagedMons:4; // Mons that have been damaged directly by using a move, includes substitute.
u8 dancerUsedMove:1;
u8 dancerOriginalTarget:3;
// End of byte
u8 emergencyExited:1;
u8 afterYou:1;
u8 preventLifeOrbDamage:1; // So that Life Orb doesn't activate various effects.
2017-09-17 13:10:32 +01:00
};
struct SideTimer
{
2018-10-14 17:10:54 +01:00
u8 reflectTimer;
u8 reflectBattlerId;
u8 lightscreenTimer;
u8 lightscreenBattlerId;
u8 mistTimer;
u8 mistBattlerId;
u8 safeguardTimer;
u8 safeguardBattlerId;
u8 spikesAmount;
2018-07-21 11:10:08 +01:00
u8 toxicSpikesAmount;
2018-07-24 20:47:00 +01:00
u8 stealthRockAmount;
2018-07-24 21:09:55 +01:00
u8 stickyWebAmount;
u8 stickyWebBattlerId;
u8 stickyWebBattlerSide; // Used for Court Change
2018-07-21 11:10:08 +01:00
u8 auroraVeilTimer;
u8 auroraVeilBattlerId;
u8 tailwindTimer;
u8 tailwindBattlerId;
2018-07-21 11:56:07 +01:00
u8 luckyChantTimer;
u8 luckyChantBattlerId;
u8 steelsurgeAmount;
// 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 09:41:50 +01:00
u8 retaliateTimer;
u8 damageNonTypesTimer;
u8 damageNonTypesType;
u8 rainbowTimer;
u8 seaOfFireTimer;
u8 swampTimer;
2017-09-17 13:10:32 +01:00
};
2018-07-14 12:17:10 +01:00
struct FieldTimer
{
u8 mudSportTimer;
u8 waterSportTimer;
u8 wonderRoomTimer;
u8 magicRoomTimer;
u8 trickRoomTimer;
2021-11-06 22:46:52 +00:00
u8 terrainTimer;
u8 gravityTimer;
2020-04-20 18:41:07 +01:00
u8 fairyLockTimer;
2017-09-17 13:10:32 +01:00
};
struct WishFutureKnock
{
2018-02-06 01:46:59 +00:00
u8 futureSightCounter[MAX_BATTLERS_COUNT];
u8 futureSightBattlerIndex[MAX_BATTLERS_COUNT];
u8 futureSightPartyIndex[MAX_BATTLERS_COUNT];
2018-02-06 01:46:59 +00:00
u16 futureSightMove[MAX_BATTLERS_COUNT];
u8 wishCounter[MAX_BATTLERS_COUNT];
2021-11-20 21:49:04 +00:00
u8 wishPartyId[MAX_BATTLERS_COUNT];
2017-09-17 13:10:32 +01:00
u8 weatherDuration;
2022-10-20 12:41:18 +01:00
u8 knockedOffMons[NUM_BATTLE_SIDES]; // Each battler is represented by a bit.
2017-09-17 13:10:32 +01:00
};
2018-07-15 17:07:01 +01:00
struct AI_SavedBattleMon
{
u16 ability;
2020-07-15 20:30:24 +01:00
u16 moves[MAX_MON_MOVES];
2018-07-15 17:07:01 +01:00
u16 heldItem;
u16 species:15;
u16 saved:1;
u8 types[3];
2018-07-15 17:07:01 +01:00
};
2022-08-23 00:07:25 +01:00
struct AiPartyMon
{
u16 species;
u16 item;
u16 heldEffect;
u16 ability;
u16 gender;
u16 level;
u16 moves[MAX_MON_MOVES];
2022-08-23 10:58:17 +01:00
u32 status;
2022-08-23 00:07:25 +01:00
bool8 isFainted;
bool8 wasSentInBattle;
2022-08-23 10:58:17 +01:00
u8 switchInCount; // Counts how many times this Pokemon has been sent out or switched into in a battle.
2022-08-23 00:07:25 +01:00
};
struct AIPartyData // Opposing battlers - party mons.
{
2023-03-28 15:38:48 +01:00
struct AiPartyMon mons[NUM_BATTLE_SIDES][PARTY_SIZE]; // 2 parties(player, opponent). Used to save information on opposing party.
u8 count[NUM_BATTLE_SIDES];
2022-08-23 00:07:25 +01:00
};
Smarter SwitchAI Mon Choices | HasBadOdds Switch Check (#3253) * SwitchAI makes much smarter mon choices * Add HasHadOdds check to ShouldSwitch decision * Remove early return * Rework Baton Pass check as per discussion with Alex * Forgot to adjust a comment * Don't program before breakfast lol (if / else if fix) * Switch AI_CalcDamage for AI_DATA->simulatedDmg in HasBadOdds Thanks Alex! :D * Typo in a hitToKO comparison * Remove and replace AI_CalcPartyMonBestMoveDamage and IsAiPartyMonOHKOBy from https://github.com/rh-hideout/pokeemerald-expansion/pull/3146 See https://discord.com/channels/419213663107416084/1144447521960251472 for details * Major refactor, new struct, switchin considers damage / healing from hazards / status / held item / weather * Forgot Snow exists and heals Ice Body, haven't played Switch games lol * (https://github.com/rh-hideout/pokeemerald-expansion/commit/766a1a27a7298e50dd89c5fecc1989b3dd8b8ce3) Compatibility, use new struct field instead of function call * Fixing oversight from previous upstream merge * Improve TSpikes handling to make GetSwitchinHazardDamage more applicable Small fixes: - EFFECT_EXPLOSION typo (!= to ==) - Order of if statements near bestResistEffective - Spacing of terms in big HasBadOdds if statements * Forgot to uncomment blocks disabled for debugging what turned out to be vanilla behaviour lol * Remove another holdover from debugging, sorry :/ * Lastly, undoing my debug trainer * Type matchup based on species type rather than current type Suggested by BLourenco on Discord, the idea is that a mon that's had its type affected by a move like Soak will still have moves as though it was its regular typing, and so prioritizing the temporary typing wouldn't be ideal. https://discord.com/channels/419213663107416084/1144447521960251472/1146644578141736970 * gActiveBattler upcoming merge fixes * Egg changes part 1 * Egg changes part 2, just need to address EWRAM still * Move SwitchinCandidate struct to AiLogicData * Consider Steel type when checking TSpikes * Comment about CanBePoisoned compatibility * Changes for Egg's 2nd review * Put period back in comment, whoops lol * Latest upcoming merge fixes * Missed a few u32 updates * Combine GetBestMonIntegrate functions / flags, some modularization * Fix merge error * Make modern fixes * Two tests done, two to go * Accidentally pushed reference test, removing it * Type matchup switching tests * Tests for defensive vs offense switches --------- Co-authored-by: DizzyEggg <jajkodizzy@wp.pl>
2023-11-11 13:37:35 +00:00
struct SwitchinCandidate
{
struct BattlePokemon battleMon;
bool8 hypotheticalStatus;
};
struct SimulatedDamage
{
s32 expected;
s32 minimum;
};
2023-09-13 16:28:26 +01:00
// Ai Data used when deciding which move to use, computed only once before each turn's start.
struct AiLogicData
{
2022-01-13 16:28:27 +00: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;
u16 speedStats[MAX_BATTLERS_COUNT]; // Speed stats for all battles, calculated only once, same way as damages
struct SimulatedDamage simulatedDmg[MAX_BATTLERS_COUNT][MAX_BATTLERS_COUNT][MAX_MON_MOVES]; // attacker, target, moveIndex
2022-01-13 16:28:27 +00:00
u8 effectiveness[MAX_BATTLERS_COUNT][MAX_BATTLERS_COUNT][MAX_MON_MOVES]; // attacker, target, moveIndex
u8 moveAccuracy[MAX_BATTLERS_COUNT][MAX_BATTLERS_COUNT][MAX_MON_MOVES]; // attacker, target, moveIndex
2022-01-13 16:28:27 +00:00
u8 moveLimitations[MAX_BATTLERS_COUNT];
2023-08-08 11:55:47 +01:00
bool8 shouldSwitchMon; // Because all available moves have no/little effect. Each bit per battler.
u8 monToSwitchId[MAX_BATTLERS_COUNT]; // ID of the mon to switch.
2023-09-14 10:44:44 +01:00
bool8 weatherHasEffect; // The same as WEATHER_HAS_EFFECT. Stored here, so it's called only once.
u8 mostSuitableMonId[MAX_BATTLERS_COUNT]; // Stores result of GetMostSuitableMonToSwitchInto, which decides which generic mon the AI would switch into if they decide to switch. This can be overruled by specific mons found in ShouldSwitch; the final resulting mon is stored in AI_monToSwitchIntoId.
Smarter SwitchAI Mon Choices | HasBadOdds Switch Check (#3253) * SwitchAI makes much smarter mon choices * Add HasHadOdds check to ShouldSwitch decision * Remove early return * Rework Baton Pass check as per discussion with Alex * Forgot to adjust a comment * Don't program before breakfast lol (if / else if fix) * Switch AI_CalcDamage for AI_DATA->simulatedDmg in HasBadOdds Thanks Alex! :D * Typo in a hitToKO comparison * Remove and replace AI_CalcPartyMonBestMoveDamage and IsAiPartyMonOHKOBy from https://github.com/rh-hideout/pokeemerald-expansion/pull/3146 See https://discord.com/channels/419213663107416084/1144447521960251472 for details * Major refactor, new struct, switchin considers damage / healing from hazards / status / held item / weather * Forgot Snow exists and heals Ice Body, haven't played Switch games lol * (https://github.com/rh-hideout/pokeemerald-expansion/commit/766a1a27a7298e50dd89c5fecc1989b3dd8b8ce3) Compatibility, use new struct field instead of function call * Fixing oversight from previous upstream merge * Improve TSpikes handling to make GetSwitchinHazardDamage more applicable Small fixes: - EFFECT_EXPLOSION typo (!= to ==) - Order of if statements near bestResistEffective - Spacing of terms in big HasBadOdds if statements * Forgot to uncomment blocks disabled for debugging what turned out to be vanilla behaviour lol * Remove another holdover from debugging, sorry :/ * Lastly, undoing my debug trainer * Type matchup based on species type rather than current type Suggested by BLourenco on Discord, the idea is that a mon that's had its type affected by a move like Soak will still have moves as though it was its regular typing, and so prioritizing the temporary typing wouldn't be ideal. https://discord.com/channels/419213663107416084/1144447521960251472/1146644578141736970 * gActiveBattler upcoming merge fixes * Egg changes part 1 * Egg changes part 2, just need to address EWRAM still * Move SwitchinCandidate struct to AiLogicData * Consider Steel type when checking TSpikes * Comment about CanBePoisoned compatibility * Changes for Egg's 2nd review * Put period back in comment, whoops lol * Latest upcoming merge fixes * Missed a few u32 updates * Combine GetBestMonIntegrate functions / flags, some modularization * Fix merge error * Make modern fixes * Two tests done, two to go * Accidentally pushed reference test, removing it * Type matchup switching tests * Tests for defensive vs offense switches --------- Co-authored-by: DizzyEggg <jajkodizzy@wp.pl>
2023-11-11 13:37:35 +00:00
struct SwitchinCandidate switchinCandidate; // Struct used for deciding which mon to switch to in battle_ai_switch_items.c
};
2017-09-04 20:43:13 +01:00
struct AI_ThinkingStruct
{
u8 aiState;
u8 movesetIndex;
u16 moveConsidered;
2023-09-13 08:27:49 +01:00
s32 score[MAX_MON_MOVES];
2017-09-04 20:43:13 +01:00
u32 funcResult;
u32 aiFlags[MAX_BATTLERS_COUNT];
2017-09-04 20:43:13 +01:00
u8 aiAction;
u8 aiLogicId;
2023-08-08 11:55:47 +01:00
struct AI_SavedBattleMon saved[MAX_BATTLERS_COUNT];
2017-09-04 20:43:13 +01:00
};
2020-07-15 20:30:24 +01:00
#define AI_MOVE_HISTORY_COUNT 3
2017-09-04 20:43:13 +01:00
struct BattleHistory
{
u16 abilities[MAX_BATTLERS_COUNT];
2018-02-06 01:46:59 +00:00
u8 itemEffects[MAX_BATTLERS_COUNT];
2020-07-15 20:30:24 +01: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 01:46:59 +00:00
u16 trainerItems[MAX_BATTLERS_COUNT];
2017-09-05 08:41:48 +01:00
u8 itemsNo;
u16 heldItems[MAX_BATTLERS_COUNT];
2017-09-04 20:43:13 +01:00
};
struct BattleScriptsStack
{
2017-09-17 13:10:32 +01:00
const u8 *ptr[8];
2017-09-04 20:43:13 +01:00
u8 size;
};
2017-09-17 16:14:32 +01:00
struct BattleCallbacksStack
{
void (*function[8])(void);
u8 size;
};
2017-09-22 20:33:49 +01:00
struct StatsArray
{
2019-04-04 20:24:21 +01:00
u16 stats[NUM_STATS];
2017-09-22 20:33:49 +01:00
};
2017-09-04 20:43:13 +01:00
struct BattleResources
{
2019-04-05 22:11:24 +01:00
struct SecretBase* secretBase;
2019-04-04 22:53:06 +01:00
struct ResourceFlags *flags;
2017-09-04 20:43:13 +01:00
struct BattleScriptsStack* battleScriptsStack;
2017-09-17 16:14:32 +01:00
struct BattleCallbacksStack* battleCallbackStack;
2019-04-04 20:24:21 +01:00
struct StatsArray* beforeLvlUp;
2017-09-04 20:43:13 +01:00
struct AI_ThinkingStruct *ai;
2022-01-13 16:28:27 +00:00
struct AiLogicData *aiData;
2022-08-23 00:07:25 +01:00
struct AIPartyData *aiParty;
2017-09-04 20:43:13 +01:00
struct BattleHistory *battleHistory;
u8 bufferA[MAX_BATTLERS_COUNT][0x200];
u8 bufferB[MAX_BATTLERS_COUNT][0x200];
u8 transferBuffer[0x100];
2017-09-04 20:43:13 +01:00
};
2020-12-11 15:05:00 +00:00
#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(gBattleResources->ai))
2022-01-13 16:28:27 +00:00
#define AI_DATA ((struct AiLogicData *)(gBattleResources->aiData))
2022-08-23 00:07:25 +01:00
#define AI_PARTY ((struct AIPartyData *)(gBattleResources->aiParty))
2020-12-11 15:05:00 +00:00
#define BATTLE_HISTORY ((struct BattleHistory *)(gBattleResources->battleHistory))
2017-09-05 08:41:48 +01:00
struct BattleResults
{
u8 playerFaintCounter; // 0x0
u8 opponentFaintCounter; // 0x1
2017-09-24 23:09:13 +01:00
u8 playerSwitchesCounter; // 0x2
u8 numHealingItemsUsed; // 0x3
u8 numRevivesUsed; // 0x4
2018-12-23 23:02:29 +00: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 16:09:36 +01:00
u8 caughtMonBall:4; // 0x5
2018-06-28 20:06:32 +01:00
u8 shinyWildMon:1; // 0x5
2017-10-05 23:12:01 +01:00
u16 playerMon1Species; // 0x6
2018-06-28 20:06:32 +01:00
u8 playerMon1Name[POKEMON_NAME_LENGTH + 1]; // 0x8
2017-09-05 08:41:48 +01:00
u8 battleTurnCounter; // 0x13
2018-06-28 20:06:32 +01:00
u8 playerMon2Name[POKEMON_NAME_LENGTH + 1]; // 0x14
u8 pokeblockThrows; // 0x1F
2017-09-05 08:41:48 +01:00
u16 lastOpponentSpecies; // 0x20
2017-10-05 23:12:01 +01:00
u16 lastUsedMovePlayer; // 0x22
u16 lastUsedMoveOpponent; // 0x24
u16 playerMon2Species; // 0x26
2017-09-28 14:34:21 +01:00
u16 caughtMonSpecies; // 0x28
2018-06-28 20:06:32 +01:00
u8 caughtMonNick[POKEMON_NAME_LENGTH + 1]; // 0x2A
u8 filler35; // 0x35
u8 catchAttempts[POKEBALL_COUNT]; // 0x36
2017-09-05 08:41:48 +01:00
};
2018-02-27 19:40:09 +00:00
struct BattleTv_Side
2018-02-27 17:13:28 +00: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 19:40:09 +00:00
u32 usedMoveSlot:2;
2018-02-27 17:13:28 +00: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 19:40:09 +00:00
u32 faintCause:4;
u32 faintCauseMonId:3;
2018-02-27 17:13:28 +00:00
u32 explosion:1;
u32 explosionMoveSlot:2;
u32 explosionMonId:3;
u32 perishSong:1;
};
2018-02-27 19:40:09 +00:00
struct BattleTv_Position
2018-02-27 17:13:28 +00: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 19:40:09 +00:00
u32 attackedByMonId:3;
u32 attackedByMoveSlot:2;
2018-02-27 17:13:28 +00:00
};
2018-02-27 19:40:09 +00:00
struct BattleTv_Mon
2018-02-27 17:13:28 +00: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 19:40:09 +00:00
struct BattleTv
2018-02-27 17:13:28 +00:00
{
2022-10-20 12:41:18 +01:00
struct BattleTv_Mon mon[NUM_BATTLE_SIDES][PARTY_SIZE];
struct BattleTv_Position pos[NUM_BATTLE_SIDES][2]; // [side][flank]
struct BattleTv_Side side[NUM_BATTLE_SIDES];
2018-02-27 17:13:28 +00:00
};
2018-02-27 19:40:09 +00:00
struct BattleTvMovePoints
2018-02-27 17:13:28 +00:00
{
2018-02-27 19:40:09 +00:00
s16 points[2][PARTY_SIZE * 4];
2018-02-27 17:13:28 +00:00
};
2021-03-15 19:22:41 +00:00
struct LinkBattlerHeader
{
2021-03-12 21:55:58 +00:00
u8 versionSignatureLo;
u8 versionSignatureHi;
u8 vsScreenHealthFlagsLo;
u8 vsScreenHealthFlagsHi;
struct BattleEnigmaBerry battleEnigmaBerry;
};
2019-08-08 12:06:55 +01:00
struct Illusion
{
u8 on;
u8 set;
u8 broken;
u8 partyId;
2019-08-08 12:06:55 +01:00
struct Pokemon *mon;
};
2020-11-26 20:56:18 +00:00
struct ZMoveData
{
Gimmick Refactor (#4449) * consolidated gimmick checks, triggers, communication, and activation; updated test runner * fixed improper use of .usableGimmick * cleaning up battle_dynamax.c, changing function args to u32s * fixed '#ifdef TESTING' causing errors * updated z-moves to use gimmick interface, pared down redundancies; no AI/tests * added support for z-moves in tests, consolidated gimmick fields * removed ShouldUseMaxMove and .usingMaxMove * renamed TryChangeZIndicator, updated z move display * added several z-move tests and fixed various z-move interactions; fixed z-move category calc * fixed useless battler arg in GetTypeBasedZMove * added basic test check for bad Z-Move or Mega usage * reworked test runner gimmick functionality; added support for Ultra Burst + Z-Move to test Light That Burns the Sky * fixed gimmick test logic; fixed damage category override * fixed mega rayquaza test fail * consolidated gimmick indicator logic; added graphics to gGimmicksInfo * removed TeraData struct * reimplemented AI logic for Z-Moves; no changes * updated Z-Move and Ultra Burst trigger gfx * added testrunner check for multiple gimmick use * fixed duplicate z-move call in test * reorganized data/graphics/gimmicks.h * added signature Z-Move ability tests; implemented Guardian of Alola * fixed bad test update * fixed Thousand Arrows not affecting Tera Flying; clean-up * fixed -ate tests * fixed tera tests * fixed tera tests really * fixed last batch of tests * fixed -ate mega test again * code review * code review pt.2 * tweaked CanTera again * dynamax flag only required for player
2024-06-22 21:25:40 +01:00
u8 viable:1; // current move can become a z move
2020-12-01 21:36:44 +00:00
u8 viewing:1; // if player is viewing the z move name instead of regular moves
Gimmick Refactor (#4449) * consolidated gimmick checks, triggers, communication, and activation; updated test runner * fixed improper use of .usableGimmick * cleaning up battle_dynamax.c, changing function args to u32s * fixed '#ifdef TESTING' causing errors * updated z-moves to use gimmick interface, pared down redundancies; no AI/tests * added support for z-moves in tests, consolidated gimmick fields * removed ShouldUseMaxMove and .usingMaxMove * renamed TryChangeZIndicator, updated z move display * added several z-move tests and fixed various z-move interactions; fixed z-move category calc * fixed useless battler arg in GetTypeBasedZMove * added basic test check for bad Z-Move or Mega usage * reworked test runner gimmick functionality; added support for Ultra Burst + Z-Move to test Light That Burns the Sky * fixed gimmick test logic; fixed damage category override * fixed mega rayquaza test fail * consolidated gimmick indicator logic; added graphics to gGimmicksInfo * removed TeraData struct * reimplemented AI logic for Z-Moves; no changes * updated Z-Move and Ultra Burst trigger gfx * added testrunner check for multiple gimmick use * fixed duplicate z-move call in test * reorganized data/graphics/gimmicks.h * added signature Z-Move ability tests; implemented Guardian of Alola * fixed bad test update * fixed Thousand Arrows not affecting Tera Flying; clean-up * fixed -ate tests * fixed tera tests * fixed tera tests really * fixed last batch of tests * fixed -ate mega test again * code review * code review pt.2 * tweaked CanTera again * dynamax flag only required for player
2024-06-22 21:25:40 +01:00
u8 healReplacement:6;
2020-12-01 21:36:44 +00:00
u8 possibleZMoves[MAX_BATTLERS_COUNT];
u16 baseMoves[MAX_BATTLERS_COUNT];
2020-12-01 18:43:15 +00:00
};
2020-11-26 20:56:18 +00:00
2023-02-22 04:16:25 +00:00
struct DynamaxData
{
u8 dynamaxTurns[MAX_BATTLERS_COUNT];
Gimmick Refactor (#4449) * consolidated gimmick checks, triggers, communication, and activation; updated test runner * fixed improper use of .usableGimmick * cleaning up battle_dynamax.c, changing function args to u32s * fixed '#ifdef TESTING' causing errors * updated z-moves to use gimmick interface, pared down redundancies; no AI/tests * added support for z-moves in tests, consolidated gimmick fields * removed ShouldUseMaxMove and .usingMaxMove * renamed TryChangeZIndicator, updated z move display * added several z-move tests and fixed various z-move interactions; fixed z-move category calc * fixed useless battler arg in GetTypeBasedZMove * added basic test check for bad Z-Move or Mega usage * reworked test runner gimmick functionality; added support for Ultra Burst + Z-Move to test Light That Burns the Sky * fixed gimmick test logic; fixed damage category override * fixed mega rayquaza test fail * consolidated gimmick indicator logic; added graphics to gGimmicksInfo * removed TeraData struct * reimplemented AI logic for Z-Moves; no changes * updated Z-Move and Ultra Burst trigger gfx * added testrunner check for multiple gimmick use * fixed duplicate z-move call in test * reorganized data/graphics/gimmicks.h * added signature Z-Move ability tests; implemented Guardian of Alola * fixed bad test update * fixed Thousand Arrows not affecting Tera Flying; clean-up * fixed -ate tests * fixed tera tests * fixed tera tests really * fixed last batch of tests * fixed -ate mega test again * code review * code review pt.2 * tweaked CanTera again * dynamax flag only required for player
2024-06-22 21:25:40 +01:00
u16 baseMoves[MAX_BATTLERS_COUNT]; // base move of Max Move
u16 lastUsedBaseMove;
u16 levelUpHP;
2023-02-22 04:16:25 +00:00
};
Gimmick Refactor (#4449) * consolidated gimmick checks, triggers, communication, and activation; updated test runner * fixed improper use of .usableGimmick * cleaning up battle_dynamax.c, changing function args to u32s * fixed '#ifdef TESTING' causing errors * updated z-moves to use gimmick interface, pared down redundancies; no AI/tests * added support for z-moves in tests, consolidated gimmick fields * removed ShouldUseMaxMove and .usingMaxMove * renamed TryChangeZIndicator, updated z move display * added several z-move tests and fixed various z-move interactions; fixed z-move category calc * fixed useless battler arg in GetTypeBasedZMove * added basic test check for bad Z-Move or Mega usage * reworked test runner gimmick functionality; added support for Ultra Burst + Z-Move to test Light That Burns the Sky * fixed gimmick test logic; fixed damage category override * fixed mega rayquaza test fail * consolidated gimmick indicator logic; added graphics to gGimmicksInfo * removed TeraData struct * reimplemented AI logic for Z-Moves; no changes * updated Z-Move and Ultra Burst trigger gfx * added testrunner check for multiple gimmick use * fixed duplicate z-move call in test * reorganized data/graphics/gimmicks.h * added signature Z-Move ability tests; implemented Guardian of Alola * fixed bad test update * fixed Thousand Arrows not affecting Tera Flying; clean-up * fixed -ate tests * fixed tera tests * fixed tera tests really * fixed last batch of tests * fixed -ate mega test again * code review * code review pt.2 * tweaked CanTera again * dynamax flag only required for player
2024-06-22 21:25:40 +01:00
struct BattleGimmickData
{
Gimmick Refactor (#4449) * consolidated gimmick checks, triggers, communication, and activation; updated test runner * fixed improper use of .usableGimmick * cleaning up battle_dynamax.c, changing function args to u32s * fixed '#ifdef TESTING' causing errors * updated z-moves to use gimmick interface, pared down redundancies; no AI/tests * added support for z-moves in tests, consolidated gimmick fields * removed ShouldUseMaxMove and .usingMaxMove * renamed TryChangeZIndicator, updated z move display * added several z-move tests and fixed various z-move interactions; fixed z-move category calc * fixed useless battler arg in GetTypeBasedZMove * added basic test check for bad Z-Move or Mega usage * reworked test runner gimmick functionality; added support for Ultra Burst + Z-Move to test Light That Burns the Sky * fixed gimmick test logic; fixed damage category override * fixed mega rayquaza test fail * consolidated gimmick indicator logic; added graphics to gGimmicksInfo * removed TeraData struct * reimplemented AI logic for Z-Moves; no changes * updated Z-Move and Ultra Burst trigger gfx * added testrunner check for multiple gimmick use * fixed duplicate z-move call in test * reorganized data/graphics/gimmicks.h * added signature Z-Move ability tests; implemented Guardian of Alola * fixed bad test update * fixed Thousand Arrows not affecting Tera Flying; clean-up * fixed -ate tests * fixed tera tests * fixed tera tests really * fixed last batch of tests * fixed -ate mega test again * code review * code review pt.2 * tweaked CanTera again * dynamax flag only required for player
2024-06-22 21:25:40 +01:00
u8 usableGimmick[MAX_BATTLERS_COUNT]; // first usable gimmick that can be selected for each battler
bool8 playerSelect; // used to toggle trigger and update battle UI
u8 triggerSpriteId;
u8 indicatorSpriteId[MAX_BATTLERS_COUNT];
Gimmick Refactor (#4449) * consolidated gimmick checks, triggers, communication, and activation; updated test runner * fixed improper use of .usableGimmick * cleaning up battle_dynamax.c, changing function args to u32s * fixed '#ifdef TESTING' causing errors * updated z-moves to use gimmick interface, pared down redundancies; no AI/tests * added support for z-moves in tests, consolidated gimmick fields * removed ShouldUseMaxMove and .usingMaxMove * renamed TryChangeZIndicator, updated z move display * added several z-move tests and fixed various z-move interactions; fixed z-move category calc * fixed useless battler arg in GetTypeBasedZMove * added basic test check for bad Z-Move or Mega usage * reworked test runner gimmick functionality; added support for Ultra Burst + Z-Move to test Light That Burns the Sky * fixed gimmick test logic; fixed damage category override * fixed mega rayquaza test fail * consolidated gimmick indicator logic; added graphics to gGimmicksInfo * removed TeraData struct * reimplemented AI logic for Z-Moves; no changes * updated Z-Move and Ultra Burst trigger gfx * added testrunner check for multiple gimmick use * fixed duplicate z-move call in test * reorganized data/graphics/gimmicks.h * added signature Z-Move ability tests; implemented Guardian of Alola * fixed bad test update * fixed Thousand Arrows not affecting Tera Flying; clean-up * fixed -ate tests * fixed tera tests * fixed tera tests really * fixed last batch of tests * fixed -ate mega test again * code review * code review pt.2 * tweaked CanTera again * dynamax flag only required for player
2024-06-22 21:25:40 +01:00
u8 toActivate; // stores whether a battler should transform at start of turn as bitfield
u8 activeGimmick[NUM_BATTLE_SIDES][PARTY_SIZE]; // stores the active gimmick for each party member
bool8 activated[MAX_BATTLERS_COUNT][GIMMICKS_COUNT]; // stores whether a trainer has used gimmick
};
struct LostItem
{
u16 originalItem:15;
u16 stolen:1;
};
#if HQ_RANDOM == TRUE
struct BattleVideo {
u32 battleTypeFlags;
rng_value_t rngSeed;
};
#endif
2017-09-05 08:41:48 +01:00
struct BattleStruct
{
2017-09-17 13:10:32 +01:00
u8 turnEffectsTracker;
2018-02-07 21:53:40 +00:00
u8 turnEffectsBattlerId;
u8 turnCountersTracker;
2019-01-27 12:52:02 +00:00
u16 wrappedMove[MAX_BATTLERS_COUNT];
2021-10-16 21:10:45 +01:00
u16 moveTarget[MAX_BATTLERS_COUNT];
u32 expShareExpValue;
u32 expValue;
u8 expGettersOrder[PARTY_SIZE]; // First battlers which were sent out, then via exp-share
2018-02-07 21:53:40 +00:00
u8 expGetterMonId;
u8 expOrderId:3;
u8 expGetterBattlerId:2;
u8 teamGotExpMsgPrinted:1; // The 'Rest of your team got msg' has been printed.
u8 givenExpMons; // Bits for enemy party's pokemon that gave exp to player's party.
u8 expSentInMons; // As bits for player party mons - not including exp share mons.
2017-09-05 08:41:48 +01:00
u8 wildVictorySong;
u8 dynamicMoveType;
2018-10-14 17:10:54 +01:00
u8 wrappedBy[MAX_BATTLERS_COUNT];
u8 focusPunchBattlers; // as bits
2018-07-07 18:57:09 +01:00
u8 battlerPreventingSwitchout;
u8 moneyMultiplier:6;
u8 moneyMultiplierItem:1;
u8 moneyMultiplierMove:1;
u8 savedTurnActionNumber;
u8 eventsBeforeFirstTurnState;
2017-12-02 13:08:55 +00:00
u8 faintedActionsState;
2018-02-07 21:53:40 +00:00
u8 faintedActionsBattlerId;
u8 scriptPartyIdx; // for printing the nickname
2018-02-06 01:46:59 +00:00
bool8 selectionScriptFinished[MAX_BATTLERS_COUNT];
u8 battlerPartyIndexes[MAX_BATTLERS_COUNT];
2018-02-06 01:46:59 +00:00
u8 monToSwitchIntoId[MAX_BATTLERS_COUNT];
u8 battlerPartyOrders[MAX_BATTLERS_COUNT][PARTY_SIZE / 2];
2017-10-05 23:12:01 +01:00
u8 runTries;
2018-10-14 17:10:54 +01:00
u8 caughtMonNick[POKEMON_NAME_LENGTH + 1];
2018-07-01 10:15:42 +01: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 01:46:59 +00:00
u8 chosenMovePositions[MAX_BATTLERS_COUNT];
u8 stateIdAfterSelScript[MAX_BATTLERS_COUNT];
2021-01-23 01:03:21 +00:00
u8 prevSelectedPartySlot;
2017-10-07 14:15:47 +01:00
u8 stringMoveType;
u8 absentBattlerFlags;
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-23 23:02:29 +00:00
u8 field_93; // related to choosing pokemon?
2017-10-24 20:45:41 +01:00
u8 wallyBattleState;
u8 wallyMovesState;
u8 wallyWaitFrames;
u8 wallyMoveFrames;
2019-01-27 12:52:02 +00:00
u16 lastTakenMove[MAX_BATTLERS_COUNT]; // Last move that a battler was hit with.
2022-10-20 12:41:18 +01:00
u16 hpOnSwitchout[NUM_BATTLE_SIDES];
2017-10-01 00:12:42 +01:00
u32 savedBattleTypeFlags;
u16 abilityPreventingSwitchout;
u8 hpScale;
2019-06-25 12:04:14 +01:00
u16 synchronizeMoveEffect;
u8 anyMonHasTransformed:1; // Only used in battle_tv.c
u8 multipleSwitchInBattlers:4; // One bit per battler
u8 multipleSwitchInState:2;
u8 multipleSwitchInCursor:3;
u8 multipleSwitchInSortedBattlers[MAX_BATTLERS_COUNT];
2017-10-01 00:12:42 +01:00
void (*savedCallback)(void);
2022-12-15 20:39:27 +00:00
u16 usedHeldItems[PARTY_SIZE][NUM_BATTLE_SIDES]; // For each party member and side. For harvest, recycle
2019-01-27 12:52:02 +00:00
u16 chosenItem[MAX_BATTLERS_COUNT];
2018-02-06 01:46:59 +00:00
u16 choicedMove[MAX_BATTLERS_COUNT];
u16 changedItems[MAX_BATTLERS_COUNT];
u8 canPickupItem;
u8 switchInBattlerCounter;
2018-12-07 22:50:56 +00:00
u8 arenaTurnCounter;
2017-09-17 13:10:32 +01:00
u8 turnSideTracker;
2019-01-27 12:52:02 +00:00
u16 lastTakenMoveFrom[MAX_BATTLERS_COUNT][MAX_BATTLERS_COUNT]; // a 2-D array [target][attacker]
union {
2021-03-15 19:22:41 +00:00
struct LinkBattlerHeader linkBattlerHeader;
#if HQ_RANDOM == FALSE
u32 battleVideo[2];
#else
struct BattleVideo battleVideo;
#endif
} multiBuffer;
2017-12-02 13:08:55 +00:00
u8 wishPerishSongState;
2018-02-07 21:53:40 +00:00
u8 wishPerishSongBattlerId;
u8 aiCalcInProgress:1;
u8 overworldWeatherDone:1;
u8 startingStatusDone:1;
u8 isAtkCancelerForCalledMove:1; // Certain cases in atk canceler should only be checked once, when the original move is called, however others need to be checked the twice.
u8 terrainDone:1;
u8 startingStatus; // status to apply at battle start. defined in constants/battle.h
u8 startingStatusTimer;
2017-09-17 13:10:32 +01:00
u8 atkCancellerTracker;
2018-02-27 19:40:09 +00:00
struct BattleTvMovePoints tvMovePoints;
struct BattleTv tv;
2018-02-06 01:46:59 +00:00
u8 AI_monToSwitchIntoId[MAX_BATTLERS_COUNT];
2018-11-11 17:33:16 +00: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 Pokémon.
2018-07-13 22:00:56 +01:00
u8 debugBattler;
2018-07-14 21:56:03 +01:00
u8 magnitudeBasePower;
u8 presentBasePower;
u8 roostTypes[MAX_BATTLERS_COUNT][2];
u8 savedBattlerTarget[5];
u8 savedBattlerAttacker[5];
u8 savedTargetCount:4;
u8 savedAttackerCount:4;
2018-07-28 17:41:57 +01:00
bool8 ateBoost[MAX_BATTLERS_COUNT];
2018-09-29 11:47:35 +01:00
u8 activeAbilityPopUps; // as bits for each battler
2020-12-06 04:04:12 +00:00
u8 abilityPopUpSpriteIds[MAX_BATTLERS_COUNT][2]; // two per battler
bool8 throwingPokeBall;
2020-11-26 20:56:18 +00:00
struct ZMoveData zmove;
2023-02-22 04:16:25 +00:00
struct DynamaxData dynamax;
Gimmick Refactor (#4449) * consolidated gimmick checks, triggers, communication, and activation; updated test runner * fixed improper use of .usableGimmick * cleaning up battle_dynamax.c, changing function args to u32s * fixed '#ifdef TESTING' causing errors * updated z-moves to use gimmick interface, pared down redundancies; no AI/tests * added support for z-moves in tests, consolidated gimmick fields * removed ShouldUseMaxMove and .usingMaxMove * renamed TryChangeZIndicator, updated z move display * added several z-move tests and fixed various z-move interactions; fixed z-move category calc * fixed useless battler arg in GetTypeBasedZMove * added basic test check for bad Z-Move or Mega usage * reworked test runner gimmick functionality; added support for Ultra Burst + Z-Move to test Light That Burns the Sky * fixed gimmick test logic; fixed damage category override * fixed mega rayquaza test fail * consolidated gimmick indicator logic; added graphics to gGimmicksInfo * removed TeraData struct * reimplemented AI logic for Z-Moves; no changes * updated Z-Move and Ultra Burst trigger gfx * added testrunner check for multiple gimmick use * fixed duplicate z-move call in test * reorganized data/graphics/gimmicks.h * added signature Z-Move ability tests; implemented Guardian of Alola * fixed bad test update * fixed Thousand Arrows not affecting Tera Flying; clean-up * fixed -ate tests * fixed tera tests * fixed tera tests really * fixed last batch of tests * fixed -ate mega test again * code review * code review pt.2 * tweaked CanTera again * dynamax flag only required for player
2024-06-22 21:25:40 +01:00
struct BattleGimmickData gimmick;
2018-11-03 00:17:16 +00:00
const u8 *trainerSlideMsg;
bool8 trainerSlideLowHpMsgDone;
u8 introState;
2019-02-01 13:17:24 +00:00
u8 ateBerry[2]; // array id determined by side, each party pokemon as bit
2019-02-14 11:15:53 +00: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
u16 tracedAbility[MAX_BATTLERS_COUNT];
2023-11-01 13:55:50 +00:00
u16 hpBefore[MAX_BATTLERS_COUNT]; // Hp of battlers before using a move. For Berserk and Anger Shell.
2019-08-08 12:06:55 +01:00
bool8 spriteIgnore0Hp;
struct Illusion illusion[MAX_BATTLERS_COUNT];
2023-09-13 08:27:49 +01:00
s32 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 18:59:09 +01: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 11:49:25 +01:00
u8 sameMoveTurns[MAX_BATTLERS_COUNT]; // For Metronome, number of times the same moves has been SUCCESFULLY used.
2020-06-25 15:15:11 +01:00
u16 moveEffect2; // For Knock Off
u16 changedSpecies[NUM_BATTLE_SIDES][PARTY_SIZE]; // For forms when multiple mons can change into the same pokemon.
u8 quickClawBattlerId;
struct LostItem itemLost[NUM_BATTLE_SIDES][PARTY_SIZE]; // Pokemon that had items consumed or stolen (two bytes per party member per side)
2023-02-08 11:42:38 +00:00
u8 forcedSwitch:4; // For each battler
u8 additionalEffectsCounter:4; // A counter for the additionalEffects applied by the current move in Cmd_setadditionaleffects
u8 blunderPolicy:1; // should blunder policy activate
u8 swapDamageCategory:1; // Photon Geyser, Shell Side Arm, Light That Burns the Sky
u8 bouncedMoveIsUsed:1;
u8 descriptionSubmenu:1; // For Move Description window in move selection screen
u8 ackBallUseBtn:1; // Used for the last used ball feature
u8 ballSwapped:1; // Used for the last used ball feature
2021-06-25 20:37:59 +01:00
u8 ballSpriteIds[2]; // item gfx, window gfx
u8 appearedInBattle; // Bitfield to track which Pokemon appeared in battle. Used for Burmy's form change
2021-11-20 19:44:48 +00:00
u8 skyDropTargets[MAX_BATTLERS_COUNT]; // For Sky Drop, to account for if multiple Pokemon use Sky Drop in a double battle.
2022-08-26 14:01:51 +01:00
// When using a move which hits multiple opponents which is then bounced by a target, we need to make sure, the move hits both opponents, the one with bounce, and the one without.
u8 attackerBeforeBounce:2;
u8 beatUpSlot:3;
bool8 hitSwitchTargetFailed:1;
bool8 effectsBeforeUsingMoveDone:1; // Mega Evo and Focus Punch/Shell Trap effects.
2022-08-26 14:01:51 +01:00
u8 targetsDone[MAX_BATTLERS_COUNT]; // Each battler as a bit.
2022-09-24 17:12:31 +01:00
u16 overwrittenAbilities[MAX_BATTLERS_COUNT]; // abilities overwritten during battle (keep separate from battle history in case of switching)
2023-02-16 14:26:26 +00:00
u8 battleBondTransformed[NUM_BATTLE_SIDES]; // Bitfield for each party.
u8 storedHealingWish:4; // Each battler as a bit.
u8 storedLunarDance:4; // Each battler as a bit.
u8 bonusCritStages[MAX_BATTLERS_COUNT]; // G-Max Chi Strike boosts crit stages of allies.
u8 itemPartyIndex[MAX_BATTLERS_COUNT];
2023-04-20 21:45:16 +01:00
u8 itemMoveIndex[MAX_BATTLERS_COUNT];
u8 trainerSlideFirstCriticalHitMsgState:2;
u8 trainerSlideFirstSuperEffectiveHitMsgState:2;
u8 trainerSlideFirstSTABMoveMsgState:2;
u8 trainerSlidePlayerMonUnaffectedMsgState:2;
u8 trainerSlideHalfHpMsgDone:1;
u8 trainerSlideMegaEvolutionMsgDone:1;
u8 trainerSlideZMoveMsgDone:1;
u8 trainerSlideBeforeFirstTurnMsgDone:1;
u8 trainerSlideDynamaxMsgDone:1;
u8 pledgeMove:1;
u8 isSkyBattle:1;
u8 poisonPuppeteerConfusion:1;
2023-09-12 09:35:05 +01:00
u32 aiDelayTimer; // Counts number of frames AI takes to choose an action.
u32 aiDelayFrames; // Number of frames it took to choose an action.
u8 timesGotHit[NUM_BATTLE_SIDES][PARTY_SIZE];
u8 enduredDamage;
u8 transformZeroToHero[NUM_BATTLE_SIDES];
u8 stickySyrupdBy[MAX_BATTLERS_COUNT];
u8 intrepidSwordBoost[NUM_BATTLE_SIDES];
u8 dauntlessShieldBoost[NUM_BATTLE_SIDES];
u8 supersweetSyrup[NUM_BATTLE_SIDES];
u8 supremeOverlordCounter[MAX_BATTLERS_COUNT];
u8 quickClawRandom[MAX_BATTLERS_COUNT];
u8 quickDrawRandom[MAX_BATTLERS_COUNT];
u8 shellSideArmCategory[MAX_BATTLERS_COUNT][MAX_BATTLERS_COUNT];
u8 speedTieBreaks; // MAX_BATTLERS_COUNT! values.
u8 boosterEnergyActivates;
u8 distortedTypeMatchups;
Gimmick Refactor (#4449) * consolidated gimmick checks, triggers, communication, and activation; updated test runner * fixed improper use of .usableGimmick * cleaning up battle_dynamax.c, changing function args to u32s * fixed '#ifdef TESTING' causing errors * updated z-moves to use gimmick interface, pared down redundancies; no AI/tests * added support for z-moves in tests, consolidated gimmick fields * removed ShouldUseMaxMove and .usingMaxMove * renamed TryChangeZIndicator, updated z move display * added several z-move tests and fixed various z-move interactions; fixed z-move category calc * fixed useless battler arg in GetTypeBasedZMove * added basic test check for bad Z-Move or Mega usage * reworked test runner gimmick functionality; added support for Ultra Burst + Z-Move to test Light That Burns the Sky * fixed gimmick test logic; fixed damage category override * fixed mega rayquaza test fail * consolidated gimmick indicator logic; added graphics to gGimmicksInfo * removed TeraData struct * reimplemented AI logic for Z-Moves; no changes * updated Z-Move and Ultra Burst trigger gfx * added testrunner check for multiple gimmick use * fixed duplicate z-move call in test * reorganized data/graphics/gimmicks.h * added signature Z-Move ability tests; implemented Guardian of Alola * fixed bad test update * fixed Thousand Arrows not affecting Tera Flying; clean-up * fixed -ate tests * fixed tera tests * fixed tera tests really * fixed last batch of tests * fixed -ate mega test again * code review * code review pt.2 * tweaked CanTera again * dynamax flag only required for player
2024-06-22 21:25:40 +01:00
u8 categoryOverride; // for Z-Moves and Max Moves
u32 stellarBoostFlags[NUM_BATTLE_SIDES]; // stored as a bitfield of flags for all types for each side
u8 fickleBeamBoosted:1;
u8 obedienceResult:3;
u8 usedMicleBerry;
2017-09-05 08:41:48 +01:00
};
// The palaceFlags member of struct BattleStruct contains 1 flag per move to indicate which moves the AI should consider,
// and 1 flag per battler to indicate whether the battler is awake and at <= 50% HP (which affects move choice).
// The assert below is to ensure palaceFlags is large enough to store these flags without overlap.
STATIC_ASSERT(sizeof(((struct BattleStruct *)0)->palaceFlags) * 8 >= MAX_BATTLERS_COUNT + MAX_MON_MOVES, PalaceFlagsTooSmall)
2023-10-20 17:46:28 +01:00
#define DYNAMIC_TYPE_MASK ((1 << 6) - 1)
#define F_DYNAMIC_TYPE_IGNORE_PHYSICALITY (1 << 6) // If set, the dynamic type's physicality won't be used for certain move effects.
2023-10-20 17:57:36 +01:00
#define F_DYNAMIC_TYPE_SET (1 << 7) // Set for all dynamic types to distinguish a dynamic type of Normal (0) from no dynamic type.
2021-10-04 15:21:03 +01:00
#define GET_MOVE_TYPE(move, typeArg) do { \
2021-10-04 15:21:03 +01:00
if (gBattleStruct->dynamicMoveType) \
typeArg = gBattleStruct->dynamicMoveType & DYNAMIC_TYPE_MASK; \
else \
typeArg = gMovesInfo[move].type; \
} while(0)
Move data unification (#3999) * Made gBattleMoves handle the InGame name and description of battle moves No more multiple arrays in separate, individual files. Note: -Keep an eye on Task_LearnedMove. * Reintroduced move names Misc: -Fixed Trick-or-Treat and Light of Ruin's expanded names. -Introduced a new field for Z-Move names, and a constant for their name length. -Added a few TODOs to GetBattleMoveName. -Updated GetMaxMoveName and GetZMoveName. There's no reason not to let GetBattleMoveName handle everything on its own. * Updated GetBattleMoveName to handle Z-Move Names Misc: -Removed pointless TODO about MOVE_NAME_LENGTH. -The compiler doesn't allow to have a move name with a value higher than MOVE_NAME_LENGTH, therefore it's pointless to worry about it. * Fixed a couple of expanded move names * Removed zMoveName variable of struct BattleMove and extended the name variable's size * Ditched no longer used MOVE_NAME_LENGTH constant * Corrected the names of the max moves I should have done this after updating the size of the name variable of the struct BattleMove, but I didn't think about it at all until Cancer Fairy indirectly gave me the idea. * Fixed U-turn's name * Brought back MOVE_NAME_LENGTH I think it doesn't make sense to have a Z_MOVE_NAME_LENGTH because the length in question is used for all battle moves, not just the Z-Moves. * Introduced a union for Move/Z-Move names in the struct BattleMove * Fixed the union for gBattleMoves move names Also updated GetBattleMoveName to properly handle Max Move names. Also also renamed the "zMoveName" variable to "bigMoveName" which better reflects its purpose. Z-Move names weren't the only thing it covered, since it also handles Max Move names. * Removed deprecated GetZMoveName and GetMaxMoveName * Reintroduced mention to gMoveNames in sGFRomHeader * Fixed move names and ported move descriptions * Fused the struct ContestMove into the struct BattleMove * Removed no longer used Z_MOVE_NAME_LENGTH constant * Renamed the struct BattleMove's bigMoveName variable and introduced macros to prettify move names * Reintroduced the contest parameters for Pokémon moves * Renamed gBattleMoves to gMovesInfo This is consistent with gSpeciesInfo, the array that contains most of the species data. * Renamed the BattleMove struct to MovesInfo This is consistent with the struct SpeciesInfo, which contains the variables used by the gSpeciesInfo array. * Removed empty lines separating battle params from contest params in gMovesInfo * Renamed MovesInfo to MoveInfo * Added Cancer Fairy's HANDLE_EXPANDED_MOVE_NAME macro Used to handle moves with expanded names in a more comfortable manner. Also fixed Trick-or-Treat's expanded name. * Renamed GetBattleMoveName to GetMoveName * Added a comment pointing out that the shared move descriptions are shared move descriptions * Re-aligned one of the escape characters of CHECK_MOVE_FLAG * Renamed the battle_moves.h file to moves_info.h instead for consistency's sake * Applied Eduardo's adjustments * Using compound string for regular move names as well, saving 1180 bytes and making their use consistent * Move description formatting * Updated Pursuit test after merge * Renamed the BATTLE_CATEGORY constants to DAMAGE_CATEGORY --------- Co-authored-by: Nephrite <thechurchofcage@gmail.com> Co-authored-by: Bassoonian <iasperbassoonian@gmail.com> Co-authored-by: Eduardo Quezada D'Ottone <eduardo602002@gmail.com>
2024-01-29 11:51:32 +00:00
#define IS_MOVE_PHYSICAL(move)(GetBattleMoveCategory(move) == DAMAGE_CATEGORY_PHYSICAL)
#define IS_MOVE_SPECIAL(move)(GetBattleMoveCategory(move) == DAMAGE_CATEGORY_SPECIAL)
#define IS_MOVE_STATUS(move)(gMovesInfo[move].category == DAMAGE_CATEGORY_STATUS)
2018-02-08 10:17:41 +00:00
Move data unification (#3999) * Made gBattleMoves handle the InGame name and description of battle moves No more multiple arrays in separate, individual files. Note: -Keep an eye on Task_LearnedMove. * Reintroduced move names Misc: -Fixed Trick-or-Treat and Light of Ruin's expanded names. -Introduced a new field for Z-Move names, and a constant for their name length. -Added a few TODOs to GetBattleMoveName. -Updated GetMaxMoveName and GetZMoveName. There's no reason not to let GetBattleMoveName handle everything on its own. * Updated GetBattleMoveName to handle Z-Move Names Misc: -Removed pointless TODO about MOVE_NAME_LENGTH. -The compiler doesn't allow to have a move name with a value higher than MOVE_NAME_LENGTH, therefore it's pointless to worry about it. * Fixed a couple of expanded move names * Removed zMoveName variable of struct BattleMove and extended the name variable's size * Ditched no longer used MOVE_NAME_LENGTH constant * Corrected the names of the max moves I should have done this after updating the size of the name variable of the struct BattleMove, but I didn't think about it at all until Cancer Fairy indirectly gave me the idea. * Fixed U-turn's name * Brought back MOVE_NAME_LENGTH I think it doesn't make sense to have a Z_MOVE_NAME_LENGTH because the length in question is used for all battle moves, not just the Z-Moves. * Introduced a union for Move/Z-Move names in the struct BattleMove * Fixed the union for gBattleMoves move names Also updated GetBattleMoveName to properly handle Max Move names. Also also renamed the "zMoveName" variable to "bigMoveName" which better reflects its purpose. Z-Move names weren't the only thing it covered, since it also handles Max Move names. * Removed deprecated GetZMoveName and GetMaxMoveName * Reintroduced mention to gMoveNames in sGFRomHeader * Fixed move names and ported move descriptions * Fused the struct ContestMove into the struct BattleMove * Removed no longer used Z_MOVE_NAME_LENGTH constant * Renamed the struct BattleMove's bigMoveName variable and introduced macros to prettify move names * Reintroduced the contest parameters for Pokémon moves * Renamed gBattleMoves to gMovesInfo This is consistent with gSpeciesInfo, the array that contains most of the species data. * Renamed the BattleMove struct to MovesInfo This is consistent with the struct SpeciesInfo, which contains the variables used by the gSpeciesInfo array. * Removed empty lines separating battle params from contest params in gMovesInfo * Renamed MovesInfo to MoveInfo * Added Cancer Fairy's HANDLE_EXPANDED_MOVE_NAME macro Used to handle moves with expanded names in a more comfortable manner. Also fixed Trick-or-Treat's expanded name. * Renamed GetBattleMoveName to GetMoveName * Added a comment pointing out that the shared move descriptions are shared move descriptions * Re-aligned one of the escape characters of CHECK_MOVE_FLAG * Renamed the battle_moves.h file to moves_info.h instead for consistency's sake * Applied Eduardo's adjustments * Using compound string for regular move names as well, saving 1180 bytes and making their use consistent * Move description formatting * Updated Pursuit test after merge * Renamed the BATTLE_CATEGORY constants to DAMAGE_CATEGORY --------- Co-authored-by: Nephrite <thechurchofcage@gmail.com> Co-authored-by: Bassoonian <iasperbassoonian@gmail.com> Co-authored-by: Eduardo Quezada D'Ottone <eduardo602002@gmail.com>
2024-01-29 11:51:32 +00:00
#define IS_MOVE_RECOIL(move)(gMovesInfo[move].recoil > 0 || gMovesInfo[move].effect == EFFECT_RECOIL_IF_MISS)
Convert move flags and bans into GCC bitfields (#2952) * Slicing moves to new bitfield * Wind moves to new bitfield * Two-strike moves to new bitfield * Forgot to add flagTwoStrikes to battle_moves.h * Removed "flag" from field names * FLAG_HIT_IN_SUBSTITUTE and FLAG_THAW_USER * Airborne moves * FLAG_POWDER, FLAG_TARGET_ABILITY_IGNORED and FLAG_DANCE * FLAG_BALLISTIC and FLAG_PROTECTION_MOVE * Fixed missing uses of MOVE_UNAVAILABLE in battle_ai_util.c * FLAG_SOUND * FLAG_DMG_UNDERGROUND and FLAG_DMG_UNDERWATER * FLAG_DMG_MINIMIZE * Cleanup * FLAG_STAT_STAGES_IGNORED * Updated Pollen Puff's ballistic flag * FLAG_STRONG_JAW_BOOST and FLAG_MEGA_LAUNCHER_BOOST * thaw * FLAG_THREE_STRIKES * FLAG_IRON_FIST_BOOST * FLAG_RECKLESS_BOOST * FLAG_HIGH_CRIT * Removed empty flags * Moves that fail when called by Me First + added missing Shell Trap * Moves that fail when Gravity is active * Better names for banned fields * Moves that fail when called by Instruct * Cleanup * Contact Moves + Fixed Wandering Spirit skipping contact checks * Inverted FLAG_PROTECT_AFFECTED so that there's a flag for moves that SKIP protect. * Simplified B_MOVE_FLAGS configs * FORBIDDEN_METRONOME * Renamed hitsPastSubstitute to ignoresSubstitute * FORBIDDEN_PARENTAL_BOND * Struggle uncallable by Metronome * FORBIDDEN_MIMIC * FLAG_KINGS_ROCK_AFFECTED * Made a single config for move flags * Macro for checking move flags * FLAG_MAGIC_COAT_AFFECTED * Fixed HasMagicCoatAffectedMove * FLAG_SNATCH_AFFECTED * Removed unused EFFECT_FLINCH_MINIMIZE_HIT * Fixed Stench/King's Rock interaction * Removed sMovesNotAffectedByStench in favor of checking move effects * Removed EFFECT_TWISTER, which was a repeat of EFFECT_FLINCH_HIT * Changed Gen2 configs to less than Gen 3 * FORBIDDEN_SLEEP_TALK * Cleanup * Inverted FLAG_MIRROR_MOVE_AFFECTED * FLAG_SHEER_FORCE_BOOST * Ordered * FORBIDDEN_ASSIST and FORBIDDEN_COPYCAT * Removed TestMoveFlags and TestMoveFlagsInMoveset + flags field * Fixed Triple Arrows test
2023-07-03 09:01:59 +01:00
2018-07-14 21:56:03 +01:00
#define BATTLER_MAX_HP(battlerId)(gBattleMons[battlerId].hp == gBattleMons[battlerId].maxHP)
#define TARGET_TURN_DAMAGED ((gSpecialStatuses[gBattlerTarget].physicalDmg != 0 || gSpecialStatuses[gBattlerTarget].specialDmg != 0) || (gBattleStruct->enduredDamage & gBitTable[gBattlerTarget]))
2023-12-16 08:33:45 +00:00
#define BATTLER_TURN_DAMAGED(battlerId) ((gSpecialStatuses[battlerId].physicalDmg != 0 || gSpecialStatuses[battlerId].specialDmg != 0) || (gBattleStruct->enduredDamage & gBitTable[battler]))
2018-02-28 23:59:52 +00:00
#define IS_BATTLER_OF_TYPE(battlerId, type)((GetBattlerType(battlerId, 0, FALSE) == type || GetBattlerType(battlerId, 1, FALSE) == type || (GetBattlerType(battlerId, 2, FALSE) != TYPE_MYSTERY && GetBattlerType(battlerId, 2, FALSE) == type)))
#define IS_BATTLER_OF_BASE_TYPE(battlerId, type)((GetBattlerType(battlerId, 0, TRUE) == type || GetBattlerType(battlerId, 1, TRUE) == type || (GetBattlerType(battlerId, 2, TRUE) != TYPE_MYSTERY && GetBattlerType(battlerId, 2, TRUE) == type)))
#define IS_BATTLER_TYPELESS(battlerId)(GetBattlerType(battlerId, 0, FALSE) == TYPE_MYSTERY && GetBattlerType(battlerId, 1, FALSE) == TYPE_MYSTERY && GetBattlerType(battlerId, 2, FALSE) == TYPE_MYSTERY)
#define SET_BATTLER_TYPE(battlerId, type) \
{ \
2024-08-07 19:35:45 +01:00
gBattleMons[battlerId].types[0] = type; \
gBattleMons[battlerId].types[1] = type; \
gBattleMons[battlerId].types[2] = TYPE_MYSTERY; \
2018-02-28 23:59:52 +00:00
}
#define RESTORE_BATTLER_TYPE(battlerId) \
{ \
2024-08-07 19:35:45 +01:00
gBattleMons[battlerId].types[0] = gSpeciesInfo[gBattleMons[battlerId].species].types[0]; \
gBattleMons[battlerId].types[1] = gSpeciesInfo[gBattleMons[battlerId].species].types[1]; \
gBattleMons[battlerId].types[2] = TYPE_MYSTERY; \
2022-12-09 01:29:07 +00: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].burningBulwarked \
|| gProtectStructs[battlerId].obstructed \
|| gProtectStructs[battlerId].silkTrapped)
#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 20:33:49 +01:00
#define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit
#define SET_STAT_BUFF_VALUE(n)((((n) << 3) & 0xF8))
2019-03-23 15:33:08 +00:00
#define SET_STATCHANGER(statId, stage, goesDown)(gBattleScripting.statChanger = (statId) + ((stage) << 3) + (goesDown << 7))
2020-04-19 14:44:44 +01:00
#define SET_STATCHANGER2(dst, statId, stage, goesDown)(dst = (statId) + ((stage) << 3) + (goesDown << 7))
2017-11-26 10:55:17 +00:00
2022-08-23 00:07:25 +01:00
// NOTE: The members of this struct have hard-coded offsets
2021-10-13 21:39:21 +01:00
// in include/constants/battle_script_commands.h
2017-09-05 08:41:48 +01:00
struct BattleScripting
{
2017-09-26 21:39:59 +01:00
s32 painSplitHp;
s32 bideDmg;
u8 multihitString[6];
2018-08-03 17:01:14 +01:00
bool8 expOnCatch;
Secondary effects overhaul minor follow-up (#4062) * settwoturnstring command * Unified two-turn attacks and Meteor Beam To do: Solar Beam * Solar Beam Also fixed various function, removed EFFECT_GUST (who knows why that exists?) * Updated Solar Beam + tests * Redid two turn move + animations logic Removed pointless various function; to do: remove Skull Bash, fix AI test * Removed now-pointless flag * Removed Skull Bash And temporarily commented out failing AI tests * Removed Sky Uppercut effect Not sure when or why this was ever necessary * Removed BattleScript_EffectSemiInvulnerable Now uses BattleScript_EffectTwoTurnsAttack. Kept the effect; used the argument field to determine which STATUS3 such moves should apply but added a function to jump over weather checks in BattleScript_EffectTwoTurnsAttack if the current move is semi-invulnerable (since the instant-fire weather check and STATUS3 use the same field) * Applied review changes * Replaced VARIOUS with callnative Tried to fix test but couldn't :/ wtf is going on * Fixed one AI test Cant fix the other... * Added KNOWN_FAILING to failing AI tests Separated them out into their own test * Optimised script, overhauled charge turn string setting Condensed multiple confusing macros into one, jumpifweathercheckchargeeffects. Script now tweaked and trimmed, string ids for charge turns now added to argument along with status3 (thanks to compression macro) and instant-fire-weather for semi-invulnerable and two-turn moves respectively. Also introduced a savedStringId in gBattleScripting to make string selection work. * Unified two turn move tests + minor corrections * Added semi-invulnerable move tests Set the Razor Wind test to known failing - something to do with its animation? --------- Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com>
2024-02-04 22:02:59 +00:00
u8 unused;
2017-09-17 13:10:32 +01:00
u8 animArg1;
u8 animArg2;
Secondary effects overhaul minor follow-up (#4062) * settwoturnstring command * Unified two-turn attacks and Meteor Beam To do: Solar Beam * Solar Beam Also fixed various function, removed EFFECT_GUST (who knows why that exists?) * Updated Solar Beam + tests * Redid two turn move + animations logic Removed pointless various function; to do: remove Skull Bash, fix AI test * Removed now-pointless flag * Removed Skull Bash And temporarily commented out failing AI tests * Removed Sky Uppercut effect Not sure when or why this was ever necessary * Removed BattleScript_EffectSemiInvulnerable Now uses BattleScript_EffectTwoTurnsAttack. Kept the effect; used the argument field to determine which STATUS3 such moves should apply but added a function to jump over weather checks in BattleScript_EffectTwoTurnsAttack if the current move is semi-invulnerable (since the instant-fire weather check and STATUS3 use the same field) * Applied review changes * Replaced VARIOUS with callnative Tried to fix test but couldn't :/ wtf is going on * Fixed one AI test Cant fix the other... * Added KNOWN_FAILING to failing AI tests Separated them out into their own test * Optimised script, overhauled charge turn string setting Condensed multiple confusing macros into one, jumpifweathercheckchargeeffects. Script now tweaked and trimmed, string ids for charge turns now added to argument along with status3 (thanks to compression macro) and instant-fire-weather for semi-invulnerable and two-turn moves respectively. Also introduced a savedStringId in gBattleScripting to make string selection work. * Unified two turn move tests + minor corrections * Added semi-invulnerable move tests Set the Razor Wind test to known failing - something to do with its animation? --------- Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com>
2024-02-04 22:02:59 +00:00
u16 savedStringId;
2019-08-23 13:46:21 +01:00
u8 moveendState;
2020-04-19 14:44:44 +01: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 01:46:59 +00:00
u8 battler;
2017-09-19 23:28:00 +01:00
u8 animTurn;
u8 animTargetsHit;
2017-09-17 16:14:32 +01:00
u8 statChanger;
2018-07-29 14:33:16 +01:00
bool8 statAnimPlayed;
2019-08-23 13:46:21 +01:00
u8 getexpState;
2017-10-02 22:32:39 +01:00
u8 battleStyle;
2019-08-23 13:46:21 +01:00
u8 drawlvlupboxState;
2017-09-24 23:09:13 +01:00
u8 learnMoveState;
u8 savedBattler;
2017-10-09 17:18:40 +01:00
u8 reshowMainState;
u8 reshowHelperState;
u8 levelUpHP;
2021-10-04 15:21:03 +01:00
u8 windowsType; // B_WIN_TYPE_*
2017-10-01 00:12:42 +01:00
u8 multiplayerId;
2018-10-21 19:13:12 +01:00
u8 specialTrainerBattleType;
2018-08-03 17:01:14 +01:00
bool8 monCaught;
s32 savedDmg;
2019-02-14 12:17:27 +00:00
u16 savedMoveEffect; // For moves hitting multiple targets.
u16 moveEffect;
u16 multihitMoveEffect;
u8 illusionNickHack; // To properly display nick in STRINGID_ENEMYABOUTTOSWITCHPKMN.
2021-09-02 20:33:42 +01:00
bool8 fixedPopup; // Force ability popup to stick until manually called back
u16 abilityPopupOverwrite;
2021-09-02 20:33:42 +01:00
u8 switchCase; // Special switching conditions, eg. red card
2021-07-25 21:55:52 +01:00
u8 overrideBerryRequirements;
u8 stickyWebStatDrop; // To prevent Defiant activating on a Court Change'd Sticky Web
2017-09-05 08:41:48 +01:00
};
2017-10-01 17:54:01 +01:00
struct BattleSpriteInfo
{
2018-06-20 22:07:51 +01: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 17:54:01 +01:00
u16 transformSpecies;
};
struct BattleAnimationInfo
{
2017-11-04 15:11:13 +00:00
u16 animArg; // to fill up later
2017-10-18 20:42:00 +01: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 01:03:21 +00:00
u8 introAnimActive:1;
u8 wildMonInvisible:1;
2018-06-20 22:07:51 +01: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 17:19:49 +00:00
u8 field_B;
s16 ballSubpx;
2017-11-02 17:19:49 +00:00
u8 field_E;
u8 field_F;
2017-10-01 17:54:01 +01:00
};
2017-10-02 22:32:39 +01:00
struct BattleHealthboxInfo
{
2018-06-28 20:06:32 +01:00
u8 partyStatusSummaryShown:1;
2018-06-20 22:07:51 +01:00
u8 healthboxIsBouncing:1;
u8 battlerIsBouncing:1;
u8 ballAnimActive:1; // 0x8
u8 statusAnimActive:1; // x10
u8 animFromTableActive:1; // x20
2018-06-28 20:06:32 +01:00
u8 specialAnimActive:1; // x40
2020-08-30 20:11:44 +01:00
u8 triedShinyMonAnim:1;
u8 finishedShinyMonAnim:1;
2022-08-18 19:23:45 +01:00
u8 opponentDrawPartyStatusSummaryDelay:4;
2021-01-23 01:03:21 +00:00
u8 bgmRestored:1;
u8 waitForCry:1;
u8 healthboxSlideInStarted:1;
2018-06-20 22:07:51 +01:00
u8 healthboxBounceSpriteId;
u8 battlerBounceSpriteId;
2017-10-22 17:43:15 +01:00
u8 animationState;
2021-01-23 01:03:21 +00:00
u8 partyStatusDelayTimer;
2018-12-18 04:08:08 +00:00
u8 matrixNum;
2017-11-04 15:11:13 +00:00
u8 shadowSpriteId;
2021-01-23 01:03:21 +00:00
u8 soundTimer;
u8 introEndDelay;
2017-10-02 22:32:39 +01:00
u8 field_A;
u8 field_B;
};
2017-10-16 17:12:27 +01:00
struct BattleBarInfo
{
u8 healthboxSpriteId;
2017-10-19 14:28:41 +01:00
s32 maxValue;
2018-06-18 23:43:15 +01:00
s32 oldValue;
2017-10-22 17:43:15 +01:00
s32 receivedValue;
2018-06-18 23:43:15 +01:00
s32 currValue;
2017-10-16 17:12:27 +01:00
};
2017-10-01 17:54:01 +01:00
struct BattleSpriteData
{
2018-02-06 22:09:39 +00:00
struct BattleSpriteInfo *battlerData;
2017-10-02 22:32:39 +01:00
struct BattleHealthboxInfo *healthBoxesData;
2017-10-01 17:54:01 +01:00
struct BattleAnimationInfo *animationData;
2017-10-16 17:12:27 +01:00
struct BattleBarInfo *battleBars;
2017-10-01 17:54:01 +01:00
};
2017-09-11 17:27:54 +01:00
#include "sprite.h"
2017-10-01 00:12:42 +01:00
struct MonSpritesGfx
2017-09-11 10:35:41 +01:00
{
void *firstDecompressed; // ptr to the decompressed sprite of the first Pokémon
u8 *spritesGfx[MAX_BATTLERS_COUNT];
2021-10-03 04:47:59 +01:00
struct SpriteTemplate templates[MAX_BATTLERS_COUNT];
struct SpriteFrameImage frameImages[MAX_BATTLERS_COUNT][MAX_MON_PIC_FRAMES];
2017-11-04 15:11:13 +00:00
u8 *barFontGfx;
2020-02-20 05:04:42 +00:00
u16 *buffer;
2017-09-11 10:35:41 +01:00
};
struct QueuedStatBoost
2020-11-19 17:35:37 +00:00
{
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 17:35:37 +00:00
}; /* size = 8 */
2018-06-30 14:35:54 +01:00
// All battle variables are declared in battle_main.c
2018-11-19 16:36:39 +00: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;
extern u8 gDisplayedStringBattle[425];
2018-06-30 14:35:54 +01:00
extern u8 gBattleTextBuff1[TEXT_BUFF_ARRAY_COUNT];
extern u8 gBattleTextBuff2[TEXT_BUFF_ARRAY_COUNT];
extern u8 gBattleTextBuff3[TEXT_BUFF_ARRAY_COUNT + 13]; //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 16:09:36 +01:00
extern u32 gBattleTypeFlags;
2018-02-07 22:21:51 +00:00
extern u8 gBattleTerrain;
2021-10-04 15:21:03 +01:00
extern u8 *gBattleAnimBgTileBuffer;
extern u8 *gBattleAnimBgTilemapBuffer;
2018-02-07 22:21:51 +00:00
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 20:06:32 +01:00
extern u8 gBattlerByTurnOrder[MAX_BATTLERS_COUNT];
2018-02-07 22:21:51 +00: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 10:17:41 +00:00
extern u8 gChosenMovePos;
2018-02-07 22:21:51 +00:00
extern u16 gCurrentMove;
extern u16 gChosenMove;
2018-09-22 17:41:00 +01:00
extern u16 gCalledMove;
2018-02-07 22:21:51 +00:00
extern s32 gBattleMoveDamage;
extern s32 gHpDealt;
2023-10-20 17:46:28 +01:00
extern s32 gBideDmg[MAX_BATTLERS_COUNT];
2018-02-07 22:21:51 +00:00
extern u16 gLastUsedItem;
extern u16 gLastUsedAbility;
2018-02-07 22:21:51 +00:00
extern u8 gBattlerAttacker;
extern u8 gBattlerTarget;
2018-02-08 10:17:41 +00:00
extern u8 gBattlerFainted;
extern u8 gEffectBattler;
2018-02-08 11:13:29 +00:00
extern u8 gPotentialItemEffectBattler;
2018-02-07 22:21:51 +00:00
extern u8 gAbsentBattlerFlags;
2018-07-14 21:56:03 +01:00
extern u8 gIsCriticalHit;
2018-02-07 22:21:51 +00: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 17:37:03 +01:00
extern u16 gLastUsedMove;
2018-02-07 22:21:51 +00:00
extern u8 gLastHitBy[MAX_BATTLERS_COUNT];
extern u16 gChosenMoveByBattler[MAX_BATTLERS_COUNT];
2018-07-21 14:11:13 +01:00
extern u16 gMoveResultFlags;
2018-02-07 22:21:51 +00:00
extern u32 gHitMarker;
2023-10-20 17:46:28 +01:00
extern u8 gBideTarget[MAX_BATTLERS_COUNT];
extern u32 gSideStatuses[NUM_BATTLE_SIDES];
2022-10-20 12:41:18 +01:00
extern struct SideTimer gSideTimers[NUM_BATTLE_SIDES];
2018-02-07 22:21:51 +00:00
extern u32 gStatuses3[MAX_BATTLERS_COUNT];
2021-10-10 05:13:23 +01:00
extern u32 gStatuses4[MAX_BATTLERS_COUNT];
2018-02-07 22:21:51 +00:00
extern struct DisableStruct gDisableStructs[MAX_BATTLERS_COUNT];
extern u16 gPauseCounterBattle;
extern u16 gPaydayMoney;
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 10:17:41 +00:00
extern u16 gIntroSlideFlags;
2018-02-07 22:21:51 +00:00
extern u8 gSentPokesToOpponent[2];
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 10:17:41 +00:00
extern u8 gBattlerStatusSummaryTaskId[MAX_BATTLERS_COUNT];
2018-02-07 22:21:51 +00:00
extern u8 gBattlerInMenuId;
extern bool8 gDoingBattleAnim;
extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
extern bool8 gTransformedShininess[MAX_BATTLERS_COUNT];
2018-02-07 22:21:51 +00:00
extern u8 gPlayerDpadHoldFrames;
extern struct BattleSpriteData *gBattleSpritesDataPtr;
extern struct MonSpritesGfx *gMonSpritesGfxPtr;
extern u16 gBattleMovePower;
extern u16 gMoveToLearn;
2018-07-14 12:17:10 +01:00
extern u32 gFieldStatuses;
extern struct FieldTimer gFieldTimers;
2018-09-29 12:36:33 +01:00
extern u8 gBattlerAbility;
extern struct QueuedStatBoost gQueuedStatBoosts[MAX_BATTLERS_COUNT];
extern const struct BattleMoveEffect gBattleMoveEffects[];
2018-02-07 22:21:51 +00:00
extern void (*gPreBattleCallback1)(void);
extern void (*gBattleMainFunc)(void);
extern struct BattleResults gBattleResults;
extern u8 gLeveledUpInBattle;
extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gMultiUsePlayerCursor;
extern u8 gNumberOfMovesToChoose;
2020-12-03 02:09:35 +00:00
extern bool8 gHasFetchedBall;
extern u8 gLastUsedBall;
extern u16 gLastThrownBall;
extern u16 gBallToDisplay;
extern bool8 gLastUsedBallMenuPresent;
2022-05-05 23:54:33 +01:00
extern u8 gPartyCriticalHits[PARTY_SIZE];
extern u8 gCategoryIconSpriteId;
2017-09-11 10:35:41 +01:00
static inline u32 GetBattlerPosition(u32 battler)
{
return gBattlerPositions[battler];
}
static inline u32 GetBattlerSide(u32 battler)
{
return GetBattlerPosition(battler) & BIT_SIDE;
}
static inline struct Pokemon *GetSideParty(u32 side)
{
return (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
}
static inline struct Pokemon *GetBattlerParty(u32 battler)
{
return GetSideParty(GetBattlerSide(battler));
}
2017-09-11 10:35:41 +01:00
#endif // GUARD_BATTLE_H