Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

81 řádky
2.0 KiB

  1. module.exports = {
  2. need: 10,
  3. have: 0,
  4. mobType: null,
  5. type: 'killX',
  6. build: function () {
  7. //If we're not in the correct zone, don't do this check, it'll just crash the server
  8. // since the mob won't be available (most likely) in the zoneFile
  9. if (this.obj.zoneName === this.zoneName) {
  10. let mobTypes = this.obj.instance.zoneConfig.mobs;
  11. if (this.mobName) {
  12. let mobType = mobTypes[this.mobName.toLowerCase()];
  13. //Maybe the zoneFile changed in the meantime. If so, regenerate
  14. if (!mobType || mobType.attackable === false || mobType.noQuest)
  15. this.mobName = null;
  16. }
  17. if (!this.mobName) {
  18. let mobCounts = this.obj.instance.spawners.mobTypes;
  19. let keys = Object.keys(mobTypes).filter(function (m) {
  20. let mobBlueprint = mobTypes[m];
  21. return (
  22. m !== 'default' &&
  23. !mobBlueprint.noQuest &&
  24. (
  25. mobBlueprint.attackable ||
  26. !mobBlueprint.has('attackable')
  27. ) &&
  28. mobBlueprint.level <= ~~(this.obj.stats.values.level * 1.35) &&
  29. mobCounts[m] > 1
  30. );
  31. }, this);
  32. //No level appropriate mobs found
  33. if (keys.length === 0)
  34. return false;
  35. this.mobType = keys[~~(Math.random() * keys.length)];
  36. let needMax = 8;
  37. this.mobName = this.mobType.replace(/\w\S*/g, function (txt) {
  38. return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
  39. });
  40. this.need = Math.max(1, ~~((needMax * 0.2) + (Math.random() * needMax * 0.8)));
  41. }
  42. }
  43. this.description = 'Kill ' + this.have + '/' + this.need + ' ' + this.mobName;
  44. return true;
  45. },
  46. getXpMultiplier: function () {
  47. return this.need;
  48. },
  49. events: {
  50. afterKillMob: function (mob) {
  51. if (
  52. !mob.name ||
  53. this.obj.zoneName !== this.zoneName ||
  54. mob.name.toLowerCase() !== this.mobName.toLowerCase() ||
  55. this.have >= this.need
  56. )
  57. return;
  58. this.have++;
  59. this.description = 'Kill ' + this.have + '/' + this.need + ' ' + this.mobName;
  60. if (this.have >= this.need)
  61. this.ready();
  62. this.obj.syncer.setArray(true, 'quests', 'updateQuests', this.simplify(true));
  63. }
  64. }
  65. };