forked from danenders/pkedx
-
Notifications
You must be signed in to change notification settings - Fork 1
/
battle_controller_link_partner.c
1697 lines (1536 loc) · 65.4 KB
/
battle_controller_link_partner.c
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
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "global.h"
#include "battle.h"
#include "battle_ai_script_commands.h"
#include "battle_anim.h"
#include "battle_controllers.h"
#include "battle_interface.h"
#include "battle_message.h"
#include "battle_setup.h"
#include "battle_tower.h"
#include "battle_tv.h"
#include "bg.h"
#include "data.h"
#include "link.h"
#include "main.h"
#include "m4a.h"
#include "palette.h"
#include "pokeball.h"
#include "pokemon.h"
#include "recorded_battle.h"
#include "reshow_battle_screen.h"
#include "sound.h"
#include "string_util.h"
#include "task.h"
#include "text.h"
#include "util.h"
#include "window.h"
#include "constants/battle_anim.h"
#include "constants/songs.h"
#include "constants/trainers.h"
#include "recorded_battle.h"
static void LinkPartnerHandleGetMonData(void);
static void LinkPartnerHandleGetRawMonData(void);
static void LinkPartnerHandleSetMonData(void);
static void LinkPartnerHandleSetRawMonData(void);
static void LinkPartnerHandleLoadMonSprite(void);
static void LinkPartnerHandleSwitchInAnim(void);
static void LinkPartnerHandleReturnMonToBall(void);
static void LinkPartnerHandleDrawTrainerPic(void);
static void LinkPartnerHandleTrainerSlide(void);
static void LinkPartnerHandleTrainerSlideBack(void);
static void LinkPartnerHandleFaintAnimation(void);
static void LinkPartnerHandlePaletteFade(void);
static void LinkPartnerHandleSuccessBallThrowAnim(void);
static void LinkPartnerHandleBallThrowAnim(void);
static void LinkPartnerHandlePause(void);
static void LinkPartnerHandleMoveAnimation(void);
static void LinkPartnerHandlePrintString(void);
static void LinkPartnerHandlePrintSelectionString(void);
static void LinkPartnerHandleChooseAction(void);
static void LinkPartnerHandleYesNoBox(void);
static void LinkPartnerHandleChooseMove(void);
static void LinkPartnerHandleChooseItem(void);
static void LinkPartnerHandleChoosePokemon(void);
static void LinkPartnerHandleCmd23(void);
static void LinkPartnerHandleHealthBarUpdate(void);
static void LinkPartnerHandleExpUpdate(void);
static void LinkPartnerHandleStatusIconUpdate(void);
static void LinkPartnerHandleStatusAnimation(void);
static void LinkPartnerHandleStatusXor(void);
static void LinkPartnerHandleDataTransfer(void);
static void LinkPartnerHandleDMA3Transfer(void);
static void LinkPartnerHandlePlayBGM(void);
static void LinkPartnerHandleCmd32(void);
static void LinkPartnerHandleTwoReturnValues(void);
static void LinkPartnerHandleChosenMonReturnValue(void);
static void LinkPartnerHandleOneReturnValue(void);
static void LinkPartnerHandleOneReturnValue_Duplicate(void);
static void LinkPartnerHandleClearUnkVar(void);
static void LinkPartnerHandleSetUnkVar(void);
static void LinkPartnerHandleClearUnkFlag(void);
static void LinkPartnerHandleToggleUnkFlag(void);
static void LinkPartnerHandleHitAnimation(void);
static void LinkPartnerHandleCantSwitch(void);
static void LinkPartnerHandlePlaySE(void);
static void LinkPartnerHandlePlayFanfareOrBGM(void);
static void LinkPartnerHandleFaintingCry(void);
static void LinkPartnerHandleIntroSlide(void);
static void LinkPartnerHandleIntroTrainerBallThrow(void);
static void LinkPartnerHandleDrawPartyStatusSummary(void);
static void LinkPartnerHandleHidePartyStatusSummary(void);
static void LinkPartnerHandleEndBounceEffect(void);
static void LinkPartnerHandleSpriteInvisibility(void);
static void LinkPartnerHandleBattleAnimation(void);
static void LinkPartnerHandleLinkStandbyMsg(void);
static void LinkPartnerHandleResetActionMoveSelection(void);
static void LinkPartnerHandleEndLinkBattle(void);
static void LinkPartnerCmdEnd(void);
static void LinkPartnerBufferRunCommand(void);
static void LinkPartnerBufferExecCompleted(void);
static void SwitchIn_WaitAndEnd(void);
static u32 CopyLinkPartnerMonData(u8 monId, u8 *dst);
static void SetLinkPartnerMonData(u8 monId);
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void LinkPartnerDoMoveAnimation(void);
static void Task_StartSendOutAnim(u8 taskId);
static void EndDrawPartyStatusSummary(void);
static void (*const sLinkPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
{
[CONTROLLER_GETMONDATA] = LinkPartnerHandleGetMonData,
[CONTROLLER_GETRAWMONDATA] = LinkPartnerHandleGetRawMonData,
[CONTROLLER_SETMONDATA] = LinkPartnerHandleSetMonData,
[CONTROLLER_SETRAWMONDATA] = LinkPartnerHandleSetRawMonData,
[CONTROLLER_LOADMONSPRITE] = LinkPartnerHandleLoadMonSprite,
[CONTROLLER_SWITCHINANIM] = LinkPartnerHandleSwitchInAnim,
[CONTROLLER_RETURNMONTOBALL] = LinkPartnerHandleReturnMonToBall,
[CONTROLLER_DRAWTRAINERPIC] = LinkPartnerHandleDrawTrainerPic,
[CONTROLLER_TRAINERSLIDE] = LinkPartnerHandleTrainerSlide,
[CONTROLLER_TRAINERSLIDEBACK] = LinkPartnerHandleTrainerSlideBack,
[CONTROLLER_FAINTANIMATION] = LinkPartnerHandleFaintAnimation,
[CONTROLLER_PALETTEFADE] = LinkPartnerHandlePaletteFade,
[CONTROLLER_SUCCESSBALLTHROWANIM] = LinkPartnerHandleSuccessBallThrowAnim,
[CONTROLLER_BALLTHROWANIM] = LinkPartnerHandleBallThrowAnim,
[CONTROLLER_PAUSE] = LinkPartnerHandlePause,
[CONTROLLER_MOVEANIMATION] = LinkPartnerHandleMoveAnimation,
[CONTROLLER_PRINTSTRING] = LinkPartnerHandlePrintString,
[CONTROLLER_PRINTSTRINGPLAYERONLY] = LinkPartnerHandlePrintSelectionString,
[CONTROLLER_CHOOSEACTION] = LinkPartnerHandleChooseAction,
[CONTROLLER_YESNOBOX] = LinkPartnerHandleYesNoBox,
[CONTROLLER_CHOOSEMOVE] = LinkPartnerHandleChooseMove,
[CONTROLLER_OPENBAG] = LinkPartnerHandleChooseItem,
[CONTROLLER_CHOOSEPOKEMON] = LinkPartnerHandleChoosePokemon,
[CONTROLLER_23] = LinkPartnerHandleCmd23,
[CONTROLLER_HEALTHBARUPDATE] = LinkPartnerHandleHealthBarUpdate,
[CONTROLLER_EXPUPDATE] = LinkPartnerHandleExpUpdate,
[CONTROLLER_STATUSICONUPDATE] = LinkPartnerHandleStatusIconUpdate,
[CONTROLLER_STATUSANIMATION] = LinkPartnerHandleStatusAnimation,
[CONTROLLER_STATUSXOR] = LinkPartnerHandleStatusXor,
[CONTROLLER_DATATRANSFER] = LinkPartnerHandleDataTransfer,
[CONTROLLER_DMA3TRANSFER] = LinkPartnerHandleDMA3Transfer,
[CONTROLLER_PLAYBGM] = LinkPartnerHandlePlayBGM,
[CONTROLLER_32] = LinkPartnerHandleCmd32,
[CONTROLLER_TWORETURNVALUES] = LinkPartnerHandleTwoReturnValues,
[CONTROLLER_CHOSENMONRETURNVALUE] = LinkPartnerHandleChosenMonReturnValue,
[CONTROLLER_ONERETURNVALUE] = LinkPartnerHandleOneReturnValue,
[CONTROLLER_ONERETURNVALUE_DUPLICATE] = LinkPartnerHandleOneReturnValue_Duplicate,
[CONTROLLER_CLEARUNKVAR] = LinkPartnerHandleClearUnkVar,
[CONTROLLER_SETUNKVAR] = LinkPartnerHandleSetUnkVar,
[CONTROLLER_CLEARUNKFLAG] = LinkPartnerHandleClearUnkFlag,
[CONTROLLER_TOGGLEUNKFLAG] = LinkPartnerHandleToggleUnkFlag,
[CONTROLLER_HITANIMATION] = LinkPartnerHandleHitAnimation,
[CONTROLLER_CANTSWITCH] = LinkPartnerHandleCantSwitch,
[CONTROLLER_PLAYSE] = LinkPartnerHandlePlaySE,
[CONTROLLER_PLAYFANFAREORBGM] = LinkPartnerHandlePlayFanfareOrBGM,
[CONTROLLER_FAINTINGCRY] = LinkPartnerHandleFaintingCry,
[CONTROLLER_INTROSLIDE] = LinkPartnerHandleIntroSlide,
[CONTROLLER_INTROTRAINERBALLTHROW] = LinkPartnerHandleIntroTrainerBallThrow,
[CONTROLLER_DRAWPARTYSTATUSSUMMARY] = LinkPartnerHandleDrawPartyStatusSummary,
[CONTROLLER_HIDEPARTYSTATUSSUMMARY] = LinkPartnerHandleHidePartyStatusSummary,
[CONTROLLER_ENDBOUNCE] = LinkPartnerHandleEndBounceEffect,
[CONTROLLER_SPRITEINVISIBILITY] = LinkPartnerHandleSpriteInvisibility,
[CONTROLLER_BATTLEANIMATION] = LinkPartnerHandleBattleAnimation,
[CONTROLLER_LINKSTANDBYMSG] = LinkPartnerHandleLinkStandbyMsg,
[CONTROLLER_RESETACTIONMOVESELECTION] = LinkPartnerHandleResetActionMoveSelection,
[CONTROLLER_ENDLINKBATTLE] = LinkPartnerHandleEndLinkBattle,
[CONTROLLER_TERMINATOR_NOP] = LinkPartnerCmdEnd
};
static void SpriteCB_Null2(void)
{
}
void SetControllerToLinkPartner(void)
{
gBattlerControllerFuncs[gActiveBattler] = LinkPartnerBufferRunCommand;
}
static void LinkPartnerBufferRunCommand(void)
{
if (gBattleControllerExecFlags & gBitTable[gActiveBattler])
{
if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sLinkPartnerBufferCommands))
sLinkPartnerBufferCommands[gBattleBufferA[gActiveBattler][0]]();
else
LinkPartnerBufferExecCompleted();
}
}
static void CompleteOnBattlerSpriteCallbackDummy(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
LinkPartnerBufferExecCompleted();
}
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
BattleGfxSfxDummy3(MALE);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
LinkPartnerBufferExecCompleted();
}
}
static void Intro_DelayAndEnd(void)
{
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
LinkPartnerBufferExecCompleted();
}
}
static void Intro_WaitForHealthbox(void)
{
bool32 finished = FALSE;
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
finished = TRUE;
}
else
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
{
finished = TRUE;
}
}
if (IsCryPlayingOrClearCrySongs())
finished = FALSE;
if (finished)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
}
}
static void Intro_ShowHealthbox(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive
&& gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& ++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay != 1)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 0;
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]]);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL);
StartHealthboxSlideIn(gActiveBattler ^ BIT_FLANK);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]);
}
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattleSpritesDataPtr->animationData->introAnimActive = FALSE;
gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForHealthbox;
}
}
static void WaitForMonAnimAfterLoad(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded && gSprites[gBattlerSpriteIds[gActiveBattler]].x2 == 0)
LinkPartnerBufferExecCompleted();
}
static void CompleteOnHealthbarDone(void)
{
s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1)
{
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
}
else
{
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
LinkPartnerBufferExecCompleted();
}
}
static void FreeMonSpriteAfterFaintAnim(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].y + gSprites[gBattlerSpriteIds[gActiveBattler]].y2 > DISPLAY_HEIGHT)
{
u16 species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES);
BattleGfxSfxDummy2(species);
FreeOamMatrix(gSprites[gBattlerSpriteIds[gActiveBattler]].oam.matrixNum);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
LinkPartnerBufferExecCompleted();
}
}
static void FreeMonSpriteAfterSwitchOutAnim(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[gActiveBattler]]);
SetHealthboxSpriteInvisible(gHealthboxSpriteIds[gActiveBattler]);
LinkPartnerBufferExecCompleted();
}
}
static void CompleteOnInactiveTextPrinter(void)
{
if (!IsTextPrinterActive(B_WIN_MSG))
LinkPartnerBufferExecCompleted();
}
static void DoHitAnimBlinkSpriteEffect(void)
{
u8 spriteId = gBattlerSpriteIds[gActiveBattler];
if (gSprites[spriteId].data[1] == 32)
{
gSprites[spriteId].data[1] = 0;
gSprites[spriteId].invisible = FALSE;
gDoingBattleAnim = FALSE;
LinkPartnerBufferExecCompleted();
}
else
{
if ((gSprites[spriteId].data[1] % 4) == 0)
gSprites[spriteId].invisible ^= 1;
gSprites[spriteId].data[1]++;
}
}
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
CopyBattleSpriteInvisibility(gActiveBattler);
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_WaitAndEnd;
}
}
static void SwitchIn_WaitAndEnd(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
LinkPartnerBufferExecCompleted();
}
}
static void SwitchIn_ShowHealthbox(void)
{
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim = FALSE;
FreeSpriteTilesByTag(ANIM_TAG_GOLD_STARS);
FreeSpritePaletteByTag(ANIM_TAG_GOLD_STARS);
CreateTask(Task_PlayerController_RestoreBgmAfterCry, 10);
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[gActiveBattler]], 0);
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowSubstitute;
}
}
static void SwitchIn_TryShinyAnim(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{
TryShinyAnimation(gActiveBattler, &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]);
}
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
{
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowHealthbox;
}
}
static void LinkPartnerBufferExecCompleted(void)
{
gBattlerControllerFuncs[gActiveBattler] = LinkPartnerBufferRunCommand;
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
u8 playerId = GetMultiplayerId();
PrepareBufferDataTransferLink(2, 4, &playerId);
gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP;
}
else
{
gBattleControllerExecFlags &= ~gBitTable[gActiveBattler];
}
}
static void CompleteOnFinishedStatusAnimation(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive)
LinkPartnerBufferExecCompleted();
}
static void CompleteOnFinishedBattleAnimation(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animFromTableActive)
LinkPartnerBufferExecCompleted();
}
static void LinkPartnerHandleGetMonData(void)
{
u8 monData[sizeof(struct Pokemon) * 2 + 56]; // this allows to get full data of two pokemon, trying to get more will result in overwriting data
u32 size = 0;
u8 monToCheck;
s32 i;
if (gBattleBufferA[gActiveBattler][2] == 0)
{
size += CopyLinkPartnerMonData(gBattlerPartyIndexes[gActiveBattler], monData);
}
else
{
monToCheck = gBattleBufferA[gActiveBattler][2];
for (i = 0; i < PARTY_SIZE; i++)
{
if (monToCheck & 1)
size += CopyLinkPartnerMonData(i, monData + size);
monToCheck >>= 1;
}
}
BtlController_EmitDataTransfer(BUFFER_B, size, monData);
LinkPartnerBufferExecCompleted();
}
static u32 CopyLinkPartnerMonData(u8 monId, u8 *dst)
{
struct BattlePokemon battleMon;
struct MovePpInfo moveData;
u8 nickname[20];
u8 *src;
s16 data16;
u32 data32;
s32 size = 0;
switch (gBattleBufferA[gActiveBattler][1])
{
case REQUEST_ALL_BATTLE:
battleMon.species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES);
battleMon.item = GetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM);
for (size = 0; size < MAX_MON_MOVES; size++)
{
battleMon.moves[size] = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + size);
battleMon.pp[size] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + size);
}
battleMon.ppBonuses = GetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES);
battleMon.friendship = GetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP);
battleMon.experience = GetMonData(&gPlayerParty[monId], MON_DATA_EXP);
battleMon.hpIV = GetMonData(&gPlayerParty[monId], MON_DATA_HP_IV);
battleMon.attackIV = GetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV);
battleMon.defenseIV = GetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV);
battleMon.speedIV = GetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV);
battleMon.spAttackIV = GetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV);
battleMon.spDefenseIV = GetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV);
battleMon.personality = GetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY);
battleMon.status1 = GetMonData(&gPlayerParty[monId], MON_DATA_STATUS);
battleMon.level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL);
battleMon.hp = GetMonData(&gPlayerParty[monId], MON_DATA_HP);
battleMon.maxHP = GetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP);
battleMon.attack = GetMonData(&gPlayerParty[monId], MON_DATA_ATK);
battleMon.defense = GetMonData(&gPlayerParty[monId], MON_DATA_DEF);
battleMon.speed = GetMonData(&gPlayerParty[monId], MON_DATA_SPEED);
battleMon.spAttack = GetMonData(&gPlayerParty[monId], MON_DATA_SPATK);
battleMon.spDefense = GetMonData(&gPlayerParty[monId], MON_DATA_SPDEF);
battleMon.isEgg = GetMonData(&gPlayerParty[monId], MON_DATA_IS_EGG);
battleMon.abilityNum = GetMonData(&gPlayerParty[monId], MON_DATA_ABILITY_NUM);
battleMon.otId = GetMonData(&gPlayerParty[monId], MON_DATA_OT_ID);
GetMonData(&gPlayerParty[monId], MON_DATA_NICKNAME, nickname);
StringCopy_Nickname(battleMon.nickname, nickname);
GetMonData(&gPlayerParty[monId], MON_DATA_OT_NAME, battleMon.otName);
src = (u8 *)&battleMon;
for (size = 0; size < sizeof(battleMon); size++)
dst[size] = src[size];
break;
case REQUEST_SPECIES_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_HELDITEM_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_MOVES_PP_BATTLE:
for (size = 0; size < MAX_MON_MOVES; size++)
{
moveData.moves[size] = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + size);
moveData.pp[size] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + size);
}
moveData.ppBonuses = GetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES);
src = (u8*)(&moveData);
for (size = 0; size < sizeof(moveData); size++)
dst[size] = src[size];
break;
case REQUEST_MOVE1_BATTLE:
case REQUEST_MOVE2_BATTLE:
case REQUEST_MOVE3_BATTLE:
case REQUEST_MOVE4_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_PP_DATA_BATTLE:
for (size = 0; size < MAX_MON_MOVES; size++)
dst[size] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + size);
dst[size] = GetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES);
size++;
break;
case REQUEST_PPMOVE1_BATTLE:
case REQUEST_PPMOVE2_BATTLE:
case REQUEST_PPMOVE3_BATTLE:
case REQUEST_PPMOVE4_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE);
size = 1;
break;
case REQUEST_OTID_BATTLE:
data32 = GetMonData(&gPlayerParty[monId], MON_DATA_OT_ID);
dst[0] = (data32 & 0x000000FF);
dst[1] = (data32 & 0x0000FF00) >> 8;
dst[2] = (data32 & 0x00FF0000) >> 16;
size = 3;
break;
case REQUEST_EXP_BATTLE:
data32 = GetMonData(&gPlayerParty[monId], MON_DATA_EXP);
dst[0] = (data32 & 0x000000FF);
dst[1] = (data32 & 0x0000FF00) >> 8;
dst[2] = (data32 & 0x00FF0000) >> 16;
size = 3;
break;
case REQUEST_HP_EV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_HP_EV);
size = 1;
break;
case REQUEST_ATK_EV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV);
size = 1;
break;
case REQUEST_DEF_EV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV);
size = 1;
break;
case REQUEST_SPEED_EV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV);
size = 1;
break;
case REQUEST_SPATK_EV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV);
size = 1;
break;
case REQUEST_SPDEF_EV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV);
size = 1;
break;
case REQUEST_FRIENDSHIP_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP);
size = 1;
break;
case REQUEST_POKERUS_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_POKERUS);
size = 1;
break;
case REQUEST_MET_LOCATION_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION);
size = 1;
break;
case REQUEST_MET_LEVEL_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL);
size = 1;
break;
case REQUEST_MET_GAME_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME);
size = 1;
break;
case REQUEST_POKEBALL_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL);
size = 1;
break;
case REQUEST_ALL_IVS_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_HP_IV);
dst[1] = GetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV);
dst[2] = GetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV);
dst[3] = GetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV);
dst[4] = GetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV);
dst[5] = GetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV);
size = 6;
break;
case REQUEST_HP_IV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_HP_IV);
size = 1;
break;
case REQUEST_ATK_IV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV);
size = 1;
break;
case REQUEST_DEF_IV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV);
size = 1;
break;
case REQUEST_SPEED_IV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV);
size = 1;
break;
case REQUEST_SPATK_IV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV);
size = 1;
break;
case REQUEST_SPDEF_IV_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV);
size = 1;
break;
case REQUEST_PERSONALITY_BATTLE:
data32 = GetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY);
dst[0] = (data32 & 0x000000FF);
dst[1] = (data32 & 0x0000FF00) >> 8;
dst[2] = (data32 & 0x00FF0000) >> 16;
dst[3] = (data32 & 0xFF000000) >> 24;
size = 4;
break;
case REQUEST_CHECKSUM_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_STATUS_BATTLE:
data32 = GetMonData(&gPlayerParty[monId], MON_DATA_STATUS);
dst[0] = (data32 & 0x000000FF);
dst[1] = (data32 & 0x0000FF00) >> 8;
dst[2] = (data32 & 0x00FF0000) >> 16;
dst[3] = (data32 & 0xFF000000) >> 24;
size = 4;
break;
case REQUEST_LEVEL_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL);
size = 1;
break;
case REQUEST_HP_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_HP);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_MAX_HP_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_ATK_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_ATK);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_DEF_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_DEF);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_SPEED_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_SPEED);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_SPATK_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_SPATK);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_SPDEF_BATTLE:
data16 = GetMonData(&gPlayerParty[monId], MON_DATA_SPDEF);
dst[0] = data16;
dst[1] = data16 >> 8;
size = 2;
break;
case REQUEST_COOL_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_COOL);
size = 1;
break;
case REQUEST_BEAUTY_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY);
size = 1;
break;
case REQUEST_CUTE_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_CUTE);
size = 1;
break;
case REQUEST_SMART_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SMART);
size = 1;
break;
case REQUEST_TOUGH_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_TOUGH);
size = 1;
break;
case REQUEST_SHEEN_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SHEEN);
size = 1;
break;
case REQUEST_COOL_RIBBON_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON);
size = 1;
break;
case REQUEST_BEAUTY_RIBBON_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON);
size = 1;
break;
case REQUEST_CUTE_RIBBON_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON);
size = 1;
break;
case REQUEST_SMART_RIBBON_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON);
size = 1;
break;
case REQUEST_TOUGH_RIBBON_BATTLE:
dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON);
size = 1;
break;
}
return size;
}
static void LinkPartnerHandleGetRawMonData(void)
{
LinkPartnerBufferExecCompleted();
}
static void LinkPartnerHandleSetMonData(void)
{
u8 monToCheck;
u8 i;
if (gBattleBufferA[gActiveBattler][2] == 0)
{
SetLinkPartnerMonData(gBattlerPartyIndexes[gActiveBattler]);
}
else
{
monToCheck = gBattleBufferA[gActiveBattler][2];
for (i = 0; i < PARTY_SIZE; i++)
{
if (monToCheck & 1)
SetLinkPartnerMonData(i);
monToCheck >>= 1;
}
}
LinkPartnerBufferExecCompleted();
}
static void SetLinkPartnerMonData(u8 monId)
{
struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3];
struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3];
s32 i;
switch (gBattleBufferA[gActiveBattler][1])
{
case REQUEST_ALL_BATTLE:
{
u8 iv;
SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &battlePokemon->species);
SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &battlePokemon->item);
for (i = 0; i < MAX_MON_MOVES; i++)
{
SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + i, &battlePokemon->moves[i]);
SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + i, &battlePokemon->pp[i]);
}
SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &battlePokemon->ppBonuses);
SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &battlePokemon->friendship);
SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &battlePokemon->experience);
iv = battlePokemon->hpIV;
SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &iv);
iv = battlePokemon->attackIV;
SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &iv);
iv = battlePokemon->defenseIV;
SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &iv);
iv = battlePokemon->speedIV;
SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &iv);
iv = battlePokemon->spAttackIV;
SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &iv);
iv = battlePokemon->spDefenseIV;
SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &iv);
SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &battlePokemon->personality);
SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &battlePokemon->status1);
SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &battlePokemon->level);
SetMonData(&gPlayerParty[monId], MON_DATA_HP, &battlePokemon->hp);
SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &battlePokemon->maxHP);
SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &battlePokemon->attack);
SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &battlePokemon->defense);
SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &battlePokemon->speed);
SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &battlePokemon->spAttack);
SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &battlePokemon->spDefense);
}
break;
case REQUEST_SPECIES_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_HELDITEM_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_MOVES_PP_BATTLE:
for (i = 0; i < MAX_MON_MOVES; i++)
{
SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + i, &moveData->moves[i]);
SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + i, &moveData->pp[i]);
}
SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &moveData->ppBonuses);
break;
case REQUEST_MOVE1_BATTLE:
case REQUEST_MOVE2_BATTLE:
case REQUEST_MOVE3_BATTLE:
case REQUEST_MOVE4_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_PP_DATA_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]);
SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]);
SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]);
SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]);
SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]);
break;
case REQUEST_PPMOVE1_BATTLE:
case REQUEST_PPMOVE2_BATTLE:
case REQUEST_PPMOVE3_BATTLE:
case REQUEST_PPMOVE4_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_OTID_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_EXP_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_HP_EV_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_ATK_EV_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_DEF_EV_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_SPEED_EV_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_SPATK_EV_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_SPDEF_EV_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_FRIENDSHIP_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_POKERUS_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_MET_LOCATION_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_MET_LEVEL_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_MET_GAME_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_POKEBALL_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_ALL_IVS_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]);
SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]);
SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]);
SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]);
SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]);
SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]);
break;
case REQUEST_HP_IV_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_ATK_IV_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_DEF_IV_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_SPEED_IV_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_SPATK_IV_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_SPDEF_IV_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_PERSONALITY_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_CHECKSUM_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_STATUS_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_LEVEL_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_HP_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_MAX_HP_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_ATK_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_DEF_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_SPEED_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_SPATK_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_SPDEF_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_COOL_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_BEAUTY_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_CUTE_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_SMART_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_TOUGH_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_SHEEN_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_COOL_RIBBON_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_BEAUTY_RIBBON_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_CUTE_RIBBON_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_SMART_RIBBON_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]);
break;
case REQUEST_TOUGH_RIBBON_BATTLE:
SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]);
break;
}
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
}
static void LinkPartnerHandleSetRawMonData(void)