Range/On Weapons
| Flag: | Range |
| File(s): | rules(md).ini |
| Values: | Floating point values: Any decimal number (clearer range should be added in Template:Values). |
| Special Values: | -2 in Red Alert 2 and Yuri's Revenge |
| Default: | 0 |
| Applicable to: | Weapons |
Define the maximum range of a weapon (in cells).
Notes
When the distance between the target and the unit is within this range, the normal Attack[1] cursor is used; otherwise, the AttackOutOfRange[2] cursor is used.
If the weapon uses a projectile with SubjectToElevation=yes, it can gain a range bonus when attacking from high ground to low ground, with calculation parameters set in [ElevationModel].
In Red Alert, if Range is negative, it will not participate in any distance checks, thus having no range limitation.
In Tiberian Sun, it is handled in a different way. If Range is negative, it will acts just the same as 0.
Starting from Red Alert 2, it is allowed to set Range=-2 for a weapon as a special handling that allows it to exit early at the beginning of the InRange check, thereby ignoring the distance limit to the target and the feasibility query along the attack path.[3]
- If you do not want some of these checks to be skipped, it is better to use a relatively large positive value to achieve infinite range. Considering the maximum distance of a map, this value should be 513 or higher.
Since the GuardRange is inherited from the Range by default, setting an excessively large Range value will cause game lag.
- Of course, you can also avoid this problem by disabling active target seeking.
- Similarly, if you set Range=-2 for all weapons that participate in the calculation of the default value of GuardRange, you need to manually configure the GuardRange to enable units to actively seek out enemies.
Generally, this determines whether to use two-dimensional plane distance or three-dimensional space distance for calculation based on whether the shooter is in the air or on the ground.
Bugs/Side-Effects/Unexpected Limitations
Building objects always use the primary weapon's Range to determine the range.
When a weapon is used as a sub weapon created by another weapon's projectile ShrapnelWeapon, its range should not exceed 11; otherwise, it will aim regardless of distance and may trigger the EIP#0046A496.
Weapons that use Arcing=yes projectiles directly judge the distance to the target's center when aiming at buildings, ignoring Foundation. This results in the weapon always being judged as OutOfRange and unable to attack if it faces a building so large that the vertical distance from the center to the long side is farther than the range.
Range=-2 will cause weapons with DiskLaser=yes to never start charging, thus unable to fire.
Range=-2 will cause aircraft to be unable to perform attack actions.
Footnotes
- ↑ In mouse.sha from frame 53 to 57 (0-based).
- ↑ In mouse.sha from frame 58 to 62 (0-based).
- ↑ The community often uses "infinite range" to summarize the behavior in this scenario. In fact, the distance limit also includes MinimumRange, and the attack path check includes SubjectToWalls and SubjectToCliffs, and so on.
References
Starting from Phobos Build#49, any weapon can be customized to use planar distance calculation or default rules (not equivalent to forced three-dimensional distance). Refer to Phobos documentation.