From be121b1ba97d61f1d909046498f562fb00ea0a47 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Sun, 18 Dec 2011 17:53:09 +0000
Subject: [PATCH] New "unavailable" category in the use talent menu Fixed staff
 of absorption quest when loosing the ambush Grand Arrival: Stone Golem
 correctly checks for stun immunity

git-svn-id: http://svn.net-core.org/repos/t-engine4@4729 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/data/chats/last-hope-elder.lua      | 2 +-
 game/modules/tome/data/damage_types.lua               | 2 +-
 game/modules/tome/data/talents/gifts/summon-melee.lua | 2 +-
 game/modules/tome/dialogs/UseTalents.lua              | 8 +++++++-
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/game/modules/tome/data/chats/last-hope-elder.lua b/game/modules/tome/data/chats/last-hope-elder.lua
index 2f6a76a8fa..0f210f4147 100644
--- a/game/modules/tome/data/chats/last-hope-elder.lua
+++ b/game/modules/tome/data/chats/last-hope-elder.lua
@@ -33,7 +33,7 @@ The staff you describe reminds me of an artifact of great power from ancient tim
 		{"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:findInAllInventoriesBy("define_as", "STAFF_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:findInAllInventoriesBy("define_as", "STAFF_ABSORPTION") and player:isQuestStatus("staff-absorption", engine.Quest.COMPLETED, "ambush-finish") end},
+		 jump="lost_staff", cond=function(npc, player) return 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 082bf53749..ed6b3d4b59 100644
--- a/game/modules/tome/data/damage_types.lua
+++ b/game/modules/tome/data/damage_types.lua
@@ -1929,7 +1929,7 @@ newDamageType{
 			elseif dam.foes then if src:reactionToward(target) < 0 then ok = true end
 			else ok = true
 			end
-			if ok then target:setEffect(dam.eff, dam.dur, table.clone(dam.p)) end
+			if ok and (not dam.check_immune or target:canBe(dam.check_immune)) then target:setEffect(dam.eff, dam.dur, table.clone(dam.p)) end
 		end
 	end,
 }
diff --git a/game/modules/tome/data/talents/gifts/summon-melee.lua b/game/modules/tome/data/talents/gifts/summon-melee.lua
index 73628b114b..2bccf865da 100644
--- a/game/modules/tome/data/talents/gifts/summon-melee.lua
+++ b/game/modules/tome/data/talents/gifts/summon-melee.lua
@@ -320,7 +320,7 @@ newTalent{
 	end,
 	on_arrival = function(self, t, m)
 		local tg = {type="ball", range=self:getTalentRange(t), radius=self:getTalentRadius(t), talent=t, x=m.x, y=m.y}
-		self:project(tg, m.x, m.y, DamageType.TEMP_EFFECT, {foes=true, eff=self.EFF_DAZED, dur=1+self:getTalentLevelRaw(t)/2, p={}}, {type="flame"})
+		self:project(tg, m.x, m.y, DamageType.TEMP_EFFECT, {foes=true, eff=self.EFF_DAZED, check_immune="stun", dur=1+self:getTalentLevelRaw(t)/2, p={}}, {type="flame"})
 	end,
 	requires_target = true,
 	action = function(self, t)
diff --git a/game/modules/tome/dialogs/UseTalents.lua b/game/modules/tome/dialogs/UseTalents.lua
index 3a878a8a64..a53a5cd319 100644
--- a/game/modules/tome/dialogs/UseTalents.lua
+++ b/game/modules/tome/dialogs/UseTalents.lua
@@ -230,7 +230,7 @@ function _M:generateList()
 	end
 ]]
 
-	local actives, sustains, sustained, cooldowns = {}, {}, {}, {}
+	local actives, sustains, sustained, unavailables, cooldowns = {}, {}, {}, {}, {}
 	local chars = {}
 
 	-- Find all talents of this school
@@ -242,6 +242,9 @@ function _M:generateList()
 			if self.actor:isTalentCoolingDown(t) then
 				nodes = cooldowns
 				status = tstring{{"color", "LIGHT_RED"}, self.actor:isTalentCoolingDown(t).." turns"}
+			elseif not self.actor:preUseTalent(t) then
+				nodes = unavailables
+				status = tstring{{"color", "GREY"}, "Unavailable"}
 			elseif t.mode == "sustained" then
 				if self.actor:isTalentActive(t.id) then nodes = sustained end
 				status = self.actor:isTalentActive(t.id) and tstring{{"color", "YELLOW"}, "Sustaining"} or tstring{{"color", "LIGHT_GREEN"}, "Sustain"}
@@ -271,10 +274,12 @@ function _M:generateList()
 	table.sort(sustains, function(a,b) return a.cname < b.cname end)
 	table.sort(sustained, function(a,b) return a.cname < b.cname end)
 	table.sort(cooldowns, function(a,b) return a.cname < b.cname end)
+	table.sort(unavailables, function(a,b) return a.cname < b.cname end)
 	for i, node in ipairs(actives) do node.char = self:makeKeyChar(letter) chars[node.char] = node letter = letter + 1 end
 	for i, node in ipairs(sustains) do node.char = self:makeKeyChar(letter) chars[node.char] = node letter = letter + 1 end
 	for i, node in ipairs(sustained) do node.char = self:makeKeyChar(letter) chars[node.char] = node letter = letter + 1 end
 	for i, node in ipairs(cooldowns) do node.char = self:makeKeyChar(letter) chars[node.char] = node letter = letter + 1 end
+	for i, node in ipairs(unavailables) do node.char = self:makeKeyChar(letter) chars[node.char] = node letter = letter + 1 end
 
 
 	list = {
@@ -282,6 +287,7 @@ function _M:generateList()
 		{ char='', name=('#{bold}#Sustainable talents#{normal}#'):toTString(), status='', hotkey='', desc="All sustainable talents you can currently use.", color=function() return colors.simple(colors.LIGHT_GREEN) end, nodes=sustains, shown=true },
 		{ char='', name=('#{bold}#Sustained talents#{normal}#'):toTString(), status='', hotkey='', desc="All sustainable talents you currently sustain, using them will de-activate them.", color=function() return colors.simple(colors.YELLOW) end, nodes=sustained, shown=true },
 		{ char='', name=('#{bold}#Cooling down talents#{normal}#'):toTString(), status='', hotkey='', desc="All talents you have used that are still cooling down.", color=function() return colors.simple(colors.LIGHT_RED) end, nodes=cooldowns, shown=true },
+		{ char='', name=('#{bold}#Unavailable talents#{normal}#'):toTString(), status='', hotkey='', desc="All talents you have that do not have enough resources, or satisfy other dependencies.", color=function() return colors.simple(colors.GREY) end, nodes=unavailables, shown=true },
 		chars = chars,
 	}
 	self.list = list
-- 
GitLab