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.
 
 
 

65 lines
1.7 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. return (
  24. (m != 'default') &&
  25. (
  26. (mobTypes[m].attackable) ||
  27. (mobTypes[m].attackable == null)
  28. )
  29. );
  30. });
  31. this.mobType = keys[~~(Math.random() * keys.length)];
  32. var needMax = 8;
  33. this.mobName = this.mobType.replace(/\w\S*/g, function(txt) {
  34. return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
  35. });
  36. this.need = Math.max(1, ~~((needMax * 0.2) + (Math.random() * needMax * 0.8)));
  37. }
  38. }
  39. this.description = 'Kill ' + this.have + '/' + this.need + ' ' + this.mobName;
  40. },
  41. events: {
  42. afterKillMob: function(mob) {
  43. if ((mob.name != this.mobName) || (this.have >= this.need))
  44. return;
  45. this.have++;
  46. this.description = 'Kill ' + this.have + '/' + this.need + ' ' + this.mobName;
  47. if (this.have >= this.need)
  48. this.ready();
  49. this.obj.syncer.setArray(true, 'quests', 'updateQuests', this.simplify(true));
  50. }
  51. }
  52. };
  53. });