summaryrefslogtreecommitdiff
path: root/engine/battle/ai
diff options
context:
space:
mode:
Diffstat (limited to 'engine/battle/ai')
-rw-r--r--engine/battle/ai/items.asm156
-rw-r--r--engine/battle/ai/move.asm9
-rw-r--r--engine/battle/ai/redundant.asm58
-rw-r--r--engine/battle/ai/scoring.asm414
-rw-r--r--engine/battle/ai/switch.asm38
5 files changed, 199 insertions, 476 deletions
diff --git a/engine/battle/ai/items.asm b/engine/battle/ai/items.asm
index 218ecd375..29bc23b20 100644
--- a/engine/battle/ai/items.asm
+++ b/engine/battle/ai/items.asm
@@ -1,4 +1,4 @@
-AI_SwitchOrTryItem: ; 38000
+AI_SwitchOrTryItem:
and a
ld a, [wBattleMode]
@@ -38,12 +38,11 @@ AI_SwitchOrTryItem: ; 38000
jp nz, SwitchSometimes
; fallthrough
-DontSwitch: ; 38041
+DontSwitch:
call AI_TryItem
ret
-; 38045
-SwitchOften: ; 38045
+SwitchOften:
callfar CheckAbleToSwitch
ld a, [wEnemySwitchMonParam]
and $f0
@@ -77,9 +76,8 @@ SwitchOften: ; 38045
; In register 'a' is the number (1-6) of the mon to switch to
ld [wEnemySwitchMonIndex], a
jp AI_TrySwitch
-; 38083
-SwitchRarely: ; 38083
+SwitchRarely:
callfar CheckAbleToSwitch
ld a, [wEnemySwitchMonParam]
and $f0
@@ -112,9 +110,8 @@ SwitchRarely: ; 38083
inc a
ld [wEnemySwitchMonIndex], a
jp AI_TrySwitch
-; 380c1
-SwitchSometimes: ; 380c1
+SwitchSometimes:
callfar CheckAbleToSwitch
ld a, [wEnemySwitchMonParam]
and $f0
@@ -147,17 +144,13 @@ SwitchSometimes: ; 380c1
inc a
ld [wEnemySwitchMonIndex], a
jp AI_TrySwitch
-; 380ff
-
-CheckSubstatusCantRun: ; 380ff
+CheckSubstatusCantRun:
ld a, [wEnemySubStatus5]
bit SUBSTATUS_CANT_RUN, a
ret
-; 38105
-
-AI_TryItem: ; 38105
+AI_TryItem:
; items are not allowed in the BattleTower
ld a, [wInBattleTowerBattle]
and a
@@ -243,8 +236,7 @@ AI_TryItem: ; 38105
scf
ret
-
-.IsHighestLevel: ; 38170
+.IsHighestLevel:
ld a, [wOTPartyCount]
ld d, a
ld e, 0
@@ -274,10 +266,8 @@ AI_TryItem: ; 38105
.yes
scf
ret
-; 38196
-
-AI_Items: ; 39196
+AI_Items:
dbw FULL_RESTORE, .FullRestore
dbw MAX_POTION, .MaxPotion
dbw HYPER_POTION, .HyperPotion
@@ -292,16 +282,14 @@ AI_Items: ; 39196
dbw X_SPEED, .XSpeed
dbw X_SPECIAL, .XSpecial
db -1 ; end
-; 381be
-.FullHeal: ; 381be
+.FullHeal:
call .Status
jp c, .DontUse
call EnemyUsedFullHeal
jp .Use
-; 381ca
-.Status: ; 381ca (e:41ca)
+.Status:
ld a, [wEnemyMonStatus]
and a
jp z, .DontUse
@@ -332,9 +320,8 @@ AI_Items: ; 39196
and 1 << FRZ | SLP
jp z, .DontUse
jp .Use
-; 38208
-.FullRestore: ; 38208
+.FullRestore:
call .HealItem
jp nc, .UseFullRestore
ld a, [bc]
@@ -346,15 +333,14 @@ AI_Items: ; 39196
.UseFullRestore:
call EnemyUsedFullRestore
jp .Use
-; 38220
-.MaxPotion: ; 38220
+.MaxPotion:
call .HealItem
jp c, .DontUse
call EnemyUsedMaxPotion
jp .Use
-.HealItem: ; 3822c (e:422c)
+.HealItem:
ld a, [bc]
bit CONTEXT_USE_F, a
jr nz, .CheckHalfOrQuarterHP
@@ -370,7 +356,7 @@ AI_Items: ; 39196
jp c, .UseHealItem
jp .DontUse
-.CheckQuarterHP: ; 38254 (e:4254)
+.CheckQuarterHP:
callfar AICheckEnemyQuarterHP
jp c, .DontUse
call Random
@@ -378,7 +364,7 @@ AI_Items: ; 39196
jp c, .DontUse
jr .UseHealItem
-.CheckHalfOrQuarterHP: ; 38267 (e:4267)
+.CheckHalfOrQuarterHP:
callfar AICheckEnemyHalfHP
jp c, .DontUse
callfar AICheckEnemyQuarterHP
@@ -387,33 +373,29 @@ AI_Items: ; 39196
cp 20 percent - 1
jp nc, .DontUse
-.UseHealItem: ; 38281 (e:4281)
+.UseHealItem:
jp .Use
-; 38284
-.HyperPotion: ; 38284
+.HyperPotion:
call .HealItem
jp c, .DontUse
ld b, 200
call EnemyUsedHyperPotion
jp .Use
-; 38292 (e:4292)
-.SuperPotion: ; 38292
+.SuperPotion:
call .HealItem
jp c, .DontUse
ld b, 50
call EnemyUsedSuperPotion
jp .Use
-; 382a0
-.Potion: ; 382a0
+.Potion:
call .HealItem
jp c, .DontUse
ld b, 20
call EnemyUsedPotion
jp .Use
-; 382ae
.asm_382ae ; This appears to be unused
callfar AICheckEnemyMaxHP
@@ -457,58 +439,50 @@ AI_Items: ; 39196
cp 39 percent + 1
jp c, .Use
jp .DontUse
-; 382f9
-.XAccuracy: ; 382f9
+.XAccuracy:
call .XItem
jp c, .DontUse
call EnemyUsedXAccuracy
jp .Use
-; 38305
-.GuardSpec: ; 38305
+.GuardSpec:
call .XItem
jp c, .DontUse
call EnemyUsedGuardSpec
jp .Use
-; 38311
-.DireHit: ; 38311
+.DireHit:
call .XItem
jp c, .DontUse
call EnemyUsedDireHit
jp .Use
-; 3831d (e:431d)
-.XAttack: ; 3831d
+.XAttack:
call .XItem
jp c, .DontUse
call EnemyUsedXAttack
jp .Use
-; 38329
-.XDefend: ; 38329
+.XDefend:
call .XItem
jp c, .DontUse
call EnemyUsedXDefend
jp .Use
-; 38335
-.XSpeed: ; 38335
+.XSpeed:
call .XItem
jp c, .DontUse
call EnemyUsedXSpeed
jp .Use
-; 38341
-.XSpecial: ; 38341
+.XSpecial:
call .XItem
jp c, .DontUse
call EnemyUsedXSpecial
jp .Use
-; 3834d
-.XItem: ; 3834d (e:434d)
+.XItem:
ld a, [wEnemyTurnsTaken]
and a
jr nz, .notfirstturnout
@@ -542,8 +516,7 @@ AI_Items: ; 39196
and a
ret
-
-AIUpdateHUD: ; 38387
+AIUpdateHUD:
call UpdateEnemyMonInParty
farcall UpdateEnemyHUD
ld a, $1
@@ -552,29 +525,26 @@ AIUpdateHUD: ; 38387
dec [hl]
scf
ret
-; 3839a
-AIUsedItemSound: ; 3839a
+AIUsedItemSound:
push de
ld de, SFX_FULL_HEAL
call PlaySFX
pop de
ret
-; 383a3
-
-EnemyUsedFullHeal: ; 383a3 (e:43a3)
+EnemyUsedFullHeal:
call AIUsedItemSound
call AI_HealStatus
ld a, FULL_HEAL
jp PrintText_UsedItemOn_AND_AIUpdateHUD
-EnemyUsedMaxPotion: ; 383ae (e:43ae)
+EnemyUsedMaxPotion:
ld a, MAX_POTION
ld [wCurEnemyItem], a
jr FullRestoreContinue
-EnemyUsedFullRestore: ; 383b5 (e:43b5)
+EnemyUsedFullRestore:
call AI_HealStatus
ld a, FULL_RESTORE
ld [wCurEnemyItem], a
@@ -583,7 +553,7 @@ EnemyUsedFullRestore: ; 383b5 (e:43b5)
xor a
ld [wEnemyConfuseCount], a
-FullRestoreContinue: ; 383c6
+FullRestoreContinue:
ld de, wCurHPAnimOldHP
ld hl, wEnemyMonHP + 1
ld a, [hld]
@@ -603,23 +573,22 @@ FullRestoreContinue: ; 383c6
ld [wCurHPAnimMaxHP + 1], a
ld [wEnemyMonHP], a
jr EnemyPotionFinish
-; 383e8 (e:43e8)
-EnemyUsedPotion: ; 383e8
+EnemyUsedPotion:
ld a, POTION
ld b, 20
jr EnemyPotionContinue
-EnemyUsedSuperPotion: ; 383ee
+EnemyUsedSuperPotion:
ld a, SUPER_POTION
ld b, 50
jr EnemyPotionContinue
-EnemyUsedHyperPotion: ; 383f4 (e:43f4)
+EnemyUsedHyperPotion:
ld a, HYPER_POTION
ld b, 200
-EnemyPotionContinue: ; 383f8
+EnemyPotionContinue:
ld [wCurEnemyItem], a
ld hl, wEnemyMonHP + 1
ld a, [hl]
@@ -658,7 +627,7 @@ EnemyPotionContinue: ; 383f8
ld [hl], a
ld [wCurHPAnimNewHP + 1], a
-EnemyPotionFinish: ; 38436
+EnemyPotionFinish:
call PrintText_UsedItemOn
hlcoord 2, 2
xor a
@@ -667,8 +636,7 @@ EnemyPotionFinish: ; 38436
predef AnimateHPBar
jp AIUpdateHUD
-
-AI_TrySwitch: ; 3844b
+AI_TrySwitch:
; Determine whether the AI can switch based on how many Pokemon are still alive.
; If it can switch, it will.
ld a, [wOTPartyCount]
@@ -695,9 +663,8 @@ AI_TrySwitch: ; 3844b
jp nc, AI_Switch
and a
ret
-; 3846c
-AI_Switch: ; 3846c
+AI_Switch:
ld a, $1
ld [wEnemyIsSwitching], a
ld [wEnemyGoesFirst], a
@@ -739,21 +706,18 @@ AI_Switch: ; 3846c
ret nz
scf
ret
-; 384d0
-TextJump_EnemyWithdrew: ; 384d0
+TextJump_EnemyWithdrew:
text_jump Text_EnemyWithdrew
db "@"
-; 384d5
Function384d5: ; This appears to be unused
call AIUsedItemSound
call AI_HealStatus
ld a, FULL_HEAL_RED ; X_SPEED
jp PrintText_UsedItemOn_AND_AIUpdateHUD
-; 384e0
-AI_HealStatus: ; 384e0
+AI_HealStatus:
ld a, [wCurOTMon]
ld hl, wOTPartyMon1Status
ld bc, PARTYMON_STRUCT_LENGTH
@@ -768,31 +732,27 @@ AI_HealStatus: ; 384e0
ld hl, wEnemySubStatus5
res SUBSTATUS_TOXIC, [hl]
ret
-; 384f7
-EnemyUsedXAccuracy: ; 384f7
+EnemyUsedXAccuracy:
call AIUsedItemSound
ld hl, wEnemySubStatus4
set SUBSTATUS_X_ACCURACY, [hl]
ld a, X_ACCURACY
jp PrintText_UsedItemOn_AND_AIUpdateHUD
-; 38504
-EnemyUsedGuardSpec: ; 38504
+EnemyUsedGuardSpec:
call AIUsedItemSound
ld hl, wEnemySubStatus4
set SUBSTATUS_MIST, [hl]
ld a, GUARD_SPEC
jp PrintText_UsedItemOn_AND_AIUpdateHUD
-; 38511
-EnemyUsedDireHit: ; 38511
+EnemyUsedDireHit:
call AIUsedItemSound
ld hl, wEnemySubStatus4
set SUBSTATUS_FOCUS_ENERGY, [hl]
ld a, DIRE_HIT
jp PrintText_UsedItemOn_AND_AIUpdateHUD
-; 3851e
Function3851e: ; This appears to be unused
ld [hDivisor], a
@@ -818,31 +778,26 @@ Function3851e: ; This appears to be unused
ld a, e
sub c
ret
-; 38541
-EnemyUsedXAttack: ; 38541
+EnemyUsedXAttack:
ld b, ATTACK
ld a, X_ATTACK
jr EnemyUsedXItem
-; 38547
-EnemyUsedXDefend: ; 38547
+EnemyUsedXDefend:
ld b, DEFENSE
ld a, X_DEFEND
jr EnemyUsedXItem
-; 3854d
-EnemyUsedXSpeed: ; 3854d
+EnemyUsedXSpeed:
ld b, SPEED
ld a, X_SPEED
jr EnemyUsedXItem
-; 38553
-EnemyUsedXSpecial: ; 38553
+EnemyUsedXSpecial:
ld b, SP_ATTACK
ld a, X_SPECIAL
-
; Parameter
; a = ITEM_CONSTANT
; b = BATTLE_CONSTANT (ATTACK, DEFENSE, SPEED, SP_ATTACK, SP_DEFENSE, ACCURACY, EVASION)
@@ -853,18 +808,15 @@ EnemyUsedXItem:
pop bc
farcall CheckIfStatCanBeRaised
jp AIUpdateHUD
-; 38568
-
; Parameter
; a = ITEM_CONSTANT
-PrintText_UsedItemOn_AND_AIUpdateHUD: ; 38568
+PrintText_UsedItemOn_AND_AIUpdateHUD:
ld [wCurEnemyItem], a
call PrintText_UsedItemOn
jp AIUpdateHUD
-; 38571
-PrintText_UsedItemOn: ; 38571
+PrintText_UsedItemOn:
ld a, [wCurEnemyItem]
ld [wd265], a
call GetItemName
@@ -874,9 +826,7 @@ PrintText_UsedItemOn: ; 38571
call CopyBytes
ld hl, TextJump_EnemyUsedOn
jp PrintText
-; 3858c
-TextJump_EnemyUsedOn: ; 3858c
+TextJump_EnemyUsedOn:
text_jump Text_EnemyUsedOn
db "@"
-; 38591
diff --git a/engine/battle/ai/move.asm b/engine/battle/ai/move.asm
index dd4357fe2..df0053141 100644
--- a/engine/battle/ai/move.asm
+++ b/engine/battle/ai/move.asm
@@ -1,4 +1,4 @@
-AIChooseMove: ; 440ce
+AIChooseMove:
; Score each move in wEnemyMonMoves starting from wBuffer1. Lower is better.
; Pick the move with the lowest score.
@@ -15,7 +15,6 @@ AIChooseMove: ; 440ce
farcall CheckEnemyLockedIn
ret nz
-
; The default score is 20. Unusable moves are given a score of 80.
ld a, 20
ld hl, wBuffer1
@@ -61,7 +60,6 @@ AIChooseMove: ; 440ce
ld [hl], 80
jr .CheckMovePP
-
; Apply AI scoring layers depending on the trainer class.
.ApplyLayers:
ld hl, TrainerClassAttributes + TRNATTR_AI_MOVE_WEIGHTS
@@ -198,10 +196,8 @@ AIChooseMove: ; 440ce
ld a, c
ld [wCurEnemyMoveNum], a
ret
-; 441af
-
-AIScoringPointers: ; 441af
+AIScoringPointers:
; entries correspond to AI_* constants
dw AI_Basic
dw AI_Setup
@@ -219,4 +215,3 @@ AIScoringPointers: ; 441af
dw AI_None
dw AI_None
dw AI_None
-; 441cf
diff --git a/engine/battle/ai/redundant.asm b/engine/battle/ai/redundant.asm
index d09b4da73..d78fccb84 100644
--- a/engine/battle/ai/redundant.asm
+++ b/engine/battle/ai/redundant.asm
@@ -1,4 +1,4 @@
-AI_Redundant: ; 2c41a
+AI_Redundant:
; Check if move effect c will fail because it's already been used.
; Return z if the move is a good choice.
; Return nz if the move is a bad choice.
@@ -13,7 +13,7 @@ AI_Redundant: ; 2c41a
ld l, a
jp hl
-.Moves: ; 2c42c
+.Moves:
dbw EFFECT_DREAM_EATER, .DreamEater
dbw EFFECT_HEAL, .Heal
dbw EFFECT_LIGHT_SCREEN, .LightScreen
@@ -46,22 +46,22 @@ AI_Redundant: ; 2c41a
dbw EFFECT_FUTURE_SIGHT, .FutureSight
db -1
-.LightScreen: ; 2c487
+.LightScreen:
ld a, [wEnemyScreens]
bit SCREENS_LIGHT_SCREEN, a
ret
-.Mist: ; 2c48d
+.Mist:
ld a, [wEnemySubStatus4]
bit SUBSTATUS_MIST, a
ret
-.FocusEnergy: ; 2c493
+.FocusEnergy:
ld a, [wEnemySubStatus4]
bit SUBSTATUS_FOCUS_ENERGY, a
ret
-.Confuse: ; 2c499
+.Confuse:
ld a, [wPlayerSubStatus3]
bit SUBSTATUS_CONFUSED, a
ret nz
@@ -69,49 +69,49 @@ AI_Redundant: ; 2c41a
bit SCREENS_SAFEGUARD, a
ret
-.Transform: ; 2c4a5
+.Transform:
ld a, [wEnemySubStatus5]
bit SUBSTATUS_TRANSFORMED, a
ret
-.Reflect: ; 2c4ab
+.Reflect:
ld a, [wEnemyScreens]
bit SCREENS_REFLECT, a
ret
-.Substitute: ; 2c4b1
+.Substitute:
ld a, [wEnemySubStatus4]
bit SUBSTATUS_SUBSTITUTE, a
ret
-.LeechSeed: ; 2c4b7
+.LeechSeed:
ld a, [wPlayerSubStatus4]
bit SUBSTATUS_LEECH_SEED, a
ret
-.Disable: ; 2c4bd
+.Disable:
ld a, [wPlayerDisableCount]
and a
ret
-.Encore: ; 2c4c2
+.Encore:
ld a, [wPlayerSubStatus5]
bit SUBSTATUS_ENCORED, a
ret
.Snore:
-.SleepTalk: ; 2c4c8
+.SleepTalk:
ld a, [wEnemyMonStatus]
and SLP
jr z, .Redundant
jr .NotRedundant
-.MeanLook: ; 2c4d1
+.MeanLook:
ld a, [wEnemySubStatus5]
bit SUBSTATUS_CANT_RUN, a
ret
-.Nightmare: ; 2c4d7
+.Nightmare:
ld a, [wBattleMonStatus]
and a
jr z, .Redundant
@@ -119,63 +119,63 @@ AI_Redundant: ; 2c41a
bit SUBSTATUS_NIGHTMARE, a
ret
-.Spikes: ; 2c4e3
+.Spikes:
ld a, [wPlayerScreens]
bit SCREENS_SPIKES, a
ret
-.Foresight: ; 2c4e9
+.Foresight:
ld a, [wPlayerSubStatus1]
bit SUBSTATUS_IDENTIFIED, a
ret
-.PerishSong: ; 2c4ef
+.PerishSong:
ld a, [wPlayerSubStatus1]
bit SUBSTATUS_PERISH, a
ret
-.Sandstorm: ; 2c4f5
+.Sandstorm:
ld a, [wBattleWeather]
cp WEATHER_SANDSTORM
jr z, .Redundant
jr .NotRedundant
-.Attract: ; 2c4fe
+.Attract:
farcall CheckOppositeGender
jr c, .Redundant
ld a, [wPlayerSubStatus1]
bit SUBSTATUS_IN_LOVE, a
ret
-.Safeguard: ; 2c50c
+.Safeguard:
ld a, [wEnemyScreens]
bit SCREENS_SAFEGUARD, a
ret
-.RainDance: ; 2c512
+.RainDance:
ld a, [wBattleWeather]
cp WEATHER_RAIN
jr z, .Redundant
jr .NotRedundant
-.SunnyDay: ; 2c51b
+.SunnyDay:
ld a, [wBattleWeather]
cp WEATHER_SUN
jr z, .Redundant
jr .NotRedundant
-.DreamEater: ; 2c524
+.DreamEater:
ld a, [wBattleMonStatus]
and SLP
jr z, .Redundant
jr .NotRedundant
-.Swagger: ; 2c52d
+.Swagger:
ld a, [wPlayerSubStatus3]
bit SUBSTATUS_CONFUSED, a
ret
-.FutureSight: ; 2c533
+.FutureSight:
ld a, [wEnemyScreens]
bit 5, a
ret
@@ -183,16 +183,16 @@ AI_Redundant: ; 2c41a
.Heal:
.MorningSun:
.Synthesis:
-.Moonlight: ; 2c539
+.Moonlight:
farcall AICheckEnemyMaxHP
jr nc, .NotRedundant
.Teleport:
-.Redundant: ; 2c541
+.Redundant:
ld a, 1
and a
ret
-.NotRedundant: ; 2c545
+.NotRedundant:
xor a
ret
diff --git a/engine/battle/ai/scoring.asm b/engine/battle/ai/scoring.asm
index 7af2db8ad..3cd0e56c4 100644
--- a/engine/battle/ai/scoring.asm
+++ b/engine/battle/ai/scoring.asm
@@ -1,6 +1,6 @@
-AIScoring: ; 38591
+AIScoring: ; used only for BANK(AIScoring)
-AI_Basic: ; 38591
+AI_Basic:
; Don't do anything redundant:
; -Using status-only moves if the player can't be statused
; -Using moves that fail if they've already been used
@@ -61,13 +61,11 @@ AI_Basic: ; 38591
.discourage
call AIDiscourageMove
jr .checkmove
-; 385db
INCLUDE "data/battle/ai/status_only_effects.asm"
-
-AI_Setup: ; 385e0
+AI_Setup:
; Use stat-modifying moves on turn 1.
; 50% chance to greatly encourage stat-up moves during the first turn of enemy's Pokemon.
@@ -140,11 +138,9 @@ AI_Setup: ; 385e0
inc [hl]
inc [hl]
jr .checkmove
-; 38635
-
-AI_Types: ; 38635
+AI_Types:
; Dismiss any move that the player is immune to.
; Encourage super-effective moves.
; Discourage not very effective moves unless
@@ -232,11 +228,9 @@ AI_Types: ; 38635
.immune
call AIDiscourageMove
jr .checkmove
-; 386a2
-
-AI_Offensive: ; 386a2
+AI_Offensive:
; Greatly discourage non-damaging moves.
ld hl, wBuffer1 - 1
@@ -261,11 +255,9 @@ AI_Offensive: ; 386a2
inc [hl]
inc [hl]
jr .checkmove
-; 386be
-
-AI_Smart: ; 386be
+AI_Smart:
; Context-specific scoring.
ld hl, wBuffer1
@@ -395,10 +387,8 @@ AI_Smart: ; 386be
dbw EFFECT_THUNDER, AI_Smart_Thunder
dbw EFFECT_FLY, AI_Smart_Fly
db -1 ; end
-; 387e3
-
-AI_Smart_Sleep: ; 387e3
+AI_Smart_Sleep:
; Greatly encourage sleep inducing moves if the enemy has either Dream Eater or Nightmare.
; 50% chance to greatly encourage sleep inducing moves otherwise.
@@ -416,10 +406,8 @@ AI_Smart_Sleep: ; 387e3
dec [hl]
dec [hl]
ret
-; 387f7
-
-AI_Smart_LeechHit: ; 387f7
+AI_Smart_LeechHit:
push hl
ld a, 1
ld [hBattleTurn], a
@@ -452,10 +440,8 @@ AI_Smart_LeechHit: ; 387f7
inc [hl]
ret
-; 3881d
-
-AI_Smart_LockOn: ; 3881d
+AI_Smart_LockOn:
ld a, [wPlayerSubStatus5]
bit SUBSTATUS_LOCK_ON, a
jr nz, .asm_38882
@@ -558,10 +544,8 @@ AI_Smart_LockOn: ; 3881d
.asm_388a2
pop hl
jp AIDiscourageMove
-; 388a6
-
-AI_Smart_Selfdestruct: ; 388a6
+AI_Smart_Selfdestruct:
; Selfdestruct, Explosion
; Unless this is the enemy's last Pokemon...
@@ -596,10 +580,8 @@ AI_Smart_Selfdestruct: ; 388a6
inc [hl]
inc [hl]
ret
-; 388ca
-
-AI_Smart_DreamEater: ; 388ca
+AI_Smart_DreamEater:
; 90% chance to greatly encourage this move.
; The AI_Basic layer will make sure that
; Dream Eater is only used against sleeping targets.
@@ -610,11 +592,8 @@ AI_Smart_DreamEater: ; 388ca
dec [hl]
dec [hl]
ret
-; 388d4
-
-
-AI_Smart_EvasionUp: ; 388d4
+AI_Smart_EvasionUp:
; Dismiss this move if enemy's evasion can't raise anymore.
ld a, [wEnemyEvaLevel]
cp $d
@@ -698,7 +677,6 @@ AI_Smart_EvasionUp: ; 388d4
bit SUBSTATUS_ROLLOUT, a
jr nz, .asm_388ef
-
.asm_38936
inc [hl]
ret
@@ -723,10 +701,8 @@ AI_Smart_EvasionUp: ; 388d4
dec [hl]
ret
-; 38947
-
-AI_Smart_AlwaysHit: ; 38947
+AI_Smart_AlwaysHit:
; 80% chance to greatly encourage this move if either...
; ...enemy's accuracy level has been lowered three or more stages
@@ -746,11 +722,8 @@ AI_Smart_AlwaysHit: ; 38947
dec [hl]
dec [hl]
ret
-; 3895b
-
-
-AI_Smart_MirrorMove: ; 3895b
+AI_Smart_MirrorMove:
; If the player did not use any move last turn...
ld a, [wLastPlayerCounterMove]
and a
@@ -790,11 +763,8 @@ AI_Smart_MirrorMove: ; 3895b
dec [hl]
ret
-; 38985
-
-
-AI_Smart_AccuracyDown: ; 38985
+AI_Smart_AccuracyDown:
; If player's HP is full...
call AICheckPlayerMaxHP
jr nc, .asm_389a0
@@ -897,11 +867,8 @@ AI_Smart_AccuracyDown: ; 38985
dec [hl]
ret
-; 389f5
-
-
-AI_Smart_ResetStats: ; 389f5
+AI_Smart_ResetStats:
; 85% chance to encourage this move if any of enemy's stat levels is lower than -2.
push hl
ld hl, wEnemyAtkLevel
@@ -940,10 +907,8 @@ AI_Smart_ResetStats: ; 389f5
pop hl
inc [hl]
ret
-; 38a1e
-
-AI_Smart_Bide: ; 38a1e
+AI_Smart_Bide:
; 90% chance to discourage this move unless enemy's HP is full.
call AICheckEnemyMaxHP
@@ -953,10 +918,8 @@ AI_Smart_Bide: ; 38a1e
ret c
inc [hl]
ret
-; 38a2a
-
-AI_Smart_ForceSwitch: ; 38a2a
+AI_Smart_ForceSwitch:
; Whirlwind, Roar.
; Discourage this move if the player has not shown
@@ -971,13 +934,11 @@ AI_Smart_ForceSwitch: ; 38a2a
ret c
inc [hl]
ret
-; 38a3a
-
AI_Smart_Heal:
AI_Smart_MorningSun:
AI_Smart_Synthesis:
-AI_Smart_Moonlight: ; 38a3a
+AI_Smart_Moonlight:
; 90% chance to greatly encourage this move if enemy's HP is below 25%.
; Discourage this move if enemy's HP is higher than 50%.
; Do nothing otherwise.
@@ -996,22 +957,18 @@ AI_Smart_Moonlight: ; 38a3a
dec [hl]
dec [hl]
ret
-; 38a4e
-
AI_Smart_Toxic:
-AI_Smart_LeechSeed: ; 38a4e
+AI_Smart_LeechSeed:
; Discourage this move if player's HP is below 50%.
call AICheckPlayerHalfHP
ret c
inc [hl]
ret
-; 38a54
-
AI_Smart_LightScreen:
-AI_Smart_Reflect: ; 38a54
+AI_Smart_Reflect:
; Over 90% chance to discourage this move unless enemy's HP is full.
call AICheckEnemyMaxHP
@@ -1021,10 +978,8 @@ AI_Smart_Reflect: ; 38a54
ret c
inc [hl]
ret
-; 38a60
-
-AI_Smart_Ohko: ; 38a60
+AI_Smart_Ohko:
; Dismiss this move if player's level is higher than enemy's level.
; Else, discourage this move is player's HP is below 50%.
@@ -1037,10 +992,8 @@ AI_Smart_Ohko: ; 38a60
ret c
inc [hl]
ret
-; 38a71
-
-AI_Smart_TrapTarget: ; 38a71
+AI_Smart_TrapTarget:
; Bind, Wrap, Fire Spin, Clamp
; 50% chance to discourage this move if the player is already trapped.
@@ -1055,7 +1008,7 @@ AI_Smart_TrapTarget: ; 38a71
jr nz, .asm_38a91
ld a, [wPlayerSubStatus1]
- and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ROLLOUT | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE
+ and 1 << SUBSTATUS_IN_LOVE | 1 << SUBSTATUS_ROLLOUT | 1 << SUBSTATUS_IDENTIFIED | 1 << SUBSTATUS_NIGHTMARE
jr nz, .asm_38a91
; Else, 50% chance to greatly encourage this move if it's the player's Pokemon first turn.
@@ -1078,11 +1031,9 @@ AI_Smart_TrapTarget: ; 38a71
dec [hl]
dec [hl]
ret
-; 38a9c
-
AI_Smart_RazorWind:
-AI_Smart_Unused2B: ; 38a9c
+AI_Smart_Unused2B:
ld a, [wEnemySubStatus1]
bit SUBSTATUS_PERISH, a
jr z, .asm_38aaa
@@ -1133,11 +1084,8 @@ AI_Smart_Unused2B: ; 38a9c
add 6
ld [hl], a
ret
-; 38adb
-
-
-AI_Smart_Confuse: ; 38adb
+AI_Smart_Confuse:
; 90% chance to discourage this move if player's HP is between 25% and 50%.
call AICheckPlayerHalfHP
ret c
@@ -1152,11 +1100,8 @@ AI_Smart_Confuse: ; 38adb
ret c
inc [hl]
ret
-; 38aed
-
-
-AI_Smart_SpDefenseUp2: ; 38aed
+AI_Smart_SpDefenseUp2:
; Discourage this move if enemy's HP is lower than 50%.
call AICheckEnemyHalfHP
jr nc, .asm_38b10
@@ -1188,10 +1133,8 @@ AI_Smart_SpDefenseUp2: ; 38aed
.asm_38b10
inc [hl]
ret
-; 38b12
-
-AI_Smart_Fly: ; 38b12
+AI_Smart_Fly:
; Fly, Dig
; Greatly encourage this move if the player is
@@ -1208,21 +1151,16 @@ AI_Smart_Fly: ; 38b12
dec [hl]
dec [hl]
ret
-; 38b20
-
-AI_Smart_SuperFang: ; 38b20
+AI_Smart_SuperFang:
; Discourage this move if player's HP is below 25%.
call AICheckPlayerQuarterHP
ret c
inc [hl]
ret
-; 38b26
-
-
-AI_Smart_Paralyze: ; 38b26
+AI_Smart_Paralyze:
; 50% chance to discourage this move if player's HP is below 25%.
call AICheckPlayerQuarterHP
jr nc, .asm_38b3a
@@ -1244,10 +1182,8 @@ AI_Smart_Paralyze: ; 38b26
ret c
inc [hl]
ret
-; 38b40
-
-AI_Smart_SpeedDownHit: ; 38b40
+AI_Smart_SpeedDownHit:
; Icy Wind
; Almost 90% chance to greatly encourage this move if the following conditions all meet:
@@ -1271,19 +1207,15 @@ AI_Smart_SpeedDownHit: ; 38b40
dec [hl]
dec [hl]
ret
-; 38b5c
-
-AI_Smart_Substitute: ; 38b5c
+AI_Smart_Substitute:
; Dismiss this move if enemy's HP is below 50%.
call AICheckEnemyHalfHP
ret c
jp AIDiscourageMove
-; 38b63
-
-AI_Smart_HyperBeam: ; 38b63
+AI_Smart_HyperBeam:
call AICheckEnemyHalfHP
jr c, .asm_38b72
@@ -1305,10 +1237,8 @@ AI_Smart_HyperBeam: ; 38b63
ret c
inc [hl]
ret
-; 38b7f
-
-AI_Smart_Rage: ; 38b7f
+AI_Smart_Rage:
ld a, [wEnemySubStatus4]
bit SUBSTATUS_RAGE, a
jr z, .asm_38b9b
@@ -1345,10 +1275,8 @@ AI_Smart_Rage: ; 38b7f
.asm_38ba6
inc [hl]
ret
-; 38ba8
-
-AI_Smart_Mimic: ; 38ba8
+AI_Smart_Mimic:
ld a, [wLastPlayerCounterMove]
and a
jr z, .asm_38be9
@@ -1396,10 +1324,8 @@ AI_Smart_Mimic: ; 38ba8
.asm_38bef
inc [hl]
ret
-; 38bf1
-
-AI_Smart_Counter: ; 38bf1
+AI_Smart_Counter:
push hl
ld hl, wPlayerUsedMoves
ld c, 4
@@ -1448,7 +1374,6 @@ AI_Smart_Counter: ; 38bf1
cp SPECIAL
jr nc, .asm_38c38
-
.asm_38c30
call Random
cp 39 percent + 1
@@ -1462,10 +1387,8 @@ AI_Smart_Counter: ; 38bf1
.asm_38c39
inc [hl]
ret
-; 38c3b
-
-AI_Smart_Encore: ; 38c3b
+AI_Smart_Encore:
call AICompareSpeed
jr nc, .asm_38c81
@@ -1518,8 +1441,7 @@ AI_Smart_Encore: ; 38c3b
INCLUDE "data/battle/ai/encore_moves.asm"
-
-AI_Smart_PainSplit: ; 38ca4
+AI_Smart_PainSplit:
; Discourage this move if [enemy's current HP * 2 > player's current HP].
push hl
@@ -1538,11 +1460,9 @@ AI_Smart_PainSplit: ; 38ca4
ret nc
inc [hl]
ret
-; 38cba
-
AI_Smart_Snore:
-AI_Smart_SleepTalk: ; 38cba
+AI_Smart_SleepTalk:
; Greatly encourage this move if enemy is fast asleep.
; Greatly discourage this move otherwise.
@@ -1561,24 +1481,20 @@ AI_Smart_SleepTalk: ; 38cba
inc [hl]
inc [hl]
ret
-; 38ccb
-
-AI_Smart_DefrostOpponent: ; 38ccb
+AI_Smart_DefrostOpponent:
; Greatly encourage this move if enemy is frozen.
; No move has EFFECT_DEFROST_OPPONENT, so this layer is unused.
ld a, [wEnemyMonStatus]
- and $20
+ and 1 << FRZ
ret z
dec [hl]
dec [hl]
dec [hl]
ret
-; 38cd5
-
-AI_Smart_Spite: ; 38cd5
+AI_Smart_Spite:
ld a, [wLastPlayerCounterMove]
and a
jr nz, .asm_38ce7
@@ -1633,27 +1549,21 @@ AI_Smart_Spite: ; 38cd5
dec [hl]
dec [hl]
ret
-; 38d16
-
-Function_0x38d16; 38d16
+Function_0x38d16:
jp AIDiscourageMove
-; 38d19
-
AI_Smart_DestinyBond:
AI_Smart_Reversal:
-AI_Smart_SkullBash: ; 38d19
+AI_Smart_SkullBash:
; Discourage this move if enemy's HP is above 25%.
call AICheckEnemyQuarterHP
ret nc
inc [hl]
ret
-; 38d1f
-
-AI_Smart_HealBell: ; 38d1f
+AI_Smart_HealBell:
; Dismiss this move if none of the opponent's Pokemon is statused.
; Encourage this move if the enemy is statused.
; 50% chance to greatly encourage this move if the enemy is fast asleep or frozen.
@@ -1709,10 +1619,8 @@ AI_Smart_HealBell: ; 38d1f
ret nz
jp AIDiscourageMove
-; 38d5a
-
-AI_Smart_PriorityHit: ; 38d5a
+AI_Smart_PriorityHit:
call AICompareSpeed
ret c
@@ -1742,20 +1650,16 @@ AI_Smart_PriorityHit: ; 38d5a
dec [hl]
dec [hl]
ret
-; 38d93
-
-AI_Smart_Thief: ; 38d93
+AI_Smart_Thief:
; Don't use Thief unless it's the only move available.
ld a, [hl]
add $1e
ld [hl], a
ret
-; 38d98
-
-AI_Smart_Conversion2: ; 38d98
+AI_Smart_Conversion2:
ld a, [wLastPlayerMove]
and a
jr nz, .asm_38dc9
@@ -1793,10 +1697,8 @@ AI_Smart_Conversion2: ; 38d98
ret c
inc [hl]
ret
-; 38dd1
-
-AI_Smart_Disable: ; 38dd1
+AI_Smart_Disable:
call AICompareSpeed
jr nc, .asm_38df3
@@ -1826,10 +1728,8 @@ AI_Smart_Disable: ; 38dd1
ret c
inc [hl]
ret
-; 38dfb
-
-AI_Smart_MeanLook: ; 38dfb
+AI_Smart_MeanLook:
call AICheckEnemyHalfHP
jr nc, .asm_38e24
@@ -1847,7 +1747,7 @@ AI_Smart_MeanLook: ; 38dfb
; 80% chance to greatly encourage this move if the player is either
; in love, identified, stuck in Rollout, or has a Nightmare.
ld a, [wPlayerSubStatus1]
- and 1<<SUBSTATUS_IN_LOVE | 1<<SUBSTATUS_ROLLOUT | 1<<SUBSTATUS_IDENTIFIED | 1<<SUBSTATUS_NIGHTMARE
+ and 1 << SUBSTATUS_IN_LOVE | 1 << SUBSTATUS_ROLLOUT | 1 << SUBSTATUS_IDENTIFIED | 1 << SUBSTATUS_NIGHTMARE
jr nz, .asm_38e26
; Otherwise, discourage this move unless the player only has not very effective moves against the enemy.
@@ -1869,10 +1769,8 @@ AI_Smart_MeanLook: ; 38dfb
dec [hl]
dec [hl]
ret
-; 38e2e
-
-AICheckLastPlayerMon: ; 38e2e
+AICheckLastPlayerMon:
ld a, [wPartyCount]
ld b, a
ld c, 0
@@ -1896,10 +1794,8 @@ AICheckLastPlayerMon: ; 38e2e
jr nz, .loop
ret
-; 38e4a
-
-AI_Smart_Nightmare: ; 38e4a
+AI_Smart_Nightmare:
; 50% chance to encourage this move.
; The AI_Basic layer will make sure that
; Dream Eater is only used against sleeping targets.
@@ -1908,10 +1804,8 @@ AI_Smart_Nightmare: ; 38e4a
ret c
dec [hl]
ret
-; 38e50
-
-AI_Smart_FlameWheel: ; 38e50
+AI_Smart_FlameWheel:
; Use this move if the enemy is frozen.
ld a, [wEnemyMonStatus]
@@ -1921,10 +1815,8 @@ rept 5
dec [hl]
endr
ret
-; 38e5c
-
-AI_Smart_Curse: ; 38e5c
+AI_Smart_Curse:
ld a, [wEnemyMonType1]
cp GHOST
jr z, .ghostcurse
@@ -1981,14 +1873,12 @@ AI_Smart_Curse: ; 38e5c
jr .asm_38eb7
-
.asm_38eb0
push hl
call AICheckLastPlayerMon
pop hl
jr z, .asm_38ecb
-
.asm_38eb7
call AICheckEnemyQuarterHP
jp nc, .asm_38e90
@@ -2010,10 +1900,8 @@ AI_Smart_Curse: ; 38e5c
dec [hl]
dec [hl]
ret
-; 38ed2
-
-AI_Smart_Protect: ; 38ed2
+AI_Smart_Protect:
ld a, [wEnemyProtectCount]
and a
jr nz, .asm_38f13
@@ -2063,10 +1951,8 @@ AI_Smart_Protect: ; 38ed2
inc [hl]
inc [hl]
ret
-; 38f1d
-
-AI_Smart_Foresight: ; 38f1d
+AI_Smart_Foresight:
ld a, [wEnemyAccLevel]
cp $5
jr c, .asm_38f41
@@ -2094,10 +1980,8 @@ AI_Smart_Foresight: ; 38f1d
dec [hl]
dec [hl]
ret
-; 38f4a
-
-AI_Smart_PerishSong: ; 38f4a
+AI_Smart_PerishSong:
push hl
callfar FindAliveEnemyMons
pop hl
@@ -2132,11 +2016,8 @@ AI_Smart_PerishSong: ; 38f4a
add 5
ld [hl], a
ret
-; 38f7a
-
-
-AI_Smart_Sandstorm: ; 38f7a
+AI_Smart_Sandstorm:
; Greatly discourage this move if the player is immune to Sandstorm damage.
ld a, [wBattleMonType1]
push hl
@@ -2177,10 +2058,8 @@ AI_Smart_Sandstorm: ; 38f7a
db GROUND
db STEEL
db -1 ; end
-; 38fac
-
-AI_Smart_Endure: ; 38fac
+AI_Smart_Endure:
ld a, [wEnemyProtectCount]
and a
jr nz, .asm_38fd8
@@ -2221,10 +2100,8 @@ AI_Smart_Endure: ; 38fac
.asm_38fd9
inc [hl]
ret
-; 38fdb
-
-AI_Smart_FuryCutter: ; 38fdb
+AI_Smart_FuryCutter:
; Encourage this move based on Fury Cutter's count.
ld a, [wEnemyFuryCutterCount]
@@ -2246,10 +2123,8 @@ AI_Smart_FuryCutter: ; 38fdb
.end
; fallthrough
-; 38fef
-
-AI_Smart_Rollout: ; 38fef
+AI_Smart_Rollout:
; Rollout, Fury Cutter
; 80% chance to discourage this move if the enemy is in love, confused, or paralyzed.
@@ -2290,11 +2165,9 @@ AI_Smart_Rollout: ; 38fef
ret c
inc [hl]
ret
-; 39026
-
AI_Smart_Swagger:
-AI_Smart_Attract: ; 39026
+AI_Smart_Attract:
; 80% chance to encourage this move during the first turn of player's Pokemon.
; 80% chance to discourage this move otherwise.
@@ -2313,10 +2186,8 @@ AI_Smart_Attract: ; 39026
ret nc
dec [hl]
ret
-; 3903a
-
-AI_Smart_Safeguard: ; 3903a
+AI_Smart_Safeguard:
; 80% chance to discourage this move if player's HP is below 50%.
call AICheckPlayerHalfHP
@@ -2325,12 +2196,9 @@ AI_Smart_Safeguard: ; 3903a
ret c
inc [hl]
ret
-; 39044
-
AI_Smart_Magnitude:
-AI_Smart_Earthquake: ; 39044
-
+AI_Smart_Earthquake:
; Greatly encourage this move if the player is underground and the enemy is faster.
ld a, [wLastPlayerCounterMove]
cp DIG
@@ -2358,10 +2226,8 @@ AI_Smart_Earthquake: ; 39044
dec [hl]
ret
-; 39062
-
-AI_Smart_BatonPass: ; 39062
+AI_Smart_BatonPass:
; Discourage this move if the player hasn't shown super-effective moves against the enemy.
; Consider player's type(s) if its moves are unknown.
@@ -2373,10 +2239,8 @@ AI_Smart_BatonPass: ; 39062
ret c
inc [hl]
ret
-; 39072
-
-AI_Smart_Pursuit: ; 39072
+AI_Smart_Pursuit:
; 50% chance to greatly encourage this move if player's HP is below 25%.
; 80% chance to discourage this move otherwise.
@@ -2393,10 +2257,8 @@ AI_Smart_Pursuit: ; 39072
dec [hl]
dec [hl]
ret
-; 39084
-
-AI_Smart_RapidSpin: ; 39084
+AI_Smart_RapidSpin:
; 80% chance to greatly encourage this move if the enemy is
; trapped (Bind effect), seeded, or scattered with spikes.
@@ -2419,10 +2281,8 @@ AI_Smart_RapidSpin: ; 39084
dec [hl]
dec [hl]
ret
-; 3909e
-
-AI_Smart_HiddenPower: ; 3909e
+AI_Smart_HiddenPower:
push hl
ld a, 1
ld [hBattleTurn], a
@@ -2459,11 +2319,8 @@ AI_Smart_HiddenPower: ; 3909e
.bad
inc [hl]
ret
-; 390cb
-
-
-AI_Smart_RainDance: ; 390cb
+AI_Smart_RainDance:
; Greatly discourage this move if it would favour the player type-wise.
; Particularly, if the player is a Water-type.
ld a, [wBattleMonType1]
@@ -2481,13 +2338,10 @@ AI_Smart_RainDance: ; 390cb
push hl
ld hl, RainDanceMoves
jr AI_Smart_WeatherMove
-; 390e7
INCLUDE "data/battle/ai/rain_dance_moves.asm"
-
-AI_Smart_SunnyDay: ; 390f3
-
+AI_Smart_SunnyDay:
; Greatly discourage this move if it would favour the player type-wise.
; Particularly, if the player is a Fire-type.
ld a, [wBattleMonType1]
@@ -2506,10 +2360,8 @@ AI_Smart_SunnyDay: ; 390f3
ld hl, SunnyDayMoves
; fallthrough
-; 3910d
-
-AI_Smart_WeatherMove: ; 3910d
+AI_Smart_WeatherMove:
; Rain Dance, Sunny Day
; Greatly discourage this move if the enemy doesn't have
@@ -2528,16 +2380,14 @@ AI_Smart_WeatherMove: ; 3910d
dec [hl]
ret
-; 3911e
-AIBadWeatherType: ; 3911e
+AIBadWeatherType:
inc [hl]
inc [hl]
inc [hl]
ret
-; 39122
-AIGoodWeatherType: ; 39122
+AIGoodWeatherType:
; Rain Dance, Sunny Day
; Greatly encourage this move if it would disfavour the player type-wise and player's HP is above 50%...
@@ -2559,13 +2409,10 @@ AIGoodWeatherType: ; 39122
dec [hl]
dec [hl]
ret
-; 39134
-
INCLUDE "data/battle/ai/sunny_day_moves.asm"
-
-AI_Smart_BellyDrum: ; 3913d
+AI_Smart_BellyDrum:
; Dismiss this move if enemy's attack is higher than +2 or if enemy's HP is below 50%.
; Else, discourage this move if enemy's HP is not full.
@@ -2586,10 +2433,8 @@ AI_Smart_BellyDrum: ; 3913d
add $5
ld [hl], a
ret
-; 39152
-
-AI_Smart_PsychUp: ; 39152
+AI_Smart_PsychUp:
push hl
ld hl, wEnemyAtkLevel
ld b, $8
@@ -2645,10 +2490,8 @@ AI_Smart_PsychUp: ; 39152
inc [hl]
inc [hl]
ret
-; 3918b
-
-AI_Smart_MirrorCoat: ; 3918b
+AI_Smart_MirrorCoat:
push hl
ld hl, wPlayerUsedMoves
ld c, $4
@@ -2697,7 +2540,6 @@ AI_Smart_MirrorCoat: ; 3918b
cp SPECIAL
jr c, .asm_391d2
-
.asm_391ca
call Random
cp 100
@@ -2710,12 +2552,9 @@ AI_Smart_MirrorCoat: ; 3918b
.asm_391d3
inc [hl]
ret
-; 391d5
-
AI_Smart_Twister:
-AI_Smart_Gust: ; 391d5
-
+AI_Smart_Gust:
; Greatly encourage this move if the player is flying and the enemy is faster.
ld a, [wLastPlayerCounterMove]
cp FLY
@@ -2742,10 +2581,8 @@ AI_Smart_Gust: ; 391d5
ret c
dec [hl]
ret
-; 391f3
-
-AI_Smart_FutureSight: ; 391f3
+AI_Smart_FutureSight:
; Greatly encourage this move if the player is
; flying or underground, and slower than the enemy.
@@ -2759,10 +2596,8 @@ AI_Smart_FutureSight: ; 391f3
dec [hl]
dec [hl]
ret
-; 39200
-
-AI_Smart_Stomp: ; 39200
+AI_Smart_Stomp:
; 80% chance to encourage this move if the player has used Minimize.
ld a, [wPlayerMinimized]
@@ -2774,10 +2609,8 @@ AI_Smart_Stomp: ; 39200
dec [hl]
ret
-; 3920b
-
-AI_Smart_Solarbeam: ; 3920b
+AI_Smart_Solarbeam:
; 80% chance to encourage this move when it's sunny.
; 90% chance to discourage this move when it's raining.
@@ -2803,10 +2636,8 @@ AI_Smart_Solarbeam: ; 3920b
dec [hl]
dec [hl]
ret
-; 39225
-
-AI_Smart_Thunder: ; 39225
+AI_Smart_Thunder:
; 90% chance to discourage this move when it's sunny.
ld a, [wBattleWeather]
@@ -2819,10 +2650,8 @@ AI_Smart_Thunder: ; 39225
inc [hl]
ret
-; 39233
-
-AICompareSpeed: ; 39233
+AICompareSpeed:
; Return carry if enemy is faster than player.
push bc
@@ -2836,30 +2665,24 @@ AICompareSpeed: ; 39233
sbc b
pop bc
ret
-; 39246
-
-AICheckPlayerMaxHP: ; 39246
+AICheckPlayerMaxHP:
push hl
push de
push bc
ld de, wBattleMonHP
ld hl, wBattleMonMaxHP
jr AICheckMaxHP
-; 39251
-
-AICheckEnemyMaxHP: ; 39251
+AICheckEnemyMaxHP:
push hl
push de
push bc
ld de, wEnemyMonHP
ld hl, wEnemyMonMaxHP
; fallthrough
-; 3925a
-
-AICheckMaxHP: ; 3925a
+AICheckMaxHP:
; Return carry if hp at de matches max hp at hl.
ld a, [de]
@@ -2884,10 +2707,8 @@ AICheckMaxHP: ; 3925a
pop hl
and a
ret
-; 3926e
-
-AICheckPlayerHalfHP: ; 3926e
+AICheckPlayerHalfHP:
push hl
ld hl, wBattleMonHP
ld b, [hl]
@@ -2903,10 +2724,8 @@ AICheckPlayerHalfHP: ; 3926e
sbc b
pop hl
ret
-; 39281
-
-AICheckEnemyHalfHP: ; 39281
+AICheckEnemyHalfHP:
push hl
push de
push bc
@@ -2926,10 +2745,8 @@ AICheckEnemyHalfHP: ; 39281
pop de
pop hl
ret
-; 39298
-
-AICheckEnemyQuarterHP: ; 39298
+AICheckEnemyQuarterHP:
push hl
push de
push bc
@@ -2951,10 +2768,8 @@ AICheckEnemyQuarterHP: ; 39298
pop de
pop hl
ret
-; 392b3
-
-AICheckPlayerQuarterHP: ; 392b3
+AICheckPlayerQuarterHP:
push hl
ld hl, wBattleMonHP
ld b, [hl]
@@ -2972,10 +2787,8 @@ AICheckPlayerQuarterHP: ; 392b3
sbc b
pop hl
ret
-; 392ca
-
-AIHasMoveEffect: ; 392ca
+AIHasMoveEffect:
; Return carry if the enemy has move b.
push hl
@@ -3005,10 +2818,8 @@ AIHasMoveEffect: ; 392ca
pop hl
scf
ret
-; 392e6
-
-AIHasMoveInArray: ; 392e6
+AIHasMoveInArray:
; Return carry if the enemy has a move in array hl.
push hl
@@ -3040,13 +2851,10 @@ AIHasMoveInArray: ; 392e6
pop de
pop hl
ret
-; 39301
-
INCLUDE "data/battle/ai/useful_moves.asm"
-
-AI_Opportunist: ; 39315
+AI_Opportunist:
; Discourage stall moves when the enemy's HP is low.
; Do nothing if enemy's HP is above 50%.
@@ -3096,8 +2904,7 @@ AI_Opportunist: ; 39315
INCLUDE "data/battle/ai/stall_moves.asm"
-
-AI_Aggressive: ; 39369
+AI_Aggressive:
; Use whatever does the most damage.
; Discourage all damaging moves but the one that does the most damage.
@@ -3204,8 +3011,7 @@ AI_Aggressive: ; 39369
INCLUDE "data/battle/ai/reckless_moves.asm"
-
-AIDamageCalc: ; 393e7
+AIDamageCalc:
ld a, 1
ld [hBattleTurn], a
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
@@ -3224,8 +3030,7 @@ AIDamageCalc: ; 393e7
INCLUDE "data/battle/ai/constant_damage_effects.asm"
-
-AI_Cautious: ; 39418
+AI_Cautious:
; 90% chance to discourage moves with residual effects after the first turn.
ld a, [wEnemyTurnsTaken]
@@ -3267,8 +3072,7 @@ AI_Cautious: ; 39418
INCLUDE "data/battle/ai/residual_moves.asm"
-
-AI_Status: ; 39453
+AI_Status:
; Dismiss status moves that don't affect the player.
ld hl, wBuffer1 - 1
@@ -3328,11 +3132,9 @@ AI_Status: ; 39453
.immune
call AIDiscourageMove
jr .checkmove
-; 394a9
-
-AI_Risky: ; 394a9
+AI_Risky:
; Use any move that will KO the target.
; Risky moves will often be an exception (see below).
@@ -3401,21 +3203,16 @@ endr
INCLUDE "data/battle/ai/risky_effects.asm"
-
-AI_None: ; 39502
+AI_None:
ret
-; 39503
-
-AIDiscourageMove: ; 39503
+AIDiscourageMove:
ld a, [hl]
add 10
ld [hl], a
ret
-; 39508
-
-AIGetEnemyMove: ; 39508
+AIGetEnemyMove:
; Load attributes of move a into ram
push hl
@@ -3434,18 +3231,13 @@ AIGetEnemyMove: ; 39508
pop de
pop hl
ret
-; 39521
-
-AI_80_20: ; 39521
+AI_80_20:
call Random
cp 20 percent - 1
ret
-; 39527
-
-AI_50_50: ; 39527
+AI_50_50:
call Random
cp 50 percent + 1
ret
-; 3952d
diff --git a/engine/battle/ai/switch.asm b/engine/battle/ai/switch.asm
index d397c8d32..b9bd2ea60 100644
--- a/engine/battle/ai/switch.asm
+++ b/engine/battle/ai/switch.asm
@@ -1,4 +1,4 @@
-CheckPlayerMoveTypeMatchups: ; 3484e
+CheckPlayerMoveTypeMatchups:
; Check how well the moves you've already used
; fare against the enemy's Pokemon. Used to
; score a potential switch.
@@ -95,10 +95,8 @@ CheckPlayerMoveTypeMatchups: ; 3484e
pop de
pop hl
ret
-; 348de
-
-.CheckEnemyMoveMatchups: ; 348de
+.CheckEnemyMoveMatchups:
ld de, wEnemyMonMoves
ld b, NUM_MOVES + 1
ld c, 0
@@ -163,21 +161,19 @@ CheckPlayerMoveTypeMatchups: ; 3484e
.doubledown
call .DecreaseScore
-.DecreaseScore: ; 34931
+.DecreaseScore:
ld a, [wEnemyAISwitchScore]
dec a
ld [wEnemyAISwitchScore], a
ret
-; 34939
-.IncreaseScore: ; 34939
+.IncreaseScore:
ld a, [wEnemyAISwitchScore]
inc a
ld [wEnemyAISwitchScore], a
ret
-; 34941
-CheckAbleToSwitch: ; 34941
+CheckAbleToSwitch:
xor a
ld [wEnemySwitchMonParam], a
call FindAliveEnemyMons
@@ -292,10 +288,8 @@ CheckAbleToSwitch: ; 34941
add $10
ld [wEnemySwitchMonParam], a
ret
-; 349f4
-
-FindAliveEnemyMons: ; 349f4
+FindAliveEnemyMons:
ld a, [wOTPartyCount]
cp 2
jr c, .only_one
@@ -344,10 +338,8 @@ FindAliveEnemyMons: ; 349f4
.more_than_one
and a
ret
-; 34a2a
-
-FindEnemyMonsImmuneToLastCounterMove: ; 34a2a
+FindEnemyMonsImmuneToLastCounterMove:
ld hl, wOTPartyMon1
ld a, [wOTPartyCount]
ld b, a
@@ -412,10 +404,8 @@ FindEnemyMonsImmuneToLastCounterMove: ; 34a2a
inc d
srl c
jr .loop
-; 34a85
-
-FindAliveEnemyMonsWithASuperEffectiveMove: ; 34a85
+FindAliveEnemyMonsWithASuperEffectiveMove:
push bc
ld a, [wOTPartyCount]
ld e, a
@@ -445,8 +435,9 @@ FindAliveEnemyMonsWithASuperEffectiveMove: ; 34a85
and c
ld c, a
-FindEnemyMonsWithASuperEffectiveMove: ; 34aa7
+ ; fallthrough
+FindEnemyMonsWithASuperEffectiveMove:
ld a, -1
ld [wEnemyAISwitchScore], a
ld hl, wOTPartyMon1Moves
@@ -551,10 +542,8 @@ FindEnemyMonsWithASuperEffectiveMove: ; 34aa7
ld [wEnemyAISwitchScore], a
pop bc
ret
-; 34b20
-
-FindEnemyMonsThatResistPlayer: ; 34b20
+FindEnemyMonsThatResistPlayer:
push bc
ld hl, wOTPartySpecies
ld b, 1 << (PARTY_LENGTH - 1)
@@ -613,10 +602,8 @@ FindEnemyMonsThatResistPlayer: ; 34b20
and c
ld c, a
ret
-; 34b77
-
-FindEnemyMonsWithAtLeastQuarterMaxHP: ; 34b77
+FindEnemyMonsWithAtLeastQuarterMaxHP:
push bc
ld de, wOTPartySpecies
ld b, 1 << (PARTY_LENGTH - 1)
@@ -669,4 +656,3 @@ FindEnemyMonsWithAtLeastQuarterMaxHP: ; 34b77
and c
ld c, a
ret
-; 34bb1