Prototype/Unit: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
m (Protected "Prototype/Unit": Migrated prototype doc to separate website ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
(Removed old prototype docs)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
'''The prototype docs have moved to a new website with an improved format.''' This documentation page can now be found here: [https://lua-api.factorio.com/latest/prototypes/UnitPrototype.html https://lua-api.factorio.com/latest/prototypes/UnitPrototype.html]
<div class="stub"><p>'''The prototype docs have moved to a new website with an improved format.''' This documentation page can now be found here: [https://lua-api.factorio.com/latest/prototypes/UnitPrototype.html https://lua-api.factorio.com/latest/prototypes/UnitPrototype.html]


This wiki page is no longer updated and '''will be removed at some point in the future''', so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback [https://forums.factorio.com/viewforum.php?f=233 on the forums].
</p><p>This wiki page is no longer updated and '''will be removed at some point in the future''', so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback [https://forums.factorio.com/viewforum.php?f=233 on the forums].</p></div>
 
 
 
{{Prototype parent|Prototype/EntityWithOwner}}
Entity that moves around and attacks players, for example [[enemies#Creatures|biters and spitters]].
 
{{Prototype TOC|unit}}
 
== Usage in base==
*[[Enemies|biters/spitters]]
 
== Mandatory properties ==
This prototype inherits all the properties from [[Prototype/EntityWithOwner]].
 
{{Prototype property|run_animation|[[Types/RotatedAnimation|RotatedAnimation]]}}
 
{{Prototype property|attack_parameters|[[Types/AttackParameters|AttackParameters]]}}
Requires animation in attack_parameters. Requires ammo_type in attack_parameters.
 
{{Prototype property|movement_speed|[[Types/float|float]]}}
Movement speed of the unit in the world, in tiles per tick.
Must be equal to or greater than 0.
 
{{Prototype property|distance_per_frame|[[Types/float|float]]}}
How fast the <code>run_animation</code> frames are advanced. The animations are advanced animation_speed frames per <code>distance_per_frame</code> that the unit moves.
 
frames_advanced = (distance_moved ÷ distance_per_frame) * animation_speed
 
{{Prototype property|pollution_to_join_attack|[[Types/float|float]]}}
The amount of pollution that has to be absorbed by the unit's spawner before the unit will leave the spawner and attack the source of the pollution.
 
{{Prototype property|distraction_cooldown|[[Types/uint32|uint32]]}}
 
{{Prototype property|vision_distance|[[Types/double|double]]}}
Max is 100.
 
Note: Setting to 50 or above can lead to undocumented behavior of individual units creating groups on their own when attacking or being attacked.
 
== Optional properties ==
 
{{Prototype property|rotation_speed|[[Types/float|float]]|0.025|optional=true}}
 
{{Prototype property|dying_sound|[[Types/Sound|Sound]]|optional=true}}
The sound file to play when entity dies.
 
{{Prototype property|min_pursue_time|[[Types/uint32|uint32]]|10 * 60|optional=true}}
 
{{Prototype property|has_belt_immunity|[[Types/bool|bool]]|false|optional=true}}
If the unit is immune to movement by belts.
 
{{Prototype property|spawning_time_modifier|[[Types/double|double]]|1|optional=true}}
 
{{Prototype property|max_pursue_distance|[[Types/double|double]]|50|optional=true}}
 
{{Prototype property|radar_range|[[Types/uint32|uint32]]|0|optional=true}}
 
{{Prototype property|ai_settings|[[Types/UnitAISettings|UnitAISettings]]|optional=true}}
 
{{Prototype property|move_while_shooting|[[Types/bool|bool]]|false|optional=true}}
 
{{Prototype property|can_open_gates|[[Types/bool|bool]]|false|optional=true}}
 
{{Prototype property|affected_by_tiles|[[Types/bool|bool]]|false|optional=true}}
 
{{Prototype property|render_layer|[[Types/RenderLayer|RenderLayer]]|"object"|optional=true}}
 
{{Prototype property|light|[[Types/LightDefinition|LightDefinition]]|optional=true}}
 
{{Prototype property|walking_sound|[[Types/Sound|Sound]]|optional=true}}
 
{{Prototype property|alternative_attacking_frame_sequence|[[Types/table|table]]|optional=true}}
Table with the following mandatory properties:
 
* warmup_frame_sequence - Array of [[Types/uint16|uint16]] - Indices of frames from the attack parameter animation.
* warmup2_frame_sequence - Array of [[Types/uint16|uint16]] - Indices of frames from the attack parameter animation.
* attacking_frame_sequence  - Array of [[Types/uint16|uint16]] - Indices of frames from the attack parameter animation.
* cooldown_frame_sequence - Array of [[Types/uint16|uint16]] - Indices of frames from the attack parameter animation.
* prepared_frame_sequence - Array of [[Types/uint16|uint16]] - Indices of frames from the attack parameter animation.
* back_to_walk_frame_sequence - Array of [[Types/uint16|uint16]] - Indices of frames from the attack parameter animation.
* warmup_animation_speed - [[Types/float|float]]
* attacking_animation_speed - [[Types/float|float]]
* cooldown_animation_speed - [[Types/float|float]]
* prepared_animation_speed - [[Types/float|float]]
* back_to_walk_animation_speed - [[Types/float|float]]
 
{{Prototype property|running_sound_animation_positions|[[Types/table|table]] (array) of [[Types/float|float]]|optional=true}}
Ignored if <code>walking_sounds</code> is not defined.
 
== Mandatory values ==
Units have additional requirements for the properties inherited from [[Prototype/EntityWithOwner]]:
* [[Prototype/EntityWithOwner#is_military_target]] must be true.
* [[Prototype/EntityWithOwner#allow_run_time_change_of_is_military_target]] must be false.

Latest revision as of 14:33, 25 October 2024

The prototype docs have moved to a new website with an improved format. This documentation page can now be found here: https://lua-api.factorio.com/latest/prototypes/UnitPrototype.html

This wiki page is no longer updated and will be removed at some point in the future, so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback on the forums.