Turret targeting API

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
SyncViews
Filter Inserter
Filter Inserter
Posts: 295
Joined: Thu Apr 21, 2016 3:17 pm
Contact:

Turret targeting API

Post by SyncViews »

It would be useful to be able to script the targeting of turrets, to select a target object or position replacing the default "nearest" logic. This could be in the form of a set_target_object, set_target_position, fire_auto, fire_single_shot, along with new helpers and events so that lua scripts do not need to run needlessly over every turret in the map, and to help find/select targets.

This would allow for designs that don`t fit well into the current model, such as AOE weapons (do not play well with expected damage, target clusters, or friendly fire for explosives), more complex damage resistances (need to pick out something can damage effectively), or substantial range changes (e.g. a long range low-dps turret should likely coordinate to target spitters, which are also often out of range of most short range gun turrets), allowing for a more interesting defense mix.


EDIT: Someone asked else where about making a turret that just bombards spawners. That would be another use of such an API, since that turret type could then easily be given an AI to only target spawners.

Buhamut
Inserter
Inserter
Posts: 24
Joined: Sun Apr 26, 2015 1:47 pm
Contact:

Re: Turret targeting API

Post by Buhamut »

I made an artillery mod a long time ago, and this issue caused me to lose interest in it fairly quickly. I used a turret prototype so that I could have animations for it raising and lowering as well as 64 degrees of rotation. This initially was great until I realized that the turret was auto-targeting the nearest enemy causing splash damage to the defenses set up by it when the biters would get close. I wrote a targeting script, but then found that I could not tell the turret what to target. The only way around this problem would be to have the script create the projectiles manually, and not use a turret at all for the prototype so I could aim it where it was going to fire.

My mod would become viable again if this API was implemented, otherwise I will have to figure out how to control all of the animations and firing manually through scripts.

User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: Turret targeting API

Post by DedlySpyder »

Look at the flame turrets, they have a minimum range somehow

Buhamut
Inserter
Inserter
Posts: 24
Joined: Sun Apr 26, 2015 1:47 pm
Contact:

Re: Turret targeting API

Post by Buhamut »

Good advice. Flamethrower turrets have a "min_range" field that I do not remember existing in previous versions. If this works for regular turrets and/or ammo, then the long standing problem my mod suffered from will be fixed, and so easily as well. Hope I can figure it out.

SyncViews
Filter Inserter
Filter Inserter
Posts: 295
Joined: Thu Apr 21, 2016 3:17 pm
Contact:

Re: Turret targeting API

Post by SyncViews »

Need to look in detail, but a simple min range still allows for friendly fire along the wall/defence line. It would only entirly solve the problem for an artillery outpost such that none of your other defence lines fall between the min and max range.

User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: Turret targeting API

Post by DedlySpyder »

SyncViews wrote:Need to look in detail, but a simple min range still allows for friendly fire along the wall/defence line. It would only entirly solve the problem for an artillery outpost such that none of your other defence lines fall between the min and max range.
Well the flamethrower turrets solve this by also having a specific firing arc. I assume the same thing could be used for artillery.

Buhamut
Inserter
Inserter
Posts: 24
Joined: Sun Apr 26, 2015 1:47 pm
Contact:

Re: Turret targeting API

Post by Buhamut »

After many hours I was able to get my mod back up and running with 0.13. The min_range field works perfectly, even showing the green highlight! I'm so pleased!

Sorry to steal the topic. While I would still like to see the ability to command the turrets implemented, the min_range field is good enough for my mod for now. Best of luck!

mpd_steam
Manual Inserter
Manual Inserter
Posts: 4
Joined: Mon Jun 27, 2016 1:57 pm
Contact:

Re: Turret targeting API

Post by mpd_steam »

I'd like this too! I have a few ideas for manual/script control of turrets, but when I looked at the lua files I've found that we can't really control their behaviour :(

How about it devs? Personally I'd be happy if I could:
- Disable auto-firing,
- Trigger turret extension,
- Set rotation, and
- 'Fire'.

The advanced targeting stuff would be nice, but would probably be a bit more work for the devs.

Post Reply

Return to “Modding interface requests”