Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

137 lignes
2.5 KiB

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