I used the anti-missile beam of the sniper bot to make a turret that shoots down missiles and artillery shells, but it's effectiveness is greatly hindered by a lack of target spreading. When I plonk down several of the turrets close together and have several artillery pieces or catapults shoot at them I notice them firing on the same projectile a lot instead of spreading their fire to cover all targets. It's weird that this is happening because it's an instakill weapon, and still they manage to fire at the entity twice or even three times. Any thoughts on how to improve this ? Here is the weapon.json Spread fire is set to true but it's not doing what I want, maybe because entity's don't have health ? { "base_spec": "/pa/tools/base_shell_turret/base_shell_turret.json", "ammo_id": "/pa/units/land/anti_ballistics/anti_ballistics_ammo.json", "rate_of_fire": 1.0, "idle_aim_delay": 5.0, "max_range": 200, "yaw_rate": 720, "pitch_rate": 720, "yaw_range": 180, "pitch_range": 89, "spread_fire": true, "auto_attack": true, "manual_fire": true, "auto_task_type": "anti_entity", "anti_entity_targets_units": false, "anti_entity_targets": ["/pa/units/land/bot_tactical_missile/bot_tactical_missile_ammo.json", "/pa/units/air/bomber_adv/bomber_adv_ammo.json", "/pa/units/land/artillery_short/artillery_short_ammo.json", "/pa/units/land/artillery_long/artillery_long_ammo.json", "/pa/units/land/tactical_missile_launcher/tactical_missile_launcher_ammo.json"], "target_layers": ["WL_Air", "WL_Orbital"] }
At some point, anti-nuke had problems with multiple units firing at the same nuke. And it was fixed. So you can try looking at anti-nuke code.
Well, the game is simulated within discrete time intervals (aka ticks). Every tick starts with some kind of task planning phase, where every unit decides what to do. After this the simulation will advance in time and all the tasks get executed. That's where units move or shoot, bullets hit, etc... Now it should be clear, why this happens. Imagine some missles approching a group of anti missle towers, during planning phase all the towers select the nearest missle, since the towers are positioned in a group, it is highly possible that all towers will select the same missle. During execution, one shot will kill the missle all other shots will count as overkill. This is a fundamental problem, you can see it on Shellers as well, but the effect is not as pronounced on slower killing weapons. There isn't an easy solution for this. Doing it correctly would require to simulate the outcome of a shot, to determine if it actually kills the target. With n targets and m shooting units this would require n*m simulations. However it might be solvable in a probabilistic way. Instead of targeting the nearest unit, you select k nearest units and choose randomly a target from this group. This will give you a 1/k chance to hit another unit than your neighbour, the downside is that you might not target the most important target.