summaryrefslogtreecommitdiff
path: root/engine/battle/trainer_ai.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/battle/trainer_ai.asm')
-rw-r--r--engine/battle/trainer_ai.asm45
1 files changed, 28 insertions, 17 deletions
diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm
index 385cdd1b..3624f5ea 100644
--- a/engine/battle/trainer_ai.asm
+++ b/engine/battle/trainer_ai.asm
@@ -145,7 +145,7 @@ AIMoveChoiceModification1:
ld [hl], a
jr .nextMove
-StatusAilmentMoveEffects: ; 57e2
+StatusAilmentMoveEffects:
db $01 ; unused sleep effect
db SLEEP_EFFECT
db POISON_EFFECT
@@ -182,7 +182,7 @@ AIMoveChoiceModification2:
jr c, .preferMove
jr .nextMove
.preferMove
- dec [hl] ; sligthly encourage this move
+ dec [hl] ; slightly encourage this move
jr .nextMove
; encourages moves that are effective against the player's mon (even if non-damaging).
@@ -295,7 +295,7 @@ TrainerClassMoveChoiceModifications:
db 1,0 ; GAMBLER
db 1,3,0 ; BEAUTY
db 1,2,0 ; PSYCHIC_TR
- db 1,3,0 ; ROCKER
+ db 1,0 ; ROCKER
db 1,0 ; JUGGLER
db 1,0 ; TAMER
db 1,0 ; BIRD_KEEPER
@@ -311,11 +311,11 @@ TrainerClassMoveChoiceModifications:
db 1,0 ; BRUNO
db 1,0 ; BROCK
db 1,3,0 ; MISTY
- db 1,3,0 ; LT_SURGE
+ db 1,0 ; LT_SURGE
db 1,3,0 ; ERIKA
db 1,3,0 ; KOGA
- db 1,3,0 ; BLAINE
- db 1,3,0 ; SABRINA
+ db 1,0 ; BLAINE
+ db 1,0 ; SABRINA
db 1,2,0 ; GENTLEMAN
db 1,3,0 ; SONY2
db 1,3,0 ; SONY3
@@ -337,13 +337,19 @@ INCLUDE "data/trainer_moves.asm"
INCLUDE "data/trainer_parties.asm"
TrainerAI:
- and a
ld a,[wIsInBattle]
dec a
- ret z ; if not a trainer, we're done here
+ jr z, .done ; if not a trainer, we're done here
ld a,[wLinkState]
cp LINK_STATE_BATTLING
- ret z
+ jr z, .done ; if in a link battle, we're done as well
+ ld a, [wEnemyBattleStatus1]
+ and 1 << ChargingUp | 1 << ThrashingAbout | 1 << StoringEnergy ; %10011
+ jr nz, .done ; don't follow trainer ai if opponent is in a locked state
+ ld a, [wEnemyBattleStatus2]
+ and 1 << UsingRage ; %1000000
+ jr nz, .done ; don't follow trainer ai if opponent is locked in rage
+ ; note that this doesn't check for hyper beam recharge which can cause problems
ld a,[wTrainerClass] ; what trainer class is this?
dec a
ld c,a
@@ -354,7 +360,7 @@ TrainerAI:
add hl,bc
ld a,[wAICount]
and a
- ret z ; if no AI uses left, we're done here
+ jr z, .done; if no AI uses left, we're done here
inc hl
inc a
jr nz,.getpointer
@@ -367,6 +373,9 @@ TrainerAI:
ld l,a
call Random
jp [hl]
+.done
+ and a
+ ret
TrainerAIPointers:
; one entry per trainer class
@@ -476,22 +485,22 @@ ErikaAI:
jp AIUseSuperPotion
KogaAI:
- cp $40
+ cp $20
ret nc
jp AIUseXAttack
BlaineAI:
cp $40
ret nc
+ ld a,$A
+ call AICheckIfHPBelowFraction
+ ret nc
jp AIUseSuperPotion
SabrinaAI:
cp $40
ret nc
- ld a,$A
- call AICheckIfHPBelowFraction
- ret nc
- jp AIUseHyperPotion
+ jp AIUseXDefend
Sony2AI:
cp $20
@@ -731,7 +740,8 @@ AICureStatus:
res 0,[hl]
ret
-AIUseXAccuracy: ; 0x3a7a8 unused
+AIUseXAccuracy:
+; unused
call AIPlayRestoringSFX
ld hl,wEnemyBattleStatus2
set 0,[hl]
@@ -745,7 +755,8 @@ AIUseGuardSpec:
ld a,GUARD_SPEC
jp AIPrintItemUse
-AIUseDireHit: ; 0x3a7c2 unused
+AIUseDireHit:
+; unused
call AIPlayRestoringSFX
ld hl,wEnemyBattleStatus2
set 2,[hl]