Prototype/Unit: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
No edit summary
(better description what this prototype type is)
 
(13 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==Basics==
{{Prototype parent|Prototype/EntityWithOwner}}
Entity that attacks player based on pollution value. Extends the [[Prototype/EntityWithHealth]]
Entity that moves around and attacks players, for example [[enemies#Creatures|biters and spitters]].
 
{{Prototype TOC|unit}}


== Usage in base==
== Usage in base==
*[[Enemies|small, medium, and big biters]]
*[[Enemies|biters/spitters]]
== Properties ==
 
=== run_animation ===
== Mandatory properties ==
'''Type''': [[Types/RotatedAnimation]]
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}}


=== attack_parameters ===
{{Prototype property|render_layer|[[Types/RenderLayer|RenderLayer]]|"object"|optional=true}}
'''Type''': [[Types/AttackParameters]]


=== movement_speed ===
{{Prototype property|light|[[Types/LightDefinition|LightDefinition]]|optional=true}}
'''Type''': [[Types/double]]


=== distance_per_frame ===
{{Prototype property|walking_sound|[[Types/Sound|Sound]]|optional=true}}
'''Type''': [[Types/double]]


=== dying_sound ===
{{Prototype property|alternative_attacking_frame_sequence|[[Types/table|table]]|optional=true}}
'''Type''': [[Types/FileName]]
Table with the following mandatory properties:
The sound file to play when entity dies


=== pollution_to_join_attack ===
* warmup_frame_sequence - Array of [[Types/uint16|uint16]] - Indices of frames from the attack parameter animation.
'''Type''': [[Types/double]]
* warmup2_frame_sequence - Array of [[Types/uint16|uint16]] - Indices of frames from the attack parameter animation.
Pollution level required before entity will leave it's spawner and attack the source of the pollution.
* 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]]


=== distraction_cooldown ===
{{Prototype property|running_sound_animation_positions|[[Types/table|table]] (array) of [[Types/float|float]]|optional=true}}
'''Type''': [[Types/Tick]]
Ignored if <code>walking_sounds</code> is not defined.


