Page 1 of 1

Invulnerable Entity

Posted: Thu Apr 13, 2017 8:28 pm
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.

Re: Invulnerable Entity

Posted: Thu Apr 13, 2017 10:18 pm
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.

Re: Invulnerable Entity

Posted: Thu Apr 13, 2017 10:21 pm
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.

Re: Invulnerable Entity

Posted: Mon Apr 17, 2017 1:50 am
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.