Page 1 of 1

Add can_shoot(target,position) to turrets

Posted: Fri Mar 06, 2020 3:50 pm
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?

Re: Add can_shoot(target,position) to turrets

Posted: Fri Mar 06, 2020 3:59 pm
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.

Re: Add can_shoot(target,position) to turrets

Posted: Fri Mar 06, 2020 4:12 pm
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