Page 1 of 1

Only Fire on/Target Spawners

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

Re: Only Fire on/Target Spawners

Posted: Mon Apr 25, 2016 4:31 pm
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.

Re: Only Fire on/Target Spawners

Posted: Mon Apr 25, 2016 4:49 pm
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.

Re: Only Fire on/Target Spawners

Posted: Mon Apr 25, 2016 5:34 pm
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.

Re: Only Fire on/Target Spawners

Posted: Mon Apr 25, 2016 6:17 pm
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).

Re: Only Fire on/Target Spawners

Posted: Tue Apr 26, 2016 6:04 pm
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.

Re: Only Fire on/Target Spawners

Posted: Tue Apr 26, 2016 7:34 pm
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: