From 419ecb6e980c758e84ed80f2f3ec2a69f9473101 Mon Sep 17 00:00:00 2001
From: Hachem_Muche <Hachem_Muche@stanfordalumni.org>
Date: Tue, 18 Jul 2017 14:09:43 -0700
Subject: [PATCH] tactical tables will check the target's lucid_dreamer
 attribute when evaluating sleep immunity

---
 game/modules/tome/class/interface/ActorAI.lua        | 8 ++++++--
 game/modules/tome/data/talents/misc/inscriptions.lua | 5 +++--
 game/modules/tome/data/talents/spells/water.lua      | 4 ++--
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/game/modules/tome/class/interface/ActorAI.lua b/game/modules/tome/class/interface/ActorAI.lua
index f5cb57e391..e61be68a31 100644
--- a/game/modules/tome/class/interface/ActorAI.lua
+++ b/game/modules/tome/class/interface/ActorAI.lua
@@ -30,7 +30,7 @@ local Talents = require "engine.interface.ActorTalents"
 
 module(..., package.seeall, class.inherit(engine.interface.ActorAI))
 
-config.settings.log_detail_ai = 1 -- debugging general output for AI messages
+--config.settings.log_detail_ai = 0 -- debugging general output for AI messages
 
 --- dgdgdgdgdg REMOVE THIS SECTION after the transitional AI phase ---
 -- soft switch enabling new AIs during transition phase
@@ -218,7 +218,7 @@ end
 -- The defensive hash value is used as a fingerprint by aiTalentTactics when updating its cache
 -- Update as needed (for custom tactics in the tactical AI)
 _M.aiDHashProps = {}
-local DHashProps = {"aiDHashvalue", "fly", "levitation", "never_move", "encased_in_ice", "stoned", "invulnerable", "negative_status_effect_immune", "mental_negative_status_effect_immune", "physical_negative_status_effect_immune", "spell_negative_status_effect_immune"}
+local DHashProps = {"aiDHashvalue", "fly", "levitation", "never_move", "encased_in_ice", "stoned", "invulnerable", "negative_status_effect_immune", "mental_negative_status_effect_immune", "physical_negative_status_effect_immune", "spell_negative_status_effect_immune", "lucid_dreamer"}
 for typ, tag in pairs(Actor.StatusTypes) do
 	table.insert(DHashProps, type(tag) == "string" and tag or typ .. "_immune")
 end
@@ -246,6 +246,7 @@ end
 --		returns the result of the "archery" function if the talent is an archery talent
 -- "offhand" -- as "weapon" but for offhand (offhand penalty applies, 0 multiplier if unarmed)
 -- "archery" -- returns the ammo DamageType and up to 2x multiplier based on launcher weapon skill (or 0 if no archery weapon/ammo)
+-- "sleep" -- checks the target's "lucid_dreamer" attribute
 _M.aiSubstDamtypes = {
 	weapon = function(self, t, target) -- get mainhand DamageType and special weight modifier (or switch to archery)
 		if self:getTalentSpeedType(t) == "archery" then return self.aiSubstDamtypes.archery(self, t, target) end
@@ -304,6 +305,9 @@ _M.aiSubstDamtypes = {
 			DType = ammo.combat.damtype or DamageType.PHYSICAL
 		end
 		return DType, wt
+	end,
+	sleep = function(self, t, target) -- Sleep immunity is modified by the "lucid_dreamer" attribute
+		return sleep, target:attr("lucid_dreamer") and 0 or 1
 	end
 }
 
diff --git a/game/modules/tome/data/talents/misc/inscriptions.lua b/game/modules/tome/data/talents/misc/inscriptions.lua
index 37363ae5b7..4bc1a711ab 100644
--- a/game/modules/tome/data/talents/misc/inscriptions.lua
+++ b/game/modules/tome/data/talents/misc/inscriptions.lua
@@ -311,7 +311,8 @@ newInscription{
 	name = "Infusion: Insidious Poison",
 	type = {"inscriptions/infusions", 1},
 	points = 1,
-	tactical = { ATTACK = { NATURE = 1 }, DISABLE= {poison = 1}, CURE = function(self, t, target)
+	tactical = { ATTACK = { NATURE = 1 }, DISABLE= {poison = 1},
+		SELF = {CURE = function(self, t, target)
 			local nb = 0
 			local data = self:getInscriptionData(t.short_name)
 			for eff_id, p in pairs(self.tmp) do
@@ -319,7 +320,7 @@ newInscription{
 				if e.type == "magical" and e.status == "detrimental" then nb = nb + 1 end
 			end
 			return nb
-		end },
+		end }},
 	requires_target = true,
 	range = function(self, t)
 		local data = self:getInscriptionData(t.short_name)
diff --git a/game/modules/tome/data/talents/spells/water.lua b/game/modules/tome/data/talents/spells/water.lua
index 3b7de19173..31c7628e24 100644
--- a/game/modules/tome/data/talents/spells/water.lua
+++ b/game/modules/tome/data/talents/spells/water.lua
@@ -25,7 +25,7 @@ newTalent{
 	random_ego = "attack",
 	mana = 12,
 	cooldown = 8,
-	tactical = { ATTACKAREA = { COLD = 2 } },
+	tactical = { DISABLE = {stun = 0.5}, ATTACKAREA = { COLD = 1 } },
 	range = 8,
 	radius = 3,
 	direct_hit = true,
@@ -74,7 +74,7 @@ newTalent{
 		if self:attr("freeze_next_cd_reduce") then mod = 1 - self.freeze_next_cd_reduce self:attr("freeze_next_cd_reduce", -self.freeze_next_cd_reduce) end
 		return math.floor(self:combatTalentLimit(t, 20, 8, 12, true)) * mod
 	end, -- Limit cooldown <20
-	tactical = { ATTACK = { COLD = 1 }, DISABLE = { stun = 3 } },
+	tactical = { ATTACK = { COLD = 2.5 }, DISABLE = { stun = 1.5 } },
 	range = 10,
 	direct_hit = true,
 	reflectable = true,
-- 
GitLab