Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

134 Zeilen
2.8 KiB

  1. module.exports = {
  2. type: 'projectile',
  3. applyEffect: null,
  4. cdMax: 7,
  5. manaCost: 0,
  6. range: 9,
  7. speed: 150,
  8. statMult: 1,
  9. damage: 1,
  10. row: 3,
  11. col: 0,
  12. needLos: true,
  13. shootAll: false,
  14. percentDamage: false,
  15. cast: function (action) {
  16. if (this.shootAll) {
  17. this.castAll(action);
  18. return true;
  19. }
  20. let obj = this.obj;
  21. let target = action.target;
  22. let ttl = (Math.sqrt(Math.pow(target.x - obj.x, 2) + Math.pow(target.y - obj.y, 2)) * this.speed) - 50;
  23. let projectileConfig = {
  24. caster: this.obj.id,
  25. extraTargets: 0,
  26. components: [{
  27. idSource: this.obj.id,
  28. idTarget: target.id,
  29. type: 'projectile',
  30. ttl: ttl,
  31. projectileOffset: this.projectileOffset,
  32. particles: this.particles
  33. }, {
  34. type: 'attackAnimation',
  35. layer: 'projectiles',
  36. loop: -1,
  37. row: this.row,
  38. col: this.col
  39. }]
  40. };
  41. this.obj.fireEvent('beforeSpawnProjectile', this, projectileConfig);
  42. this.sendBump(target);
  43. let targets = [target];
  44. let aggroList = this.obj.aggro.list
  45. .filter(function (l) {
  46. return (l.obj !== target);
  47. });
  48. for (let i = 0; i < Math.min(aggroList.length, projectileConfig.extraTargets); i++) {
  49. let pick = ~~(Math.random() * aggroList.length);
  50. targets.push(aggroList[pick].obj);
  51. aggroList.splice(pick, 1);
  52. }
  53. targets.forEach(function (t) {
  54. ttl = (Math.sqrt(Math.pow(t.x - obj.x, 2) + Math.pow(t.y - obj.y, 2)) * this.speed) - 50;
  55. let config = extend({}, projectileConfig);
  56. config.components[0].ttl = ttl;
  57. config.components[0].idTarget = t.id;
  58. this.sendAnimation(config);
  59. this.queueCallback(this.explode.bind(this, t), ttl, null, t);
  60. }, this);
  61. return true;
  62. },
  63. castAll: function (action) {
  64. let obj = this.obj;
  65. let list = this.obj.aggro.list;
  66. let lLen = list.length;
  67. for (let i = 0; i < lLen; i++) {
  68. let target = list[i].obj;
  69. let ttl = (Math.sqrt(Math.pow(target.x - obj.x, 2) + Math.pow(target.y - obj.y, 2)) * this.speed) - 50;
  70. let projectileConfig = {
  71. caster: this.obj.id,
  72. components: [{
  73. idSource: this.obj.id,
  74. idTarget: target.id,
  75. type: 'projectile',
  76. ttl: ttl,
  77. projectileOffset: this.projectileOffset,
  78. particles: this.particles
  79. }, {
  80. type: 'attackAnimation',
  81. layer: 'projectiles',
  82. loop: -1,
  83. row: this.row,
  84. col: this.col
  85. }]
  86. };
  87. this.obj.fireEvent('beforeSpawnProjectile', this, projectileConfig);
  88. this.sendAnimation(projectileConfig);
  89. this.sendBump(target);
  90. this.queueCallback(this.explode.bind(this, target), ttl, null, target);
  91. }
  92. },
  93. explode: function (target) {
  94. if ((this.obj.destroyed) || (target.destroyed))
  95. return;
  96. let damage = this.getDamage(target);
  97. if (!target.stats)
  98. return;
  99. if (this.applyEffect)
  100. target.effects.addEffect(this.applyEffect, this.obj);
  101. target.stats.takeDamage(damage, this.threatMult, this.obj);
  102. }
  103. };