123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- DrainHPEffect_:
- ld hl, wDamage
- ld a, [hl]
- srl a ; divide damage by 2
- ld [hli], a
- ld a, [hl]
- rr a
- ld [hld], a
- or [hl] ; is damage 0?
- jr nz, .getAttackerHP
- ; if damage is 0, increase to 1 so that the attacker gains at least 1 HP
- inc hl
- inc [hl]
- .getAttackerHP
- ld hl, wBattleMonHP
- ld de, wBattleMonMaxHP
- ld a, [H_WHOSETURN]
- and a
- jp z, .addDamageToAttackerHP
- ld hl, wEnemyMonHP
- ld de, wEnemyMonMaxHP
- .addDamageToAttackerHP
- ld bc, wHPBarOldHP+1
- ; copy current HP to wHPBarOldHP
- ld a, [hli]
- ld [bc], a
- ld a, [hl]
- dec bc
- ld [bc], a
- ; copy max HP to wHPBarMaxHP
- ld a, [de]
- dec bc
- ld [bc], a
- inc de
- ld a, [de]
- dec bc
- ld [bc], a
- ; add damage to attacker's HP and copy new HP to wHPBarNewHP
- ld a, [wDamage + 1]
- ld b, [hl]
- add b
- ld [hld], a
- ld [wHPBarNewHP], a
- ld a, [wDamage]
- ld b, [hl]
- adc b
- ld [hli], a
- ld [wHPBarNewHP+1], a
- jr c, .capToMaxHP ; if HP > 65,535, cap to max HP
- ; compare HP with max HP
- ld a, [hld]
- ld b, a
- ld a, [de]
- dec de
- sub b
- ld a, [hli]
- ld b, a
- ld a, [de]
- inc de
- sbc b
- jr nc, .next
- .capToMaxHP
- ld a, [de]
- ld [hld], a
- ld [wHPBarNewHP], a
- dec de
- ld a, [de]
- ld [hli], a
- ld [wHPBarNewHP+1], a
- inc de
- .next
- ld a, [H_WHOSETURN]
- and a
- coord hl, 10, 9
- ld a, $1
- jr z, .next2
- coord hl, 2, 2
- xor a
- .next2
- ld [wHPBarType], a
- predef UpdateHPBar2
- predef DrawPlayerHUDAndHPBar
- predef DrawEnemyHUDAndHPBar
- callab ReadPlayerMonCurHPAndStatus
- ld hl, SuckedHealthText
- ld a, [H_WHOSETURN]
- and a
- ld a, [wPlayerMoveEffect]
- jr z, .next3
- ld a, [wEnemyMoveEffect]
- .next3
- cp DREAM_EATER_EFFECT
- jr nz, .printText
- ld hl, DreamWasEatenText
- .printText
- jp PrintText
- SuckedHealthText:
- TX_FAR _SuckedHealthText
- db "@"
- DreamWasEatenText:
- TX_FAR _DreamWasEatenText
- db "@"
|