From 6c18ab8f6d7c059aedc6b4cd9d12e8ec422f8b08 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Sun, 6 Jun 2010 16:28:56 +0000
Subject: [PATCH] monsters now have lite(does not show)/infravision/...
 stealth/invis now prevents the monsters from targetting you light makes it
 obvious where you are even if stealth/invis is active stealth disables light
 automatically (invis does NOT) a warning pops up if a monster targets you
 while stealthed or invis

git-svn-id: http://svn.net-core.org/repos/t-engine4@755 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/Actor.lua                   |  2 ++
 game/modules/tome/class/NPC.lua                     |  4 ++++
 game/modules/tome/class/Player.lua                  | 13 ++++++++++++-
 game/modules/tome/data/general/npcs/ant.lua         |  1 +
 .../tome/data/general/npcs/aquatic_critter.lua      |  1 +
 .../tome/data/general/npcs/aquatic_demon.lua        |  1 +
 game/modules/tome/data/general/npcs/bear.lua        |  1 +
 game/modules/tome/data/general/npcs/canine.lua      |  1 +
 game/modules/tome/data/general/npcs/ghoul.lua       |  1 +
 game/modules/tome/data/general/npcs/jelly.lua       |  1 +
 game/modules/tome/data/general/npcs/minotaur.lua    |  2 ++
 game/modules/tome/data/general/npcs/molds.lua       |  1 +
 game/modules/tome/data/general/npcs/mummy.lua       |  1 +
 game/modules/tome/data/general/npcs/ooze.lua        |  1 +
 game/modules/tome/data/general/npcs/orc.lua         |  2 ++
 game/modules/tome/data/general/npcs/plant.lua       |  1 +
 game/modules/tome/data/general/npcs/rodent.lua      |  1 +
 game/modules/tome/data/general/npcs/sandworm.lua    |  1 +
 game/modules/tome/data/general/npcs/skeleton.lua    |  1 +
 game/modules/tome/data/general/npcs/snake.lua       |  1 +
 game/modules/tome/data/general/npcs/spider.lua      |  1 +
 .../modules/tome/data/general/npcs/sunwall-town.lua |  1 +
 game/modules/tome/data/general/npcs/swarm.lua       |  1 +
 game/modules/tome/data/general/npcs/thieve.lua      |  1 +
 game/modules/tome/data/general/npcs/troll.lua       |  1 +
 game/modules/tome/data/general/npcs/vampire.lua     |  1 +
 game/modules/tome/data/general/npcs/vermin.lua      |  1 +
 game/modules/tome/data/general/npcs/wight.lua       |  1 +
 .../tome/data/general/objects/egos/rings.lua        |  2 ++
 game/modules/tome/data/talents/cunning/stealth.lua  |  4 ++--
 game/modules/tome/data/talents/spells/phantasm.lua  |  1 +
 31 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index 8abb155c99..5c2bbe8804 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -77,6 +77,8 @@ function _M:init(t, no_default)
 	self.unused_talents =  self.unused_talents or 0
 	self.unused_talents_types = self.unused_talents_types or 0
 
+	t.lite = t.lite or 0
+
 	t.size_category = t.size_category or 3
 	t.rank = t.rank or 2
 
diff --git a/game/modules/tome/class/NPC.lua b/game/modules/tome/class/NPC.lua
index 71d4c364da..6c082baf04 100644
--- a/game/modules/tome/class/NPC.lua
+++ b/game/modules/tome/class/NPC.lua
@@ -34,6 +34,10 @@ function _M:act()
 	if not mod.class.Actor.act(self) then return end
 
 	-- Compute FOV, if needed
+--	if self.lite > 0 then
+--	print("lite", self.name, self.lite)
+--		self:computeFOV(self.lite, "block_sight", function(x, y, dx, dy, sqdist) game.level.map:applyLite(x, y) end, true, true)
+--	end
 	self:computeFOV(self.sight or 20)
 
 	-- Let the AI think .... beware of Shub !
diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua
index 3f9c8a76b8..54353ddd19 100644
--- a/game/modules/tome/class/Player.lua
+++ b/game/modules/tome/class/Player.lua
@@ -159,7 +159,7 @@ function _M:playerFOV()
 		self:computeFOV(self.sight or 20, "block_sight", function(x, y, dx, dy, sqdist)
 			game.level.map:apply(x, y, math.max((20 - math.sqrt(sqdist)) / 14, 0.6))
 		end, true, false, true)
-		if self.lite == 0 then game.level.map:applyLite(self.x, self.y)
+		if self.lite <= 0 then game.level.map:applyLite(self.x, self.y)
 		else self:computeFOV(self.lite, "block_sight", function(x, y, dx, dy, sqdist) game.level.map:applyLite(x, y) end, true, true, true) end
 	end
 
@@ -526,6 +526,17 @@ function _M:useOrbPortal(portal)
 	if portal.message then game.logPlayer(self, portal.message) end
 end
 
+--- Tell us when we are targetted
+function _M:on_targeted(act)
+	if self:attr("invisible") or self:attr("stealth") then
+		if self:canSee(act) and game.level.map.seens(act.x, act.y) then
+			game.logPlayer(self, "#LIGHT_RED#%s has seen you!", act.name:capitalize())
+		else
+			game.logPlayer(self, "#LIGHT_RED#Something has seen you!")
+		end
+	end
+end
+
 ------ Quest Events
 function _M:on_quest_grant(quest)
 	game.logPlayer(self, "#LIGHT_GREEN#Accepted quest '%s'! #WHITE#(Press CTRL+Q to see the quest log)", quest.name)
