From 84e7ba315c63d9ed145e079b6dd6117f44a1f155 Mon Sep 17 00:00:00 2001
From: Alexander Sedov <alex0player@gmail.com>
Date: Thu, 12 Feb 2015 18:15:21 +0300
Subject: [PATCH] Fixed mage apprentice being squashed by chronomancers and
 archmages beaming down.

---
 game/modules/tome/class/Encounter.lua | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/game/modules/tome/class/Encounter.lua b/game/modules/tome/class/Encounter.lua
index 03208ea124..17088a326b 100644
--- a/game/modules/tome/class/Encounter.lua
+++ b/game/modules/tome/class/Encounter.lua
@@ -85,8 +85,11 @@ end
 function _M:findSpot(who, what)
 	if not who then return end
 	what = what or "block_move"
+	-- check the original spot first, dammit, the world map does a lot to ensure apprentice is in the right place
+	local check_spots = {{who.x, who.y}}
+	table.append(check_spots, table.values(util.adjacentCoords(who.x, who.y)))
 	local spots = {}
-	for _, coord in pairs(util.adjacentCoords(who.x, who.y)) do if game.level.map:isBound(coord[1], coord[2]) then
+	for _, coord in ipairs(check_spots) do if game.level.map:isBound(coord[1], coord[2]) then
 		if not game.level.map:checkAllEntities(coord[1], coord[2], what, who) and game.level.map:checkAllEntities(coord[1], coord[2], "can_encounter", who) and not game.level.map:checkAllEntities(coord[1], coord[2], "change_level") then
 			spots[#spots+1] = {coord[1], coord[2]}
 		end
-- 
GitLab