@@ -264,6 +264,9 @@ HandleBetweenTurnEffects:
264
264
call HandlePerishSong
265
265
call CheckFaint_PlayerThenEnemy
266
266
ret c
267
+ call HandleTrickRoom
268
+ call CheckFaint_PlayerThenEnemy
269
+ ret c
267
270
jr .NoMoreFaintingConditions
268
271
269
272
.CheckEnemyFirst:
@@ -281,6 +284,9 @@ HandleBetweenTurnEffects:
281
284
call HandlePerishSong
282
285
call CheckFaint_EnemyThenPlayer
283
286
ret c
287
+ call HandleTrickRoom
288
+ call CheckFaint_PlayerThenEnemy
289
+ ret c
284
290
285
291
.NoMoreFaintingConditions:
286
292
call HandleLeftovers
@@ -535,6 +541,10 @@ DetermineMoveOrder:
535
541
ld c , 2
536
542
call CompareBytes
537
543
jr z , .speed_tie
544
+ ld a , [ wTrickRoom ]
545
+ ld d , a
546
+ and d ; Is Trick Room active?
547
+ jp nz , .trick_room
538
548
jp nc , .player_first
539
549
jp .enemy_first
540
550
@@ -551,6 +561,7 @@ DetermineMoveOrder:
551
561
call BattleRandom
552
562
cp 50 percent + 1
553
563
jp c , .enemy_first
564
+
554
565
.player_first
555
566
scf
556
567
ret
@@ -559,6 +570,27 @@ DetermineMoveOrder:
559
570
and a
560
571
ret
561
572
573
+ .trick_room
574
+ ld hl , wTrickRoom
575
+ jp nc , .enemy_first
576
+ jp .player_first
577
+
578
+
579
+ HandleTrickRoom:
580
+ ld hl , wTrickRoom
581
+ ld a , [ hl ]
582
+ and a
583
+ ret z
584
+ dec [ hl ]
585
+ ret nz
586
+ ld hl , TrickRoomEndedText
587
+ jp StdBattleTextbox
588
+
589
+ .end_trick_room
590
+ ld hl , TrickRoomEndedText
591
+ jp StdBattleTextbox
592
+
593
+
562
594
CheckContestBattleOver:
563
595
ld a , [ wBattleType ]
564
596
cp BATTLETYPE_CONTEST
@@ -609,13 +641,15 @@ ParsePlayerAction:
609
641
bit SUBSTATUS_ENCORED , [ hl ]
610
642
jr z , .not_encored
611
643
ld a , [ wLastPlayerMove ]
644
+ and a
645
+ jr z , .not_encored
612
646
ld [ wCurPlayerMove ], a
613
647
jr .encored
614
648
615
649
.not_encored
616
650
ld a , [ wBattlePlayerAction ]
617
651
cp BATTLEPLAYERACTION_SWITCH
618
- jr z , .reset_rage
652
+ jp z , .reset_rage
619
653
and a
620
654
jr nz , .reset_bide
621
655
ld a , [ wPlayerSubStatus3 ]
@@ -639,6 +673,7 @@ ParsePlayerAction:
639
673
ldh [ hBGMapMode ], a
640
674
pop af
641
675
ret nz
676
+ call SetChoiceLock
642
677
643
678
.encored
644
679
call SetPlayerTurn
@@ -829,8 +864,8 @@ GetMovePriority:
829
864
830
865
ld b , a
831
866
832
- ; Vital Throw goes last.
833
- cp VITAL_THROW
867
+ ; Trick Room goes last.
868
+ cp TRICK_ROOM
834
869
ld a , 0
835
870
ret z
836
871
@@ -1294,9 +1329,33 @@ HandleLeftovers:
1294
1329
ld [ wNamedObjectIndex ], a
1295
1330
call GetItemName
1296
1331
ld a , b
1332
+ cp HELD_BLACK_SLUDGE
1333
+ jr nz , .check_leftovers
1334
+
1335
+ ; check if user is poison type
1336
+ ld hl , wBattleMonType1
1337
+ ldh a , [ hBattleTurn ]
1338
+ and a
1339
+ jr z , .gottype
1340
+ ld hl , wEnemyMonType1
1341
+ .gottype
1342
+ ld a , [ hli ]
1343
+ cp POISON
1344
+ jp z , .get_hp
1345
+ ld a , [ hl ]
1346
+ cp POISON
1347
+ jp z , .get_hp
1348
+
1349
+ ; User is not poison, deal damage
1350
+ call GetEighthMaxHP
1351
+ call SubtractHPFromTarget
1352
+ ld hl , BattleText_UsersHurtByStringBuffer1
1353
+ jp StdBattleTextbox
1354
+
1355
+ .check_leftovers
1297
1356
cp HELD_LEFTOVERS
1298
1357
ret nz
1299
-
1358
+ .get_hp
1300
1359
ld hl , wBattleMonHP
1301
1360
ldh a , [ hBattleTurn ]
1302
1361
and a
@@ -1323,6 +1382,7 @@ HandleLeftovers:
1323
1382
ld hl , BattleText_TargetRecoveredWithItem
1324
1383
jp StdBattleTextbox
1325
1384
1385
+
1326
1386
HandleMysteryberry:
1327
1387
ldh a , [ hSerialConnectionStatus ]
1328
1388
cp USING_EXTERNAL_CLOCK
@@ -1687,14 +1747,22 @@ HandleWeather:
1687
1747
1688
1748
ld hl , wWeatherCount
1689
1749
dec [ hl ]
1690
- jr z , .ended
1750
+ jr nz , .continues
1751
+
1752
+ ; ended
1753
+ ld hl , .WeatherEndedMessages
1754
+ call .PrintWeatherMessage
1755
+ xor a
1756
+ ld [ wBattleWeather ], a
1757
+ ret
1691
1758
1759
+ .continues
1692
1760
ld hl , .WeatherMessages
1693
1761
call .PrintWeatherMessage
1694
1762
1695
1763
ld a , [ wBattleWeather ]
1696
1764
cp WEATHER_SANDSTORM
1697
- ret nz
1765
+ jr nz , .check_hail
1698
1766
1699
1767
ldh a , [ hSerialConnectionStatus ]
1700
1768
cp USING_EXTERNAL_CLOCK
@@ -1751,12 +1819,51 @@ HandleWeather:
1751
1819
ld hl , SandstormHitsText
1752
1820
jp StdBattleTextbox
1753
1821
1754
- .ended
1755
- ld hl , .WeatherEndedMessages
1756
- call .PrintWeatherMessage
1757
- xor a
1758
- ld [ wBattleWeather ], a
1759
- ret
1822
+ .check_hail
1823
+ ld a , [ wBattleWeather ]
1824
+ cp WEATHER_HAIL
1825
+ ret nz
1826
+
1827
+ ldh a , [ hSerialConnectionStatus ]
1828
+ cp USING_EXTERNAL_CLOCK
1829
+ jr z , .enemy_first_hail
1830
+
1831
+ ; player first
1832
+ call SetPlayerTurn
1833
+ call .HailDamage
1834
+ call SetEnemyTurn
1835
+ jr .HailDamage
1836
+
1837
+ .enemy_first_hail
1838
+ call SetEnemyTurn
1839
+ call .HailDamage
1840
+ call SetPlayerTurn
1841
+
1842
+ .HailDamage:
1843
+ ld a , BATTLE_VARS_SUBSTATUS3
1844
+ call GetBattleVar
1845
+ bit SUBSTATUS_UNDERGROUND , a
1846
+ ret nz
1847
+
1848
+ ld hl , wBattleMonType1
1849
+ ldh a , [ hBattleTurn ]
1850
+ and a
1851
+ jr z , .ok1
1852
+ ld hl , wEnemyMonType1
1853
+ .ok1
1854
+ ld a , [ hli ]
1855
+ cp ICE
1856
+ ret z
1857
+
1858
+ ld a , [ hl ]
1859
+ cp ICE
1860
+ ret z
1861
+
1862
+ call GetSixteenthMaxHP
1863
+ call SubtractHPFromUser
1864
+
1865
+ ld hl , PeltedByHailText
1866
+ jp StdBattleTextbox
1760
1867
1761
1868
.PrintWeatherMessage:
1762
1869
ld a , [ wBattleWeather ]
@@ -1775,12 +1882,14 @@ HandleWeather:
1775
1882
dw BattleText_RainContinuesToFall
1776
1883
dw BattleText_TheSunlightIsStrong
1777
1884
dw BattleText_TheSandstormRages
1885
+ dw BattleText_HailContinuesToFall
1778
1886
1779
1887
.WeatherEndedMessages:
1780
1888
; entries correspond to WEATHER_* constants
1781
1889
dw BattleText_TheRainStopped
1782
1890
dw BattleText_TheSunlightFaded
1783
1891
dw BattleText_TheSandstormSubsided
1892
+ dw BattleText_TheHailStopped
1784
1893
1785
1894
SubtractHPFromTarget:
1786
1895
call SubtractHP
@@ -4172,7 +4281,7 @@ PursuitSwitch:
4172
4281
4173
4282
ld a , BATTLE_VARS_MOVE
4174
4283
call GetBattleVarAddr
4175
- ld a , $ ff
4284
+ xor a ; NO_MOVE
4176
4285
ld [ hl ], a
4177
4286
4178
4287
pop af
@@ -5808,6 +5917,7 @@ ParseEnemyAction:
5808
5917
bit SUBSTATUS_ENCORED , [ hl ]
5809
5918
ld a , [ wLastEnemyMove ]
5810
5919
jp nz , .finish
5920
+ call SetChoiceLock
5811
5921
ld hl , wEnemyMonMoves
5812
5922
ld b , 0
5813
5923
add hl , bc
@@ -5888,6 +5998,7 @@ ParseEnemyAction:
5888
5998
5889
5999
.skip_load
5890
6000
call SetEnemyTurn
6001
+ call SetChoiceLock
5891
6002
callfar UpdateMoveData
5892
6003
call CheckEnemyLockedIn
5893
6004
jr nz , .raging
@@ -5924,6 +6035,30 @@ ParseEnemyAction:
5924
6035
ld a , STRUGGLE
5925
6036
jr .finish
5926
6037
6038
+ SetChoiceLock:
6039
+ push hl
6040
+ push bc
6041
+ callfar GetUserItem
6042
+ ld a , b
6043
+ cp HELD_CHOICE_BOOST
6044
+ jr nz , .done
6045
+ ld hl , wPlayerEncoreCount
6046
+ ldh a , [ hBattleTurn ]
6047
+ and a
6048
+ jr z , .GotEncoreCount
6049
+ ld hl , wEnemyEncoreCount
6050
+ .GotEncoreCount
6051
+ ld a , - 1 ; Set encore count to 255
6052
+ ld [ hl ], a
6053
+ ld a , BATTLE_VARS_SUBSTATUS5
6054
+ call GetBattleVarAddr
6055
+ set SUBSTATUS_ENCORED , [ hl ]
6056
+
6057
+ .done
6058
+ pop bc
6059
+ pop hl
6060
+ ret
6061
+
5927
6062
ResetVarsForSubstatusRage:
5928
6063
xor a
5929
6064
ld [ wEnemyFuryCutterCount ], a
@@ -6192,12 +6327,13 @@ LoadEnemyMon:
6192
6327
jr nc , .GenerateDVs
6193
6328
6194
6329
.CheckMagikarpArea:
6330
+ ; TODO: Replace GROUP_NONE and MAP_NONE with the map you want for large Magikarp.
6195
6331
; BUG: Magikarp in Lake of Rage are shorter, not longer (see docs/bugs_and_glitches.md)
6196
6332
ld a , [ wMapGroup ]
6197
- cp GROUP_LAKE_OF_RAGE
6333
+ cp GROUP_NONE
6198
6334
jr z , .Happiness
6199
6335
ld a , [ wMapNumber ]
6200
- cp MAP_LAKE_OF_RAGE
6336
+ cp MAP_NONE
6201
6337
jr z , .Happiness
6202
6338
; 40% chance of not flooring
6203
6339
call Random
@@ -6791,7 +6927,7 @@ BadgeStatBoosts:
6791
6927
rrca
6792
6928
ld c , a
6793
6929
ld a , d
6794
- and (( 1 << ZEPHYRBADGE ) | ( 1 << HIVEBADGE) | ( 1 << FOGBADGE) | ( 1 << STORMBADGE) | ( 1 << GLACIERBADGE) | ( 1 << RISINGBADGE))
6930
+ and (( 1 << ANCHORBADGE ) | ( 1 << HIVEBADGE) | ( 1 << FOGBADGE) | ( 1 << STORMBADGE) | ( 1 << GLACIERBADGE) | ( 1 << RISINGBADGE))
6795
6931
or b
6796
6932
or c
6797
6933
ld b , a
@@ -7404,6 +7540,37 @@ BoostExp:
7404
7540
pop bc
7405
7541
ret
7406
7542
7543
+ CheckOpponentFullHP:
7544
+ ; check if the opponent has full HP
7545
+ ; z: yes, nz: no
7546
+ ld hl , wEnemyMonHP
7547
+ ld a , [ hBattleTurn ]
7548
+ and a
7549
+ jr z , DoCheckFullHP
7550
+ ld hl , wBattleMonHP
7551
+ jr DoCheckFullHP
7552
+
7553
+ CheckFullHP:
7554
+ ; check if the user has full HP
7555
+ ; z: yes, nz: no
7556
+ ld hl , wBattleMonHP
7557
+ ld a , [ hBattleTurn ]
7558
+ and a
7559
+ jr z , DoCheckFullHP
7560
+ ld hl , wEnemyMonHP
7561
+ ; fallthrough
7562
+ DoCheckFullHP:
7563
+ ld a , [ hli ]
7564
+ ld b , a
7565
+ ld a , [ hli ]
7566
+ ld c , a
7567
+ ld a , [ hli ]
7568
+ cp b
7569
+ ret nz
7570
+ ld a , [ hl ]
7571
+ cp c
7572
+ ret
7573
+
7407
7574
Text_MonGainedExpPoint:
7408
7575
text_far Text_Gained
7409
7576
text_asm
@@ -8123,9 +8290,9 @@ InitEnemyTrainer:
8123
8290
callfar GetTrainerAttributes
8124
8291
callfar ReadTrainerParty
8125
8292
8126
- ; RIVAL1 's first mon has no held item
8293
+ ; RIVALP 's first mon has no held item
8127
8294
ld a , [ wTrainerClass ]
8128
- cp RIVAL1
8295
+ cp POKEMON_PROF
8129
8296
jr nz , .ok
8130
8297
xor a
8131
8298
ld [ wOTPartyMon1Item ], a
0 commit comments