From bb5fe9c6e57e06ea3eb73c051893320a354448fb Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sun, 29 Dec 2013 16:58:45 -0700 Subject: [PATCH] classes: temporary stopgap for https://github.com/HabitRPG/habitrpg/issues/2150 , burst-of-flames being too powerful. This isn't the real solution we need something better --- dist/habitrpg-shared.js | 24 ++++++++++++++++-------- script/content.coffee | 14 ++++++++++---- script/index.coffee | 2 +- tests/math_samples.coffee | 12 ++++++------ 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/dist/habitrpg-shared.js b/dist/habitrpg-shared.js index 43f8253179..62bb6474b3 100644 --- a/dist/habitrpg-shared.js +++ b/dist/habitrpg-shared.js @@ -9167,7 +9167,7 @@ var global=self;/** },{}],5:[function(require,module,exports){ (function() { - var api, gear, moment, repeat, _; + var api, diminishingReturns, gear, moment, repeat, _; _ = require('lodash'); @@ -10001,6 +10001,13 @@ var global=self;/** */ + diminishingReturns = function(bonus, max, halfway) { + if (halfway == null) { + halfway = max / 2; + } + return max * (bonus / (bonus + halfway)); + }; + api.spells = { wizard: { fireball: { @@ -10011,11 +10018,12 @@ var global=self;/** notes: 'With a crack, flames burst from your staff, scorching a task. You deal high damage to the task, and gain additional experience (more experience for greens).', cast: function(user, target) { var bonus; - target.value += user._statsComputed.int * .0075 * user.fns.crit('per'); - bonus = (target.value < 0 ? 1 : target.value + 1) * 2.5; - user.stats.exp += bonus; + bonus = user._statsComputed.int * user.fns.crit('per'); + target.value += diminishingReturns(bonus * .02, 4); + bonus *= Math.ceil((target.value < 0 ? 1 : target.value + 1) * .075); + user.stats.exp += diminishingReturns(bonus, 75); if (user.party.quest.key) { - return user.party.quest.progress.up += bonus; + return user.party.quest.progress.up += diminishingReturns(bonus * .1, 50, 30); } } }, @@ -10757,7 +10765,7 @@ var process=require("__browserify_process");(function() { api.diminishingReturns = function(bonus, max, halfway) { if (halfway == null) { - halfway = bonus / 2; + halfway = max / 2; } return max * (bonus / (bonus + halfway)); }; @@ -11293,8 +11301,8 @@ var process=require("__browserify_process");(function() { return typeof cb === "function" ? cb("Task not found") : void 0; } _.merge(task, req.body); - if (typeof user.markModified === "function") { - user.markModified('tags'); + if (typeof task.markModified === "function") { + task.markModified('tags'); } return typeof cb === "function" ? cb(null, task) : void 0; }, diff --git a/script/content.coffee b/script/content.coffee index 2892e3cae2..034cf635ee 100644 --- a/script/content.coffee +++ b/script/content.coffee @@ -209,6 +209,9 @@ api.potion = type: 'potion', text: "Health Potion", notes: "Recover 15 Health (I Note, user.stats.mp is docked after automatically (it's appended to functions automatically down below in an _.each) ### +# +diminishingReturns = (bonus, max, halfway=max/2) -> max*(bonus/(bonus+halfway)) + api.spells = wizard: @@ -219,10 +222,13 @@ api.spells = target: 'task' notes: 'With a crack, flames burst from your staff, scorching a task. You deal high damage to the task, and gain additional experience (more experience for greens).' cast: (user, target) -> - target.value += user._statsComputed.int * .0075 * user.fns.crit('per') - bonus = (if target.value < 0 then 1 else target.value+1) * 2.5 - user.stats.exp += bonus - user.party.quest.progress.up += bonus if user.party.quest.key + # I seriously have no idea what I'm doing here. I'm just mashing buttons until numbers seem right-ish. Anyone know math? + bonus = user._statsComputed.int * user.fns.crit('per') + target.value += diminishingReturns(bonus*.02, 4) + bonus *= Math.ceil ((if target.value < 0 then 1 else target.value+1) *.075) + #console.log {bonus, expBonus:bonus,upBonus:bonus*.1} + user.stats.exp += diminishingReturns(bonus,75) + user.party.quest.progress.up += diminishingReturns(bonus*.1,50,30) if user.party.quest.key mpheal: text: 'Ethereal Surge' diff --git a/script/index.coffee b/script/index.coffee index e4cc81be0b..0171f21b2c 100644 --- a/script/index.coffee +++ b/script/index.coffee @@ -74,7 +74,7 @@ api.tnl = (lvl) -> {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) -> +api.diminishingReturns = (bonus, max, halfway=max/2) -> max*(bonus/(bonus+halfway)) api.monod = (bonus, rateOfIncrease, max) -> diff --git a/tests/math_samples.coffee b/tests/math_samples.coffee index 359aa09182..96ce6e22bd 100644 --- a/tests/math_samples.coffee +++ b/tests/math_samples.coffee @@ -12,7 +12,7 @@ _ = require 'lodash' id = shared.uuid() user = stats: {class: 'warrior', buffs: {per:0,int:0,con:0,str:0}} - party: quest: tally: {up:0,down:0} + party: quest: key:'evilsanta', progress: {up:0,down:0} items: eggs: {} hatchingPotions: {} @@ -42,12 +42,12 @@ console.log "================================================\n\n" 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} + _.merge user.party.quest.progress, {up:0,down:0} user.items.lastDrop = {count:0} -_.each [1,50,99], (lvl) -> +_.each [1,25,50,75,99], (lvl) -> console.log "[LEVEL #{lvl}] (#{lvl} points in every attr)\n\n" - _.each {red:-5,yellow:0,green:5}, (taskVal, color) -> + _.each {red:-25,yellow:0,green:35}, (taskVal, color) -> console.log "[task.value = #{taskVal} (#{color})]" console.log "direction\texpΔ\t\thpΔ\tgpΔ\ttask.valΔ\ttask.valΔ bonus\t\tboss-hit" _.each ['up','down'], (direction) -> @@ -56,14 +56,14 @@ _.each [1,50,99], (lvl) -> task.value = taskVal task.type = 'daily' if direction is 'up' delta = user.ops.score params:{id, direction} - console.log "#{if direction is 'up' then '↑' else '↓'}\t\t#{s.exp}/#{shared.tnl(s.lvl)}\t\t#{(b4.hp-s.hp).toFixed(1)}\t#{s.gp.toFixed(1)}\t#{delta.toFixed(1)}\t\t#{(task.value-b4.taskVal-delta).toFixed(1)}\t\t\t#{user.party.quest.tally.up.toFixed(1)}" + console.log "#{if direction is 'up' then '↑' else '↓'}\t\t#{s.exp}/#{shared.tnl(s.lvl)}\t\t#{(b4.hp-s.hp).toFixed(1)}\t#{s.gp.toFixed(1)}\t#{delta.toFixed(1)}\t\t#{(task.value-b4.taskVal-delta).toFixed(1)}\t\t\t#{user.party.quest.progress.up.toFixed(1)}" str = '- [Wizard]' task.value = taskVal;clearUser(lvl) b4 = {taskVal} shared.content.spells.wizard.fireball.cast(user,task) - str += "\tfireball(task.valΔ:#{(task.value-taskVal).toFixed(1)} exp:#{s.exp.toFixed(1)})" + str += "\tfireball(task.valΔ:#{(task.value-taskVal).toFixed(1)} exp:#{s.exp.toFixed(1)} bossHit:#{user.party.quest.progress.up.toFixed(2)})" task.value = taskVal;clearUser(lvl) _party = [user, {stats:{mp:0}}]