From e68efd61b1806d458b246220032b29b2cf3e8dfe Mon Sep 17 00:00:00 2001
From: Hachem_Muche <Hachem_Muche@stanfordalumni.org>
Date: Wed, 7 Dec 2016 18:05:47 -0800
Subject: [PATCH] Fixed error in parry talent descriptions. Fixed Fan of Knives
 allocating too many knives to some targets. bladestorm is unmovable.

---
 .../tome/data/talents/cunning/traps.lua       |  1 +
 .../data/talents/techniques/dualweapon.lua    |  2 +-
 .../tome/data/talents/techniques/duelist.lua  |  2 +-
 .../talents/techniques/throwing-knives.lua    | 30 ++++++++-----------
 4 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/game/modules/tome/data/talents/cunning/traps.lua b/game/modules/tome/data/talents/cunning/traps.lua
index b4628aac56..da0ca2bccc 100644
--- a/game/modules/tome/data/talents/cunning/traps.lua
+++ b/game/modules/tome/data/talents/cunning/traps.lua
@@ -427,6 +427,7 @@ summon_bladestorm = function(self, target, duration, x, y, scale )
 
 		life_rating = 12,
 		never_move = 1,
+		cant_be_moved = 1,
 		negative_status_effect_immune = 1,
 		
 		combat_armor = math.floor(self.level*.75 + 10), combat_def = self.level * 2,
diff --git a/game/modules/tome/data/talents/techniques/dualweapon.lua b/game/modules/tome/data/talents/techniques/dualweapon.lua
index c6569f8bda..e41c672770 100644
--- a/game/modules/tome/data/talents/techniques/dualweapon.lua
+++ b/game/modules/tome/data/talents/techniques/dualweapon.lua
@@ -73,7 +73,7 @@ newTalent{ -- Note: classes: Temporal Warden, Rogue, Shadowblade, Marauder
 		return ([[You have learned to block incoming blows with your offhand weapon.
 		When dual wielding, your defense is increased by %d.
 		Up to %0.1f times a turn, you have a %d%% chance to parry up to %d damage (%d%% of your offhand weapon damage) from a melee attack.
-		A successful parry reduces damage like armour (before any attack multipliers) and prevents critical strikes.  Partial parries have a proportionally reduced chance to succeed.  You cannot parry attacks from an unseen attacker or with a mindstar.
+		A successful parry reduces damage like armour (before any attack multipliers) and prevents critical strikes.  Partial parries have a proportionally reduced chance to succeed.  It is difficult to parry attacks from unseen attackers and you cannot parry with a mindstar.
 		The defense and chance to parry improve with Dexterity.  The number of parries increases with Cunning.]]):format(t.getDefense(self, t), t.getDeflects(self, t, true), t.getDeflectChance(self,t), t.getDamageChange(self, t, true), t.getDeflectPercent(self,t))
 	end,
 }
diff --git a/game/modules/tome/data/talents/techniques/duelist.lua b/game/modules/tome/data/talents/techniques/duelist.lua
index ba1d9c7841..d79817d9f4 100644
--- a/game/modules/tome/data/talents/techniques/duelist.lua
+++ b/game/modules/tome/data/talents/techniques/duelist.lua
@@ -59,7 +59,7 @@ newTalent{
 		chance = t.getDeflectChance(self,t)
 		perc = t.getDeflectPercent(self,t)
 		return ([[Up to %d times a turn, you have a %d%% chance to parry up to %d damage (%d%% of your offhand weapon damage) from a melee or ranged attack.
-		A successful parry reduces damage like armour (before any attack multipliers) and prevents critical strikes.  You cannot parry attacks from an unseen attacker or with a mindstar.
+		A successful parry reduces damage like armour (before any attack multipliers) and prevents critical strikes.  It is difficult to parry attacks from unseen attackers and you cannot parry with a mindstar.
 		The number of attacks you can parry and their chance partially stacks with those of Dual Weapon Defense.]]):
 		format(t.getDeflects(self, t, true), chance, block, perc)
 	end,
diff --git a/game/modules/tome/data/talents/techniques/throwing-knives.lua b/game/modules/tome/data/talents/techniques/throwing-knives.lua
index e53558a4c6..21c9509419 100644
--- a/game/modules/tome/data/talents/techniques/throwing-knives.lua
+++ b/game/modules/tome/data/talents/techniques/throwing-knives.lua
@@ -224,33 +224,29 @@ newTalent{
 		local tg = self:getTalentTarget(t)
 		local x, y = self:getTarget(tg)
 		if not x or not y then return end
-
 		local count = t.getNb(self,t)
-		local reload = self:callTalent(self.T_THROWING_KNIVES, "getReload")
-		local max = self:callTalent(self.T_THROWING_KNIVES, "getNb")
 		
-		local tg2 = {type="bolt", range=tg.radius}
 		local tgts = {}
-		grids = self:project(tg, x, y, function(px, py)
+		self:project(tg, x, y, function(px, py)
 			local target = game.level.map(px, py, engine.Map.ACTOR)
 			if not target then return end
-			tgts[#tgts+1] = target
+			tgts[#tgts+1] = {act=target, cnt=0}
 		end)
-
-		table.shuffle(tgts)
-		
-		while count > 0 and #tgts > 0 do
-			for i = 1, math.min(count, #tgts) do
-				if #tgts <= 0 then break end
-				local a, id = tgts[i]
-				if a then
-					local proj = throw(self, self:getTalentRadius(t), t.getDamage(self,t), a.x, a.y, nil, nil, 1)
+		local tgt_cnt = #tgts
+		if tgt_cnt > 0 then
+			local tgt_max = math.min(3, math.ceil(count/tgt_cnt))
+			while count > 0 and #tgts > 0 do
+				local tgt, id = rng.table(tgts)
+				if tgt then
+					local proj = throw(self, self:getTalentRadius(t), t.getDamage(self,t), tgt.act.x, tgt.act.y, nil, nil, 1)
 					proj.name = "Fan of Knives"
+					tgt.cnt = tgt.cnt + 1
+					print(("Fan of Knives #%d: target:%s (%s, %s) = %d"):format(count, tgt.act.name, tgt.act.x, tgt.act.y, tgt.cnt))
 					count = count - 1
-					a.turn_procs.fan_of_knives = 1 + (a.turn_procs.fan_of_knives or 0)
-					if a.turn_procs.fan_of_knives==3 then table.remove(tgts, id) end
+					if tgt.cnt >= tgt_max then table.remove(tgts, id) end
 				end
 			end
+			print(count, "knives untargeted.")
 		end
 
 		return true
-- 
GitLab