-
Notifications
You must be signed in to change notification settings - Fork 817
/
item_effects.asm
2922 lines (2491 loc) · 47.4 KB
/
item_effects.asm
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
_DoItemEffect::
ld a, [wCurItem]
ld [wNamedObjectIndex], a
call GetItemName
call CopyName1
ld a, 1
ld [wItemEffectSucceeded], a
ld a, [wCurItem]
dec a
ld hl, ItemEffects
rst JumpTable
ret
ItemEffects:
; entries correspond to item ids (see constants/item_constants.asm)
table_width 2, ItemEffects
dw PokeBallEffect ; MASTER_BALL
dw PokeBallEffect ; ULTRA_BALL
dw NoEffect ; BRIGHTPOWDER
dw PokeBallEffect ; GREAT_BALL
dw PokeBallEffect ; POKE_BALL
dw TownMapEffect ; TOWN_MAP
dw BicycleEffect ; BICYCLE
dw EvoStoneEffect ; MOON_STONE
dw StatusHealingEffect ; ANTIDOTE
dw StatusHealingEffect ; BURN_HEAL
dw StatusHealingEffect ; ICE_HEAL
dw StatusHealingEffect ; AWAKENING
dw StatusHealingEffect ; PARLYZ_HEAL
dw FullRestoreEffect ; FULL_RESTORE
dw RestoreHPEffect ; MAX_POTION
dw RestoreHPEffect ; HYPER_POTION
dw RestoreHPEffect ; SUPER_POTION
dw RestoreHPEffect ; POTION
dw EscapeRopeEffect ; ESCAPE_ROPE
dw RepelEffect ; REPEL
dw RestorePPEffect ; MAX_ELIXER
dw EvoStoneEffect ; FIRE_STONE
dw EvoStoneEffect ; THUNDERSTONE
dw EvoStoneEffect ; WATER_STONE
dw NoEffect ; ITEM_19
dw VitaminEffect ; HP_UP
dw VitaminEffect ; PROTEIN
dw VitaminEffect ; IRON
dw VitaminEffect ; CARBOS
dw NoEffect ; LUCKY_PUNCH
dw VitaminEffect ; CALCIUM
dw RareCandyEffect ; RARE_CANDY
dw XAccuracyEffect ; X_ACCURACY
dw EvoStoneEffect ; LEAF_STONE
dw NoEffect ; METAL_POWDER
dw NoEffect ; NUGGET
dw PokeDollEffect ; POKE_DOLL
dw StatusHealingEffect ; FULL_HEAL
dw ReviveEffect ; REVIVE
dw ReviveEffect ; MAX_REVIVE
dw GuardSpecEffect ; GUARD_SPEC
dw SuperRepelEffect ; SUPER_REPEL
dw MaxRepelEffect ; MAX_REPEL
dw DireHitEffect ; DIRE_HIT
dw NoEffect ; ITEM_2D
dw RestoreHPEffect ; FRESH_WATER
dw RestoreHPEffect ; SODA_POP
dw RestoreHPEffect ; LEMONADE
dw XItemEffect ; X_ATTACK
dw NoEffect ; ITEM_32
dw XItemEffect ; X_DEFEND
dw XItemEffect ; X_SPEED
dw XItemEffect ; X_SPECIAL
dw CoinCaseEffect ; COIN_CASE
dw ItemfinderEffect ; ITEMFINDER
dw PokeFluteEffect ; POKE_FLUTE
dw NoEffect ; EXP_SHARE
dw OldRodEffect ; OLD_ROD
dw GoodRodEffect ; GOOD_ROD
dw NoEffect ; SILVER_LEAF
dw SuperRodEffect ; SUPER_ROD
dw RestorePPEffect ; PP_UP
dw RestorePPEffect ; ETHER
dw RestorePPEffect ; MAX_ETHER
dw RestorePPEffect ; ELIXER
dw NoEffect ; RED_SCALE
dw NoEffect ; SECRETPOTION
dw NoEffect ; S_S_TICKET
dw NoEffect ; MYSTERY_EGG
dw NoEffect ; CLEAR_BELL
dw NoEffect ; SILVER_WING
dw RestoreHPEffect ; MOOMOO_MILK
dw NoEffect ; QUICK_CLAW
dw StatusHealingEffect ; PSNCUREBERRY
dw NoEffect ; GOLD_LEAF
dw NoEffect ; SOFT_SAND
dw NoEffect ; SHARP_BEAK
dw StatusHealingEffect ; PRZCUREBERRY
dw StatusHealingEffect ; BURNT_BERRY
dw StatusHealingEffect ; ICE_BERRY
dw NoEffect ; POISON_BARB
dw NoEffect ; KINGS_ROCK
dw BitterBerryEffect ; BITTER_BERRY
dw StatusHealingEffect ; MINT_BERRY
dw NoEffect ; RED_APRICORN
dw NoEffect ; TINYMUSHROOM
dw NoEffect ; BIG_MUSHROOM
dw NoEffect ; SILVERPOWDER
dw NoEffect ; BLU_APRICORN
dw NoEffect ; ITEM_5A
dw NoEffect ; AMULET_COIN
dw NoEffect ; YLW_APRICORN
dw NoEffect ; GRN_APRICORN
dw NoEffect ; CLEANSE_TAG
dw NoEffect ; MYSTIC_WATER
dw NoEffect ; TWISTEDSPOON
dw NoEffect ; WHT_APRICORN
dw NoEffect ; BLACKBELT_I
dw NoEffect ; BLK_APRICORN
dw NoEffect ; ITEM_64
dw NoEffect ; PNK_APRICORN
dw NoEffect ; BLACKGLASSES
dw NoEffect ; SLOWPOKETAIL
dw NoEffect ; PINK_BOW
dw NoEffect ; STICK
dw NoEffect ; SMOKE_BALL
dw NoEffect ; NEVERMELTICE
dw NoEffect ; MAGNET
dw StatusHealingEffect ; MIRACLEBERRY
dw NoEffect ; PEARL
dw NoEffect ; BIG_PEARL
dw NoEffect ; EVERSTONE
dw NoEffect ; SPELL_TAG
dw RestoreHPEffect ; RAGECANDYBAR
dw NoEffect ; GS_BALL
dw BlueCardEffect ; BLUE_CARD
dw NoEffect ; MIRACLE_SEED
dw NoEffect ; THICK_CLUB
dw NoEffect ; FOCUS_BAND
dw NoEffect ; ITEM_78
dw EnergypowderEffect ; ENERGYPOWDER
dw EnergyRootEffect ; ENERGY_ROOT
dw HealPowderEffect ; HEAL_POWDER
dw RevivalHerbEffect ; REVIVAL_HERB
dw NoEffect ; HARD_STONE
dw NoEffect ; LUCKY_EGG
dw CardKeyEffect ; CARD_KEY
dw NoEffect ; MACHINE_PART
dw NoEffect ; EGG_TICKET
dw NoEffect ; LOST_ITEM
dw NoEffect ; STARDUST
dw NoEffect ; STAR_PIECE
dw BasementKeyEffect ; BASEMENT_KEY
dw NoEffect ; PASS
dw NoEffect ; ITEM_87
dw NoEffect ; ITEM_88
dw NoEffect ; ITEM_89
dw NoEffect ; CHARCOAL
dw RestoreHPEffect ; BERRY_JUICE
dw NoEffect ; SCOPE_LENS
dw NoEffect ; ITEM_8D
dw NoEffect ; ITEM_8E
dw NoEffect ; METAL_COAT
dw NoEffect ; DRAGON_FANG
dw NoEffect ; ITEM_91
dw NoEffect ; LEFTOVERS
dw NoEffect ; ITEM_93
dw NoEffect ; ITEM_94
dw NoEffect ; ITEM_95
dw RestorePPEffect ; MYSTERYBERRY
dw NoEffect ; DRAGON_SCALE
dw NoEffect ; BERSERK_GENE
dw NoEffect ; ITEM_99
dw NoEffect ; ITEM_9A
dw NoEffect ; ITEM_9B
dw SacredAshEffect ; SACRED_ASH
dw PokeBallEffect ; HEAVY_BALL
dw NoEffect ; FLOWER_MAIL
dw PokeBallEffect ; LEVEL_BALL
dw PokeBallEffect ; LURE_BALL
dw PokeBallEffect ; FAST_BALL
dw NoEffect ; ITEM_A2
dw NoEffect ; LIGHT_BALL
dw PokeBallEffect ; FRIEND_BALL
dw PokeBallEffect ; MOON_BALL
dw PokeBallEffect ; LOVE_BALL
dw NormalBoxEffect ; NORMAL_BOX
dw GorgeousBoxEffect ; GORGEOUS_BOX
dw EvoStoneEffect ; SUN_STONE
dw NoEffect ; POLKADOT_BOW
dw NoEffect ; ITEM_AB
dw NoEffect ; UP_GRADE
dw RestoreHPEffect ; BERRY
dw RestoreHPEffect ; GOLD_BERRY
dw SquirtbottleEffect ; SQUIRTBOTTLE
dw NoEffect ; ITEM_B0
dw PokeBallEffect ; PARK_BALL
dw NoEffect ; RAINBOW_WING
dw NoEffect ; ITEM_B3
assert_table_length ITEM_B3
; The items past ITEM_B3 do not have effect entries:
; BRICK_PIECE
; SURF_MAIL
; LITEBLUEMAIL
; PORTRAITMAIL
; LOVELY_MAIL
; EON_MAIL
; MORPH_MAIL
; BLUESKY_MAIL
; MUSIC_MAIL
; MIRAGE_MAIL
; ITEM_BE
; They all have the ITEMMENU_NOUSE attribute so they can't be used anyway.
; NoEffect would be appropriate, with the table then being NUM_ITEMS long.
PokeBallEffect:
; BUG: The Dude's catching tutorial may crash if his Poké Ball can't be used (see docs/bugs_and_glitches.md)
ld a, [wBattleMode]
dec a
jp nz, UseBallInTrainerBattle
ld a, [wPartyCount]
cp PARTY_LENGTH
jr nz, .room_in_party
ld a, BANK(sBoxCount)
call OpenSRAM
ld a, [sBoxCount]
cp MONS_PER_BOX
call CloseSRAM
jp z, Ball_BoxIsFullMessage
.room_in_party
; BUG: Using a Park Ball in non-Contest battles has a corrupt animation (see docs/bugs_and_glitches.md)
xor a
ld [wWildMon], a
ld a, [wCurItem]
cp PARK_BALL
call nz, ReturnToBattle_UseBall
ld hl, wOptions
res NO_TEXT_SCROLL, [hl]
ld hl, ItemUsedText
call PrintText
ld a, [wEnemyMonCatchRate]
ld b, a
ld a, [wBattleType]
cp BATTLETYPE_TUTORIAL
jp z, .catch_without_fail
ld a, [wCurItem]
cp MASTER_BALL
jp z, .catch_without_fail
ld a, [wCurItem]
ld c, a
ld hl, BallMultiplierFunctionTable
.get_multiplier_loop
ld a, [hli]
cp $ff
jr z, .skip_or_return_from_ball_fn
cp c
jr z, .call_ball_function
inc hl
inc hl
jr .get_multiplier_loop
.call_ball_function
ld a, [hli]
ld h, [hl]
ld l, a
ld de, .skip_or_return_from_ball_fn
push de
jp hl
.skip_or_return_from_ball_fn
ld a, [wCurItem]
cp LEVEL_BALL
ld a, b
jp z, .skip_hp_calc
ld a, b
ldh [hMultiplicand + 2], a
ld hl, wEnemyMonHP
ld b, [hl]
inc hl
ld c, [hl]
inc hl
ld d, [hl]
inc hl
ld e, [hl]
sla c
rl b
ld h, d
ld l, e
add hl, de
add hl, de
ld d, h
ld e, l
ld a, d
and a
jr z, .okay_1
srl d
rr e
srl d
rr e
srl b
rr c
srl b
rr c
ld a, c
and a
jr nz, .okay_1
ld c, $1
.okay_1
ld b, e
push bc
ld a, b
sub c
ldh [hMultiplier], a
xor a
ldh [hDividend + 0], a
ldh [hMultiplicand + 0], a
ldh [hMultiplicand + 1], a
call Multiply
pop bc
ld a, b
ldh [hDivisor], a
ld b, 4
call Divide
ldh a, [hQuotient + 3]
and a
jr nz, .statuscheck
ld a, 1
.statuscheck
; BUG: BRN/PSN/PAR do not affect catch rate (see docs/bugs_and_glitches.md)
ld b, a
ld a, [wEnemyMonStatus]
and 1 << FRZ | SLP_MASK
ld c, 10
jr nz, .addstatus
and a
ld c, 5
jr nz, .addstatus
ld c, 0
.addstatus
ld a, b
add c
jr nc, .max_1
ld a, $ff
.max_1
; BUG: HELD_CATCH_CHANCE has no effect (see docs/bugs_and_glitches.md)
ld d, a
push de
ld a, [wBattleMonItem]
farcall GetItemHeldEffect
ld a, b
cp HELD_CATCH_CHANCE
pop de
ld a, d
jr nz, .max_2
add c
jr nc, .max_2
ld a, $ff
.max_2
.skip_hp_calc
ld b, a
ld [wFinalCatchRate], a
call Random
cp b
ld a, 0
jr z, .catch_without_fail
jr nc, .fail_to_catch
.catch_without_fail
ld a, [wEnemyMonSpecies]
.fail_to_catch
ld [wWildMon], a
ld c, 20
call DelayFrames
ld a, [wCurItem]
cp POKE_BALL + 1 ; Assumes Master/Ultra/Great come before
jr c, .not_kurt_ball
ld a, POKE_BALL
.not_kurt_ball
ld [wBattleAnimParam], a
ld de, ANIM_THROW_POKE_BALL
ld a, e
ld [wFXAnimID], a
ld a, d
ld [wFXAnimID + 1], a
xor a
ldh [hBattleTurn], a
ld [wThrownBallWobbleCount], a
ld [wNumHits], a
predef PlayBattleAnim
ld a, [wWildMon]
and a
jr nz, .caught
ld a, [wThrownBallWobbleCount]
cp 1
ld hl, BallBrokeFreeText
jp z, .shake_and_break_free
cp 2
ld hl, BallAppearedCaughtText
jp z, .shake_and_break_free
cp 3
ld hl, BallAlmostHadItText
jp z, .shake_and_break_free
cp 4
ld hl, BallSoCloseText
jp z, .shake_and_break_free
.caught
ld hl, wEnemyMonStatus
ld a, [hli]
push af
inc hl
ld a, [hli]
push af
ld a, [hl]
push af
push hl
ld hl, wEnemyMonItem
ld a, [hl]
push af
push hl
ld hl, wEnemySubStatus5
ld a, [hl]
push af
set SUBSTATUS_TRANSFORMED, [hl]
; BUG: Catching a Transformed Pokémon always catches a Ditto (see docs/bugs_and_glitches.md)
bit SUBSTATUS_TRANSFORMED, a
jr nz, .ditto
jr .not_ditto
.ditto
ld a, DITTO
ld [wTempEnemyMonSpecies], a
jr .load_data
.not_ditto
set SUBSTATUS_TRANSFORMED, [hl]
ld hl, wEnemyBackupDVs
ld a, [wEnemyMonDVs]
ld [hli], a
ld a, [wEnemyMonDVs + 1]
ld [hl], a
.load_data
ld a, [wTempEnemyMonSpecies]
ld [wCurPartySpecies], a
ld a, [wEnemyMonLevel]
ld [wCurPartyLevel], a
farcall LoadEnemyMon
pop af
ld [wEnemySubStatus5], a
pop hl
pop af
ld [hl], a
pop hl
pop af
ld [hld], a
pop af
ld [hld], a
dec hl
pop af
ld [hl], a
ld hl, wEnemySubStatus5
bit SUBSTATUS_TRANSFORMED, [hl]
jr nz, .Transformed
ld hl, wWildMonMoves
ld de, wEnemyMonMoves
ld bc, NUM_MOVES
call CopyBytes
ld hl, wWildMonPP
ld de, wEnemyMonPP
ld bc, NUM_MOVES
call CopyBytes
.Transformed:
ld a, [wEnemyMonSpecies]
ld [wWildMon], a
ld [wCurPartySpecies], a
ld [wTempSpecies], a
ld a, [wBattleType]
cp BATTLETYPE_TUTORIAL
jp z, .FinishTutorial
farcall StubbedTrainerRankings_WildMonsCaught
ld hl, Text_GotchaMonWasCaught
call PrintText
call ClearSprites
ld a, [wTempSpecies]
dec a
call CheckCaughtMon
ld a, c
push af
ld a, [wTempSpecies]
dec a
call SetSeenAndCaughtMon
pop af
and a
jr nz, .skip_pokedex
call CheckReceivedDex
jr z, .skip_pokedex
ld hl, NewDexDataText
call PrintText
call ClearSprites
ld a, [wEnemyMonSpecies]
ld [wTempSpecies], a
predef NewPokedexEntry
.skip_pokedex
ld a, [wBattleType]
cp BATTLETYPE_CONTEST
jp z, .catch_bug_contest_mon
cp BATTLETYPE_CELEBI
jr nz, .not_celebi
ld hl, wBattleResult
set BATTLERESULT_CAUGHT_CELEBI, [hl]
.not_celebi
ld a, [wPartyCount]
cp PARTY_LENGTH
jr z, .SendToPC
xor a ; PARTYMON
ld [wMonType], a
call ClearSprites
predef TryAddMonToParty
farcall SetCaughtData
ld a, [wCurItem]
cp FRIEND_BALL
jr nz, .SkipPartyMonFriendBall
ld a, [wPartyCount]
dec a
ld hl, wPartyMon1Happiness
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld a, FRIEND_BALL_HAPPINESS
ld [hl], a
.SkipPartyMonFriendBall:
ld hl, AskGiveNicknameText
call PrintText
ld a, [wCurPartySpecies]
ld [wNamedObjectIndex], a
call GetPokemonName
call YesNoBox
jp c, .return_from_capture
ld a, [wPartyCount]
dec a
ld [wCurPartyMon], a
ld hl, wPartyMonNicknames
ld bc, MON_NAME_LENGTH
call AddNTimes
ld d, h
ld e, l
push de
xor a ; PARTYMON
ld [wMonType], a
ld b, NAME_MON
farcall NamingScreen
call RotateThreePalettesRight
call LoadStandardFont
pop hl
ld de, wStringBuffer1
call InitName
jp .return_from_capture
.SendToPC:
call ClearSprites
predef SendMonIntoBox
farcall SetBoxMonCaughtData
ld a, BANK(sBoxCount)
call OpenSRAM
ld a, [sBoxCount]
cp MONS_PER_BOX
jr nz, .BoxNotFullYet
ld hl, wBattleResult
set BATTLERESULT_BOX_FULL, [hl]
.BoxNotFullYet:
ld a, [wCurItem]
cp FRIEND_BALL
jr nz, .SkipBoxMonFriendBall
; The captured mon is now first in the box
ld a, FRIEND_BALL_HAPPINESS
ld [sBoxMon1Happiness], a
.SkipBoxMonFriendBall:
call CloseSRAM
ld hl, AskGiveNicknameText
call PrintText
ld a, [wCurPartySpecies]
ld [wNamedObjectIndex], a
call GetPokemonName
call YesNoBox
jr c, .SkipBoxMonNickname
xor a
ld [wCurPartyMon], a
ld a, BOXMON
ld [wMonType], a
ld de, wMonOrItemNameBuffer
ld b, NAME_MON
farcall NamingScreen
ld a, BANK(sBoxMonNicknames)
call OpenSRAM
ld hl, wMonOrItemNameBuffer
ld de, sBoxMonNicknames
ld bc, MON_NAME_LENGTH
call CopyBytes
ld hl, sBoxMonNicknames
ld de, wStringBuffer1
call InitName
call CloseSRAM
.SkipBoxMonNickname:
ld a, BANK(sBoxMonNicknames)
call OpenSRAM
ld hl, sBoxMonNicknames
ld de, wMonOrItemNameBuffer
ld bc, MON_NAME_LENGTH
call CopyBytes
call CloseSRAM
ld hl, BallSentToPCText
call PrintText
call RotateThreePalettesRight
call LoadStandardFont
jr .return_from_capture
.catch_bug_contest_mon
farcall BugContest_SetCaughtContestMon
jr .return_from_capture
.FinishTutorial:
ld hl, Text_GotchaMonWasCaught
.shake_and_break_free
call PrintText
call ClearSprites
.return_from_capture
ld a, [wBattleType]
cp BATTLETYPE_TUTORIAL
ret z
cp BATTLETYPE_DEBUG
ret z
cp BATTLETYPE_CONTEST
jr z, .used_park_ball
ld a, [wWildMon]
and a
jr z, .toss
call ClearBGPalettes
call ClearTilemap
.toss
ld hl, wNumItems
inc a
ld [wItemQuantityChange], a
jp TossItem
.used_park_ball
ld hl, wParkBallsRemaining
dec [hl]
ret
BallMultiplierFunctionTable:
; table of routines that increase or decrease the catch rate based on
; which ball is used in a certain situation.
dbw ULTRA_BALL, UltraBallMultiplier
dbw GREAT_BALL, GreatBallMultiplier
dbw SAFARI_BALL, SafariBallMultiplier ; Safari Ball, leftover from RBY
dbw HEAVY_BALL, HeavyBallMultiplier
dbw LEVEL_BALL, LevelBallMultiplier
dbw LURE_BALL, LureBallMultiplier
dbw FAST_BALL, FastBallMultiplier
dbw MOON_BALL, MoonBallMultiplier
dbw LOVE_BALL, LoveBallMultiplier
dbw PARK_BALL, ParkBallMultiplier
db -1 ; end
UltraBallMultiplier:
; multiply catch rate by 2
sla b
ret nc
ld b, $ff
ret
SafariBallMultiplier:
GreatBallMultiplier:
ParkBallMultiplier:
; multiply catch rate by 1.5
ld a, b
srl a
add b
ld b, a
ret nc
ld b, $ff
ret
HeavyBall_GetDexEntryBank:
; BUG: Heavy Ball uses wrong weight value for three Pokémon (see docs/bugs_and_glitches.md)
push hl
push de
ld a, [wEnemyMonSpecies]
rlca
rlca
maskbits NUM_DEX_ENTRY_BANKS
ld hl, .PokedexEntryBanks
ld d, 0
ld e, a
add hl, de
ld a, [hl]
pop de
pop hl
ret
.PokedexEntryBanks:
db BANK("Pokedex Entries 001-064")
db BANK("Pokedex Entries 065-128")
db BANK("Pokedex Entries 129-192")
db BANK("Pokedex Entries 193-251")
HeavyBallMultiplier:
; subtract 20 from catch rate if weight < 102.4 kg
; else add 0 to catch rate if weight < 204.8 kg
; else add 20 to catch rate if weight < 307.2 kg
; else add 30 to catch rate if weight < 409.6 kg
; else add 40 to catch rate
ld a, [wEnemyMonSpecies]
ld hl, PokedexDataPointerTable
dec a
ld e, a
ld d, 0
add hl, de
add hl, de
ld a, BANK(PokedexDataPointerTable)
call GetFarWord
.SkipText:
call HeavyBall_GetDexEntryBank
call GetFarByte
inc hl
cp "@"
jr nz, .SkipText
call HeavyBall_GetDexEntryBank
push bc
inc hl
inc hl
call GetFarWord
srl h
rr l
ld b, h
ld c, l
rept 4
srl b
rr c
endr
call .subbc
srl b
rr c
call .subbc
ld a, h
pop bc
jr .compare
.subbc
; subtract bc from hl
push bc
ld a, b
cpl
ld b, a
ld a, c
cpl
ld c, a
inc bc
add hl, bc
pop bc
ret
.compare
ld c, a
cp HIGH(1024) ; 102.4 kg
jr c, .lightmon
ld hl, .WeightsTable
.lookup
ld a, c
cp [hl]
jr c, .heavymon
inc hl
inc hl
jr .lookup
.heavymon
inc hl
ld a, b
add [hl]
ld b, a
ret nc
ld b, $ff
ret
.lightmon
ld a, b
sub 20
ld b, a
ret nc
ld b, $1
ret
.WeightsTable:
; weight factor, boost
db HIGH(2048), 0
db HIGH(3072), 20
db HIGH(4096), 30
db HIGH(65280), 40
LureBallMultiplier:
; multiply catch rate by 3 if this is a fishing rod battle
ld a, [wBattleType]
cp BATTLETYPE_FISH
ret nz
ld a, b
add a
jr c, .max
add b
jr nc, .done
.max
ld a, $ff
.done
ld b, a
ret
MoonBallMultiplier:
push bc
ld a, [wTempEnemyMonSpecies]
dec a
ld c, a
ld b, 0
ld hl, EvosAttacksPointers
add hl, bc
add hl, bc
ld a, BANK(EvosAttacksPointers)
call GetFarWord
pop bc
push bc
ld a, BANK("Evolutions and Attacks")
call GetFarByte
cp EVOLVE_ITEM
pop bc
ret nz
; BUG: Moon Ball does not boost catch rate (see docs/bugs_and_glitches.md)
inc hl
inc hl
inc hl
push bc
ld a, BANK("Evolutions and Attacks")
call GetFarByte
cp MOON_STONE_RED ; BURN_HEAL
pop bc
ret nz
sla b
jr c, .max
sla b
jr nc, .done
.max
ld b, $ff
.done
ret
LoveBallMultiplier:
; does species match?
ld a, [wTempEnemyMonSpecies]
ld c, a
ld a, [wTempBattleMonSpecies]
cp c
ret nz
; check player mon species
push bc
ld a, [wTempBattleMonSpecies]
ld [wCurPartySpecies], a
xor a ; PARTYMON
ld [wMonType], a
ld a, [wCurBattleMon]
ld [wCurPartyMon], a
farcall GetGender
jr c, .done1 ; no effect on genderless
ld d, 0 ; male
jr nz, .got_player_gender
inc d ; female
.got_player_gender
; check wild mon species
push de
ld a, [wTempEnemyMonSpecies]
ld [wCurPartySpecies], a
ld a, WILDMON
ld [wMonType], a
farcall GetGender
jr c, .done2 ; no effect on genderless
ld d, 0 ; male
jr nz, .got_wild_gender
inc d ; female
.got_wild_gender
; BUG: Love Ball boosts catch rate for the wrong gender (see docs/bugs_and_glitches.md)
ld a, d
pop de
cp d
pop bc
ret nz
sla b
jr c, .max
sla b
jr c, .max
sla b
ret nc
.max
ld b, $ff
ret
.done2
pop de
.done1
pop bc
ret
FastBallMultiplier: