Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2019-02-23 17:27:50

Anonymous
New member
Registered: 2019-02-23
Post 1/3

Pokemon Red/Blue (Modifying Trainer AIs)

I am currently working on a difficulty hack of Pokemon Red. I am able to successfully increase pokemon parties and increase trainer pokemon DV's but I don't know how to modify the trainer AI by making them use a Potion, Super Potion, Hyper Potion, Full Restore etc. I am working with the disassembly and I read the file called trainer_ai.asm but it has not really helped as much. Can somebody please tell me what from what offset to what offset are all the AI changes done. Here is the trainer_ai.asm file

TrainerAI:
and a
ld a, [wIsInBattle]
dec a
ret z ; if not a trainer, we're done here
ld a, [wLinkState]
cp LINK_STATE_BATTLING
ret z
ld a, [wTrainerClass] ; 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, [wAICount]
and a
ret z ; if no AI uses left, we're done here
inc hl
inc a
jr nz, .getpointer
dec hl
ld a, [hli]
ld [wAICount], a
.getpointer
ld a, [hli]
ld h, [hl]
ld l, a
call Random
jp hl

TrainerAIPointers:
; one entry per trainer class
; first byte, number of times (per Pokémon) it can occur
; next two bytes, pointer to AI subroutine for trainer class
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,JugglerAI ; juggler_x
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,GenericAI
dbw 3,JugglerAI ; juggler
dbw 3,GenericAI
dbw 3,GenericAI
dbw 2,BlackbeltAI ; blackbelt
dbw 3,GenericAI
dbw 3,GenericAI
dbw 1,GenericAI ; chief
dbw 3,GenericAI
dbw 1,GiovanniAI ; giovanni
dbw 3,GenericAI
dbw 2,CooltrainerMAI ; cooltrainerm
dbw 1,CooltrainerFAI ; cooltrainerf
dbw 2,BrunoAI ; bruno
dbw 5,BrockAI ; brock
dbw 1,MistyAI ; misty
dbw 1,LtSurgeAI ; surge
dbw 1,ErikaAI ; erika
dbw 2,KogaAI ; koga
dbw 2,BlaineAI ; blaine
dbw 1,SabrinaAI ; sabrina
dbw 3,GenericAI
dbw 1,Sony2AI ; sony2
dbw 1,Sony3AI ; sony3
dbw 2,LoreleiAI ; lorelei
dbw 3,GenericAI
dbw 2,AgathaAI ; agatha
dbw 1,LanceAI ; lance

JugglerAI:
cp $40
ret nc
jp AISwitchIfEnoughMons

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 AICheckIfHPBelowFraction
jp c, AIUseHyperPotion
ld a, 5
call AICheckIfHPBelowFraction
ret nc
jp AISwitchIfEnoughMons

BrockAI:
; if his active monster has a status condition, use a full heal
ld a, [wEnemyMonStatus]
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 AICheckIfHPBelowFraction
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 AICheckIfHPBelowFraction
ret nc
jp AIUseHyperPotion

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

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

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

BrunoAI:
cp $40
ret nc
jp AIUseXDefend

AgathaAI:
cp $14
jp c, AISwitchIfEnoughMons
cp $80
ret nc
ld a, 4
call AICheckIfHPBelowFraction
ret nc
jp AIUseSuperPotion

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

Offline

Board footer

Powered by FluxBB