Page 1 of 1

Detecting that the player has aggro'd enemies

Posted: Sat Nov 14, 2020 5:12 pm
by PFQNiet
Is there any way to determine that the player has caused some enemies to attack them? Or that enemies in general have begun an attack?

In my specific case I'm looking for a way of detecting that an enemy has been distracted from its default wandering.

Code: Select all

struct.entity.set_command{
  type = defines.command.compound,
  structure_type = defines.compound_command.return_last,
  commands = {
    {
      type = defines.command.go_to_location,
      destination = struct.spawn,
      radius = 10,
      distraction = defines.distraction.by_damage
    },
    {
      type = defines.command.wander,
      radius = 15,
      distraction = defines.distraction.by_enemy
    }
  }
}
It would be sufficient for me to know when this command has been interrupted by a distraction.