summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/bank3d/bank3d_battle.asm4
-rwxr-xr-xengine/battle/bank_e_misc.asm25
-rwxr-xr-xengine/battle/core.asm130
-rw-r--r--engine/battle/get_trainer_name.asm2
-rw-r--r--engine/battle/moveEffects/drain_hp_effect.asm2
-rw-r--r--engine/battle/moveEffects/haze_effect.asm2
-rw-r--r--engine/battle/moveEffects/heal_effect.asm2
-rw-r--r--engine/battle/moveEffects/paralyze_effect.asm2
-rw-r--r--engine/battle/moveEffects/recoil_effect.asm2
-rw-r--r--engine/battle/moveEffects/reflect_light_screen_effect.asm2
-rwxr-xr-xengine/battle/read_trainer_party.asm113
-rw-r--r--engine/battle/save_trainer_name.asm2
-rw-r--r--engine/battle/trainer_ai.asm169
-rwxr-xr-xengine/battle/trainer_pic_money_pointers.asm2
14 files changed, 215 insertions, 244 deletions
diff --git a/engine/bank3d/bank3d_battle.asm b/engine/bank3d/bank3d_battle.asm
index 876737b7..fde29f5d 100644
--- a/engine/bank3d/bank3d_battle.asm
+++ b/engine/bank3d/bank3d_battle.asm
@@ -32,7 +32,7 @@ asm_f601d: ; f601d (f:601d)
ld a, [wEnemyMonSpecies2]
sub $c8
jp c, InitWildBattle
- ld [W_TRAINERCLASS], a
+ ld [wTrainerClass], a
call GetTrainerInformation
callab ReadTrainer
callab DoBattleTransitionAndInitBattleVariables
@@ -100,7 +100,7 @@ InitWildBattle: ; f607c (3d:607c)
call LoadMonFrontSprite ; load mon sprite
.spriteLoaded
xor a
- ld [W_TRAINERCLASS], a
+ ld [wTrainerClass], a
ld [$ffe1], a
coord hl, 12, 0
predef CopyUncompressedPicToTilemap
diff --git a/engine/battle/bank_e_misc.asm b/engine/battle/bank_e_misc.asm
index dc766f23..278cce61 100755
--- a/engine/battle/bank_e_misc.asm
+++ b/engine/battle/bank_e_misc.asm
@@ -1,5 +1,5 @@
; formats a string at wMovesString that lists the moves at wMoves
-FormatMovesString: ; 39b87 (e:5b87)
+FormatMovesString: ; 39b06 (e:5b06)
ld hl, wMoves
ld de, wMovesString
ld b, $0
@@ -52,7 +52,7 @@ FormatMovesString: ; 39b87 (e:5b87)
ret
; XXX this is called in a few places, but it doesn't appear to do anything useful
-InitList: ; 39bd5 (e:5bd5)
+InitList: ; 39b53 (e:5b53)
ld a, [wInitListType]
cp INIT_ENEMYOT_LIST
jr nz, .notEnemy
@@ -100,23 +100,4 @@ InitList: ; 39bd5 (e:5bd5)
ld [wItemPrices], a
ld a, b
ld [wItemPrices + 1], a
- ret
-
-; get species of mon e in list [wMonDataLocation] for LoadMonData
-GetMonSpecies: ; 39c37 (e:5c37)
- ld hl, wPartySpecies
- ld a, [wMonDataLocation]
- and a
- jr z, .getSpecies
- dec a
- jr z, .enemyParty
- ld hl, wBoxSpecies
- jr .getSpecies
-.enemyParty
- ld hl, wEnemyPartyMons
-.getSpecies
- ld d, 0
- add hl, de
- ld a, [hl]
- ld [wcf91], a
- ret
+ ret \ No newline at end of file
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 5663b8b4..e5d1e36f 100755
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -851,7 +851,7 @@ FaintEnemyPokemon: ; 0x3c567
ld [hli], a
ld [hli], a
ld [hl], a
- ld [W_ENEMYDISABLEDMOVE], a
+ ld [wEnemyDisabledMove], a
ld [wEnemyDisabledMoveNumber], a
ld [wEnemyMonMinimized], a
ld hl, wPlayerUsedMove
@@ -994,7 +994,7 @@ ReplaceFaintedEnemyMon: ; 3c664 (f:4664)
.notLinkBattle
call EnemySendOut
xor a
- ld [W_ENEMYMOVENUM], a
+ ld [wEnemyMoveNum], a
ld [wActionResultOrTookBattleTurn], a
ld [wAILayer2Encouragement], a
inc a ; reset Z flag
@@ -1008,7 +1008,7 @@ TrainerBattleVictory: ; 3c696 (f:4696)
jr nz, .gymleader
ld b, MUSIC_DEFEATED_TRAINER
.gymleader
- ld a, [W_TRAINERCLASS]
+ ld a, [wTrainerClass]
cp SONY3 ; final battle against rival
jr nz, .notrival
ld b, MUSIC_DEFEATED_GYM_LEADER
@@ -1384,7 +1384,7 @@ EnemySendOutFirstMon: ; 3c92a (f:492a)
ld [hli],a
ld [hli],a
ld [hl],a
- ld [W_ENEMYDISABLEDMOVE],a
+ ld [wEnemyDisabledMove],a
ld [wEnemyDisabledMoveNumber],a
ld [wEnemyMonMinimized],a
ld hl,wPlayerUsedMove
@@ -3034,7 +3034,7 @@ SelectEnemyMove: ; 3d564 (f:5564)
ld a, [hld]
and a
jr nz, .atLeastTwoMovesAvailable
- ld a, [W_ENEMYDISABLEDMOVE]
+ ld a, [wEnemyDisabledMove]
and a
ld a, STRUGGLE ; struggle if the only move is disabled
jr nz, .done
@@ -3063,7 +3063,7 @@ SelectEnemyMove: ; 3d564 (f:5564)
ld a, b
dec a
ld [wEnemyMoveListIndex], a
- ld a, [W_ENEMYDISABLEDMOVE]
+ ld a, [wEnemyDisabledMove]
swap a
and $f
cp b
@@ -3786,7 +3786,7 @@ MonName1Text: ; 3dafb (f:5afb)
ld a, [W_PLAYERMOVENUM]
ld hl, wPlayerUsedMove
jr z, .asm_3db11
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
ld hl, wEnemyUsedMove
.asm_3db11
ld [hl], a
@@ -3921,7 +3921,7 @@ PrintMoveFailureText: ; 3dbe2 (f:5be2)
ld a, [H_WHOSETURN]
and a
jr z, .playersTurn
- ld de, W_ENEMYMOVEEFFECT
+ ld de, wEnemyMoveEffect
.playersTurn
ld hl, DoesntAffectMonText
ld a, [wDamageMultipliers]
@@ -4351,7 +4351,7 @@ GetDamageVarsForEnemyAttack: ; 3de75 (f:5e75)
ld d, a ; d = move power
and a
ret z ; return if move power is zero
- ld a, [hl] ; a = [W_ENEMYMOVETYPE]
+ ld a, [hl] ; a = [wEnemyMoveType]
cp FIRE ; types >= FIRE are all special
jr nc, .specialAttack
.physicalAttack
@@ -4508,7 +4508,7 @@ CalculateDamage: ; 3df65 (f:5f65)
and a
ld a, [W_PLAYERMOVEEFFECT]
jr z, .effect
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
.effect
; EXPLODE_EFFECT halves defense.
@@ -4938,7 +4938,7 @@ ApplyAttackToEnemyPokemonDone: ; 3e19d (f:619d)
jp DrawHUDsAndHPBars
ApplyAttackToPlayerPokemon: ; 3e1a0 (f:61a0)
- ld a,[W_ENEMYMOVEEFFECT]
+ ld a,[wEnemyMoveEffect]
cp a,OHKO_EFFECT
jr z,ApplyDamageToPlayerPokemon
cp a,SUPER_FANG_EFFECT
@@ -4971,7 +4971,7 @@ ApplyAttackToPlayerPokemon: ; 3e1a0 (f:61a0)
ld hl,wEnemyMonLevel
ld a,[hl]
ld b,a
- ld a,[W_ENEMYMOVENUM]
+ ld a,[wEnemyMoveNum]
cp a,SEISMIC_TOSS
jr z,.storeDamage
cp a,NIGHT_SHADE
@@ -5104,7 +5104,7 @@ AttackSubstitute: ; 3e25e (f:625e)
ld hl,W_PLAYERMOVEEFFECT ; value for player's turn
and a
jr z,.nullifyEffect
- ld hl,W_ENEMYMOVEEFFECT ; value for enemy's turn
+ ld hl,wEnemyMoveEffect ; value for enemy's turn
.nullifyEffect
xor a
ld [hl],a ; zero the effect of the attacker's move
@@ -5123,7 +5123,7 @@ HandleBuildingRage: ; 3e2b6 (f:62b6)
; values for the player turn
ld hl,wEnemyBattleStatus2
ld de,wEnemyMonStatMods
- ld bc,W_ENEMYMOVENUM
+ ld bc,wEnemyMoveNum
ld a,[H_WHOSETURN]
and a
jr z,.next
@@ -5183,7 +5183,7 @@ MirrorMoveCopyMove: ; 3e2fd (f:62fd)
jr z,.next
; values for enemy turn
ld a,[wPlayerUsedMove]
- ld de,W_ENEMYMOVENUM
+ ld de,wEnemyMoveNum
ld hl,wEnemySelectedMove
.next
ld [hl],a
@@ -5231,7 +5231,7 @@ MetronomePickMove: ; 3e348 (f:6348)
and a
jr z,.pickMoveLoop
; values for enemy turn
- ld de,W_ENEMYMOVENUM
+ ld de,wEnemyMoveNum
ld hl,wEnemySelectedMove
; loop to pick a random number in the range [1, $a5) to be the move used by Metronome
.pickMoveLoop
@@ -5304,7 +5304,7 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5)
ld a,[hli]
ld d,a ; d = type 1 of defender
ld e,[hl] ; e = type 2 of defender
- ld a,[W_ENEMYMOVETYPE]
+ ld a,[wEnemyMoveType]
ld [wMoveType],a
.next
ld a,[wMoveType]
@@ -5400,7 +5400,7 @@ AdjustDamageForMoveType: ; 3e3a5 (f:63a5)
; ($05 is not very effective, $10 is neutral, $14 is super effective)
; as far is can tell, this is only used once in some AI code to help decide which move to use
AIGetTypeEffectiveness: ; 3e449 (f:6449)
- ld a,[W_ENEMYMOVETYPE]
+ ld a,[wEnemyMoveType]
ld d,a ; d = type of enemy move
ld hl,wBattleMonType
ld b,[hl] ; b = type 1 of player's pokemon
@@ -5444,7 +5444,7 @@ MoveHitTest: ; 3e56b (f:656b)
jr z,.dreamEaterCheck
; enemy's turn
ld hl,wPlayerBattleStatus1
- ld de,W_ENEMYMOVEEFFECT
+ ld de,wEnemyMoveEffect
ld bc,wBattleMonStatus
.dreamEaterCheck
ld a,[de]
@@ -5499,7 +5499,7 @@ MoveHitTest: ; 3e56b (f:656b)
ret nz ; if so, always hit regardless of accuracy/evasion
jr .calcHitChance
.enemyTurn
- ld a,[W_ENEMYMOVEEFFECT]
+ ld a,[wEnemyMoveEffect]
cp a,ATTACK_DOWN1_EFFECT
jr c,.skipPlayerMistCheck
cp a,HAZE_EFFECT + 1
@@ -5696,7 +5696,7 @@ ExecuteEnemyMove: ; 3e6bc (f:66bc)
call GetCurrentMove
CheckIfEnemyNeedsToChargeUp: ; 3e6fc (f:66fc)
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
cp CHARGE_EFFECT
jp z, JumpMoveEffect
cp FLY_EFFECT
@@ -5706,7 +5706,7 @@ EnemyCanExecuteChargingMove: ; 3e70b (f:670b)
ld hl, wEnemyBattleStatus1
res ChargingUp, [hl] ; no longer charging up for attack
res Invulnerable, [hl] ; no longer invulnerable to typical attacks
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
ld [wd0b5], a
ld a, BANK(MoveNames)
ld [wPredefBank], a
@@ -5719,19 +5719,19 @@ EnemyCanExecuteMove: ; 3e72b (f:672b)
xor a
ld [wMonIsDisobedient], a
call PrintMonName1Text
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
ld hl, ResidualEffects1
ld de, $1
call IsInArray
jp c, JumpMoveEffect
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
ld hl, SpecialEffectsCont
ld de, $1
call IsInArray
call c, JumpMoveEffect
EnemyCalcMoveDamage: ; 3e750 (f:6750)
call SwapPlayerAndEnemyLevels
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
ld hl, SetDamageEffects
ld de, $1
call IsInArray
@@ -5753,7 +5753,7 @@ handleIfEnemyMoveMissed: ; 3e782 (f:6782)
ld a, [wMoveMissed]
and a
jr z, .asm_3e791
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
cp EXPLODE_EFFECT
jr z, asm_3e7a0
jr EnemyCheckIfFlyOrChargeEffect
@@ -5761,7 +5761,7 @@ handleIfEnemyMoveMissed: ; 3e782 (f:6782)
call SwapPlayerAndEnemyLevels
GetEnemyAnimationType: ; 3e794 (f:6794)
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
and a
ld a, $1
jr z, playEnemyMoveAnimation
@@ -5779,7 +5779,7 @@ playEnemyMoveAnimation: ; 3e7a4 (f:67a4)
call nz, Bankswitch
pop af
ld [wAnimationType], a
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
call PlayMoveAnimation
call HandleExplodingAnimation
call DrawEnemyHUDAndHPBar
@@ -5794,7 +5794,7 @@ EnemyCheckIfFlyOrChargeEffect: ; 3e7d1 (f:67d1)
call SwapPlayerAndEnemyLevels
ld c, 30
call DelayFrames
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
cp FLY_EFFECT
jr z, .playAnim
cp CHARGE_EFFECT
@@ -5806,7 +5806,7 @@ EnemyCheckIfFlyOrChargeEffect: ; 3e7d1 (f:67d1)
ld a,STATUS_AFFECTED_ANIM
call PlayMoveAnimation
EnemyCheckIfMirrorMoveEffect: ; 3e7ef (f:67ef)
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
cp MIRROR_MOVE_EFFECT
jr nz, .notMirrorMoveEffect
call MirrorMoveCopyMove
@@ -5818,7 +5818,7 @@ EnemyCheckIfMirrorMoveEffect: ; 3e7ef (f:67ef)
call MetronomePickMove
jp CheckIfEnemyNeedsToChargeUp
.notMetronomeEffect
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
ld hl, ResidualEffects2
ld de, $1
call IsInArray
@@ -5827,7 +5827,7 @@ EnemyCheckIfMirrorMoveEffect: ; 3e7ef (f:67ef)
and a
jr z, .asm_3e82b
call PrintMoveFailureText
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
cp EXPLODE_EFFECT
jr z, .asm_3e83e
jp ExecuteEnemyMoveDone
@@ -5838,7 +5838,7 @@ EnemyCheckIfMirrorMoveEffect: ; 3e7ef (f:67ef)
ld a, 1
ld [wMoveDidntMiss], a
.asm_3e83e
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
ld hl, AlwaysHappenSideEffects
ld de, $1
call IsInArray
@@ -5863,7 +5863,7 @@ EnemyCheckIfMirrorMoveEffect: ; 3e7ef (f:67ef)
xor a
ld [wEnemyNumHits], a
.asm_3e873
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
and a
jr z, ExecuteEnemyMoveDone
ld hl, SpecialEffects
@@ -5942,7 +5942,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld hl, ExecuteEnemyMoveDone ; enemy can't move this turn
jp .enemyReturnToHL
.checkIfAnyMoveDisabled
- ld hl, W_ENEMYDISABLEDMOVE
+ ld hl, wEnemyDisabledMove
ld a, [hl]
and a
jr z, .checkIfConfused
@@ -5991,7 +5991,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld [hli], a
ld a, [wEnemyMonDefense + 1]
ld [hl], a
- ld hl, W_ENEMYMOVEEFFECT
+ ld hl, wEnemyMoveEffect
push hl
ld a, [hl]
push af
@@ -6047,7 +6047,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
; clear bide, thrashing about, charging up, and multi-turn moves such as warp
and $ff ^ ((1 << StoringEnergy) | (1 << ThrashingAbout) | (1 << ChargingUp) | (1 << UsingTrappingMove))
ld [hl], a
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
cp FLY_EFFECT
jr z, .flyOrChargeEffect
cp CHARGE_EFFECT
@@ -6066,7 +6066,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
bit StoringEnergy, [hl] ; is mon using bide?
jr z, .checkIfThrashingAbout
xor a
- ld [W_ENEMYMOVENUM], a
+ ld [wEnemyMoveNum], a
ld hl, wDamage
ld a, [hli]
ld b, a
@@ -6107,7 +6107,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
ld [hli], a
ld [hl], a
ld a, BIDE
- ld [W_ENEMYMOVENUM], a
+ ld [wEnemyMoveNum], a
call SwapPlayerAndEnemyLevels
ld hl, handleIfEnemyMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
jp .enemyReturnToHL
@@ -6115,7 +6115,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
bit ThrashingAbout, [hl] ; is mon using thrash or petal dance?
jr z, .checkIfUsingMultiturnMove
ld a, THRASH
- ld [W_ENEMYMOVENUM], a
+ ld [wEnemyMoveNum], a
ld hl, ThrashingAboutText
call PrintText
ld hl, wEnemyNumAttacksLeft
@@ -6153,7 +6153,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f)
call GetMoveName
call CopyStringToCF4B
xor a
- ld [W_ENEMYMOVEEFFECT], a
+ ld [wEnemyMoveEffect], a
ld hl, EnemyCanExecuteMove
jp .enemyReturnToHL
.enemyReturnToHL
@@ -6168,7 +6168,7 @@ GetCurrentMove: ; 3eabe (f:6abe)
ld a, [H_WHOSETURN]
and a
jp z, .player
- ld de, W_ENEMYMOVENUM
+ ld de, wEnemyMoveNum
ld a, [wEnemySelectedMove]
jr .selected
.player
@@ -6805,7 +6805,7 @@ HandleExplodingAnimation: ; 3eed3 (f:6ed3)
jr z, .asm_3eeea
ld hl, wBattleMonType1
ld de, wEnemyBattleStatus1
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
.asm_3eeea
cp SELFDESTRUCT
jr z, .asm_3eef1
@@ -6849,7 +6849,7 @@ _JumpMoveEffect: ; 3f138 (f:7138)
and a
ld a, [W_PLAYERMOVEEFFECT]
jr z, .next1
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
.next1
dec a ; subtract 1, there is no special effect for 00
add a ; x2, 16bit pointers
@@ -7009,7 +7009,7 @@ PoisonEffect: ; 3f24f (f:724f)
and a
jr z, .poisonEffect
ld hl, wBattleMonStatus
- ld de, W_ENEMYMOVEEFFECT
+ ld de, wEnemyMoveEffect
.poisonEffect
call CheckTargetSubstitute
jr nz, .noEffect ; can't posion a substitute target
@@ -7181,7 +7181,7 @@ opponentAttacker: ; 3f382 (f:7382)
ld a, [wBattleMonStatus] ; mostly same as above with addresses swapped for opponent
and a
jp nz, CheckDefrost
- ld a, [W_ENEMYMOVETYPE]
+ ld a, [wEnemyMoveType]
ld b, a
ld a, [wBattleMonType1]
cp b
@@ -7189,7 +7189,7 @@ opponentAttacker: ; 3f382 (f:7382)
ld a, [wBattleMonType2]
cp b
ret z
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
cp a, PARALYZE_SIDE_EFFECT1 + 1
ld b, $1a
jr c, .next1
@@ -7252,7 +7252,7 @@ CheckDefrost: ; 3f3e2 (f:73e2)
ld hl, FireDefrostedText
jr .common
.opponent
- ld a, [W_ENEMYMOVETYPE] ; same as above with addresses swapped
+ ld a, [wEnemyMoveType] ; same as above with addresses swapped
sub a, FIRE
ret nz
ld [wBattleMonStatus], a
@@ -7277,7 +7277,7 @@ StatModifierUpEffect: ; 3f428 (f:7428)
and a
jr z, .statModifierUpEffect
ld hl, wEnemyMonStatMods
- ld de, W_ENEMYMOVEEFFECT
+ ld de, wEnemyMoveEffect
.statModifierUpEffect
ld a, [de]
sub ATTACK_UP1_EFFECT
@@ -7386,7 +7386,7 @@ UpdateStatDone: ; 3f4ca (f:74ca)
and a
jr z, .asm_3f4e6
ld hl, wEnemyBattleStatus2
- ld de, W_ENEMYMOVENUM
+ ld de, wEnemyMoveNum
ld bc, wEnemyMonMinimized
.asm_3f4e6
ld a, [de]
@@ -7442,7 +7442,7 @@ MonsStatsRoseText: ; 3f528 (f:7528)
and a
ld a, [W_PLAYERMOVEEFFECT]
jr z, .asm_3f53b
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
.asm_3f53b
cp ATTACK_DOWN1_EFFECT
ret nc
@@ -7465,7 +7465,7 @@ StatModifierDownEffect: ; 3f54c (f:754c)
and a
jr z, .statModifierDownEffect
ld hl, wPlayerMonStatMods
- ld de, W_ENEMYMOVEEFFECT
+ ld de, wEnemyMoveEffect
ld bc, wPlayerBattleStatus1
ld a, [wLinkState]
cp LINK_STATE_BATTLING
@@ -7644,7 +7644,7 @@ MonsStatsFellText: ; 3f661 (f:7661)
and a
ld a, [W_PLAYERMOVEEFFECT]
jr z, .asm_3f674
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
.asm_3f674
cp $1a
ret c
@@ -7718,7 +7718,7 @@ BideEffect: ; 3f6e5 (f:76e5)
inc de
ld [de], a
ld [W_PLAYERMOVEEFFECT], a
- ld [W_ENEMYMOVEEFFECT], a
+ ld [wEnemyMoveEffect], a
call BattleRandom
and $1
inc a
@@ -7814,7 +7814,7 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739)
jr nc, .asm_3f7c1
ld c, 50
call DelayFrames
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
cp TELEPORT
jp nz, PrintDidntAffectText
jp PrintButItFailedText_
@@ -7824,13 +7824,13 @@ SwitchAndTeleportEffect: ; 3f739 (f:7739)
ld [wAnimationType], a
inc a
ld [wEscapedFromBattle], a
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
jr .asm_3f7e4
.asm_3f7d1
ld c, 50
call DelayFrames
ld hl, IsUnaffectedText
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
cp TELEPORT
jp nz, PrintText
jp ConditionalPrintButItFailed
@@ -7880,7 +7880,7 @@ TwoToFiveAttacksEffect: ; 3f811 (f:7811)
ld a, [H_WHOSETURN]
and a
jr z, .setNumberOfHits
- ld hl, W_ENEMYMOVEEFFECT
+ ld hl, wEnemyMoveEffect
.setNumberOfHits
ld a, [hl]
cp TWINEEDLE_EFFECT
@@ -7916,7 +7916,7 @@ FlinchSideEffect: ; 3f85b (f:785b)
and a
jr z, .flinchSideEffect
ld hl, wPlayerBattleStatus1
- ld de, W_ENEMYMOVEEFFECT
+ ld de, wEnemyMoveEffect
.flinchSideEffect
ld a, [de]
cp FLINCH_SIDE_EFFECT1
@@ -7942,7 +7942,7 @@ ChargeEffect: ; 3f88c (f:788c)
ld b, XSTATITEM_ANIM
jr z, .chargeEffect
ld hl, wEnemyBattleStatus1
- ld de, W_ENEMYMOVEEFFECT
+ ld de, wEnemyMoveEffect
ld b, ANIM_AF
.chargeEffect
set ChargingUp, [hl]
@@ -8073,7 +8073,7 @@ ConfusionSideEffectSuccess: ; 3f96f (f:796f)
jr z, .confuseTarget
ld hl, wPlayerBattleStatus1
ld bc, W_PLAYERCONFUSEDCOUNTER
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
.confuseTarget
bit Confused, [hl] ; is mon confused?
jr nz, ConfusionEffectFailed
@@ -8227,7 +8227,7 @@ DisableEffect: ; 3fa8a (f:7a8a)
ld a, [wMoveMissed]
and a
jr nz, .moveMissed
- ld de, W_ENEMYDISABLEDMOVE
+ ld de, wEnemyDisabledMove
ld hl, wEnemyMonMoves
ld a, [H_WHOSETURN]
and a
@@ -8286,7 +8286,7 @@ DisableEffect: ; 3fa8a (f:7a8a)
inc a ; 1-8 turns disabled
inc c ; move 1-4 will be disabled
swap c
- add c ; map disabled move to high nibble of W_ENEMYDISABLEDMOVE / W_PLAYERDISABLEDMOVE
+ add c ; map disabled move to high nibble of wEnemyDisabledMove / W_PLAYERDISABLEDMOVE
ld [de], a
call PlayCurrentMoveAnimation2
ld hl, wPlayerDisabledMoveNumber
@@ -8391,7 +8391,7 @@ PlayCurrentMoveAnimation2: ; 3fb89 (f:7b89)
and a
ld a, [W_PLAYERMOVENUM]
jr z, .notEnemyTurn
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
.notEnemyTurn
and a
ret z
@@ -8417,7 +8417,7 @@ PlayCurrentMoveAnimation: ; 3fba8 (f:7ba8)
and a
ld a, [W_PLAYERMOVENUM]
jr z, .notEnemyTurn
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
.notEnemyTurn
and a
ret z
diff --git a/engine/battle/get_trainer_name.asm b/engine/battle/get_trainer_name.asm
index bbc577b3..cacf7ee8 100644
--- a/engine/battle/get_trainer_name.asm
+++ b/engine/battle/get_trainer_name.asm
@@ -4,7 +4,7 @@ GetTrainerName_: ; f67a5 (3d:67a5)
and a
jr nz, .foundName
ld hl, wRivalName
- ld a, [W_TRAINERCLASS]
+ ld a, [wTrainerClass]
cp SONY1
jr z, .foundName
cp SONY2
diff --git a/engine/battle/moveEffects/drain_hp_effect.asm b/engine/battle/moveEffects/drain_hp_effect.asm
index 0dc02e46..46d61196 100644
--- a/engine/battle/moveEffects/drain_hp_effect.asm
+++ b/engine/battle/moveEffects/drain_hp_effect.asm
@@ -87,7 +87,7 @@ DrainHPEffect_: ; 76e7 (1:76e7)
and a
ld a, [W_PLAYERMOVEEFFECT]
jr z, .next3
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
.next3
cp DREAM_EATER_EFFECT
jr nz, .printText
diff --git a/engine/battle/moveEffects/haze_effect.asm b/engine/battle/moveEffects/haze_effect.asm
index de36ac36..e7e7a68a 100644
--- a/engine/battle/moveEffects/haze_effect.asm
+++ b/engine/battle/moveEffects/haze_effect.asm
@@ -32,7 +32,7 @@ HazeEffect_: ; 139a4 (4:79a4)
.cureVolatileStatuses
xor a
ld [W_PLAYERDISABLEDMOVE], a
- ld [W_ENEMYDISABLEDMOVE], a
+ ld [wEnemyDisabledMove], a
ld hl, wPlayerDisabledMoveNumber
ld [hli], a
ld [hl], a
diff --git a/engine/battle/moveEffects/heal_effect.asm b/engine/battle/moveEffects/heal_effect.asm
index dbce6ebb..7a1983d7 100644
--- a/engine/battle/moveEffects/heal_effect.asm
+++ b/engine/battle/moveEffects/heal_effect.asm
@@ -7,7 +7,7 @@ HealEffect_: ; f62ba (3d:62ba)
jr z, .healEffect
ld de, wEnemyMonHP
ld hl, wEnemyMonMaxHP
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
.healEffect
ld b, a
ld a, [de]
diff --git a/engine/battle/moveEffects/paralyze_effect.asm b/engine/battle/moveEffects/paralyze_effect.asm
index 9b364425..a8d39629 100644
--- a/engine/battle/moveEffects/paralyze_effect.asm
+++ b/engine/battle/moveEffects/paralyze_effect.asm
@@ -5,7 +5,7 @@ ParalyzeEffect_: ; f6562 (3d:6562)
and a
jp z, .next
ld hl, wBattleMonStatus
- ld de, W_ENEMYMOVETYPE
+ ld de, wEnemyMoveType
.next
ld a, [hl]
and a ; does the target already have a status ailment?
diff --git a/engine/battle/moveEffects/recoil_effect.asm b/engine/battle/moveEffects/recoil_effect.asm
index 76394ddf..984feba7 100644
--- a/engine/battle/moveEffects/recoil_effect.asm
+++ b/engine/battle/moveEffects/recoil_effect.asm
@@ -4,7 +4,7 @@ RecoilEffect_: ; 138f6 (4:78f6)
ld a, [W_PLAYERMOVENUM]
ld hl, wBattleMonMaxHP
jr z, .recoilEffect
- ld a, [W_ENEMYMOVENUM]
+ ld a, [wEnemyMoveNum]
ld hl, wEnemyMonMaxHP
.recoilEffect
ld d, a
diff --git a/engine/battle/moveEffects/reflect_light_screen_effect.asm b/engine/battle/moveEffects/reflect_light_screen_effect.asm
index 12bb3367..c3f4de7f 100644
--- a/engine/battle/moveEffects/reflect_light_screen_effect.asm
+++ b/engine/battle/moveEffects/reflect_light_screen_effect.asm
@@ -5,7 +5,7 @@ ReflectLightScreenEffect_: ; f645d (3d:645d)
and a
jr z, .reflectLightScreenEffect
ld hl, wEnemyBattleStatus3
- ld de, W_ENEMYMOVEEFFECT
+ ld de, wEnemyMoveEffect
.reflectLightScreenEffect
ld a, [de]
cp LIGHT_SCREEN_EFFECT
diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm
index 9f94981e..a4843417 100755
--- a/engine/battle/read_trainer_party.asm
+++ b/engine/battle/read_trainer_party.asm
@@ -1,4 +1,4 @@
-ReadTrainer: ; 39c53 (e:5c53)
+ReadTrainer: ; 39bb6 (e:5bb6)
; don't change any moves in a link battle
ld a,[wLinkState]
@@ -15,9 +15,9 @@ ReadTrainer: ; 39c53 (e:5c53)
ld [hl],a
; get the pointer to trainer data for this class
- ld a,[wCurOpponent]
- sub $C9 ; convert value from pokemon to trainer
- add a,a
+ ld a,[wTrainerClass] ; get trainer class
+ dec a
+ add a
ld hl,TrainerDataPointers
ld c,a
ld b,0
@@ -25,7 +25,7 @@ ReadTrainer: ; 39c53 (e:5c53)
ld a,[hli]
ld h,[hl]
ld l,a
- ld a,[W_TRAINERNO]
+ ld a,[wTrainerNo]
ld b,a
; At this point b contains the trainer number,
; and hl points to the trainer class.
@@ -53,7 +53,7 @@ ReadTrainer: ; 39c53 (e:5c53)
.LoopTrainerData
ld a,[hli]
and a ; have we reached the end of the trainer data?
- jr z,.FinishUp
+ jp z, .AddAdditionalMoveData
ld [wcf91],a ; write species somewhere (XXX why?)
ld a,ENEMY_PARTY_DATA
ld [wMonDataLocation],a
@@ -68,7 +68,7 @@ ReadTrainer: ; 39c53 (e:5c53)
; - if [wLoneAttackNo] != 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,.AddLoneMove
+ jr z,.AddAdditionalMoveData
ld [wCurEnemyLVL],a
ld a,[hli]
ld [wcf91],a
@@ -78,69 +78,48 @@ ReadTrainer: ; 39c53 (e:5c53)
call AddPartyMon
pop hl
jr .SpecialTrainer
-.AddLoneMove
-; does the trainer have a single monster with a different move
- ld a,[wLoneAttackNo] ; Brock is 01, Misty is 02, Erika is 04, etc
+.AddAdditionalMoveData
+; does the trainer have additional move data?
+ ld a, [wTrainerClass]
+ ld b, a
+ ld a, [wTrainerNo]
+ ld c, a
+ ld hl, SpecialTrainerMoves
+.loopAdditionalMoveData
+ ld a, [hli]
+ cp $ff
+ jr z, .FinishUp
+ cp b
+ jr nz, .asm_39c46
+ ld a, [hli]
+ cp c
+ jr nz, .asm_39c46
+ ld d, h
+ ld e, l
+.writeAdditionalMoveDataLoop
+ ld a, [de]
+ inc de
and a
- jr z,.AddTeamMove
+ jp z, .FinishUp
dec a
- add a,a
- ld c,a
- ld b,0
- ld hl,LoneMoves
- add hl,bc
- ld a,[hli]
- ld d,[hl]
- ld hl,wEnemyMon1Moves + 2
- ld bc,wEnemyMon2 - wEnemyMon1
+ ld hl, wEnemyMon1Moves
+ ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes
- ld [hl],d
- jr .FinishUp
-.AddTeamMove
-; check if our trainer's team has special moves
-
-; get trainer class number
- ld a,[wCurOpponent]
- sub 200
- ld b,a
- ld hl,TeamMoves
-
-; iterate through entries in TeamMoves, checking each for our trainer class
-.IterateTeamMoves
- ld a,[hli]
- cp b
- jr z,.GiveTeamMoves ; is there a match?
- inc hl ; if not, go to the next entry
- inc a
- jr nz,.IterateTeamMoves
-
-; no matches found. is this trainer champion rival?
- ld a,b
- cp SONY3
- jr z,.ChampionRival
- jr .FinishUp ; nope
-.GiveTeamMoves
- ld a,[hl]
- ld [wEnemyMon5Moves + 2],a
- jr .FinishUp
-.ChampionRival ; give moves to his team
-
-; pidgeot
- ld a,SKY_ATTACK
- ld [wEnemyMon1Moves + 2],a
-
-; starter
- ld a,[W_RIVALSTARTER]
- cp STARTER3
- ld b,MEGA_DRAIN
- jr z,.GiveStarterMove
- cp STARTER1
- ld b,FIRE_BLAST
- jr z,.GiveStarterMove
- ld b,BLIZZARD ; must be squirtle
-.GiveStarterMove
- ld a,b
- ld [wEnemyMon6Moves + 2],a
+ ld a, [de]
+ inc de
+ dec a
+ ld c, a
+ ld b, 0
+ add hl,bc
+ ld a, [de]
+ inc de
+ ld [hl], a
+ jr .writeAdditionalMoveDataLoop
+.asm_39c46
+ ld a, [hli]
+ and a
+ jr nz, .asm_39c46
+ jr .loopAdditionalMoveData
.FinishUp
; clear wAmountMoneyWon addresses
xor a
diff --git a/engine/battle/save_trainer_name.asm b/engine/battle/save_trainer_name.asm
index a5a578af..227dbbcb 100644
--- a/engine/battle/save_trainer_name.asm
+++ b/engine/battle/save_trainer_name.asm
@@ -1,6 +1,6 @@
SaveTrainerName: ; 27dff (9:7dff)
ld hl,TrainerNamePointers
- ld a,[W_TRAINERCLASS]
+ ld a,[wTrainerClass]
dec a
ld c,a
ld b,0
diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm
index 2209fb57..0af1b86d 100644
--- a/engine/battle/trainer_ai.asm
+++ b/engine/battle/trainer_ai.asm
@@ -1,13 +1,13 @@
; creates a set of moves that may be used and returns its address in hl
; unused slots are filled with 0, all used slots may be chosen with equal probability
-AIEnemyTrainerChooseMoves: ; 39719 (e:5719)
+AIEnemyTrainerChooseMoves: ; 3969c (e:569c)
ld a, $a
ld hl, wBuffer ; init temporary move selection array. Only the moves with the lowest numbers are chosen in the end
ld [hli], a ; move 1
ld [hli], a ; move 2
ld [hli], a ; move 3
ld [hl], a ; move 4
- ld a, [W_ENEMYDISABLEDMOVE] ; forbid disabled move (if any)
+ ld a, [wEnemyDisabledMove] ; forbid disabled move (if any)
swap a
and $f
jr z, .noMoveDisabled
@@ -19,7 +19,7 @@ AIEnemyTrainerChooseMoves: ; 39719 (e:5719)
ld [hl], $50 ; forbid (highly discourage) disabled move
.noMoveDisabled
ld hl, TrainerClassMoveChoiceModifications
- ld a, [W_TRAINERCLASS]
+ ld a, [wTrainerClass]
ld b, a
.loopTrainerClasses
dec b
@@ -103,14 +103,14 @@ AIEnemyTrainerChooseMoves: ; 39719 (e:5719)
ld hl, wEnemyMonMoves ; use original move set
ret
-AIMoveChoiceModificationFunctionPointers: ; 397a3 (e:57a3)
+AIMoveChoiceModificationFunctionPointers: ; 39726 (e:5726)
dw AIMoveChoiceModification1
dw AIMoveChoiceModification2
dw AIMoveChoiceModification3
dw AIMoveChoiceModification4 ; unused, does nothing
; discourages moves that cause no damage but only a status ailment if player's mon already has one
-AIMoveChoiceModification1: ; 397ab (e:57ab)
+AIMoveChoiceModification1: ; 3972e (e:572e)
ld a, [wBattleMonStatus]
and a
ret z ; return if no status ailment on player's mon
@@ -129,7 +129,7 @@ AIMoveChoiceModification1: ; 397ab (e:57ab)
ld a, [W_ENEMYMOVEPOWER]
and a
jr nz, .nextMove
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
push hl
push de
push bc
@@ -145,7 +145,7 @@ AIMoveChoiceModification1: ; 397ab (e:57ab)
ld [hl], a
jr .nextMove
-StatusAilmentMoveEffects: ; 57e2
+StatusAilmentMoveEffects: ; 39765 (e:5765)
db $01 ; unused sleep effect
db SLEEP_EFFECT
db POISON_EFFECT
@@ -155,7 +155,7 @@ StatusAilmentMoveEffects: ; 57e2
; slightly encourage moves with specific effects.
; in particular, stat-modifying moves and other move effects
; that fall in-bewteen
-AIMoveChoiceModification2: ; 397e7 (e:57e7)
+AIMoveChoiceModification2: ; 3976a (e:576a)
ld a, [wAILayer2Encouragement]
cp $1
ret nz
@@ -171,7 +171,7 @@ AIMoveChoiceModification2: ; 397e7 (e:57e7)
ret z ; no more moves in move set
inc de
call ReadMove
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
cp ATTACK_UP1_EFFECT
jr c, .nextMove
cp BIDE_EFFECT
@@ -182,13 +182,13 @@ AIMoveChoiceModification2: ; 397e7 (e:57e7)
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).
; discourage damaging moves that are ineffective or not very effective against the player's mon,
; unless there's no damaging move that deals at least neutral damage
-AIMoveChoiceModification3: ; 39817 (e:5817)
+AIMoveChoiceModification3: ; 3979a (e:579a)
ld hl, wBuffer - 1 ; temp move selection array (-1 byte offset)
ld de, wEnemyMonMoves ; enemy moves
ld b, NUM_MOVES + 1
@@ -218,7 +218,7 @@ AIMoveChoiceModification3: ; 39817 (e:5817)
push hl
push de
push bc
- ld a, [W_ENEMYMOVETYPE]
+ ld a, [wEnemyMoveType]
ld d, a
ld hl, wEnemyMonMoves ; enemy moves
ld b, NUM_MOVES + 1
@@ -230,14 +230,14 @@ AIMoveChoiceModification3: ; 39817 (e:5817)
and a
jr z, .done
call ReadMove
- ld a, [W_ENEMYMOVEEFFECT]
+ ld a, [wEnemyMoveEffect]
cp SUPER_FANG_EFFECT
jr z, .betterMoveFound ; Super Fang is considered to be a better move
cp SPECIAL_DAMAGE_EFFECT
jr z, .betterMoveFound ; any special damage moves are considered to be better moves
cp FLY_EFFECT
jr z, .betterMoveFound ; Fly is considered to be a better move
- ld a, [W_ENEMYMOVETYPE]
+ ld a, [wEnemyMoveType]
cp d
jr z, .loopMoves
ld a, [W_ENEMYMOVEPOWER]
@@ -255,10 +255,10 @@ AIMoveChoiceModification3: ; 39817 (e:5817)
jr z, .nextMove
inc [hl] ; sligthly discourage this move
jr .nextMove
-AIMoveChoiceModification4: ; 39883 (e:5883)
+AIMoveChoiceModification4: ; 39806 (e:5806)
ret
-ReadMove: ; 39884 (e:5884)
+ReadMove: ; 39807 (e:5807)
push hl
push de
push bc
@@ -266,7 +266,7 @@ ReadMove: ; 39884 (e:5884)
ld hl,Moves
ld bc,MoveEnd - Moves
call AddNTimes
- ld de,W_ENEMYMOVENUM
+ ld de,wEnemyMoveNum
call CopyData
pop bc
pop de
@@ -275,7 +275,7 @@ ReadMove: ; 39884 (e:5884)
; move choice modification methods that are applied for each trainer class
; 0 is sentinel value
-TrainerClassMoveChoiceModifications: ; 3989b (e:589b)
+TrainerClassMoveChoiceModifications: ; 3981e (e:581e)
db 0 ; YOUNGSTER
db 1,0 ; BUG CATCHER
db 1,0 ; LASS
@@ -295,7 +295,7 @@ TrainerClassMoveChoiceModifications: ; 3989b (e:589b)
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: ; 3989b (e:589b)
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
@@ -336,15 +336,21 @@ INCLUDE "data/trainer_moves.asm"
INCLUDE "data/trainer_parties.asm"
-TrainerAI: ; 3a52e (e:652e)
- and a
+TrainerAI: ; 3a5b2 (e:65b2)
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
- ld a,[W_TRAINERCLASS] ; what trainer class is this?
+ 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
ld b,0
@@ -354,7 +360,7 @@ TrainerAI: ; 3a52e (e:652e)
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,8 +373,11 @@ TrainerAI: ; 3a52e (e:652e)
ld l,a
call Random
jp [hl]
+.done
+ and a
+ ret
-TrainerAIPointers: ; 3a55c (e:655c)
+TrainerAIPointers: ; 3a5f2 (e:65f2)
; 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
@@ -420,27 +429,27 @@ TrainerAIPointers: ; 3a55c (e:655c)
dbw 2,AgathaAI ; agatha
dbw 1,LanceAI ; lance
-JugglerAI: ; 3a5e9 (e:65e9)
+JugglerAI: ; 3a67f (e:667f)
cp $40
ret nc
jp AISwitchIfEnoughMons
-BlackbeltAI: ; 3a5ef (e:65ef)
+BlackbeltAI: ; 3a685 (e:6685)
cp $20
ret nc
jp AIUseXAttack
-GiovanniAI: ; 3a5f5 (e:65f5)
+GiovanniAI: ; 3a68b (e:668b)
cp $40
ret nc
jp AIUseGuardSpec
-CooltrainerMAI: ; 3a5fb (e:65fb)
+CooltrainerMAI: ; 3a691 (e:6691)
cp $40
ret nc
jp AIUseXAttack
-CooltrainerFAI: ; 3a601 (e:6601)
+CooltrainerFAI: ; 3a697 (e:6697)
cp $40
ld a,$A
call AICheckIfHPBelowFraction
@@ -450,24 +459,24 @@ CooltrainerFAI: ; 3a601 (e:6601)
ret nc
jp AISwitchIfEnoughMons
-BrockAI: ; 3a614 (e:6614)
+BrockAI: ; 3a6aa (e:66aa)
; if his active monster has a status condition, use a full heal
ld a,[wEnemyMonStatus]
and a
ret z
jp AIUseFullHeal
-MistyAI: ; 3a61c (e:661c)
+MistyAI: ; 3a6b2 (e:66b2)
cp $40
ret nc
jp AIUseXDefend
-LtSurgeAI: ; 3a622 (e:6622)
+LtSurgeAI: ; 3a6b8 (e:66b8)
cp $40
ret nc
jp AIUseXSpeed
-ErikaAI: ; 3a628 (e:6628)
+ErikaAI: ; 3a6be (e:66be)
cp $80
ret nc
ld a,$A
@@ -475,25 +484,25 @@ ErikaAI: ; 3a628 (e:6628)
ret nc
jp AIUseSuperPotion
-KogaAI: ; 3a634 (e:6634)
- cp $40
+KogaAI: ; 3a6ca (e:66ca)
+ cp $20
ret nc
jp AIUseXAttack
-BlaineAI: ; 3a63a (e:663a)
+BlaineAI: ; 3a6d0 (e:66d0)
cp $40
ret nc
+ ld a,$A
+ call AICheckIfHPBelowFraction
+ ret nc
jp AIUseSuperPotion
-SabrinaAI: ; 3a640 (e:6640)
+SabrinaAI: ; 3a6dc (e:66dc)
cp $40
ret nc
- ld a,$A
- call AICheckIfHPBelowFraction
- ret nc
- jp AIUseHyperPotion
+ jp AIUseXDefend
-Sony2AI: ; 3a64c (e:664c)
+Sony2AI: ; 3a6e2 (e:66e2)
cp $20
ret nc
ld a,5
@@ -501,7 +510,7 @@ Sony2AI: ; 3a64c (e:664c)
ret nc
jp AIUsePotion
-Sony3AI: ; 3a658 (e:6658)
+Sony3AI: ; 3a6ee (e:66ee)
cp $20
ret nc
ld a,5
@@ -509,7 +518,7 @@ Sony3AI: ; 3a658 (e:6658)
ret nc
jp AIUseFullRestore
-LoreleiAI: ; 3a664 (e:6664)
+LoreleiAI: ; 3a6fa (e:66fa)
cp $80
ret nc
ld a,5
@@ -517,12 +526,12 @@ LoreleiAI: ; 3a664 (e:6664)
ret nc
jp AIUseSuperPotion
-BrunoAI: ; 3a670 (e:6670)
+BrunoAI: ; 3a706 (e:6706)
cp $40
ret nc
jp AIUseXDefend
-AgathaAI: ; 3a676 (e:6676)
+AgathaAI: ; 3a70c (e:670c)
cp $14
jp c,AISwitchIfEnoughMons
cp $80
@@ -532,7 +541,7 @@ AgathaAI: ; 3a676 (e:6676)
ret nc
jp AIUseSuperPotion
-LanceAI: ; 3a687 (e:6687)
+LanceAI: ; 3a71d (e:671d)
cp $80
ret nc
ld a,5
@@ -540,23 +549,23 @@ LanceAI: ; 3a687 (e:6687)
ret nc
jp AIUseHyperPotion
-GenericAI: ; 3a693 (e:6693)
+GenericAI: ; 3a729 (e:6729)
and a ; clear carry
ret
; end of individual trainer AI routines
-DecrementAICount: ; 3a695 (e:6695)
+DecrementAICount: ; 3a72b (e:672b)
ld hl,wAICount
dec [hl]
scf
ret
-AIPlayRestoringSFX: ; 3a69b (e:669b)
+AIPlayRestoringSFX: ; 3a731 (e:6731)
ld a,SFX_HEAL_AILMENT
jp PlaySoundWaitForCurrent
-AIUseFullRestore: ; 3a6a0 (e:66a0)
+AIUseFullRestore: ; 3a736 (e:6736)
call AICureStatus
ld a,FULL_RESTORE
ld [wAIItem],a
@@ -580,25 +589,25 @@ AIUseFullRestore: ; 3a6a0 (e:66a0)
ld [wEnemyMonHP],a
jr AIPrintItemUseAndUpdateHPBar
-AIUsePotion: ; 3a6ca (e:66ca)
+AIUsePotion: ; 3a760 (e:6760)
; enemy trainer heals his monster with a potion
ld a,POTION
ld b,20
jr AIRecoverHP
-AIUseSuperPotion: ; 3a6d0 (e:66d0)
+AIUseSuperPotion: ; 3a766 (e:6766)
; enemy trainer heals his monster with a super potion
ld a,SUPER_POTION
ld b,50
jr AIRecoverHP
-AIUseHyperPotion: ; 3a6d6 (e:66d6)
+AIUseHyperPotion: ; 3a76c (e:676c)
; enemy trainer heals his monster with a hyper potion
ld a,HYPER_POTION
ld b,200
; fallthrough
-AIRecoverHP: ; 3a6da (e:66da)
+AIRecoverHP: ; 3a770 (e:6770)
; heal b HP and print "trainer used $(a) on pokemon!"
ld [wAIItem],a
ld hl,wEnemyMonHP + 1
@@ -639,7 +648,7 @@ AIRecoverHP: ; 3a6da (e:66da)
ld [wHPBarNewHP+1],a
; fallthrough
-AIPrintItemUseAndUpdateHPBar: ; 3a718 (e:6718)
+AIPrintItemUseAndUpdateHPBar: ; 3a7ae (e:67ae)
call AIPrintItemUse_
coord hl, 2, 2
xor a
@@ -647,7 +656,7 @@ AIPrintItemUseAndUpdateHPBar: ; 3a718 (e:6718)
predef UpdateHPBar2
jp DecrementAICount
-AISwitchIfEnoughMons: ; 3a72a (e:672a)
+AISwitchIfEnoughMons: ; 3a7c0 (e:67c0)
; enemy trainer switches if there are 3 or more unfainted mons in party
ld a,[wEnemyPartyCount]
ld c,a
@@ -677,7 +686,7 @@ AISwitchIfEnoughMons: ; 3a72a (e:672a)
and a
ret
-SwitchEnemyMon: ; 3a74b (e:674b)
+SwitchEnemyMon: ; 3a7e1 (e:67e1)
; prepare to withdraw the active monster: copy hp, number, and status to roster
@@ -708,17 +717,17 @@ SwitchEnemyMon: ; 3a74b (e:674b)
scf
ret
-AIBattleWithdrawText: ; 3a781 (e:6781)
+AIBattleWithdrawText: ; 3a817 (e:6817)
TX_FAR _AIBattleWithdrawText
db "@"
-AIUseFullHeal: ; 3a786 (e:6786)
+AIUseFullHeal: ; 3a81c (e:681c)
call AIPlayRestoringSFX
call AICureStatus
ld a,FULL_HEAL
jp AIPrintItemUse
-AICureStatus: ; 3a791 (e:6791)
+AICureStatus: ; 3a827 (e:6827)
; cures the status of enemy's active pokemon
ld a,[wEnemyMonPartyPos]
ld hl,wEnemyMon1Status
@@ -731,28 +740,30 @@ AICureStatus: ; 3a791 (e:6791)
res 0,[hl]
ret
-AIUseXAccuracy: ; 0x3a7a8 unused
+AIUseXAccuracy: ; 3a83e (e:683e)
+; unused
call AIPlayRestoringSFX
ld hl,wEnemyBattleStatus2
set 0,[hl]
ld a,X_ACCURACY
jp AIPrintItemUse
-AIUseGuardSpec: ; 3a7b5 (e:67b5)
+AIUseGuardSpec: ; 3a84b (e:684b)
call AIPlayRestoringSFX
ld hl,wEnemyBattleStatus2
set 1,[hl]
ld a,GUARD_SPEC_
jp AIPrintItemUse
-AIUseDireHit: ; 0x3a7c2 unused
+AIUseDireHit: ; 3a858 (e:6858)
+; unused
call AIPlayRestoringSFX
ld hl,wEnemyBattleStatus2
set 2,[hl]
ld a,DIRE_HIT
jp AIPrintItemUse
-AICheckIfHPBelowFraction: ; 3a7cf (e:67cf)
+AICheckIfHPBelowFraction: ; 3a865 (e:6865)
; return carry if enemy trainer's current HP is below 1 / a of the maximum
ld [H_DIVISOR],a
ld hl,wEnemyMonMaxHP
@@ -778,32 +789,32 @@ AICheckIfHPBelowFraction: ; 3a7cf (e:67cf)
sub c
ret
-AIUseXAttack: ; 3a7f2 (e:67f2)
+AIUseXAttack: ; 3a888 (e:6888)
ld b,$A
ld a,X_ATTACK
jr AIIncreaseStat
-AIUseXDefend: ; 3a7f8 (e:67f8)
+AIUseXDefend: ; 3a88e (e:688e)
ld b,$B
ld a,X_DEFEND
jr AIIncreaseStat
-AIUseXSpeed: ; 3a7fe (e:67fe)
+AIUseXSpeed: ; 3a894 (e:6894)
ld b,$C
ld a,X_SPEED
jr AIIncreaseStat
-AIUseXSpecial: ; 3a804 (e:6804)
+AIUseXSpecial: ; 3a89a (e:689a)
ld b,$D
ld a,X_SPECIAL
; fallthrough
-AIIncreaseStat: ; 3a808 (e:6808)
+AIIncreaseStat: ; 3a89e (e:689e)
ld [wAIItem],a
push bc
call AIPrintItemUse_
pop bc
- ld hl,W_ENEMYMOVEEFFECT
+ ld hl,wEnemyMoveEffect
ld a,[hld]
push af
ld a,[hl]
@@ -820,12 +831,12 @@ AIIncreaseStat: ; 3a808 (e:6808)
ld [hl],a
jp DecrementAICount
-AIPrintItemUse: ; 3a82c (e:682c)
+AIPrintItemUse: ; 3a8c2 (e:68c2)
ld [wAIItem],a
call AIPrintItemUse_
jp DecrementAICount
-AIPrintItemUse_: ; 3a835 (e:6835)
+AIPrintItemUse_: ; 3a8cb (e:68cb)
; print "x used [wAIItem] on z!"
ld a,[wAIItem]
ld [wd11e],a
@@ -833,6 +844,6 @@ AIPrintItemUse_: ; 3a835 (e:6835)
ld hl, AIBattleUseItemText
jp PrintText
-AIBattleUseItemText: ; 3a844 (e:6844)
+AIBattleUseItemText: ; 3a8da (e:68da)
TX_FAR _AIBattleUseItemText
db "@"
diff --git a/engine/battle/trainer_pic_money_pointers.asm b/engine/battle/trainer_pic_money_pointers.asm
index 3f684db3..69599dc0 100755
--- a/engine/battle/trainer_pic_money_pointers.asm
+++ b/engine/battle/trainer_pic_money_pointers.asm
@@ -1,4 +1,4 @@
-TrainerPicAndMoneyPointers: ; 39914 (e:5914)
+TrainerPicAndMoneyPointers: ; 39893 (e:5893)
; trainer pic pointers and base money.
; money received after battle = base money × level of highest-level enemy mon
dw YoungsterPic