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.
 
 
 

101 lines
1.9 KiB

  1. let slots = require('../../../items/config/slots');
  2. module.exports = {
  3. slot: null,
  4. quality: 0,
  5. type: 'loot',
  6. build: function () {
  7. let slotNames = slots.slots
  8. .filter(s => (s !== 'tool'));
  9. if (this.slot) {
  10. if (!slotNames.some(s => (s === this.slot)))
  11. this.slot = null;
  12. }
  13. if (!this.slot) {
  14. if (Math.random() < 0.2) {
  15. this.quality = 1 + ~~(Math.random() * 2);
  16. this.slotName = '';
  17. if (this.quality === 1) {
  18. let roll = ~~(Math.random() * 2);
  19. if (roll === 0)
  20. this.slotName = 'Magic Armor';
  21. else
  22. this.slotName = 'Magic Accessory';
  23. this.slot = ([
  24. [
  25. 'head',
  26. 'chest',
  27. 'hands',
  28. 'waist',
  29. 'legs',
  30. 'feet',
  31. 'offHand'
  32. ],
  33. [
  34. 'trinket',
  35. 'neck',
  36. 'finger'
  37. ]
  38. ])[roll];
  39. } else {
  40. this.slotName = 'Rare Equipment';
  41. this.slot = slotNames;
  42. }
  43. this.name = 'Purveyor of Rarities';
  44. this.description = 'Loot 1x ' + this.slotName;
  45. } else {
  46. this.name = 'Purveyor of Artefacts';
  47. this.slot = slotNames[~~(Math.random() * slotNames.length)];
  48. this.slotName = this.slot[0].toUpperCase() + this.slot.substr(1);
  49. this.description = 'Loot 1x ' + this.slotName + ' slot item';
  50. }
  51. }
  52. return true;
  53. },
  54. getXpMultiplier: function () {
  55. let multiplier = 1;
  56. if (!this.quality)
  57. multiplier *= 8;
  58. else if (this.quality === 2)
  59. multiplier *= 6;
  60. else if (this.quality === 1)
  61. multiplier *= 4;
  62. return multiplier;
  63. },
  64. events: {
  65. afterLootMobItem: function (item) {
  66. if (
  67. (this.isReady) ||
  68. (this.obj.zoneName !== this.zoneName) ||
  69. (
  70. (this.quality) &&
  71. (item.quality < this.quality)
  72. ) ||
  73. (
  74. (this.slot.indexOf) &&
  75. (this.slot.indexOf(item.slot) === -1)
  76. ) ||
  77. (
  78. (!this.slot.indexOf) &&
  79. (this.slot !== item.slot)
  80. )
  81. )
  82. return;
  83. this.ready();
  84. }
  85. }
  86. };