From 2d777c0a8e7c32d4a96944a5cc9db3556aa356e4 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Sun, 27 Nov 2011 19:21:48 +0000
Subject: [PATCH] Fixed mind damage cross tier effects Cursed Touch unlearn TL
 5 now works Curse of Madness correctly reduces confusion

git-svn-id: http://svn.net-core.org/repos/t-engine4@4673 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/ai/target.lua                       | 3 ++-
 game/modules/tome/data/chats/last-hope-elder.lua      | 4 ++--
 game/modules/tome/data/damage_types.lua               | 2 +-
 game/modules/tome/data/talents/cursed/cursed-aura.lua | 7 ++++++-
 game/modules/tome/data/talents/psionic/focus.lua      | 1 +
 game/modules/tome/data/timed_effects/other.lua        | 4 ++--
 6 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/game/modules/tome/ai/target.lua b/game/modules/tome/ai/target.lua
index cb99870021..aca05b6a74 100644
--- a/game/modules/tome/ai/target.lua
+++ b/game/modules/tome/ai/target.lua
@@ -54,6 +54,7 @@ end)
 
 -- Target the player if within sense radius
 newAI("target_player_radius", function(self)
+	if not game.player.x then return end
 	if self.ai_target.actor and not self.ai_target.actor.dead and rng.percent(90) then return true end
 
 	if core.fov.distance(self.x, self.y, game.player.x, game.player.y) < self.ai_state.sense_radius then
@@ -66,7 +67,7 @@ end)
 newAI("target_simple_or_player_radius", function(self)
 	if self:runAI("target_simple") then return true end
 
-	if core.fov.distance(self.x, self.y, game.player.x, game.player.y) < self.ai_state.sense_radius then
+	if game.player.x and core.fov.distance(self.x, self.y, game.player.x, game.player.y) < self.ai_state.sense_radius then
 		self.ai_target.actor = game.player
 		return true
 	end
diff --git a/game/modules/tome/data/chats/last-hope-elder.lua b/game/modules/tome/data/chats/last-hope-elder.lua
index 45e93c91b9..f7f22ac0fa 100644
--- a/game/modules/tome/data/chats/last-hope-elder.lua
+++ b/game/modules/tome/data/chats/last-hope-elder.lua
@@ -31,9 +31,9 @@ newChat{ id="found_staff",
 The staff you describe reminds me of an artifact of great power from ancient times. May I see it?]],
 	answers = {
 		{"Here it is. #LIGHT_GREEN#*Tell him the encounter with the orcs*#LAST# You should keep it. I can feel its power and it would be safer if it were guarded by the armies of the kingdom.",
-		 jump="given_staff", cond=function(npc, player) return player:isQuestStatus("staff-absorption", engine.Quest.COMPLETED, "survived-ukruk") end},
+		 jump="given_staff", cond=function(npc, player) return player:findInAllInventories("Staff of Absorption") and player:isQuestStatus("staff-absorption", engine.Quest.COMPLETED, "survived-ukruk") end},
 		{"I am afraid I lost it. #LIGHT_GREEN#*Tell him about the encounter with the orcs*",
-		 jump="lost_staff", cond=function(npc, player) return player:isQuestStatus("staff-absorption", engine.Quest.COMPLETED, "ambush-finish") end},
+		 jump="lost_staff", cond=function(npc, player) return player:findInAllInventories("Staff of Absorption") and player:isQuestStatus("staff-absorption", engine.Quest.COMPLETED, "ambush-finish") end},
 	}
 }
 
