From af130a701c258ca315548a0ee53ae507459e08e7 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Sun, 9 Nov 2014 10:35:03 +0800 Subject: [PATCH 1/6] Diminish critical hit bonus towards 450% --- script/index.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/script/index.coffee b/script/index.coffee index 32a8f592c4..68559fc349 100644 --- a/script/index.coffee +++ b/script/index.coffee @@ -1158,7 +1158,9 @@ api.wrap = (user, main=true) -> crit: (stat='str', chance=.03) -> #console.log("Crit Chance:"+chance*(1+user._statsComputed[stat]/100)) - if user.fns.predictableRandom() <= chance*(1+user._statsComputed[stat]/100) then 1.5 + (.02*user._statsComputed[stat]) + s = user._statsComputed[stat] + if user.fns.predictableRandom() <= chance*(1 + s/100) + 1.5 + 4*s/(s + 200) else 1 ### From 7b22244f0123cf649c9f2aada0811f35a565688d Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Wed, 10 Dec 2014 21:21:09 -0600 Subject: [PATCH 2/6] feat(scoring): MP gain from Habits and Dailies Turns MP gain from tasks into a function, and calls the function with varying inputs from Habits (1/4 gain), Dailies (normal gain), and To-Dos (normal gain multiplied by checklist completion). --- script/index.coffee | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/script/index.coffee b/script/index.coffee index 68559fc349..6f9d95397f 100644 --- a/script/index.coffee +++ b/script/index.coffee @@ -1052,6 +1052,7 @@ api.wrap = (user, main=true) -> switch task.type when 'habit' changeTaskValue() + gainMP(_.max([0.25, (.0025 * user._statsComputed.maxMP)]) * if direction is 'down' then -1 else 1) # Add habit value to habit-history (if different) if (delta > 0) then addPoints() else subtractPoints() @@ -1070,6 +1071,7 @@ api.wrap = (user, main=true) -> task.streak = 0 unless user.stats.buffs.streaks else changeTaskValue() + gainMP(_.max([1, (.01 * user._statsComputed.maxMP)]) * if direction is 'down' then -1 else 1) if direction is 'down' delta = calculateDelta() # recalculate delta for unchecking so the gp and exp come out correctly addPoints() # obviously for delta>0, but also a trick to undo accidental checkboxes @@ -1096,12 +1098,7 @@ api.wrap = (user, main=true) -> addPoints() # obviously for delta>0, but also a trick to undo accidental checkboxes # MP++ per checklist item in ToDo, bonus per CLI multiplier = _.max([(_.reduce(task.checklist,((m,i)->m+(if i.completed then 1 else 0)),1)),1]) - mpDelta = _.max([(multiplier), (.01 * user._statsComputed.maxMP * multiplier)]) - mpDelta *= user._tmp.crit or 1 - mpDelta *= -1 if direction is 'down' # unticking a todo - user.stats.mp += mpDelta - user.stats.mp = user._statsComputed.maxMP if user.stats.mp >= user._statsComputed.maxMP - user.stats.mp = 0 if user.stats.mp < 0 # BUT DO WE WANT THIS? SEE COMMIT DESCRIPTION + gainMP(_.max([(multiplier), (.01 * user._statsComputed.maxMP * multiplier)]) * if direction is 'down' then -1 else 1) when 'reward' # Don't adjust values for rewards @@ -1186,6 +1183,12 @@ api.wrap = (user, main=true) -> # Scoring # ---------------------------------------------------------------------- + gainMP: (delta) -> + delta *= user._tmp.crit or 1 + user.stats.mp += delta + user.stats.mp = user._statsComputed.maxMP if user.stats.mp >= user._statsComputed.maxMP + user.stats.mp = 0 if user.stats.mp < 0 + randomDrop: (modifiers, req) -> {task} = modifiers From 2fc0cb8fa1b3b5975c16653cb110be2f03b5427e Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Wed, 10 Dec 2014 21:45:51 -0600 Subject: [PATCH 3/6] fix(scoring): move gainMP into score --- script/index.coffee | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/script/index.coffee b/script/index.coffee index 6f9d95397f..daf4885581 100644 --- a/script/index.coffee +++ b/script/index.coffee @@ -1049,6 +1049,12 @@ api.wrap = (user, main=true) -> hpMod = delta * conBonus * task.priority * 2 # constant 2 multiplier for better results stats.hp += Math.round(hpMod * 10) / 10 # round to 1dp + gainMP = (delta) -> + delta *= user._tmp.crit or 1 + user.stats.mp += delta + user.stats.mp = user._statsComputed.maxMP if user.stats.mp >= user._statsComputed.maxMP + user.stats.mp = 0 if user.stats.mp < 0 + switch task.type when 'habit' changeTaskValue() @@ -1183,12 +1189,6 @@ api.wrap = (user, main=true) -> # Scoring # ---------------------------------------------------------------------- - gainMP: (delta) -> - delta *= user._tmp.crit or 1 - user.stats.mp += delta - user.stats.mp = user._statsComputed.maxMP if user.stats.mp >= user._statsComputed.maxMP - user.stats.mp = 0 if user.stats.mp < 0 - randomDrop: (modifiers, req) -> {task} = modifiers From 11ec69674ca9fbd3bcecd91da6764ab7d043ee28 Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Wed, 10 Dec 2014 21:49:40 -0600 Subject: [PATCH 4/6] chore(grunt): grunt --- dist/habitrpg-shared.js | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/dist/habitrpg-shared.js b/dist/habitrpg-shared.js index a05e64ee8e..2678292a25 100644 --- a/dist/habitrpg-shared.js +++ b/dist/habitrpg-shared.js @@ -15471,7 +15471,7 @@ api.wrap = function(user, main) { return typeof cb === "function" ? cb(null, user.items.gear.owned) : void 0; }, score: function(req, cb) { - var addPoints, calculateDelta, calculateReverseDelta, changeTaskValue, delta, direction, id, mpDelta, multiplier, num, options, stats, subtractPoints, task, th, _ref; + var addPoints, calculateDelta, calculateReverseDelta, changeTaskValue, delta, direction, gainMP, id, multiplier, num, options, stats, subtractPoints, task, th, _ref; _ref = req.params, id = _ref.id, direction = _ref.direction; task = user.tasks[id]; options = req.query || {}; @@ -15582,9 +15582,20 @@ api.wrap = function(user, main) { hpMod = delta * conBonus * task.priority * 2; return stats.hp += Math.round(hpMod * 10) / 10; }; + gainMP = function(delta) { + delta *= user._tmp.crit || 1; + user.stats.mp += delta; + if (user.stats.mp >= user._statsComputed.maxMP) { + user.stats.mp = user._statsComputed.maxMP; + } + if (user.stats.mp < 0) { + return user.stats.mp = 0; + } + }; switch (task.type) { case 'habit': changeTaskValue(); + gainMP(_.max([0.25, .0025 * user._statsComputed.maxMP]) * (direction === 'down' ? -1 : 1)); if (delta > 0) { addPoints(); } else { @@ -15614,6 +15625,7 @@ api.wrap = function(user, main) { } } else { changeTaskValue(); + gainMP(_.max([1, .01 * user._statsComputed.maxMP]) * (direction === 'down' ? -1 : 1)); if (direction === 'down') { delta = calculateDelta(); } @@ -15646,18 +15658,7 @@ api.wrap = function(user, main) { return m + (i.completed ? 1 : 0); }), 1), 1 ]); - mpDelta = _.max([multiplier, .01 * user._statsComputed.maxMP * multiplier]); - mpDelta *= user._tmp.crit || 1; - if (direction === 'down') { - mpDelta *= -1; - } - user.stats.mp += mpDelta; - if (user.stats.mp >= user._statsComputed.maxMP) { - user.stats.mp = user._statsComputed.maxMP; - } - if (user.stats.mp < 0) { - user.stats.mp = 0; - } + gainMP(_.max([multiplier, .01 * user._statsComputed.maxMP * multiplier]) * (direction === 'down' ? -1 : 1)); } break; case 'reward': @@ -15733,14 +15734,16 @@ api.wrap = function(user, main) { return x - Math.floor(x); }, crit: function(stat, chance) { + var s; if (stat == null) { stat = 'str'; } if (chance == null) { chance = .03; } - if (user.fns.predictableRandom() <= chance * (1 + user._statsComputed[stat] / 100)) { - return 1.5 + (.02 * user._statsComputed[stat]); + s = user._statsComputed[stat]; + if (user.fns.predictableRandom() <= chance * (1 + s / 100)) { + return 1.5 + 4 * s / (s + 200); } else { return 1; } @@ -16256,5 +16259,5 @@ api.wrap = function(user, main) { }; -}).call(this,require("/Users/lefnire/Google Drive/Sync/Sites/habitrpg/modules/habitrpg-shared/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js")) -},{"./content.coffee":5,"./i18n.coffee":6,"/Users/lefnire/Google Drive/Sync/Sites/habitrpg/modules/habitrpg-shared/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":2,"lodash":3,"moment":4}]},{},[1]) \ No newline at end of file +}).call(this,require("/home/sabrecat/habitrpg-shared/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js")) +},{"./content.coffee":5,"./i18n.coffee":6,"/home/sabrecat/habitrpg-shared/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":2,"lodash":3,"moment":4}]},{},[1]) \ No newline at end of file From 43dcded051b602d8a4efc30eef45365abfd238b4 Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Thu, 11 Dec 2014 19:50:46 -0600 Subject: [PATCH 5/6] feat(quests): Boss damage from Habits + Habit hits now damage bosses at half the strength of Dailies and To-Dos. Also removed a bit of leftover commentary/logic from back when STR caused tasks to get blue faster. --- script/index.coffee | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/script/index.coffee b/script/index.coffee index daf4885581..2af591a2e1 100644 --- a/script/index.coffee +++ b/script/index.coffee @@ -1003,12 +1003,10 @@ api.wrap = (user, main=true) -> nextDelta = if not options.cron and direction is 'down' then calculateReverseDelta() else calculateDelta() unless task.type is 'reward' if (user.preferences.automaticAllocation is true and user.preferences.allocationMode is 'taskbased' and !(task.type is 'todo' and direction is 'down')) then user.stats.training[task.attribute] += nextDelta - # ===== STRENGTH ===== - # (Only for up-scoring, ignore up-onlies and rewards) - # Note, we create a new val (adjustAmt) to add to task.value, since delta will be used in Exp & GP calculations - we don't want STR to bonus that - if direction is 'up' and !(task.type is 'habit' and !task.down) + if direction is 'up' # Make progress on quest based on STR user.party.quest.progress.up = user.party.quest.progress.up || 0; user.party.quest.progress.up += (nextDelta * (1 + (user._statsComputed.str / 200))) if task.type in ['daily','todo'] + user.party.quest.progress.up += (nextDelta * (0.5 + (user._statsComputed.str / 400))) if task.type is 'habit' task.value += nextDelta delta += nextDelta From 96157068cfa2458760c44216a88c7ee9dae7cd10 Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Thu, 11 Dec 2014 19:58:14 -0600 Subject: [PATCH 6/6] chore(grunt): grunt --- dist/habitrpg-shared.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dist/habitrpg-shared.js b/dist/habitrpg-shared.js index 2678292a25..7af488ef36 100644 --- a/dist/habitrpg-shared.js +++ b/dist/habitrpg-shared.js @@ -15550,11 +15550,14 @@ api.wrap = function(user, main) { if (user.preferences.automaticAllocation === true && user.preferences.allocationMode === 'taskbased' && !(task.type === 'todo' && direction === 'down')) { user.stats.training[task.attribute] += nextDelta; } - if (direction === 'up' && !(task.type === 'habit' && !task.down)) { + if (direction === 'up') { user.party.quest.progress.up = user.party.quest.progress.up || 0; if ((_ref1 = task.type) === 'daily' || _ref1 === 'todo') { user.party.quest.progress.up += nextDelta * (1 + (user._statsComputed.str / 200)); } + if (task.type === 'habit') { + user.party.quest.progress.up += nextDelta * (0.5 + (user._statsComputed.str / 400)); + } } task.value += nextDelta; }