From 48ad103e09ef7c59e5ff0a8c47b2e85dcd5a3d8d Mon Sep 17 00:00:00 2001 From: Shaun Date: Wed, 22 Feb 2023 06:40:34 +0200 Subject: [PATCH] chore: added better defaulting for threatMult and added a helper method to reset aggro --- src/server/components/aggro.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/server/components/aggro.js b/src/server/components/aggro.js index 568fa0d7..636d3f6b 100644 --- a/src/server/components/aggro.js +++ b/src/server/components/aggro.js @@ -178,7 +178,7 @@ module.exports = { this.ignoreList.spliceWhere(o => o === obj); }, - tryEngage: function (source, amount, threatMult) { + tryEngage: function (source, amount, threatMult = 1) { let obj = this.obj; //Don't aggro yourself, stupid @@ -204,7 +204,7 @@ module.exports = { let list = this.list; amount = (amount || 0); - let threat = (amount / obj.stats.values.hpMax) * (threatMult || 1); + let threat = (amount / obj.stats.values.hpMax) * threatMult; let exists = list.find(l => l.obj.id === oId); if (!exists) { @@ -237,7 +237,7 @@ module.exports = { return null; }, - die: function () { + reset: function () { let list = this.list; let lLen = list.length; @@ -259,6 +259,10 @@ module.exports = { this.list = []; }, + die: function () { + this.reset(); + }, + unAggro: function (obj, amount) { let list = this.list; let lLen = list.length;