From 6a5edc98e9760a9cfa63f0e8ffb6ba8747f9ff03 Mon Sep 17 00:00:00 2001 From: Rangi Date: Mon, 9 Nov 2020 16:12:19 -0500 Subject: [PATCH] Terser damage calculation constants --- constants/battle_constants.asm | 4 ---- engine/battle/effect_commands.asm | 27 +++++++++++++++------------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/constants/battle_constants.asm b/constants/battle_constants.asm index b9729467f..d66778a55 100644 --- a/constants/battle_constants.asm +++ b/constants/battle_constants.asm @@ -10,10 +10,6 @@ NUM_MOVES EQU 4 BASE_STAT_LEVEL EQU 7 MAX_STAT_LEVEL EQU 13 -; damage limits before type effectiveness -MIN_NEUTRAL_DAMAGE EQU 2 -MAX_NEUTRAL_DAMAGE EQU 999 - ; turns that sleep lasts REST_SLEEP_TURNS EQU 2 TREEMON_SLEEP_TURNS EQU 7 diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm index cd3a66eb1..b1070e8d9 100644 --- a/engine/battle/effect_commands.asm +++ b/engine/battle/effect_commands.asm @@ -3066,8 +3066,11 @@ BattleCommand_DamageCalc: ; Critical hits call .CriticalMultiplier -; Update wCurDamage. -; Capped at MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE: 999 - 2 = 997. +; Update wCurDamage. Max 999 (capped at 997, then add 2). +MAX_DAMAGE EQU 999 +MIN_DAMAGE EQU 2 +DAMAGE_CAP EQU MAX_DAMAGE - MIN_DAMAGE + ld hl, wCurDamage ld b, [hl] ldh a, [hQuotient + 3] @@ -3089,14 +3092,14 @@ BattleCommand_DamageCalc: jr nz, .Cap ldh a, [hQuotient + 2] - cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) + cp HIGH(DAMAGE_CAP + 1) jr c, .dont_cap_2 - cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) + 1 + cp HIGH(DAMAGE_CAP + 1) + 1 jr nc, .Cap ldh a, [hQuotient + 3] - cp LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) + cp LOW(DAMAGE_CAP + 1) jr nc, .Cap .dont_cap_2 @@ -3114,28 +3117,28 @@ BattleCommand_DamageCalc: jr c, .Cap ld a, [hl] - cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) + cp HIGH(DAMAGE_CAP + 1) jr c, .dont_cap_3 - cp HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) + 1 + cp HIGH(DAMAGE_CAP + 1) + 1 jr nc, .Cap inc hl ld a, [hld] - cp LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE + 1) + cp LOW(DAMAGE_CAP + 1) jr c, .dont_cap_3 .Cap: - ld a, HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE) + ld a, HIGH(DAMAGE_CAP) ld [hli], a - ld a, LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE) + ld a, LOW(DAMAGE_CAP) ld [hld], a .dont_cap_3 -; Add back MIN_NEUTRAL_DAMAGE (capping at 999). +; Add back MIN_DAMAGE (capping at 999). inc hl ld a, [hl] - add MIN_NEUTRAL_DAMAGE + add MIN_DAMAGE ld [hld], a jr nc, .dont_floor inc [hl]