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.
 
 
 

72 lines
1.2 KiB

  1. module.exports = {
  2. type: 'iceSpear',
  3. cdMax: 7,
  4. manaCost: 0,
  5. range: 9,
  6. speed: 70,
  7. damage: 1,
  8. freezeDuration: 10,
  9. needLos: true,
  10. cast: function (action) {
  11. let obj = this.obj;
  12. let target = action.target;
  13. let ttl = Math.sqrt(Math.pow(target.x - obj.x, 2) + Math.pow(target.y - obj.y, 2)) * this.speed;
  14. let projectileConfig = {
  15. caster: this.obj.id,
  16. x: obj.x,
  17. y: obj.y,
  18. components: [{
  19. idSource: this.obj.id,
  20. idTarget: target.id,
  21. type: 'projectile',
  22. row: 3,
  23. col: 0,
  24. ttl: ttl,
  25. particles: this.particles
  26. }, {
  27. type: 'attackAnimation',
  28. layer: 'projectiles',
  29. loop: -1,
  30. row: 3,
  31. col: 4
  32. }]
  33. };
  34. this.obj.fireEvent('beforeSpawnProjectile', this, projectileConfig);
  35. this.sendAnimation(projectileConfig);
  36. this.sendBump(target);
  37. this.queueCallback(this.explode.bind(this, target), ttl);
  38. return true;
  39. },
  40. explode: function (target) {
  41. if (this.obj.destroyed)
  42. return;
  43. target.effects.addEffect({
  44. type: 'slowed',
  45. ttl: this.freezeDuration
  46. });
  47. let damage = this.getDamage(target);
  48. target.stats.takeDamage({
  49. damage,
  50. threatMult: this.threatMult,
  51. source: this.obj,
  52. target,
  53. spellName: 'iceSpear'
  54. });
  55. }
  56. };