Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/battle/effects.asm
1271 views
1
JumpMoveEffect:
2
call _JumpMoveEffect
3
ld b, $1
4
ret
5
6
_JumpMoveEffect:
7
ldh a, [hWhoseTurn]
8
and a
9
ld a, [wPlayerMoveEffect]
10
jr z, .next
11
ld a, [wEnemyMoveEffect]
12
.next
13
dec a ; subtract 1, there is no special effect for 00
14
add a ; x2, 16bit pointers
15
ld hl, MoveEffectPointerTable
16
ld b, 0
17
ld c, a
18
add hl, bc
19
ld a, [hli]
20
ld h, [hl]
21
ld l, a
22
jp hl ; jump to special effect handler
23
24
INCLUDE "data/moves/effects_pointers.asm"
25
26
SleepEffect:
27
ld de, wEnemyMonStatus
28
ld bc, wEnemyBattleStatus2
29
ldh a, [hWhoseTurn]
30
and a
31
jp z, .sleepEffect
32
ld de, wBattleMonStatus
33
ld bc, wPlayerBattleStatus2
34
35
.sleepEffect
36
ld a, [bc]
37
bit NEEDS_TO_RECHARGE, a ; does the target need to recharge? (hyper beam)
38
res NEEDS_TO_RECHARGE, a ; target no longer needs to recharge
39
ld [bc], a
40
jr nz, .setSleepCounter ; if the target had to recharge, all hit tests will be skipped
41
; including the event where the target already has another status
42
ld a, [de]
43
ld b, a
44
and $7
45
jr z, .notAlreadySleeping ; can't affect a mon that is already asleep
46
ld hl, AlreadyAsleepText
47
jp PrintText
48
.notAlreadySleeping
49
ld a, b
50
and a
51
jr nz, .didntAffect ; can't affect a mon that is already statused
52
push de
53
call MoveHitTest ; apply accuracy tests
54
pop de
55
ld a, [wMoveMissed]
56
and a
57
jr nz, .didntAffect
58
.setSleepCounter
59
; set target's sleep counter to a random number between 1 and 7
60
call BattleRandom
61
and $7
62
jr z, .setSleepCounter
63
ld [de], a
64
call PlayCurrentMoveAnimation2
65
ld hl, FellAsleepText
66
jp PrintText
67
.didntAffect
68
jp PrintDidntAffectText
69
70
FellAsleepText:
71
text_far _FellAsleepText
72
text_end
73
74
AlreadyAsleepText:
75
text_far _AlreadyAsleepText
76
text_end
77
78
PoisonEffect:
79
ld hl, wEnemyMonStatus
80
ld de, wPlayerMoveEffect
81
ldh a, [hWhoseTurn]
82
and a
83
jr z, .poisonEffect
84
ld hl, wBattleMonStatus
85
ld de, wEnemyMoveEffect
86
.poisonEffect
87
call CheckTargetSubstitute
88
jr nz, .noEffect ; can't poison a substitute target
89
ld a, [hli]
90
ld b, a
91
and a
92
jr nz, .noEffect ; miss if target is already statused
93
ld a, [hli]
94
cp POISON ; can't poison a poison-type target
95
jr z, .noEffect
96
ld a, [hld]
97
cp POISON ; can't poison a poison-type target
98
jr z, .noEffect
99
ld a, [de]
100
cp POISON_SIDE_EFFECT1
101
ld b, 20 percent + 1 ; chance of poisoning
102
jr z, .sideEffectTest
103
cp POISON_SIDE_EFFECT2
104
ld b, 40 percent + 1 ; chance of poisoning
105
jr z, .sideEffectTest
106
push hl
107
push de
108
call MoveHitTest ; apply accuracy tests
109
pop de
110
pop hl
111
ld a, [wMoveMissed]
112
and a
113
jr nz, .didntAffect
114
jr .inflictPoison
115
.sideEffectTest
116
call BattleRandom
117
cp b ; was side effect successful?
118
ret nc
119
.inflictPoison
120
dec hl
121
set PSN, [hl]
122
push de
123
dec de
124
ldh a, [hWhoseTurn]
125
and a
126
ld b, SHAKE_SCREEN_ANIM
127
ld hl, wPlayerBattleStatus3
128
ld a, [de]
129
ld de, wPlayerToxicCounter
130
jr nz, .ok
131
ld b, ENEMY_HUD_SHAKE_ANIM
132
ld hl, wEnemyBattleStatus3
133
ld de, wEnemyToxicCounter
134
.ok
135
cp TOXIC
136
jr nz, .normalPoison ; done if move is not Toxic
137
set BADLY_POISONED, [hl] ; else set Toxic battstatus
138
xor a
139
ld [de], a
140
ld hl, BadlyPoisonedText
141
jr .continue
142
.normalPoison
143
ld hl, PoisonedText
144
.continue
145
pop de
146
ld a, [de]
147
cp POISON_EFFECT
148
jr z, .regularPoisonEffect
149
ld a, b
150
call PlayBattleAnimation2
151
jp PrintText
152
.regularPoisonEffect
153
call PlayCurrentMoveAnimation2
154
jp PrintText
155
.noEffect
156
ld a, [de]
157
cp POISON_EFFECT
158
ret nz
159
.didntAffect
160
ld c, 50
161
call DelayFrames
162
jp PrintDidntAffectText
163
164
PoisonedText:
165
text_far _PoisonedText
166
text_end
167
168
BadlyPoisonedText:
169
text_far _BadlyPoisonedText
170
text_end
171
172
DrainHPEffect:
173
jpfar DrainHPEffect_
174
175
ExplodeEffect:
176
ld hl, wBattleMonHP
177
ld de, wPlayerBattleStatus2
178
ldh a, [hWhoseTurn]
179
and a
180
jr z, .faintUser
181
ld hl, wEnemyMonHP
182
ld de, wEnemyBattleStatus2
183
.faintUser
184
xor a
185
ld [hli], a ; set the mon's HP to 0
186
ld [hli], a
187
inc hl
188
ld [hl], a ; set mon's status to 0
189
ld a, [de]
190
res SEEDED, a ; clear mon's leech seed status
191
ld [de], a
192
ret
193
194
FreezeBurnParalyzeEffect:
195
xor a
196
ld [wAnimationType], a
197
call CheckTargetSubstitute
198
ret nz ; return if they have a substitute, can't effect them
199
ldh a, [hWhoseTurn]
200
and a
201
jp nz, .opponentAttacker
202
ld a, [wEnemyMonStatus]
203
and a
204
jp nz, CheckDefrost ; can't inflict status if opponent is already statused
205
ld a, [wPlayerMoveType]
206
ld b, a
207
ld a, [wEnemyMonType1]
208
cp b ; do target type 1 and move type match?
209
ret z ; return if they match (an ice move can't freeze an ice-type, body slam can't paralyze a normal-type, etc.)
210
ld a, [wEnemyMonType2]
211
cp b ; do target type 2 and move type match?
212
ret z ; return if they match
213
ld a, [wPlayerMoveEffect]
214
cp PARALYZE_SIDE_EFFECT1 + 1
215
ld b, 10 percent + 1
216
jr c, .regular_effectiveness
217
; extra effectiveness
218
ld b, 30 percent + 1
219
ASSERT PARALYZE_SIDE_EFFECT2 - PARALYZE_SIDE_EFFECT1 == BURN_SIDE_EFFECT2 - BURN_SIDE_EFFECT1
220
ASSERT PARALYZE_SIDE_EFFECT2 - PARALYZE_SIDE_EFFECT1 == FREEZE_SIDE_EFFECT2 - FREEZE_SIDE_EFFECT1
221
sub PARALYZE_SIDE_EFFECT2 - PARALYZE_SIDE_EFFECT1 ; treat extra effective as regular from now on
222
.regular_effectiveness
223
push af
224
call BattleRandom ; get random 8bit value for probability test
225
cp b
226
pop bc
227
ret nc ; do nothing if random value is >= 1A or 4D [no status applied]
228
ld a, b ; what type of effect is this?
229
cp BURN_SIDE_EFFECT1
230
jr z, .burn1
231
cp FREEZE_SIDE_EFFECT1
232
jr z, .freeze1
233
; .paralyze1
234
ld a, 1 << PAR
235
ld [wEnemyMonStatus], a
236
call QuarterSpeedDueToParalysis ; quarter speed of affected mon
237
ld a, ENEMY_HUD_SHAKE_ANIM
238
call PlayBattleAnimation
239
jp PrintMayNotAttackText ; print paralysis text
240
.burn1
241
ld a, 1 << BRN
242
ld [wEnemyMonStatus], a
243
call HalveAttackDueToBurn ; halve attack of affected mon
244
ld a, ENEMY_HUD_SHAKE_ANIM
245
call PlayBattleAnimation
246
ld hl, BurnedText
247
jp PrintText
248
.freeze1
249
call ClearHyperBeam ; resets hyper beam (recharge) condition from target
250
ld a, 1 << FRZ
251
ld [wEnemyMonStatus], a
252
ld a, ENEMY_HUD_SHAKE_ANIM
253
call PlayBattleAnimation
254
ld hl, FrozenText
255
jp PrintText
256
.opponentAttacker
257
ld a, [wBattleMonStatus] ; mostly same as above with addresses swapped for opponent
258
and a
259
jp nz, CheckDefrost
260
ld a, [wEnemyMoveType]
261
ld b, a
262
ld a, [wBattleMonType1]
263
cp b
264
ret z
265
ld a, [wBattleMonType2]
266
cp b
267
ret z
268
ld a, [wEnemyMoveEffect]
269
cp PARALYZE_SIDE_EFFECT1 + 1
270
ld b, 10 percent + 1
271
jr c, .regular_effectiveness2
272
; extra effectiveness
273
ld b, 30 percent + 1
274
sub BURN_SIDE_EFFECT2 - BURN_SIDE_EFFECT1 ; treat extra effective as regular from now on
275
.regular_effectiveness2
276
push af
277
call BattleRandom
278
cp b
279
pop bc
280
ret nc
281
ld a, b
282
cp BURN_SIDE_EFFECT1
283
jr z, .burn2
284
cp FREEZE_SIDE_EFFECT1
285
jr z, .freeze2
286
; .paralyze2
287
ld a, 1 << PAR
288
ld [wBattleMonStatus], a
289
call QuarterSpeedDueToParalysis
290
jp PrintMayNotAttackText
291
.burn2
292
ld a, 1 << BRN
293
ld [wBattleMonStatus], a
294
call HalveAttackDueToBurn
295
ld hl, BurnedText
296
jp PrintText
297
.freeze2
298
; hyper beam bits aren't reset for opponent's side
299
ld a, 1 << FRZ
300
ld [wBattleMonStatus], a
301
ld hl, FrozenText
302
jp PrintText
303
304
BurnedText:
305
text_far _BurnedText
306
text_end
307
308
FrozenText:
309
text_far _FrozenText
310
text_end
311
312
CheckDefrost:
313
; any fire-type move that has a chance inflict burn (all but Fire Spin) will defrost a frozen target
314
and 1 << FRZ ; are they frozen?
315
ret z ; return if so
316
ldh a, [hWhoseTurn]
317
and a
318
jr nz, .opponent
319
;player [attacker]
320
ld a, [wPlayerMoveType]
321
sub FIRE
322
ret nz ; return if type of move used isn't fire
323
ld [wEnemyMonStatus], a ; set opponent status to 00 ["defrost" a frozen monster]
324
ld hl, wEnemyMon1Status
325
ld a, [wEnemyMonPartyPos]
326
ld bc, wEnemyMon2 - wEnemyMon1
327
call AddNTimes
328
xor a
329
ld [hl], a ; clear status in roster
330
ld hl, FireDefrostedText
331
jr .common
332
.opponent
333
ld a, [wEnemyMoveType] ; same as above with addresses swapped
334
sub FIRE
335
ret nz
336
ld [wBattleMonStatus], a
337
ld hl, wPartyMon1Status
338
ld a, [wPlayerMonNumber]
339
ld bc, wPartyMon2 - wPartyMon1
340
call AddNTimes
341
xor a
342
ld [hl], a
343
ld hl, FireDefrostedText
344
.common
345
jp PrintText
346
347
FireDefrostedText:
348
text_far _FireDefrostedText
349
text_end
350
351
StatModifierUpEffect:
352
ld hl, wPlayerMonStatMods
353
ld de, wPlayerMoveEffect
354
ldh a, [hWhoseTurn]
355
and a
356
jr z, .statModifierUpEffect
357
ld hl, wEnemyMonStatMods
358
ld de, wEnemyMoveEffect
359
.statModifierUpEffect
360
ld a, [de]
361
sub ATTACK_UP1_EFFECT
362
cp EVASION_UP1_EFFECT + $3 - ATTACK_UP1_EFFECT ; covers all +1 effects
363
jr c, .incrementStatMod
364
sub ATTACK_UP2_EFFECT - ATTACK_UP1_EFFECT ; map +2 effects to equivalent +1 effect
365
.incrementStatMod
366
ld c, a
367
ld b, $0
368
add hl, bc
369
ld b, [hl]
370
inc b ; increment corresponding stat mod
371
ld a, $d
372
cp b ; can't raise stat past +6 ($d or 13)
373
jp c, PrintNothingHappenedText
374
ld a, [de]
375
cp ATTACK_UP1_EFFECT + $8 ; is it a +2 effect?
376
jr c, .ok
377
inc b ; if so, increment stat mod again
378
ld a, $d
379
cp b ; unless it's already +6
380
jr nc, .ok
381
ld b, a
382
.ok
383
ld [hl], b
384
ld a, c
385
cp $4
386
jr nc, UpdateStatDone ; jump if mod affected is evasion/accuracy
387
push hl
388
ld hl, wBattleMonAttack + 1
389
ld de, wPlayerMonUnmodifiedAttack
390
ldh a, [hWhoseTurn]
391
and a
392
jr z, .pointToStats
393
ld hl, wEnemyMonAttack + 1
394
ld de, wEnemyMonUnmodifiedAttack
395
.pointToStats
396
push bc
397
sla c
398
ld b, $0
399
add hl, bc ; hl = modified stat
400
ld a, c
401
add e
402
ld e, a
403
jr nc, .checkIf999
404
inc d ; de = unmodified (original) stat
405
.checkIf999
406
pop bc
407
; check if stat is already 999
408
ld a, [hld]
409
sub LOW(MAX_STAT_VALUE)
410
jr nz, .recalculateStat
411
ld a, [hl]
412
sbc HIGH(MAX_STAT_VALUE)
413
jp z, RestoreOriginalStatModifier
414
.recalculateStat ; recalculate affected stat
415
; paralysis and burn penalties, as well as badge boosts are ignored
416
push hl
417
push bc
418
ld hl, StatModifierRatios
419
dec b
420
sla b
421
ld c, b
422
ld b, $0
423
add hl, bc
424
pop bc
425
xor a
426
ldh [hMultiplicand], a
427
ld a, [de]
428
ldh [hMultiplicand + 1], a
429
inc de
430
ld a, [de]
431
ldh [hMultiplicand + 2], a
432
ld a, [hli]
433
ldh [hMultiplier], a
434
call Multiply
435
ld a, [hl]
436
ldh [hDivisor], a
437
ld b, $4
438
call Divide
439
pop hl
440
; cap at MAX_STAT_VALUE (999)
441
ldh a, [hProduct + 3]
442
sub LOW(MAX_STAT_VALUE)
443
ldh a, [hProduct + 2]
444
sbc HIGH(MAX_STAT_VALUE)
445
jp c, UpdateStat
446
ld a, HIGH(MAX_STAT_VALUE)
447
ldh [hMultiplicand + 1], a
448
ld a, LOW(MAX_STAT_VALUE)
449
ldh [hMultiplicand + 2], a
450
451
UpdateStat:
452
ldh a, [hProduct + 2]
453
ld [hli], a
454
ldh a, [hProduct + 3]
455
ld [hl], a
456
pop hl
457
UpdateStatDone:
458
ld b, c
459
inc b
460
call PrintStatText
461
ld hl, wPlayerBattleStatus2
462
ld de, wPlayerMoveNum
463
ld bc, wPlayerMonMinimized
464
ldh a, [hWhoseTurn]
465
and a
466
jr z, .playerTurn
467
ld hl, wEnemyBattleStatus2
468
ld de, wEnemyMoveNum
469
ld bc, wEnemyMonMinimized
470
.playerTurn
471
ld a, [de]
472
cp MINIMIZE
473
jr nz, .notMinimize
474
; if a substitute is up, slide off the substitute and show the mon pic before
475
; playing the minimize animation
476
bit HAS_SUBSTITUTE_UP, [hl]
477
push af
478
push bc
479
ld hl, HideSubstituteShowMonAnim
480
ld b, BANK(HideSubstituteShowMonAnim)
481
push de
482
call nz, Bankswitch
483
pop de
484
.notMinimize
485
call PlayCurrentMoveAnimation
486
ld a, [de]
487
cp MINIMIZE
488
jr nz, .applyBadgeBoostsAndStatusPenalties
489
pop bc
490
ld a, $1
491
ld [bc], a
492
ld hl, ReshowSubstituteAnim
493
ld b, BANK(ReshowSubstituteAnim)
494
pop af
495
call nz, Bankswitch
496
.applyBadgeBoostsAndStatusPenalties
497
ldh a, [hWhoseTurn]
498
and a
499
call z, ApplyBadgeStatBoosts ; whenever the player uses a stat-up move, badge boosts get reapplied again to every stat,
500
; even to those not affected by the stat-up move (will be boosted further)
501
ld hl, MonsStatsRoseText
502
call PrintText
503
504
; these shouldn't be here
505
call QuarterSpeedDueToParalysis ; apply speed penalty to the player whose turn is not, if it's paralyzed
506
jp HalveAttackDueToBurn ; apply attack penalty to the player whose turn is not, if it's burned
507
508
RestoreOriginalStatModifier:
509
pop hl
510
dec [hl]
511
512
PrintNothingHappenedText:
513
ld hl, NothingHappenedText
514
jp PrintText
515
516
MonsStatsRoseText:
517
text_far _MonsStatsRoseText
518
text_asm
519
ld hl, GreatlyRoseText
520
ldh a, [hWhoseTurn]
521
and a
522
ld a, [wPlayerMoveEffect]
523
jr z, .playerTurn
524
ld a, [wEnemyMoveEffect]
525
.playerTurn
526
cp ATTACK_DOWN1_EFFECT
527
ret nc
528
ld hl, RoseText
529
ret
530
531
GreatlyRoseText:
532
text_pause
533
text_far _GreatlyRoseText
534
; fallthrough
535
RoseText:
536
text_far _RoseText
537
text_end
538
539
StatModifierDownEffect:
540
ld hl, wEnemyMonStatMods
541
ld de, wPlayerMoveEffect
542
ld bc, wEnemyBattleStatus1
543
ldh a, [hWhoseTurn]
544
and a
545
jr z, .statModifierDownEffect
546
ld hl, wPlayerMonStatMods
547
ld de, wEnemyMoveEffect
548
ld bc, wPlayerBattleStatus1
549
ld a, [wLinkState]
550
cp LINK_STATE_BATTLING
551
jr z, .statModifierDownEffect
552
call BattleRandom
553
cp 25 percent + 1 ; chance to miss by in regular battle
554
jp c, MoveMissed
555
.statModifierDownEffect
556
call CheckTargetSubstitute ; can't hit through substitute
557
jp nz, MoveMissed
558
ld a, [de]
559
cp ATTACK_DOWN_SIDE_EFFECT
560
jr c, .nonSideEffect
561
call BattleRandom
562
cp 33 percent + 1 ; chance for side effects
563
jp nc, CantLowerAnymore
564
ld a, [de]
565
sub ATTACK_DOWN_SIDE_EFFECT ; map each stat to 0-3
566
jr .decrementStatMod
567
.nonSideEffect ; non-side effects only
568
push hl
569
push de
570
push bc
571
call MoveHitTest ; apply accuracy tests
572
pop bc
573
pop de
574
pop hl
575
ld a, [wMoveMissed]
576
and a
577
jp nz, MoveMissed
578
ld a, [bc]
579
bit INVULNERABLE, a ; fly/dig
580
jp nz, MoveMissed
581
ld a, [de]
582
sub ATTACK_DOWN1_EFFECT
583
cp EVASION_DOWN1_EFFECT + $3 - ATTACK_DOWN1_EFFECT ; covers all -1 effects
584
jr c, .decrementStatMod
585
sub ATTACK_DOWN2_EFFECT - ATTACK_DOWN1_EFFECT ; map -2 effects to corresponding -1 effect
586
.decrementStatMod
587
ld c, a
588
ld b, $0
589
add hl, bc
590
ld b, [hl]
591
dec b ; dec corresponding stat mod
592
jp z, CantLowerAnymore ; if stat mod is 1 (-6), can't lower anymore
593
ld a, [de]
594
cp ATTACK_DOWN2_EFFECT - $16 ; $24
595
jr c, .ok
596
cp EVASION_DOWN2_EFFECT + $5 ; $44
597
jr nc, .ok
598
dec b ; stat down 2 effects only (dec mod again)
599
jr nz, .ok
600
inc b ; increment mod to 1 (-6) if it would become 0 (-7)
601
.ok
602
ld [hl], b ; save modified mod
603
ld a, c
604
cp $4
605
jr nc, UpdateLoweredStatDone ; jump for evasion/accuracy
606
push hl
607
push de
608
ld hl, wEnemyMonAttack + 1
609
ld de, wEnemyMonUnmodifiedAttack
610
ldh a, [hWhoseTurn]
611
and a
612
jr z, .pointToStat
613
ld hl, wBattleMonAttack + 1
614
ld de, wPlayerMonUnmodifiedAttack
615
.pointToStat
616
push bc
617
sla c
618
ld b, $0
619
add hl, bc ; hl = modified stat
620
ld a, c
621
add e
622
ld e, a
623
jr nc, .noCarry
624
inc d ; de = unmodified stat
625
.noCarry
626
pop bc
627
ld a, [hld]
628
sub $1 ; can't lower stat below 1 (-6)
629
jr nz, .recalculateStat
630
ld a, [hl]
631
and a
632
jp z, CantLowerAnymore_Pop
633
.recalculateStat
634
; recalculate affected stat
635
; paralysis and burn penalties, as well as badge boosts are ignored
636
push hl
637
push bc
638
ld hl, StatModifierRatios
639
dec b
640
sla b
641
ld c, b
642
ld b, $0
643
add hl, bc
644
pop bc
645
xor a
646
ldh [hMultiplicand], a
647
ld a, [de]
648
ldh [hMultiplicand + 1], a
649
inc de
650
ld a, [de]
651
ldh [hMultiplicand + 2], a
652
ld a, [hli]
653
ldh [hMultiplier], a
654
call Multiply
655
ld a, [hl]
656
ldh [hDivisor], a
657
ld b, $4
658
call Divide
659
pop hl
660
ldh a, [hProduct + 3]
661
ld b, a
662
ldh a, [hProduct + 2]
663
or b
664
jp nz, UpdateLoweredStat
665
ldh [hMultiplicand + 1], a
666
ld a, $1
667
ldh [hMultiplicand + 2], a
668
669
UpdateLoweredStat:
670
ldh a, [hProduct + 2]
671
ld [hli], a
672
ldh a, [hProduct + 3]
673
ld [hl], a
674
pop de
675
pop hl
676
UpdateLoweredStatDone:
677
ld b, c
678
inc b
679
push de
680
call PrintStatText
681
pop de
682
ld a, [de]
683
cp ATTACK_DOWN_SIDE_EFFECT ; for all side effects, move animation has already played, skip it
684
jr nc, .ApplyBadgeBoostsAndStatusPenalties
685
call PlayCurrentMoveAnimation2
686
.ApplyBadgeBoostsAndStatusPenalties
687
ldh a, [hWhoseTurn]
688
and a
689
call nz, ApplyBadgeStatBoosts ; whenever the player uses a stat-down move, badge boosts get reapplied again to every stat,
690
; even to those not affected by the stat-down move (will be boosted further)
691
ld hl, MonsStatsFellText
692
call PrintText
693
694
; These where probably added given that a stat-down move affecting speed or attack will override
695
; the stat penalties from paralysis and burn respectively.
696
; But they are always called regardless of the stat affected by the stat-down move.
697
call QuarterSpeedDueToParalysis
698
jp HalveAttackDueToBurn
699
700
CantLowerAnymore_Pop:
701
pop de
702
pop hl
703
inc [hl]
704
705
CantLowerAnymore:
706
ld a, [de]
707
cp ATTACK_DOWN_SIDE_EFFECT
708
ret nc
709
ld hl, NothingHappenedText
710
jp PrintText
711
712
MoveMissed:
713
ld a, [de]
714
cp $44
715
ret nc
716
jp ConditionalPrintButItFailed
717
718
MonsStatsFellText:
719
text_far _MonsStatsFellText
720
text_asm
721
ld hl, FellText
722
ldh a, [hWhoseTurn]
723
and a
724
ld a, [wPlayerMoveEffect]
725
jr z, .playerTurn
726
ld a, [wEnemyMoveEffect]
727
.playerTurn
728
; check if the move's effect decreases a stat by 2
729
cp BIDE_EFFECT
730
ret c
731
cp ATTACK_DOWN_SIDE_EFFECT
732
ret nc
733
ld hl, GreatlyFellText
734
ret
735
736
GreatlyFellText:
737
text_pause
738
text_far _GreatlyFellText
739
; fallthrough
740
FellText:
741
text_far _FellText
742
text_end
743
744
PrintStatText:
745
ld hl, StatModTextStrings
746
ld c, "@"
747
.findStatName_outer
748
dec b
749
jr z, .foundStatName
750
.findStatName_inner
751
ld a, [hli]
752
cp c
753
jr z, .findStatName_outer
754
jr .findStatName_inner
755
.foundStatName
756
ld de, wStringBuffer
757
ld bc, $a
758
jp CopyData
759
760
INCLUDE "data/battle/stat_mod_names.asm"
761
762
INCLUDE "data/battle/stat_modifiers.asm"
763
764
BideEffect:
765
ld hl, wPlayerBattleStatus1
766
ld de, wPlayerBideAccumulatedDamage
767
ld bc, wPlayerNumAttacksLeft
768
ldh a, [hWhoseTurn]
769
and a
770
jr z, .bideEffect
771
ld hl, wEnemyBattleStatus1
772
ld de, wEnemyBideAccumulatedDamage
773
ld bc, wEnemyNumAttacksLeft
774
.bideEffect
775
set STORING_ENERGY, [hl] ; mon is now using bide
776
xor a
777
ld [de], a
778
inc de
779
ld [de], a
780
ld [wPlayerMoveEffect], a
781
ld [wEnemyMoveEffect], a
782
call BattleRandom
783
and $1
784
inc a
785
inc a
786
ld [bc], a ; set Bide counter to 2 or 3 at random
787
ldh a, [hWhoseTurn]
788
add XSTATITEM_ANIM
789
jp PlayBattleAnimation2
790
791
ThrashPetalDanceEffect:
792
ld hl, wPlayerBattleStatus1
793
ld de, wPlayerNumAttacksLeft
794
ldh a, [hWhoseTurn]
795
and a
796
jr z, .thrashPetalDanceEffect
797
ld hl, wEnemyBattleStatus1
798
ld de, wEnemyNumAttacksLeft
799
.thrashPetalDanceEffect
800
set THRASHING_ABOUT, [hl] ; mon is now using thrash/petal dance
801
call BattleRandom
802
and $1
803
inc a
804
inc a
805
ld [de], a ; set thrash/petal dance counter to 2 or 3 at random
806
ldh a, [hWhoseTurn]
807
add SHRINKING_SQUARE_ANIM
808
jp PlayBattleAnimation2
809
810
SwitchAndTeleportEffect:
811
ldh a, [hWhoseTurn]
812
and a
813
jr nz, .handleEnemy
814
ld a, [wIsInBattle]
815
dec a
816
jr nz, .notWildBattle1
817
ld a, [wCurEnemyLevel]
818
ld b, a
819
ld a, [wBattleMonLevel]
820
cp b ; is the player's level greater than the enemy's level?
821
jr nc, .playerMoveWasSuccessful ; if so, teleport will always succeed
822
add b
823
ld c, a
824
inc c ; c = playerLevel + enemyLevel + 1
825
.rejectionSampleLoop1
826
call BattleRandom
827
cp c ; get a random number between 0 and c
828
jr nc, .rejectionSampleLoop1
829
srl b
830
srl b ; b = enemyLevel / 4
831
cp b ; is rand[0, playerLevel + enemyLevel] >= (enemyLevel / 4)?
832
jr nc, .playerMoveWasSuccessful ; if so, allow teleporting
833
ld c, 50
834
call DelayFrames
835
ld a, [wPlayerMoveNum]
836
cp TELEPORT
837
jp nz, PrintDidntAffectText
838
jp PrintButItFailedText_
839
.playerMoveWasSuccessful
840
call ReadPlayerMonCurHPAndStatus
841
xor a
842
ld [wAnimationType], a
843
inc a
844
ld [wEscapedFromBattle], a
845
ld a, [wPlayerMoveNum]
846
jr .playAnimAndPrintText
847
.notWildBattle1
848
ld c, 50
849
call DelayFrames
850
ld hl, IsUnaffectedText
851
ld a, [wPlayerMoveNum]
852
cp TELEPORT
853
jp nz, PrintText
854
jp PrintButItFailedText_
855
.handleEnemy
856
ld a, [wIsInBattle]
857
dec a
858
jr nz, .notWildBattle2
859
ld a, [wBattleMonLevel]
860
ld b, a
861
ld a, [wCurEnemyLevel]
862
cp b
863
jr nc, .enemyMoveWasSuccessful
864
add b
865
ld c, a
866
inc c
867
.rejectionSampleLoop2
868
call BattleRandom
869
cp c
870
jr nc, .rejectionSampleLoop2
871
srl b
872
srl b
873
cp b
874
jr nc, .enemyMoveWasSuccessful
875
ld c, 50
876
call DelayFrames
877
ld a, [wEnemyMoveNum]
878
cp TELEPORT
879
jp nz, PrintDidntAffectText
880
jp PrintButItFailedText_
881
.enemyMoveWasSuccessful
882
call ReadPlayerMonCurHPAndStatus
883
xor a
884
ld [wAnimationType], a
885
inc a
886
ld [wEscapedFromBattle], a
887
ld a, [wEnemyMoveNum]
888
jr .playAnimAndPrintText
889
.notWildBattle2
890
ld c, 50
891
call DelayFrames
892
ld hl, IsUnaffectedText
893
ld a, [wEnemyMoveNum]
894
cp TELEPORT
895
jp nz, PrintText
896
jp ConditionalPrintButItFailed
897
.playAnimAndPrintText
898
push af
899
call PlayBattleAnimation
900
ld c, 20
901
call DelayFrames
902
pop af
903
ld hl, RanFromBattleText
904
cp TELEPORT
905
jr z, .printText
906
ld hl, RanAwayScaredText
907
cp ROAR
908
jr z, .printText
909
ld hl, WasBlownAwayText
910
.printText
911
jp PrintText
912
913
RanFromBattleText:
914
text_far _RanFromBattleText
915
text_end
916
917
RanAwayScaredText:
918
text_far _RanAwayScaredText
919
text_end
920
921
WasBlownAwayText:
922
text_far _WasBlownAwayText
923
text_end
924
925
TwoToFiveAttacksEffect:
926
ld hl, wPlayerBattleStatus1
927
ld de, wPlayerNumAttacksLeft
928
ld bc, wPlayerNumHits
929
ldh a, [hWhoseTurn]
930
and a
931
jr z, .twoToFiveAttacksEffect
932
ld hl, wEnemyBattleStatus1
933
ld de, wEnemyNumAttacksLeft
934
ld bc, wEnemyNumHits
935
.twoToFiveAttacksEffect
936
bit ATTACKING_MULTIPLE_TIMES, [hl] ; is mon attacking multiple times?
937
ret nz
938
set ATTACKING_MULTIPLE_TIMES, [hl] ; mon is now attacking multiple times
939
ld hl, wPlayerMoveEffect
940
ldh a, [hWhoseTurn]
941
and a
942
jr z, .setNumberOfHits
943
ld hl, wEnemyMoveEffect
944
.setNumberOfHits
945
ld a, [hl]
946
cp TWINEEDLE_EFFECT
947
jr z, .twineedle
948
cp ATTACK_TWICE_EFFECT
949
ld a, $2 ; number of hits it's always 2 for ATTACK_TWICE_EFFECT
950
jr z, .saveNumberOfHits
951
; for TWO_TO_FIVE_ATTACKS_EFFECT 3/8 chance for 2 and 3 hits, and 1/8 chance for 4 and 5 hits
952
call BattleRandom
953
and $3
954
cp $2
955
jr c, .gotNumHits
956
; if the number of hits was greater than 2, re-roll again for a lower chance
957
call BattleRandom
958
and $3
959
.gotNumHits
960
inc a
961
inc a
962
.saveNumberOfHits
963
ld [de], a
964
ld [bc], a
965
ret
966
.twineedle
967
ld a, POISON_SIDE_EFFECT1
968
ld [hl], a ; set Twineedle's effect to poison effect
969
jr .saveNumberOfHits
970
971
FlinchSideEffect:
972
call CheckTargetSubstitute
973
ret nz
974
ld hl, wEnemyBattleStatus1
975
ld de, wPlayerMoveEffect
976
ldh a, [hWhoseTurn]
977
and a
978
jr z, .flinchSideEffect
979
ld hl, wPlayerBattleStatus1
980
ld de, wEnemyMoveEffect
981
.flinchSideEffect
982
ld a, [de]
983
cp FLINCH_SIDE_EFFECT1
984
ld b, 10 percent + 1 ; chance of flinch (FLINCH_SIDE_EFFECT1)
985
jr z, .gotEffectChance
986
ld b, 30 percent + 1 ; chance of flinch otherwise
987
.gotEffectChance
988
call BattleRandom
989
cp b
990
ret nc
991
set FLINCHED, [hl] ; set mon's status to flinching
992
call ClearHyperBeam
993
ret
994
995
OneHitKOEffect:
996
jpfar OneHitKOEffect_
997
998
ChargeEffect:
999
ld hl, wPlayerBattleStatus1
1000
ld de, wPlayerMoveEffect
1001
ldh a, [hWhoseTurn]
1002
and a
1003
ld b, XSTATITEM_ANIM
1004
jr z, .chargeEffect
1005
ld hl, wEnemyBattleStatus1
1006
ld de, wEnemyMoveEffect
1007
ld b, XSTATITEM_DUPLICATE_ANIM
1008
.chargeEffect
1009
set CHARGING_UP, [hl]
1010
ld a, [de]
1011
dec de ; de contains enemy or player MOVENUM
1012
cp FLY_EFFECT
1013
jr nz, .notFly
1014
set INVULNERABLE, [hl] ; mon is now invulnerable to typical attacks (fly/dig)
1015
ld b, TELEPORT ; load Teleport's animation
1016
.notFly
1017
ld a, [de]
1018
cp DIG
1019
jr nz, .notDigOrFly
1020
set INVULNERABLE, [hl] ; mon is now invulnerable to typical attacks (fly/dig)
1021
ld b, SLIDE_DOWN_ANIM
1022
.notDigOrFly
1023
xor a
1024
ld [wAnimationType], a
1025
ld a, b
1026
call PlayBattleAnimation
1027
ld a, [de]
1028
ld [wChargeMoveNum], a
1029
ld hl, ChargeMoveEffectText
1030
jp PrintText
1031
1032
ChargeMoveEffectText:
1033
text_far _ChargeMoveEffectText
1034
text_asm
1035
ld a, [wChargeMoveNum]
1036
cp RAZOR_WIND
1037
ld hl, MadeWhirlwindText
1038
jr z, .gotText
1039
cp SOLARBEAM
1040
ld hl, TookInSunlightText
1041
jr z, .gotText
1042
cp SKULL_BASH
1043
ld hl, LoweredItsHeadText
1044
jr z, .gotText
1045
cp SKY_ATTACK
1046
ld hl, SkyAttackGlowingText
1047
jr z, .gotText
1048
cp FLY
1049
ld hl, FlewUpHighText
1050
jr z, .gotText
1051
cp DIG
1052
ld hl, DugAHoleText
1053
.gotText
1054
ret
1055
1056
MadeWhirlwindText:
1057
text_far _MadeWhirlwindText
1058
text_end
1059
1060
TookInSunlightText:
1061
text_far _TookInSunlightText
1062
text_end
1063
1064
LoweredItsHeadText:
1065
text_far _LoweredItsHeadText
1066
text_end
1067
1068
SkyAttackGlowingText:
1069
text_far _SkyAttackGlowingText
1070
text_end
1071
1072
FlewUpHighText:
1073
text_far _FlewUpHighText
1074
text_end
1075
1076
DugAHoleText:
1077
text_far _DugAHoleText
1078
text_end
1079
1080
TrappingEffect:
1081
ld hl, wPlayerBattleStatus1
1082
ld de, wPlayerNumAttacksLeft
1083
ldh a, [hWhoseTurn]
1084
and a
1085
jr z, .trappingEffect
1086
ld hl, wEnemyBattleStatus1
1087
ld de, wEnemyNumAttacksLeft
1088
.trappingEffect
1089
bit USING_TRAPPING_MOVE, [hl]
1090
ret nz
1091
call ClearHyperBeam ; since this effect is called before testing whether the move will hit,
1092
; the target won't need to recharge even if the trapping move missed
1093
set USING_TRAPPING_MOVE, [hl] ; mon is now using a trapping move
1094
call BattleRandom ; 3/8 chance for 2 and 3 attacks, and 1/8 chance for 4 and 5 attacks
1095
and $3
1096
cp $2
1097
jr c, .setTrappingCounter
1098
call BattleRandom
1099
and $3
1100
.setTrappingCounter
1101
inc a
1102
ld [de], a
1103
ret
1104
1105
MistEffect:
1106
jpfar MistEffect_
1107
1108
FocusEnergyEffect:
1109
jpfar FocusEnergyEffect_
1110
1111
RecoilEffect:
1112
jpfar RecoilEffect_
1113
1114
ConfusionSideEffect:
1115
call BattleRandom
1116
cp 10 percent ; chance of confusion
1117
ret nc
1118
jr ConfusionSideEffectSuccess
1119
1120
ConfusionEffect:
1121
call CheckTargetSubstitute
1122
jr nz, ConfusionEffectFailed
1123
call MoveHitTest
1124
ld a, [wMoveMissed]
1125
and a
1126
jr nz, ConfusionEffectFailed
1127
1128
ConfusionSideEffectSuccess:
1129
ldh a, [hWhoseTurn]
1130
and a
1131
ld hl, wEnemyBattleStatus1
1132
ld bc, wEnemyConfusedCounter
1133
ld a, [wPlayerMoveEffect]
1134
jr z, .confuseTarget
1135
ld hl, wPlayerBattleStatus1
1136
ld bc, wPlayerConfusedCounter
1137
ld a, [wEnemyMoveEffect]
1138
.confuseTarget
1139
bit CONFUSED, [hl] ; is mon confused?
1140
jr nz, ConfusionEffectFailed
1141
set CONFUSED, [hl] ; mon is now confused
1142
push af
1143
call BattleRandom
1144
and $3
1145
inc a
1146
inc a
1147
ld [bc], a ; confusion status will last 2-5 turns
1148
pop af
1149
cp CONFUSION_SIDE_EFFECT
1150
call nz, PlayCurrentMoveAnimation2
1151
ld hl, BecameConfusedText
1152
jp PrintText
1153
1154
BecameConfusedText:
1155
text_far _BecameConfusedText
1156
text_end
1157
1158
ConfusionEffectFailed:
1159
cp CONFUSION_SIDE_EFFECT
1160
ret z
1161
ld c, 50
1162
call DelayFrames
1163
jp ConditionalPrintButItFailed
1164
1165
ParalyzeEffect:
1166
jpfar ParalyzeEffect_
1167
1168
SubstituteEffect:
1169
jpfar SubstituteEffect_
1170
1171
HyperBeamEffect:
1172
ld hl, wPlayerBattleStatus2
1173
ldh a, [hWhoseTurn]
1174
and a
1175
jr z, .hyperBeamEffect
1176
ld hl, wEnemyBattleStatus2
1177
.hyperBeamEffect
1178
set NEEDS_TO_RECHARGE, [hl] ; mon now needs to recharge
1179
ret
1180
1181
ClearHyperBeam:
1182
push hl
1183
ld hl, wEnemyBattleStatus2
1184
ldh a, [hWhoseTurn]
1185
and a
1186
jr z, .playerTurn
1187
ld hl, wPlayerBattleStatus2
1188
.playerTurn
1189
res NEEDS_TO_RECHARGE, [hl] ; mon no longer needs to recharge
1190
pop hl
1191
ret
1192
1193
RageEffect:
1194
ld hl, wPlayerBattleStatus2
1195
ldh a, [hWhoseTurn]
1196
and a
1197
jr z, .player
1198
ld hl, wEnemyBattleStatus2
1199
.player
1200
set USING_RAGE, [hl] ; mon is now in "rage" mode
1201
ret
1202
1203
MimicEffect:
1204
ld c, 50
1205
call DelayFrames
1206
call MoveHitTest
1207
ld a, [wMoveMissed]
1208
and a
1209
jr nz, .mimicMissed
1210
ldh a, [hWhoseTurn]
1211
and a
1212
ld hl, wBattleMonMoves
1213
ld a, [wPlayerBattleStatus1]
1214
jr nz, .enemyTurn
1215
ld a, [wLinkState]
1216
cp LINK_STATE_BATTLING
1217
jr nz, .letPlayerChooseMove
1218
ld hl, wEnemyMonMoves
1219
ld a, [wEnemyBattleStatus1]
1220
.enemyTurn
1221
bit INVULNERABLE, a
1222
jr nz, .mimicMissed
1223
.getRandomMove
1224
push hl
1225
call BattleRandom
1226
and $3
1227
ld c, a
1228
ld b, $0
1229
add hl, bc
1230
ld a, [hl]
1231
pop hl
1232
and a
1233
jr z, .getRandomMove
1234
ld d, a
1235
ldh a, [hWhoseTurn]
1236
and a
1237
ld hl, wBattleMonMoves
1238
ld a, [wPlayerMoveListIndex]
1239
jr z, .playerTurn
1240
ld hl, wEnemyMonMoves
1241
ld a, [wEnemyMoveListIndex]
1242
jr .playerTurn
1243
.letPlayerChooseMove
1244
ld a, [wEnemyBattleStatus1]
1245
bit INVULNERABLE, a
1246
jr nz, .mimicMissed
1247
ld a, [wCurrentMenuItem]
1248
push af
1249
ld a, $1
1250
ld [wMoveMenuType], a
1251
call MoveSelectionMenu
1252
call LoadScreenTilesFromBuffer1
1253
ld hl, wEnemyMonMoves
1254
ld a, [wCurrentMenuItem]
1255
ld c, a
1256
ld b, $0
1257
add hl, bc
1258
ld d, [hl]
1259
pop af
1260
ld hl, wBattleMonMoves
1261
.playerTurn
1262
ld c, a
1263
ld b, $0
1264
add hl, bc
1265
ld a, d
1266
ld [hl], a
1267
ld [wNamedObjectIndex], a
1268
call GetMoveName
1269
call PlayCurrentMoveAnimation
1270
ld hl, MimicLearnedMoveText
1271
jp PrintText
1272
.mimicMissed
1273
jp PrintButItFailedText_
1274
1275
MimicLearnedMoveText:
1276
text_far _MimicLearnedMoveText
1277
text_end
1278
1279
LeechSeedEffect:
1280
jpfar LeechSeedEffect_
1281
1282
SplashEffect:
1283
call PlayCurrentMoveAnimation
1284
jp PrintNoEffectText
1285
1286
DisableEffect:
1287
call MoveHitTest
1288
ld a, [wMoveMissed]
1289
and a
1290
jr nz, .moveMissed
1291
ld de, wEnemyDisabledMove
1292
ld hl, wEnemyMonMoves
1293
ldh a, [hWhoseTurn]
1294
and a
1295
jr z, .disableEffect
1296
ld de, wPlayerDisabledMove
1297
ld hl, wBattleMonMoves
1298
.disableEffect
1299
; no effect if target already has a move disabled
1300
ld a, [de]
1301
and a
1302
jr nz, .moveMissed
1303
.pickMoveToDisable
1304
push hl
1305
call BattleRandom
1306
and $3
1307
ld c, a
1308
ld b, $0
1309
add hl, bc
1310
ld a, [hl]
1311
pop hl
1312
and a
1313
jr z, .pickMoveToDisable ; loop until a non-00 move slot is found
1314
ld [wNamedObjectIndex], a ; store move number
1315
push hl
1316
ldh a, [hWhoseTurn]
1317
and a
1318
ld hl, wBattleMonPP
1319
jr nz, .enemyTurn
1320
ld a, [wLinkState]
1321
cp LINK_STATE_BATTLING
1322
pop hl ; wEnemyMonMoves
1323
jr nz, .playerTurnNotLinkBattle
1324
; .playerTurnLinkBattle
1325
push hl
1326
ld hl, wEnemyMonPP
1327
.enemyTurn
1328
push hl
1329
ld a, [hli]
1330
or [hl]
1331
inc hl
1332
or [hl]
1333
inc hl
1334
or [hl]
1335
and PP_MASK
1336
pop hl ; wBattleMonPP or wEnemyMonPP
1337
jr z, .moveMissedPopHL ; nothing to do if all moves have no PP left
1338
add hl, bc
1339
ld a, [hl]
1340
pop hl
1341
and a
1342
jr z, .pickMoveToDisable ; pick another move if this one had 0 PP
1343
.playerTurnNotLinkBattle
1344
; non-link battle enemies have unlimited PP so the previous checks aren't needed
1345
call BattleRandom
1346
and $7
1347
inc a ; 1-8 turns disabled
1348
inc c ; move 1-4 will be disabled
1349
swap c
1350
add c ; map disabled move to high nibble of wEnemyDisabledMove / wPlayerDisabledMove
1351
ld [de], a
1352
call PlayCurrentMoveAnimation2
1353
ld hl, wPlayerDisabledMoveNumber
1354
ldh a, [hWhoseTurn]
1355
and a
1356
jr nz, .printDisableText
1357
inc hl ; wEnemyDisabledMoveNumber
1358
.printDisableText
1359
ld a, [wNamedObjectIndex] ; move number
1360
ld [hl], a
1361
call GetMoveName
1362
ld hl, MoveWasDisabledText
1363
jp PrintText
1364
.moveMissedPopHL
1365
pop hl
1366
.moveMissed
1367
jp PrintButItFailedText_
1368
1369
MoveWasDisabledText:
1370
text_far _MoveWasDisabledText
1371
text_end
1372
1373
PayDayEffect:
1374
jpfar PayDayEffect_
1375
1376
ConversionEffect:
1377
jpfar ConversionEffect_
1378
1379
HazeEffect:
1380
jpfar HazeEffect_
1381
1382
HealEffect:
1383
jpfar HealEffect_
1384
1385
TransformEffect:
1386
jpfar TransformEffect_
1387
1388
ReflectLightScreenEffect:
1389
jpfar ReflectLightScreenEffect_
1390
1391
NothingHappenedText:
1392
text_far _NothingHappenedText
1393
text_end
1394
1395
PrintNoEffectText:
1396
ld hl, NoEffectText
1397
jp PrintText
1398
1399
NoEffectText:
1400
text_far _NoEffectText
1401
text_end
1402
1403
ConditionalPrintButItFailed:
1404
ld a, [wMoveDidntMiss]
1405
and a
1406
ret nz ; return if the side effect failed, yet the attack was successful
1407
1408
PrintButItFailedText_:
1409
ld hl, ButItFailedText
1410
jp PrintText
1411
1412
ButItFailedText:
1413
text_far _ButItFailedText
1414
text_end
1415
1416
PrintDidntAffectText:
1417
ld hl, DidntAffectText
1418
jp PrintText
1419
1420
DidntAffectText:
1421
text_far _DidntAffectText
1422
text_end
1423
1424
IsUnaffectedText:
1425
text_far _IsUnaffectedText
1426
text_end
1427
1428
PrintMayNotAttackText:
1429
ld hl, ParalyzedMayNotAttackText
1430
jp PrintText
1431
1432
ParalyzedMayNotAttackText:
1433
text_far _ParalyzedMayNotAttackText
1434
text_end
1435
1436
CheckTargetSubstitute:
1437
push hl
1438
ld hl, wEnemyBattleStatus2
1439
ldh a, [hWhoseTurn]
1440
and a
1441
jr z, .next
1442
ld hl, wPlayerBattleStatus2
1443
.next
1444
bit HAS_SUBSTITUTE_UP, [hl]
1445
pop hl
1446
ret
1447
1448
PlayCurrentMoveAnimation2:
1449
; animation at MOVENUM will be played unless MOVENUM is 0
1450
; plays wAnimationType 3 or 6
1451
ldh a, [hWhoseTurn]
1452
and a
1453
ld a, [wPlayerMoveNum]
1454
jr z, .notEnemyTurn
1455
ld a, [wEnemyMoveNum]
1456
.notEnemyTurn
1457
and a
1458
ret z
1459
1460
PlayBattleAnimation2:
1461
; play animation ID at a and animation type 6 or 3
1462
ld [wAnimationID], a
1463
ldh a, [hWhoseTurn]
1464
and a
1465
ld a, ANIMATIONTYPE_SHAKE_SCREEN_HORIZONTALLY_SLOW_2
1466
jr z, .storeAnimationType
1467
ld a, ANIMATIONTYPE_SHAKE_SCREEN_HORIZONTALLY_SLOW
1468
.storeAnimationType
1469
ld [wAnimationType], a
1470
jp PlayBattleAnimationGotID
1471
1472
PlayCurrentMoveAnimation:
1473
; animation at MOVENUM will be played unless MOVENUM is 0
1474
; resets wAnimationType
1475
xor a
1476
ld [wAnimationType], a
1477
ldh a, [hWhoseTurn]
1478
and a
1479
ld a, [wPlayerMoveNum]
1480
jr z, .notEnemyTurn
1481
ld a, [wEnemyMoveNum]
1482
.notEnemyTurn
1483
and a
1484
ret z
1485
1486
PlayBattleAnimation:
1487
; play animation ID at a and predefined animation type
1488
ld [wAnimationID], a
1489
1490
PlayBattleAnimationGotID:
1491
; play animation at wAnimationID
1492
push hl
1493
push de
1494
push bc
1495
predef MoveAnimation
1496
pop bc
1497
pop de
1498
pop hl
1499
ret
1500
1501