diff --git a/game/modules/tome/data/damage_types.lua b/game/modules/tome/data/damage_types.lua
index ca71a9121d..a131eca515 100644
--- a/game/modules/tome/data/damage_types.lua
+++ b/game/modules/tome/data/damage_types.lua
@@ -417,7 +417,7 @@ newDamageType{
 				if criticals then
 					dam = src:mindCrit(dam)
 				end
-				if crossTierChance and rng.change(crossTierChance) then
+				if crossTierChance and rng.chance(crossTierChance) then
 					target:crossTierEffect(target.EFF_BRAINLOCKED, src:combatMindpower())
 				end
 				return DamageType.defaultProjector(src, x, y, type, dam)
diff --git a/game/modules/tome/data/talents/cursed/cursed-aura.lua b/game/modules/tome/data/talents/cursed/cursed-aura.lua
index 2bb04ed576..b1496f576e 100644
--- a/game/modules/tome/data/talents/cursed/cursed-aura.lua
+++ b/game/modules/tome/data/talents/cursed/cursed-aura.lua
@@ -32,7 +32,7 @@ newTalent{
 	cooldown = 0,
 	no_energy = true,
 	no_npc_use = true,
-	no_unlearn_last = true,
+	--no_unlearn_last = true,
 	-- list of all curses
 	getCurses = function(self, t)
 		return { self.EFF_CURSE_OF_CORPSES, self.EFF_CURSE_OF_MADNESS, self.EFF_CURSE_OF_MISFORTUNE, self.EFF_CURSE_OF_NIGHTMARES, self.EFF_CURSE_OF_SHROUDS }
@@ -109,6 +109,7 @@ newTalent{
 	on_onTakeOff = function(self, t, o)
 		t.updateCurses(self, t)
 	end,
+	
 	-- chooses whether the player accepts the cursed aura tree when a cursable item is found..only offered once for Afflicted classes
 	chooseCursedAuraTree = function(self, t)
 		local choose = false
@@ -224,6 +225,10 @@ newTalent{
 		t.curseFloor(self, t, self.x, self.y)
 		t.updateCurses(self, t)
 	end,
+	on_unlearn = function(self, t)
+		-- turn off cursed aura (which gets disabled, but does not turn off)
+		t.setCursedAura(self, t, nil)
+	end,
 	on_pre_use = function(self, t, silent)
 		return self:getTalentLevelRaw(t) >= 5
 	end,
diff --git a/game/modules/tome/data/talents/psionic/focus.lua b/game/modules/tome/data/talents/psionic/focus.lua
index d80b3f181e..a662f2b575 100644
--- a/game/modules/tome/data/talents/psionic/focus.lua
+++ b/game/modules/tome/data/talents/psionic/focus.lua
@@ -36,6 +36,7 @@ newTalent{
 	psi = 10,
 	tactical = { ATTACK = function(self, t, target)
 		local val = { PHYSICAL = 2}
+		local gem_level = getGemLevel(self)
 		if gem_level > 0 and not target.dead and self:knowTalent(self.T_CONDUIT) and self:isTalentActive(self.T_CONDUIT) then
 			local c =  self:getTalentFromId(self.T_CONDUIT)
 			local auras = self:isTalentActive(c.id)
diff --git a/game/modules/tome/data/timed_effects/other.lua b/game/modules/tome/data/timed_effects/other.lua
index 11097f1e08..27827e66e4 100644
--- a/game/modules/tome/data/timed_effects/other.lua
+++ b/game/modules/tome/data/timed_effects/other.lua
@@ -774,7 +774,7 @@ newEffect{
 	cancel_on_level_change = true,
 	parameters = {},
 	getMindResistChange = function(level) return -level * 3 end,
-	getConfusionImmuneChange = function(level) return -level * 4 end,
+	getConfusionImmuneChange = function(level) return -level * 0.04 end,
 	getCombatCriticalPowerChange = function(level) return level * 3 end,
 	getOffHandMultChange = function(level) return level * 4 end,
 	getLckChange = function(eff, level)
@@ -796,7 +796,7 @@ newEffect{
 #CRIMSON#Level 3: %sConspirator: When you are confused, any foe that hits you or that you hit in melee becomes confused.
 #CRIMSON#Level 4: %sMania: Any time you take more than %d%% damage during a single turn, the remaining cooldown of one of your talents is reduced by 1.]]):format(
 		level, self.cursed_aura == self.EFF_CURSE_OF_MADNESS and ", Cursed Aura" or "",
-		def.getMindResistChange(level), def.getConfusionImmuneChange(level),
+		def.getMindResistChange(level), def.getConfusionImmuneChange(level) * 100,
 		bonusLevel >= 1 and "#WHITE#" or "#GREY#", def.getCombatCriticalPowerChange(math.max(level, 1)), def.getOffHandMultChange(math.max(level, 1)),
 		bonusLevel >= 2 and "#WHITE#" or "#GREY#", def.getLckChange(eff, math.max(level, 2)), def.getDexChange(math.max(level, 2)),
 		bonusLevel >= 3 and "#WHITE#" or "#GREY#",
-- 
GitLab