Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

131 строка
2.4 KiB

  1. define([
  2. ], function(
  3. ) {
  4. return {
  5. type: 'warnBlast',
  6. needLos: false,
  7. range: 100,
  8. castingEffect: null,
  9. statType: 'agi',
  10. statMult: 1,
  11. targetGround: true,
  12. needLos: true,
  13. damage: 10,
  14. delay: 10,
  15. radius: 1,
  16. cast: function(action) {
  17. var obj = this.obj;
  18. var physics = obj.instance.physics;
  19. var target = action.target;
  20. var x = target.x;
  21. var y = target.y;
  22. var radius = this.radius;
  23. var xMin = x - radius;
  24. var xMax = x + radius;
  25. var yMin = y - radius;
  26. var yMax = y + radius;
  27. var attackTemplate = this.attackTemplate;
  28. if (attackTemplate)
  29. attackTemplate = attackTemplate.split(' ');
  30. var count = -1;
  31. for (var i = xMin; i <= xMax; i++) {
  32. for (var j = yMin; j <= yMax; j++) {
  33. count++;
  34. if (!physics.hasLos(x, y, i, j))
  35. continue;
  36. else if ((attackTemplate) && (attackTemplate[count] == 'x'))
  37. continue;
  38. if ((attackTemplate) && (~~attackTemplate[count] > 0)) {
  39. this.queueCallback(this.spawnWarning.bind(this, i, j), ~~attackTemplate[count] * 350);
  40. continue;
  41. }
  42. else
  43. this.spawnWarning(i, j);
  44. }
  45. }
  46. this.sendBump(target);
  47. return true;
  48. },
  49. spawnWarning: function(x, y) {
  50. var obj = this.obj;
  51. var syncer = obj.instance.syncer;
  52. var effect = {
  53. x: x,
  54. y: y,
  55. components: [{
  56. type: 'particles',
  57. noExplosion: true,
  58. ttl: this.delay * 175 / 16,
  59. blueprint: this.particles
  60. }]
  61. };
  62. syncer.queue('onGetObject', effect);
  63. this.queueCallback(this.onWarningOver.bind(this, x, y), this.delay * 350);
  64. },
  65. onWarningOver: function(x, y) {
  66. var obj = this.obj;
  67. var physics = obj.instance.physics;
  68. var syncer = obj.instance.syncer;
  69. var effect = {
  70. x: x,
  71. y: y,
  72. components: [{
  73. type: 'attackAnimation',
  74. destroyObject: true,
  75. row: [10, 10, 10, 10, 10, 10, 10, 8, 8, 8, 7, 7, 7][~~(Math.random() * 13)],
  76. col: 4,
  77. frameDelay: 4 + ~~(Math.random() * 7)
  78. }]
  79. };
  80. syncer.queue('onGetObject', effect);
  81. var mobs = physics.getCell(x, y);
  82. var mLen = mobs.length;
  83. for (var k = 0; k < mLen; k++) {
  84. var m = mobs[k];
  85. //Maybe we killed something?
  86. if (!m) {
  87. mLen--;
  88. continue;
  89. } else if (!m.aggro)
  90. continue;
  91. else if ((!m.aggro.willAttack(this.obj)) && (!!this.obj.player == !!m.player))
  92. continue;
  93. var damage = this.getDamage(m);
  94. m.stats.takeDamage(damage, 1, obj);
  95. }
  96. }
  97. };
  98. });