Factorio.com|Forums|Wiki|Mod Portal|API Docs

# Factorio Runtime Docs Version 2.0.77

# SegmentedUnitAIState - Runtime Docs

## SegmentedUnitAIState :: table

A structure describing the state of a LuaSegmentedUnit's AI.

#### Table fields

type | :: defines.segmented_unit_ai_state | Type of the AI state.
Type of the AI state.

Other attributes may be specified depending on `type`:

#### `defines.segmented_unit_ai_state.patrolling`

waypoint | :: uint32 | Index into the unit's territory's LuaTerritory::get_patrol_path array. If the unit is not assigned to a territory, then this value is an index into a patrol path that the engine internally uses to guide the segmented unit and cannot be directly accessed. See SegmentedUnitPrototype::territory_radius.
Index into the unit's territory's LuaTerritory::get_patrol_path array. If the unit is not assigned to a territory, then this value is an index into a patrol path that the engine internally uses to guide the segmented unit and cannot be directly accessed. See SegmentedUnitPrototype::territory_radius.
destination | :: MapPosition | Read-only. The position of the `waypoint` the unit is navigating to. This field is provided as a convenience when reading the AI state and is not used during parsing.
Read-only. The position of the `waypoint` the unit is navigating to. This field is provided as a convenience when reading the AI state and is not used during parsing.

#### `defines.segmented_unit_ai_state.investigating`

destination | :: MapPosition | The position where the unit detected a disturbance in its territory and is presently navigating towards.
The position where the unit detected a disturbance in its territory and is presently navigating towards.

#### `defines.segmented_unit_ai_state.attacking`

target | :: LuaEntity? | The entity that the unit is attacking. May be nil if the entity has been destroyed or is otherwise invalid, but the segmented unit has not had an opportunity to update its AI.
The entity that the unit is attacking. May be nil if the entity has been destroyed or is otherwise invalid, but the segmented unit has not had an opportunity to update its AI.
destination | :: MapPosition? | Read-only. The position of `target`. This field is provided as a convenience when reading the AI state and is not used during parsing.
Read-only. The position of `target`. This field is provided as a convenience when reading the AI state and is not used during parsing.

#### `defines.segmented_unit_ai_state.enraged_at_target`

last_damage_time | :: MapTick | The map tick when the segmented unit was last attacked. Controls how long the segmented unit will remain enraged before returning to one of the other states. See SegmentedUnitPrototype::enraged_duration.
The map tick when the segmented unit was last attacked. Controls how long the segmented unit will remain enraged before returning to one of the other states. See SegmentedUnitPrototype::enraged_duration.
remaining_time | :: MapTick | Read-only. The number of ticks the segmented unit will remain enraged before transitioning to one of the non-enraged states. This field is provided as a convenience when reading the AI state but is not used during parsing.
Read-only. The number of ticks the segmented unit will remain enraged before transitioning to one of the non-enraged states. This field is provided as a convenience when reading the AI state but is not used during parsing.
target | :: LuaEntity? | The entity that the unit is attacking. May be nil if the entity has been destroyed or is otherwise invalid, but the segmented unit has not had an opportunity to update its AI.
The entity that the unit is attacking. May be nil if the entity has been destroyed or is otherwise invalid, but the segmented unit has not had an opportunity to update its AI.
attacked_me | :: boolean | True if the `target` entity attacked this segmented unit. Entities that have attacked this segmented unit will have attack priority over those that have not.
True if the `target` entity attacked this segmented unit. Entities that have attacked this segmented unit will have attack priority over those that have not.
destination | :: MapPosition? | Read-only. The position of `target`. This field is provided as a convenience when reading the AI state and is not used during parsing.
Read-only. The position of `target`. This field is provided as a convenience when reading the AI state and is not used during parsing.

#### `defines.segmented_unit_ai_state.enraged_at_nothing`

last_damage_time | :: MapTick | The map tick when the segmented unit was last attacked. Controls how long the segmented unit will remain enraged before returning to one of the non-enraged states. See SegmentedUnitPrototype::enraged_duration.
The map tick when the segmented unit was last attacked. Controls how long the segmented unit will remain enraged before returning to one of the non-enraged states. See SegmentedUnitPrototype::enraged_duration.
remaining_time | :: MapTick | Read-only. The number of ticks the segmented unit will remain enraged before transitioning to one of the non-enraged states. This field is provided as a convenience when reading the AI state but is not used during parsing.
Read-only. The number of ticks the segmented unit will remain enraged before transitioning to one of the non-enraged states. This field is provided as a convenience when reading the AI state but is not used during parsing.
destination | :: MapPosition | The arbitrary position the segmented unit is navigating to while searching for a nearby attack target.
The arbitrary position the segmented unit is navigating to while searching for a nearby attack target.

Concept used in

- LuaSegmentedUnit::get_ai_state()
- LuaSegmentedUnit::set_ai_state()