drop-rate calculation modification. not the end solution, just a step toward

implementing collection quests (fyi @sabrecat)
This commit is contained in:
Tyler Renelle 2013-12-24 09:32:15 -07:00
parent 5eadabbf10
commit fe6b505c09
2 changed files with 13 additions and 15 deletions

View file

@ -74,6 +74,8 @@ api.tnl = (lvl) ->
api.diminishingReturns = (bonus, max, halfway=bonus/2) ->
max*(bonus/(bonus+halfway))
api.monod = (bonus, rateOfIncrease, max) ->
rateOfIncrease*max*bonus/(rateOfIncrease*bonus+max)
###
Preen history for users with > 7 history entries
@ -861,9 +863,7 @@ api.wrap = (user) ->
# ----------------------------------------------------------------------
randomDrop: (modifiers) ->
{delta} = modifiers
{priority, streak} = modifiers.task
streak ?= 0
{task} = modifiers
# limit drops to 2 / day
user.items.lastDrop ?=
date: +moment().subtract('d', 1) # trick - set it to yesterday on first run, that way they can get drops today
@ -873,20 +873,17 @@ api.wrap = (user) ->
return if reachedDropLimit
# % chance of getting a pet or meat
chanceMultiplier = Math.abs(delta)
chanceMultiplier *= priority # multiply chance by reddness
chanceMultiplier += streak # streak bonus
chanceMultiplier += user._statsComputed.per*.3
bonus =
Math.abs(task.value) * # + Task Redness (as a %)
task.priority + # * Task Priority
(task.streak or 0) + # + Streak bonus
(user._statsComputed.per * .5) # + Perception
bonus /= 100 # /100 (as a percent)
chance = api.diminishingReturns(bonus, 1, 0.5) # see HabitRPG/habitrpg#1922 for details
console.log "Drop Equation: Bonus(#{bonus.toFixed(3)}), Modified Chance(#{chance.toFixed(3)})\n"
# Temporary solution to lower the maximum drop chance to 75 percent. More thorough
# overhaul of drop changes is needed. See HabitRPG/habitrpg#1922 for details.
# Old drop chance:
# if user.flags?.dropsEnabled and Math.random() < (.05 * chanceMultiplier)
max = 0.75 # Max probability of drop
a = 0.1 # rate of increase
alpha = a*max*chanceMultiplier/(a*chanceMultiplier+max) # current probability of drop
if user.flags?.dropsEnabled and user.fns.predictableRandom(user.stats.exp) < chance
if user.flags?.dropsEnabled and user.fns.predictableRandom(user.stats.exp) < alpha
# current breakdown - 1% (adjustable) chance on drop
# If they got a drop: 50% chance of egg, 50% Hatching Potion. If hatchingPotion, broken down further even further
rarity = user.fns.predictableRandom(user.stats.gp)

View file

@ -43,6 +43,7 @@ clearUser = (lvl=1) ->
_.merge user.stats, {exp:0, gp:0, hp:50, lvl:lvl, str:lvl, con:lvl, per:lvl, int:lvl, mp: 100}
_.merge s.buffs, {str:0,con:0,int:0,per:0}
_.merge user.party.quest.tally, {up:0,down:0}
user.items.lastDrop = {count:0}
_.each [1,50,99], (lvl) ->
console.log "[LEVEL #{lvl}] (#{lvl} points in every attr)\n\n"