ref: 7eef66af3f53ba9ed758af7a3c6f2e636ff4a55f
parent: f5ac9b0eb7773a9d05108b1ee6e41140d53020cd
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Sun Jul 5 11:09:12 EDT 2020
Use MAX_NEUTRAL_DAMAGE in BattleCommand_DamageCalc Also make .gitignore consistent with pokered
--- a/.gitignore
+++ b/.gitignore
@@ -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 @@
# 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
--- a/constants/battle_constants.asm
+++ b/constants/battle_constants.asm
@@ -10,8 +10,9 @@
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
--- a/engine/battle/effect_commands.asm
+++ b/engine/battle/effect_commands.asm
@@ -3066,47 +3066,48 @@
; 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
@@ -3113,25 +3114,25 @@
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 @@
inc [hl]
.dont_floor
+; Returns nz and nc.
ld a, 1
and a
ret
@@ -3152,18 +3154,18 @@
; 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