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.
 
 
 

48 lines
1.1 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 (!this.mobName) {
  11. var mobTypes = this.obj.instance.spawners.zone.mobs;
  12. var mobCounts = this.obj.instance.spawners.mobTypes;
  13. var keys = Object.keys(mobTypes).filter(function(m) {
  14. return (m != 'default');
  15. });
  16. this.mobType = keys[~~(Math.random() * keys.length)];
  17. var needMax = 8;
  18. this.mobName = this.mobType.replace(/\w\S*/g, function(txt) {
  19. return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
  20. });
  21. this.need = Math.max(1, ~~((needMax * 0.2) + (Math.random() * needMax * 0.8)));
  22. }
  23. this.description = 'Kill ' + this.have + '/' + this.need + ' ' + this.mobName;
  24. },
  25. events: {
  26. afterKillMob: function(mob) {
  27. if ((mob.name != this.mobName) || (this.have >= this.need))
  28. return;
  29. this.have++;
  30. this.description = 'Kill ' + this.have + '/' + this.need + ' ' + this.mobName;
  31. if (this.have >= this.need)
  32. this.ready();
  33. this.obj.syncer.setArray(true, 'quests', 'updateQuests', this.simplify(true));
  34. }
  35. }
  36. };
  37. });