forked from pret/pokefirered
-
Notifications
You must be signed in to change notification settings - Fork 0
/
battle.h
726 lines (658 loc) · 21.3 KB
/
battle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
#ifndef GUARD_BATTLE_H
#define GUARD_BATTLE_H
#include <limits.h>
#include "global.h"
#include "constants/battle.h"
#include "constants/battle_script_commands.h"
#include "battle_util.h"
#include "battle_script_commands.h"
#include "battle_main.h"
#include "battle_ai_switch_items.h"
#include "battle_gfx_sfx_util.h"
#include "battle_util2.h"
#include "battle_bg.h"
/*
Banks are a name given to what could be called a 'battlerId' or 'monControllerId'.
Each bank has a value consisting of two bits.
0x1 bit is responsible for the side, 0 = player's side, 1 = opponent's side.
0x2 bit is responsible for the id of sent out pokemon. 0 means it's the first sent out pokemon, 1 it's the second one. (Triple battle didn't exist at the time yet.)
*/
#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))
// 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]))
// 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_BAIT 6
#define B_ACTION_SAFARI_GO_NEAR 7
#define B_ACTION_SAFARI_RUN 8
#define B_ACTION_OLDMAN_THROW 9
#define B_ACTION_EXEC_SCRIPT 10
#define B_ACTION_TRY_FINISH 11
#define B_ACTION_FINISHED 12
#define B_ACTION_CANCEL_PARTNER 12 // when choosing an action
#define B_ACTION_NOTHING_FAINTED 13 // when choosing an action
#define B_ACTION_NONE 0xFF
#define MAX_TRAINER_ITEMS 4
enum {
BATTLER_AFFINE_NORMAL,
BATTLER_AFFINE_EMERGE,
BATTLER_AFFINE_RETURN,
};
#define MOVE_TARGET_SELECTED 0
#define MOVE_TARGET_DEPENDS (1 << 0)
#define MOVE_TARGET_USER_OR_SELECTED (1 << 1)
#define MOVE_TARGET_RANDOM (1 << 2)
#define MOVE_TARGET_BOTH (1 << 3)
#define MOVE_TARGET_USER (1 << 4)
#define MOVE_TARGET_FOES_AND_ALLY (1 << 5)
#define MOVE_TARGET_OPPONENTS_FIELD (1 << 6)
// For the second argument of GetMoveTarget, when no target override is needed
#define NO_TARGET_OVERRIDE 0
struct TrainerMonNoItemDefaultMoves
{
u16 iv;
u8 lvl;
u16 species;
};
struct TrainerMonItemDefaultMoves
{
u16 iv;
u8 lvl;
u16 species;
u16 heldItem;
};
struct TrainerMonNoItemCustomMoves
{
u16 iv;
u8 lvl;
u16 species;
u16 moves[MAX_MON_MOVES];
};
struct TrainerMonItemCustomMoves
{
u16 iv;
u8 lvl;
u16 species;
u16 heldItem;
u16 moves[MAX_MON_MOVES];
};
#define NO_ITEM_DEFAULT_MOVES(party) { .NoItemDefaultMoves = party }, .partySize = ARRAY_COUNT(party), .partyFlags = 0
#define NO_ITEM_CUSTOM_MOVES(party) { .NoItemCustomMoves = party }, .partySize = ARRAY_COUNT(party), .partyFlags = F_TRAINER_PARTY_CUSTOM_MOVESET
#define ITEM_DEFAULT_MOVES(party) { .ItemDefaultMoves = party }, .partySize = ARRAY_COUNT(party), .partyFlags = F_TRAINER_PARTY_HELD_ITEM
#define ITEM_CUSTOM_MOVES(party) { .ItemCustomMoves = party }, .partySize = ARRAY_COUNT(party), .partyFlags = F_TRAINER_PARTY_CUSTOM_MOVESET | F_TRAINER_PARTY_HELD_ITEM
union TrainerMonPtr
{
const struct TrainerMonNoItemDefaultMoves *NoItemDefaultMoves;
const struct TrainerMonNoItemCustomMoves *NoItemCustomMoves;
const struct TrainerMonItemDefaultMoves *ItemDefaultMoves;
const struct TrainerMonItemCustomMoves *ItemCustomMoves;
};
struct Trainer
{
/*0x00*/ u8 partyFlags;
/*0x01*/ u8 trainerClass;
/*0x02*/ u8 encounterMusic_gender; // last bit is gender
/*0x03*/ u8 trainerPic;
/*0x04*/ u8 trainerName[12];
/*0x10*/ u16 items[MAX_TRAINER_ITEMS];
/*0x18*/ bool8 doubleBattle;
/*0x1C*/ u32 aiFlags;
/*0x20*/ u8 partySize;
/*0x24*/ const union TrainerMonPtr party;
};
extern const struct Trainer gTrainers[];
struct ResourceFlags
{
u32 flags[4];
};
#define RESOURCE_FLAG_FLASH_FIRE 1
struct DisableStruct
{
/*0x00*/ u32 transformedMonPersonality;
/*0x04*/ u16 disabledMove;
/*0x06*/ u16 encoredMove;
/*0x08*/ u8 protectUses;
/*0x09*/ u8 stockpileCounter;
/*0x0A*/ u8 substituteHP;
/*0x0B*/ u8 disableTimer : 4;
/*0x0B*/ u8 disableTimerStartValue : 4;
/*0x0C*/ u8 encoredMovePos;
/*0x0D*/ u8 unkD;
/*0x0E*/ u8 encoreTimer : 4;
/*0x0E*/ u8 encoreTimerStartValue : 4;
/*0x0F*/ u8 perishSongTimer : 4;
/*0x0F*/ u8 perishSongTimerStartValue : 4;
/*0x10*/ u8 furyCutterCounter;
/*0x11*/ u8 rolloutTimer : 4;
/*0x11*/ u8 rolloutTimerStartValue : 4;
/*0x12*/ u8 chargeTimer : 4;
/*0x12*/ u8 chargeTimerStartValue : 4;
/*0x13*/ u8 tauntTimer:4;
/*0x13*/ u8 tauntTimer2:4;
/*0x14*/ u8 battlerPreventingEscape;
/*0x15*/ u8 battlerWithSureHit;
/*0x16*/ u8 isFirstTurn;
/*0x17*/ u8 unk17;
/*0x18*/ u8 truantCounter : 1;
/*0x18*/ u8 truantSwitchInHack : 1; // Unused here, but used in pokeemerald
/*0x18*/ u8 unk18_a_2 : 2;
/*0x18*/ u8 mimickedMoves : 4;
/*0x19*/ u8 rechargeTimer;
/*0x1A*/ u8 unk1A[2];
};
extern struct DisableStruct gDisableStructs[MAX_BATTLERS_COUNT];
struct ProtectStruct
{
/* field_0 */
u32 protected:1;
u32 endured:1;
u32 noValidMoves:1;
u32 helpingHand:1;
u32 bounceMove:1;
u32 stealMove:1;
u32 flag0Unknown:1;
u32 prlzImmobility:1;
/* field_1 */
u32 confusionSelfDmg:1;
u32 targetNotAffected:1;
u32 chargingTurn:1;
u32 fleeType:2; // for RunAway and Smoke Ball
u32 usedImprisonedMove:1;
u32 loveImmobility:1;
u32 usedDisabledMove:1;
/* field_2 */
u32 usedTauntedMove:1; // 0x1
u32 flag2Unknown:1; // 0x2
u32 flinchImmobility:1; // 0x4
u32 notFirstStrike:1; // 0x8
u32 flag_x10 : 1; // 0x10
u32 flag_x20 : 1; // 0x20
u32 flag_x40 : 1; // 0x40
u32 flag_x80 : 1; // 0x80
u32 field3 : 8;
u32 physicalDmg;
u32 specialDmg;
u8 physicalBattlerId;
u8 specialBattlerId;
u16 fieldE;
};
extern struct ProtectStruct gProtectStructs[MAX_BATTLERS_COUNT];
struct SpecialStatus
{
u8 statLowered:1; // 0x1
u8 lightningRodRedirected:1; // 0x2
u8 restoredBattlerSprite:1; // 0x4
u8 intimidatedMon:1; // 0x8
u8 traced:1; // 0x10
u8 ppNotAffectedByPressure:1;
u8 faintedHasReplacement:1;
u8 focusBanded:1;
u8 field1[3];
s32 dmg;
s32 physicalDmg;
s32 specialDmg;
u8 physicalBattlerId;
u8 specialBattlerId;
u8 field12;
u8 field13;
};
extern struct SpecialStatus gSpecialStatuses[MAX_BATTLERS_COUNT];
struct SideTimer
{
/*0x00*/ u8 reflectTimer;
/*0x01*/ u8 reflectBattlerId;
/*0x02*/ u8 lightscreenTimer;
/*0x03*/ u8 lightscreenBattlerId;
/*0x04*/ u8 mistTimer;
/*0x05*/ u8 mistBattlerId;
/*0x06*/ u8 safeguardTimer;
/*0x07*/ u8 safeguardBattlerId;
/*0x08*/ u8 followmeTimer;
/*0x09*/ u8 followmeTarget;
/*0x0A*/ u8 spikesAmount;
/*0x0B*/ u8 fieldB;
};
extern struct SideTimer gSideTimers[];
struct WishFutureKnock
{
u8 futureSightCounter[MAX_BATTLERS_COUNT];
u8 futureSightAttacker[MAX_BATTLERS_COUNT];
s32 futureSightDmg[MAX_BATTLERS_COUNT];
u16 futureSightMove[MAX_BATTLERS_COUNT];
u8 wishCounter[MAX_BATTLERS_COUNT];
u8 wishMonId[MAX_BATTLERS_COUNT];
u8 weatherDuration;
u8 knockedOffMons[2];
};
extern struct WishFutureKnock gWishFutureKnock;
struct AI_ThinkingStruct
{
u8 aiState;
u8 movesetIndex;
u16 moveConsidered;
s8 score[4];
u32 funcResult;
u32 aiFlags;
u8 aiAction;
u8 aiLogicId;
u8 filler12[6];
u8 simulatedRNG[4];
};
extern u8 gActiveBattler;
extern u8 gBattlerTarget;
extern u8 gAbsentBattlerFlags;
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
struct UsedMoves
{
u16 moves[MAX_BATTLERS_COUNT];
u16 unknown[MAX_BATTLERS_COUNT];
};
struct BattleHistory
{
/*0x00*/ u16 usedMoves[2][8]; // 0xFFFF means move not used (confuse self hit, etc)
/*0x20*/ u8 abilities[MAX_BATTLERS_COUNT / 2];
/*0x22*/ u8 itemEffects[MAX_BATTLERS_COUNT / 2];
/*0x24*/ u16 trainerItems[MAX_BATTLERS_COUNT];
/*0x2C*/ u8 itemsNo;
};
struct BattleScriptsStack
{
const u8 *ptr[8];
u8 size;
};
struct BattleCallbacksStack
{
void (*function[8])(void);
u8 size;
};
struct StatsArray
{
u16 stats[NUM_STATS];
};
struct BattleResources
{
struct SecretBaseRecord *secretBase;
struct ResourceFlags *flags;
struct BattleScriptsStack *battleScriptsStack;
struct BattleCallbacksStack *battleCallbackStack;
struct StatsArray *beforeLvlUp;
struct AI_ThinkingStruct *ai;
struct BattleHistory *battleHistory;
struct BattleScriptsStack *AI_ScriptsStack;
};
extern struct BattleResources *gBattleResources;
struct BattleResults
{
u8 playerFaintCounter; // 0x0
u8 opponentFaintCounter; // 0x1
u8 playerSwitchesCounter; // 0x2
u8 numHealingItemsUsed; // 0x3
u8 numRevivesUsed; // 0x4
u8 playerMonWasDamaged:1; // 0x5
u8 usedMasterBall:1; // 0x5
u8 caughtMonBall:4; // 0x5
u8 shinyWildMon:1; // 0x5
u8 unk5_7:1; // 0x5
u16 playerMon1Species; // 0x6
u8 playerMon1Name[11]; // 0x8
u8 battleTurnCounter; // 0x13
u8 playerMon2Name[11]; // 0x14
u8 pokeblockThrows; // 0x1F
u16 lastOpponentSpecies; // 0x20
u16 lastUsedMovePlayer; // 0x22
u16 lastUsedMoveOpponent; // 0x24
u16 playerMon2Species; // 0x26
u16 caughtMonSpecies; // 0x28
u8 caughtMonNick[10]; // 0x2A
u8 filler34[2];
u8 catchAttempts[11]; // 0x36
};
extern struct BattleResults gBattleResults;
struct LinkBattlerHeader
{
u8 versionSignatureLo;
u8 versionSignatureHi;
u8 vsScreenHealthFlagsLo;
u8 vsScreenHealthFlagsHi;
struct BattleEnigmaBerry battleEnigmaBerry;
};
struct BattleStruct
{
u8 turnEffectsTracker;
u8 turnEffectsBattlerId;
u8 filler2; // unused
u8 turnCountersTracker;
u8 wrappedMove[MAX_BATTLERS_COUNT * 2]; // Leftover from Ruby's ewram access.
u8 moveTarget[MAX_BATTLERS_COUNT];
u8 expGetterMonId;
u8 field_11; // unused
u8 wildVictorySong;
u8 dynamicMoveType;
u8 wrappedBy[MAX_BATTLERS_COUNT];
u16 assistPossibleMoves[PARTY_SIZE * MAX_MON_MOVES]; // 6 mons, each of them knowing 4 moves
u8 focusPunchBattlerId;
u8 battlerPreventingSwitchout;
u8 moneyMultiplier;
u8 savedTurnActionNumber;
u8 switchInAbilitiesCounter;
u8 faintedActionsState;
u8 faintedActionsBattlerId;
// balign 2
u16 expValue;
u8 scriptPartyIdx; // for printing the nickname
u8 sentInPokes;
bool8 selectionScriptFinished[MAX_BATTLERS_COUNT];
u8 battlerPartyIndexes[MAX_BATTLERS_COUNT];
u8 monToSwitchIntoId[MAX_BATTLERS_COUNT];
u8 battlerPartyOrders[MAX_BATTLERS_COUNT][3];
u8 runTries;
u8 caughtMonNick[POKEMON_NAME_LENGTH + 1];
u8 field_78; // unused
u8 safariRockThrowCounter;
u8 safariBaitThrowCounter;
u8 safariEscapeFactor;
u8 safariCatchFactor;
u8 linkBattleVsSpriteId_V;
u8 linkBattleVsSpriteId_S;
u8 formToChangeInto;
u8 chosenMovePositions[MAX_BATTLERS_COUNT];
u8 stateIdAfterSelScript[MAX_BATTLERS_COUNT];
u8 field_88; // unused
u8 field_89; // unused
u8 field_8A; // unused
u8 playerPartyIdx;
u8 field_8C; // unused
u8 field_8D; // unused
u8 stringMoveType;
u8 expGetterBattlerId;
u8 field_90; // unused
u8 absentBattlerFlags;
u8 AI_monToSwitchIntoId[2];
u8 simulatedInputState[4]; // used by Oak/Old Man/Pokedude controllers
u8 lastTakenMove[MAX_BATTLERS_COUNT * 2 * 2]; // ask gamefreak why they declared it that way
u16 hpOnSwitchout[2];
u8 abilityPreventingSwitchout;
u8 hpScale;
u16 savedBattleTypeFlags;
void (*savedCallback)(void);
u8 synchronizeMoveEffect;
u8 multiplayerId;
u8 overworldWeatherDone;
u8 atkCancellerTracker;
u16 usedHeldItems[MAX_BATTLERS_COUNT];
u8 chosenItem[4]; // why is this an u8?
u8 AI_itemType[2];
u8 AI_itemFlags[2];
u16 choicedMove[MAX_BATTLERS_COUNT];
u16 changedItems[MAX_BATTLERS_COUNT];
u8 intimidateBattler;
u8 switchInItemsCounter;
u8 field_DA; // battle tower related
u8 turnSideTracker;
u8 fillerDC[0xDF-0xDC];
u8 givenExpMons;
u8 lastTakenMoveFrom[MAX_BATTLERS_COUNT * MAX_BATTLERS_COUNT * 2];
u16 castformPalette[MAX_BATTLERS_COUNT][16];
u8 wishPerishSongState;
u8 wishPerishSongBattlerId;
u8 lastAttackerToFaintOpponent;
// align 4
union {
struct LinkBattlerHeader linkBattlerHeader;
struct MultiBattlePokemonTx multiBattleMons[3];
} multiBuffer;
u8 padding_1E4[0x1C];
}; // size == 0x200 bytes
extern struct BattleStruct *gBattleStruct;
#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_TYPE_PHYSICAL(moveType)(moveType < TYPE_MYSTERY)
#define IS_TYPE_SPECIAL(moveType)(moveType > TYPE_MYSTERY)
#define TARGET_TURN_DAMAGED ((gSpecialStatuses[gBattlerTarget].physicalDmg != 0 || gSpecialStatuses[gBattlerTarget].specialDmg != 0))
#define IS_BATTLER_OF_TYPE(battlerId, type)((gBattleMons[battlerId].type1 == type || gBattleMons[battlerId].type2 == type))
#define SET_BATTLER_TYPE(battlerId, type) \
{ \
gBattleMons[battlerId].type1 = type; \
gBattleMons[battlerId].type2 = type; \
}
#define GET_STAT_BUFF_ID(n)((n & 0xF)) // first four bits 0x1, 0x2, 0x4, 0x8
#define GET_STAT_BUFF_VALUE2(n)((n & 0xF0))
#define GET_STAT_BUFF_VALUE(n)(((n >> 4) & 7)) // 0x10, 0x20, 0x40
#define STAT_BUFF_NEGATIVE 0x80 // 0x80, the sign bit
#define SET_STAT_BUFF_VALUE(n)(((s8)(((s8)(n) << 4)) & 0xF0))
#define SET_STATCHANGER(statId, stage, goesDown)(gBattleScripting.statChanger = (statId) + (stage << 4) + (goesDown << 7))
// NOTE: The members of this struct have hard-coded offsets
// in include/constants/battle_script_commands.h
struct BattleScripting
{
s32 painSplitHp;
s32 bideDmg;
u8 multihitString[6];
u8 dmgMultiplier;
u8 twoTurnsMoveStringId;
u8 animArg1;
u8 animArg2;
u16 tripleKickPower;
u8 moveendState;
u8 battlerWithAbility;
u8 multihitMoveEffect;
u8 battler;
u8 animTurn;
u8 animTargetsHit;
u8 statChanger;
bool8 statAnimPlayed;
u8 getexpState;
u8 battleStyle;
u8 drawlvlupboxState;
u8 learnMoveState;
u8 pursuitDoublesAttacker;
u8 reshowMainState;
u8 reshowHelperState;
u8 levelUpHP;
};
struct BattleSpriteInfo
{
/*0x0*/ u16 invisible : 1; // 0x1
u16 lowHpSong : 1; // 0x2
u16 behindSubstitute : 1; // 0x4
u16 flag_x8 : 1; // 0x8
u16 hpNumbersNoBars : 1; // 0x10
/*0x2*/ u16 transformSpecies;
};
struct BattleAnimationInfo
{
u16 animArg; // to fill up later
u8 field_2;
u8 field_3;
u8 field_4;
u8 field_5;
u8 field_6;
u8 field_7;
u8 ballThrowCaseId;
u8 introAnimActive:1;
u8 wildMonInvisible:1;
u8 field_9_x1C:3;
u8 field_9_x20:1;
u8 field_9_x40:1;
u8 field_9_x80:1;
u8 numBallParticles;
u8 field_B;
s16 ballSubpx;
u8 field_E;
u8 field_F;
};
struct BattleHealthboxInfo
{
u8 partyStatusSummaryShown : 1; // x1
u8 healthboxIsBouncing : 1; // x2
u8 battlerIsBouncing : 1; // x4
u8 ballAnimActive : 1; // 0x8
u8 statusAnimActive : 1; // x10
u8 animFromTableActive : 1; // x20
u8 specialAnimActive : 1; // x40
u8 triedShinyMonAnim : 1; // x80
u8 finishedShinyMonAnim : 1; // x1
u8 opponentDrawPartyStatusSummaryDelay : 5; // x2
u8 healthboxBounceSpriteId;
u8 battlerBounceSpriteId;
u8 animationState;
u8 partyStatusDelayTimer;
u8 matrixNum;
u8 shadowSpriteId;
u8 soundTimer;
u8 introEndDelay;
};
struct BattleBarInfo
{
u8 healthboxSpriteId;
s32 maxValue;
s32 oldValue;
s32 receivedValue; // if positive/negative, fills the bar to the left/right respectively
s32 currValue;
};
struct BattleSpriteData
{
struct BattleSpriteInfo *battlerData;
struct BattleHealthboxInfo *healthBoxesData;
struct BattleAnimationInfo *animationData;
struct BattleBarInfo *battleBars;
};
extern struct BattleSpriteData *gBattleSpritesDataPtr;
#define BATTLE_BUFFER_LINK_SIZE 0x1000
extern u8 *gLinkBattleSendBuffer;
extern u8 *gLinkBattleRecvBuffer;
// Move this somewhere else
#include "sprite.h"
struct MonSpritesGfx
{
void *firstDecompressed; // ptr to the decompressed sprite of the first pokemon
void *sprites[MAX_BATTLERS_COUNT];
struct SpriteTemplate templates[MAX_BATTLERS_COUNT];
struct SpriteFrameImage images[MAX_BATTLERS_COUNT][4];
u8 field_F4[0x80]; // unused
u8 *barFontGfx;
void *field_178; // freed but never allocated
u16 *multiUseBuffer;
};
struct PokedudeBattlerState
{
u8 action_idx;
u8 move_idx;
u8 timer;
u8 msg_idx;
u8 saved_bg0y;
};
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 struct BattleSpritesGfx *gMonSpritesGfx;
extern u8 gBattleOutcome;
extern u16 gLastUsedItem;
extern u32 gBattleTypeFlags;
extern struct MonSpritesGfx *gMonSpritesGfxPtr;
extern u16 gTrainerBattleOpponent_A;
extern u16 gMoveToLearn;
extern u16 gBattleMovePower;
extern struct BattleEnigmaBerry gEnigmaBerries[MAX_BATTLERS_COUNT];
extern u16 gCurrentMove;
extern u16 gChosenMove;
extern u16 gCalledMove;
extern u8 gCritMultiplier;
extern u16 gBattleWeather;
extern u8 gLastUsedAbility;
extern u8 gBattlerInMenuId;
extern u8 gPotentialItemEffectBattler;
extern u8 gBattlersCount;
extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern s32 gBattleMoveDamage;
extern u16 gIntroSlideFlags;
extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
extern u8 gBattlerPositions[MAX_BATTLERS_COUNT];
extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT];
extern u8 gBattleOutcome;
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
extern void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void);
extern u32 gBattleControllerExecFlags;
extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200];
extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200];
extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT];
extern void (*gPreBattleCallback1)(void);
extern bool8 gDoingBattleAnim;
extern struct PokedudeBattlerState *gPokedudeBattlerStates[MAX_BATTLERS_COUNT];
extern u8 *gBattleAnimBgTileBuffer;
extern u8 *gBattleAnimBgTilemapBuffer;
extern void (*gBattleMainFunc)(void);
extern u8 gMoveSelectionCursor[MAX_BATTLERS_COUNT];
extern u32 gUnusedFirstBattleVar1;
extern u8 gUnusedFirstBattleVar2;
extern u8 gBattlerAttacker;
extern u8 gEffectBattler;
extern u8 gMultiHitCounter;
extern struct BattleScripting gBattleScripting;
extern u8 gBattlerFainted;
extern u32 gStatuses3[MAX_BATTLERS_COUNT];
extern u8 gSentPokesToOpponent[2];
extern const u8 *gBattlescriptCurrInstr;
extern const u8 *gSelectionBattleScripts[MAX_BATTLERS_COUNT];
extern u16 gLastMoves[MAX_BATTLERS_COUNT];
extern u8 gBattlerByTurnOrder[MAX_BATTLERS_COUNT];
extern u8 gBattleCommunication[BATTLE_COMMUNICATION_ENTRIES_COUNT];
extern u16 gSideStatuses[2];
extern u32 gHitMarker;
extern u16 gChosenMoveByBattler[MAX_BATTLERS_COUNT];
extern u8 gMoveResultFlags;
extern s32 gTakenDmg[MAX_BATTLERS_COUNT];
extern u8 gTakenDmgByBattler[MAX_BATTLERS_COUNT];
extern u8 gCurrentActionFuncId;
extern u8 gCurrMovePos;
extern u8 gChosenMovePos;
extern u8 gBattleControllerData[MAX_BATTLERS_COUNT];
extern u8 gBattlerStatusSummaryTaskId[MAX_BATTLERS_COUNT];
extern u16 gDynamicBasePower;
extern u16 gLastLandedMoves[MAX_BATTLERS_COUNT];
extern u8 gLastHitBy[MAX_BATTLERS_COUNT];
extern u8 gMultiUsePlayerCursor;
extern u8 gNumberOfMovesToChoose;
extern u16 gLastHitByType[MAX_BATTLERS_COUNT];
extern s32 gHpDealt;
extern u16 gPauseCounterBattle;
extern u16 gPaydayMoney;
extern u16 gLockedMoves[MAX_BATTLERS_COUNT];
extern u8 gCurrentTurnActionNumber;
extern u16 gExpShareExp;
extern u8 gLeveledUpInBattle;
extern u16 gLastResultingMoves[MAX_BATTLERS_COUNT];
extern u16 gLastPrintedMoves[MAX_BATTLERS_COUNT];
extern u8 gActionsByTurnOrder[MAX_BATTLERS_COUNT];
extern u8 gChosenActionByBattler[MAX_BATTLERS_COUNT];
extern u8 gBattleTerrain;
extern struct MultiBattlePokemonTx gMultiPartnerParty[3];
extern u16 gRandomTurnNumber;
#endif // GUARD_BATTLE_H