Page 1 of 1

anti-nest/base turret

Posted: Sun Mar 12, 2017 2:25 am
by Bizobinator
How do I set a turret so that it will only attack worms, spawners, and other player's buildings (for PvP)?

Re: anti-nest/base turret

Posted: Sun Mar 12, 2017 7:55 pm
by Bizobinator
Is this something that gets specified for the turret? For the ammunition? Does it have to be part of the control.lua?

Re: anti-nest/base turret

Posted: Sun Mar 12, 2017 8:33 pm
by Adil
Yes, it must be done through script.
A true turret entity from the game will only care if its enemy or friend.
You'll need to use lua to perform all the turret logic.
It's not like it will be problematic though: buildings are immobile and don't appear out of nowhere.

Re: anti-nest/base turret

Posted: Sun Mar 12, 2017 11:31 pm
by Bizobinator
Rats, really?

Damn :P. That might create a fair bit of lag for what I want to do....

Re: anti-nest/base turret

Posted: Sun Mar 12, 2017 11:49 pm
by Adil
If done correctly, a "turret" that "can only shoot immobile entities" will be in the list of the less performance taxing mods.

Re: anti-nest/base turret

Posted: Mon Mar 13, 2017 4:57 pm
by Bizobinator
Adil wrote:If done correctly, a "turret" that "can only shoot immobile entities" will be in the list of the less performance taxing mods.

Oh?

I've read a little bit of the logic/control.lua from the Bio-Cannon & Additional Turrets mods.... How exactly would I go about coding what you described?

Btw, thanks for your help :)

Re: anti-nest/base turret

Posted: Mon Mar 13, 2017 6:03 pm
by darkfrei
Adil wrote:If done correctly, a "turret" that "can only shoot immobile entities" will be in the list of the less performance taxing mods.
You can use the bomber logic from modding tutorial. No graphics, but searching and hit entities by timer.

Re: anti-nest/base turret

Posted: Sun Mar 19, 2017 7:17 pm
by Bizobinator
Hmm... Adil, what way did you have in mind? I read up on the bomber tutorial, & I think it'll definitely help me. But, is there a command that makes a turret attack a specific entity?

Re: anti-nest/base turret

Posted: Sun Mar 19, 2017 11:11 pm
by Adil
No there's no command for that.
I was referring to the fact that you can emulate the turret behavior with quite little computations involved, if the goal is to attack only immobile objects. The entity would not actually be a "turret" from the game engine perspective. Most likely it'd be a chest from which you'd deduct ammunition via the script command and use the scripts to damage the enemy entities.

What makes scripts slow is the interface api, some of them notably more slow than the others. The `find_entities` function from the bomber tutorial is one of the slowest in the game.
The idea is that that command actually needs to be called very infrequently. You could maintain short ordered lists of valid targets for each `turret` and only sometimes run scan for the enemy entities when the list is empty. The buildings created by players (robots) can be detected with respective events, for biters new base detection could be rigged by maintaining the counts of entities belonging to their force.