From 03f923d49c6d8523adff51574d0e88b65be17b17 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Wed, 10 Nov 2010 14:06:52 +0000
Subject: [PATCH] Stuns can now be partial, each turn you do not loose the
 energy of a whole turn, but a variable amount based on your stun resistance

git-svn-id: http://svn.net-core.org/repos/t-engine4@1847 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/engines/default/engine/Birther.lua       |  8 ++--
 game/modules/tome/class/Actor.lua             |  3 +-
 .../modules/tome/data/general/npcs/horror.lua | 24 -----------
 .../tome/data/general/npcs/minor-demon.lua    | 24 +++++++++++
 game/modules/tome/data/timed_effects.lua      | 40 +++++++++----------
 5 files changed, 51 insertions(+), 48 deletions(-)

diff --git a/game/engines/default/engine/Birther.lua b/game/engines/default/engine/Birther.lua
index fbce6a3463..8de65c39ba 100644
--- a/game/engines/default/engine/Birther.lua
+++ b/game/engines/default/engine/Birther.lua
@@ -85,12 +85,14 @@ Mouse: #00FF00#Left click#FFFFFF# to accept; #00FF00#right click#FFFFFF# to go b
 	self.c_random = Button.new{text="Random", width=math.floor(self.iw / 2 - 40), fct=function() self:randomSelect() end}
 	self.c_desc = Textzone.new{width=math.floor(self.iw / 2 - 10), height=self.ih - self.c_tut.h - 20, no_color_bleed=true, text=""}
 
