From ad2660b037450a73bfc9f998da445ec3f6fc51cf Mon Sep 17 00:00:00 2001 From: Aleos Date: Tue, 1 Feb 2022 14:01:58 -0500 Subject: [PATCH] Resolves cardfix calculation going below zero (#6560) * Fixes an issue where cardfix bonuses cause the final result to go below zero ultimately giving unwanted effects. Thanks to @Tokeiburu and@alycecil! --- src/map/battle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/map/battle.cpp b/src/map/battle.cpp index 0d898d26d1..b628750d12 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -675,7 +675,7 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li s_defele = (tsd) ? (enum e_element)status_get_element(src) : ELE_NONE; //Official servers apply the cardfix value on a base of 1000 and round down the reduction/increase -#define APPLY_CARDFIX(damage, fix) { (damage) = (damage) - (int64)(((damage) * (1000 - (fix))) / 1000); } +#define APPLY_CARDFIX(damage, fix) { (damage) = (damage) - (int64)(((damage) * (1000 - min(max(0, fix), 1000))) / 1000); } switch( attack_type ) { case BF_MAGIC: