Use MAX_NEUTRAL_DAMAGE in BattleCommand_DamageCalc

Also make .gitignore consistent with pokered
This commit is contained in:
Rangi 2020-07-05 15:09:12 -04:00
parent f5ac9b0eb7
commit 7eef66af3f
3 changed files with 35 additions and 31 deletions

13
.gitignore vendored
View File

@ -13,7 +13,7 @@
*.gbc
*.gb
# for any of the poor souls with save game files in their working directory
# save game files
*.sgm
*.sav
*.rtc
@ -32,14 +32,15 @@ pokecrystal.txt
# used_space.py
used_space.png
# for vim configuration
# url: http://www.vim.org/scripts/script.php?script_id=441
# vim configuration
# http://www.vim.org/scripts/script.php?script_id=441
.lvimrc
# swap files for vim
# swap files for vim and gedit
.*.swp
# swap files for gedit
*~
# osx files
# macos files
.DS_STORE
# compiled graphics

View File

@ -10,8 +10,9 @@ NUM_MOVES EQU 4
BASE_STAT_LEVEL EQU 7
MAX_STAT_LEVEL EQU 13
; minimum damage before type effectiveness
; damage limits before type effectiveness
MIN_NEUTRAL_DAMAGE EQU 2
MAX_NEUTRAL_DAMAGE EQU 999
; turns that sleep lasts
REST_SLEEP_TURNS EQU 2

View File

@ -3066,72 +3066,73 @@ BattleCommand_DamageCalc:
; Critical hits
call .CriticalMultiplier
; Update wCurDamage (capped at 997).
; Update wCurDamage.
; Capped at MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE: 999 - 2 = 997.
ld hl, wCurDamage
ld b, [hl]
ldh a, [hProduct + 3]
ldh a, [hQuotient + 3]
add b
ldh [hProduct + 3], a
ldh [hQuotient + 3], a
jr nc, .dont_cap_1
ldh a, [hProduct + 2]
ldh a, [hQuotient + 2]
inc a
ldh [hProduct + 2], a
ldh [hQuotient + 2], a
and a
jr z, .Cap
.dont_cap_1
ldh a, [hProduct]
ldh a, [hQuotient]
ld b, a
ldh a, [hProduct + 1]
ldh a, [hQuotient + 1]
or a
jr nz, .Cap
ldh a, [hProduct + 2]
cp HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1)
ldh a, [hQuotient + 2]
cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1)
jr c, .dont_cap_2
cp HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1) + 1
cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) + 1
jr nc, .Cap
ldh a, [hProduct + 3]
cp LOW(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1)
ldh a, [hQuotient + 3]
cp LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1)
jr nc, .Cap
.dont_cap_2
inc hl
ldh a, [hProduct + 3]
ldh a, [hQuotient + 3]
ld b, [hl]
add b
ld [hld], a
ldh a, [hProduct + 2]
ldh a, [hQuotient + 2]
ld b, [hl]
adc b
ld [hl], a
jr c, .Cap
ld a, [hl]
cp HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1)
cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1)
jr c, .dont_cap_3
cp HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1) + 1
cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) + 1
jr nc, .Cap
inc hl
ld a, [hld]
cp LOW(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE + 1)
cp LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1)
jr c, .dont_cap_3
.Cap:
ld a, HIGH(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE)
ld a, HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE)
ld [hli], a
ld a, LOW(MAX_STAT_VALUE - MIN_NEUTRAL_DAMAGE)
ld a, LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE)
ld [hld], a
.dont_cap_3
; Minimum neutral damage is 2 (bringing the cap to 999).
; Add back MIN_NEUTRAL_DAMAGE (capping at 999).
inc hl
ld a, [hl]
add MIN_NEUTRAL_DAMAGE
@ -3140,6 +3141,7 @@ BattleCommand_DamageCalc:
inc [hl]
.dont_floor
; Returns nz and nc.
ld a, 1
and a
ret
@ -3152,18 +3154,18 @@ BattleCommand_DamageCalc:
; x2
ldh a, [hQuotient + 3]
add a
ldh [hProduct + 3], a
ldh [hQuotient + 3], a
ldh a, [hQuotient + 2]
rl a
ldh [hProduct + 2], a
ldh [hQuotient + 2], a
; Cap at $ffff.
ret nc
ld a, $ff
ldh [hProduct + 2], a
ldh [hProduct + 3], a
ldh [hQuotient + 2], a
ldh [hQuotient + 3], a
ret