-	self.c_list = ListColumns.new{width=math.floor(self.iw / 2 - 10), height=self.ih - 10 - self.c_random.h, scrollbar=true, columns={
+	self.c_list = ListColumns.new{width=math.floor(self.iw / 2 - 10), height=self.ih - 10 - self.c_random.h, scrollbar=true, all_clicks=true, columns={
 		{name="", width=8, display_prop="char"},
 		{name="", width=92, display_prop="display_name"},
-	}, list={}, fct=function(item, sel)
+	}, list={}, fct=function(item, sel, button, event)
 		self.sel = sel
-		self:next()
+		if event == "button" and button == "left" then self:next()
+		elseif event == "button" and button == "right" then self:prev()
+		end
 	end, select=function(item, sel) self.sel = sel self:select(item) end}
 
 	self.cur_order = 1
diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index 852d4643fc..9bbc353684 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -225,7 +225,8 @@ function _M:act()
 		t.do_gloom(self, t)
 	end
 
-	if self:attr("stunned") then self.energy.value = 0 end
+	if self:attr("stunned") then self.energy.value = self.energy.value - (game.energy_to_act * (100 - (self:attr("stun_immune") or 0))) end
+	if self:attr("encased_in_ice") then self.energy.value = 0 end
 	if self:attr("stoned") then self.energy.value = 0 end
 	if self:attr("dazed") then self.energy.value = 0 end
 
diff --git a/game/modules/tome/data/general/npcs/horror.lua b/game/modules/tome/data/general/npcs/horror.lua
index 9126a3f2de..7af4f11c11 100644
--- a/game/modules/tome/data/general/npcs/horror.lua
+++ b/game/modules/tome/data/general/npcs/horror.lua
@@ -39,30 +39,6 @@ newEntity{
 	size_category = 3,
 }
 
-newEntity{ base = "BASE_NPC_DEMON",
-	name = "wretchling", color=colors.GREEN,
-	desc = "Acid oozes all over this small demon's skin.  Beware, they tend to hunt in packs.",
-	level_range = {16, nil}, exp_worth = 1,
-	rarity = 1,
-	rank = 2,
-	size_category = 1,
-	autolevel = "caster",
-	combat_armor = 1, combat_def = 0,
-	combat = {dam=resolvers.mbonus(55, 15), apr=10, atk=resolvers.mbonus(50, 15), damtype=DamageType.ACID, dammod={mag=1}},
-
-	resists={[DamageType.ACID] = 100},
-
-	resolvers.talents{
-		[Talents.T_RUSH]=6,
-		[Talents.T_ACID_BLOOD]=3,
-		[Talents.T_CORROSIVE_VAPOUR]=3,
-	},
-
-	make_escort = {
-		{type="demon", subtype="minor", name="wretchling", number=rng.range(1, 4), no_subescort=true},
-	},
-}
-
 newEntity{ base = "BASE_NPC_HORROR",
 	name = "worm that walks", color=colors.SANDY_BROWN, define_as="TEST",
 	desc = [[A maggot filled robe with a vaguely humanoid shape.]],
diff --git a/game/modules/tome/data/general/npcs/minor-demon.lua b/game/modules/tome/data/general/npcs/minor-demon.lua
index 413732e493..e6ed2ce0cd 100644
--- a/game/modules/tome/data/general/npcs/minor-demon.lua
+++ b/game/modules/tome/data/general/npcs/minor-demon.lua
@@ -61,6 +61,30 @@ newEntity{ base = "BASE_NPC_DEMON",
 	},
 }
 
+newEntity{ base = "BASE_NPC_DEMON",
+	name = "wretchling", color=colors.GREEN,
+	desc = "Acid oozes all over this small demon's skin.  Beware, they tend to hunt in packs.",
+	level_range = {16, nil}, exp_worth = 1,
+	rarity = 1,
+	rank = 2,
+	size_category = 1,
+	autolevel = "caster",
+	combat_armor = 1, combat_def = 0,
+	combat = {dam=resolvers.mbonus(55, 15), apr=10, atk=resolvers.mbonus(50, 15), damtype=DamageType.ACID, dammod={mag=1}},
+
+	resists={[DamageType.ACID] = 100},
+
+	resolvers.talents{
+		[Talents.T_RUSH]=6,
+		[Talents.T_ACID_BLOOD]=3,
+		[Talents.T_CORROSIVE_VAPOUR]=3,
+	},
+
+	make_escort = {
+		{type="demon", subtype="minor", name="wretchling", number=rng.range(1, 4), no_subescort=true},
+	},
+}
+
 newEntity{ base = "BASE_NPC_DEMON",
 	name = "quasit", color=colors.LIGHT_GREY,
 	desc = "A small, heavily armoured demon, rushing toward you.",
diff --git a/game/modules/tome/data/timed_effects.lua b/game/modules/tome/data/timed_effects.lua
index ba141b1b0d..6abaf653b9 100644
--- a/game/modules/tome/data/timed_effects.lua
+++ b/game/modules/tome/data/timed_effects.lua
@@ -142,12 +142,12 @@ newEffect{
 		self.color_b = 155
 		game.level.map:updateMap(self.x, self.y)
 
-		eff.tmpid = self:addTemporaryValue("stunned", 1)
+		eff.tmpid = self:addTemporaryValue("encased_in_ice", 1)
 		eff.frozid = self:addTemporaryValue("frozen", 1)
 		eff.dur = self:updateEffectDuration(eff.dur, "freeze")
 	end,
 	deactivate = function(self, eff)
-		self:removeTemporaryValue("stunned", eff.tmpid)
+		self:removeTemporaryValue("encased_in_ice", eff.tmpid)
 		self:removeTemporaryValue("frozen", eff.frozid)
 		self.color_r = eff.old_r
 		self.color_g = eff.old_g
@@ -220,6 +220,24 @@ newEffect{
 	end,
 }
 
+newEffect{
+	name = "STUNNED",
+	desc = "Stunned",
+	long_desc = function(self, eff) return "The target is stunned, preventing any actions." end,
+	type = "physical",
+	status = "detrimental",
+	parameters = {},
+	on_gain = function(self, err) return "#Target# is stunned!", "+Stunned" end,
+	on_lose = function(self, err) return "#Target# is not stunned anymore.", "-Stunned" end,
+	activate = function(self, eff)
+		eff.tmpid = self:addTemporaryValue("stunned", 1)
+		eff.dur = self:updateEffectDuration(eff.dur, "stun")
+	end,
+	deactivate = function(self, eff)
+		self:removeTemporaryValue("stunned", eff.tmpid)
+	end,
+}
+
 newEffect{
 	name = "SPYDRIC_POISON",
 	desc = "Spydric Poison",
@@ -241,24 +259,6 @@ newEffect{
 	end,
 }
 
-newEffect{
-	name = "STUNNED",
-	desc = "Stunned",
-	long_desc = function(self, eff) return "The target is stunned, preventing any actions." end,
-	type = "physical",
-	status = "detrimental",
-	parameters = {},
-	on_gain = function(self, err) return "#Target# is stunned!", "+Stunned" end,
-	on_lose = function(self, err) return "#Target# is not stunned anymore.", "-Stunned" end,
-	activate = function(self, eff)
-		eff.tmpid = self:addTemporaryValue("stunned", 1)
-		eff.dur = self:updateEffectDuration(eff.dur, "stun")
-	end,
-	deactivate = function(self, eff)
-		self:removeTemporaryValue("stunned", eff.tmpid)
-	end,
-}
-
 newEffect{
 	name = "SILENCED",
 	desc = "Silenced",
-- 
GitLab