Skip to content

Commit

Permalink
base code for randomized trainers, possible setup for battle tower later
Browse files Browse the repository at this point in the history
Right now, you can test it by defeating the elite four, then resetting a gym like cerulean and battling a swimmer there.
  • Loading branch information
longlostsoul committed Oct 16, 2021
1 parent 765c88f commit b2afd5d
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 10 deletions.
2 changes: 1 addition & 1 deletion constants/event_constants.asm
Expand Up @@ -2312,7 +2312,7 @@ const_value = 0
const EVENT_905 ; 905, (D867, bit 5)
const EVENT_906 ; 906, (D867, bit 6)
const ELITE4_CHAMPION_EVENTS_END ; 907, (D867, bit 7)
const EVENT_908 ; 908, (D868, bit 0)
const EVENT_908 ; 908, (D868, bit 0) ;beat elite???
const EVENT_909 ; 909, (D868, bit 1)
const EVENT_90A ; 90A, (D868, bit 2)
const EVENT_90B ; 90B, (D868, bit 3)
Expand Down
2 changes: 1 addition & 1 deletion constants/trainer_constants.asm
Expand Up @@ -18,7 +18,7 @@ const_value = 1
trainer_const BIKER ; $0A | OPP = $D2
trainer_const BURGLAR ; $0B | OPP = $D3
trainer_const ENGINEER ; $0C | OPP = $D4
trainer_const JUGGLER_X ; $0D | OPP = $D5
trainer_const RANDTRAINER ; $0D | OPP = $D5
trainer_const FISHER ; $0E | OPP = $D6
trainer_const SWIMMER ; $0F | OPP = $D7
trainer_const CUE_BALL ; $10 | OPP = $D8
Expand Down
5 changes: 3 additions & 2 deletions data/trainer_parties.asm
Expand Up @@ -219,8 +219,9 @@ EngineerData:
db 25,VOLTORB,MAGNEMITE,PORYGON2,0;not used?
db 25,MAGNEMITE,PORYGONZ,FLAAFFY,0
db 23,MAGNEMITE,MAGNETON,MAGNEZONE,0
Juggler1Data:
; none
Juggler1Data:
; none. now RANDTRAINER
db 50,SQUIRTLE,BULBASAUR,CHARMANDER,MEW,MEWTWO,RATTATA,0
FisherData:
db 20,GEODUDE,CHINCHOU,GOLDEEN,0
db 27,TENTACOOL,STARYU,SHELLDER,0
Expand Down
2 changes: 1 addition & 1 deletion data/trainer_types.asm
Expand Up @@ -6,7 +6,7 @@ FemaleTrainerList::
db $FF

EvilTrainerList::
db OPP_JUGGLER_X
;db OPP_JUGGLER_X
db OPP_GAMBLER
db OPP_ROCKER
db OPP_JUGGLER
Expand Down
54 changes: 52 additions & 2 deletions engine/battle/read_trainer_party.asm
Expand Up @@ -64,9 +64,40 @@ ReadTrainer:
ld a,ENEMY_PARTY_DATA
ld [wMonDataLocation],a
push hl
call AddPartyMon
ld a,[wTrainerClass] ;BEGINNING OF RANDOMIZER TRAINER CODE 1.
cp RANDTRAINER
jr z, .pookachu
;SetEvent EVENT_908
CheckEvent EVENT_908 ;has elite 4 been beaten? if so, expand the random trainers list
jr z, .addmon ;if no, don't. However, this only works on very specific trainers, ones that have no level specified
ld a,[wTrainerClass]
cp COOLTRAINER_F
jr z, .pookachu
cp LASS
jr z, .pookachu
cp JUGGLER
jr z, .pookachu
cp SWIMMER
jr z, .pookachu
cp COOLTRAINER_M
jr z, .pookachu
.addmon
call AddPartyMon ;ADDING a mon, whether random or not
ld a,ENEMY_PARTY_DATA
pop hl
jr .LoopTrainerData
.pookachu
call Random
cp 250
jr c, .skippika
;ld a, 5
;ld [wCurEnemyLVL], a
ld a, PIKACHU;If we get an invalid number for our randomizer, get pika?
.skippika
ld [wd11e], a
ld [wcf91], a
jr .addmon ; END TRAINER RANDOMIZER
.SpecialTrainer
; if this code is being run:
; - each pokemon has a specific level
Expand All @@ -86,9 +117,26 @@ ReadTrainer:
ld a,ENEMY_PARTY_DATA
ld [wMonDataLocation],a
push hl
call AddPartyMon
ld a,[wTrainerClass] ;BEGINNING OF RANDOMIZER TRAINER CODE 2.
cp RANDTRAINER
jr z, .pookachu1
; This only works on very specific trainers that have mon levels specified
.addmon1
call AddPartyMon ;ADDING a mon, whether random or not
ld a,ENEMY_PARTY_DATA
pop hl
jr .SpecialTrainer
.pookachu1
call Random
cp 250
jr c, .skippika1
;ld a, 5
;ld [wCurEnemyLVL], a
ld a, PIKACHU;If we get an invalid number for our randomizer, get pika?
.skippika1
ld [wd11e], a
ld [wcf91], a
jr .addmon1 ; END TRAINER RANDOMIZER
.AddAdditionalMoveData
; does the trainer have additional move data?
ld a, [wTrainerClass]
Expand Down Expand Up @@ -155,6 +203,8 @@ ReadTrainer:
jr nz,.LastLoop ; repeat wCurEnemyLVL times
ret

ModifyTrainerLevel: ;Pokemon Roaming Red, average trainer levels and make Elite still higher level, make things a little more balanced.
push af
push bc
Expand Down
2 changes: 1 addition & 1 deletion engine/battle/trainer_ai.asm
Expand Up @@ -309,7 +309,7 @@ TrainerClassMoveChoiceModifications:
db 1,2,0 ; BIKER
db 1,3,0 ; BURGLAR
db 1,2,3,0 ; ENGINEER
db 1,2,0 ; JUGGLER_X
db 1,2,3,0 ; JUGGLER_X now RANDTRAINER I guess for battletower?
db 1,3,0 ; FISHER
db 1,2,3,0 ; SWIMMER
db 3,0 ; CUE_BALL
Expand Down
4 changes: 2 additions & 2 deletions engine/battle/trainer_pic_money_pointers.asm
Expand Up @@ -37,7 +37,7 @@ TrainerPicAndMoneyPointers:
dw EngineerPic
money 5000

dw JugglerPic
dw RedPicFront ;Juggler1
money 3500

dw FisherPic
Expand All @@ -61,7 +61,7 @@ TrainerPicAndMoneyPointers:
dw RockerPic
money 2500

dw JugglerPic
dw JugglerPic ;Actual Juggler
money 3500

dw TamerPic
Expand Down
1 change: 1 addition & 0 deletions scripts/halloffameroom.asm
Expand Up @@ -40,6 +40,7 @@ HallofFameRoomScript2:
ld [wLanceCurScript], a
ld [wHallOfFameRoomCurScript], a
; Elite 4 events
SetEvent EVENT_908 ;just useful to have this I guess
ResetEventRange ELITE4_EVENTS_START, ELITE4_CHAMPION_EVENTS_END, 1
xor a
ld [wHallOfFameRoomCurScript], a
Expand Down

0 comments on commit b2afd5d

Please sign in to comment.