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.
 
 
 

130 lines
2.2 KiB

  1. module.exports = {
  2. type: 'slowBlast',
  3. intCd: 0,
  4. intCdMax: 1,
  5. thickness: 2,
  6. casting: false,
  7. radius: 0,
  8. needLos: false,
  9. range: 100,
  10. castingEffect: null,
  11. update: function () {
  12. if (!this.casting)
  13. return;
  14. if (this.intCd > 0) {
  15. this.intCd--;
  16. return;
  17. } this.intCd = this.intCdMax;
  18. let obj = this.obj;
  19. let x = obj.x;
  20. let y = obj.y;
  21. for (let a = 0; a < this.thickness; a++) {
  22. this.radius++;
  23. let radius = this.radius;
  24. let physics = obj.instance.physics;
  25. let syncer = obj.instance.syncer;
  26. let xMin = x - radius;
  27. let yMin = y - radius;
  28. let xMax = x + radius;
  29. let yMax = y + radius;
  30. let success = false;
  31. for (let i = xMin; i <= xMax; i++) {
  32. let dx = Math.abs(x - i);
  33. for (let j = yMin; j <= yMax; j++) {
  34. let dy = Math.abs(y - j);
  35. if (Math.random() < 0.35)
  36. continue;
  37. let distance = ~~Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
  38. if (distance !== radius)
  39. continue;
  40. if (!physics.hasLos(x, y, i, j))
  41. continue;
  42. success = true;
  43. let effect = {
  44. x: i,
  45. y: j,
  46. components: [{
  47. type: 'attackAnimation',
  48. destroyObject: true,
  49. row: [10, 10, 10, 10, 10, 10, 10, 8, 8, 8, 7, 7, 7][~~(Math.random() * 13)],
  50. col: 4,
  51. frameDelay: 1 + ~~(Math.random() * 10)
  52. }, {
  53. type: 'particles',
  54. noExplosion: true,
  55. blueprint: this.particles
  56. }]
  57. };
  58. syncer.queue('onGetObject', effect, -1);
  59. let mobs = physics.getCell(i, j);
  60. let mLen = mobs.length;
  61. for (let k = 0; k < mLen; k++) {
  62. let m = mobs[k];
  63. //Maybe we killed something?
  64. if (!m) {
  65. mLen--;
  66. continue;
  67. } else if (!m.player)
  68. continue;
  69. let damage = this.getDamage(m);
  70. m.stats.takeDamage({
  71. damage,
  72. threatMult: 1,
  73. source: obj,
  74. target: m,
  75. spellName: 'slowBlast'
  76. });
  77. }
  78. }
  79. }
  80. if (!success) {
  81. this.casting = false;
  82. this.castingEffect.destroyed = true;
  83. return;
  84. }
  85. }
  86. this.sendBump({
  87. x: x,
  88. y: y + 1
  89. });
  90. return true;
  91. },
  92. cast: function (action) {
  93. this.castingEffect = this.obj.effects.addEffect({
  94. type: 'casting'
  95. });
  96. this.casting = true;
  97. this.radius = 0;
  98. this.intCd = 0;
  99. return true;
  100. }
  101. };