== Example ==
== Mandatory values ==
    {
Units have additional requirements for the properties inherited from [[Prototype/EntityWithOwner]]:
    type = "unit",
* [[Prototype/EntityWithOwner#is_military_target]] must be true.
    name = "small-biter",
* [[Prototype/EntityWithOwner#allow_run_time_change_of_is_military_target]] must be false.
    icon = "__base__/graphics/icons/creeper.png",
    flags = {"placeable-player", "placeable-enemy", "placeable-off-grid", "breaths-air"},
    max_health = 15,
    healing_per_tick = 0.01,
    collision_box = {{-0.2, -0.2}, {0.2, 0.2}},
    selection_box = {{-0.4, -0.7}, {0.7, 0.4}},
    attack_parameters =
    {
      range = 0.5,
      cooldown = 35,
      ammo_category = "melee",
      ammo_type = make_unit_melee_ammo_type(6),
      animation =
      {
        filename = "__base__/graphics/entity/small-biter/small-biter-attack.png",
        frame_width = 139,
        frame_height = 93,
        frame_count = 11,
        direction_count = 16,
        axially_symmetrical = false,
        shift = {0.84375, -0.3125}
      }
    },
    movement_speed = 0.2,
    distance_per_frame = 0.1,
    pollution_to_join_attack = 200,
    distraction_cooldown = 300,
    corpse = "small-biter-corpse",
    dying_sound =
    {
      {
        filename = "__base__/sound/creeper-death-1.wav",
        volume = 0.7
      },
      {
        filename = "__base__/sound/creeper-death-2.wav",
        volume = 0.7
      },
      {
        filename = "__base__/sound/creeper-death-3.wav",
        volume = 0.7
      },
      {
        filename = "__base__/sound/creeper-death-4.wav",
        volume = 0.7
      }
    },
    run_animation =
    {
      filename = "__base__/graphics/entity/small-biter/small-biter-run.png",
      still_frame = 4,
      frame_width = 86,
      frame_height = 59,
      frame_count = 16,
      direction_count = 16,
      shift = {0.359375, -0.15625},
      axially_symmetrical = false
    }
  }

Latest revision as of 10:12, 25 February 2022

Prototype definitions » PrototypeBase » Prototype/Entity » Prototype/EntityWithHealth » Prototype/EntityWithOwner » Prototype/Unit


Entity that moves around and attacks players, for example biters and spitters.


Prototype/Unit — unit
attack_parameters::AttackParameters
distance_per_frame::float
distraction_cooldown::uint32
movement_speed::float
pollution_to_join_attack::float
run_animation::RotatedAnimation
vision_distance::double
affected_by_tiles::bool (optional)
ai_settings::UnitAISettings (optional)
alternative_attacking_frame_sequence::table (optional)
can_open_gates::bool (optional)
dying_sound::Sound (optional)
has_belt_immunity::bool (optional)
light::LightDefinition (optional)
max_pursue_distance::double (optional)
min_pursue_time::uint32 (optional)
move_while_shooting::bool (optional)
radar_range::uint32 (optional)
render_layer::RenderLayer (optional)
rotation_speed::float (optional)
running_sound_animation_positions::table (array) of float (optional)
spawning_time_modifier::double (optional)
walking_sound::Sound (optional)
Inherited from Prototype/EntityWithOwner
allow_run_time_change_of_is_military_target::bool (optional)
is_military_target::bool (optional)
Inherited from Prototype/EntityWithHealth
alert_when_damaged::bool (optional)
attack_reaction::AttackReaction (optional)
corpse::string or table of strings (optional)
create_ghost_on_death::bool (optional)
damaged_trigger_effect::TriggerEffect (optional)
dying_explosion::ExplosionDefinition or table of ExplosionDefinition (optional)
dying_trigger_effect::TriggerEffect (optional)
healing_per_tick::float (optional)
hide_resistances::bool (optional)
integration_patch::Sprite4Way (optional)
integration_patch_render_layer::RenderLayer (optional)
loot::Loot (optional)
max_health::float (optional)
random_corpse_variation::bool (optional)
repair_sound::Sound (optional)
repair_speed_modifier::float (optional)
resistances::Resistances (optional)
Inherited from Prototype/Entity
icons, icon, icon_size (IconSpecification)::IconSpecification
additional_pastable_entities::table of string (optional)
alert_icon_scale::float (optional)
alert_icon_shift::vector (optional)
allow_copy_paste::bool (optional)
autoplace::AutoplaceSpecification (optional)
build_base_evolution_requirement::double (optional)
build_grid_size::uint8 (optional)
build_sound::Sound (optional)
close_sound::Sound (optional)
collision_box::BoundingBox (optional)
collision_mask::CollisionMask (optional)
created_effect::Trigger (optional)
created_smoke::CreateTrivialSmokeEffectItem (optional)
drawing_box::BoundingBox (optional)
emissions_per_second::double (optional)
enemy_map_color::Color (optional)
fast_replaceable_group::string (optional)
flags::EntityPrototypeFlags (optional)
friendly_map_color::Color (optional)
hit_visualization_box::BoundingBox (optional)
map_color::Color (optional)
map_generator_bounding_box::BoundingBox (optional)
minable::MinableProperties (optional)
mined_sound::Sound (optional)
mining_sound::Sound (optional)
next_upgrade::string (optional)
open_sound::Sound (optional)
placeable_by::ItemToPlace or table of ItemToPlace (optional)
protected_from_tile_building::bool (optional)
radius_visualisation_specification::RadiusVisualisationSpecification (optional)
remains_when_mined::string or table of string (optional)
remove_decoratives::string (optional)
rotated_sound::Sound (optional)
selectable_in_game::bool (optional)
selection_box::BoundingBox (optional)
selection_priority::uint8 (optional)
shooting_cursor_size::double (optional)
sticker_box::BoundingBox (optional)
subgroup::string (optional)
tile_height::uint32 (optional)
tile_width::uint32 (optional)
trigger_target_mask::TriggerTargetMask (optional)
vehicle_impact_sound::Sound (optional)
water_reflection::WaterReflectionDefinition (optional)
working_sound::WorkingSound (optional)
Inherited from PrototypeBase
name::string
type::string
localised_description::LocalisedString (optional)
localised_name::LocalisedString (optional)
order::Order (optional)

Usage in base

Mandatory properties

This prototype inherits all the properties from Prototype/EntityWithOwner.

run_animation

Type: RotatedAnimation

attack_parameters

Type: AttackParameters
Requires animation in attack_parameters. Requires ammo_type in attack_parameters.

movement_speed

Type: float
Movement speed of the unit in the world, in tiles per tick. Must be equal to or greater than 0.

distance_per_frame

Type: float
How fast the run_animation frames are advanced. The animations are advanced animation_speed frames per distance_per_frame that the unit moves.

frames_advanced = (distance_moved ÷ distance_per_frame) * animation_speed

pollution_to_join_attack

Type: 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.

distraction_cooldown

Type: uint32

vision_distance

Type: 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

rotation_speed

Type: float
Default: 0.025

dying_sound

Type: Sound
The sound file to play when entity dies.

min_pursue_time

Type: uint32
Default: 10 * 60

has_belt_immunity

Type: bool
Default: false
If the unit is immune to movement by belts.

spawning_time_modifier

Type: double
Default: 1

max_pursue_distance

Type: double
Default: 50

radar_range

Type: uint32
Default: 0

ai_settings

Type: UnitAISettings

move_while_shooting

Type: bool
Default: false

can_open_gates

Type: bool
Default: false

affected_by_tiles

Type: bool
Default: false

render_layer

Type: RenderLayer
Default: "object"

light

Type: LightDefinition

walking_sound

Type: Sound

alternative_attacking_frame_sequence

Type: table
Table with the following mandatory properties:

  • warmup_frame_sequence - Array of uint16 - Indices of frames from the attack parameter animation.
  • warmup2_frame_sequence - Array of uint16 - Indices of frames from the attack parameter animation.
  • attacking_frame_sequence - Array of uint16 - Indices of frames from the attack parameter animation.
  • cooldown_frame_sequence - Array of uint16 - Indices of frames from the attack parameter animation.
  • prepared_frame_sequence - Array of uint16 - Indices of frames from the attack parameter animation.
  • back_to_walk_frame_sequence - Array of uint16 - Indices of frames from the attack parameter animation.
  • warmup_animation_speed - float
  • attacking_animation_speed - float
  • cooldown_animation_speed - float
  • prepared_animation_speed - float
  • back_to_walk_animation_speed - float

running_sound_animation_positions

Type: table (array) of float
Ignored if walking_sounds is not defined.

Mandatory values

Units have additional requirements for the properties inherited from Prototype/EntityWithOwner: