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

View File

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

View File

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