Page 1 of 1

Turret targeting API

Posted: Sun Apr 24, 2016 10:26 am
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.

Re: Turret targeting API

Posted: Tue Jul 05, 2016 6:47 pm
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.

Re: Turret targeting API

Posted: Tue Jul 05, 2016 7:11 pm
by DedlySpyder
Look at the flame turrets, they have a minimum range somehow

Re: Turret targeting API

Posted: Wed Jul 06, 2016 12:20 am
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.

Re: Turret targeting API

Posted: Wed Jul 06, 2016 11:21 am
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.

Re: Turret targeting API

Posted: Wed Jul 06, 2016 11:31 am
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.

Re: Turret targeting API

Posted: Wed Jul 06, 2016 10:00 pm
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!

Re: Turret targeting API

Posted: Sat Aug 20, 2016 7:47 am
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.