I think this thing should be solved by engine, if we would agree attack command execution is engine task :).
Requested on mantis: http://springrts.com/mantis/view.php?id=3900
-------------------------------
Examples of use (in all examples unit gets attack command when 3000 from target):
Result in Spring 94.1: Unit will run to trunget, when 800 from target, it will use the Net, target is stunned, but after it Headhunter just stay 800 from target and do nothing until target moves away or Net is reloaded.Unit1 (Headhunter)
- Weapon1: Sabre - Melee (range: 30, DMG: 1500, reload: 1sec)
- Weapon2: Net (range: 800, DMG: 0-20, reload: 15sec, => stun target for 8 seconds)
Btw in Spring 91 Unit1 this unit would work ok, because there was some ancient primary/secondary selection of weapons. But yes, i understand why it was changed.
Result in Spring 94.1: Battleship goes to target, when 1000 from target, Weapon4 shoots, and ship is stopped, use only one weapon, because for rest of them target is far away from them.Unit2 (Bismark Zuckerberg - battleship)
- Weapon1: Tripple plasma (range: 850, DMG: 300, reload: 3secs)
- Weapon2: Tripple plasma (range: 850, DMG: 300, reload: 3secs)
- Weapon3: Tripple plasma (range: 850, DMG: 300, reload: 3secs)
- Weapon4: Dua long plasma (range: 1000, DMG: 250, reload: 4secs)
- Weapons5-10: Some shity guns (range: 300-500, DMG: 10-100, reload: variable)
-------------------------------
Solution:
- make UnitDef called "MaxAttackDistance" (default <= range of weapon with the longest range, integer)
- make Lua SyncedCtrl "Spring.SetMaxAttackDistance(unitID)" which can set/change the default/defined value.