summaryrefslogtreecommitdiff
path: root/engine/battle/moveEffects/heal_effect.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/battle/moveEffects/heal_effect.asm')
-rw-r--r--engine/battle/moveEffects/heal_effect.asm42
1 files changed, 23 insertions, 19 deletions
diff --git a/engine/battle/moveEffects/heal_effect.asm b/engine/battle/moveEffects/heal_effect.asm
index 22d482e7..862917f7 100644
--- a/engine/battle/moveEffects/heal_effect.asm
+++ b/engine/battle/moveEffects/heal_effect.asm
@@ -4,22 +4,23 @@ HealEffect_: ; 3b9ec (e:79ec)
ld de, wBattleMonHP
ld hl, wBattleMonMaxHP
ld a, [W_PLAYERMOVENUM]
- jr z, .asm_3ba03
+ jr z, .healEffect
ld de, wEnemyMonHP
ld hl, wEnemyMonMaxHP
ld a, [W_ENEMYMOVENUM]
-.asm_3ba03
+.healEffect
ld b, a
ld a, [de]
- cp [hl]
+ cp [hl] ; most significant bytes comparison is ignored
+ ; causes the move to miss if max HP is 255 or 511 points higher than the current HP
inc de
inc hl
ld a, [de]
sbc [hl]
- jp z, .failed
+ jp z, .failed ; no effect if user's HP is already at its maximum
ld a, b
cp REST
- jr nz, .asm_3ba37
+ jr nz, .healHP
push hl
push de
push af
@@ -28,31 +29,33 @@ HealEffect_: ; 3b9ec (e:79ec)
ld hl, wBattleMonStatus
ld a, [H_WHOSETURN]
and a
- jr z, .asm_3ba25
+ jr z, .restEffect
ld hl, wEnemyMonStatus
-.asm_3ba25
+.restEffect
ld a, [hl]
and a
- ld [hl], 2 ; Number of turns from Rest
- ld hl, StartedSleepingEffect
- jr z, .asm_3ba31
- ld hl, FellAsleepBecameHealthyText
-.asm_3ba31
+ ld [hl], 2 ; clear status and set number of turns asleep to 2
+ ld hl, StartedSleepingEffect ; if mon didn't have an status
+ jr z, .printRestText
+ ld hl, FellAsleepBecameHealthyText ; if mon had an status
+.printRestText
call PrintText
pop af
pop de
pop hl
-.asm_3ba37
+.healHP
ld a, [hld]
ld [wHPBarMaxHP], a
ld c, a
ld a, [hl]
ld [wHPBarMaxHP+1], a
ld b, a
- jr z, .asm_3ba47
+ jr z, .gotHPAmountToHeal
+; Recover and Softboiled only heal for half the mon's max HP
srl b
rr c
-.asm_3ba47
+.gotHPAmountToHeal
+; update HP
ld a, [de]
ld [wHPBarOldHP], a
add c
@@ -72,7 +75,8 @@ HealEffect_: ; 3b9ec (e:79ec)
dec hl
ld a, [de]
sbc [hl]
- jr c, .asm_3ba6f
+ jr c, .playAnim
+; copy max HP to current HP if an overflow ocurred
ld a, [hli]
ld [de], a
ld [wHPBarNewHP+1], a
@@ -80,17 +84,17 @@ HealEffect_: ; 3b9ec (e:79ec)
ld a, [hl]
ld [de], a
ld [wHPBarNewHP], a
-.asm_3ba6f
+.playAnim
ld hl, PlayCurrentMoveAnimation
call BankswitchEtoF
ld a, [H_WHOSETURN]
and a
hlCoord 10, 9
ld a, $1
- jr z, .asm_3ba83
+ jr z, .updateHPBar
hlCoord 2, 2
xor a
-.asm_3ba83
+.updateHPBar
ld [wHPBarType], a
predef UpdateHPBar2
ld hl, DrawHUDsAndHPBars