From b75000188f91b802554e58c28f853ab8bf11390b Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Sun, 16 Feb 2014 11:12:04 -0600 Subject: [PATCH 1/3] 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. --- script/index.coffee | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/script/index.coffee b/script/index.coffee index f46f8afbd8..966c366940 100644 --- a/script/index.coffee +++ b/script/index.coffee @@ -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 From 98d91a24ce2fba699e3d74115e30ffb31f0e0b7b Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Sun, 16 Feb 2014 23:52:26 -0600 Subject: [PATCH 2/3] fix(drops): Increase base value, improve comments --- script/index.coffee | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/script/index.coffee b/script/index.coffee index 966c366940..eee667de8c 100644 --- a/script/index.coffee +++ b/script/index.coffee @@ -981,17 +981,17 @@ api.wrap = (user, main=true) -> # % chance of getting a drop - 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 = Math.abs(task.value - 25) / 1000 # Base drop chance based on task value. Subtract more than the max possible task value so we never get a 0 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 + task.priority * # Task priority: +50% for Medium, +100% for Hard + (1 + (task.streak / 100 or 0)) * # Streak bonus: +1% per streak + (1 + (user._statsComputed.per / 100)) * # PERception: +1% per point + (1 + (user.contributor.level / 50 or 0)) * # Contrib levels: +2% per level + (1 + (user.achievements.rebirths / 50 or 0)) * # Rebirths: +2% per achievement + (1 + (user.achievements.streak / 100 or 0)) * # Streak achievements: +1% 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 + (1 + (_.reduce(task.checklist,((m,i)->m+(if i.completed then 1 else 0)),0) or 0)) # +100% per checklist item complete #console.log("Drop chance: " + chance) From c32d91a33184ac8bb1913d99c00cab6026903acf Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Wed, 26 Feb 2014 20:44:43 -0600 Subject: [PATCH 3/3] fix(drops): Further overhaul drop chance Reduces the divisors for several modifiers to give them a more noticeable effect (especially PERception, so Rogues continue to be durn sharp). --- dist/habitrpg-shared.js | 13 +++++++------ script/index.coffee | 6 +++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/dist/habitrpg-shared.js b/dist/habitrpg-shared.js index 0e0d70cfe8..9b012f1648 100644 --- a/dist/habitrpg-shared.js +++ b/dist/habitrpg-shared.js @@ -12645,14 +12645,15 @@ var process=require("__browserify_process");(function() { }), user); }, randomDrop: function(modifiers) { - var acceptableDrops, bonus, chance, drop, dropK, quest, rarity, task, _base, _base1, _base2, _name, _name1, _name2, _ref, _ref1, _ref2, _ref3, _ref4; + var acceptableDrops, chance, drop, dropK, quest, rarity, task, _base, _base1, _base2, _name, _name1, _name2, _ref, _ref1, _ref2, _ref3, _ref4; task = modifiers.task; - bonus = Math.abs(task.value) * task.priority + (task.streak || 0) + (user._statsComputed.per * .5); - bonus /= 100; - chance = api.diminishingReturns(bonus, 1, 0.5); + chance = Math.abs(task.value - 25) / 1000; + chance *= task.priority * (1 + (task.streak / 100 || 0)) * (1 + (user._statsComputed.per / 50)) * (1 + (user.contributor.level / 25 || 0)) * (1 + (user.achievements.rebirths / 25 || 0)) * (1 + (user.achievements.streak / 100 || 0)) * (user._tmp.crit || 1) * (1 + (_.reduce(task.checklist, (function(m, i) { + return m + (i.completed ? 1 : 0); + }), 0) || 0)); quest = content.quests[(_ref = user.party.quest) != null ? _ref.key : void 0]; - if ((quest != null ? quest.collect : void 0) && user.fns.predictableRandom(user.stats.gp) < bonus) { + if ((quest != null ? quest.collect : void 0) && user.fns.predictableRandom(user.stats.gp) < (chance * 2)) { dropK = user.fns.randomVal(quest.collect, { key: true }); @@ -12661,7 +12662,7 @@ var process=require("__browserify_process");(function() { user.markModified('party.quest.progress'); } } - if ((api.daysSince(user.items.lastDrop.date, user.preferences) === 0) && (user.items.lastDrop.count >= 5)) { + if ((api.daysSince(user.items.lastDrop.date, user.preferences) === 0) && (user.items.lastDrop.count >= 5 + Math.floor(user._statsComputed.per / 10))) { return; } if (((_ref1 = user.flags) != null ? _ref1.dropsEnabled : void 0) && user.fns.predictableRandom(user.stats.exp) < chance) { diff --git a/script/index.coffee b/script/index.coffee index b603ca15fa..b2634196c9 100644 --- a/script/index.coffee +++ b/script/index.coffee @@ -987,9 +987,9 @@ api.wrap = (user, main=true) -> chance *= task.priority * # Task priority: +50% for Medium, +100% for Hard (1 + (task.streak / 100 or 0)) * # Streak bonus: +1% per streak - (1 + (user._statsComputed.per / 100)) * # PERception: +1% per point - (1 + (user.contributor.level / 50 or 0)) * # Contrib levels: +2% per level - (1 + (user.achievements.rebirths / 50 or 0)) * # Rebirths: +2% per achievement + (1 + (user._statsComputed.per / 50)) * # PERception: +2% per point + (1 + (user.contributor.level / 25 or 0)) * # Contrib levels: +4% per level + (1 + (user.achievements.rebirths / 25 or 0)) * # Rebirths: +4% per achievement (1 + (user.achievements.streak / 100 or 0)) * # Streak achievements: +1% 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% per checklist item complete