2016-06-12 00:24:04 +00:00
|
|
|
HealEffect_:
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh a, [hWhoseTurn]
|
2015-04-01 14:51:04 +00:00
|
|
|
and a
|
|
|
|
ld de, wBattleMonHP
|
|
|
|
ld hl, wBattleMonMaxHP
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wPlayerMoveNum]
|
2015-04-08 10:15:08 +00:00
|
|
|
jr z, .healEffect
|
2015-04-01 14:51:04 +00:00
|
|
|
ld de, wEnemyMonHP
|
|
|
|
ld hl, wEnemyMonMaxHP
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wEnemyMoveNum]
|
2015-04-08 10:15:08 +00:00
|
|
|
.healEffect
|
2015-04-01 14:51:04 +00:00
|
|
|
ld b, a
|
|
|
|
ld a, [de]
|
2015-04-08 10:15:08 +00:00
|
|
|
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
|
2015-04-01 14:51:04 +00:00
|
|
|
inc de
|
|
|
|
inc hl
|
|
|
|
ld a, [de]
|
|
|
|
sbc [hl]
|
2015-04-08 10:15:08 +00:00
|
|
|
jp z, .failed ; no effect if user's HP is already at its maximum
|
2015-04-01 14:51:04 +00:00
|
|
|
ld a, b
|
|
|
|
cp REST
|
2015-04-08 10:15:08 +00:00
|
|
|
jr nz, .healHP
|
2015-04-01 14:51:04 +00:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push af
|
|
|
|
ld c, 50
|
|
|
|
call DelayFrames
|
|
|
|
ld hl, wBattleMonStatus
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh a, [hWhoseTurn]
|
2015-04-01 14:51:04 +00:00
|
|
|
and a
|
2015-04-08 10:15:08 +00:00
|
|
|
jr z, .restEffect
|
2015-04-01 14:51:04 +00:00
|
|
|
ld hl, wEnemyMonStatus
|
2015-04-08 10:15:08 +00:00
|
|
|
.restEffect
|
2015-04-01 14:51:04 +00:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-04-08 10:15:08 +00:00
|
|
|
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
|
2015-04-01 14:51:04 +00:00
|
|
|
call PrintText
|
|
|
|
pop af
|
|
|
|
pop de
|
|
|
|
pop hl
|
2015-04-08 10:15:08 +00:00
|
|
|
.healHP
|
2015-04-01 14:51:04 +00:00
|
|
|
ld a, [hld]
|
|
|
|
ld [wHPBarMaxHP], a
|
|
|
|
ld c, a
|
|
|
|
ld a, [hl]
|
|
|
|
ld [wHPBarMaxHP+1], a
|
|
|
|
ld b, a
|
2015-04-08 10:15:08 +00:00
|
|
|
jr z, .gotHPAmountToHeal
|
|
|
|
; Recover and Softboiled only heal for half the mon's max HP
|
2015-04-01 14:51:04 +00:00
|
|
|
srl b
|
|
|
|
rr c
|
2015-04-08 10:15:08 +00:00
|
|
|
.gotHPAmountToHeal
|
|
|
|
; update HP
|
2015-04-01 14:51:04 +00:00
|
|
|
ld a, [de]
|
|
|
|
ld [wHPBarOldHP], a
|
|
|
|
add c
|
|
|
|
ld [de], a
|
|
|
|
ld [wHPBarNewHP], a
|
|
|
|
dec de
|
|
|
|
ld a, [de]
|
|
|
|
ld [wHPBarOldHP+1], a
|
|
|
|
adc b
|
|
|
|
ld [de], a
|
|
|
|
ld [wHPBarNewHP+1], a
|
|
|
|
inc hl
|
|
|
|
inc de
|
|
|
|
ld a, [de]
|
|
|
|
dec de
|
|
|
|
sub [hl]
|
|
|
|
dec hl
|
|
|
|
ld a, [de]
|
|
|
|
sbc [hl]
|
2015-04-08 10:15:08 +00:00
|
|
|
jr c, .playAnim
|
2017-06-24 20:01:43 +00:00
|
|
|
; copy max HP to current HP if an overflow occurred
|
2015-04-01 14:51:04 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
ld [wHPBarNewHP+1], a
|
|
|
|
inc de
|
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
|
|
|
ld [wHPBarNewHP], a
|
2015-04-08 10:15:08 +00:00
|
|
|
.playAnim
|
2015-04-01 14:51:04 +00:00
|
|
|
ld hl, PlayCurrentMoveAnimation
|
2020-11-05 21:55:39 +00:00
|
|
|
call EffectCallBattleCore
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh a, [hWhoseTurn]
|
2015-04-01 14:51:04 +00:00
|
|
|
and a
|
2020-07-07 15:30:10 +00:00
|
|
|
hlcoord 10, 9
|
2015-04-01 14:51:04 +00:00
|
|
|
ld a, $1
|
2015-04-08 10:15:08 +00:00
|
|
|
jr z, .updateHPBar
|
2020-07-07 15:30:10 +00:00
|
|
|
hlcoord 2, 2
|
2015-04-01 14:51:04 +00:00
|
|
|
xor a
|
2015-04-08 10:15:08 +00:00
|
|
|
.updateHPBar
|
2015-04-01 14:51:04 +00:00
|
|
|
ld [wHPBarType], a
|
|
|
|
predef UpdateHPBar2
|
|
|
|
ld hl, DrawHUDsAndHPBars
|
2020-11-05 21:55:39 +00:00
|
|
|
call EffectCallBattleCore
|
2015-04-01 14:51:04 +00:00
|
|
|
ld hl, RegainedHealthText
|
|
|
|
jp PrintText
|
|
|
|
.failed
|
|
|
|
ld c, 50
|
|
|
|
call DelayFrames
|
|
|
|
ld hl, PrintButItFailedText_
|
2020-11-05 21:55:39 +00:00
|
|
|
jp EffectCallBattleCore
|
2015-04-01 14:51:04 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
StartedSleepingEffect:
|
2020-07-04 21:09:35 +00:00
|
|
|
text_far _StartedSleepingEffect
|
|
|
|
text_end
|
2015-04-01 14:51:04 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
FellAsleepBecameHealthyText:
|
2020-07-04 21:09:35 +00:00
|
|
|
text_far _FellAsleepBecameHealthyText
|
|
|
|
text_end
|
2015-04-01 14:51:04 +00:00
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
RegainedHealthText:
|
2020-07-04 21:09:35 +00:00
|
|
|
text_far _RegainedHealthText
|
|
|
|
text_end
|