From f57216074007f15cbb6aa5b1ab9f474a03660c0e Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Thu, 10 Nov 2011 01:17:49 +0000
Subject: [PATCH] Blood Sacrifice changed into Bloodcasting

git-svn-id: http://svn.net-core.org/repos/t-engine4@4635 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/Actor.lua             |  20 ++++++++++++--
 .../{blood_sacrifice.png => bloodcasting.png} | Bin
 .../data/talents/corruptions/sanguisuge.lua   |  26 ++++++++++++++++--
 .../tome/data/timed_effects/magical.lua       |  16 +++++++++++
 4 files changed, 58 insertions(+), 4 deletions(-)
 rename game/modules/tome/data/gfx/talents/{blood_sacrifice.png => bloodcasting.png} (100%)

diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index cec12a6919..087d91943a 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -2330,7 +2330,6 @@ end
 
 -- Overwrite incStamina to set up Adrenaline Surge
 local previous_incStamina = _M.incStamina
-
 function _M:incStamina(stamina)
 	if stamina < 0 and self:hasEffect(self.EFF_ADRENALINE_SURGE) then
 		local stamina_cost = math.abs(stamina)
@@ -2346,6 +2345,23 @@ function _M:incStamina(stamina)
 	end
 end
 
+-- Overwrite incVim to set up Bloodcasting
+local previous_incVim = _M.incVim
+function _M:incVim(v)
+	if v < 0 and self:attr("bloodcasting") then
+		local cost = math.abs(v)
+		if self.vim - cost < 0 then
+			local damage = cost - (self.vim or 0)
+			self:incVim(-self.vim or 0)
+			self.life = self.life - damage
+		else
+			return previous_incVim(self, v)
+		end
+	else
+		return previous_incVim(self, v)
+	end
+end
+
 --- Called before a talent is used
 -- Check the actor can cast it
 -- @param ab the talent (not the id, the table)
@@ -2419,7 +2435,7 @@ function _M:preUseTalent(ab, silent, fake)
 			if not silent then game.logPlayer(self, "You do not have enough stamina to use %s.", ab.name) end
 			return false
 		end
-		if ab.vim and self:getVim() < ab.vim then
+		if ab.vim and self:getVim() < ab.vim and (not self:attr("bloodcasting") or self.life < ab.vim) then
 			if not silent then game.logPlayer(self, "You do not have enough vim to use %s.", ab.name) end
 			return false
 		end
diff --git a/game/modules/tome/data/gfx/talents/blood_sacrifice.png b/game/modules/tome/data/gfx/talents/bloodcasting.png
similarity index 100%
rename from game/modules/tome/data/gfx/talents/blood_sacrifice.png
rename to game/modules/tome/data/gfx/talents/bloodcasting.png
diff --git a/game/modules/tome/data/talents/corruptions/sanguisuge.lua b/game/modules/tome/data/talents/corruptions/sanguisuge.lua
index a1f5a6d35f..1306823ae7 100644
--- a/game/modules/tome/data/talents/corruptions/sanguisuge.lua
+++ b/game/modules/tome/data/talents/corruptions/sanguisuge.lua
@@ -45,6 +45,7 @@ newTalent{
 	end,
 }
 
+--[[
 newTalent{
 	name = "Blood Sacrifice",
 	type = {"corruption/sanguisuge", 2},
@@ -80,12 +81,33 @@ newTalent{
 		return true
 	end,
 	info = function(self, t)
-		return ([[Sacrifices 50%% of your current life to restore %d vim.
+		return ([=[Sacrifices 50%% of your current life to restore %d vim.
 		This only works if there is at least one foe in sight.
-		The effect will increase with your Magic stat.]]):
+		The effect will increase with your Magic stat.]=]):
 		format(30 + self:combatTalentSpellDamage(t, 5, 150))
 	end,
 }
+]]
+newTalent{
+	name = "Bloodcasting",
+	type = {"corruption/sanguisuge", 2},
+	require = corrs_req2,
+	points = 5,
+	vim = 0,
+	cooldown = 18,
+	no_energy = true,
+	range = 10,
+	no_npc_use = true,
+	action = function(self, t)
+		self:setEffect(self.EFF_BLOODCASTING, 2 + math.floor(self:getTalentLevel(t)), {})
+		game:playSoundNear(self, "talents/spell_generic2")
+		return true
+	end,
+	info = function(self, t)
+		return ([[For %d turns your corruption spells will consume health instead of vim if their cost is higher than your vim.]]):
+		format(2 + math.floor(self:getTalentLevel(t)))
+	end,
+}
 
 newTalent{
 	name = "Absorb Life",
diff --git a/game/modules/tome/data/timed_effects/magical.lua b/game/modules/tome/data/timed_effects/magical.lua
index e13a0b0e6d..e69e3a1bee 100644
--- a/game/modules/tome/data/timed_effects/magical.lua
+++ b/game/modules/tome/data/timed_effects/magical.lua
@@ -1578,3 +1578,19 @@ newEffect{
 		end
 	end,
 }
+
+newEffect{
+	name = "BLOODCASTING", image = "talents/bloodcasting.png",
+	desc = "Bloodcasting",
+	long_desc = function(self, eff) return ("Corruptions consume health instead of vim.") end,
+	type = "magical",
+	subtype = {corruption=true},
+	status = "beneficial",
+	parameters = {},
+	activate = function(self, eff)
+		eff.tmpid = self:addTemporaryValue("bloodcasting", 1)
+	end,
+	deactivate = function(self, eff)
+		self:removeTemporaryValue("bloodcasting", eff.tmpid)
+	end,
+}
-- 
GitLab