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 line
1.8 KiB

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