Ticket #2093: distance_spread.diff
File distance_spread.diff, 2.2 KB (added by , 11 years ago) |
---|
-
binaries/data/mods/public/simulation/components/Attack.js
138 138 "<element name='ProjectileSpeed' a:help='Speed of projectiles (in metres per second). If unspecified, then it is a melee attack instead'>" + 139 139 "<ref name='nonNegativeDecimal'/>" + 140 140 "</element>" + 141 "<element name='Spread' a:help='Radius over which missiles will tend to land . Roughly 2/3 will land inside this radius (in metres)'><ref name='nonNegativeDecimal'/></element>" +141 "<element name='Spread' a:help='Radius over which missiles will tend to land when shooting of the maximum range. Roughly 2/3 will land inside this radius (in metres). When the target is closer to this unit, the spread is naturally diminised.'><ref name='nonNegativeDecimal'/></element>" + 142 142 bonusesSchema + 143 143 preferredClassesSchema + 144 144 restrictedClassesSchema + … … 469 469 // Predict where the unit is when the missile lands. 470 470 var predictedPosition = {"x": targetPosition.x + targetVelocity.x * timeToTarget, 471 471 "z": targetPosition.z + targetVelocity.z * timeToTarget}; 472 472 473 473 // Compute the real target point (based on spread and target speed) 474 var range = this.GetRange(type); 475 var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 476 var elevationAdaptedMaxRange = cmpRangeManager.GetElevationAdaptedRange(selfPosition, cmpPosition.GetRotation(), range.max, range.elevationBonus, 0); 477 var distanceModifiedSpread = spread * Math.sqrt(horizDistance/elevationAdaptedMaxRange); 474 478 var randNorm = this.GetNormalDistribution(); 475 var offsetX = randNorm[0] * spread * (1 + this.VectorLength(targetVelocity) / 20);476 var offsetZ = randNorm[1] * spread * (1 + this.VectorLength(targetVelocity) / 20);479 var offsetX = randNorm[0] * distanceModifiedSpread; 480 var offsetZ = randNorm[1] * distanceModifiedSpread; 477 481 478 482 var realTargetPosition = { "x": predictedPosition.x + offsetX, "y": targetPosition.y, "z": predictedPosition.z + offsetZ }; 479 483