From d2805a8001f2246bbe9745401c5a352268a4fc91 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Wed, 1 Jun 2011 20:40:49 +0000
Subject: [PATCH] When using Dominant Will it is impossible to access the
 slave's inventory Fixed the error spam when freezing creatures

git-svn-id: http://svn.net-core.org/repos/t-engine4@3533 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/engines/default/engine/Map.lua                  |  4 ++--
 game/modules/tome/class/Actor.lua                    |  2 +-
 game/modules/tome/class/Game.lua                     |  7 +++++++
 game/modules/tome/class/Player.lua                   |  2 +-
 .../tome/data/general/encounters/maj-eyal.lua        |  1 +
 game/modules/tome/data/quests/paradoxology.lua       |  2 +-
 game/modules/tome/data/talents/cunning/tactical.lua  | 12 ++++++------
 game/modules/tome/data/timed_effects.lua             |  1 +
 8 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/game/engines/default/engine/Map.lua b/game/engines/default/engine/Map.lua
index 2296c844e2..7d74de5e6f 100644
--- a/game/engines/default/engine/Map.lua
+++ b/game/engines/default/engine/Map.lua
@@ -436,7 +436,7 @@ end
 -- @param pos what kind of entity to set(Map.TERRAIN, Map.OBJECT, Map.ACTOR)
 -- @param e the entity to set, if null it will return the current one
 function _M:call(x, y, pos, e)
-	if x < 0 or y < 0 or x >= self.w or y >= self.h then return end
+	if not x or not y or x < 0 or y < 0 or x >= self.w or y >= self.h then return end
 	if e then
 		self.map[x + y * self.w][pos] = e
 		if e.__position_aware then e.x = x e.y = y end
@@ -736,7 +736,7 @@ end
 
 --- Checks the given coords to see if they are in bound
 function _M:isBound(x, y)
-	if x and y and x < 0 or x >= self.w or y < 0 or y >= self.h then return false end
+	if not x or not y or x < 0 or x >= self.w or y < 0 or y >= self.h then return false end
 	return true
 end
 
diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index e5131e9391..08df406b79 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -497,7 +497,7 @@ function _M:move(x, y, force)
 		end
 
 		-- Encased in ice, attack the ice
-		if self:attr("encased_in_ice") then
+		if not force and self:attr("encased_in_ice") then
 			self:attackTarget(self)
 			moved = true
 		-- Should we prob travel through walls ?
diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua
index 202e86cedd..e3928b167c 100644
--- a/game/modules/tome/class/Game.lua
+++ b/game/modules/tome/class/Game.lua
@@ -1084,12 +1084,15 @@ function _M:setupCommands()
 		end,
 
 		PICKUP_FLOOR = not_wild(function()
+			if self.player.no_inventory_access then return end
 			self.player:playerPickup()
 		end),
 		DROP_FLOOR = function()
+			if self.player.no_inventory_access then return end
 			self.player:playerDrop()
 		end,
 		SHOW_INVENTORY = function()
+			if self.player.no_inventory_access then return end
 			local d
 			local titleupdator = self.player:getEncumberTitleUpdator("Inventory")
 			d = self.player:showEquipInven(titleupdator(), nil, function(o, inven, item, button, event)
@@ -1105,16 +1108,20 @@ function _M:setupCommands()
 		end,
 		SHOW_EQUIPMENT = "SHOW_INVENTORY",
 		WEAR_ITEM = function()
+			if self.player.no_inventory_access then return end
 			self.player:playerWear()
 		end,
 		TAKEOFF_ITEM = function()
+			if self.player.no_inventory_access then return end
 			self.player:playerTakeoff()
 		end,
 		USE_ITEM = not_wild(function()
+			if self.player.no_inventory_access then return end
 			self.player:playerUseItem()
 		end),
 
 		QUICK_SWITCH_WEAPON = function()
+			if self.player.no_inventory_access then return end
 			self.player:quickSwitchWeapons()
 		end,
 
diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua
index 569556e791..65a632a0fd 100644
--- a/game/modules/tome/class/Player.lua
+++ b/game/modules/tome/class/Player.lua
@@ -438,7 +438,7 @@ end
 --- Suffocate a bit, lose air
 function _M:suffocate(value, src)
 	local dead, affected = mod.class.Actor.suffocate(self, value, src)
-	if affected and value > 0 then
+	if affected and value > 0 and self.runStop then
 		self:runStop("suffocating")
 		self:restStop("suffocating")
 	end
diff --git a/game/modules/tome/data/general/encounters/maj-eyal.lua b/game/modules/tome/data/general/encounters/maj-eyal.lua
index 2ba8948c75..359549af1b 100644
--- a/game/modules/tome/data/general/encounters/maj-eyal.lua
+++ b/game/modules/tome/data/general/encounters/maj-eyal.lua
@@ -101,6 +101,7 @@ newEntity{
 
 					on_leave = function(lev, old_lev, newzone)
 						if not newzone then return end
+						game.player:grantQuest("lost-merchant")
 						game.player:hasQuest("lost-merchant"):leave_zone(game.player)
 					end,
 				})
