ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Thu Jun 04, 2020 12:03 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Unseen Force fixes
PostPosted: Tue Jul 15, 2014 10:46 am 
Offline

Joined: Sun Jul 13, 2014 7:04 am
Posts: 2
Quote:
game/modules/tome/data/talents/cursed/force-of-will.lua

First change optimizes getAdjustedTalentLevel()

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:
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)


edit: replaced diff with one that didn't somehow lose a comma after testing the fix


Top
 Profile  
 
 Post subject: Re: Unseen Force fixes
PostPosted: Wed Jul 16, 2014 10:44 pm 
Offline

Joined: Sun Jul 13, 2014 7:04 am
Posts: 2
alternate diff that puts hit calculations in their own functions

Code:
diff --git a/master/force-of-will.lua b/test/force-of-will.lua
index e12e71b..0a5a76d 100644
--- a/master/force-of-will.lua
+++ b/test/force-of-will.lua
@@ -311,16 +311,17 @@ newTalent{
    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
+      return math.max(0, self:getTalentLevel(t) - 4)
    end,
    getSecondHitChance = function(self, t)
       return self:combatTalentScale(t.getAdjustedTalentLevel(self, t), 15, 35)
    end,
+   getBaseHitCount = function(self, t)
+      return math.floor(t.getSecondHitChance(self, t)/100) + 1
+   end,
+   getExtraHitChance = function(self, t)
+      return t.getSecondHitChance(self, t) % 100
+   end,
    action = function(self, t)
       game.logSeen(self, "An unseen force begins to swirl around %s!", self.name)
       local duration = t.getDuration(self, t)
@@ -345,9 +346,8 @@ 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 hitCount = t.getBaseHitCount(self, t)
+         if rng.percent(t.getExtraHitChance(self, t)) then hitCount = hitCount + 1 end
 
          -- Randomly take targets
          for i = 1, hitCount do
@@ -371,9 +371,8 @@ newTalent{
       local duration = t.getDuration(self, t)
       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 chance = t.getExtraHitChance(self, t)
+      local hits = t.getBaseHitCount(self, t)
       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)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group