Unseen Force fixes
Posted: Tue Jul 15, 2014 10:46 am
				
				First change optimizes getAdjustedTalentLevel()game/modules/tome/data/talents/cursed/force-of-will.lua
Second change fixes deciding whether a random bonus hit happens (as well as fixing extra hits to >100% extra hits, but that doesn't happen until ~44 tLvl with current scaling)
Third change fixes info() to correctly display how many hits and the odds of one more
Code: Select all
diff --git a/master/force-of-will.lua b/test/force-of-will.lua
index e12e71b..84870bf 100644
--- a/master/force-of-will.lua
+++ b/test/force-of-will.lua
@@ -310,13 +310,8 @@ newTalent{
 		return 2
 	end,
 	-- Minimum effects until tLvl > 4
-	getAdjustedTalentLevel = function(self, t)
-		local tLevel = self:getTalentLevel(self, t) - 4
-		-- Do not feed a negative talent level to the scaling functions
-		if tLevel < 0 then
-			tLevel = 0
-		end
-		return tLevel
+	getAdjustedTalentLevel = function(self, t) 
+		return math.max(0, self:getTalentLevel(t) - 4)
 	end,
 	getSecondHitChance = function(self, t)
 		return self:combatTalentScale(t.getAdjustedTalentLevel(self, t), 15, 35)
@@ -345,9 +340,9 @@ newTalent{
 			local damage = t.getDamage(self, t)
 			local knockback = t.getKnockback(self, t)
 
-			local xtrahits = t.getSecondHitChance(self,t)/100
-			local hitCount = 1 + math.floor(xtrahits)
-			if rng.percent(xtrahits - math.floor(xtrahits)*100) then hitCount = hitCount + 1 end
+			local xtrahits = t.getSecondHitChance(self,t)
+			local hitCount = 1 + math.floor(xtrahits / 100)
+			if rng.percent(xtrahits % 100) then hitCount = hitCount + 1 end
 
 			-- Randomly take targets
 			for i = 1, hitCount do
@@ -372,8 +367,8 @@ newTalent{
 		local damage = t.getDamage(self, t)
 		local knockback = t.getKnockback(self, t)
 		local secondHitChance = t.getSecondHitChance(self, t)
-		local hits = 1 + math.floor(secondHitChance/100)
-		local chance = secondHitChance - math.floor(secondHitChance/100)*100
+		local hits = 1 + (secondHitChance - chance)/100
+		local chance = secondHitChance % 100
 		return ([[Your fury becomes an unseen force that randomly lashes out at foes around you. For %d turns you strike %d (%d%% chance for %d) nearby target(s) within range 5 doing %d damage and %d knockback.  The number of extra strikes increases at higher talent levels.
 		In addition, your ability to channel force with this talent increases all critical damage by %d%% (currently: %d%%)
 		Damage increases with your Mindpower.]]):format(duration, hits, chance, hits+1, damDesc(self, DamageType.PHYSICAL, damage), knockback, t.critpower(self, t), self.combat_critical_power or 0)