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.
 
 
 

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