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.
 
 
 

95 lines
1.8 KiB

  1. let spawners = require('../../world/spawners');
  2. let mobBuilder = require('../../world/mobBuilder');
  3. let combat = require('../../combat/combat');
  4. module.exports = {
  5. id: 'akarei',
  6. name: 'The Akarei',
  7. description: 'The last descendents of the ancient Akarei.',
  8. uniqueStat: {
  9. damage: 1,
  10. chance: {
  11. min: 20,
  12. max: 45
  13. },
  14. generate: function (item) {
  15. let chance = this.chance;
  16. let chanceRoll = ~~(random.norm(chance.min, chance.max) * 10) / 10;
  17. let result = null;
  18. if (item.effects)
  19. result = item.effects.find(e => (e.factionId === 'akarei'));
  20. if (!result) {
  21. if (!item.effects)
  22. item.effects = [];
  23. result = {
  24. factionId: 'akarei',
  25. properties: {
  26. chance: chanceRoll
  27. },
  28. text: chanceRoll + '% chance on crit to cast a lightning bolt',
  29. events: {}
  30. };
  31. item.effects.push(result);
  32. }
  33. if (!result.events)
  34. result.events = {};
  35. for (let e in this.events)
  36. result.events[e] = this.events[e];
  37. return result;
  38. },
  39. events: {
  40. beforeDealDamage: function (item, damage, target) {
  41. if (!damage.crit)
  42. return;
  43. let effect = item.effects.find(e => (e.factionId === 'akarei'));
  44. let roll = Math.random() * 100;
  45. if (roll >= effect.properties.chance)
  46. return;
  47. let cbExplode = function (target) {
  48. if ((this.destroyed) || (target.destroyed))
  49. return;
  50. let damage = combat.getDamage({
  51. source: this,
  52. target: target,
  53. damage: item.level * 5,
  54. element: 'arcane',
  55. noCrit: true
  56. });
  57. target.stats.takeDamage(damage, 1, this);
  58. };
  59. this.instance.syncer.queue('onGetObject', {
  60. id: this.id,
  61. components: [{
  62. type: 'lightningEffect',
  63. toX: target.x,
  64. toY: target.y
  65. }]
  66. }, -1);
  67. this.spellbook.registerCallback(this.id, cbExplode.bind(this, target), 1);
  68. }
  69. }
  70. },
  71. rewards: {
  72. }
  73. };