From 4edff555a3a7acd952a2b169f890169a39ab527e Mon Sep 17 00:00:00 2001 From: fatherbushido Date: Mon, 10 Oct 2016 18:59:59 +0000 Subject: [PATCH] Fix an issue with ranged attack: wrong units were damaged. Refs #4276. Commented by leper and Itms. This was SVN commit r18828. --- .../public/simulation/components/Damage.js | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/binaries/data/mods/public/simulation/components/Damage.js b/binaries/data/mods/public/simulation/components/Damage.js index 48c931dcf3..4ab21b57af 100644 --- a/binaries/data/mods/public/simulation/components/Damage.js +++ b/binaries/data/mods/public/simulation/components/Damage.js @@ -130,21 +130,24 @@ Damage.prototype.MissileHit = function(data, lateness) // If we didn't hit the main target look for nearby units let cmpPlayer = QueryPlayerIDInterface(data.attackerOwner); let ents = this.EntitiesNearPoint(Vector2D.from3D(data.position), targetPosition.horizDistanceTo(data.position) * 2, cmpPlayer.GetEnemies()); + let projectileHit = false; for (let ent of ents) + { if (!this.TestCollision(ent, data.position, lateness)) - { - this.CauseDamage({ - "strengths": data.strengths, - "target": ent, - "attacker": data.attacker, - "multiplier": data.multiplier, - "type": data.type, - "attackerOwner": data.attackerOwner - }); + continue; - cmpProjectileManager.RemoveProjectile(data.projectileId); - break; - } + projectileHit = true; + this.CauseDamage({ + "strengths": data.strengths, + "target": ent, + "attacker": data.attacker, + "multiplier": data.multiplier, + "type": data.type, + "attackerOwner": data.attackerOwner + }); + } + if (projectileHit) + cmpProjectileManager.RemoveProjectile(data.projectileId); }; /**