Only Fire on/Target Spawners

Place to get help with not working mods / modding interface.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Only Fire on/Target Spawners

Post by TheSAguy »

Hi,

I'd like to create a turret / Artillery that can only fire at spawners. (So not enemy units)

How would I go about accomplishing this?
Thanks.


Thanks.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Only Fire on/Target Spawners

Post by TheSAguy »

Still need some help here please.

If it's not possible to just target spawners, would it be possible to make it so that the turret can't be placed if there is no spawner in the firing range?

Order of preference:
1 - can only fire at Spawners.
2 - can't be placed, unless there is a spawner in range of were you want to place it.
3 - you can place it, but the range will be 0 and you'll get a message saying there was no spawner in range. (Something like: "You need a spawner in range to calibrate firing, as a result your turret rage is 0"


I think option 3 is relatively easy (To a programmer), Just a test to see if there is a spawner in rage, something to do with find entity filter blah blah blah...

I'd appreciate the help!
Thanks.
SyncViews
Filter Inserter
Filter Inserter
Posts: 295
Joined: Thu Apr 21, 2016 3:17 pm
Contact:

Re: Only Fire on/Target Spawners

Post by SyncViews »

How would 3 then shoot the spawner (and not a biter that is likely nearer)? Only idea I have is to fake it entirely since your talking about a small number of turrets, projectiles and targets. Make a non-turret building, then write a lua script to spawn "bullet" entities above your turret object that moves towards the nearest spawner, at which point delete the bullet entity and damage the spawner.

I created a thread for Turret targeting API yesterday, this would be another use case.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Only Fire on/Target Spawners

Post by TheSAguy »

SyncViews wrote:How would 3 then shoot the spawner (and not a biter that is likely nearer)?
You're right, option 2 & 3 will both be able to target units. My workaround would have been to make the projectiles go very slow. So units wold be missed, but stationary targets like spawners would eventually be hit. Not ideal, but...that's what you get when you cant get option 1 :)
SyncViews wrote:Only idea I have is to fake it entirely since your talking about a small number of turrets, projectiles and targets. Make a non-turret building, then write a lua script to spawn "bullet" entities above your turret object that moves towards the nearest spawner, at which point delete the bullet entity and damage the spawner.
Interesting idea. Will have to think how to write this code.
SyncViews
Filter Inserter
Filter Inserter
Posts: 295
Joined: Thu Apr 21, 2016 3:17 pm
Contact:

Re: Only Fire on/Target Spawners

Post by SyncViews »

I don't think slow projectiles will work. I am pretty sure that all projectiles are homing and will exceed the max range if the unit moves away. Also the game tracks how much damage it expects an entity to take, so once a biter has a slow "death orb" chasing it, no other turret will shoot that biter (which also prevents thing like shotgun turrets really working, because the expected damage calculation is wrong).
User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: Only Fire on/Target Spawners

Post by Adil »

You don't make it a turret. Just create a box and intermittently check whether it's time to shoot and use other entities to play animation and spawn projectiles with lua. It's not like all that will burden the game engine much since it don't really need to be checked often.
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.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Only Fire on/Target Spawners

Post by TheSAguy »

Adil wrote:You don't make it a turret. Just create a box and intermittently check whether it's time to shoot and use other entities to play animation and spawn projectiles with lua. It's not like all that will burden the game engine much since it don't really need to be checked often.
You make it sound so easy... and for you it probably is just basic code!

I get the don't use turret, container switch-out. Speedy Brain's Supreme Warfare does something like that.

So I guess what's needed is a search for spawner in radius every x ticks and if found send a projectile to it...

Still could use some help to actually accomplish this :oops:
Post Reply

Return to “Modding help”