From 16eb97ae9cca0ce52531860c499c3346e6a2cf9e Mon Sep 17 00:00:00 2001 From: Remy Oukaour Date: Wed, 10 Jan 2018 02:55:44 -0500 Subject: Constant swap explains this Battle Tower bug --- engine/events/battle_tower/load_trainer.asm | 13 ++++++++----- engine/events/battle_tower/rules.asm | 6 +++--- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'engine') 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 -- cgit v1.2.3