From 14e391f9dc86146217a288d407e7055b48d770fa Mon Sep 17 00:00:00 2001
From: DarkGod <darkgod@net-core.org>
Date: Mon, 28 Oct 2013 13:52:19 +0100
Subject: [PATCH] Flat damage cap% is now applied after shields

---
 game/modules/tome/class/Actor.lua       | 11 +++++++++++
 game/modules/tome/data/damage_types.lua | 11 -----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index 3c91314d9f..6e1ee63c3d 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -2132,6 +2132,17 @@ function _M:onTakeHit(value, src, death_note)
 		end
 	end
 
+	-- Flat damage cap
+	if self.flat_damage_cap and self.max_life and death_note and death_note.damtype then
+		local cap = nil
+		if self.flat_damage_cap.all then cap = self.flat_damage_cap.all end
+		if self.flat_damage_cap[death_note.damtype] then cap = self.flat_damage_cap[death_note.damtype] end
+		if cap and cap > 0 then
+			value = math.max(math.min(value, cap * self.max_life / 100), 0)
+			print("[TAKE HIT] after flat damage cap", value)
+		end
+	end
+
 	local hd = {"Actor:takeHit", value=value, src=src, death_note=death_note}
 	if self:triggerHook(hd) then value = hd.value end
 
diff --git a/game/modules/tome/data/damage_types.lua b/game/modules/tome/data/damage_types.lua
index 2e428171ec..bd0337f20a 100644
--- a/game/modules/tome/data/damage_types.lua
+++ b/game/modules/tome/data/damage_types.lua
@@ -296,17 +296,6 @@ setDefaultProjector(function(src, x, y, type, dam, tmp, no_martyr)
 			print("[PROJECTOR] after flat damage armor", dam)
 		end
 
-		-- Flat damage cap
-		if target.flat_damage_cap and target.max_life then
-			local cap = nil
-			if target.flat_damage_cap.all then cap = target.flat_damage_cap.all end
-			if target.flat_damage_cap[type] then cap = target.flat_damage_cap[type] end
-			if cap and cap > 0 then
-				dam = math.max(math.min(dam, cap * target.max_life / 100), 0)
-				print("[PROJECTOR] after flat damage cap", dam)
-			end
-		end
-
 		-- roll with it damage reduction
 		if type == DamageType.PHYSICAL and target:knowTalent(target.T_ROLL_WITH_IT) and not target:attr("never_move") then
 			dam = dam * target:callTalent(target.T_ROLL_WITH_IT, "getMult")
-- 
GitLab