anti-nest/base turret

Place to get help with not working mods / modding interface.
Post Reply
Bizobinator
Fast Inserter
Fast Inserter
Posts: 193
Joined: Fri May 06, 2016 10:35 pm
Contact:

anti-nest/base turret

Post by Bizobinator »

How do I set a turret so that it will only attack worms, spawners, and other player's buildings (for PvP)?

Bizobinator
Fast Inserter
Fast Inserter
Posts: 193
Joined: Fri May 06, 2016 10:35 pm
Contact:

Re: anti-nest/base turret

Post by Bizobinator »

Is this something that gets specified for the turret? For the ammunition? Does it have to be part of the control.lua?

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: anti-nest/base turret

Post 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.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

Bizobinator
Fast Inserter
Fast Inserter
Posts: 193
Joined: Fri May 06, 2016 10:35 pm
Contact:

Re: anti-nest/base turret

Post by Bizobinator »

Rats, really?

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

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: anti-nest/base turret

Post by Adil »

If done correctly, a "turret" that "can only shoot immobile entities" will be in the list of the less performance taxing mods.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

Bizobinator
Fast Inserter
Fast Inserter
Posts: 193
Joined: Fri May 06, 2016 10:35 pm
Contact:

Re: anti-nest/base turret

Post 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 :)

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2904
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: anti-nest/base turret

Post 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.

Bizobinator
Fast Inserter
Fast Inserter
Posts: 193
Joined: Fri May 06, 2016 10:35 pm
Contact:

Re: anti-nest/base turret

Post 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?

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: anti-nest/base turret

Post 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.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

Post Reply

Return to “Modding help”