From 15108267a2970a1b800a7fb6d981d8e0eabbeca6 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Thu, 5 May 2011 16:24:36 +0000
Subject: [PATCH] Fixed a rare bug when patrols chase players on the worldmap
 Harno the messanger should correctly pop even if Golbug is killed on the
 Demon Plane

git-svn-id: http://svn.net-core.org/repos/t-engine4@3310 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/ai/worldnpcs.lua                  | 2 +-
 game/modules/tome/class/Game.lua                    | 7 +++----
 game/modules/tome/class/Player.lua                  | 2 +-
 game/modules/tome/data/zones/reknor-escape/npcs.lua | 1 +
 game/modules/tome/data/zones/reknor/npcs.lua        | 8 +++++---
 5 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/game/modules/tome/ai/worldnpcs.lua b/game/modules/tome/ai/worldnpcs.lua
index d57db76bd9..8d8002e982 100644
--- a/game/modules/tome/ai/worldnpcs.lua
+++ b/game/modules/tome/ai/worldnpcs.lua
@@ -49,7 +49,7 @@ end)
 
 newAI("world_patrol", function(self)
 	if not self.energy.used then
-		if self:runAI("target_world") and self:reactionToward(self.ai_target.actor) < 0 then
+		if self:runAI("target_world") and self:reactionToward(self.ai_target.actor) < 0 and game.level.map:isBound(self.ai_target.actor.x, self.ai_target.actor.y) then
 			self:runAI("move_dmap")
 		else
 			self:runAI("move_world_patrol")
diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua
index bfec13e39d..768dd514af 100644
--- a/game/modules/tome/class/Game.lua
+++ b/game/modules/tome/class/Game.lua
@@ -841,7 +841,7 @@ function _M:display(nb_keyframes)
 			self.zone_name_w, self.zone_name_h,
 			self.zone_name_tw, self.zone_name_th
 		)
-		
+
 		-- emotes display
 		map:displayEmotes(nb_keyframe or 1)
 
@@ -871,9 +871,9 @@ function _M:display(nb_keyframes)
 	engine.GameTurnBased.display(self, nb_keyframes)
 
 	-- Tooltip is displayed over all else, even dialogs
-	
+
 	local mx, my, button = core.mouse.get()
-	
+
 	if self.tooltip.w and mx > self.w - self.tooltip.w and my > self.h - self.tooltip.h then
 		self:targetDisplayTooltip(self.level.map.display_x, self.h)
 	else
@@ -934,7 +934,6 @@ function _M:setupCommands()
 --			self.state:debugRandomZone()
 --			local m = game.zone:makeEntity(game.level, "actor", {random_boss=true}, nil, true)
 --			if m then game.zone:addEntity(game.level, m, "actor", game.player.x, game.player.y + 1) end
-			self.player:setEffect(self.player.EFF_STUNNED, 10, {})
 		end end,
 	}
 
diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua
index b7a7b6ed25..400575dede 100644
--- a/game/modules/tome/class/Player.lua
+++ b/game/modules/tome/class/Player.lua
@@ -183,7 +183,7 @@ function _M:move(x, y, force)
 		game.level.map:moveViewSurround(self.x, self.y, 8, 8)
 		game.level.map.attrs(self.x, self.y, "walked", true)
 
-		self:describeFloor(self.x, self.y)
+		if self.describeFloor then self:describeFloor(self.x, self.y) end
 	end
 
 	-- Update wilderness coords
diff --git a/game/modules/tome/data/zones/reknor-escape/npcs.lua b/game/modules/tome/data/zones/reknor-escape/npcs.lua
index ad3e2062cb..329c584fed 100644
--- a/game/modules/tome/data/zones/reknor-escape/npcs.lua
+++ b/game/modules/tome/data/zones/reknor-escape/npcs.lua
@@ -82,6 +82,7 @@ newEntity{ define_as = "NORGAN",
 	move_others=true,
 	never_anger = true,
 	remove_from_party_on_death = true,
+	silent_levelup = true,
 
 	body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1, LITE=1 },
 	equipment = resolvers.equip{
diff --git a/game/modules/tome/data/zones/reknor/npcs.lua b/game/modules/tome/data/zones/reknor/npcs.lua
index 56959481f7..c51858ae52 100644
--- a/game/modules/tome/data/zones/reknor/npcs.lua
+++ b/game/modules/tome/data/zones/reknor/npcs.lua
@@ -102,9 +102,11 @@ newEntity{ define_as = "GOLBUG",
 		game.player:setQuestStatus("orc-hunt", engine.Quest.DONE)
 		game.player:grantQuest("wild-wild-east")
 
-		-- Add the herald
-		local harno = game.zone:makeEntityByName(game.level, "actor", "HARNO")
-		game.zone:addEntity(game.level, harno, "actor", 0, 13)
+		-- Add the herald, at the end of tick because we might have changed levels (like with a Demon Plane spell)
+		game:onTickEnd(function()
+			local harno = game.zone:makeEntityByName(game.level, "actor", "HARNO")
+			game.zone:addEntity(game.level, harno, "actor", 0, 13)
+		end)
 	end,
 }
 
-- 
GitLab