Page 1 of 1

Wanting to adjust turret targeting priorities

Posted: Fri Feb 23, 2018 10:31 am
by Illiander42
I'm wanting to write a simple mod to let you say "this turret shoots the thing farthest away, this one shoots the thing nearest" and looking through the documentation I can't see how to do it.

Is there a mod that already does this, or is it something we can't do?

Why:

I want to set up a combined defence line where the laser turrets prioritise the stuff that stays at range (currently just spitters), and the bullet turrets take the stuff against the wall.

Re: Wanting to adjust turret targeting priorities

Posted: Sun Feb 25, 2018 7:56 pm
by 321freddy
AFAIK turrets don't have a prioritising mechanic built in, so you would have to simulate it.
You can set the shootng target of a turret using LuaEntity::shooting_target
Although I don't know how this could be used in a way that doesn't completely kill your performance.
Maybe use the events on_entity_damaged and on_entity_died with the cause parameter to script the desired behaviour.