Invulnerable Entity

Place to get help with not working mods / modding interface.
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2179
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Invulnerable Entity

Post by Ranakastrasz »

Is there any way to prevent Enemies from being permitted to attack a certain type of entity
Setting Hp to zero breaks the game if you mine the entity again, and even a script can't fix it, and setting destructable to false doesn't stop enemies from attacking, but prevents damage, resulting in a bunch of really stupid looking biters and spitters.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Rseding91
Factorio Staff
Factorio Staff
Posts: 16018
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Invulnerable Entity

Post by Rseding91 »

Setting to destructible=false should prevent anything from targeting the entity. It doesn't however clear things already targeting it when it's set.

If it's not working please explain in what situations it's not working.
If you want to get ahold of me I'm almost always on Discord.
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2179
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: Invulnerable Entity

Post by Ranakastrasz »

Using Rampant AI. Entity is indestructible. Enemies attack it, but do nothing.

Rampant AI might force an attach, but I kinda expected it to reject the order.


Managed to fix it, sort of. The entity is now owned by "neutral" force once placed, and the biters now ignore it. That plus indestructible seems to work, but unlike a prototype change, takes some work if you want to be able to reverse it.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Veden
Filter Inserter
Filter Inserter
Posts: 296
Joined: Wed Jul 13, 2016 3:54 pm
Contact:

Re: Invulnerable Entity

Post by Veden »

The situation is:

***NOTE When I say biter I mean a unit group with at least one unit.

A biter kills a chunk of rail, the on death fires with the entity

Code: Select all

    local repairPosition = entity.position
    local repairName = entity.name
    local repairForce = entity.force
    local repairDirection = entity.direction
    entity.destroy()
    local entityRepaired = surface.create_entity({position=repairPosition,
						  name=repairName,
						  direction=repairDirection,
						  force=repairForce})
    entityRepaired.destructible = false
The biter that killed the rail moves to the next rail until all in the area are gone, at which point the rails have all been remade with destructible=false.

The next unit group of biters passes by the indestructible rails and begins attacking them.

I control biter movement through attack area commands with distraction by_enemy or by_anything and never set individual targets.
Post Reply

Return to “Modding help”