From 4bd6bf1c0402c77b8917f59410f3e99d2243e539 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Fri, 29 Oct 2010 23:15:05 +0000
Subject: [PATCH] Reworked Divination spells, there are now: Keen Senses,
 Arcane Eye, Vision and Premonition

git-svn-id: http://svn.net-core.org/repos/t-engine4@1700 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/Actor.lua             |  2 +-
 game/modules/tome/data/damage_types.lua       |  7 +++
 .../tome/data/talents/spells/divination.lua   | 63 +++++++++++--------
 game/modules/tome/data/timed_effects.lua      | 17 +++++
 .../tome/data/zones/tempest-peak/zone.lua     |  2 +-
 5 files changed, 62 insertions(+), 29 deletions(-)

diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index 1f6301e3de..9435f0b69f 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -1515,7 +1515,7 @@ function _M:canSeeNoCache(actor, def, def_pct)
 
 	-- Check for stealth. Checks against the target cunning and level
 	if actor:attr("stealth") and actor ~= self then
-		local def = self.level / 2 + self:getCun(25)
+		local def = self.level / 2 + self:getCun(25) + (self:attr("see_stealth") or 0)
 		local hit, chance = self:checkHit(def, actor:attr("stealth") + (actor:attr("inc_stealth") or 0), 0, 100)
 		if not hit then
 			return false, chance
