From 7bb19d5641a163f160a7d863dd09a5ef44419f71 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Sun, 21 Apr 2013 23:36:03 +0000
Subject: [PATCH] Autouse talents will not trigger sounds

git-svn-id: http://svn.net-core.org/repos/t-engine4@6631 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/Game.lua   | 2 +-
 game/modules/tome/class/Player.lua | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua
index 5d944107f2..18e463f61a 100644
--- a/game/modules/tome/class/Game.lua
+++ b/game/modules/tome/class/Game.lua
@@ -1956,7 +1956,7 @@ function _M:setAllowedBuild(what, notify)
 end
 
 function _M:playSoundNear(who, name)
-	if who and self.level and self.level.map.seens(who.x, who.y) then
+	if who and not who:attr("_forbid_sounds") and self.level and self.level.map.seens(who.x, who.y) then
 		local pos = {x=0,y=0,z=0}
 		if self.player and self.player.x then pos.x, pos.y = who.x - self.player.x, who.y - self.player.y end
 		self:playSound(name, pos)
diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua
index 752fe67d2d..4067b55931 100644
--- a/game/modules/tome/class/Player.lua
+++ b/game/modules/tome/class/Player.lua
@@ -684,6 +684,7 @@ end
 --- Try to auto use listed talents
 -- This should be called in your actors "act()" method
 function _M:automaticTalents()
+	self:attr("_forbid_sounds", 1)
 	for tid, c in pairs(self.talents_auto) do
 		local t = self.talents_def[tid]
 		local spotted = spotHostiles(self)
@@ -707,7 +708,7 @@ function _M:automaticTalents()
 			end
 		end
 	end
-	return
+	self:attr("_forbid_sounds", -1)
 end
 
 --- We started resting
-- 
GitLab