From 1023ad7c3f7b7b7adf9ba0eb054be09f717a5fba Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Sat, 21 Aug 2010 20:53:42 +0000
Subject: [PATCH] NPCs will "transfer" their targets to their friends in sight
 if they do not have a target themselves

git-svn-id: http://svn.net-core.org/repos/t-engine4@1046 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/engine/ai/simple.lua                       |  2 +-
 game/modules/tome/class/NPC.lua                 | 10 ++++++++++
 game/modules/tome/data/quests/starter-zones.lua |  2 +-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/game/engine/ai/simple.lua b/game/engine/ai/simple.lua
index a3969265d3..7e7e321d3b 100644
--- a/game/engine/ai/simple.lua
+++ b/game/engine/ai/simple.lua
@@ -35,7 +35,7 @@ newAI("move_dmap", function(self)
 		if self:hasLOS(a.x, a.y) then return self:runAI("move_simple") end
 
 		local c = a:distanceMap(self.x, self.y)
-		if not c then return end
+		if not c then return self:runAI("move_simple") end
 		local dir = 5
 		for i = 1, 9 do
 			local sx, sy = util.coordAddDir(self.x, self.y, i)
diff --git a/game/modules/tome/class/NPC.lua b/game/modules/tome/class/NPC.lua
index 677730693a..cd56cf7f64 100644
--- a/game/modules/tome/class/NPC.lua
+++ b/game/modules/tome/class/NPC.lua
@@ -52,6 +52,16 @@ function _M:act()
 	if not self.energy.used then self:useEnergy() end
 end
 
+--- Give target to others
+function _M:seen_by(who)
+	if self.ai_target.actor then return end
+	if not who.ai_target then return end
+	if not who.ai_target.actor then return end
+	if self:reactionToward(who) < 0 then return end
+	if not who:canSee(who.ai_target.actor) then return end
+	self:setTarget(who.ai_target.actor)
+end
+
 --- Called by ActorLife interface
 -- We use it to pass aggression values to the AIs
 function _M:onTakeHit(value, src)
diff --git a/game/modules/tome/data/quests/starter-zones.lua b/game/modules/tome/data/quests/starter-zones.lua
index cb3b9fcda6..b1c182080d 100644
--- a/game/modules/tome/data/quests/starter-zones.lua
+++ b/game/modules/tome/data/quests/starter-zones.lua
@@ -24,7 +24,7 @@ desc = function(self, who)
 	desc[#desc+1] = "It is time to explore some new places dark, forgotten and dangerous ones."
 	desc[#desc+1] = "The Old Forest is just south-west of the town of Bree."
 	desc[#desc+1] = "The Maze is west of Bree."
-	desc[#desc+1] = "The Sandworm is to the far west of Bree, near the sea."
+	desc[#desc+1] = "The Sandworm Lair is to the far west of Bree, near the sea."
 	desc[#desc+1] = "Carn Dûm is to the north of Amon Sûl."
 	if self:isCompleted("old-forest") then
 		desc[#desc+1] = "#LIGHT_GREEN#* You have explored the Old Forest and vanquished the Old Man Willow.#WHITE#"
-- 
GitLab