Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2010-11-09 12:16:00

Miksy91
Member
Registered: 2010-10-16
Post 174/2,339

Pokémon Yellow Trainer Data

Notice that the offsets are only for Pokemon Yellow !

This is not any normal "how to edit pokemon of a certain trainer" document.
It's focused on modifying the Trainer Data inside the Map Header.

Here is the trainer data of a certain trainer in map header.
[Picture Number][Y position + 4][X position + 4][Movement 1][Movement 2]
[Text String Number][Trainer type][Pokemon set]

Now, I'm going to explain how to edit [Trainer type] & [Pokemon set] bytes.

At offset 0x39DD1, there are several 2-byte pointers to the each [Trainer type] in the game.
For example, at 0x39E13 you can find Trainer type Brock's pointer (54 64). Don't confuse this with a single trainer !
In the first generation, you can only battle one Brock but practically it's possible to add as many Brocks to the game as you like.

Other trainers of that group (or Trainer type) follow the first trainer in the same group and don't have their own pointers.
Instead of having pointers to them, the game locates their trainer data with the [Pokemon set] byte.
The first trainer of each trainer type, has 01 as its [Pokemon set byte].
Then second one has 02, the third 03 etc.
*There could practically be 255 trainers in each group.

Let's give another example:
We know that the offset for Trainer type Birdkeeper is located at 0x3A210 (Open the ROM with a hex editor to keep up with this).
If we wanted to know where is the location for Birdkeeper with 06 as its [Pokemon set] byte, we would first go to 0x3A210 and then
look for the sixth trainer data that starts (after byte 00). The trainer data would be at 0x3A228.

Still one more example:
Let's say we want to know the trainer data for Trainer type Koga whose [Pokemon set] is 04.
First, we would go to 0x3A46C and then locate the fourth trainer of that group. The trainer data would be at 0x3A486.
Because there is only one trainer of types Koga, Blaine and Sabrina, we happen to find out we just made Koga have the same pokemon
data as the first trainer of Trainer type Gentleman. Actually, there is a difference with having EE 04 and F1 01 as the trainer data.

EE 04 keeps the sprite and name of Koga whileas F1 01 has sprite of Gentleman but still the same pokemon data !



However, this isn't all you can use trainer data for ;)

Apparently, the game loads the event pokemon (Articuno, Zapdos etc.) with the use of same bytes.
Encountered trainers have C9-F7 as their [Trainer type] bytes.
Wild pokemon are numbered from 00 to BE in Pokemon RBY. So, if you replace the [Trainer type] byte with one from this space, you
encounter a wild pokemon instead. In this occasion, the [Pokemon set] byte works as the level of the encountered wild pokemon.



Pointers & Trainer Types

Pointers
0x39DD1-0x39E2E

[Trainer type]

Youngster C9 (0x39E2F)
Bug Catcher CA (0x39E67)
Lass CB (0x39EA9)
Sailor CC (0x39EF8)
Jr. Trainer (M) CD (0x39F17)
Jr. Trainer (F) CE (0x39F3F)
Pokemaniac CF (0x39FAE)
Super Nerd D0 (0x39FCB)
Hiker D1 (0x3A003)
Biker D2 (0x3A041)
Burglar D3 (0x3A089)
Engineer D4 (0x3A0AC)
Juggler (1) D5 (0x3A0B8) - Juggler that has the exact same pokemon data as the Fishermen with the same [Pokemon set] byte. Repoint him instead of Juggler (2).
Fisherman D6 (0x3A0B8)
Swimmer D7 (0x3A0EE)
Cue Ball D8 (0x3A132)
Gambler D9 (0x3A158)
Beauty DA (0x3A176)
Psychic DB (0x3A1BA)
Rocker DC (0x3A1CC)
Juggler (2) DD (0x3A1D5) - The game loads Juggler -trainers from this section. Juggler (1) should work fine but is unused.
Tamer DE (0x3A1F6)
Bird Keeper DF (0x3A210)
Blackbelt E0 (0x3A263)
Gary (1) E1 (0x3A289)
Prof. Oak E2 (0x3A29C)
Chief E3 (0x3A2C0)
Scientist E4 (0x3A2CO) - With the same [Pokemon set] byte, has the same pokemon data and sprite as Chief.
Giovanni E5 (0x3A2FD)
Rocket E6 (0x3A31B)
Cooltrainer (M) E7 (0x3A3F9)
Cooltrainer (F) E8 (0x3A424)
Bruno E9 (0x3A448)
Brock EA (0x3A454)
Misty EB (0x3A45A)
Lt. Surge EC (0x3A460)
Erika ED (0x3A464)
Koga EE (0x3A46C)
Blaine EF (0x3A476)
Sabrina F0 (0x3A47E)
Gentleman F1 (0x3A486)
Gary (2) F2 (0x3A499)
Gary (3) F3 (0x3A515)
Lorelei F4 (0x3A53F)
Channeler F5 (0x3A54B)
Agatha F6 (0x3A59A)
Lance F7 (0x3A665)



So, what do you need these for ?

-Making trainers have more/less pokemon than originally
-Possibility to expand the number of various trainers
-Editing the base of several "bosses"


Editing the base of several "bosses"


Gym leaders and Elite Four (maybe also others) have pokemon with special movesets but they can also use items.
I have no idea where to find the data for those and they will most likely get in your way if you don't want your game to be "glitchy".
I happened to figure this out as I wanted to make a certain trainer have Nidorino but originally after changing that pokemon into Nidorino, it could use Mega Drain.

It happens to be so that [Trainer type] & [Pokemon set] bytes together tell the game whether or not to load some special trainer battle data.
As explained above, that would mean the trainer may be able to use items and stuff with certain [Trainer type] & [Pokemon set] bytes.

For instance, original Brock (EA 01) has a pokemon (Onix) that knows Bind (and likely Bide) as its special moves.
Brock is also capable of giving his pokemon Full Heals (Unlimited amount?).

Because we don't want Brock to be a cheater who can use Full Heals or perhaps we want Brock to be a real boss whose pokemon don't know that bad moves,
we have to make the game load the trainer data of some other Brock. If you learned this already, you'd know EA 02 works as a Brock who would have Misty's pokemon data.
However, we don't want to make Misty have the same pokemon with Brock. Therefore, we've to repoint Trainer type Brock !
Above: "For example, at 0x39E13 you can find Trainer type Brock's pointer (54 64)."

So, let's go to 0x39E13 and change bytes 54 64 to 00 7C (because we haven't written any data to 0x3BC00 yet).
Now, write any kind of trainer data for Brock (EA 01) as you wish (at 0x3BC00), I'd myself keep the original one in the game just in case you need it so
write FF 0A A9 0C 22 00 there. Now that we've repointed Brock, the game loads trainer data EA 02 after byte 00 (at 0x3BC06).
Let's for example write bytes FF 0A A9 0C 22 00 there again.

