summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorRemy Oukaour <remy.oukaour@gmail.com>2018-01-10 02:55:44 -0500
committerRemy Oukaour <remy.oukaour@gmail.com>2018-01-10 02:55:44 -0500
commit16eb97ae9cca0ce52531860c499c3346e6a2cf9e (patch)
treee2bdf2e80c925514881a35c7f4bce4f0e7341739 /engine
parent7de7441e72f12ba1518504055acdec741bf4db74 (diff)
Constant swap explains this Battle Tower bug
Diffstat (limited to 'engine')
-rw-r--r--engine/events/battle_tower/load_trainer.asm13
-rw-r--r--engine/events/battle_tower/rules.asm6
2 files changed, 11 insertions, 8 deletions
diff --git a/engine/events/battle_tower/load_trainer.asm b/engine/events/battle_tower/load_trainer.asm
index bf8b20a27..08571dcef 100644
--- a/engine/events/battle_tower/load_trainer.asm
+++ b/engine/events/battle_tower/load_trainer.asm
@@ -27,11 +27,14 @@ Function_LoadOpponentTrainerAndPokemons: ; 1f8000
add b
ld b, a ; b contains the nr of the trainer
if DEF(_CRYSTAL11)
- and $7f
+ and BATTLETOWER_TRAINER_MASK
+ cp BATTLETOWER_NUM_UNIQUE_TRAINERS
else
- and $1f
+; Crystal 1.0 used the wrong constants here, so only the first 21
+; trainers in BattleTowerTrainers can be sampled.
+ and BATTLETOWER_PKMN_MASK
+ cp BATTLETOWER_NUM_UNIQUE_PKMN
endc
- cp (BattleTowerTrainersEnd - BattleTowerTrainers) / NAME_LENGTH
jr nc, .resample
ld b, a
@@ -112,8 +115,8 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081
ld a, [hRandomAdd]
add b
ld b, a
- and $1f
- cp BATTLETOWER_NROFPKMNS * BATTLETOWER_NROFTRAINERS
+ and BATTLETOWER_PKMN_MASK
+ cp BATTLETOWER_NUM_UNIQUE_PKMN
jr nc, .resample
; in register 'a' is the chosen Pkmn of the LevelGroup
diff --git a/engine/events/battle_tower/rules.asm b/engine/events/battle_tower/rules.asm
index de6022145..8d037951b 100644
--- a/engine/events/battle_tower/rules.asm
+++ b/engine/events/battle_tower/rules.asm
@@ -213,7 +213,7 @@ BattleTower_ExecuteJumptable: ; 8b25b
BattleTower_CheckPartyLengthIs3: ; 8b2bb
ld a, [PartyCount]
- cp 3
+ cp BATTLETOWER_NROFPKMNS
ret
; 8b2c1
@@ -235,13 +235,13 @@ BattleTower_CheckPartyHasThreeMonsThatAreNotEggs: ; 8b2c1
cp b
ret z
ld a, b
- cp 3
+ cp BATTLETOWER_NROFPKMNS
ret
; 8b2da
Function_PartyCountEq3: ; 8b2da
ld a, [PartyCount]
- cp 3
+ cp BATTLETOWER_NROFPKMNS
ret z
scf
ret