Comment SapHealth

Also fixed some Beat Up inconsistencies to make it more readable.
This commit is contained in:
mid-kid 2018-04-04 22:35:47 +02:00
parent 0c446367ce
commit e1da37e033
2 changed files with 37 additions and 12 deletions

View File

@ -4136,6 +4136,7 @@ BattleCommand_EatDream: ; 36008
SapHealth: ; 36011
; Divide damage by 2, store it in hDividend
ld hl, wCurDamage
ld a, [hli]
srl a
@ -4145,10 +4146,11 @@ SapHealth: ; 36011
rr a
ld [hDividend + 1], a
or b
jr nz, .ok1
ld a, $1
jr nz, .at_least_one
ld a, 1
ld [hDividend + 1], a
.ok1
.at_least_one
ld hl, wBattleMonHP
ld de, wBattleMonMaxHP
ld a, [hBattleTurn]
@ -4157,12 +4159,16 @@ SapHealth: ; 36011
ld hl, wEnemyMonHP
ld de, wEnemyMonMaxHP
.battlemonhp
; Store current HP in little endian wBuffer3/4
ld bc, wBuffer4
ld a, [hli]
ld [bc], a
ld a, [hl]
dec bc
ld [bc], a
; Store max HP in little endian wBuffer1/2
ld a, [de]
dec bc
ld [bc], a
@ -4170,6 +4176,8 @@ SapHealth: ; 36011
ld a, [de]
dec bc
ld [bc], a
; Add hDividend to current HP and copy it to little endian wBuffer5/6
ld a, [hDividend + 1]
ld b, [hl]
add b
@ -4180,7 +4188,9 @@ SapHealth: ; 36011
adc b
ld [hli], a
ld [wBuffer6], a
jr c, .okay2
jr c, .max_hp
; Substract current HP from max HP (to see if we have more than max HP)
ld a, [hld]
ld b, a
ld a, [de]
@ -4191,8 +4201,10 @@ SapHealth: ; 36011
ld a, [de]
inc de
sbc b
jr nc, .okay3
.okay2
jr nc, .finish
.max_hp
; Load max HP into current HP and copy it to little endian wBuffer5/6
ld a, [de]
ld [hld], a
ld [wBuffer5], a
@ -4201,7 +4213,8 @@ SapHealth: ; 36011
ld [hli], a
ld [wBuffer6], a
inc de
.okay3
.finish
ld a, [hBattleTurn]
and a
hlcoord 10, 9

View File

@ -5,9 +5,11 @@ BattleCommand_BeatUp: ; 35461
ld a, [hBattleTurn]
and a
jp nz, .enemy_beats_up
ld a, [wPlayerSubStatus3]
bit SUBSTATUS_IN_LOOP, a
jr nz, .next_mon
ld c, 20
call DelayFrames
xor a
@ -51,11 +53,13 @@ BattleCommand_BeatUp: ; 35461
ld [wBeatUpHitAtLeastOnce], a
ld hl, BeatUpAttackText
call StdBattleTextBox
ld a, [wEnemyMonSpecies]
ld [wCurSpecies], a
call GetBaseData
ld a, [wBaseDefense]
ld c, a
push bc
ld a, MON_SPECIES
call GetBeatupMonLocation
@ -65,12 +69,14 @@ BattleCommand_BeatUp: ; 35461
ld a, [wBaseAttack]
pop bc
ld b, a
push bc
ld a, MON_LEVEL
call GetBeatupMonLocation
ld a, [hl]
ld e, a
pop bc
ld a, [wPlayerMoveStructPower]
ld d, a
ret
@ -78,21 +84,22 @@ BattleCommand_BeatUp: ; 35461
.enemy_beats_up
ld a, [wEnemySubStatus3]
bit SUBSTATUS_IN_LOOP, a
jr nz, .not_first_enemy_beatup
jr nz, .enemy_next_mon
xor a
ld [wEnemyRolloutCount], a
ld [wd002], a
ld [wBeatUpHitAtLeastOnce], a
jr .enemy_continue
jr .enemy_got_mon
.not_first_enemy_beatup
.enemy_next_mon
ld a, [wEnemyRolloutCount]
ld b, a
ld a, [wOTPartyCount]
sub b
ld [wd002], a
.enemy_continue
.enemy_got_mon
ld a, [wBattleMode]
dec a
jr z, .wild
@ -122,19 +129,20 @@ BattleCommand_BeatUp: ; 35461
call AddNTimes
ld de, wStringBuffer1
call CopyBytes
.got_enemy_nick
ld a, MON_HP
call GetBeatupMonLocation
ld a, [hli]
or [hl]
jp z, .beatup_fail
ld a, [wd002]
ld b, a
ld a, [wCurOTMon]
cp b
ld hl, wEnemyMonStatus
jr z, .active_enemy
ld a, MON_STATUS
call GetBeatupMonLocation
.active_enemy
@ -157,11 +165,13 @@ BattleCommand_BeatUp: ; 35461
.finish_beatup
ld hl, BeatUpAttackText
call StdBattleTextBox
ld a, [wBattleMonSpecies]
ld [wCurSpecies], a
call GetBaseData
ld a, [wBaseDefense]
ld c, a
push bc
ld a, MON_SPECIES
call GetBeatupMonLocation
@ -171,12 +181,14 @@ BattleCommand_BeatUp: ; 35461
ld a, [wBaseAttack]
pop bc
ld b, a
push bc
ld a, MON_LEVEL
call GetBeatupMonLocation
ld a, [hl]
ld e, a
pop bc
ld a, [wEnemyMoveStructPower]
ld d, a
ret