62668192.png

This time, if you change the trainer data of Person Brock inside Pewter Gym's Map Header (at 0x5C433) to EA 02, in the game you would encounter
the "same" Brock as before but now he couldn't use Full Heals anymore and his Onix couldn't use special moves either :D

Last edited by Miksy91 (2010-11-19 20:20:36)

Offline

#2 2010-11-10 03:42:47

54/703

Re: Pokémon Yellow Trainer Data

Miksy91 wrote:

The bytes for each pokemon go from 00 to BE.
The [Trainer type] bytes for each "trainer" go from C9 to F7.

By changing the [Trainer type] to something between 00 and BE, you'll encounter a wild pokemon instead of the original trainer :O

This is why you can encounter trainers along Cinnabar coast.

As I recall, there's another flag in RAM nearby that defines whether it's a trainer or not, and glitches out when it's not set if the ID is a trainer and not a Pokémon. Hence why the trainers you encounter along the coast glitch terribly.

Miksy91 wrote:

Juggler (2) DD (same sprite and name with Juggler (1), locates the trainer data pointers elsewhere though)

The first Juggler type is completely unused; its pointer leads to Fisher data.

I've disassembled a lot of the trainer data, including AI; if anyone's interested, here it is. (As usual, it's available at BitBucket; I kept from pushing to the repository for a while because I wanted to clean it up, but better to push it now than forget about it and never release it.)

; trainer data: from 5C53 to 652E

ReadTrainer: ; 5C53

; don't change any moves in a link battle
    ld a,[W_ISLINKBATTLE]
    and a
    ret nz

; set [W_ENEMYMONCOUNT] to 0, [$D89D] to FF
; XXX first is total enemy pokemon?
; XXX second is species of first pokemon?
    ld hl,W_ENEMYMONCOUNT
    xor a
    ld [hli],a
    dec a
    ld [hl],a

; get the pointer to trainer data for this class
    ld a,[W_CUROPPONENT]
    sub $C9 ; convert value from pokemon to trainer
    add a,a
    ld hl,TrainerDataPointers
    ld c,a
    ld b,0
    add hl,bc ; hl points to trainer class
    ld a,[hli]
    ld h,[hl]
    ld l,a
    ld a,[W_TRAINERNO]
    ld b,a
; At this point b contains the trainer number,
; and hl points to the trainer class.
; Our next task is to iterate through the trainers,
; decrementing b each time, until we get to the right one.
.outer\@
    dec b
    jr z,.IterateTrainer
.inner\@
    ld a,[hli]
    and a
    jr nz,.inner\@
    jr .outer\@

; if the first byte of trainer data is FF,
; - each pokemon has a specific level
;      (as opposed to the whole team being of the same level)
; - if [W_LONEATTACKNO] != 0, one pokemon on the team has a special move
; else the first byte is the level of every pokemon on the team
.IterateTrainer
    ld a,[hli]
    cp $FF ; is the trainer special?
    jr z,.SpecialTrainer\@ ; if so, check for special attacks
    ld [W_CURENEMYLVL],a
.LoopTrainerData\@
    ld a,[hli]
    and a ; have we reached the end of the trainer data?
    jr z,.FinishUp\@
    ld [$CF91],a ; write species somewhere (XXX why?)
    ld a,1
    ld [$CC49],a
    push hl
    call $3927
    pop hl
    jr .LoopTrainerData\@
.SpecialTrainer\@
; if this code is being run:
; - each pokemon has a specific level
;      (as opposed to the whole team being of the same level)
; - if [W_LONEATTACKNO] != 0, one pokemon on the team has a special move
    ld a,[hli]
    and a ; have we reached the end of the trainer data?
    jr z,.AddLoneAttack\@
    ld [W_CURENEMYLVL],a
    ld a,[hli]
    ld [$CF91],a
    ld a,1
    ld [$CC49],a
    push hl
    call $3927
    pop hl
    jr .SpecialTrainer\@
.AddLoneAttack\@
; does the trainer have a single monster with a different move
    ld a,[W_LONEATTACKNO] ; Brock is 01, Misty is 02, Erika is 04, etc
    and a
    jr z,.AddTeamAttack\@
    dec a
    add a,a
    ld c,a
    ld b,0
    ld hl,LoneAttacks
    add hl,bc
    ld a,[hli]
    ld d,[hl]
    ld hl,W_ENEMYMON1MOVE3
    ld bc,W_ENEMYMON2MOVE3 - W_ENEMYMON1MOVE3
    call AddNTimes
    ld [hl],d
    jr .FinishUp\@
.AddTeamAttack\@
; check if our trainer's team has special moves

; get trainer class number
    ld a,[$D059]
    sub $C8
    ld b,a
    ld hl,TeamAttacks

; iterate through entries in TeamAttacks, checking each for our trainer class
.IterateTeamAttacks\@
    ld a,[hli]
    cp b
    jr z,.GiveTeamAttacks\@ ; is there a match?
    inc hl ; if not, go to the next entry
    inc a
    jr nz,.IterateTeamAttacks\@

    ; no matches found. is this trainer champion rival?
    ld a,b
    cp SONY3
    jr z,.ChampionRival\@
    jr .FinishUp\@ ; nope
.GiveTeamAttacks\@
    ld a,[hl]
    ld [$D95E],a
    jr .FinishUp\@
.ChampionRival\@ ; give attacks to his team

; pidgeot
    ld a,SKY_ATTACK
    ld [W_ENEMYMON1MOVE3],a

; starter
    ld a,[W_RIVALSTARTER]
    cp BULBASAUR
    ld b,MEGA_DRAIN
    jr z,.GiveStarterMove\@
    cp CHARMANDER
    ld b,FIRE_BLAST
    jr z,.GiveStarterMove\@
    ld b,BLIZZARD ; must be squirtle
.GiveStarterMove\@
    ld a,b
    ld [W_ENEMYMON6MOVE3],a
.FinishUp\@ ; XXX this needs documenting
    xor a       ; clear D079-D07B
    ld de,$D079
    ld [de],a
    inc de
    ld [de],a
    inc de
    ld [de],a
    ld a,[W_CURENEMYLVL]
    ld b,a
.LastLoop\@
    ld hl,$D047
    ld c,2
    push bc
    ld a,$B
    call $3E6D
    pop bc
    inc de
    inc de
    dec b
    jr nz,.LastLoop\@
    ret

LoneAttacks: ; 5D22
; these are used for gym leaders.
; this is not automatic! you have to write the number you want to W_LONEATTACKNO
; first. e.g., erika's script writes 4 to W_LONEATTACKNO to get mega drain,
; the fourth entry in the list.

; first byte:  pokemon in the trainer's party that gets the move
; second byte: move
; unterminated
    db 1,BIDE
    db 1,BUBBLEBEAM
    db 2,THUNDERBOLT
    db 2,MEGA_DRAIN
    db 3,TOXIC
    db 3,PSYWAVE
    db 3,FIRE_BLAST
    db 4,FISSURE

TeamAttacks: ; 5D32
; these are used for elite four.
; this is automatic, based on trainer class.
; don't be confused by LoneAttacks above, the two data structures are
    ; _completely_ unrelated.

; first byte: trainer (all trainers in this class have this move)
; second byte: move
; ff-terminated
    db LORELEI,BLIZZARD
    db BRUNO,FISSURE
    db AGATHA,TOXIC
    db LANCE,BARRIER
    db $FF

TrainerDataPointers: ; 5D3B
    dw YoungsterData,BugCatcherData,LassData,SailorData,JrTrainerMData
    dw JrTrainerFData,PokemaniacData,SuperNerdData,HikerData,BikerData
    dw BurglarData,EngineerData,Juggler1Data,FisherData,SwimmerData
    dw CueBallData,GamblerData,BeautyData,PsychicData,RockerData
    dw JugglerData,TamerData,BirdKeeperData,BlackbeltData,Green1Data
    dw ProfOakData,ChiefData,ScientistData,GiovanniData,RocketData
    dw CooltrainerMData,CooltrainerFData,BrunoData,BrockData,MistyData
    dw LtSurgeData,ErikaData,KogaData,BlaineData,SabrinaData
    dw GentlemanData,Green2Data,Green3Data,LoreleiData,ChannelerData
    dw AgathaData,LanceData

; if first byte != FF, then
    ; first byte is level (of all pokemon on this team)
    ; all the next bytes are pokemon species
    ; null-terminated
; if first byte == FF, then
    ; first byte is FF (obviously)
    ; every next two bytes are a level and species
    ; null-terminated

YoungsterData:
    db 11,RATTATA,EKANS,0
    db 14,SPEAROW,0
    db 10,RATTATA,RATTATA,ZUBAT,0
    db 14,RATTATA,EKANS,ZUBAT,0
    db 15,RATTATA,SPEAROW,0
    db 17,SLOWPOKE,0
    db 14,EKANS,SANDSHREW,0
    db 21,NIDORAN_M,0
    db 21,EKANS,0
    db 19,SANDSHREW,ZUBAT,0
    db 17,RATTATA,RATTATA,RATICATE,0
    db 18,NIDORAN_M,NIDORINO,0
    db 17,SPEAROW,RATTATA,RATTATA,SPEAROW,0
BugCatcherData:
    db 6,WEEDLE,CATERPIE,0
    db 7,WEEDLE,KAKUNA,WEEDLE,0
    db 9,WEEDLE,0
    db 10,CATERPIE,WEEDLE,CATERPIE,0
    db 9,WEEDLE,KAKUNA,CATERPIE,METAPOD,0
    db 11,CATERPIE,METAPOD,0
    db 11,WEEDLE,KAKUNA,0
    db 10,CATERPIE,METAPOD,CATERPIE,0
    db 14,CATERPIE,WEEDLE,0
    db 16,WEEDLE,CATERPIE,WEEDLE,0
    db 20,BUTTERFREE,0
    db 18,METAPOD,CATERPIE,VENONAT,0
    db 19,BEEDRILL,BEEDRILL,0
    db 20,CATERPIE,WEEDLE,VENONAT,0
LassData:
    db 9,PIDGEY,PIDGEY,0
    db 10,RATTATA,NIDORAN_M,0
    db 14,JIGGLYPUFF,0
    db 31,PARAS,PARAS,PARASECT,0
    db 11,ODDISH,BELLSPROUT,0
    db 14,CLEFAIRY,0
    db 16,PIDGEY,NIDORAN_F,0
    db 14,PIDGEY,NIDORAN_F,0
    db 15,NIDORAN_M,NIDORAN_F,0
    db 13,ODDISH,PIDGEY,ODDISH,0
    db 18,PIDGEY,NIDORAN_F,0
    db 18,RATTATA,PIKACHU,0
    db 23,NIDORAN_F,NIDORINA,0
    db 24,MEOWTH,MEOWTH,MEOWTH,0
    db 19,PIDGEY,RATTATA,NIDORAN_M,MEOWTH,PIKACHU,0
    db 22,CLEFAIRY,CLEFAIRY,0
    db 23,BELLSPROUT,WEEPINBELL,0
    db 23,ODDISH,GLOOM,0
SailorData:
    db 18,MACHOP,SHELLDER,0
    db 17,MACHOP,TENTACOOL,0
    db 21,SHELLDER,0
    db 17,HORSEA,SHELLDER,TENTACOOL,0
    db 18,TENTACOOL,STARYU,0
    db 17,HORSEA,HORSEA,HORSEA,0
    db 20,MACHOP,0
    db 21,PIKACHU,PIKACHU,0
JrTrainerMData:
    db 11,DIGLETT,SANDSHREW,0
    db 14,RATTATA,EKANS,0
    db 18,MANKEY,0
    db 20,SQUIRTLE,0
    db 16,SPEAROW,RATICATE,0
    db 18,DIGLETT,DIGLETT,SANDSHREW,0
    db 21,GROWLITHE,CHARMANDER,0
    db 19,RATTATA,DIGLETT,EKANS,SANDSHREW,0
    db 29,NIDORAN_M,NIDORINO,0
JrTrainerFData:
    db 19,GOLDEEN,0
    db 16,RATTATA,PIKACHU,0
    db 16,PIDGEY,PIDGEY,PIDGEY,0
    db 22,BULBASAUR,0
    db 18,ODDISH,BELLSPROUT,ODDISH,BELLSPROUT,0
    db 23,MEOWTH,0
    db 20,PIKACHU,CLEFAIRY,0
    db 21,PIDGEY,PIDGEOTTO,0
    db 21,JIGGLYPUFF,PIDGEY,MEOWTH,0
    db 22,ODDISH,BULBASAUR,0
    db 24,BULBASAUR,IVYSAUR,0
    db 24,PIDGEY,MEOWTH,RATTATA,PIKACHU,MEOWTH,0
    db 30,POLIWAG,POLIWAG,0
    db 27,PIDGEY,MEOWTH,PIDGEY,PIDGEOTTO,0
    db 28,GOLDEEN,POLIWAG,HORSEA,0
    db 31,GOLDEEN,SEAKING,0
    db 22,BELLSPROUT,CLEFAIRY,0
    db 20,MEOWTH,ODDISH,PIDGEY,0
    db 19,PIDGEY,RATTATA,RATTATA,BELLSPROUT,0
    db 28,GLOOM,ODDISH,ODDISH,0
    db 29,PIKACHU,RAICHU,0
    db 33,CLEFAIRY,0
    db 29,BELLSPROUT,ODDISH,TANGELA,0
    db 30,TENTACOOL,HORSEA,SEEL,0
PokemaniacData:
    db 30,RHYHORN,LICKITUNG,0
    db 20,CUBONE,SLOWPOKE,0
    db 20,SLOWPOKE,SLOWPOKE,SLOWPOKE,0
    db 22,CHARMANDER,CUBONE,0
    db 25,SLOWPOKE,0
    db 40,CHARMELEON,LAPRAS,LICKITUNG,0
    db 23,CUBONE,SLOWPOKE,0
SuperNerdData:
    db 11,MAGNEMITE,VOLTORB,0
    db 12,GRIMER,VOLTORB,KOFFING,0
    db 20,VOLTORB,KOFFING,VOLTORB,MAGNEMITE,0
    db 22,GRIMER,MUK,GRIMER,0
    db 26,KOFFING,0
    db 22,KOFFING,MAGNEMITE,WEEZING,0
    db 20,MAGNEMITE,MAGNEMITE,KOFFING,MAGNEMITE,0
    db 24,MAGNEMITE,VOLTORB,0
    db 36,VULPIX,VULPIX,NINETALES,0
    db 34,PONYTA,CHARMANDER,VULPIX,GROWLITHE,0
    db 41,RAPIDASH,0
    db 37,GROWLITHE,VULPIX,0
HikerData:
    db 10,GEODUDE,GEODUDE,ONIX,0
    db 15,MACHOP,GEODUDE,0
    db 13,GEODUDE,GEODUDE,MACHOP,GEODUDE,0
    db 17,ONIX,0
    db 21,GEODUDE,ONIX,0
    db 20,GEODUDE,MACHOP,GEODUDE,0
    db 21,GEODUDE,ONIX,0
    db 19,ONIX,GRAVELER,0
    db 21,GEODUDE,GEODUDE,GRAVELER,0
    db 25,GEODUDE,0
    db 20,MACHOP,ONIX,0
    db 19,GEODUDE,MACHOP,GEODUDE,GEODUDE,0
    db 20,ONIX,ONIX,GEODUDE,0
    db 21,GEODUDE,GRAVELER,0
BikerData:
    db 28,KOFFING,KOFFING,KOFFING,0
    db 29,KOFFING,GRIMER,0
    db 25,KOFFING,KOFFING,WEEZING,KOFFING,GRIMER,0
    db 28,KOFFING,GRIMER,WEEZING,0
    db 29,GRIMER,KOFFING,0
    db 33,WEEZING,0
    db 26,GRIMER,GRIMER,GRIMER,GRIMER,0
    db 28,WEEZING,KOFFING,WEEZING,0
    db 33,MUK,0
    db 29,VOLTORB,VOLTORB,0
    db 29,WEEZING,MUK,0
    db 25,KOFFING,WEEZING,KOFFING,KOFFING,WEEZING,0
    db 26,KOFFING,KOFFING,GRIMER,KOFFING,0
    db 28,GRIMER,GRIMER,KOFFING,0
    db 29,KOFFING,MUK,0
BurglarData:
    db 29,GROWLITHE,VULPIX,0
    db 33,GROWLITHE,0
    db 28,VULPIX,CHARMANDER,PONYTA,0
    db 36,GROWLITHE,VULPIX,NINETALES,0
    db 41,PONYTA,0
    db 37,VULPIX,GROWLITHE,0
    db 34,CHARMANDER,CHARMELEON,0
    db 38,NINETALES,0
    db 34,GROWLITHE,PONYTA,0
EngineerData:
    db 21,VOLTORB,MAGNEMITE,0
    db 21,MAGNEMITE,0
    db 18,MAGNEMITE,MAGNEMITE,MAGNETON,0
Juggler1Data:
; none
FisherData:
    db 17,GOLDEEN,TENTACOOL,GOLDEEN,0
    db 17,TENTACOOL,STARYU,SHELLDER,0
    db 22,GOLDEEN,POLIWAG,GOLDEEN,0
    db 24,TENTACOOL,GOLDEEN,0
    db 27,GOLDEEN,0
    db 21,POLIWAG,SHELLDER,GOLDEEN,HORSEA,0
    db 28,SEAKING,GOLDEEN,SEAKING,SEAKING,0
    db 31,SHELLDER,CLOYSTER,0
    db 27,MAGIKARP,MAGIKARP,MAGIKARP,MAGIKARP,MAGIKARP,MAGIKARP,0
    db 33,SEAKING,GOLDEEN,0
    db 24,MAGIKARP,MAGIKARP,0
SwimmerData:
    db 16,HORSEA,SHELLDER,0
    db 30,TENTACOOL,SHELLDER,0
    db 29,GOLDEEN,HORSEA,STARYU,0
    db 30,POLIWAG,POLIWHIRL,0
    db 27,HORSEA,TENTACOOL,TENTACOOL,GOLDEEN,0
    db 29,GOLDEEN,SHELLDER,SEAKING,0
    db 30,HORSEA,HORSEA,0
    db 27,TENTACOOL,TENTACOOL,STARYU,HORSEA,TENTACRUEL,0
    db 31,SHELLDER,CLOYSTER,0
    db 35,STARYU,0
    db 28,HORSEA,HORSEA,SEADRA,HORSEA,0
    db 33,SEADRA,TENTACRUEL,0
    db 37,STARMIE,0
    db 33,STARYU,WARTORTLE,0
    db 32,POLIWHIRL,TENTACOOL,SEADRA,0
CueBallData:
    db 28,MACHOP,MANKEY,MACHOP,0
    db 29,MANKEY,MACHOP,0
    db 33,MACHOP,0
    db 29,MANKEY,PRIMEAPE,0
    db 29,MACHOP,MACHOKE,0
    db 33,MACHOKE,0
    db 26,MANKEY,MANKEY,MACHOKE,MACHOP,0
    db 29,PRIMEAPE,MACHOKE,0
    db 31,TENTACOOL,TENTACOOL,TENTACRUEL,0
GamblerData:
    db 18,POLIWAG,HORSEA,0
    db 18,BELLSPROUT,ODDISH,0
    db 18,VOLTORB,MAGNEMITE,0
    db 18,GROWLITHE,VULPIX,0
    db 22,POLIWAG,POLIWAG,POLIWHIRL,0
    db 22,ONIX,GEODUDE,GRAVELER,0
    db 24,GROWLITHE,VULPIX,0
BeautyData:
    db 21,ODDISH,BELLSPROUT,ODDISH,BELLSPROUT,0
    db 24,BELLSPROUT,BELLSPROUT,0
    db 26,EXEGGCUTE,0
    db 27,RATTATA,PIKACHU,RATTATA,0
    db 29,CLEFAIRY,MEOWTH,0
    db 35,SEAKING,0
    db 30,SHELLDER,SHELLDER,CLOYSTER,0
    db 31,POLIWAG,SEAKING,0
    db 29,PIDGEOTTO,WIGGLYTUFF,0
    db 29,BULBASAUR,IVYSAUR,0
    db 33,WEEPINBELL,BELLSPROUT,WEEPINBELL,0
    db 27,POLIWAG,GOLDEEN,SEAKING,GOLDEEN,POLIWAG,0
    db 30,GOLDEEN,SEAKING,0
    db 29,STARYU,STARYU,STARYU,0
    db 30,SEADRA,HORSEA,SEADRA,0
PsychicData:
    db 31,KADABRA,SLOWPOKE,MR__MIME,KADABRA,0
    db 34,MR__MIME,KADABRA,0
    db 33,SLOWPOKE,SLOWPOKE,SLOWBRO,0
    db 38,SLOWBRO,0
RockerData:
    db 20,VOLTORB,MAGNEMITE,VOLTORB,0
    db 29,VOLTORB,ELECTRODE,0
JugglerData:
    db 29,KADABRA,MR__MIME,0
    db 41,DROWZEE,HYPNO,KADABRA,KADABRA,0
    db 31,DROWZEE,DROWZEE,KADABRA,DROWZEE,0
    db 34,DROWZEE,HYPNO,0
    db 48,MR__MIME,0
    db 33,HYPNO,0
    db 38,HYPNO,0
    db 34,DROWZEE,KADABRA,0
TamerData:
    db 34,SANDSLASH,ARBOK,0
    db 33,ARBOK,SANDSLASH,ARBOK,0
    db 43,RHYHORN,0
    db 39,ARBOK,TAUROS,0
    db 44,PERSIAN,GOLDUCK,0
    db 42,RHYHORN,PRIMEAPE,ARBOK,TAUROS,0
BirdKeeperData:
    db 29,PIDGEY,PIDGEOTTO,0
    db 25,SPEAROW,PIDGEY,PIDGEY,SPEAROW,SPEAROW,0
    db 26,PIDGEY,PIDGEOTTO,SPEAROW,FEAROW,0
    db 33,FARFETCH_D,0
    db 29,SPEAROW,FEAROW,0
    db 26,PIDGEOTTO,FARFETCH_D,DODUO,PIDGEY,0
    db 28,DODRIO,DODUO,DODUO,0
    db 29,SPEAROW,FEAROW,0
    db 34,DODRIO,0
    db 26,SPEAROW,SPEAROW,FEAROW,SPEAROW,0
    db 30,FEAROW,FEAROW,PIDGEOTTO,0
    db 39,PIDGEOTTO,PIDGEOTTO,PIDGEY,PIDGEOTTO,0
    db 42,FARFETCH_D,FEAROW,0
    db 28,PIDGEY,DODUO,PIDGEOTTO,0
    db 26,PIDGEY,SPEAROW,PIDGEY,FEAROW,0
    db 29,PIDGEOTTO,FEAROW,0
    db 28,SPEAROW,DODUO,FEAROW,0
BlackbeltData:
    db 37,HITMONLEE,HITMONCHAN,0
    db 31,MANKEY,MANKEY,PRIMEAPE,0
    db 32,MACHOP,MACHOKE,0
    db 36,PRIMEAPE,0
    db 31,MACHOP,MANKEY,PRIMEAPE,0
    db 40,MACHOP,MACHOKE,0
    db 43,MACHOKE,0
    db 38,MACHOKE,MACHOP,MACHOKE,0
    db 43,MACHOKE,MACHOP,MACHOKE,0
Green1Data:
    db 5,SQUIRTLE,0
    db 5,BULBASAUR,0
    db 5,CHARMANDER,0
    db $FF,9,PIDGEY,8,SQUIRTLE,0
    db $FF,9,PIDGEY,8,BULBASAUR,0
    db $FF,9,PIDGEY,8,CHARMANDER,0
    db $FF,18,PIDGEOTTO,15,ABRA,15,RATTATA,17,SQUIRTLE,0
    db $FF,18,PIDGEOTTO,15,ABRA,15,RATTATA,17,BULBASAUR,0
    db $FF,18,PIDGEOTTO,15,ABRA,15,RATTATA,17,CHARMANDER,0
ProfOakData:
    db $FF,66,TAUROS,67,EXEGGUTOR,68,ARCANINE,69,BLASTOISE,70,GYARADOS,0
    db $FF,66,TAUROS,67,EXEGGUTOR,68,ARCANINE,69,VENUSAUR,70,GYARADOS,0
    db $FF,66,TAUROS,67,EXEGGUTOR,68,ARCANINE,69,CHARIZARD,70,GYARADOS,0
ChiefData:
; none
ScientistData:
    db 34,KOFFING,VOLTORB,0
    db 26,GRIMER,WEEZING,KOFFING,WEEZING,0
    db 28,MAGNEMITE,VOLTORB,MAGNETON,0
    db 29,ELECTRODE,WEEZING,0
    db 33,ELECTRODE,0
    db 26,MAGNETON,KOFFING,WEEZING,MAGNEMITE,0
    db 25,VOLTORB,KOFFING,MAGNETON,MAGNEMITE,KOFFING,0
    db 29,ELECTRODE,MUK,0
    db 29,GRIMER,ELECTRODE,0
    db 28,VOLTORB,KOFFING,MAGNETON,0
    db 29,MAGNEMITE,KOFFING,0
    db 33,MAGNEMITE,MAGNETON,VOLTORB,0
    db 34,MAGNEMITE,ELECTRODE,0
GiovanniData:
    db $FF,25,ONIX,24,RHYHORN,29,KANGASKHAN,0
    db $FF,37,NIDORINO,35,KANGASKHAN,37,RHYHORN,41,NIDOQUEEN,0
    db $FF,45,RHYHORN,42,DUGTRIO,44,NIDOQUEEN,45,NIDOKING,50,RHYDON,0
RocketData:
    db 13,RATTATA,ZUBAT,0
    db 11,SANDSHREW,RATTATA,ZUBAT,0
    db 12,ZUBAT,EKANS,0
    db 16,RATICATE,0
    db 17,MACHOP,DROWZEE,0
    db 15,EKANS,ZUBAT,0
    db 20,RATICATE,ZUBAT,0
    db 21,DROWZEE,MACHOP,0
    db 21,RATICATE,RATICATE,0
    db 20,GRIMER,KOFFING,KOFFING,0
    db 19,RATTATA,RATICATE,RATICATE,RATTATA,0
    db 22,GRIMER,KOFFING,0
    db 17,ZUBAT,KOFFING,GRIMER,ZUBAT,RATICATE,0
    db 20,RATTATA,RATICATE,DROWZEE,0
    db 21,MACHOP,MACHOP,0
    db 23,SANDSHREW,EKANS,SANDSLASH,0
    db 23,EKANS,SANDSHREW,ARBOK,0
    db 21,KOFFING,ZUBAT,0
    db 25,ZUBAT,ZUBAT,GOLBAT,0
    db 26,KOFFING,DROWZEE,0
    db 23,ZUBAT,RATTATA,RATICATE,ZUBAT,0
    db 26,DROWZEE,KOFFING,0
    db 29,CUBONE,ZUBAT,0
    db 25,GOLBAT,ZUBAT,ZUBAT,RATICATE,ZUBAT,0
    db 28,RATICATE,HYPNO,RATICATE,0
    db 29,MACHOP,DROWZEE,0
    db 28,EKANS,ZUBAT,CUBONE,0
    db 33,ARBOK,0
    db 33,HYPNO,0
    db 29,MACHOP,MACHOKE,0
    db 28,ZUBAT,ZUBAT,GOLBAT,0
    db 26,RATICATE,ARBOK,KOFFING,GOLBAT,0
    db 29,CUBONE,CUBONE,0
    db 29,SANDSHREW,SANDSLASH,0
    db 26,RATICATE,ZUBAT,GOLBAT,RATTATA,0
    db 28,WEEZING,GOLBAT,KOFFING,0
    db 28,DROWZEE,GRIMER,MACHOP,0
    db 28,GOLBAT,DROWZEE,HYPNO,0
    db 33,MACHOKE,0
    db 25,RATTATA,RATTATA,ZUBAT,RATTATA,EKANS,0
    db 32,CUBONE,DROWZEE,MAROWAK,0
CooltrainerMData:
    db 39,NIDORINO,NIDOKING,0
    db 43,EXEGGUTOR,CLOYSTER,ARCANINE,0
    db 43,KINGLER,TENTACRUEL,BLASTOISE,0
    db 45,KINGLER,STARMIE,0
    db 42,IVYSAUR,WARTORTLE,CHARMELEON,CHARIZARD,0
    db 44,IVYSAUR,WARTORTLE,CHARMELEON,0
    db 49,NIDOKING,0
    db 44,KINGLER,CLOYSTER,0
    db 39,SANDSLASH,DUGTRIO,0
    db 43,RHYHORN,0
CooltrainerFData:
    db 24,WEEPINBELL,GLOOM,IVYSAUR,0
    db 43,BELLSPROUT,WEEPINBELL,VICTREEBEL,0
    db 43,PARASECT,DEWGONG,CHANSEY,0
    db 46,VILEPLUME,BUTTERFREE,0
    db 44,PERSIAN,NINETALES,0
    db 45,IVYSAUR,VENUSAUR,0
    db 45,NIDORINA,NIDOQUEEN,0
    db 43,PERSIAN,NINETALES,RAICHU,0
BrunoData:
    db $FF,53,ONIX,55,HITMONCHAN,55,HITMONLEE,56,ONIX,58,MACHAMP,0
BrockData:
    db $FF,12,GEODUDE,14,ONIX,0
MistyData:
    db $FF,18,STARYU,21,STARMIE,0
LtSurgeData:
    db $FF,21,VOLTORB,18,PIKACHU,24,RAICHU,0
ErikaData:
    db $FF,29,VICTREEBEL,24,TANGELA,29,VILEPLUME,0
KogaData:
    db $FF,37,KOFFING,39,MUK,37,KOFFING,43,WEEZING,0
BlaineData:
    db $FF,42,GROWLITHE,40,PONYTA,42,RAPIDASH,47,ARCANINE,0
SabrinaData:
    db $FF,38,KADABRA,37,MR__MIME,38,VENOMOTH,43,ALAKAZAM,0
GentlemanData:
    db 18,GROWLITHE,GROWLITHE,0
    db 19,NIDORAN_M,NIDORAN_F,0
    db 23,PIKACHU,0
    db 48,PRIMEAPE,0
    db 17,GROWLITHE,PONYTA,0
Green2Data:
    db $FF,19,PIDGEOTTO,16,RATICATE,18,KADABRA,20,WARTORTLE,0
    db $FF,19,PIDGEOTTO,16,RATICATE,18,KADABRA,20,IVYSAUR,0
    db $FF,19,PIDGEOTTO,16,RATICATE,18,KADABRA,20,CHARMELEON,0
    db $FF,25,PIDGEOTTO,23,GROWLITHE,22,EXEGGCUTE,20,KADABRA,25,WARTORTLE,0
    db $FF,25,PIDGEOTTO,23,GYARADOS,22,GROWLITHE,20,KADABRA,25,IVYSAUR,0
    db $FF,25,PIDGEOTTO,23,EXEGGCUTE,22,GYARADOS,20,KADABRA,25,CHARMELEON,0
    db $FF,37,PIDGEOT,38,GROWLITHE,35,EXEGGCUTE,35,ALAKAZAM,40,BLASTOISE,0
    db $FF,37,PIDGEOT,38,GYARADOS,35,GROWLITHE,35,ALAKAZAM,40,VENUSAUR,0
    db $FF,37,PIDGEOT,38,EXEGGCUTE,35,GYARADOS,35,ALAKAZAM,40,CHARIZARD,0
    db $FF,47,PIDGEOT,45,RHYHORN,45,GROWLITHE,47,EXEGGCUTE,50,ALAKAZAM ;\
        db 53,BLASTOISE,0
    db $FF,47,PIDGEOT,45,RHYHORN,45,GYARADOS,47,GROWLITHE,50,ALAKAZAM ;\
        db 53,VENUSAUR,0
    db $FF,47,PIDGEOT,45,RHYHORN,45,EXEGGCUTE,47,GYARADOS,50,ALAKAZAM ;\
        db 53,CHARIZARD,0
Green3Data:
    db $FF,61,PIDGEOT,59,ALAKAZAM,61,RHYDON,61,ARCANINE,63,EXEGGUTOR ;\
        db 65,BLASTOISE,0
    db $FF,61,PIDGEOT,59,ALAKAZAM,61,RHYDON,61,GYARADOS,63,ARCANINE ;\
        db 65,VENUSAUR,0
    db $FF,61,PIDGEOT,59,ALAKAZAM,61,RHYDON,61,EXEGGUTOR,63,GYARADOS ;\
        db 65,CHARIZARD,0
LoreleiData:
    db $FF,54,DEWGONG,53,CLOYSTER,54,SLOWBRO,56,JYNX,56,LAPRAS,0
ChannelerData:
    db 22,GASTLY,0
    db 24,GASTLY,0
    db 23,GASTLY,GASTLY,0
    db 24,GASTLY,0
    db 23,GASTLY,0
    db 24,GASTLY,0
    db 24,HAUNTER,0
    db 22,GASTLY,0
    db 24,GASTLY,0
    db 23,GASTLY,GASTLY,0
    db 24,GASTLY,0
    db 22,GASTLY,0
    db 24,GASTLY,0
    db 23,HAUNTER,0
    db 24,GASTLY,0
    db 22,GASTLY,0
    db 24,GASTLY,0
    db 22,HAUNTER,0
    db 22,GASTLY,GASTLY,GASTLY,0
    db 24,GASTLY,0
    db 24,GASTLY,0
    db 34,GASTLY,HAUNTER,0
    db 38,HAUNTER,0
    db 33,GASTLY,GASTLY,HAUNTER,0
AgathaData:
    db $FF,56,GENGAR,56,GOLBAT,55,HAUNTER,58,ARBOK,60,GENGAR,0
LanceData:
    db $FF,58,GYARADOS,56,DRAGONAIR,56,DRAGONAIR,60,AERODACTYL ;\
        db 62,DRAGONITE,0

TrainerAI: ; 652E
;XXX called at 34964, 3c342, 3c398
    and a
    ld a,[W_ISTRAINERBATTLE]
    dec a
    ret z ; if not a trainer, we're done here
    ld a,[W_ISLINKBATTLE]
    cp 4
    ret z
    ld a,[W_TRAINERCLASS] ; what trainer class is this?
    dec a
    ld c,a
    ld b,0
    ld hl,TrainerAIPointers
    add hl,bc
    add hl,bc
    add hl,bc
    ld a,[$CCDF] ; XXX 340b0,3a548,3a553,3a696,3c943,3ef74
    and a
    ret z ; if XXX, we're done here
    inc hl
    inc a
    jr nz,.getpointer\@
    dec hl
    ld a,[hli]
    ld [$CCDF],a
.getpointer\@
    ld a,[hli]
    ld h,[hl]
    ld l,a
    call $3E5C
    jp [hl]

TrainerAIPointers: ; 655C
; one entry per trainer class
; XXX first byte, ???
; next two bytes, pointer to AI subroutine for trainer class
    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 3 ; juggler_x
    dw JugglerAI

    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 3 ; juggler
    dw JugglerAI

    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 2 ; blackbelt
    dw BlackbeltAI

    db 3
    dw GenericAI

    db 3
    dw GenericAI

    db 1 ; chief
    dw GenericAI

    db 3
    dw GenericAI

    db 1 ; giovanni
    dw GiovanniAI

    db 3
    dw GenericAI

    db 2 ; cooltrainerm
    dw CooltrainerMAI

    db 1 ; cooltrainerf
    dw CooltrainerFAI

    db 2 ; bruno
    dw BrunoAI

    db 5 ; brock
    dw BrockAI

    db 1 ; misty
    dw MistyAI

    db 1 ; surge
    dw LtSurgeAI

    db 1 ; erika
    dw ErikaAI

    db 2 ; koga
    dw KogaAI

    db 2 ; blaine
    dw BlaineAI

    db 1 ; sabrina
    dw SabrinaAI

    db 3
    dw GenericAI

    db 1 ; sony2
    dw Sony2AI

    db 1 ; sony3
    dw Sony3AI

    db 2 ; lorelei
    dw LoreleiAI

    db 3
    dw GenericAI

    db 2 ; agatha
    dw AgathaAI

    db 1 ; lance
    dw LanceAI

JugglerAI:
    cp $40
    ret nc
    jp $672A

BlackbeltAI:
    cp $20
    ret nc
    jp AIUseXAttack

GiovanniAI:
    cp $40
    ret nc
    jp AIUseGuardSpec

CooltrainerMAI:
    cp $40
    ret nc
    jp AIUseXAttack

CooltrainerFAI:
    cp $40
    ld a,$A
    call $67CF
    jp c,AIUseHyperPotion
    ld a,5
    call $67CF
    ret nc
    jp $672A

BrockAI:
; if his active monster has a status condition, use a full heal
    ld a,[W_OPPONENTSTATUS]
    and a
    ret z
    jp AIUseFullHeal

MistyAI:
    cp $40
    ret nc
    jp AIUseXDefend

LtSurgeAI:
    cp $40
    ret nc
    jp AIUseXSpeed

ErikaAI:
    cp $80
    ret nc
    ld a,$A
    call $67CF
    ret nc
    jp AIUseSuperPotion

KogaAI:
    cp $40
    ret nc
    jp AIUseXAttack

BlaineAI:
    cp $40
    ret nc
    jp AIUseSuperPotion

SabrinaAI:
    cp $40
    ret nc
    ld a,$A
    call $67CF
    ret nc
    jp AIUseHyperPotion

Sony2AI:
    cp $20
    ret nc
    ld a,5
    call $67CF
    ret nc
    jp AIUsePotion

Sony3AI:
    cp $20
    ret nc
    ld a,5
    call $67CF
    ret nc
    jp AIUseFullRestore

LoreleiAI:
    cp $80
    ret nc
    ld a,5
    call $67CF
    ret nc
    jp AIUseSuperPotion

BrunoAI:
    cp $40
    ret nc
    jp AIUseXDefend

AgathaAI:
    cp $14
    jp c,$672A
    cp $80
    ret nc
    ld a,4
    call $67CF
    ret nc
    jp AIUseSuperPotion

LanceAI:
    cp $80
    ret nc
    ld a,5
    call $67CF
    ret nc
    jp AIUseHyperPotion

GenericAI:
    and a
    ret

; end of individual trainer AI routines

Function6695: ; 6695
; XXX what does this do
    ld hl,$CCDF
    dec [hl]
    scf
    ret

Function669B: ; 669B
; XXX what does this do
    ld a,$8E
    jp $3740

AIUseFullRestore:
    call AICureStatus
    ld a,FULL_RESTORE
    ld [$CF05],a
    ld de,$CEEB
    ld hl,$CFE7
    ld a,[hld]
    ld [de],a
    inc de
    ld a,[hl]
    ld [de],a
    inc de
    ld hl,$CFF5
    ld a,[hld]
    ld [de],a
    inc de
    ld [$CEE9],a
    ld [$CFE7],a
    ld a,[hl]
    ld [de],a
    ld [$CEEA],a
    ld [W_OPPONENTHP],a
    jr Function6718

AIUsePotion:
; enemy trainer heals his monster with a potion
    ld a,POTION
    ld b,20
    jr AIRecoverHP

AIUseSuperPotion:
; enemy trainer heals his monster with a super potion
    ld a,SUPER_POTION
    ld b,50
    jr AIRecoverHP

AIUseHyperPotion:
; enemy trainer heals his monster with a hyper potion
    ld a,HYPER_POTION
    ld b,200
    ; fallthrough

AIRecoverHP: ; 66DA
; heal b HP and print "trainer used $(a) on pokemon!"
    ld [$CF05],a
    ld hl,$CFE7
    ld a,[hl]
    ld [$CEEB],a
    add b
    ld [hld],a
    ld [$CEED],a
    ld a,[hl]
    ld [$CEEC],a
    ld [$CEEE],a
    jr nc,.next\@
    inc a
    ld [hl],a
    ld [$CEEE],a
.next\@
    inc hl
    ld a,[hld]
    ld b,a
    ld de,$CFF5
    ld a,[de]
    dec de
    ld [$CEE9],a
    sub b
    ld a,[hli]
    ld b,a
    ld a,[de]
    ld [$CEEA],a
    sbc b
    jr nc,Function6718
    inc de
    ld a,[de]
    dec de
    ld [hld],a
    ld [$CEED],a
    ld a,[de]
    ld [hl],a
    ld [$CEEE],a
    ; fallthrough

Function6718: ; 6718
    call AIPrintItemUse_
    ld hl,$C3CA
    xor a
    ld [$CF94],a
    ld a,$48
    call $3E6D
    jp $6695

Function672A: ; 672A
    ld a,[W_ENEMYMONCOUNT]
    ld c,a
    ld hl,W_ENEMYMON1HP

    ld d,0 ; keep count of unfainted monsters

    ; count how many monsters haven't fainted yet
.loop\@
    ld a,[hli]
    ld b,a
    ld a,[hld]
    or b
    jr z,.Fainted\@ ; has monster fainted?
    inc d
.Fainted\@
    push bc
    ld bc,$2C
    add hl,bc
    pop bc
    dec c
    jr nz,.loop\@

    ld a,d ; how many available monsters are there?
    cp 2 ; don't bother if only 1 or 2
    jp nc,Function674B ; XXX check, does this jump when a = 2?
    and a
    ret

Function674B: ; 674B

; prepare to withdraw the active monster: copy hp, number, and status to roster

    ld a,[W_OPPONENTNUMBER]
    ld hl,W_ENEMYMON1HP
    ld bc,$2C
    call AddNTimes
    ld d,h
    ld e,l
    ld hl,W_OPPONENTHP
    ld bc,4
    call CopyData

    ld hl,AIBattleWithdrawText
    call PrintText

    ld a,1
    ld [$D11D],a
    ld hl,EnemySendOut
    ld b,BANK(EnemySendOut)
    call Bankswitch
    xor a
    ld [$D11D],a

    ld a,[W_ISLINKBATTLE]
    cp 4
    ret z
    scf
    ret

AIBattleWithdrawText:
    TX_FAR _AIBattleWithdrawText
    TX_NULL

AIUseFullHeal:
    call $669B
    call AICureStatus
    ld a,FULL_HEAL
    jp AIPrintItemUse

AICureStatus:
; cures the status of enemy's active pokemon
    ld a,[W_OPPONENTNUMBER]
    ld hl,$D8A8
    ld bc,$2C
    call AddNTimes
    xor a
    ld [hl],a ; clear status in enemy team roster
    ld [W_OPPONENTSTATUS],a ; clear status of active enemy
    ld hl,$D069
    res 0,[hl]
    ret

AIUseXAccuracy: ; unused
    call $669B
    ld hl,$D068
    set 0,[hl]
    ld a,X_ACCURACY
    jp AIPrintItemUse

AIUseGuardSpec:
    call $669B
    ld hl,$D068
    set 1,[hl]
    ld a,GUARD_SPEC_
    jp AIPrintItemUse

AIUseDireHit: ; unused
    call $669B
    ld hl,$D068
    set 2,[hl]
    ld a,DIRE_HIT
    jp AIPrintItemUse

Function67CF: ; 67CF
    ld [$FF99],a
    ld hl,$CFF4
    ld a,[hli]
    ld [$FF95],a
    ld a,[hl]
    ld [$FF96],a
    ld b,2
    call $38B9
    ld a,[$FF98]
    ld c,a
    ld a,[$FF97]
    ld b,a
    ld hl,$CFE7
    ld a,[hld]
    ld e,a
    ld a,[hl]
    ld d,a
    ld a,d
    sub b
    ret nz
    ld a,e
    sub c
    ret

AIUseXAttack:
    ld b,$A
    ld a,X_ATTACK
    jr AIIncreaseStat

AIUseXDefend:
    ld b,$B
    ld a,X_DEFEND
    jr AIIncreaseStat

AIUseXSpeed:
    ld b,$C
    ld a,X_SPEED
    jr AIIncreaseStat

AIUseXSpecial:
    ld b,$D
    ld a,X_SPECIAL
    ; fallthrough

AIIncreaseStat:
    ld [$CF05],a
    push bc
    call AIPrintItemUse_
    pop bc
    ld hl,$CFCD
    ld a,[hld]
    push af
    ld a,[hl]
    push af
    push hl
    ld a,$AF
    ld [hli],a
    ld [hl],b
    ld hl,$7428
    ld b,$F
    call Bankswitch
    pop hl
    pop af
    ld [hli],a
    pop af
    ld [hl],a
    jp $6695

AIPrintItemUse:
    ld [$CF05],a
    call AIPrintItemUse_
    jp $6695

AIPrintItemUse_:
; print "x used [$CF05] on z!"
    ld a,[$CF05]
    ld [$D11E],a
    call GetItemName
    ld hl,AIBattleUseItemText
    jp PrintText

AIBattleUseItemText:
    TX_FAR _AIBattleUseItemText
    TX_NULL

#3 2010-11-19 20:00:45

Miksy91
Member
Registered: 2010-10-16
Post 182/2,339

Re: Pokémon Yellow Trainer Data

I re-wrote the thread completely and figured out how it really works so check it out ;)

Offline

Board footer

Powered by FluxBB