summaryrefslogtreecommitdiff
path: root/battle/ai/scoring.asm
diff options
context:
space:
mode:
Diffstat (limited to 'battle/ai/scoring.asm')
-rw-r--r--battle/ai/scoring.asm606
1 files changed, 311 insertions, 295 deletions
diff --git a/battle/ai/scoring.asm b/battle/ai/scoring.asm
index bf4b660e5..52112faf6 100644
--- a/battle/ai/scoring.asm
+++ b/battle/ai/scoring.asm
@@ -1,5 +1,7 @@
-AIScoring_RedStatus: ; 38591
-; Handle the AI of status-only moves and moves with special effects.
+AI_Basic: ; 38591
+; 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
ld hl, Buffer1 - 1
ld de, EnemyMonMoves
@@ -25,7 +27,7 @@ AIScoring_RedStatus: ; 38591
push hl
push de
push bc
- callba AISpecialEffects
+ callba AI_Redundant
pop bc
pop de
pop hl
@@ -69,7 +71,9 @@ AIScoring_RedStatus: ; 38591
-AIScoring_RedStatMods: ; 385e0
+AI_Setup: ; 385e0
+; Use stat-modifying moves on turn 1.
+
; 50% chance to greatly encourage stat-up moves during the first turn of enemy's Pokemon.
; 50% chance to greatly encourage stat-down moves during the first turn of player's Pokemon.
; Almost 90% chance to greatly discourage stat-modifying moves otherwise.
@@ -97,7 +101,7 @@ AIScoring_RedStatMods: ; 385e0
jr c, .statup
; cp EFFECT_ATTACK_DOWN - 1
- jr z, .checkmove ; ignore EFFECT_ALWAYS_HIT
+ jr z, .checkmove
cp EFFECT_EVASION_DOWN + 1
jr c, .statdown
@@ -107,7 +111,7 @@ AIScoring_RedStatMods: ; 385e0
jr c, .statup
; cp EFFECT_ATTACK_DOWN_2 - 1
- jr z, .checkmove ; ignore EFFECT_TRANSFROM
+ jr z, .checkmove
cp EFFECT_EVASION_DOWN_2 + 1
jr c, .statdown
@@ -126,7 +130,7 @@ AIScoring_RedStatMods: ; 385e0
jr nz, .discourage
.encourage
- call AIRandom2
+ call AI_50_50
jr c, .checkmove
dec [hl]
@@ -144,7 +148,7 @@ AIScoring_RedStatMods: ; 385e0
-AIScoring_RedSuperEffective: ; 38635
+AI_Types: ; 38635
; Dismiss any move that the player is immune to.
; Encourage super-effective moves.
; Discourage not very effective moves unless
@@ -236,7 +240,7 @@ AIScoring_RedSuperEffective: ; 38635
-AIScoring_Offensive: ; 386a2
+AI_Offensive: ; 386a2
; Greatly discourage non-damaging moves.
ld hl, Buffer1 - 1
@@ -265,7 +269,7 @@ AIScoring_Offensive: ; 386a2
-AIScoring_Smart: ; 386be
+AI_Smart: ; 386be
; Context-specific scoring.
ld hl, Buffer1
@@ -314,104 +318,104 @@ AIScoring_Smart: ; 386be
jr .checkmove
.table_386f2
- dbw EFFECT_SLEEP, AIScoring_Sleep
- dbw EFFECT_LEECH_HIT, AIScoring_LeechHit
- dbw EFFECT_EXPLOSION, AIScoring_Explosion
- dbw EFFECT_DREAM_EATER, AIScoring_DreamEater
- dbw EFFECT_MIRROR_MOVE, AIScoring_MirrorMove
- dbw EFFECT_EVASION_UP, AIScoring_EvasionUp
- dbw EFFECT_ALWAYS_HIT, AIScoring_AlwaysHit
- dbw EFFECT_ACCURACY_DOWN, AIScoring_AccuracyDown
- dbw EFFECT_HAZE, AIScoring_Haze
- dbw EFFECT_BIDE, AIScoring_Bide
- dbw EFFECT_WHIRLWIND, AIScoring_Whirlwind
- dbw EFFECT_HEAL, AIScoring_Heal
- dbw EFFECT_TOXIC, AIScoring_Toxic
- dbw EFFECT_LIGHT_SCREEN, AIScoring_LightScreen
- dbw EFFECT_OHKO, AIScoring_Ohko
- dbw EFFECT_RAZOR_WIND, AIScoring_RazorWind
- dbw EFFECT_SUPER_FANG, AIScoring_SuperFang
- dbw EFFECT_BIND, AIScoring_Bind
- dbw EFFECT_UNUSED_2B, AIScoring_Unused2B
- dbw EFFECT_CONFUSE, AIScoring_Confuse
- dbw EFFECT_SP_DEF_UP_2, AIScoring_SpDefenseUp2
- dbw EFFECT_REFLECT, AIScoring_Reflect
- dbw EFFECT_PARALYZE, AIScoring_Paralyze
- dbw EFFECT_SPEED_DOWN_HIT, AIScoring_SpeedDownHit
- dbw EFFECT_SUBSTITUTE, AIScoring_Substitute
- dbw EFFECT_HYPER_BEAM, AIScoring_HyperBeam
- dbw EFFECT_RAGE, AIScoring_Rage
- dbw EFFECT_MIMIC, AIScoring_Mimic
- dbw EFFECT_LEECH_SEED, AIScoring_LeechSeed
- dbw EFFECT_DISABLE, AIScoring_Disable
- dbw EFFECT_COUNTER, AIScoring_Counter
- dbw EFFECT_ENCORE, AIScoring_Encore
- dbw EFFECT_PAIN_SPLIT, AIScoring_PainSplit
- dbw EFFECT_SNORE, AIScoring_Snore
- dbw EFFECT_CONVERSION2, AIScoring_Conversion2
- dbw EFFECT_LOCK_ON, AIScoring_LockOn
- dbw EFFECT_DEFROST_OPPONENT, AIScoring_DefrostOpponent
- dbw EFFECT_SLEEP_TALK, AIScoring_SleepTalk
- dbw EFFECT_DESTINY_BOND, AIScoring_DestinyBond
- dbw EFFECT_REVERSAL, AIScoring_Reversal
- dbw EFFECT_SPITE, AIScoring_Spite
- dbw EFFECT_HEAL_BELL, AIScoring_HealBell
- dbw EFFECT_PRIORITY_HIT, AIScoring_PriorityHit
- dbw EFFECT_THIEF, AIScoring_Thief
- dbw EFFECT_MEAN_LOOK, AIScoring_MeanLook
- dbw EFFECT_NIGHTMARE, AIScoring_Nightmare
- dbw EFFECT_FLAME_WHEEL, AIScoring_FlameWheel
- dbw EFFECT_CURSE, AIScoring_Curse
- dbw EFFECT_PROTECT, AIScoring_Protect
- dbw EFFECT_FORESIGHT, AIScoring_Foresight
- dbw EFFECT_PERISH_SONG, AIScoring_PerishSong
- dbw EFFECT_SANDSTORM, AIScoring_Sandstorm
- dbw EFFECT_ENDURE, AIScoring_Endure
- dbw EFFECT_ROLLOUT, AIScoring_Rollout
- dbw EFFECT_SWAGGER, AIScoring_Swagger
- dbw EFFECT_FURY_CUTTER, AIScoring_FuryCutter
- dbw EFFECT_ATTRACT, AIScoring_Attract
- dbw EFFECT_SAFEGUARD, AIScoring_Safeguard
- dbw EFFECT_MAGNITUDE, AIScoring_Magnitude
- dbw EFFECT_BATON_PASS, AIScoring_BatonPass
- dbw EFFECT_PURSUIT, AIScoring_Pursuit
- dbw EFFECT_RAPID_SPIN, AIScoring_RapidSpin
- dbw EFFECT_MORNING_SUN, AIScoring_MorningSun
- dbw EFFECT_SYNTHESIS, AIScoring_Synthesis
- dbw EFFECT_MOONLIGHT, AIScoring_Moonlight
- dbw EFFECT_HIDDEN_POWER, AIScoring_HiddenPower
- dbw EFFECT_RAIN_DANCE, AIScoring_RainDance
- dbw EFFECT_SUNNY_DAY, AIScoring_SunnyDay
- dbw EFFECT_BELLY_DRUM, AIScoring_BellyDrum
- dbw EFFECT_PSYCH_UP, AIScoring_PsychUp
- dbw EFFECT_MIRROR_COAT, AIScoring_MirrorCoat
- dbw EFFECT_SKULL_BASH, AIScoring_SkullBash
- dbw EFFECT_TWISTER, AIScoring_Twister
- dbw EFFECT_EARTHQUAKE, AIScoring_Earthquake
- dbw EFFECT_FUTURE_SIGHT, AIScoring_FutureSight
- dbw EFFECT_GUST, AIScoring_Gust
- dbw EFFECT_STOMP, AIScoring_Stomp
- dbw EFFECT_SOLARBEAM, AIScoring_Solarbeam
- dbw EFFECT_THUNDER, AIScoring_Thunder
- dbw EFFECT_FLY, AIScoring_Fly
+ dbw EFFECT_SLEEP, AI_Smart_Sleep
+ dbw EFFECT_LEECH_HIT, AI_Smart_LeechHit
+ dbw EFFECT_EXPLOSION, AI_Smart_Explosion
+ dbw EFFECT_DREAM_EATER, AI_Smart_DreamEater
+ dbw EFFECT_MIRROR_MOVE, AI_Smart_MirrorMove
+ dbw EFFECT_EVASION_UP, AI_Smart_EvasionUp
+ dbw EFFECT_ALWAYS_HIT, AI_Smart_AlwaysHit
+ dbw EFFECT_ACCURACY_DOWN, AI_Smart_AccuracyDown
+ dbw EFFECT_HAZE, AI_Smart_Haze
+ dbw EFFECT_BIDE, AI_Smart_Bide
+ dbw EFFECT_WHIRLWIND, AI_Smart_Whirlwind
+ dbw EFFECT_HEAL, AI_Smart_Heal
+ dbw EFFECT_TOXIC, AI_Smart_Toxic
+ dbw EFFECT_LIGHT_SCREEN, AI_Smart_LightScreen
+ dbw EFFECT_OHKO, AI_Smart_Ohko
+ dbw EFFECT_RAZOR_WIND, AI_Smart_RazorWind
+ dbw EFFECT_SUPER_FANG, AI_Smart_SuperFang
+ dbw EFFECT_BIND, AI_Smart_Bind
+ dbw EFFECT_UNUSED_2B, AI_Smart_Unused2B
+ dbw EFFECT_CONFUSE, AI_Smart_Confuse
+ dbw EFFECT_SP_DEF_UP_2, AI_Smart_SpDefenseUp2
+ dbw EFFECT_REFLECT, AI_Smart_Reflect
+ dbw EFFECT_PARALYZE, AI_Smart_Paralyze
+ dbw EFFECT_SPEED_DOWN_HIT, AI_Smart_SpeedDownHit
+ dbw EFFECT_SUBSTITUTE, AI_Smart_Substitute
+ dbw EFFECT_HYPER_BEAM, AI_Smart_HyperBeam
+ dbw EFFECT_RAGE, AI_Smart_Rage
+ dbw EFFECT_MIMIC, AI_Smart_Mimic
+ dbw EFFECT_LEECH_SEED, AI_Smart_LeechSeed
+ dbw EFFECT_DISABLE, AI_Smart_Disable
+ dbw EFFECT_COUNTER, AI_Smart_Counter
+ dbw EFFECT_ENCORE, AI_Smart_Encore
+ dbw EFFECT_PAIN_SPLIT, AI_Smart_PainSplit
+ dbw EFFECT_SNORE, AI_Smart_Snore
+ dbw EFFECT_CONVERSION2, AI_Smart_Conversion2
+ dbw EFFECT_LOCK_ON, AI_Smart_LockOn
+ dbw EFFECT_DEFROST_OPPONENT, AI_Smart_DefrostOpponent
+ dbw EFFECT_SLEEP_TALK, AI_Smart_SleepTalk
+ dbw EFFECT_DESTINY_BOND, AI_Smart_DestinyBond
+ dbw EFFECT_REVERSAL, AI_Smart_Reversal
+ dbw EFFECT_SPITE, AI_Smart_Spite
+ dbw EFFECT_HEAL_BELL, AI_Smart_HealBell
+ dbw EFFECT_PRIORITY_HIT, AI_Smart_PriorityHit
+ dbw EFFECT_THIEF, AI_Smart_Thief
+ dbw EFFECT_MEAN_LOOK, AI_Smart_MeanLook
+ dbw EFFECT_NIGHTMARE, AI_Smart_Nightmare
+ dbw EFFECT_FLAME_WHEEL, AI_Smart_FlameWheel
+ dbw EFFECT_CURSE, AI_Smart_Curse
+ dbw EFFECT_PROTECT, AI_Smart_Protect
+ dbw EFFECT_FORESIGHT, AI_Smart_Foresight
+ dbw EFFECT_PERISH_SONG, AI_Smart_PerishSong
+ dbw EFFECT_SANDSTORM, AI_Smart_Sandstorm
+ dbw EFFECT_ENDURE, AI_Smart_Endure
+ dbw EFFECT_ROLLOUT, AI_Smart_Rollout
+ dbw EFFECT_SWAGGER, AI_Smart_Swagger
+ dbw EFFECT_FURY_CUTTER, AI_Smart_FuryCutter
+ dbw EFFECT_ATTRACT, AI_Smart_Attract
+ dbw EFFECT_SAFEGUARD, AI_Smart_Safeguard
+ dbw EFFECT_MAGNITUDE, AI_Smart_Magnitude
+ dbw EFFECT_BATON_PASS, AI_Smart_BatonPass
+ dbw EFFECT_PURSUIT, AI_Smart_Pursuit
+ dbw EFFECT_RAPID_SPIN, AI_Smart_RapidSpin
+ dbw EFFECT_MORNING_SUN, AI_Smart_MorningSun
+ dbw EFFECT_SYNTHESIS, AI_Smart_Synthesis
+ dbw EFFECT_MOONLIGHT, AI_Smart_Moonlight
+ dbw EFFECT_HIDDEN_POWER, AI_Smart_HiddenPower
+ dbw EFFECT_RAIN_DANCE, AI_Smart_RainDance
+ dbw EFFECT_SUNNY_DAY, AI_Smart_SunnyDay
+ dbw EFFECT_BELLY_DRUM, AI_Smart_BellyDrum
+ dbw EFFECT_PSYCH_UP, AI_Smart_PsychUp
+ dbw EFFECT_MIRROR_COAT, AI_Smart_MirrorCoat
+ dbw EFFECT_SKULL_BASH, AI_Smart_SkullBash
+ dbw EFFECT_TWISTER, AI_Smart_Twister
+ dbw EFFECT_EARTHQUAKE, AI_Smart_Earthquake
+ dbw EFFECT_FUTURE_SIGHT, AI_Smart_FutureSight
+ dbw EFFECT_GUST, AI_Smart_Gust
+ dbw EFFECT_STOMP, AI_Smart_Stomp
+ dbw EFFECT_SOLARBEAM, AI_Smart_Solarbeam
+ dbw EFFECT_THUNDER, AI_Smart_Thunder
+ dbw EFFECT_FLY, AI_Smart_Fly
db $ff
; 387e3
-AIScoring_Sleep: ; 387e3
+AI_Smart_Sleep: ; 387e3
; Greatly encourage sleep inducing moves if the enemy has either Dream Eater or Nightmare.
; 50% chance to greatly encourage sleep inducing moves otherwise.
ld b, EFFECT_DREAM_EATER
- call AIHasMove
+ call AIHasMoveEffect
jr c, .asm_387f0
ld b, EFFECT_NIGHTMARE
- call AIHasMove
+ call AIHasMoveEffect
ret nc
.asm_387f0
- call AIRandom2
+ call AI_50_50
ret c
dec [hl]
dec [hl]
@@ -419,7 +423,7 @@ AIScoring_Sleep: ; 387e3
; 387f7
-AIScoring_LeechHit: ; 387f7
+AI_Smart_LeechHit: ; 387f7
push hl
ld a, 1
ld [hBattleTurn], a
@@ -439,22 +443,23 @@ AIScoring_LeechHit: ; 387f7
ret c
; 80% chance to encourage this move otherwise.
- call AIRandom1
+ call AI_80_20
ret c
+
dec [hl]
ret
.asm_38815
call Random
-
- cp $64
+ cp 100
ret c
+
inc [hl]
ret
; 3881d
-AIScoring_LockOn: ; 3881d
+AI_Smart_LockOn: ; 3881d
ld a, [PlayerSubStatus5]
bit SUBSTATUS_LOCK_ON, a
jr nz, .asm_38882
@@ -521,7 +526,7 @@ AIScoring_LockOn: ; 3881d
.asm_3887a
pop hl
- call AIRandom2
+ call AI_50_50
ret c
dec [hl]
@@ -560,12 +565,12 @@ AIScoring_LockOn: ; 3881d
; 388a6
-AIScoring_Explosion: ; 388a6
+AI_Smart_Explosion: ; 388a6
; Selfdestruct, Explosion
; Unless this is the enemy's last Pokemon...
push hl
- callba Function349f4
+ callba CountEnemyAliveMons
pop hl
jr nc, .asm_388b7
@@ -598,12 +603,12 @@ AIScoring_Explosion: ; 388a6
; 388ca
-AIScoring_DreamEater: ; 388ca
+AI_Smart_DreamEater: ; 388ca
; 90% chance to greatly encourage this move.
-; The AIScoring_RedStatus layer will make sure that
+; The AI_Basic layer will make sure that
; Dream Eater is only used against sleeping targets.
call Random
- cp $19
+ cp 25
ret c
dec [hl]
dec [hl]
@@ -612,7 +617,7 @@ AIScoring_DreamEater: ; 388ca
; 388d4
-AIScoring_EvasionUp: ; 388d4
+AI_Smart_EvasionUp: ; 388d4
; Dismiss this move if enemy's evasion can't raise anymore.
ld a, [EnemyEvaLevel]
@@ -627,7 +632,7 @@ AIScoring_EvasionUp: ; 388d4
ld a, [PlayerSubStatus5]
bit SUBSTATUS_TOXIC, a
jr nz, .asm_388ef
-
+
; ...70% chance to greatly encourage this move if player is not badly poisoned.
call Random
cp $b2
@@ -654,13 +659,13 @@ AIScoring_EvasionUp: ; 388d4
jr nc, .asm_3890a
; If enemy's HP is above 50% but not full, 20% chance to greatly encourage this move.
- call AIRandom1
+ call AI_80_20
jr c, .asm_388ef
jr .asm_38911
.asm_3890a
; ...50% chance to greatly discourage this move.
- call AIRandom2
+ call AI_50_50
jr c, .asm_38911
.asm_3890f
@@ -717,7 +722,7 @@ AIScoring_EvasionUp: ; 388d4
; 50% chance to encourage this move.
; This would partly counter any previous discouragement.
.asm_38941
- call AIRandom2
+ call AI_50_50
ret c
dec [hl]
@@ -725,7 +730,7 @@ AIScoring_EvasionUp: ; 388d4
; 38947
-AIScoring_AlwaysHit: ; 38947
+AI_Smart_AlwaysHit: ; 38947
; 80% chance to greatly encourage this move if either...
; ...enemy's accuracy level has been lowered three or more stages
@@ -739,16 +744,16 @@ AIScoring_AlwaysHit: ; 38947
ret c
.asm_38954
- call AIRandom1
-
+ call AI_80_20
ret c
+
dec [hl]
dec [hl]
ret
; 3895b
-AIScoring_MirrorMove: ; 3895b
+AI_Smart_MirrorMove: ; 3895b
; If the player did not use any move last turn...
ld a, [LastEnemyCounterMove]
@@ -758,7 +763,7 @@ AIScoring_MirrorMove: ; 3895b
; ...do nothing if enemy is slower than player
call AICompareSpeed
ret nc
-
+
; ...or dismiss this move if enemy is faster than player.
jp AIDiscourageMove
@@ -774,8 +779,9 @@ AIScoring_MirrorMove: ; 3895b
ret nc
; If he did, 50% chance to encourage this move...
- call AIRandom2
+ call AI_50_50
ret c
+
dec [hl]
; ...and 90% chance to encourage this move again if the enemy is faster.
@@ -791,7 +797,7 @@ AIScoring_MirrorMove: ; 3895b
; 38985
-AIScoring_AccuracyDown: ; 38985
+AI_Smart_AccuracyDown: ; 38985
; If player's HP is full...
call AICheckPlayerMaxHP
@@ -832,13 +838,13 @@ AIScoring_AccuracyDown: ; 38985
jr nc, .asm_389b8
; If player's HP is above 50% but not full, 20% chance to greatly encourage this move.
- call AIRandom1
+ call AI_80_20
jr c, .asm_3899d
jr .asm_389bf
; ...50% chance to greatly discourage this move.
.asm_389b8
- call AIRandom2
+ call AI_50_50
jr c, .asm_389bf
.asm_389bd
@@ -890,7 +896,7 @@ AIScoring_AccuracyDown: ; 38985
; 50% chance to encourage this move.
; This would partly counter any previous discouragement.
.asm_389ef
- call AIRandom2
+ call AI_50_50
ret c
dec [hl]
@@ -898,7 +904,7 @@ AIScoring_AccuracyDown: ; 38985
; 389f5
-AIScoring_Haze: ; 389f5
+AI_Smart_Haze: ; 389f5
; 85% chance to encourage this move if any of enemy's stat levels is lower than -2.
push hl
@@ -941,7 +947,7 @@ AIScoring_Haze: ; 389f5
; 38a1e
-AIScoring_Bide: ; 38a1e
+AI_Smart_Bide: ; 38a1e
; 90% chance to discourage this move unless enemy's HP is full.
call AICheckEnemyMaxHP
@@ -954,7 +960,7 @@ AIScoring_Bide: ; 38a1e
; 38a2a
-AIScoring_Whirlwind: ; 38a2a
+AI_Smart_Whirlwind: ; 38a2a
; Whirlwind, Roar.
; Discourage this move if the player has not shown
@@ -972,10 +978,10 @@ AIScoring_Whirlwind: ; 38a2a
; 38a3a
-AIScoring_Heal:
-AIScoring_MorningSun:
-AIScoring_Synthesis:
-AIScoring_Moonlight: ; 38a3a
+AI_Smart_Heal:
+AI_Smart_MorningSun:
+AI_Smart_Synthesis:
+AI_Smart_Moonlight: ; 38a3a
; 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.
@@ -997,8 +1003,8 @@ AIScoring_Moonlight: ; 38a3a
; 38a4e
-AIScoring_Toxic:
-AIScoring_LeechSeed: ; 38a4e
+AI_Smart_Toxic:
+AI_Smart_LeechSeed: ; 38a4e
; Discourage this move if player's HP is below 50%.
call AICheckPlayerHalfHP
@@ -1008,8 +1014,8 @@ AIScoring_LeechSeed: ; 38a4e
; 38a54
-AIScoring_LightScreen:
-AIScoring_Reflect: ; 38a54
+AI_Smart_LightScreen:
+AI_Smart_Reflect: ; 38a54
; Over 90% chance to discourage this move unless enemy's HP is full.
call AICheckEnemyMaxHP
@@ -1022,7 +1028,7 @@ AIScoring_Reflect: ; 38a54
; 38a60
-AIScoring_Ohko: ; 38a60
+AI_Smart_Ohko: ; 38a60
; Dismiss this move if player's level is higher than enemy's level.
; Else, discourage this move is player's HP is below 50%.
@@ -1038,7 +1044,7 @@ AIScoring_Ohko: ; 38a60
; 38a71
-AIScoring_Bind: ; 38a71
+AI_Smart_Bind: ; 38a71
; Bind, Wrap, Fire Spin, Clamp
; 50% chance to discourage this move if the player is already trapped.
@@ -1063,7 +1069,7 @@ AIScoring_Bind: ; 38a71
; 50% chance to discourage this move otherwise.
.asm_38a8b
- call AIRandom2
+ call AI_50_50
ret c
inc [hl]
ret
@@ -1071,7 +1077,7 @@ AIScoring_Bind: ; 38a71
.asm_38a91
call AICheckEnemyQuarterHP
ret nc
- call AIRandom2
+ call AI_50_50
ret c
dec [hl]
dec [hl]
@@ -1079,8 +1085,8 @@ AIScoring_Bind: ; 38a71
; 38a9c
-AIScoring_RazorWind:
-AIScoring_Unused2B: ; 38a9c
+AI_Smart_RazorWind:
+AI_Smart_Unused2B: ; 38a9c
ld a, [EnemySubStatus1]
bit SUBSTATUS_PERISH, a
jr z, .asm_38aaa
@@ -1134,7 +1140,7 @@ AIScoring_Unused2B: ; 38a9c
; 38adb
-AIScoring_Confuse: ; 38adb
+AI_Smart_Confuse: ; 38adb
; 90% chance to discourage this move if player's HP is between 25% and 50%.
call AICheckPlayerHalfHP
@@ -1153,7 +1159,7 @@ AIScoring_Confuse: ; 38adb
; 38aed
-AIScoring_SpDefenseUp2: ; 38aed
+AI_Smart_SpDefenseUp2: ; 38aed
; Discourage this move if enemy's HP is lower than 50%.
call AICheckEnemyHalfHP
@@ -1168,6 +1174,7 @@ AIScoring_SpDefenseUp2: ; 38aed
; enemy's Special Defense level is lower than +2, and the player is of a special type.
cp $9
ret nc
+
ld a, [BattleMonType1]
cp SPECIAL
jr nc, .asm_38b09
@@ -1176,7 +1183,7 @@ AIScoring_SpDefenseUp2: ; 38aed
ret c
.asm_38b09
- call AIRandom1
+ call AI_80_20
ret c
dec [hl]
dec [hl]
@@ -1188,7 +1195,7 @@ AIScoring_SpDefenseUp2: ; 38aed
; 38b12
-AIScoring_Fly: ; 38b12
+AI_Smart_Fly: ; 38b12
; Fly, Dig
; Greatly encourage this move if the player is
@@ -1208,7 +1215,7 @@ AIScoring_Fly: ; 38b12
; 38b20
-AIScoring_SuperFang: ; 38b20
+AI_Smart_SuperFang: ; 38b20
; Discourage this move if player's HP is below 25%.
call AICheckPlayerQuarterHP
@@ -1218,7 +1225,7 @@ AIScoring_SuperFang: ; 38b20
; 38b26
-AIScoring_Paralyze: ; 38b26
+AI_Smart_Paralyze: ; 38b26
; 50% chance to discourage this move if player's HP is below 25%.
call AICheckPlayerQuarterHP
@@ -1230,21 +1237,21 @@ AIScoring_Paralyze: ; 38b26
ret c
call AICheckEnemyQuarterHP
ret nc
- call AIRandom1
+ call AI_80_20
ret c
dec [hl]
dec [hl]
ret
.asm_38b3a
- call AIRandom2
+ call AI_50_50
ret c
inc [hl]
ret
; 38b40
-AIScoring_SpeedDownHit: ; 38b40
+AI_Smart_SpeedDownHit: ; 38b40
; Icy Wind
; Almost 90% chance to greatly encourage this move if the following conditions all meet:
@@ -1271,7 +1278,7 @@ AIScoring_SpeedDownHit: ; 38b40
; 38b5c
-AIScoring_Substitute: ; 38b5c
+AI_Smart_Substitute: ; 38b5c
; Dismiss this move if enemy's HP is below 50%.
call AICheckEnemyHalfHP
@@ -1280,14 +1287,14 @@ AIScoring_Substitute: ; 38b5c
; 38b63
-AIScoring_HyperBeam: ; 38b63
+AI_Smart_HyperBeam: ; 38b63
call AICheckEnemyHalfHP
jr c, .asm_38b72
; 50% chance to encourage this move if enemy's HP is below 25%.
call AICheckEnemyQuarterHP
ret c
- call AIRandom2
+ call AI_50_50
ret c
dec [hl]
ret
@@ -1298,21 +1305,22 @@ AIScoring_HyperBeam: ; 38b63
cp 40
ret c
inc [hl]
- call AIRandom2
+ call AI_50_50
ret c
inc [hl]
ret
; 38b7f
-AIScoring_Rage: ; 38b7f
+AI_Smart_Rage: ; 38b7f
ld a, [EnemySubStatus4]
bit SUBSTATUS_RAGE, a
jr z, .asm_38b9b
; If enemy's Rage is building, 50% chance to encourage this move.
- call AIRandom2
+ call AI_50_50
jr c, .asm_38b8c
+
dec [hl]
; Encourage this move based on Rage's counter.
@@ -1333,7 +1341,7 @@ AIScoring_Rage: ; 38b7f
jr nc, .asm_38ba6
; 50% chance to encourage this move otherwise.
- call AIRandom1
+ call AI_80_20
ret nc
dec [hl]
ret
@@ -1344,7 +1352,7 @@ AIScoring_Rage: ; 38b7f
; 38ba8
-AIScoring_Mimic: ; 38ba8
+AI_Smart_Mimic: ; 38ba8
ld a, [LastEnemyCounterMove]
and a
jr z, .asm_38be9
@@ -1366,7 +1374,7 @@ AIScoring_Mimic: ; 38ba8
jr c, .asm_38bef
jr z, .asm_38bd4
- call AIRandom2
+ call AI_50_50
jr c, .asm_38bd4
dec [hl]
@@ -1380,7 +1388,7 @@ AIScoring_Mimic: ; 38ba8
pop hl
ret nc
- call AIRandom2
+ call AI_50_50
ret c
dec [hl]
ret
@@ -1395,7 +1403,7 @@ AIScoring_Mimic: ; 38ba8
; 38bf1
-AIScoring_Counter: ; 38bf1
+AI_Smart_Counter: ; 38bf1
push hl
ld hl, PlayerUsedMoves
ld c, 4
@@ -1461,7 +1469,7 @@ AIScoring_Counter: ; 38bf1
; 38c3b
-AIScoring_Encore: ; 38c3b
+AI_Smart_Encore: ; 38c3b
call AICompareSpeed
jr nc, .asm_38c81
@@ -1492,7 +1500,7 @@ AIScoring_Encore: ; 38c3b
.asm_38c68
push hl
ld a, [LastEnemyCounterMove]
- ld hl, .encoremoves
+ ld hl, .EncoreMoves
ld de, 1
call IsInArray
pop hl
@@ -1512,7 +1520,7 @@ AIScoring_Encore: ; 38c3b
inc [hl]
ret
-.encoremoves
+.EncoreMoves:
db SWORDS_DANCE
db WHIRLWIND
db LEER
@@ -1547,7 +1555,7 @@ AIScoring_Encore: ; 38c3b
; 38ca4
-AIScoring_PainSplit: ; 38ca4
+AI_Smart_PainSplit: ; 38ca4
; Discourage this move if [enemy's current HP * 2 > player's current HP].
push hl
@@ -1569,8 +1577,8 @@ AIScoring_PainSplit: ; 38ca4
; 38cba
-AIScoring_Snore:
-AIScoring_SleepTalk: ; 38cba
+AI_Smart_Snore:
+AI_Smart_SleepTalk: ; 38cba
; Greatly encourage this move if enemy is fast asleep.
; Greatly discourage this move otherwise.
@@ -1592,7 +1600,7 @@ AIScoring_SleepTalk: ; 38cba
; 38ccb
-AIScoring_DefrostOpponent: ; 38ccb
+AI_Smart_DefrostOpponent: ; 38ccb
; Greatly encourage this move if enemy is frozen.
; No move has EFFECT_DEFROST_OPPONENT, so this layer is unused.
@@ -1606,7 +1614,7 @@ AIScoring_DefrostOpponent: ; 38ccb
; 38cd5
-AIScoring_Spite: ; 38cd5
+AI_Smart_Spite: ; 38cd5
ld a, [LastEnemyCounterMove]
and a
jr nz, .asm_38ce7
@@ -1614,7 +1622,7 @@ AIScoring_Spite: ; 38cd5
call AICompareSpeed
jp c, AIDiscourageMove
- call AIRandom2
+ call AI_50_50
ret c
inc [hl]
ret
@@ -1669,9 +1677,9 @@ Function_0x38d16; 38d16
; 38d19
-AIScoring_DestinyBond:
-AIScoring_Reversal:
-AIScoring_SkullBash: ; 38d19
+AI_Smart_DestinyBond:
+AI_Smart_Reversal:
+AI_Smart_SkullBash: ; 38d19
; Discourage this move if enemy's HP is above 25%.
call AICheckEnemyQuarterHP
@@ -1681,7 +1689,7 @@ AIScoring_SkullBash: ; 38d19
; 38d1f
-AIScoring_HealBell: ; 38d1f
+AI_Smart_HealBell: ; 38d1f
; 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.
@@ -1699,10 +1707,11 @@ AIScoring_HealBell: ; 38d1f
or [hl]
jr z, .next
+ ; status
+ dec hl
dec hl
dec hl
- dec hl ; status
- ld a, [hl]
+ ld a, [hl]
or c
ld c, a
@@ -1724,7 +1733,7 @@ AIScoring_HealBell: ; 38d1f
.ok
and 1 << FRZ | SLP
ret z
- call AIRandom2
+ call AI_50_50
ret c
dec [hl]
dec [hl]
@@ -1739,10 +1748,10 @@ AIScoring_HealBell: ; 38d1f
; 38d5a
-AIScoring_PriorityHit: ; 38d5a
+AI_Smart_PriorityHit: ; 38d5a
call AICompareSpeed
ret c
-
+
; Dismiss this move if the player is flying or underground.
ld a, [PlayerSubStatus3]
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
@@ -1772,7 +1781,7 @@ AIScoring_PriorityHit: ; 38d5a
; 38d93
-AIScoring_Thief: ; 38d93
+AI_Smart_Thief: ; 38d93
; Don't use Thief unless it's the only move available.
ld a, [hl]
@@ -1782,7 +1791,7 @@ AIScoring_Thief: ; 38d93
; 38d98
-AIScoring_Conversion2: ; 38d98
+AI_Smart_Conversion2: ; 38d98
ld a, [LastPlayerMove]
and a
jr nz, .asm_38dc9
@@ -1806,25 +1815,24 @@ AIScoring_Conversion2: ; 38d98
cp $a
pop hl
jr c, .asm_38dc9
-
ret z
- call AIRandom2
+ call AI_50_50
ret c
+
dec [hl]
ret
.asm_38dc9
call Random
-
- cp $19
+ cp 25
ret c
inc [hl]
ret
; 38dd1
-AIScoring_Disable: ; 38dd1
+AI_Smart_Disable: ; 38dd1
call AICompareSpeed
jr nc, .asm_38df3
@@ -1857,7 +1865,7 @@ AIScoring_Disable: ; 38dd1
; 38dfb
-AIScoring_MeanLook: ; 38dfb
+AI_Smart_MeanLook: ; 38dfb
call AICheckEnemyHalfHP
jr nc, .asm_38e24
@@ -1890,7 +1898,7 @@ AIScoring_MeanLook: ; 38dfb
ret
.asm_38e26
- call AIRandom1
+ call AI_80_20
ret c
dec [hl]
dec [hl]
@@ -1926,19 +1934,19 @@ AICheckLastPlayerMon: ; 38e2e
; 38e4a
-AIScoring_Nightmare: ; 38e4a
+AI_Smart_Nightmare: ; 38e4a
; 50% chance to encourage this move.
-; The AIScoring_RedStatus layer will make sure that
+; The AI_Basic layer will make sure that
; Dream Eater is only used against sleeping targets.
- call AIRandom2
+ call AI_50_50
ret c
dec [hl]
ret
; 38e50
-AIScoring_FlameWheel: ; 38e50
+AI_Smart_FlameWheel: ; 38e50
; Use this move if the enemy is frozen.
ld a, [EnemyMonStatus]
@@ -1953,7 +1961,7 @@ AIScoring_FlameWheel: ; 38e50
; 38e5c
-AIScoring_Curse: ; 38e5c
+AI_Smart_Curse: ; 38e5c
ld a, [EnemyMonType1]
cp GHOST
jr z, .ghostcurse
@@ -1978,7 +1986,7 @@ AIScoring_Curse: ; 38e5c
ld a, [BattleMonType2]
cp SPECIAL
ret nc
- call AIRandom1
+ call AI_80_20
ret c
dec [hl]
dec [hl]
@@ -1999,7 +2007,7 @@ AIScoring_Curse: ; 38e5c
jp nz, AIDiscourageMove
push hl
- callba Function349f4
+ callba CountEnemyAliveMons
pop hl
jr nc, .asm_38eb0
@@ -2033,16 +2041,16 @@ AIScoring_Curse: ; 38e5c
ret nz
.asm_38ecb
- call AIRandom2
-
+ call AI_50_50
ret c
+
dec [hl]
dec [hl]
ret
; 38ed2
-AIScoring_Protect: ; 38ed2
+AI_Smart_Protect: ; 38ed2
ld a, [$c681]
and a
jr nz, .asm_38f13
@@ -2077,7 +2085,7 @@ AIScoring_Protect: ; 38ed2
jr c, .asm_38f14
.asm_38f0d
- call AIRandom1
+ call AI_80_20
ret c
dec [hl]
ret
@@ -2095,7 +2103,7 @@ AIScoring_Protect: ; 38ed2
; 38f1d
-AIScoring_Foresight: ; 38f1d
+AI_Smart_Foresight: ; 38f1d
ld a, [EnemyAccLevel]
cp $5
jr c, .asm_38f41
@@ -2126,15 +2134,15 @@ AIScoring_Foresight: ; 38f1d
; 38f4a
-AIScoring_PerishSong: ; 38f4a
+AI_Smart_PerishSong: ; 38f4a
push hl
- callab Function349f4
+ callab CountEnemyAliveMons
pop hl
- jr c, .asm_38f75
+ jr c, .no
ld a, [PlayerSubStatus5]
bit SUBSTATUS_CANT_RUN, a
- jr nz, .asm_38f6f
+ jr nz, .yes
push hl
callab Function3484e
@@ -2143,20 +2151,20 @@ AIScoring_PerishSong: ; 38f4a
pop hl
ret c
- call AIRandom2
+ call AI_50_50
ret c
inc [hl]
ret
-.asm_38f6f
- call AIRandom2
+.yes
+ call AI_50_50
ret c
dec [hl]
ret
-.asm_38f75
+.no
ld a, [hl]
add 5
ld [hl], a
@@ -2164,7 +2172,7 @@ AIScoring_PerishSong: ; 38f4a
; 38f7a
-AIScoring_Sandstorm: ; 38f7a
+AI_Smart_Sandstorm: ; 38f7a
; Greatly discourage this move if the player is immune to Sandstorm damage.
ld a, [BattleMonType1]
@@ -2188,7 +2196,7 @@ AIScoring_Sandstorm: ; 38f7a
jr nc, .asm_38fa6
; 50% chance to encourage this move otherwise.
- call AIRandom2
+ call AI_50_50
ret c
dec [hl]
@@ -2209,7 +2217,7 @@ AIScoring_Sandstorm: ; 38f7a
; 38fac
-AIScoring_Endure: ; 38fac
+AI_Smart_Endure: ; 38fac
ld a, [$c681]
and a
jr nz, .asm_38fd8
@@ -2221,10 +2229,10 @@ AIScoring_Endure: ; 38fac
jr c, .asm_38fd9
ld b, EFFECT_REVERSAL
- call AIHasMove
+ call AIHasMoveEffect
jr nc, .asm_38fcb
- call AIRandom1
+ call AI_80_20
ret c
dec [hl]
@@ -2236,9 +2244,10 @@ AIScoring_Endure: ; 38fac
ld a, [EnemySubStatus5]
bit SUBSTATUS_LOCK_ON, a
ret z
- call AIRandom2
+ call AI_50_50
ret c
+
dec [hl]
dec [hl]
ret
@@ -2252,7 +2261,7 @@ AIScoring_Endure: ; 38fac
; 38fdb
-AIScoring_FuryCutter: ; 38fdb
+AI_Smart_FuryCutter: ; 38fdb
; Encourage this move based on Fury Cutter's count.
ld a, [EnemyFuryCutterCount]
@@ -2272,11 +2281,12 @@ AIScoring_FuryCutter: ; 38fdb
dec [hl]
.end
+
; fallthrough
; 38fef
-AIScoring_Rollout: ; 38fef
+AI_Smart_Rollout: ; 38fef
; Rollout, Fury Cutter
; 80% chance to discourage this move if the enemy is in love, confused, or paralyzed.
@@ -2313,15 +2323,15 @@ AIScoring_Rollout: ; 38fef
ret
.asm_39020
- call AIRandom1
+ call AI_80_20
ret c
inc [hl]
ret
; 39026
-AIScoring_Swagger:
-AIScoring_Attract: ; 39026
+AI_Smart_Swagger:
+AI_Smart_Attract: ; 39026
; 80% chance to encourage this move during the first turn of player's Pokemon.
; 80% chance to discourage this move otherwise.
@@ -2329,7 +2339,7 @@ AIScoring_Attract: ; 39026
and a
jr z, .first_turn
- call AIRandom1
+ call AI_80_20
ret c
inc [hl]
ret
@@ -2343,20 +2353,20 @@ AIScoring_Attract: ; 39026
; 3903a
-AIScoring_Safeguard: ; 3903a
+AI_Smart_Safeguard: ; 3903a
; 80% chance to discourage this move if player's HP is below 50%.
call AICheckPlayerHalfHP
ret c
- call AIRandom1
+ call AI_80_20
ret c
inc [hl]
ret
; 39044
-AIScoring_Magnitude:
-AIScoring_Earthquake: ; 39044
+AI_Smart_Magnitude:
+AI_Smart_Earthquake: ; 39044
; Greatly encourage this move if the player is underground and the enemy is faster.
ld a, [LastEnemyCounterMove]
@@ -2365,7 +2375,7 @@ AIScoring_Earthquake: ; 39044
ld a, [PlayerSubStatus3]
bit SUBSTATUS_UNDERGROUND, a
- jr z, .couldDig
+ jr z, .could_dig
call AICompareSpeed
ret nc
@@ -2373,20 +2383,22 @@ AIScoring_Earthquake: ; 39044
dec [hl]
ret
-; Try to predict if the player will use Dig this turn.
-.couldDig
+.could_dig
+ ; Try to predict if the player will use Dig this turn.
-; 50% chance to encourage this move if the enemy is slower than the player.
+ ; 50% chance to encourage this move if the enemy is slower than the player.
call AICompareSpeed
ret c
- call AIRandom2
+
+ call AI_50_50
ret c
+
dec [hl]
ret
; 39062
-AIScoring_BatonPass: ; 39062
+AI_Smart_BatonPass: ; 39062
; 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.
@@ -2401,19 +2413,19 @@ AIScoring_BatonPass: ; 39062
; 39072
-AIScoring_Pursuit: ; 39072
+AI_Smart_Pursuit: ; 39072
; 50% chance to greatly encourage this move if player's HP is below 25%.
; 80% chance to discourage this move otherwise.
call AICheckPlayerQuarterHP
jr nc, .asm_3907d
- call AIRandom1
+ call AI_80_20
ret c
inc [hl]
ret
.asm_3907d
- call AIRandom2
+ call AI_50_50
ret c
dec [hl]
dec [hl]
@@ -2421,7 +2433,7 @@ AIScoring_Pursuit: ; 39072
; 39084
-AIScoring_RapidSpin: ; 39084
+AI_Smart_RapidSpin: ; 39084
; 80% chance to greatly encourage this move if the enemy is
; trapped (Bind effect), seeded, or scattered with spikes.
@@ -2438,15 +2450,16 @@ AIScoring_RapidSpin: ; 39084
ret z
.asm_39097
- call AIRandom1
+ call AI_80_20
ret c
+
dec [hl]
dec [hl]
ret
; 3909e
-AIScoring_HiddenPower: ; 3909e
+AI_Smart_HiddenPower: ; 3909e
push hl
ld a, 1
ld [hBattleTurn], a
@@ -2458,37 +2471,35 @@ AIScoring_HiddenPower: ; 3909e
; Discourage Hidden Power if not very effective.
ld a, [$d265]
- cp $a
- jr c, .asm_390c9
-
+ cp 10
+ jr c, .bad
+
; Discourage Hidden Power if its base power is lower than 50.
ld a, d
cp 50
- jr c, .asm_390c9
-
+ jr c, .bad
+
; Encourage Hidden Power if super-effective.
ld a, [$d265]
- cp $b
- jr nc, .asm_390c7
-
+ cp 11
+ jr nc, .good
+
; Encourage Hidden Power if its base power is 70.
ld a, d
- cp 70
-
-; Do nothing if none of these conditions meet.
+ cp 70
ret c
-.asm_390c7
+.good
dec [hl]
ret
-.asm_390c9
+.bad
inc [hl]
ret
; 390cb
-AIScoring_RainDance: ; 390cb
+AI_Smart_RainDance: ; 390cb
; Greatly discourage this move if it would favour the player type-wise.
; Particularly, if the player is a Water-type.
@@ -2506,7 +2517,7 @@ AIScoring_RainDance: ; 390cb
push hl
ld hl, RainDanceMoves
- jr AIScoring_WeatherMove
+ jr AI_Smart_WeatherMove
; 390e7
RainDanceMoves: ; 390e7
@@ -2525,7 +2536,7 @@ RainDanceMoves: ; 390e7
; 390f3
-AIScoring_SunnyDay: ; 390f3
+AI_Smart_SunnyDay: ; 390f3
; Greatly discourage this move if it would favour the player type-wise.
; Particularly, if the player is a Fire-type.
@@ -2548,7 +2559,7 @@ AIScoring_SunnyDay: ; 390f3
; 3910d
-AIScoring_WeatherMove: ; 3910d
+AI_Smart_WeatherMove: ; 3910d
; Rain Dance, Sunny Day
; Greatly discourage this move if the enemy doesn't have
@@ -2562,7 +2573,7 @@ AIScoring_WeatherMove: ; 3910d
jr nc, AIBadWeatherType
; 50% chance to encourage this move otherwise.
- call AIRandom2
+ call AI_50_50
ret c
dec [hl]
@@ -2614,7 +2625,7 @@ SunnyDayMoves: ; 39134
; 3913d
-AIScoring_BellyDrum: ; 3913d
+AI_Smart_BellyDrum: ; 3913d
; 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.
@@ -2624,8 +2635,9 @@ AIScoring_BellyDrum: ; 3913d
call AICheckEnemyMaxHP
ret c
-
+
inc [hl]
+
call AICheckEnemyHalfHP
ret c
@@ -2637,7 +2649,7 @@ AIScoring_BellyDrum: ; 3913d
; 39152
-AIScoring_PsychUp: ; 39152
+AI_Smart_PsychUp: ; 39152
push hl
ld hl, EnemyAtkLevel
ld b, $8
@@ -2648,7 +2660,7 @@ AIScoring_PsychUp: ; 39152
.asm_3915a
ld a, [hli]
sub $7
- add c
+ add c
ld c, a
dec b
jr nz, .asm_3915a
@@ -2682,9 +2694,10 @@ AIScoring_PsychUp: ; 39152
ld a, [EnemyEvaLevel]
cp $8
ret nc
- call AIRandom1
+ call AI_80_20
ret c
+
dec [hl]
ret
@@ -2695,7 +2708,7 @@ AIScoring_PsychUp: ; 39152
; 3918b
-AIScoring_MirrorCoat: ; 3918b
+AI_Smart_MirrorCoat: ; 3918b
push hl
ld hl, PlayerUsedMoves
ld c, $4
@@ -2760,8 +2773,8 @@ AIScoring_MirrorCoat: ; 3918b
; 391d5
-AIScoring_Twister:
-AIScoring_Gust: ; 391d5
+AI_Smart_Twister:
+AI_Smart_Gust: ; 391d5
; Greatly encourage this move if the player is flying and the enemy is faster.
ld a, [LastEnemyCounterMove]
@@ -2774,6 +2787,7 @@ AIScoring_Gust: ; 391d5
call AICompareSpeed
ret nc
+
dec [hl]
dec [hl]
ret
@@ -2784,14 +2798,14 @@ AIScoring_Gust: ; 391d5
; 50% chance to encourage this move if the enemy is slower than the player.
call AICompareSpeed
ret c
- call AIRandom2
+ call AI_50_50
ret c
dec [hl]
ret
; 391f3
-AIScoring_FutureSight: ; 391f3
+AI_Smart_FutureSight: ; 391f3
; Greatly encourage this move if the player is
; flying or underground, and slower than the enemy.
@@ -2808,14 +2822,14 @@ AIScoring_FutureSight: ; 391f3
; 39200
-AIScoring_Stomp: ; 39200
+AI_Smart_Stomp: ; 39200
; 80% chance to encourage this move if the player has used Minimize.
ld a, [$c6fe]
and a
ret z
- call AIRandom1
+ call AI_80_20
ret c
dec [hl]
@@ -2823,7 +2837,7 @@ AIScoring_Stomp: ; 39200
; 3920b
-AIScoring_Solarbeam: ; 3920b
+AI_Smart_Solarbeam: ; 3920b
; 80% chance to encourage this move when it's sunny.
; 90% chance to discourage this move when it's raining.
@@ -2843,7 +2857,7 @@ AIScoring_Solarbeam: ; 3920b
ret
.asm_3921e
- call AIRandom1
+ call AI_80_20
ret c
dec [hl]
@@ -2852,7 +2866,7 @@ AIScoring_Solarbeam: ; 3920b
; 39225
-AIScoring_Thunder: ; 39225
+AI_Smart_Thunder: ; 39225
; 90% chance to discourage this move when it's sunny.
ld a, [Weather]
@@ -3021,7 +3035,7 @@ AICheckPlayerQuarterHP: ; 392b3
; 392ca
-AIHasMove: ; 392ca
+AIHasMoveEffect: ; 392ca
; Return carry if the enemy has move b.
push hl
@@ -3031,23 +3045,23 @@ AIHasMove: ; 392ca
.checkmove
ld a, [hli]
and a
- jr z, .asm_392e0
+ jr z, .no
call AIGetEnemyMove
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
cp b
- jr z, .asm_392e3
+ jr z, .yes
dec c
jr nz, .checkmove
-.asm_392e0
+.no
pop hl
and a
ret
-.asm_392e3
+.yes
pop hl
scf
ret
@@ -3061,27 +3075,27 @@ AIHasMoveInArray: ; 392e6
push de
push bc
-.asm_392e9
+.next
ld a, [hli]
cp $ff
- jr z, .asm_392fd
+ jr z, .done
ld b, a
ld c, EnemyMonMovesEnd - EnemyMonMoves + 1
ld de, EnemyMonMoves
-.asm_392f4
+.check
dec c
- jr z, .asm_392e9
+ jr z, .next
ld a, [de]
inc de
cp b
- jr nz, .asm_392f4
+ jr nz, .check
scf
-.asm_392fd
+.done
pop bc
pop de
pop hl
@@ -3090,6 +3104,7 @@ AIHasMoveInArray: ; 392e6
UsefulMoves: ; 39301
+; Moves that are usable all-around.
db DOUBLE_EDGE
db SING
db FLAMETHROWER
@@ -3113,7 +3128,7 @@ UsefulMoves: ; 39301
; 39315
-AIScoring_Opportunist: ; 39315
+AI_Opportunist: ; 39315
; Discourage stall moves when the enemy's HP is low.
; Do nothing if enemy's HP is above 50%.
@@ -3125,7 +3140,7 @@ AIScoring_Opportunist: ; 39315
jr nc, .asm_39322
; 50% chance to discourage stall moves if enemy's HP is between 25% and 50%.
- call AIRandom2
+ call AI_50_50
ret c
.asm_39322
@@ -3198,7 +3213,9 @@ AIScoring_Opportunist: ; 39315
-AIScoring_Aggressive: ; 39369
+AI_Aggressive: ; 39369
+; Use whatever does the most damage.
+
; Discourage all damaging moves but the one that does the most damage.
; If no damaging move deals damage to the player (immune),
; no move will be discouraged
@@ -3250,13 +3267,12 @@ AIScoring_Aggressive: ; 39369
jr .checkmove
.gotstrongestmove
-; Discourage moves that do less damage unless they're reckless too.
-
; Nothing we can do if no attacks did damage.
ld a, c
and a
jr z, .done
+; Discourage moves that do less damage unless they're reckless too.
ld hl, Buffer1 - 1
ld de, EnemyMonMoves
ld b, 0
@@ -3287,7 +3303,7 @@ AIScoring_Aggressive: ; 39369
push de
push bc
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
- ld hl, .recklessmoves
+ ld hl, .RecklessMoves
ld de, 1
call IsInArray
pop bc
@@ -3302,7 +3318,7 @@ AIScoring_Aggressive: ; 39369
.done
ret
-.recklessmoves
+.RecklessMoves:
db EFFECT_EXPLOSION
db EFFECT_RAMPAGE
db EFFECT_MULTI_HIT
@@ -3337,8 +3353,8 @@ AIDamageCalc: ; 393e7
; 39418
-AIScoring_Cautious: ; 39418
-; 90% chance to discourage moves with residual effects after enemy's Pokemon first turn.
+AI_Cautious: ; 39418
+; 90% chance to discourage moves with residual effects after the first turn.
ld a, [EnemyTurnsTaken]
and a
@@ -3394,7 +3410,7 @@ AIScoring_Cautious: ; 39418
-AIScoring_StatusImmunity: ; 39453
+AI_Status: ; 39453
; Dismiss status moves that don't affect the player.
ld hl, Buffer1 - 1
@@ -3458,7 +3474,7 @@ AIScoring_StatusImmunity: ; 39453
-AIScoring_Risky: ; 394a9
+AI_Risky: ; 394a9
; Use any move that will KO the target.
; Risky moves will often be an exception (see below).
@@ -3483,20 +3499,20 @@ AIScoring_Risky: ; 394a9
ld a, [wEnemyMoveStruct + MOVE_POWER]
and a
jr z, .nextmove
-
+
+; Don't use risky moves at max hp.
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
ld de, 1
- ld hl, .riskymoves
+ ld hl, .RiskyMoves
call IsInArray
jr nc, .checkko
-; Exclude risky moves if enemy's HP is full.
call AICheckEnemyMaxHP
jr c, .nextmove
; Else, 80% chance to exclude them.
call Random
- cp 200
+ cp 200 ; 1/5
jr c, .nextmove
.checkko
@@ -3526,7 +3542,7 @@ AIScoring_Risky: ; 394a9
pop de
jr .checkmove
-.riskymoves
+.RiskyMoves:
db EFFECT_EXPLOSION
db EFFECT_OHKO
db $ff
@@ -3534,7 +3550,7 @@ AIScoring_Risky: ; 394a9
-AIScoring_None: ; 39502
+AI_None: ; 39502
ret
; 39503
@@ -3569,14 +3585,14 @@ AIGetEnemyMove: ; 39508
; 39521
-AIRandom1: ; 39521
+AI_80_20: ; 39521
call Random
cp 50 ; 1/5
ret
; 39527
-AIRandom2: ; 39527
+AI_50_50: ; 39527
call Random
cp $80 ; 1/2
ret