summaryrefslogtreecommitdiff
path: root/battle/ai
diff options
context:
space:
mode:
Diffstat (limited to 'battle/ai')
-rw-r--r--battle/ai/items.asm47
-rwxr-xr-xbattle/ai/move.asm7
-rw-r--r--battle/ai/scoring.asm178
-rwxr-xr-xbattle/ai/switch.asm94
4 files changed, 144 insertions, 182 deletions
diff --git a/battle/ai/items.asm b/battle/ai/items.asm
index 16511de79..4405ae756 100644
--- a/battle/ai/items.asm
+++ b/battle/ai/items.asm
@@ -196,9 +196,9 @@ AI_TryItem: ; 38105
jr z, .has_item
dec de
-rept 3
inc hl
-endr
+ inc hl
+ inc hl
jr .loop
.has_item
@@ -216,9 +216,8 @@ endr
pop de
pop hl
-rept 2
inc hl
-endr
+ inc hl
jr c, .loop
.used_item
@@ -572,20 +571,20 @@ EnemyUsedFullHeal: ; 383a3 (e:43a3)
EnemyUsedMaxPotion: ; 383ae (e:43ae)
ld a, MAX_POTION
- ld [wd1f1], a
+ ld [CurEnemyItem], a
jr FullRestoreContinue
EnemyUsedFullRestore: ; 383b5 (e:43b5)
call AI_HealStatus
ld a, FULL_RESTORE
- ld [wd1f1], a
+ ld [CurEnemyItem], a
ld hl, EnemySubStatus3
res SUBSTATUS_CONFUSED, [hl]
xor a
ld [EnemyConfuseCount], a
FullRestoreContinue: ; 383c6
- ld de, wd1ec
+ ld de, wCurHPAnimOldHP
ld hl, EnemyMonHP + 1
ld a, [hld]
ld [de], a
@@ -597,11 +596,11 @@ FullRestoreContinue: ; 383c6
ld a, [hld]
ld [de], a
inc de
- ld [Buffer1], a
+ ld [wCurHPAnimMaxHP], a
ld [EnemyMonHP + 1], a
ld a, [hl]
ld [de], a
- ld [Buffer2], a
+ ld [wCurHPAnimMaxHP + 1], a
ld [EnemyMonHP], a
jr EnemyPotionFinish
; 383e8 (e:43e8)
@@ -621,20 +620,20 @@ EnemyUsedHyperPotion: ; 383f4 (e:43f4)
ld b, 200
EnemyPotionContinue: ; 383f8
- ld [wd1f1], a
+ ld [CurEnemyItem], a
ld hl, EnemyMonHP + 1
ld a, [hl]
- ld [wd1ec], a
+ ld [wCurHPAnimOldHP], a
add b
ld [hld], a
- ld [wd1ee], a
+ ld [wCurHPAnimNewHP], a
ld a, [hl]
- ld [wd1ec + 1], a
- ld [wd1ee + 1], a
+ ld [wCurHPAnimOldHP + 1], a
+ ld [wCurHPAnimNewHP + 1], a
jr nc, .ok
inc a
ld [hl], a
- ld [wd1ee + 1], a
+ ld [wCurHPAnimNewHP + 1], a
.ok
inc hl
ld a, [hld]
@@ -642,22 +641,22 @@ EnemyPotionContinue: ; 383f8
ld de, EnemyMonMaxHP + 1
ld a, [de]
dec de
- ld [Buffer1], a
+ ld [wCurHPAnimMaxHP], a
sub b
ld a, [hli]
ld b, a
ld a, [de]
- ld [Buffer2], a
+ ld [wCurHPAnimMaxHP + 1], a
sbc b
jr nc, EnemyPotionFinish
inc de
ld a, [de]
dec de
ld [hld], a
- ld [wd1ee], a
+ ld [wCurHPAnimNewHP], a
ld a, [de]
ld [hl], a
- ld [wd1ef], a
+ ld [wCurHPAnimNewHP + 1], a
EnemyPotionFinish: ; 38436
call PrintText_UsedItemOn
@@ -726,7 +725,7 @@ AI_Switch: ; 3846c
.skiptext
ld a, 1
- ld [wAISwitch], a
+ ld [wBattleHasJustStarted], a
callab NewEnemyMonStatus
callab ResetEnemyStatLevels
ld hl, PlayerSubStatus1
@@ -734,7 +733,7 @@ AI_Switch: ; 3846c
callba EnemySwitch
callba ResetBattleParticipants
xor a
- ld [wAISwitch], a
+ ld [wBattleHasJustStarted], a
ld a, [wLinkMode]
and a
ret nz
@@ -844,7 +843,7 @@ EnemyUsedXSpecial: ; 38553
; a = ITEM_CONSTANT
; b = BATTLE_CONSTANT (ATTACK, DEFENSE, SPEED, SP_ATTACK, SP_DEFENSE, ACCURACY, EVASION)
EnemyUsedXItem:
- ld [wd1f1], a
+ ld [CurEnemyItem], a
push bc
call PrintText_UsedItemOn
pop bc
@@ -856,13 +855,13 @@ EnemyUsedXItem:
; Parameter
; a = ITEM_CONSTANT
PrintText_UsedItemOn_AND_AIUpdateHUD: ; 38568
- ld [wd1f1], a
+ ld [CurEnemyItem], a
call PrintText_UsedItemOn
jp AIUpdateHUD
; 38571
PrintText_UsedItemOn: ; 38571
- ld a, [wd1f1]
+ ld a, [CurEnemyItem]
ld [wd265], a
call GetItemName
ld hl, StringBuffer1
diff --git a/battle/ai/move.asm b/battle/ai/move.asm
index 0d1c6c968..6e5aca358 100755
--- a/battle/ai/move.asm
+++ b/battle/ai/move.asm
@@ -19,9 +19,9 @@ AIChooseMove: ; 440ce
; The default score is 20. Unusable moves are given a score of 80.
ld a, 20
ld hl, Buffer1
-rept 3
ld [hli], a
-endr
+ ld [hli], a
+ ld [hli], a
ld [hl], a
; Don't pick disabled moves.
@@ -107,9 +107,8 @@ endr
ld hl, AIScoringPointers
dec c
ld b, 0
-rept 2
add hl, bc
-endr
+ add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
diff --git a/battle/ai/scoring.asm b/battle/ai/scoring.asm
index 9b8dd6e42..3091697e5 100644
--- a/battle/ai/scoring.asm
+++ b/battle/ai/scoring.asm
@@ -133,18 +133,16 @@ AI_Setup: ; 385e0
call AI_50_50
jr c, .checkmove
-rept 2
dec [hl]
-endr
+ dec [hl]
jr .checkmove
.discourage
call Random
cp 30
jr c, .checkmove
-rept 2
inc [hl]
-endr
+ inc [hl]
jr .checkmove
; 38635
@@ -264,9 +262,8 @@ AI_Offensive: ; 386a2
and a
jr nz, .checkmove
-rept 2
inc [hl]
-endr
+ inc [hl]
jr .checkmove
; 386be
@@ -420,9 +417,8 @@ AI_Smart_Sleep: ; 387e3
.asm_387f0
call AI_50_50
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 387f7
@@ -533,9 +529,8 @@ AI_Smart_LockOn: ; 3881d
call AI_50_50
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.asm_38882
@@ -560,9 +555,8 @@ endr
cp 180
jr nc, .asm_3888b
-rept 2
dec [hl]
-endr
+ dec [hl]
jr .asm_3888b
.asm_388a2
@@ -602,9 +596,9 @@ AI_Smart_Explosion: ; 388a6
ret c
.asm_388c6
-rept 3
inc [hl]
-endr
+ inc [hl]
+ inc [hl]
ret
; 388ca
@@ -616,9 +610,9 @@ AI_Smart_DreamEater: ; 388ca
call Random
cp 25
ret c
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
; 388d4
@@ -645,9 +639,8 @@ AI_Smart_EvasionUp: ; 388d4
jr nc, .asm_38911
.asm_388ef
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.asm_388f2
@@ -676,9 +669,8 @@ endr
jr c, .asm_38911
.asm_3890f
-rept 2
inc [hl]
-endr
+ inc [hl]
; 30% chance to end up here if enemy's HP is full and player is not badly poisoned.
; 77% chance to end up here if enemy's HP is above 50% but not full.
@@ -722,9 +714,8 @@ endr
call Random
cp $50
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; Player is seeded.
@@ -756,9 +747,8 @@ AI_Smart_AlwaysHit: ; 38947
call AI_80_20
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 3895b
@@ -828,9 +818,8 @@ AI_Smart_AccuracyDown: ; 38985
jr nc, .asm_389bf
.asm_3899d
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.asm_389a0
@@ -859,9 +848,8 @@ endr
jr c, .asm_389bf
.asm_389bd
-rept 2
inc [hl]
-endr
+ inc [hl]
; We only end up here if the move has not been already encouraged.
.asm_389bf
@@ -900,9 +888,8 @@ endr
call Random
cp $50
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; Player is seeded.
@@ -1010,9 +997,8 @@ AI_Smart_Moonlight: ; 38a3a
call Random
cp $19
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 38a4e
@@ -1093,9 +1079,8 @@ AI_Smart_Bind: ; 38a71
ret nc
call AI_50_50
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 38a9c
@@ -1200,9 +1185,8 @@ AI_Smart_SpDefenseUp2: ; 38aed
.asm_38b09
call AI_80_20
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.asm_38b10
@@ -1224,9 +1208,9 @@ AI_Smart_Fly: ; 38b12
call AICompareSpeed
ret nc
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
; 38b20
@@ -1255,9 +1239,8 @@ AI_Smart_Paralyze: ; 38b26
ret nc
call AI_80_20
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.asm_38b3a
@@ -1289,9 +1272,8 @@ AI_Smart_SpeedDownHit: ; 38b40
call Random
cp 30
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 38b5c
@@ -1528,15 +1510,14 @@ AI_Smart_Encore: ; 38c3b
call Random
cp $46
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.asm_38c81
-rept 3
inc [hl]
-endr
+ inc [hl]
+ inc [hl]
ret
.EncoreMoves:
@@ -1606,15 +1587,15 @@ AI_Smart_SleepTalk: ; 38cba
cp $1
jr z, .asm_38cc7
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
.asm_38cc7
-rept 3
inc [hl]
-endr
+ inc [hl]
+ inc [hl]
ret
; 38ccb
@@ -1626,9 +1607,9 @@ AI_Smart_DefrostOpponent: ; 38ccb
ld a, [EnemyMonStatus]
and $20
ret z
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
; 38cd5
@@ -1685,9 +1666,8 @@ AI_Smart_Spite: ; 38cd5
call Random
cp $64
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 38d16
@@ -1728,9 +1708,9 @@ AI_Smart_HealBell: ; 38d1f
jr z, .next
; status
-rept 3
dec hl
-endr
+ dec hl
+ dec hl
ld a, [hl]
or c
ld c, a
@@ -1755,9 +1735,8 @@ endr
ret z
call AI_50_50
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.no_status
@@ -1795,9 +1774,9 @@ AI_Smart_PriorityHit: ; 38d5a
ld a, [BattleMonHP]
sbc b
ret nc
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
; 38d93
@@ -1921,9 +1900,9 @@ AI_Smart_MeanLook: ; 38dfb
.asm_38e26
call AI_80_20
ret c
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
; 38e2e
@@ -2007,15 +1986,13 @@ AI_Smart_Curse: ; 38e5c
ret nc
call AI_80_20
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.asm_38e90
-rept 2
inc [hl]
-endr
+ inc [hl]
.asm_38e92
inc [hl]
.asm_38e93
@@ -2065,9 +2042,8 @@ endr
call AI_50_50
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 38ed2
@@ -2119,9 +2095,8 @@ AI_Smart_Protect: ; 38ed2
call Random
cp 20
ret c
-rept 2
inc [hl]
-endr
+ inc [hl]
ret
; 38f1d
@@ -2151,9 +2126,8 @@ AI_Smart_Foresight: ; 38f1d
call Random
cp 100
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 38f4a
@@ -2259,9 +2233,9 @@ AI_Smart_Endure: ; 38fac
call AI_80_20
ret c
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
ret
.asm_38fcb
@@ -2272,9 +2246,8 @@ endr
call AI_50_50
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.asm_38fd8
@@ -2296,15 +2269,14 @@ AI_Smart_FuryCutter: ; 38fdb
cp 2
jr c, .end
-rept 2
dec [hl]
-endr
+ dec [hl]
cp 3
jr c, .end
-rept 3
dec [hl]
-endr
+ dec [hl]
+ dec [hl]
.end
@@ -2344,9 +2316,8 @@ AI_Smart_Rollout: ; 38fef
call Random
cp 200
ret nc
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.asm_39020
@@ -2406,9 +2377,8 @@ AI_Smart_Earthquake: ; 39044
call AICompareSpeed
ret nc
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
.could_dig
@@ -2455,9 +2425,8 @@ AI_Smart_Pursuit: ; 39072
.asm_3907d
call AI_50_50
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 39084
@@ -2482,9 +2451,8 @@ AI_Smart_RapidSpin: ; 39084
call AI_80_20
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 3909e
@@ -2611,9 +2579,9 @@ AI_Smart_WeatherMove: ; 3910d
; 3911e
AIBadWeatherType: ; 3911e
-rept 3
inc [hl]
-endr
+ inc [hl]
+ inc [hl]
ret
; 39122
@@ -2636,9 +2604,8 @@ AIGoodWeatherType: ; 39122
ret nz
.good
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 39134
@@ -2733,9 +2700,8 @@ AI_Smart_PsychUp: ; 39152
ret
.asm_39188
-rept 2
inc [hl]
-endr
+ inc [hl]
ret
; 3918b
@@ -2820,9 +2786,8 @@ AI_Smart_Gust: ; 391d5
call AICompareSpeed
ret nc
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; Try to predict if the player will use Fly this turn.
@@ -2849,9 +2814,8 @@ AI_Smart_FutureSight: ; 391f3
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
ret z
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 39200
@@ -2886,18 +2850,16 @@ AI_Smart_Solarbeam: ; 3920b
cp 25 ; 1/10
ret c
-rept 2
inc [hl]
-endr
+ inc [hl]
ret
.asm_3921e
call AI_80_20
ret c
-rept 2
dec [hl]
-endr
+ dec [hl]
ret
; 39225
@@ -2991,9 +2953,8 @@ AICheckPlayerHalfHP: ; 3926e
ld c, [hl]
sla c
rl b
-rept 2
inc hl
-endr
+ inc hl
ld a, [hld]
cp c
ld a, [hl]
@@ -3013,9 +2974,8 @@ AICheckEnemyHalfHP: ; 39281
ld c, [hl]
sla c
rl b
-rept 2
inc hl
-endr
+ inc hl
ld a, [hld]
cp c
ld a, [hl]
@@ -3039,9 +2999,8 @@ AICheckEnemyQuarterHP: ; 39298
rl b
sla c
rl b
-rept 2
inc hl
-endr
+ inc hl
ld a, [hld]
cp c
ld a, [hl]
@@ -3063,9 +3022,8 @@ AICheckPlayerQuarterHP: ; 392b3
rl b
sla c
rl b
-rept 2
inc hl
-endr
+ inc hl
ld a, [hld]
cp c
ld a, [hl]
diff --git a/battle/ai/switch.asm b/battle/ai/switch.asm
index 8f5db7a54..cb1fe3660 100755
--- a/battle/ai/switch.asm
+++ b/battle/ai/switch.asm
@@ -136,9 +136,11 @@ CheckPlayerMoveTypeMatchups: ; 3484e
jr c, .loop2
; neutral
-rept 5
inc c
-endr
+ inc c
+ inc c
+ inc c
+ inc c
cp 10
jr z, .loop2
@@ -161,11 +163,6 @@ endr
.doubledown
call .DecreaseScore
-
- ; fallthrough
-; 34931
-
-
.DecreaseScore: ; 34931
ld a, [wEnemyAISwitchScore]
dec a
@@ -173,7 +170,6 @@ endr
ret
; 34939
-
.IncreaseScore: ; 34939
ld a, [wEnemyAISwitchScore]
inc a
@@ -198,16 +194,16 @@ CheckAbleToSwitch: ; 34941
; Perish count is 1
call FindAliveEnemyMons
- call FindEnemyMonsWithEnoughHP
+ call FindEnemyMonsWithAtLeastQuarterMaxHP
call FindEnemyMonsThatResistPlayer
- call Function34a85
+ call FindAliveEnemyMonsWithASuperEffectiveMove
ld a, e
cp 2
jr nz, .not_2
ld a, [wEnemyAISwitchScore]
- add $30
+ add $30 ; maximum chance
ld [wEnemySwitchMonParam], a
ret
@@ -223,12 +219,11 @@ CheckAbleToSwitch: ; 34941
jr nc, .loop1
ld a, b
- add $30
+ add $30 ; maximum chance
ld [wEnemySwitchMonParam], a
ret
.no_perish
-
call CheckPlayerMoveTypeMatchups
ld a, [wEnemyAISwitchScore]
cp 11
@@ -238,13 +233,13 @@ CheckAbleToSwitch: ; 34941
and a
jr z, .no_last_counter_move
- call Function34a2a
+ call FindEnemyMonsImmuneToLastCounterMove
ld a, [wEnemyAISwitchScore]
and a
jr z, .no_last_counter_move
ld c, a
- call Function34aa7
+ call FindEnemyMonsWithASuperEffectiveMove
ld a, [wEnemyAISwitchScore]
cp $ff
ret z
@@ -285,9 +280,9 @@ CheckAbleToSwitch: ; 34941
ret nc
call FindAliveEnemyMons
- call FindEnemyMonsWithEnoughHP
+ call FindEnemyMonsWithAtLeastQuarterMaxHP
call FindEnemyMonsThatResistPlayer
- call Function34a85
+ call FindAliveEnemyMonsWithASuperEffectiveMove
ld a, e
cp $2
@@ -352,7 +347,7 @@ FindAliveEnemyMons: ; 349f4
; 34a2a
-Function34a2a: ; 34a2a
+FindEnemyMonsImmuneToLastCounterMove: ; 34a2a
ld hl, OTPartyMon1
ld a, [OTPartyCount]
ld b, a
@@ -361,44 +356,50 @@ Function34a2a: ; 34a2a
xor a
ld [wEnemyAISwitchScore], a
-.asm_34a39
+.loop
ld a, [CurOTMon]
cp d
push hl
- jr z, .asm_34a77
+ jr z, .next
push hl
push bc
+
+ ; If the Pokemon has at least 1 HP...
ld bc, MON_HP
add hl, bc
pop bc
ld a, [hli]
or [hl]
pop hl
- jr z, .asm_34a77
+ jr z, .next
ld a, [hl]
ld [CurSpecies], a
call GetBaseData
+
+ ; the enemy's last move is damaging...
ld a, [LastEnemyCounterMove]
dec a
ld hl, Moves + MOVE_POWER
call GetMoveAttr
and a
- jr z, .asm_34a77
+ jr z, .next
+ ; and the Pokemon is immune to it...
inc hl
call GetMoveByte
ld hl, BaseType
call CheckTypeMatchup
ld a, [wTypeMatchup]
and a
- jr nz, .asm_34a77
+ jr nz, .next
+ ; ... encourage that Pokemon.
ld a, [wEnemyAISwitchScore]
or c
ld [wEnemyAISwitchScore], a
-.asm_34a77
+.next
pop hl
dec b
ret z
@@ -410,11 +411,11 @@ Function34a2a: ; 34a2a
inc d
srl c
- jr .asm_34a39
+ jr .loop
; 34a85
-Function34a85: ; 34a85
+FindAliveEnemyMonsWithASuperEffectiveMove: ; 34a85
push bc
ld a, [OTPartyCount]
ld e, a
@@ -444,13 +445,9 @@ Function34a85: ; 34a85
and c
ld c, a
+FindEnemyMonsWithASuperEffectiveMove: ; 34aa7
- ; fallthrough
-; 34aa7
-
-Function34aa7: ; 34aa7
-
- ld a, $ff
+ ld a, -1
ld [wEnemyAISwitchScore], a
ld hl, OTPartyMon1Moves
ld b, 1 << (PARTY_LENGTH - 1)
@@ -463,32 +460,40 @@ Function34aa7: ; 34aa7
push hl
push bc
+ ; for move on mon:
ld b, NUM_MOVES
ld c, 0
.loop3
+ ; if move is None: break
ld a, [hli]
and a
push hl
jr z, .break3
+ ; if move has no power: continue
dec a
ld hl, Moves + MOVE_POWER
call GetMoveAttr
and a
jr z, .nope
+ ; check type matchups
inc hl
call GetMoveByte
ld hl, BattleMonType1
call CheckTypeMatchup
+
+ ; if immune or not very effective: continue
ld a, [wTypeMatchup]
cp 10
jr c, .nope
+ ; if neutral: load 1 and continue
ld e, 1
cp 10 + 1
jr c, .nope
+ ; if super-effective: load 2 and break
ld e, 2
jr .break3
@@ -505,18 +510,19 @@ Function34aa7: ; 34aa7
ld a, e
pop bc
pop hl
- cp $2
- jr z, .done2
-
- cp $1
- jr nz, .next
+ cp 2
+ jr z, .done2 ; at least one move is super-effective
+ cp 1
+ jr nz, .next ; no move does more than half damage
+ ; encourage this pokemon
ld a, d
or b
ld d, a
- jr .next
+ jr .next ; such a long jump
.next
+ ; next pokemon?
push bc
ld bc, PARTYMON_STRUCT_LENGTH
add hl, bc
@@ -524,12 +530,14 @@ Function34aa7: ; 34aa7
srl b
jr nc, .loop
+ ; if no pokemon has a super-effective move: return
ld a, d
ld b, a
and a
ret z
.done2
+ ; convert the bit flag to an int and return
push bc
sla b
sla b
@@ -608,7 +616,7 @@ FindEnemyMonsThatResistPlayer: ; 34b20
; 34b77
-FindEnemyMonsWithEnoughHP: ; 34b77
+FindEnemyMonsWithAtLeastQuarterMaxHP: ; 34b77
push bc
ld de, OTPartySpecies
ld b, 1 << (PARTY_LENGTH - 1)
@@ -626,17 +634,15 @@ FindEnemyMonsWithEnoughHP: ; 34b77
ld b, [hl]
inc hl
ld c, [hl]
-rept 2
inc hl
-endr
+ inc hl
; hl = MaxHP + 1
-; b = (4 * b) % $100 + (c & 3)
-; c = c / 4
+; bc = [CurHP] * 4
srl c
rl b
srl c
rl b
-; a = (MaxHP / $100) - b - (1 if c > (MaxHP % $100) else 0)
+; if bc >= [hl], encourage
ld a, [hld]
cp c
ld a, [hl]