math-balancing WIP for passive stats & abilities
This commit is contained in:
+24
-11
@@ -65,6 +65,16 @@ api.tnl = (lvl) ->
|
||||
else Math.round(((Math.pow(lvl, 2) * 0.25) + (10 * lvl) + 139.75) / 10) * 10
|
||||
# round to nearest 10?
|
||||
|
||||
###
|
||||
A hyperbola function that creates diminishing returns, so you can't go to infinite (eg, with Exp gain).
|
||||
{max} The asymptote
|
||||
{bonus} All the numbers combined for your point bonus (eg, task.value * user.stats.int * critChance, etc)
|
||||
{halfway} (optional) the point at which the graph starts bending
|
||||
###
|
||||
api.diminishingReturns = (bonus, max, halfway=bonus/2) ->
|
||||
max*(bonus/(bonus+halfway))
|
||||
|
||||
|
||||
###
|
||||
Preen history for users with > 7 history entries
|
||||
This takes an infinite array of single day entries [day day day day day...], and turns it into a condensed array
|
||||
@@ -676,26 +686,25 @@ api.wrap = (user) ->
|
||||
# (Only for up-scoring, ignore up-onlies and rewards)
|
||||
if direction is 'up' and task.type != 'reward' and !(task.type is 'habit' and !task.down)
|
||||
# TODO STR Improves the amount by which Dailies and +/- Habits decrease in threat when scored, by .25% per point.
|
||||
task.value += nextDelta * user._statsComputed.str * .005
|
||||
task.value += nextDelta * user._statsComputed.str * .004
|
||||
delta += nextDelta
|
||||
|
||||
addPoints = ->
|
||||
# ===== CRITICAL HITS =====
|
||||
crit =
|
||||
if user.fns.predictableRandom() <= .03 then 1.5 + (.05*user._statsComputed.str)
|
||||
else 1
|
||||
_crit = user.fns.crit()
|
||||
|
||||
# Exp Modifier
|
||||
# ===== Intelligence =====
|
||||
# TODO Increases Experience gain by .2% per point.
|
||||
intMod = 1 + (user._statsComputed.int * .075)
|
||||
stats.exp += Math.round(delta * intMod * task.priority * crit * 6)
|
||||
intBonus = 1 + (user._statsComputed.int * .025)
|
||||
stats.exp += Math.round (delta * intBonus * task.priority * _crit * 6)
|
||||
|
||||
# GP modifier
|
||||
gpMod = delta * task.priority * crit
|
||||
# ===== PERCEPTION =====
|
||||
# TODO Increases Gold gained from tasks by .3% per point.
|
||||
gpMod *= (1 + user._statsComputed.per *.06)
|
||||
perBonus = (1 + user._statsComputed.per *.02)
|
||||
gpMod = (delta * task.priority * _crit * perBonus)
|
||||
gpMod *=
|
||||
stats.gp +=
|
||||
if task.streak
|
||||
streakBonus = task.streak / 100 + 1 # eg, 1-day streak is 1.1, 2-day is 1.2, etc
|
||||
@@ -708,9 +717,9 @@ api.wrap = (user) ->
|
||||
subtractPoints = ->
|
||||
# ===== CONSTITUTION =====
|
||||
# TODO Decreases HP loss from bad habits / missed dailies by 0.5% per point.
|
||||
conMod = 1 - (user._statsComputed.con / 250)
|
||||
conMod = 0.1 if conMod < .1
|
||||
hpMod = delta * conMod * task.priority
|
||||
conBonus = 1 - (user._statsComputed.con / 250)
|
||||
conBonus = 0.1 if conBonus < .1
|
||||
hpMod = delta * conBonus * task.priority * 2 # constant 2 multiplier for better results
|
||||
stats.hp += Math.round(hpMod * 10) / 10 # round to 1dp
|
||||
|
||||
switch task.type
|
||||
@@ -807,6 +816,10 @@ api.wrap = (user) ->
|
||||
x = Math.sin(seed++) * 10000
|
||||
x - Math.floor(x)
|
||||
|
||||
crit: (stat='str', chance=.03) ->
|
||||
if user.fns.predictableRandom() <= chance then 1.5 + (.02*user._statsComputed[stat])
|
||||
else 1
|
||||
|
||||
###
|
||||
Get a random property from an object
|
||||
http://stackoverflow.com/questions/2532218/pick-random-property-from-a-javascript-object
|
||||
|
||||
Reference in New Issue
Block a user