Usually, turrets automatically look for a target they can reach. I've described a case here where turrets get targets assigned by script. This will always work for turrets of the "ammo-turret" protptype ("electric-turret" as well, I guess), but not for turrets of the prototype "fluid-turret", because fluid turrets can only cover a segment of a circle instead of a whole circle.
Currently, it is not possible without potentially expensive trickery (intersecting results from find_entities_filtered{area=…, …} and find_entities_filtered{position=…, radius=…, …}, trigonometry etc.) to determine whether a given turret can actually reach a certain enemy unit. Players have the property "can_shoot(target, position). Making this property available to fluid turrets would be extremely helpful. Would you consider adding it, please?
Add can_shoot(target,position) to turrets
Add can_shoot(target,position) to turrets
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
- Deadlock989
- Smart Inserter
- Posts: 2529
- Joined: Fri Nov 06, 2015 7:41 pm
Re: Add can_shoot(target,position) to turrets
Technically, any turret can have the turn_range property. I have an electric turret which fires projectiles within a limited turning arc. It's just that the only turret in vanilla which uses turn_range happens to be a fluid turret. Likewise, fluid turrets can also be set up to fire in any direction.Pi-C wrote: Fri Mar 06, 2020 3:50 pm Usually, turrets automatically look for a target they can reach. I've described a case here where turrets get targets assigned by script. This will always work for turrets of the "ammo-turret" protptype ("electric-turret" as well, I guess), but not for turrets of the prototype "fluid-turret", because fluid turrets can only cover a segment of a circle instead of a whole circle.
Re: Add can_shoot(target,position) to turrets
So, it would make sense to have that property for all turret types? Actually, I wouldn't mind that either! It would make at least two tests obsolete: for min_range <= distance_turret_enemy <= max_range and for direction.Deadlock989 wrote: Fri Mar 06, 2020 3:59 pm Technically, any turret can have the turn_range property.

A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!