You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

75 lines
1.9 KiB

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