mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-27 00:59:42 +00:00
fix(drops): Overhaul drops to a percentage multiplier system
WIP. Initial draft of an overhaul to drop chance. Most important bits: (1) A modular system of percentage-based multipliers on the task-value-based initial drop chance. (2) Perception increases the daily drop cap by 1 per 10 points. Fixes HabitRPG/habitrpg/#1922.
This commit is contained in:
parent
d3c1a70619
commit
b75000188f
1 changed files with 16 additions and 10 deletions
|
|
@ -980,23 +980,29 @@ api.wrap = (user, main=true) ->
|
|||
{task} = modifiers
|
||||
|
||||
# % chance of getting a drop
|
||||
bonus =
|
||||
Math.abs(task.value) * # + Task Redness
|
||||
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"
|
||||
|
||||
chance = Math.abs(task.value - 21.27) / 1000 # Base drop chance based on task value. This formula will tend to give us base chance in the 1% to 2% range, topping out at 6.8%.
|
||||
|
||||
chance *=
|
||||
task.priority * # Task priority multiplier: 50% for Medium, 100% for Hard
|
||||
(1 + (task.streak / 100 or 0)) * # Streak bonus: 1% multiplier per streak
|
||||
(1 + (user._statsComputed.per / 100)) * # PERception: 1% multiplier per point
|
||||
(1 + (user.contributor.level / 50 or 0)) * # Contrib levels: 2% multiplier per level
|
||||
(1 + (user.achievements.rebirths / 50 or 0)) * # Rebirths: 2% multiplier per achievement
|
||||
(1 + (user.achievements.streak / 100 or 0)) * # Streak achievements: 1% multiplier per achievement
|
||||
(user._tmp.crit or 1) * # Use the crit multiplier if we got one
|
||||
(1 + (_.reduce(task.checklist,((m,i)->m+(if i.completed then 1 else 0)),0) or 0)) # 100% multiplier per checklist item complete
|
||||
|
||||
#console.log("Drop chance: " + chance)
|
||||
|
||||
quest = content.quests[user.party.quest?.key]
|
||||
if quest?.collect and user.fns.predictableRandom(user.stats.gp) < bonus # NOTE: < bonus, higher chance than drops
|
||||
if quest?.collect and user.fns.predictableRandom(user.stats.gp) < (chance * 2) # 2x as likely to get a collection quest drop as a pet item drop
|
||||
dropK = user.fns.randomVal quest.collect, {key:true}
|
||||
user.party.quest.progress.collect[dropK]++
|
||||
user.markModified? 'party.quest.progress'
|
||||
#console.log {progress:user.party.quest.progress}
|
||||
|
||||
return if (api.daysSince(user.items.lastDrop.date, user.preferences) is 0) and (user.items.lastDrop.count >= 5)
|
||||
return if (api.daysSince(user.items.lastDrop.date, user.preferences) is 0) and (user.items.lastDrop.count >= 5 + Math.floor(user._statsComputed.per / 10))
|
||||
if user.flags?.dropsEnabled and user.fns.predictableRandom(user.stats.exp) < chance
|
||||
|
||||
# current breakdown - 1% (adjustable) chance on drop
|
||||
|
|
|
|||
Loading…
Reference in a new issue