From b3ab5ccb9b6ffa05b6d82481f6c73187154465b7 Mon Sep 17 00:00:00 2001 From: bigbadwaffle Date: Wed, 22 Feb 2017 10:13:16 +0200 Subject: [PATCH] Fixed #22 --- .../config/quests/templates/questKillX.js | 51 ++++++++++--------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/src/server/config/quests/templates/questKillX.js b/src/server/config/quests/templates/questKillX.js index 615814c0..9503822c 100644 --- a/src/server/config/quests/templates/questKillX.js +++ b/src/server/config/quests/templates/questKillX.js @@ -12,31 +12,36 @@ define([ type: 'killX', build: function() { - var mobTypes = this.obj.instance.spawners.zone.mobs; + //If we're not in the correct zone, don't do this check, it'll just crash the server + // since the mob won't be available (most likely) in the zoneFile + if (this.obj.zoneName == this.zoneName) { + var mobTypes = this.obj.instance.spawners.zone.mobs; + if (this.mobName) { + var mobType = mobTypes[this.mobName.toLowerCase()]; + //Maybe the zoneFile changed in the meantime. If so, regenerate + if ((!mobType) || (mobType.attackable == false)) + this.mobName = null; + } - if (this.mobName) { - if (mobTypes[this.mobName.toLowerCase()].attackable == false) - this.mobName = null; - } + if (!this.mobName) { + var mobCounts = this.obj.instance.spawners.mobTypes; + var keys = Object.keys(mobTypes).filter(function(m) { + return ( + (m != 'default') && + ( + (mobTypes[m].attackable) || + (mobTypes[m].attackable == null) + ) + ); + }); + this.mobType = keys[~~(Math.random() * keys.length)]; + var needMax = 8; + this.mobName = this.mobType.replace(/\w\S*/g, function(txt) { + return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); + }); - if (!this.mobName) { - var mobCounts = this.obj.instance.spawners.mobTypes; - var keys = Object.keys(mobTypes).filter(function(m) { - return ( - (m != 'default') && - ( - (mobTypes[m].attackable) || - (mobTypes[m].attackable == null) - ) - ); - }); - this.mobType = keys[~~(Math.random() * keys.length)]; - var needMax = 8; - this.mobName = this.mobType.replace(/\w\S*/g, function(txt) { - return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); - }); - - this.need = Math.max(1, ~~((needMax * 0.2) + (Math.random() * needMax * 0.8))); + this.need = Math.max(1, ~~((needMax * 0.2) + (Math.random() * needMax * 0.8))); + } } this.description = 'Kill ' + this.have + '/' + this.need + ' ' + this.mobName;