Showing
1 changed file
with
19 additions
and
24 deletions
... | ... | @@ -1489,27 +1489,22 @@ end |
1489 | 1489 | -- x = a numeric value |
1490 | 1490 | -- limit = value approached as x increases |
1491 | 1491 | -- y_high = value to match at when x = x_high |
1492 | --- y_low (optional) = value to match when x = x_low | |
1493 | --- returns (limit - add)*x/(x + halfpoint) + add (= add when x = 0 and limit when x = infinity) | |
1494 | --- halfpoint and add are internally computed to match the desired high/low values | |
1495 | --- note that the progression low->high->limit must be monotone, consistently increasing or decreasing | |
1492 | +-- y_low = value to match when x = x_low | |
1493 | +-- returns limit * (1-{a*(x)^0.75+b}) | |
1494 | +-- (1-(e)^(-x)) ranges from 0 to 1 and can effectively be thought of as giving a percent of limit based on talent level (note that a*(x)^0.75+b will be < 0 for all x) | |
1495 | +-- note that the progression low->high->limit must be monotone, consistently increasing or decreasing | |
1496 | 1496 | function _M:combatLimit(x, limit, y_low, x_low, y_high, x_high) |
1497 | --- local x_low, x_high = 1,5 -- Implied talent levels for low and high values respectively | |
1498 | --- local tl = type(t) == "table" and (raw and self:getTalentLevelRaw(t) or self:getTalentLevel(t)) or t | |
1499 | - if y_low and x_low then | |
1500 | - local p = limit*(x_high-x_low) | |
1501 | - local m = x_high*y_high - x_low*y_low | |
1502 | --- local halfpoint = (p-m)/(y_high - y_low) | |
1503 | --- local add = (limit*(x_high*y_low-x_low*y_high) + y_high*y_low*(x_low-x_high))/(p-m) | |
1504 | --- return (limit-add)*x/(x + halfpoint) + add | |
1505 | - local ah = (limit*(x_high*y_low-x_low*y_high)+ y_high*y_low*(x_low-x_high))/(y_high - y_low) -- add*halfpoint product calculated at once to avoid possible divide by zero | |
1506 | - return (limit*x + ah)/(x + (p-m)/(y_high - y_low)) --factored version of above formula | |
1507 | --- return (limit-add)*x/(x + halfpoint) + add, halfpoint, add | |
1508 | - else | |
1509 | - local add = 0 | |
1510 | - local halfpoint = limit*x_high/(y_high-add)-x_high | |
1511 | - return (limit-add)*x/(x + halfpoint) + add | |
1512 | --- return (limit-add)*x/(x + halfpoint) + add, halfpoint, add | |
1497 | + x_low = x_low^0.75 | |
1498 | + x_high = x_high^0.75 | |
1499 | + if y_high >= y_low then -- find a and b such that (1-exp{a*sqrt(x)+b}) * limit returns y_low at x_low and y_high at x_high | |
1500 | + -- gaze in horror at how we find our constants | |
1501 | + local a = math.log( (y_high-limit)/(y_low-limit) )/(x_high - x_low) | |
1502 | + local b = -( (x_high - x_low) * math.log(1 - y_high/limit) - x_high * math.log( (y_high-limit)/(y_low-limit) ) )/(x_low - x_high) | |
1503 | + return limit * (1 - math.exp( ((x)^.75*a+b)) ) | |
1504 | + elseif y_low > y_high then -- find a and b such that y_low - (y_low-limit)*(1-exp{a*(x)^0.75+b}) returns y_low at x_low and y_high at x_high | |
1505 | + local a = math.log( (y_high-limit)/(y_low-limit) ) / (x_high - x_low) | |
1506 | + local b = -( (x_high - x_low)*math.log(1-(y_low-y_high)/(y_low-limit)) - x_high * math.log( (y_high-limit)/(y_low-limit) ) )/(x_low - x_high) | |
1507 | + return y_low - (y_low-limit) * (1 - math.exp( ((x)^.75*a+b) )) | |
1513 | 1508 | end |
1514 | 1509 | end |
1515 | 1510 | |
... | ... | @@ -1605,19 +1600,19 @@ end |
1605 | 1600 | -- limit = value approached as stats increase |
1606 | 1601 | -- high = value to match when stat = 100 |
1607 | 1602 | -- low = value to match when stat = 10 |
1608 | --- returns limit * (1-exp{a*(tl)^0.75+b}) | |
1609 | --- (1-(e)^(-x)) ranges from 0 to 1 and can effectively be thought of as giving a percent of limit based on talent level (note that a*(tl)^0.75+b will be < 0 for all tl) | |
1603 | +-- returns limit * (1-exp{a*(stat)^0.75+b}) | |
1604 | +-- (1-(e)^(-x)) ranges from 0 to 1 and can effectively be thought of as giving a percent of limit based on talent level (note that a*(stat)^0.75+b will be < 0 for all tl) | |
1610 | 1605 | -- note that the progression low->high->limit must be monotone, consistently increasing or decreasing |
1611 | 1606 | function _M:combatStatLimit(stat, limit, low, high) |
1612 | 1607 | local x_low = 5.6234 -- 10^0.75 |
1613 | 1608 | local x_high = 31.623 --100^0.75 |
1614 | 1609 | stat = type(stat) == "string" and self:getStat(stat,nil,true) or stat |
1615 | - if high >= low then -- find a and b such that (1-exp{a*sqrt(tl)+b}) * limit returns low at x_low and high at x_high | |
1610 | + if high >= low then -- find a and b such that (1-exp{a*(stat)^0.75+b}) * limit returns low at 10 stat and high at 100 | |
1616 | 1611 | -- gaze in horror at how we find our constants |
1617 | 1612 | local a = math.log( (high-limit)/(low-limit) )/(x_high - x_low) |
1618 | 1613 | local b = -( (x_high - x_low) * math.log(1 - high/limit) - x_high * math.log( (high-limit)/(low-limit) ) )/(x_low - x_high) |
1619 | 1614 | return limit * (1 - math.exp( ((stat)^.75*a+b)) ) |
1620 | - elseif low > high then -- find a and b such that low - (low-limit)*(1-exp{a*sqrt(tl)+b}) returns low at x_low and high at x_high | |
1615 | + elseif low > high then -- find a and b such that low - (low-limit)*(1-exp{a*(stat)^0.75+b}) returns low at 10 stat and high at 100 | |
1621 | 1616 | local a = math.log( (high-limit)/(low-limit) ) / (x_high - x_low) |
1622 | 1617 | local b = -( (x_high - x_low)*math.log(1-(low-high)/(low-limit)) - x_high * math.log( (high-limit)/(low-limit) ) )/(x_low - x_high) |
1623 | 1618 | return low - (low-limit) * (1 - math.exp( ((stat)^.75*a+b) )) | ... | ... |
-
Please register or login to post a comment