Friendly fire turrets

Place to get help with not working mods / modding interface.
User avatar
droid
Manual Inserter
Manual Inserter
Posts: 4
Joined: Fri Dec 09, 2016 4:04 pm
Contact:

Friendly fire turrets

Post 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.
daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: Friendly fire turrets

Post 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.
quick links: log file | graphical issues | wiki
User avatar
droid
Manual Inserter
Manual Inserter
Posts: 4
Joined: Fri Dec 09, 2016 4:04 pm
Contact:

Re: Friendly fire turrets

Post 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.
User avatar
droid
Manual Inserter
Manual Inserter
Posts: 4
Joined: Fri Dec 09, 2016 4:04 pm
Contact:

Re: Friendly fire turrets

Post 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.
User avatar
droid
Manual Inserter
Manual Inserter
Posts: 4
Joined: Fri Dec 09, 2016 4:04 pm
Contact:

Re: Friendly fire turrets

Post by droid »

And by relying on this bug I can insert into an enemy turret as long as I use an inserter.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Friendly fire turrets

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

Return to “Modding help”