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.
 
 
 

126 lines
2.2 KiB

  1. let cpnArcanePatch = {
  2. type: 'arcanePatch',
  3. contents: [],
  4. init: function (blueprint) {
  5. for (let p in blueprint)
  6. this[p] = blueprint[p];
  7. },
  8. collisionEnter: function (o) {
  9. if ((!o.aggro) || (!o.player))
  10. return;
  11. let isPlayer = !!this.caster.player;
  12. let isTargetPlayer = !!o.player;
  13. if ((this.caster.aggro.canAttack(o)) || (isPlayer !== isTargetPlayer))
  14. return;
  15. this.contents.push(o);
  16. },
  17. collisionExit: function (o) {
  18. let contents = this.contents;
  19. let cLen = contents.length;
  20. for (let i = 0; i < cLen; i++) {
  21. if (contents[i] === o) {
  22. contents.splice(i, 1);
  23. return;
  24. }
  25. }
  26. },
  27. update: function () {
  28. let contents = this.contents;
  29. let cLen = contents.length;
  30. for (let i = 0; i < cLen; i++) {
  31. let c = contents[i];
  32. let heal = this.spell.getDamage(c, true);
  33. c.stats.getHp({
  34. heal,
  35. source: this.caster,
  36. target: c
  37. });
  38. }
  39. }
  40. };
  41. module.exports = {
  42. type: 'arcaneBarrier',
  43. cdMax: 20,
  44. manaCost: 0,
  45. range: 9,
  46. duration: 70,
  47. targetGround: true,
  48. cast: function (action) {
  49. let obj = this.obj;
  50. let target = action.target;
  51. let radius = this.radius;
  52. let x = target.x;
  53. let y = target.y;
  54. let objects = obj.instance.objects;
  55. let patches = [];
  56. let physics = obj.instance.physics;
  57. for (let i = x - radius; i <= x + radius; i++) {
  58. let dx = Math.abs(x - i);
  59. for (let j = y - radius; j <= y + radius; j++) {
  60. let distance = dx + Math.abs(j - y);
  61. if (distance > radius + 1)
  62. continue;
  63. if (!physics.hasLos(x, y, i, j))
  64. continue;
  65. let patch = objects.buildObjects([{
  66. x: i,
  67. y: j,
  68. properties: {
  69. cpnArcanePatch: cpnArcanePatch,
  70. cpnParticles: {
  71. simplify: function () {
  72. return {
  73. type: 'particles',
  74. blueprint: this.blueprint
  75. };
  76. },
  77. blueprint: this.particles
  78. }
  79. },
  80. extraProperties: {
  81. arcanePatch: {
  82. caster: obj,
  83. spell: this
  84. }
  85. }
  86. }]);
  87. patches.push(patch);
  88. }
  89. }
  90. this.sendBump(target);
  91. this.queueCallback(null, this.duration * consts.tickTime, this.endEffect.bind(this, patches), null, true);
  92. return true;
  93. },
  94. endEffect: function (patches) {
  95. let pLen = patches.length;
  96. for (let i = 0; i < pLen; i++)
  97. patches[i].destroyed = true;
  98. }
  99. };