Add can_shoot(target,position) to turrets

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1743
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Add can_shoot(target,position) to turrets

Post by Pi-C »

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?
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2529
Joined: Fri Nov 06, 2015 7:41 pm

Re: Add can_shoot(target,position) to turrets

Post by Deadlock989 »

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.
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
Smart Inserter
Smart Inserter
Posts: 1743
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Add can_shoot(target,position) to turrets

Post by Pi-C »

Deadlock989 wrote: Fri Mar 06, 2020 3:59 pm Technically, any turret can have the turn_range property.
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. :-D
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Post Reply

Return to “Modding interface requests”