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.
 
 
 

85 lines
1.8 KiB

  1. module.exports = {
  2. rewards: [],
  3. init: function (hideMessage) {
  4. if (!this.build())
  5. return false;
  6. let level = this.obj.instance.spawners.zone.level;
  7. level = level[0];
  8. let xp = ~~(level * 22 * this.getXpMultiplier());
  9. this.xp = xp;
  10. this.obj.syncer.setArray(true, 'quests', 'obtainQuests', this.simplify(true));
  11. if (!hideMessage) {
  12. this.obj.instance.syncer.queue('onGetMessages', {
  13. id: this.obj.id,
  14. messages: [{
  15. class: 'color-yellowB',
  16. message: 'quest obtained (' + this.name + ')'
  17. }]
  18. }, [this.obj.serverId]);
  19. }
  20. return true;
  21. },
  22. ready: function () {
  23. this.isReady = true;
  24. if (this.oReady)
  25. this.oReady();
  26. this.obj.instance.syncer.queue('onGetMessages', {
  27. id: this.obj.id,
  28. messages: [{
  29. class: 'color-yellowB',
  30. message: 'quest ready for turn-in (' + this.name + ')'
  31. }]
  32. }, [this.obj.serverId]);
  33. this.obj.syncer.setArray(true, 'quests', 'updateQuests', this.simplify(true));
  34. },
  35. complete: function () {
  36. if (this.oComplete)
  37. this.oComplete();
  38. let obj = this.obj;
  39. this.obj.instance.eventEmitter.emitNoSticky('beforeCompleteAutoquest', this, obj);
  40. obj.instance.syncer.queue('onGetMessages', {
  41. id: obj.id,
  42. messages: [{
  43. class: 'color-yellowB',
  44. message: 'quest completed (' + this.name + ')'
  45. }]
  46. }, [obj.serverId]);
  47. obj.syncer.setArray(true, 'quests', 'completeQuests', this.id);
  48. this.obj.instance.eventEmitter.emit('onCompleteQuest', this);
  49. this.rewards.forEach(function (r) {
  50. this.obj.inventory.getItem(r);
  51. }, this);
  52. this.obj.stats.getXp(this.xp || 10, this.obj, this);
  53. },
  54. simplify: function (self) {
  55. let values = {};
  56. for (let p in this) {
  57. let value = this[p];
  58. if ((typeof (value) === 'function') || (p === 'obj'))
  59. continue;
  60. values[p] = value;
  61. }
  62. return values;
  63. }
  64. };