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.
 
 
 

135 lines
2.3 KiB

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