Hello, I recently started getting into trying to figure out the assembly code for crystal, and in crystal the following code is used:
.got_text
call FailText_CheckOpponentProtect
xor a
ld [wCriticalHit], a
ld a, BATTLE_VARS_MOVE_EFFECT
call GetBattleVar
cp EFFECT_JUMP_KICK
ret nz
ld a, [wTypeModifier]
and EFFECTIVENESS_MASK
ret z
ld hl, wCurDamage
ld a, [hli]
ld b, [hl]
rept 3
srl a
rr b
endr
ld [hl], b
dec hl
ld [hli], a
or b
jr nz, .do_at_least_1_damage
inc a
ld [hl], a
.do_at_least_1_damage
ld hl, CrashedText
call StdBattleTextbox
ld a, $1
ld [wBattleAnimParam], a
call LoadMoveAnim
ld c, TRUE
ldh a, [hBattleTurn]
and a
jp nz, DoEnemyDamage
jp DoPlayerDamage
How can I change this so that instead of using the wCurDamage and then dividing it by 1/8th it takes the user or enemy's max hp and then subtracts from the total when missing? I have tried calling different functions like GetHalfMaxHP and such but it never really works out when testing. If anyone knows what needs to be changed it would be of great help
.got_text
call FailText_CheckOpponentProtect
xor a
ld [wCriticalHit], a
ld a, BATTLE_VARS_MOVE_EFFECT
call GetBattleVar
cp EFFECT_JUMP_KICK
ret nz
ld a, [wTypeModifier]
and EFFECTIVENESS_MASK
ret z
ld hl, wCurDamage
ld a, [hli]
ld b, [hl]
rept 3
srl a
rr b
endr
ld [hl], b
dec hl
ld [hli], a
or b
jr nz, .do_at_least_1_damage
inc a
ld [hl], a
.do_at_least_1_damage
ld hl, CrashedText
call StdBattleTextbox
ld a, $1
ld [wBattleAnimParam], a
call LoadMoveAnim
ld c, TRUE
ldh a, [hBattleTurn]
and a
jp nz, DoEnemyDamage
jp DoPlayerDamage
How can I change this so that instead of using the wCurDamage and then dividing it by 1/8th it takes the user or enemy's max hp and then subtracts from the total when missing? I have tried calling different functions like GetHalfMaxHP and such but it never really works out when testing. If anyone knows what needs to be changed it would be of great help