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.
 
 
 

132 lines
2.3 KiB

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