From a60093b51a5d6bf43b12c3d465c9557fda233e4b Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Tue, 9 Mar 2010 11:30:27 +0000
Subject: [PATCH] fear

git-svn-id: http://svn.net-core.org/repos/t-engine4@387 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/Actor.lua                | 6 ++++++
 game/modules/tome/class/interface/Combat.lua     | 9 +++++++++
 game/modules/tome/data/general/npcs/molds.lua    | 1 +
 game/modules/tome/data/general/npcs/ooze.lua     | 1 +
 game/modules/tome/data/general/npcs/plant.lua    | 1 +
 game/modules/tome/data/general/npcs/skeleton.lua | 1 +
 game/modules/tome/data/general/npcs/troll.lua    | 1 +
 7 files changed, 20 insertions(+)

diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index e45be9e0d6..93ec5410fb 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -407,6 +407,11 @@ end
 -- @param ab the talent (not the id, the table)
 -- @return true to continue, false to stop
 function _M:preUseTalent(ab, silent)
+	if self:attr("feared") then
+		game.logSeen(self, "%s is too afraid to use %s.", self.name:capitalize(), ab.name)
+		return false
+	end
+
 	if not self:enoughEnergy() then print("fail energy") return false end
 
 	if ab.mode == "sustained" then
@@ -655,6 +660,7 @@ function _M:canBe(what)
 	if what == "cut" and rng.percent(100 * (self:attr("cut_immune") or 0)) then return false end
 	if what == "blind" and rng.percent(100 * (self:attr("blind_immune") or 0)) then return false end
 	if what == "stun" and rng.percent(100 * (self:attr("stun_immune") or 0)) then return false end
+	if what == "fear" and rng.percent(100 * (self:attr("fear_immune") or 0)) then return false end
 	if what == "knockback" and rng.percent(100 * (self:attr("knockback_immune") or 0)) then return false end
 	if what == "instakill" and rng.percent(100 * (self:attr("instakill_immune") or 0)) then return false end
 	return true
diff --git a/game/modules/tome/class/interface/Combat.lua b/game/modules/tome/class/interface/Combat.lua
index 2fa0ac8938..682b0bbab2 100644
--- a/game/modules/tome/class/interface/Combat.lua
+++ b/game/modules/tome/class/interface/Combat.lua
@@ -42,6 +42,15 @@ The ToME combat system has the following attributes:
 function _M:attackTarget(target, damtype, mult, noenergy)
 	local speed, hit = nil, false
 
+	if self:attr("feared") then
+		if not noenergy then
+			self:useEnergy(game.energy_to_act * speed)
+			self.did_energy = true
+		end
+		game.logSeen(self, "%s is too afraid to attack.", self.name:capitalize())
+		return false
+	end
+
 	-- Cancel stealth early if we are noticed
 	if self:isTalentActive(self.T_STEALTH) and target:canSee(self) then
 		self:useTalent(self.T_STEALTH)
diff --git a/game/modules/tome/data/general/npcs/molds.lua b/game/modules/tome/data/general/npcs/molds.lua
index 7bc49fede9..66def10fcc 100644
--- a/game/modules/tome/data/general/npcs/molds.lua
+++ b/game/modules/tome/data/general/npcs/molds.lua
@@ -12,6 +12,7 @@ newEntity{
 	energy = { mod=0.5 },
 	combat_armor = 1, combat_def = 1,
 	never_move = 1,
+	fear_immune = 1,
 }
 
 newEntity{ base = "BASE_NPC_MOLD",
diff --git a/game/modules/tome/data/general/npcs/ooze.lua b/game/modules/tome/data/general/npcs/ooze.lua
index 3aac1522ba..ec1581e5e5 100644
--- a/game/modules/tome/data/general/npcs/ooze.lua
+++ b/game/modules/tome/data/general/npcs/ooze.lua
@@ -18,6 +18,7 @@ newEntity{
 	resolvers.drops{chance=60, nb=1, {type="money"} },
 
 	resists = { [DamageType.LIGHT] = -50 },
+	fear_immune = 1,
 }
 
 newEntity{ base = "BASE_NPC_OOZE",
diff --git a/game/modules/tome/data/general/npcs/plant.lua b/game/modules/tome/data/general/npcs/plant.lua
index bef3a498f3..45c7817738 100644
--- a/game/modules/tome/data/general/npcs/plant.lua
+++ b/game/modules/tome/data/general/npcs/plant.lua
@@ -14,6 +14,7 @@ newEntity{
 	energy = { mod=1 },
 	combat_armor = 1, combat_def = 1,
 	never_move = 1,
+	fear_immune = 1,
 }
 
 newEntity{ base = "BASE_NPC_PLANT",
diff --git a/game/modules/tome/data/general/npcs/skeleton.lua b/game/modules/tome/data/general/npcs/skeleton.lua
index f5495e0cff..ca5e28b3e4 100644
--- a/game/modules/tome/data/general/npcs/skeleton.lua
+++ b/game/modules/tome/data/general/npcs/skeleton.lua
@@ -20,6 +20,7 @@ newEntity{
 	tmasteries = resolvers.tmasteries{ ["technique/other"]=0.3, ["technique/2hweapon-offense"]=0.3, ["technique/2hweapon-cripple"]=0.3 },
 
 	blind_immune = 1,
+	fear_immune = 1,
 	see_invisible = 2,
 	undead = 1,
 }
diff --git a/game/modules/tome/data/general/npcs/troll.lua b/game/modules/tome/data/general/npcs/troll.lua
index b3e285c863..9a8aefb35f 100644
--- a/game/modules/tome/data/general/npcs/troll.lua
+++ b/game/modules/tome/data/general/npcs/troll.lua
@@ -23,6 +23,7 @@ newEntity{
 	tmasteries = resolvers.tmasteries{ ["technique/other"]=0.3 },
 
 	resists = { [DamageType.FIRE] = -50 },
+	fear_immune = 1,
 }
 
 newEntity{ base = "BASE_NPC_TROLL",
-- 
GitLab