From c6e7d2283627cdb181319e531e4fd452062ecc86 Mon Sep 17 00:00:00 2001
From: DarkGod <darkgod@net-core.org>
Date: Mon, 31 Aug 2020 16:09:41 +0200
Subject: [PATCH] Lightning+daze damage type does not undaze if target is
 already dazed and it didnt re-proc

---
 game/modules/tome/class/Actor.lua       | 2 +-
 game/modules/tome/data/damage_types.lua | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index 8f2848eaf5..1fae366f90 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -2376,7 +2376,7 @@ function _M:onTakeHit(value, src, death_note)
 	end
 
 	-- Un-daze
-	if self:hasEffect(self.EFF_DAZED) and not self:attr("damage_dont_undaze") then
+	if self:hasEffect(self.EFF_DAZED) and not self:attr("damage_dont_undaze") and (not src or not src.turn_procs or not src.turn_procs.dealing_damage_dont_undaze) then
 		self:removeEffect(self.EFF_DAZED)
 	end
 
diff --git a/game/modules/tome/data/damage_types.lua b/game/modules/tome/data/damage_types.lua
index 9eef59ea08..c376c91dbe 100644
--- a/game/modules/tome/data/damage_types.lua
+++ b/game/modules/tome/data/damage_types.lua
@@ -1552,7 +1552,10 @@ newDamageType{
 		useImplicitCrit(src, state)
 		if _G.type(dam) == "number" then dam = {dam=dam, daze=25} end
 		dam.daze = dam.daze or 25
+		local oldundaze
+		if src.turn_procs then src.turn_procs.dealing_damage_dont_undaze, oldundaze = true, src.turn_procs.dealing_damage_dont_undaze end
 		local realdam = DamageType:get(DamageType.LIGHTNING).projector(src, x, y, DamageType.LIGHTNING, dam.dam, state)
+		if src.turn_procs then src.turn_procs.dealing_damage_dont_undaze = oldundaze end
 		local target = game.level.map(x, y, Map.ACTOR)
 		if target and dam.daze > 0 and rng.percent(dam.daze) then
 			if target:canBe("stun") then
-- 
GitLab