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.
 
 
 

99 lines
2.0 KiB

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