diff --git a/game/modules/tome/data/general/npcs/ant.lua b/game/modules/tome/data/general/npcs/ant.lua
index a6b681dc49..b576f22589 100644
--- a/game/modules/tome/data/general/npcs/ant.lua
+++ b/game/modules/tome/data/general/npcs/ant.lua
@@ -32,6 +32,7 @@ newEntity{
 	energy = { mod=1 },
 	combat_armor = 1, combat_def = 1,
 	combat = { dam=5, atk=15, apr=7, dammod={str=0.6} },
+	infravision = 20,
 	max_life = resolvers.rngavg(10,20),
 	rank = 1,
 	size_category = 1,
diff --git a/game/modules/tome/data/general/npcs/aquatic_critter.lua b/game/modules/tome/data/general/npcs/aquatic_critter.lua
index 59935e0e57..fd7438ade4 100644
--- a/game/modules/tome/data/general/npcs/aquatic_critter.lua
+++ b/game/modules/tome/data/general/npcs/aquatic_critter.lua
@@ -33,6 +33,7 @@ newEntity{
 	combat_armor = 1, combat_def = 1,
 	combat = { dam=5, atk=15, apr=7, dammod={str=0.6} },
 	max_life = resolvers.rngavg(10,20), life_rating = 6,
+	infravision = 20,
 	rank = 1,
 	size_category = 2,
 	can_breath={water=1},
diff --git a/game/modules/tome/data/general/npcs/aquatic_demon.lua b/game/modules/tome/data/general/npcs/aquatic_demon.lua
index 69fc005bc2..43f9d9e37c 100644
--- a/game/modules/tome/data/general/npcs/aquatic_demon.lua
+++ b/game/modules/tome/data/general/npcs/aquatic_demon.lua
@@ -33,6 +33,7 @@ newEntity{
 	combat_armor = 1, combat_def = 1,
 	combat = { dam=5, atk=15, apr=7, dammod={str=0.6} },
 	max_life = resolvers.rngavg(100,120),
+	infravision = 20,
 	open_door = true,
 	rank = 2,
 	size_category = 3,
diff --git a/game/modules/tome/data/general/npcs/bear.lua b/game/modules/tome/data/general/npcs/bear.lua
index 1b7db8a2fe..89725410df 100644
--- a/game/modules/tome/data/general/npcs/bear.lua
+++ b/game/modules/tome/data/general/npcs/bear.lua
@@ -33,6 +33,7 @@ newEntity{
 	ai = "dumb_talented_simple", ai_state = { talent_in=5, },
 	energy = { mod=0.9 },
 	stats = { str=18, dex=13, mag=5, con=15 },
+	infravision = 20,
 	rank = 2,
 	size_category = 4,
 
diff --git a/game/modules/tome/data/general/npcs/canine.lua b/game/modules/tome/data/general/npcs/canine.lua
index fc3aea58f3..3705a11f71 100644
--- a/game/modules/tome/data/general/npcs/canine.lua
+++ b/game/modules/tome/data/general/npcs/canine.lua
@@ -30,6 +30,7 @@ newEntity{
 	max_stamina = 150,
 	rank = 1,
 	size_category = 2,
+	infravision = 20,
 
 	autolevel = "warrior",
 	ai = "dumb_talented_simple", ai_state = { talent_in=2, },
diff --git a/game/modules/tome/data/general/npcs/ghoul.lua b/game/modules/tome/data/general/npcs/ghoul.lua
index fd07dba3bd..adad1c5309 100644
--- a/game/modules/tome/data/general/npcs/ghoul.lua
+++ b/game/modules/tome/data/general/npcs/ghoul.lua
@@ -34,6 +34,7 @@ newEntity{
 	stats = { str=14, dex=12, mag=10, con=12 },
 	rank = 2,
 	size_category = 3,
+	infravision = 20,
 
 	resolvers.tmasteries{ ["technique/other"]=1, },
 
diff --git a/game/modules/tome/data/general/npcs/jelly.lua b/game/modules/tome/data/general/npcs/jelly.lua
index 43fe6efaa6..f1a605e7b1 100644
--- a/game/modules/tome/data/general/npcs/jelly.lua
+++ b/game/modules/tome/data/general/npcs/jelly.lua
@@ -35,6 +35,7 @@ newEntity{
 	never_move = 1,
 	rank = 2,
 	size_category = 3,
+	infravision = 20,
 
 	drops = resolvers.drops{chance=60, nb=1, {type="money"} },
 
diff --git a/game/modules/tome/data/general/npcs/minotaur.lua b/game/modules/tome/data/general/npcs/minotaur.lua
index 17ef1ca51d..329fa575a7 100644
--- a/game/modules/tome/data/general/npcs/minotaur.lua
+++ b/game/modules/tome/data/general/npcs/minotaur.lua
@@ -30,6 +30,8 @@ newEntity{
 	resolvers.drops{chance=20, nb=1, {} },
 	resolvers.drops{chance=40, nb=1, {type="money"} },
 
+	infravision = 20,
+	lite = 2,
 	max_stamina = 100,
 	life_rating = 13,
 	max_life = resolvers.rngavg(100,120),
diff --git a/game/modules/tome/data/general/npcs/molds.lua b/game/modules/tome/data/general/npcs/molds.lua
index 5df5934d59..129fb5c466 100644
--- a/game/modules/tome/data/general/npcs/molds.lua
+++ b/game/modules/tome/data/general/npcs/molds.lua
@@ -29,6 +29,7 @@ newEntity{
 	ai = "dumb_talented_simple", ai_state = { talent_in=1, },
 	stats = { str=10, dex=15, mag=3, con=3 },
 	energy = { mod=0.5 },
+	infravision = 20,
 	combat_armor = 1, combat_def = 1,
 	never_move = 1,
 	fear_immune = 1,
diff --git a/game/modules/tome/data/general/npcs/mummy.lua b/game/modules/tome/data/general/npcs/mummy.lua
index 25d44e74ab..c3b55e931e 100644
--- a/game/modules/tome/data/general/npcs/mummy.lua
+++ b/game/modules/tome/data/general/npcs/mummy.lua
@@ -31,6 +31,7 @@ newEntity{
 	ai = "dumb_talented_simple", ai_state = { talent_in=2, },
 	energy = { mod=0.8 },
 	stats = { str=14, dex=12, mag=10, con=12 },
+	infravision = 20,
 	rank = 2,
 	size_category = 3,
 
diff --git a/game/modules/tome/data/general/npcs/ooze.lua b/game/modules/tome/data/general/npcs/ooze.lua
index 666a75ecbd..ab6798b263 100644
--- a/game/modules/tome/data/general/npcs/ooze.lua
+++ b/game/modules/tome/data/general/npcs/ooze.lua
@@ -34,6 +34,7 @@ newEntity{
 	combat_armor = 1, combat_def = 1,
 	rank = 1,
 	size_category = 3,
+	infravision = 20,
 
 	resolvers.drops{chance=90, nb=1, {} },
 	resolvers.drops{chance=60, nb=1, {type="money"} },
diff --git a/game/modules/tome/data/general/npcs/orc.lua b/game/modules/tome/data/general/npcs/orc.lua
index 311714327c..5c69118bdc 100644
--- a/game/modules/tome/data/general/npcs/orc.lua
+++ b/game/modules/tome/data/general/npcs/orc.lua
@@ -30,6 +30,8 @@ newEntity{
 	body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1, QUIVER=1 },
 	resolvers.drops{chance=20, nb=1, {} },
 	resolvers.drops{chance=10, nb=1, {type="money"} },
+	infravision = 20,
+	lite = 2,
 
 	life_rating = 11,
 	rank = 2,
diff --git a/game/modules/tome/data/general/npcs/plant.lua b/game/modules/tome/data/general/npcs/plant.lua
index ce67cb5b96..cab14d82ef 100644
--- a/game/modules/tome/data/general/npcs/plant.lua
+++ b/game/modules/tome/data/general/npcs/plant.lua
@@ -31,6 +31,7 @@ newEntity{
 	ai = "dumb_talented_simple", ai_state = { talent_in=3, },
 	stats = { str=10, dex=10, mag=3, con=10 },
 	energy = { mod=1 },
+	infravision = 20,
 	combat_armor = 1, combat_def = 1,
 	rank = 1,
 	size_category = 1,
diff --git a/game/modules/tome/data/general/npcs/rodent.lua b/game/modules/tome/data/general/npcs/rodent.lua
index 2e1be6e551..74d99a431b 100644
--- a/game/modules/tome/data/general/npcs/rodent.lua
+++ b/game/modules/tome/data/general/npcs/rodent.lua
@@ -25,6 +25,7 @@ newEntity{ --rodent base
 	display = "r", color=colors.WHITE,
 	can_multiply = 2,
 	body = { INVEN = 10 },
+	infravision = 20,
 
 	autolevel = "warrior",
 	ai = "dumb_talented_simple", ai_state = { talent_in=3, },
diff --git a/game/modules/tome/data/general/npcs/sandworm.lua b/game/modules/tome/data/general/npcs/sandworm.lua
index ef43accc8c..c00c59d5fa 100644
--- a/game/modules/tome/data/general/npcs/sandworm.lua
+++ b/game/modules/tome/data/general/npcs/sandworm.lua
@@ -26,6 +26,7 @@ newEntity{
 	level_range = {15, 50},
 	body = { INVEN = 10 },
 
+	infravision = 20,
 	max_life = 40, life_rating = 5,
 	max_stamina = 85,
 	max_mana = 85,
diff --git a/game/modules/tome/data/general/npcs/skeleton.lua b/game/modules/tome/data/general/npcs/skeleton.lua
index 58ed274725..40af081584 100644
--- a/game/modules/tome/data/general/npcs/skeleton.lua
+++ b/game/modules/tome/data/general/npcs/skeleton.lua
@@ -29,6 +29,7 @@ newEntity{
 	body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1, QUIVER=1 },
 	resolvers.drops{chance=20, nb=1, {} },
 	resolvers.drops{chance=60, nb=1, {type="money"} },
+	infravision = 20,
 	rank = 2,
 	size_category = 3,
 
diff --git a/game/modules/tome/data/general/npcs/snake.lua b/game/modules/tome/data/general/npcs/snake.lua
index fd69b80ffe..744fd2d80e 100644
--- a/game/modules/tome/data/general/npcs/snake.lua
+++ b/game/modules/tome/data/general/npcs/snake.lua
@@ -25,6 +25,7 @@ newEntity{
 	display = "J", color=colors.WHITE,
 	body = { INVEN = 10 },
 
+	infravision = 20,
 	max_stamina = 110,
 	rank = 2,
 	size_category = 2,
diff --git a/game/modules/tome/data/general/npcs/spider.lua b/game/modules/tome/data/general/npcs/spider.lua
index 9228894830..080b421174 100644
--- a/game/modules/tome/data/general/npcs/spider.lua
+++ b/game/modules/tome/data/general/npcs/spider.lua
@@ -29,6 +29,7 @@ newEntity{
 
 	body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 },
 
+	infravision = 20,
 	size_category = 2,
 	rank = 1,
 
diff --git a/game/modules/tome/data/general/npcs/sunwall-town.lua b/game/modules/tome/data/general/npcs/sunwall-town.lua
index 1e57a17ec9..13d1c1b452 100644
--- a/game/modules/tome/data/general/npcs/sunwall-town.lua
+++ b/game/modules/tome/data/general/npcs/sunwall-town.lua
@@ -29,6 +29,7 @@ newEntity{
 
 	body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1, QUIVER=1 },
 	resolvers.drops{chance=20, nb=1, {} },
+	lite = 3,
 
 	life_rating = 10,
 	rank = 2,
diff --git a/game/modules/tome/data/general/npcs/swarm.lua b/game/modules/tome/data/general/npcs/swarm.lua
index 893e6c6372..a2fcf64996 100644
--- a/game/modules/tome/data/general/npcs/swarm.lua
+++ b/game/modules/tome/data/general/npcs/swarm.lua
@@ -32,6 +32,7 @@ newEntity{
 	ai = "dumb_talented_simple", ai_state = { talent_in=1, },
 	stats = { str=1, dex=20, mag=3, con=1 },
 	energy = { mod=2 },
+	infravision = 20,
 	combat_armor = 1, combat_def = 10,
 	rank = 1,
 	size_category = 1,
diff --git a/game/modules/tome/data/general/npcs/thieve.lua b/game/modules/tome/data/general/npcs/thieve.lua
index df524ab95a..d5f72d58c4 100644
--- a/game/modules/tome/data/general/npcs/thieve.lua
+++ b/game/modules/tome/data/general/npcs/thieve.lua
@@ -34,6 +34,7 @@ newEntity{
 		{type="armor", subtype="light", autoreq=true}
 	},
 	resolvers.drops{chance=100, nb=2, {type="money"} },
+	infravision = 10,
 
 	max_stamina = 100,
 	rank = 2,
diff --git a/game/modules/tome/data/general/npcs/troll.lua b/game/modules/tome/data/general/npcs/troll.lua
index 4d7180d933..1e25974f55 100644
--- a/game/modules/tome/data/general/npcs/troll.lua
+++ b/game/modules/tome/data/general/npcs/troll.lua
@@ -30,6 +30,7 @@ newEntity{
 	resolvers.drops{chance=20, nb=1, {} },
 	resolvers.drops{chance=60, nb=1, {type="money"} },
 
+	infravision = 20,
 	life_rating = 15,
 	life_regen = 2,
 	max_stamina = 90,
diff --git a/game/modules/tome/data/general/npcs/vampire.lua b/game/modules/tome/data/general/npcs/vampire.lua
index 5731066dbd..ac6c642fab 100644
--- a/game/modules/tome/data/general/npcs/vampire.lua
+++ b/game/modules/tome/data/general/npcs/vampire.lua
@@ -51,6 +51,7 @@ newEntity{
 	ai = "dumb_talented_simple", ai_state = { talent_in=9, },
 	energy = { mod=1 },
 	stats = { str=12, dex=12, mag=12, con=12 },
+	infravision = 20,
 	life_regen = 3,
 	size_category = 3,
 	rank = 2,
diff --git a/game/modules/tome/data/general/npcs/vermin.lua b/game/modules/tome/data/general/npcs/vermin.lua
index 1e752d5257..462957e35d 100644
--- a/game/modules/tome/data/general/npcs/vermin.lua
+++ b/game/modules/tome/data/general/npcs/vermin.lua
@@ -31,6 +31,7 @@ newEntity{
 	energy = { mod=0.9 },
 	stats = { str=10, dex=15, mag=3, con=3 },
 	combat_armor = 1, combat_def = 1,
+	infravision = 20,
 	rank = 1,
 	size_category = 1,
 }
diff --git a/game/modules/tome/data/general/npcs/wight.lua b/game/modules/tome/data/general/npcs/wight.lua
index b382a8169c..38450aef4d 100644
--- a/game/modules/tome/data/general/npcs/wight.lua
+++ b/game/modules/tome/data/general/npcs/wight.lua
@@ -42,6 +42,7 @@ newEntity{
 	ai = "dumb_talented_simple", ai_state = { talent_in=4, },
 	energy = { mod=1 },
 	stats = { str=11, dex=11, mag=15, con=12 },
+	infravision = 20,
 	rank = 2,
 	size_category = 3,
 
diff --git a/game/modules/tome/data/general/objects/egos/rings.lua b/game/modules/tome/data/general/objects/egos/rings.lua
index 4861f64b52..7d24cbe72d 100644
--- a/game/modules/tome/data/general/objects/egos/rings.lua
+++ b/game/modules/tome/data/general/objects/egos/rings.lua
@@ -32,6 +32,8 @@ newEntity{
 
 newEntity{
 	name = " of invisibility",
+	desc = [[Allows the wearer to become invisible to normal sight
+Beware, you should take off your light, otherwise you will still be easily spotted.]],
 	level_range = {30, 40},
 	rarity = 4,
 	cost = 16,
diff --git a/game/modules/tome/data/talents/cunning/stealth.lua b/game/modules/tome/data/talents/cunning/stealth.lua
index f81966b346..1e915ab8bf 100644
--- a/game/modules/tome/data/talents/cunning/stealth.lua
+++ b/game/modules/tome/data/talents/cunning/stealth.lua
@@ -43,14 +43,14 @@ newTalent{
 
 		local res = {
 			stealth = self:addTemporaryValue("stealth", self:getCun(10) * self:getTalentLevel(t)),
---			lite = self:addTemporaryValue("lite", -100),
+			lite = self:addTemporaryValue("lite", -1000),
 		}
 		game.level.map:updateMap(self.x, self.y)
 		return res
 	end,
 	deactivate = function(self, t, p)
 		self:removeTemporaryValue("stealth", p.stealth)
---		self:removeTemporaryValue("lite", p.lite)
+		self:removeTemporaryValue("lite", p.lite)
 		game.level.map:updateMap(self.x, self.y)
 		return true
 	end,
diff --git a/game/modules/tome/data/talents/spells/phantasm.lua b/game/modules/tome/data/talents/spells/phantasm.lua
index 5a6e0dc2e9..7164e6504b 100644
--- a/game/modules/tome/data/talents/spells/phantasm.lua
+++ b/game/modules/tome/data/talents/spells/phantasm.lua
@@ -127,6 +127,7 @@ newTalent{
 	end,
 	info = function(self, t)
 		return ([[The caster fades from sight, granting %d bonus to invisibility.
+		Beware, you should take off your light, otherwise you will still be easily spotted.
 		This powerful spell constantly drains your mana while active.
 		The bonus will increase with the Magic stat]]):format(4 + self:combatSpellpower(0.04) * self:getTalentLevel(t))
 	end,
-- 
GitLab