destroy{raise_destroy?=…} | Destroys the segmented unit. | |
Destroys the segmented unit. | ||
die(force?, cause?, damage_type?) | Immediately kills the unit. [...] | |
Immediately kills the unit. [...] | ||
damage(damage, force, type?, source?, cause?) | → float | Damages the unit. |
Damages the unit. | ||
move_forward(distance) | Moves the unit forward by a fixed distance according to its natural movement patterns and AI configuration. [...] | |
Moves the unit forward by a fixed distance according to its natural movement patterns and AI configuration. [...] | ||
clone{position=…, surface?=…, force?=…, territory?=…} | → LuaSegmentedUnit? | Clones this unit. |
Clones this unit. | ||
get_body_nodes() | → array[MapPosition] | Gets the nodes that define the shape of the unit's body from front to back. [...] |
Gets the nodes that define the shape of the unit's body from front to back. [...] | ||
set_body_nodes(nodes) | Overwrites the segmented unit's body nodes, which are a series of points that make up the general shape of the unit. [...] | |
Overwrites the segmented unit's body nodes, which are a series of points that make up the general shape of the unit. [...] | ||
get_ai_state() | → SegmentedUnitAIState | Gets the state of the unit's AI. [...] |
Gets the state of the unit's AI. [...] | ||
set_ai_state(state) | Sets the segmented unit's AI. | |
Sets the segmented unit's AI. | ||
prototype | :: R LuaEntityPrototype | The prototype of the |
The prototype of the | ||
surface | :: R LuaSurface | The surface on which the unit is located. |
The surface on which the unit is located. | ||
territory | :: RW LuaTerritory? | The territory that the unit is protecting. |
The territory that the unit is protecting. | ||
segments | :: R array[LuaSegment] | The segments that compose the unit. |
The segments that compose the unit. | ||
force | :: R LuaForce | W ForceID | The force that the unit belongs to. [...] |
The force that the unit belongs to. [...] | ||
unit_number | :: R uint64 | A unique number identifying this unit for the lifetime of the save. [...] |
A unique number identifying this unit for the lifetime of the save. [...] | ||
health | :: RW float | The current health of the unit. [...] |
The current health of the unit. [...] | ||
max_health | :: R float | The maximum health of the unit. |
The maximum health of the unit. | ||
health_ratio | :: RW float | The ratio of LuaSegmentedUnit::health to LuaSegmentedUnit::max_health. [...] |
The ratio of LuaSegmentedUnit::health to LuaSegmentedUnit::max_health. [...] | ||
speed | :: RW double | The current instantaneous speed in tiles per map tick. [...] |
The current instantaneous speed in tiles per map tick. [...] | ||
target_speed | :: R double | The speed in tiles per tick that the unit is currently attempting to reach, as determined by its AI. [...] |
The speed in tiles per tick that the unit is currently attempting to reach, as determined by its AI. [...] | ||
acceleration | :: R double | The rate at which LuaSegmentedUnit::speed is changing over time, in tiles per tick per tick. [...] |
The rate at which LuaSegmentedUnit::speed is changing over time, in tiles per tick per tick. [...] | ||
max_body_nodes | :: R uint | The maximum length of LuaSegmentedUnit::get_body_nodes. |
The maximum length of LuaSegmentedUnit::get_body_nodes. | ||
activity_mode | :: RW defines.segmented_unit_activity_mode | The current activity mode of the unit. [...] |
The current activity mode of the unit. [...] | ||
minimum_activity_mode | :: RW defines.segmented_unit_activity_mode | The lowest-level activity mode that the unit is allowed to be in. [...] |
The lowest-level activity mode that the unit is allowed to be in. [...] | ||
valid | :: R boolean | Is this object valid? [...] |
Is this object valid? [...] | ||
object_name | :: R string | The class name of this object. [...] |
The class name of this object. [...] |
raise_destroy | :: boolean? | If |
If |
script_raised_destroy_segmented_unit? instantly | Raised if the |
force | :: ForceID? | The force to attribute the kill to. Defaults to the |
The force to attribute the kill to. Defaults to the | ||
cause | :: LuaEntity? | The cause to attribute the kill to. |
The cause to attribute the kill to. | ||
damage_type | :: DamageTypeID? | The final damage type that caused the unit to die. |
The final damage type that caused the unit to die. |
on_segmented_unit_died instantly | |
on_post_segmented_unit_died instantly |
damage | :: float | The amount of damage to be done. |
The amount of damage to be done. | ||
force | :: ForceID | The force that is doing the damage. |
The force that is doing the damage. | ||
type | :: DamageTypeID? | The type of damage being done. Defaults to |
The type of damage being done. Defaults to | ||
source | :: LuaEntity? | The entity that is directly dealing the damage. This is the projectile, flame, sticker, grenade, laster beam, etc. Must be on the same surface as the entity being damaged. |
The entity that is directly dealing the damage. This is the projectile, flame, sticker, grenade, laster beam, etc. Must be on the same surface as the entity being damaged. | ||
cause | :: LuaEntity? | The entity that originally triggered the events that led to this damage being dealt. This can be the player character, turret, unit, etc. that pulled the trigger. Does not need to be on the same surface as the segmented unit being damaged. |
The entity that originally triggered the events that led to this damage being dealt. This can be the player character, turret, unit, etc. that pulled the trigger. Does not need to be on the same surface as the segmented unit being damaged. |
→ float | The total damage actually applied after resistances. |
on_segmented_unit_damaged instantly |
distance | :: double | The distance in tiles to move the segmented unit forward. |
The distance in tiles to move the segmented unit forward. |
position | :: MapPosition | The destination position of the head segment. The rest of the body nodes will be copied relative to this. |
The destination position of the head segment. The rest of the body nodes will be copied relative to this. | ||
surface | :: LuaSurface? | The destination surface. If different from this unit's surface, then the clone will not copy the original unit's territory. |
The destination surface. If different from this unit's surface, then the clone will not copy the original unit's territory. | ||
force | :: ForceID? | The new unit's force. |
The new unit's force. | ||
territory | :: LuaTerritory? | The territory that the clone should guard. Must be on the same surface as the destination surface. |
The territory that the clone should guard. Must be on the same surface as the destination surface. |
→ LuaSegmentedUnit? | The cloned unit or |
on_segmented_unit_created? instantly | Raised if a clone of the segmented unit was successfully created. cause will be set to script_cloned. |
nodes | :: array[MapPosition] | The new positions that make up the segmented unit's body nodes. Must not be empty. |
The new positions that make up the segmented unit's body nodes. Must not be empty. |
state | :: SegmentedUnitAIState | The new AI state. A copy of this table used, so you can read or write to this table after calling this function without being affected by or affecting the unit's AI. |
The new AI state. A copy of this table used, so you can read or write to this table after calling this function without being affected by or affecting the unit's AI. |