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.
 
 
 

142 lines
2.4 KiB

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