diff --git a/game/modules/tome/data/quests/paradoxology.lua b/game/modules/tome/data/quests/paradoxology.lua
index 844427575c..d3eb25f1fd 100644
--- a/game/modules/tome/data/quests/paradoxology.lua
+++ b/game/modules/tome/data/quests/paradoxology.lua
@@ -103,7 +103,7 @@ generate = function(self, player, x, y)
 	end
 	a.on_kill = function(self, who)
 		local p = game.party:findMember{main=true}
-		if who == p then                util.show_backtrace()
+		if who == p then
 			p:setQuestStatus("paradoxology", engine.Quest.COMPLETED, "now-died")
 			game.logSeen(self, "#LIGHT_BLUE#Your future self kills you! The timestreams are broken by the paradox!")
 			game.logSeen(self, "#LIGHT_BLUE#All those events never happened. Except they did, somewhen.")
diff --git a/game/modules/tome/data/talents/cunning/tactical.lua b/game/modules/tome/data/talents/cunning/tactical.lua
index 2a1047c36c..17bddd9512 100644
--- a/game/modules/tome/data/talents/cunning/tactical.lua
+++ b/game/modules/tome/data/talents/cunning/tactical.lua
@@ -39,11 +39,11 @@ newTalent{
 		local act
 		for i = 1, #self.fov.actors_dist do
 			act = self.fov.actors_dist[i]
-			if self:reactionToward(act) < 0 and self:canSee(act) and act["__sqdist"] <= 2 then nb_foes = nb_foes + 1 end
+			if act and game.level:hasEntity(act) and self:reactionToward(act) < 0 and self:canSee(act) and act["__sqdist"] <= 2 then nb_foes = nb_foes + 1 end
 		end
-			
+
 		local defense = nb_foes * t.getDefense(self, t)
-		
+
 		if defense <= t.getMaximum(self, t) then
 			defense = defense
 		else
@@ -90,7 +90,7 @@ newTalent{
 	action = function(self, t)
 
 		self:setEffect(self.EFF_DEFENSIVE_MANEUVER, t.getDuration(self, t), {power=t.getDefense(self, t)})
-		
+
 		return true
 	end,
 	info = function(self, t)
@@ -115,9 +115,9 @@ newTalent{
 	getMovement = function(self, t) return 1 - 1 / (1 + (100)/ 100) end,
 	getDuration = function(self, t) return 4 + math.ceil(self:getTalentLevel(t)) end,
 	action = function(self, t)
-		
+
 		self:setEffect(self.EFF_SPRINT, t.getDuration(self, t), {power=t.getMovement(self, t)})
-		
+
 		return true
 	end,
 	info = function(self, t)
diff --git a/game/modules/tome/data/timed_effects.lua b/game/modules/tome/data/timed_effects.lua
index 1aaae1237b..f81d73e6f3 100644
--- a/game/modules/tome/data/timed_effects.lua
+++ b/game/modules/tome/data/timed_effects.lua
@@ -889,6 +889,7 @@ newEffect{
 		self.ai_state = self.ai_state or {}
 		self.ai_state.tactic_leash = 100
 		self.remove_from_party_on_death = true
+		self.no_inventory_access = true
 		self.move_others = true
 		self.summoner = eff.src
 		self.summoner_gain_exp = true
-- 
GitLab