diff --git a/game/modules/tome/data/damage_types.lua b/game/modules/tome/data/damage_types.lua
index 5d9fb588f0..2e76063868 100644
--- a/game/modules/tome/data/damage_types.lua
+++ b/game/modules/tome/data/damage_types.lua
@@ -38,6 +38,12 @@ setDefaultProjector(function(src, x, y, type, dam)
 		end
 		print("[PROJECTOR] after difficulty dam", dam)
 
+		-- Preemptive shielding
+		if target.isTalentActive and target:isTalentActive(target.T_PREMONITION) then
+			local t = target:getTalentFromId(target.T_PREMONITION)
+			t.on_damage(target, target.T_PREMONITION, type)
+		end
+
 		-- Increases damage
 		if src.inc_damage then
 			local inc = (src.inc_damage.all or 0) + (src.inc_damage[type] or 0)
@@ -58,6 +64,7 @@ setDefaultProjector(function(src, x, y, type, dam)
 		end
 		print("[PROJECTOR] after resists dam", dam)
 
+		-- Static reduce damage
 		if target.isTalentActive and target:isTalentActive(target.T_ANTIMAGIC_SHIELD) then
 			local t = target:getTalentFromId(target.T_ANTIMAGIC_SHIELD)
 			dam = t.on_damage(target, target.T_ANTIMAGIC_SHIELD, type, dam)
diff --git a/game/modules/tome/data/talents/spells/divination.lua b/game/modules/tome/data/talents/spells/divination.lua
index 4792b52974..f5ae4aed45 100644
--- a/game/modules/tome/data/talents/spells/divination.lua
+++ b/game/modules/tome/data/talents/spells/divination.lua
@@ -18,29 +18,35 @@
 -- darkgod@te4.org
 
 newTalent{
-	name = "Sense",
+	name = "Keen Senses",
 	type = {"spell/divination", 1},
 	require = spells_req1,
+	mode = "sustained",
 	points = 5,
-	random_ego = "utility",
-	mana = 10,
-	cooldown = 10,
-	action = function(self, t)
-		local rad = 10 + self:combatSpellpower(0.1) * self:getTalentLevel(t)
-		self:setEffect(self.EFF_SENSE, 2, {
-			range = rad,
-			actor = 1,
-			object = (self:getTalentLevel(t) >= 2) and 1 or 0,
-			trap = (self:getTalentLevel(t) >= 5) and 1 or 0,
-		})
+	sustain_mana = 40,
+	cooldown = 30,
+	activate = function(self, t)
 		game:playSoundNear(self, "talents/spell_generic")
+		return {
+			invis = self:addTemporaryValue("see_invisible", self:combatTalentSpellDamage(t, 2, 45)),
+			stealth = self:addTemporaryValue("see_stealth", self:combatTalentSpellDamage(t, 2, 20)),
+			crit = self:addTemporaryValue("combat_spellcrit", self:combatTalentSpellDamage(t, 2, 12)),
+		}
+	end,
+	deactivate = function(self, t, p)
+		self:removeTemporaryValue("see_invisible", p.invis)
+		self:removeTemporaryValue("see_stealth", p.stealth)
+		self:removeTemporaryValue("combat_spellcrit", p.crit)
 		return true
 	end,
 	info = function(self, t)
-		return ([[Sense foes around you in a radius of %d.
-		At level 2 it detects objects.
-		At level 5 it detects traps.
-		The radius will increase with the Magic stat]]):format(10 + self:combatSpellpower(0.1) * self:getTalentLevel(t))
+		return ([[You focus your senses, getting informations from moments in the future.
+		Improves see invisible +%d.
+		Improves see through stealth +%d.
+		Improves critical spell chance +%d%%.
+		The effects will improve with the Magic stat]]):format(
+			self:combatTalentSpellDamage(t, 2, 45), self:combatTalentSpellDamage(t, 2, 20), self:combatTalentSpellDamage(t, 2, 12)
+		)
 	end,
 }
 
@@ -97,30 +103,33 @@ newTalent{
 }
 
 newTalent{
-	name = "Telepathy",
+	name = "Premonition",
 	type = {"spell/divination", 4},
 	mode = "sustained",
 	require = spells_req4,
 	points = 5,
-	sustain_mana = 200,
+	sustain_mana = 120,
 	cooldown = 30,
+	on_damage = function(self, t, damtype)
+		if damtype == DamageType.PHYSICAL then return end
+
+		if not self:hasEffect(self.EFF_PREMONITION_SHIELD) then
+			self:setEffect(self.EFF_PREMONITION_SHIELD, 5, {damtype=damtype, resist=10 + self:combatTalentSpellDamage(t, 2, 25)})
+			game.logPlayer(self, "#OLIVE_DRAB#Your premonition allows you to raise a shield just in time!")
+		end
+	end,
 	activate = function(self, t)
-		-- There is an implicit +10, as it is the default radius
-		local rad = self:combatTalentSpellDamage(t, 2, 10)
 		game:playSoundNear(self, "talents/spell_generic")
 		return {
-			esp = self:addTemporaryValue("esp", {range=rad, all=1}),
-			drain = self:addTemporaryValue("mana_regen", -3 * self:getTalentLevelRaw(t)),
 		}
 	end,
 	deactivate = function(self, t, p)
-		self:removeTemporaryValue("esp", p.esp)
-		self:removeTemporaryValue("mana_regen", p.drain)
 		return true
 	end,
 	info = function(self, t)
-		return ([[Allows you to sense the presence of foes, in a radius of %d.
-		This powerful spell will continuously drain mana while active.
-		The bonus will increase with the Magic stat]]):format(10 + self:combatTalentSpellDamage(t, 2, 10))
+		return ([[Echos of the future flashes before your eyes, allowing you to sense some incomming attacks.
+		If the attack is elemental or magical you will erect a temporary shield that reduces all damage of this type by %d%% for 5 turns.
+		This effect can only happen once every 5 turns.
+		The bonus will increase with the Magic stat]]):format(10 + self:combatTalentSpellDamage(t, 2, 25), 5)
 	end,
 }
diff --git a/game/modules/tome/data/timed_effects.lua b/game/modules/tome/data/timed_effects.lua
index 9154f78c29..f450552882 100644
--- a/game/modules/tome/data/timed_effects.lua
+++ b/game/modules/tome/data/timed_effects.lua
@@ -1918,3 +1918,20 @@ newEffect{
 		end
 	end,
 }
+
+newEffect{
+	name = "PREMONITION_SHIELD",
+	desc = "Premonition Shield",
+	long_desc = function(self, eff) return ("Reduces %s damage received by %d%%."):format(DamageType:get(eff.damtype).name, eff.resist) end,
+	type = "magical",
+	status = "beneficial",
+	parameters = { },
+	on_gain = function(self, err) return "#Target# casts a protective shield just in time!", "+Premonition Shield" end,
+	on_lose = function(self, err) return "The protective shield of #Target# disappears.", "-Premonition Shield" end,
+	activate = function(self, eff)
+		eff.tmpid = self:addTemporaryValue("resists", {[eff.damtype]=eff.resist})
+	end,
+	deactivate = function(self, eff)
+		self:removeTemporaryValue("resists", eff.tmpid)
+	end,
+}
diff --git a/game/modules/tome/data/zones/tempest-peak/zone.lua b/game/modules/tome/data/zones/tempest-peak/zone.lua
index 71520e799b..94be3e5831 100644
--- a/game/modules/tome/data/zones/tempest-peak/zone.lua
+++ b/game/modules/tome/data/zones/tempest-peak/zone.lua
@@ -38,7 +38,7 @@ return {
 			lite_room_chance = 100,
 			['.'] = "ROCKY_GROUND",
 			['#'] = "MOUNTAIN_WALL",
-			up = "UP",
+			up = "ROCKY_GROUND",
 			down = "DOWN",
 			door = "DOOR",
 		},
-- 
GitLab