From ed4cb82df4223dab68c2546989fd37f1fd9157b3 Mon Sep 17 00:00:00 2001
From: Eric Wykoff <ericwykoff@yahoo.com>
Date: Fri, 23 Jan 2015 16:05:18 -0600
Subject: [PATCH] seal fate now creates spin when you damage a target

---
 game/modules/tome/data/damage_types.lua       |  4 ---
 .../data/talents/chronomancy/fate-weaving.lua | 30 ++++++++-----------
 .../tome/data/timed_effects/magical.lua       | 20 +++++++++++--
 3 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/game/modules/tome/data/damage_types.lua b/game/modules/tome/data/damage_types.lua
index b4c57fa900..5b8366eac0 100644
--- a/game/modules/tome/data/damage_types.lua
+++ b/game/modules/tome/data/damage_types.lua
@@ -361,10 +361,6 @@ setDefaultProjector(function(src, x, y, type, dam, state)
 			print("[PROJECTOR] after Roll With It dam", dam)
 		end
 
-		if src and src.hasEffect and src:hasEffect(src.EFF_SEAL_FATE) then
-			src:callEffect(src.EFF_SEAL_FATE, "doDamage", target)
-		end
-
 		if target:attr("resist_unseen") and not target:canSee(src) then
 			dam = dam * (1 - math.min(target.resist_unseen,100)/100)
 		end
diff --git a/game/modules/tome/data/talents/chronomancy/fate-weaving.lua b/game/modules/tome/data/talents/chronomancy/fate-weaving.lua
index 2df1a5cbdb..48e113e84b 100644
--- a/game/modules/tome/data/talents/chronomancy/fate-weaving.lua
+++ b/game/modules/tome/data/talents/chronomancy/fate-weaving.lua
@@ -27,25 +27,19 @@ newTalent{
 	points = 5,
 	getSaveBonus = function(self, t) return math.ceil(self:combatTalentScale(t, 2, 8, 0.75)) end,
 	getMaxSpin = function(self, t) return self:hasEffect(self.EFF_WEBS_OF_FATE) and 6 or 3 end,
+	doSpin = function(self, t)
+		self:setEffect(self.EFF_SPIN_FATE, 3, {save_bonus=t.getSaveBonus(self, t), spin=1, max_spin=t.getMaxSpin(self, t)})
+		
+		-- Fateweaver
+		if self:knowTalent(self.T_FATEWEAVER) then
+			self:callTalent(self.T_FATEWEAVER, "doFateweaver")
+		end
+	end,
 	callbackOnTakeDamage = function(self, t, src, x, y, type, dam, tmp)
 		if dam > 0 and src ~= self then
 			if self.turn_procs and not self.turn_procs.spin_fate then
-				
-				self:setEffect(self.EFF_SPIN_FATE, 3, {save_bonus=t.getSaveBonus(self, t), spin=1, max_spin=t.getMaxSpin(self, t)})
-				
-				if self:knowTalent(self.T_FATEWEAVER) then
-					self:callTalent(self.T_FATEWEAVER, "doFateweaver")
-				end
-
-				-- Set our turn procs, we do spin_fate last since it's the only one checked above
-				if self.hasEffect and self:hasEffect(self.EFF_WEBS_OF_FATE) and not self.turn_procs.spin_webs then
-					self.turn_procs.spin_webs = true
-				elseif self.hasEffect and self:hasEffect(self.EFF_SEAL_FATE) and not self.turn_procs.spin_seal then
-					self.turn_procs.spin_seal = true
-				else
-					self.turn_procs.spin_fate = true
-				end
-
+				t.doSpinFate(self, t)
+				self.turn_procs.spin_fate = true
 			end
 		end
 
@@ -77,9 +71,9 @@ newTalent{
 	info = function(self, t)
 		local procs = t.getProcs(self, t)
 		local duration = t.getDuration(self, t)
-		return ([[Activate to Seal Fate for %d turns.  When you damage a target while Seal Fate is active you have a 50%% chance to increase the duration of one detrimental status effect on it by one turn.
+		return ([[Activate to Seal Fate for %d turns.  When you damage a target while Seal Fate is active you gain Spin and have a 50%% chance to increase the duration of one detrimental status effect on it by one turn.
 		If you have Spin Fate active the chance will be increased by 33%% per Spin (to a maximum of 100%% at three Spin.)
-		This can occur at most %d times per turn.  While Seal Fate is active you may gain one additional spin per turn.]]):format(duration, procs)
+		The duration increase can occur %d times per turn.]]):format(duration, procs)
 	end,
 }
 
diff --git a/game/modules/tome/data/timed_effects/magical.lua b/game/modules/tome/data/timed_effects/magical.lua
index 6b636a528a..a62007d45f 100644
--- a/game/modules/tome/data/timed_effects/magical.lua
+++ b/game/modules/tome/data/timed_effects/magical.lua
@@ -3056,6 +3056,13 @@ newEffect{
 	on_lose = function(self, err) return nil, "-Webs of Fate" end,
 	parameters = { power=0.1 },
 	callbackOnTakeDamage = function(self, eff, src, x, y, type, dam, tmp)
+		-- Spin Fate?
+		if self.turn_procs and not self.turn_procs.spin_webs then
+			self.turn_procs.spin_webs = true
+			self:callTalent(self.T_SPIN_FATE, "doSpin")
+		end
+	
+		-- Displace Damage?
 		local t = eff.talent
 		if dam > 0 and src ~= self then
 			-- find available targets
@@ -3077,7 +3084,7 @@ newEffect{
 				game:delayedLogDamage(src, self, 0, ("%s(%d webs of fate)#LAST#"):format(DamageType:get(type).text_color or "#aaaaaa#", displace), false)
 			end
 		end
-
+		
 		return {dam=dam}
 	end,
 	activate = function(self, eff)
@@ -3096,7 +3103,16 @@ newEffect{
 	parameters = { procs=1 },
 	on_gain = function(self, err) return nil, "+Seal Fate" end,
 	on_lose = function(self, err) return nil, "-Seal Fate" end,
-	doDamage = function(self, eff, target)
+	callbackOnDealDamage = function(self, eff, dam, target)
+		if dam <=0 then return end
+		
+		-- Spin Fate?
+		if self.turn_procs and not self.turn_procs.spin_seal then
+			self.turn_procs.spin_seal = true
+			self:callTalent(self.T_SPIN_FATE, "doSpin")
+		end
+	
+	
 		if self.turn_procs and target.tmp then
 			if self.turn_procs.seal_fate and self.turn_procs.seal_fate >= eff.procs then return end
 			local chance = 50
-- 
GitLab