Page 1 of 1

Friendly fire turrets

Posted: Fri Dec 09, 2016 4:35 pm
by droid
I would like to make turrets that attack the player that placed them as well as the enemy force.

I tried a few variations on the function game.player.force.set_cease_fire() but saw no effect. If it worked it might create more problems because turrets would also fire at turrets and other structures.

I could do this if I change the force of the turret when it is placed. This has several problematic side effects:
  • can't open the inventory of the turret (for bullet firing turrets)
    can't repair the turret
    technologies will not apply to the other force
Rather than work around the side effects, I might re-write the targeting logic, but I am not sure what functions to override.

Re: Friendly fire turrets

Posted: Fri Dec 09, 2016 6:32 pm
by daniel34
After reading the first two paragraphs my idea would be to place the turret into a newly created force that attacks the player force. But why would you want the player to be able to open the inventory of the turret and repair it if it shoots at the player? I don't understand your use-case. (Why would a player place a turret that targets himself?)
droid wrote:technologies will not apply to the other force
You can just copy the enabled technologies (or their result) to the turret-force.

Re: Friendly fire turrets

Posted: Sat Dec 10, 2016 12:15 am
by droid
I want using turrets to be more challenging.

The idea is that I still want to use them to defend my base (so they need to accept more ammo) but they just have a simple motion detector to find and eliminate targets and so using them safely is more challenging.

It will be possible to approach them without being hit because I have already limited their firing angle and added a minimum firing range.

Re: Friendly fire turrets

Posted: Sat Dec 10, 2016 12:28 am
by droid
Turret force is looking more workable. The inventory problem is the only one that remains.

Changing the force works well for laser turrets, you can repair them and give them electricity. Only gun-turret is a problem.

Re: Friendly fire turrets

Posted: Sat Dec 10, 2016 1:22 am
by droid
And by relying on this bug I can insert into an enemy turret as long as I use an inserter.

Re: Friendly fire turrets

Posted: Sat Dec 10, 2016 3:24 pm
by darkfrei
droid wrote:Turret force is looking more workable. The inventory problem is the only one that remains.

Changing the force works well for laser turrets, you can repair them and give them electricity. Only gun-turret is a problem.
This friendly-fire turrets can be good for health-turrets. You can change the force to enemy if it have enough energy or ammo. Without energy or ammo it have the player force.