Browse Source

chore: added better defaulting for threatMult and added a helper method to reset aggro

tags/v0.12.0
Shaun 1 year ago
parent
commit
48ad103e09
1 changed files with 7 additions and 3 deletions
  1. +7
    -3
      src/server/components/aggro.js

+ 7
- 3
src/server/components/aggro.js View File

@@ -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;


Loading…
Cancel
Save