From ddf957511fb0e316d7ea9b0d532e1dee04d6a67d Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Tue, 5 Jun 2012 21:52:50 +0000
Subject: [PATCH] Sacrifice now provides a very special shield

git-svn-id: http://svn.net-core.org/repos/t-engine4@5194 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/Actor.lua             |  5 -----
 game/modules/tome/data/damage_types.lua       |  4 ++--
 .../spells/advanced-necrotic-minions.lua      |  8 +++----
 .../tome/data/talents/spells/temporal.lua     |  2 +-
 .../tome/data/timed_effects/magical.lua       | 21 ++++++-------------
 5 files changed, 13 insertions(+), 27 deletions(-)

diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index bf576b4a09..513ca0389a 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -1533,11 +1533,6 @@ function _M:onTakeHit(value, src)
 		end
 	end
 
-	if self:hasEffect(self.EFF_BONE_SHIELD) then
-		local e = self.tempeffect_def[self.EFF_BONE_SHIELD]
-		e.absorb(self, self.tmp[self.EFF_BONE_SHIELD])
-		value = 0
-	end
 	if self:isTalentActive(self.T_BONE_SHIELD) then
 		local t = self:getTalentFromId(self.T_BONE_SHIELD)
 		t.absorb(self, t, self:isTalentActive(self.T_BONE_SHIELD))
diff --git a/game/modules/tome/data/damage_types.lua b/game/modules/tome/data/damage_types.lua
index 065d7d6339..704ddeb8c8 100644
--- a/game/modules/tome/data/damage_types.lua
+++ b/game/modules/tome/data/damage_types.lua
@@ -205,12 +205,12 @@ setDefaultProjector(function(src, x, y, type, dam, tmp, no_martyr)
 		end
 
 		-- Flat damage cap
-		if target.flat_damage_cap then
+		if target.flat_damage_cap and target.max_life then
 			local cap = nil
 			if target.flat_damage_cap.all then cap = target.flat_damage_cap.all end
 			if target.flat_damage_cap[type] then cap = target.flat_damage_cap[type] end
 			if cap and cap > 0 then
-				dam = math.max(math.min(dam, cap), 0)
+				dam = math.max(math.min(dam, cap * target.max_life / 100), 0)
 				print("[PROJECTOR] after flat damage cap", dam)
 			end
 		end
diff --git a/game/modules/tome/data/talents/spells/advanced-necrotic-minions.lua b/game/modules/tome/data/talents/spells/advanced-necrotic-minions.lua
index 3765a68603..dccf812311 100644
--- a/game/modules/tome/data/talents/spells/advanced-necrotic-minions.lua
+++ b/game/modules/tome/data/talents/spells/advanced-necrotic-minions.lua
@@ -308,7 +308,7 @@ newTalent{
 		return false
 	end,
 	getTurns = function(self, t) return math.floor(4 + self:combatTalentSpellDamage(t, 8, 20)) end,
-	getBones = function(self, t) return math.floor(1 + self:getTalentLevel(t)) end,
+	getPower = function(self, t) return 25 - math.ceil(1 + self:getTalentLevel(t) * 1.5) end,
 	action = function(self, t)
 		local list = {}
 		if game.party and game.party:hasMember(self) then
@@ -324,16 +324,16 @@ newTalent{
 
 		rng.tableRemove(list):die(self)
 
-		self:setEffect(self.EFF_BONE_SHIELD, t.getTurns(self, t), {nb=t.getBones(self, t)})
+		self:setEffect(self.EFF_BONE_SHIELD, t.getTurns(self, t), {power=t.getPower(self, t)})
 
 		game:playSoundNear(self, "talents/spell_generic2")
 		return true
 	end,
 	info = function(self, t)
-		return ([[Sacrifice a bone giant minion. Using its bones you make a temporary bone shield around you with %d charges.
+		return ([[Sacrifice a bone giant minion. Using its bones you make a temporary shield around you that prevents any attacks from doing more than %d%% of your total life.
 		The effect lasts %d turns or until all charges are depleted.
 		Each charge will fully absorb one attack.]]):
-		format(t.getBones(self, t), t.getTurns(self, t))
+		format(t.getPower(self, t), t.getTurns(self, t))
 	end,
 }
 
diff --git a/game/modules/tome/data/talents/spells/temporal.lua b/game/modules/tome/data/talents/spells/temporal.lua
index 90f126b099..607a6e4d53 100644
--- a/game/modules/tome/data/talents/spells/temporal.lua
+++ b/game/modules/tome/data/talents/spells/temporal.lua
@@ -66,7 +66,7 @@ newTalent{
 	getDuration = function(self, t) return util.bound(5 + math.floor(self:getTalentLevel(t)), 5, 15) end,
 	getDotDuration = function(self, t) return util.bound(4 + math.floor(self:getTalentLevel(t)), 4, 12) end,
 	getTimeReduction = function(self, t) return util.bound(15 + math.floor(self:getTalentLevel(t) * 2), 15, 35) end,
-		action = function(self, t)
+	action = function(self, t)
 		self:setEffect(self.EFF_TIME_SHIELD, t.getDuration(self, t), {power=t.getMaxAbsorb(self, t), dot_dur=t.getDotDuration(self, t), time_reducer=t.getTimeReduction(self, t)})
 		game:playSoundNear(self, "talents/spell_generic")
 		return true
diff --git a/game/modules/tome/data/timed_effects/magical.lua b/game/modules/tome/data/timed_effects/magical.lua
index 39745a18bb..fdc4bbc036 100644
--- a/game/modules/tome/data/timed_effects/magical.lua
+++ b/game/modules/tome/data/timed_effects/magical.lua
@@ -1172,29 +1172,20 @@ newEffect{
 newEffect{
 	name = "BONE_SHIELD", image = "talents/bone_shield.png",
 	desc = "Bone Shield",
-	long_desc = function(self, eff) return ("Fully protects from %d damaging actions."):format(#eff.particles) end,
+	long_desc = function(self, eff) return ("Any attacks doing more than %d%% of your life is reduced to %d%%."):format(eff.power, eff.power) end,
 	type = "magical",
 	subtype = { arcane=true },
 	status = "beneficial",
-	parameters = { nb=3 },
+	parameters = { power=30 },
 	on_gain = function(self, err) return "#Target# protected by flying bones.", "+Bone Shield" end,
 	on_lose = function(self, err) return "#Target# flying bones crumble.", "-Bone Shield" end,
-	absorb = function(self, eff)
-		game.logPlayer(self, "Your bone shield absorbs the damage!")
-		local pid = table.remove(eff.particles)
-		if pid then self:removeParticles(pid) end
-		if #eff.particles <= 0 then
-			eff.dur = 0
-		end
-	end,
 	activate = function(self, eff)
-		local nb = eff.nb
-		local ps = {}
-		for i = 1, nb do ps[#ps+1] = self:addParticles(Particles.new("bone_shield", 1)) end
-		eff.particles = ps
+		eff.tmpid = self:addTemporaryValue("flat_damage_cap", {all=eff.power})
+		eff.particle = self:addParticles(Particles.new("time_shield_bubble", 1))
 	end,
 	deactivate = function(self, eff)
-		for i, particle in ipairs(eff.particles) do self:removeParticles(particle) end
+		self:removeTemporaryValue("flat_damage_cap", eff.tmpid)
+		self:removeParticles(eff.particle)
 	end,
 }
 
-- 
GitLab