Prototype/EntityWithHealth: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
m (typo)
(1.1.51: Prototype/EntityWithOwner added)
 
(20 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==Basics==
{{Prototype parent|Prototype/Entity}}
The common properties of all entities with health in the game.
Abstract base of all entities with health in the game.
Extends the [[Prototype/Entity]]
 
{{Prototype TOC|''abstract''}}


== Extensions ==
== Extensions ==
<div class="factorio-list">
<div class="factorio-list">
* [[Prototype/Accumulator]] '''accumulator'''
* [[Prototype/EntityWithOwner]] <abstract>
* [[Prototype/ArtilleryTurret]] '''artillery-turret'''
** [[Prototype/Accumulator]] '''accumulator'''
* [[Prototype/Beacon]] '''beacon'''
** [[Prototype/ArtilleryTurret]] '''artillery-turret'''
* [[Prototype/Boiler]] '''boiler'''
** [[Prototype/Beacon]] '''beacon'''
* [[Prototype/Character]] '''player'''
** [[Prototype/Boiler]] '''boiler'''
* [[Prototype/Combinator]] <abstract>
** [[Prototype/BurnerGenerator]] '''burner-generator'''
** [[Prototype/ArithmeticCombinator]] '''arithmetic-combinator'''
** [[Prototype/Character]] '''character'''
** [[Prototype/DeciderCombinator]] '''decider-combinator'''
** [[Prototype/Combinator]] <abstract>
* [[Prototype/ConstantCombinator]] '''constant-combinator'''
*** [[Prototype/ArithmeticCombinator]] '''arithmetic-combinator'''
* [[Prototype/Container]] '''container'''
*** [[Prototype/DeciderCombinator]] '''decider-combinator'''
** [[Prototype/LegacySmartContainer]] '''smart-container''' (unused in the base-game, but exists for migration)
** [[Prototype/ConstantCombinator]] '''constant-combinator'''
** [[Prototype/LogisticContainer]] '''logistic-container'''
** [[Prototype/Container]] '''container'''
*** [[Prototype/InfinityContainer]] '''infinity-container'''
*** [[Prototype/LogisticContainer]] '''logistic-container'''
* [[Prototype/CraftingMachine]] <abstract>
**** [[Prototype/InfinityContainer]] '''infinity-container'''
** [[Prototype/AssemblingMachine]] '''assembling-machine'''
** [[Prototype/CraftingMachine]] <abstract>
*** [[Prototype/RocketSilo]] '''rocket-silo'''
*** [[Prototype/AssemblingMachine]] '''assembling-machine'''
** [[Prototype/Furnace]] '''furnace'''
**** [[Prototype/RocketSilo]] '''rocket-silo'''
* [[Prototype/ElectricEnergyInterface]] '''electric-energy-interface'''
*** [[Prototype/Furnace]] '''furnace'''
* [[Prototype/ElectricPole]] '''electric-pole'''
** [[Prototype/ElectricEnergyInterface]] '''electric-energy-interface'''
* [[Prototype/EnemySpawner]] '''unit-spawner'''
** [[Prototype/ElectricPole]] '''electric-pole'''
** [[Prototype/EnemySpawner]] '''unit-spawner'''
** [[Prototype/FlyingRobot]] <abstract>
*** [[Prototype/CombatRobot]] '''combat-robot'''
*** [[Prototype/RobotWithLogisticInterface]] <abstract>
**** [[Prototype/ConstructionRobot]] '''construction-robot'''
**** [[Prototype/LogisticRobot]] '''logistic-robot'''
** [[Prototype/Gate]] '''gate'''
** [[Prototype/Generator]] '''generator'''
** [[Prototype/HeatInterface]] '''heat-interface'''
** [[Prototype/HeatPipe]] '''heat-pipe'''
** [[Prototype/Inserter]] '''inserter'''
** [[Prototype/Lab]] '''lab'''
** [[Prototype/Lamp]] '''lamp'''
** [[Prototype/LandMine]] '''land-mine'''
** [[Prototype/LinkedContainer]] '''linked-container'''
** [[Prototype/Market]] '''market'''
** [[Prototype/MiningDrill]] '''mining-drill'''
** [[Prototype/OffshorePump]] '''offshore-pump'''
** [[Prototype/Pipe]] '''pipe'''
*** [[Prototype/InfinityPipe]] '''infinity-pipe'''
** [[Prototype/PipeToGround]] '''pipe-to-ground'''
** [[Prototype/PlayerPort]] '''player-port'''
** [[Prototype/PowerSwitch]] '''power-switch'''
** [[Prototype/ProgrammableSpeaker]] '''programmable-speaker'''
** [[Prototype/Pump]] '''pump'''
** [[Prototype/Radar]] '''radar'''
** [[Prototype/Rail]] <abstract>
*** [[Prototype/CurvedRail]] '''curved-rail'''
*** [[Prototype/StraightRail]] '''straight-rail'''
** [[Prototype/RailSignalBase]] <abstract>
*** [[Prototype/RailChainSignal]] '''rail-chain-signal'''
*** [[Prototype/RailSignal]] '''rail-signal'''
** [[Prototype/Reactor]] '''reactor'''
** [[Prototype/Roboport]] '''roboport'''
** [[Prototype/SimpleEntityWithOwner]] '''simple-entity-with-owner'''
*** [[Prototype/SimpleEntityWithForce]] '''simple-entity-with-force'''
** [[Prototype/SolarPanel]] '''solar-panel'''
** [[Prototype/StorageTank]] '''storage-tank'''
** [[Prototype/TrainStop]] '''train-stop'''
** [[Prototype/TransportBeltConnectable]] <abstract>
*** [[Prototype/LinkedBelt]] '''linked-belt'''
*** [[Prototype/Loader1x1]] '''loader-1x1'''
*** [[Prototype/Loader1x2]] '''loader'''
*** [[Prototype/Splitter]] '''splitter'''
*** [[Prototype/TransportBelt]] '''transport-belt'''
*** [[Prototype/UndergroundBelt]] '''underground-belt'''
** [[Prototype/Turret]] '''turret'''
*** [[Prototype/AmmoTurret]] '''ammo-turret'''
*** [[Prototype/ElectricTurret]] '''electric-turret'''
*** [[Prototype/FluidTurret]] '''fluid-turret'''
** [[Prototype/Unit]] '''unit'''
** [[Prototype/Vehicle]] <abstract>
*** [[Prototype/Car]] '''car'''
*** [[Prototype/RollingStock]] <abstract>
**** [[Prototype/ArtilleryWagon]] '''artillery-wagon'''
**** [[Prototype/CargoWagon]] '''cargo-wagon'''
**** [[Prototype/FluidWagon]] '''fluid-wagon'''
**** [[Prototype/Locomotive]] '''locomotive'''
*** [[Prototype/SpiderVehicle]] '''spider-vehicle'''
** [[Prototype/Wall]] '''wall'''
* [[Prototype/Fish]] '''fish'''
* [[Prototype/Fish]] '''fish'''
* [[Prototype/FlyingRobot]] <abstract>
** [[Prototype/CombatRobot]] '''combat-robot'''
** [[Prototype/RobotWithLogisticInterface]] <abstract>
*** [[Prototype/ConstructionRobot]] '''construction-robot'''
*** [[Prototype/LogisticRobot]] '''logistic-robot'''
* [[Prototype/Gate]] '''gate'''
* [[Prototype/Generator]] '''generator'''
* [[Prototype/HeatPipe]] '''heat-pipe'''
* [[Prototype/Inserter]] '''inserter'''
* [[Prototype/Lab]] '''lab'''
* [[Prototype/Lamp]] '''lamp'''
* [[Prototype/LandMine]] '''land-mine'''
* [[Prototype/LegacyRocketDefense]] '''rocket-defense''' (unused in the base-game, but exists for migration)
* [[Prototype/Market]] '''market'''
* [[Prototype/MiningDrill]] '''mining-drill'''
* [[Prototype/OffshorePump]] '''offshore-pump'''
* [[Prototype/Pipe]] '''pipe'''
* [[Prototype/PipeToGround]] '''pipe-to-ground'''
* [[Prototype/PlayerPort]] '''player-port'''
* [[Prototype/PowerSwitch]] '''power-switch'''
* [[Prototype/ProgrammableSpeaker]] '''programmable-speaker'''
* [[Prototype/Pump]] '''pump'''
* [[Prototype/Radar]] '''radar'''
* [[Prototype/Rail]] <abstract>
** [[Prototype/CurvedRail]] '''curved-rail'''
** [[Prototype/StraightRail]] '''straight-rail'''
* [[Prototype/RailSignalBase]] <abstract>
** [[Prototype/RailChainSignal]] '''rail-chain-signal'''
** [[Prototype/RailSignal]] '''rail-signal'''
* [[Prototype/Reactor]] '''reactor'''
* [[Prototype/Roboport]] '''roboport'''
* [[Prototype/SimpleEntity]] '''simple-entity'''
* [[Prototype/SimpleEntity]] '''simple-entity'''
* [[Prototype/SimpleEntityWithOwner]] '''simple-entity-with-owner'''
* [[Prototype/SpiderLeg]] '''spider-leg'''
** [[Prototype/SimpleEntityWtihForce]] '''simple-entity-with-force'''
* [[Prototype/SolarPanel]] '''solar-panel'''
* [[Prototype/StorageTank]] '''storage-tank'''
* [[Prototype/TrainStop]] '''train-stop'''
* [[Prototype/TransportBeltConnectable]] <abstract>
** [[Prototype/Loader]] '''loader'''
** [[Prototype/Splitter]] '''splitter'''
** [[Prototype/TransportBelt]] '''transport-belt'''
** [[Prototype/UndergroundBelt]] '''underground-belt'''
* [[Prototype/Tree]] '''tree'''
* [[Prototype/Tree]] '''tree'''
* [[Prototype/Turret]] '''turret'''
** [[Prototype/AmmoTurret]] '''ammo-turret'''
** [[Prototype/ElectricTurret]] '''electric-turret'''
** [[Prototype/FluidTurret]] '''fluid-turret'''
* [[Prototype/Unit]] '''unit'''
* [[Prototype/Vehicle]] <abstract>
** [[Prototype/Car]] '''car'''
** [[Prototype/RollingStock]] <abstract>
*** [[Prototype/ArtilleryWagon]] '''artillery-wagon'''
*** [[Prototype/CargoWagon]] '''cargo-wagon'''
*** [[Prototype/FluidWagon]] '''fluid-wagon'''
*** [[Prototype/Locomotive]] '''locomotive'''
* [[Prototype/Wall]] '''wall'''
</div>
</div>


== Properties ==
== Optional properties ==
=== max_health ===
'''Type''': [[Types/float]]


'''Default''': 10
{{Prototype property|max_health|[[Types/float|float]]|10|optional=true}}
 
The unit health can never go over the maximum. Default health of units on creation is set to max. Must be greater than 0.
The unit health can never go over the maxmum. Default health of units on creation is set to max.
     max_health = 50
     max_health = 50


=== healing_per_tick ===
{{Prototype property|healing_per_tick|[[Types/float|float]]|0.001666 for [[Prototype/Tree]], 0 for the rest of entities|optional=true}}
'''Type''': [[Types/float]]
The amount of health automatically regenerated per tick. The entity must be active for this to work.<br>
 
Trees will regenerate every 60 ticks with <code>healing_per_tick × 60</code> and they don't need to be active.
'''Default''': 0
 
The amount of health cured by tick naturally.
Works only on active entities. (Todo explain)
   healing_per_tick = 0.01
   healing_per_tick = 0.01


=== repair_speed_modifier ===
{{Prototype property|repair_speed_modifier|[[Types/float|float]]|1|optional=true}}
'''Type''': [[Types/float]]
 
'''Default''': 1
 
=== flammability ===
'''Type''': [[Types/float]]


'''Default''': 0
{{Prototype property|dying_explosion|[[Types/ExplosionDefinition|ExplosionDefinition]] or [[Types/table|table]] of [[Types/ExplosionDefinition|ExplosionDefinition]]|optional=true}}
Either one [[Types/ExplosionDefinition|ExplosionDefinition]] or an array of them. The entities that are spawned in place of this one when it dies.


=== dying_explosion ===
{{Prototype property|dying_trigger_effect|[[Types/TriggerEffect|TriggerEffect]]|optional=true}}
'''Type''': [[Types/string]]


The entity that is spawned in place of this one when it dies.
{{Prototype property|damaged_trigger_effect|[[Types/TriggerEffect|TriggerEffect]]|optional=true}}


=== loot ===
{{Prototype property|loot|[[Types/Loot|Loot]]|optional=true}}
'''Type''': [[Types/Loot]]
The loot is dropped on the ground when the entity is killed.
The loot is generated when the entity is killed.
<syntaxhighlight lang="lua">loot =
<syntaxhighlight lang="lua">loot =
{
{
Line 129: Line 123:
   }
   }
}</syntaxhighlight>
}</syntaxhighlight>
=== resistances ===
'''Type''': [[Types/Resistances]]


{{Prototype property|resistances|[[Types/Resistances|Resistances]]|optional=true}}
'''See''': [[Damage]]
'''See''': [[Damage]]
<syntaxhighlight lang="lua">resistances =  
<syntaxhighlight lang="lua">resistances =  
Line 145: Line 138:
}</syntaxhighlight>
}</syntaxhighlight>


=== attack_reaction ===
{{Prototype property|attack_reaction|[[Types/AttackReaction|AttackReaction]]|Empty|optional=true}}
'''Type''': [[Types/AttackReaction]]


'''Default''': Empty
{{Prototype property|repair_sound|[[Types/Sound|Sound]]|Utility sound (defaultManualRepair)|optional=true}}


=== repair_sound ===
{{Prototype property|alert_when_damaged|[[Types/bool|bool]]|true|optional=true}}
'''Type''': [[Types/Sound]]


'''Default''': Utility sound (defaultManualRepair)
{{Prototype property|hide_resistances|[[Types/bool|bool]]|true|optional=true}}
Whether the resistances of this entity should be hidden in the entity tooltip.


=== alert_when_damaged ===
{{Prototype property|create_ghost_on_death|[[Types/bool|bool]]|true|optional=true}}
'''Type''': [[Types/bool]]


'''Default''': true
{{Prototype property|random_corpse_variation|[[Types/bool|bool]]|false|optional=true}}


=== hide_resistances ===
{{Prototype property|integration_patch_render_layer|[[Types/RenderLayer|RenderLayer]]|"lower-object"|optional=true}}
'''Type''': [[Types/bool]]
 
'''Default''': true
 
=== corpse ===
'''Type''': [[Types/string]] or [[Types/table]] of [[Types/string]]s
 
'''Default''': Empty


{{Prototype property|corpse|[[Types/string|string]] or [[Types/table|table]] of [[Types/string|string]]s|Empty|optional=true}}
Specifies the name(s) of the [[Prototype/Corpse]] entity to be used when this entity dies.
Specifies the name(s) of the [[Prototype/Corpse]] entity to be used when this entity dies.


=== integration_patch ===
{{Prototype property|integration_patch|[[Types/Sprite4Way|Sprite4Way]]|optional=true}}
'''Type''': [[Types/Sprite4Way]]
 
Sprite drawn on ground under the entity to make it feel more integrated into the ground.
Sprite drawn on ground under the entity to make it feel more integrated into the ground.



Latest revision as of 19:25, 21 January 2022

Prototype definitions » PrototypeBase » Prototype/Entity » Prototype/EntityWithHealth


Abstract base of all entities with health in the game.


Prototype/EntityWithHealth — abstract
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)

Extensions

Optional properties

max_health

Type: float
Default: 10
The unit health can never go over the maximum. Default health of units on creation is set to max. Must be greater than 0.

   max_health = 50

healing_per_tick

Type: float
Default: 0.001666 for Prototype/Tree, 0 for the rest of entities
The amount of health automatically regenerated per tick. The entity must be active for this to work.
Trees will regenerate every 60 ticks with healing_per_tick × 60 and they don't need to be active.

  healing_per_tick = 0.01

repair_speed_modifier

Type: float
Default: 1

dying_explosion

Type: ExplosionDefinition or table of ExplosionDefinition
Either one ExplosionDefinition or an array of them. The entities that are spawned in place of this one when it dies.

dying_trigger_effect

Type: TriggerEffect

damaged_trigger_effect

Type: TriggerEffect

loot

Type: Loot
The loot is dropped on the ground when the entity is killed.

loot =
{
  {
    count_max = 10,
    count_min = 2,
    item = "stone",
    probability = 1
  }
}

resistances

Type: Resistances
See: Damage

resistances = 
{
  {
    type = "fire",
    percent = 80
  },
  {
    type = "explosion",
    percent = 30
  }
}

attack_reaction

Type: AttackReaction
Default: Empty

repair_sound

Type: Sound
Default: Utility sound (defaultManualRepair)

alert_when_damaged

Type: bool
Default: true

hide_resistances

Type: bool
Default: true
Whether the resistances of this entity should be hidden in the entity tooltip.

create_ghost_on_death

Type: bool
Default: true

random_corpse_variation

Type: bool
Default: false

integration_patch_render_layer

Type: RenderLayer
Default: "lower-object"

corpse

Type: string or table of strings
Default: Empty
Specifies the name(s) of the Prototype/Corpse entity to be used when this entity dies.

integration_patch

Type: Sprite4Way
Sprite drawn on ground under the entity to make it feel more integrated into the ground.

Example

{
    type = "container",
    name = "wooden-chest",
    icon = "__base__/graphics/icons/wooden-chest.png",
    flags = {"placeable-neutral", "player-creation"},
    minable = {mining_time = 1, result = "wooden-chest"},
    max_health = 100,
    corpse = "small-remnants",
    collision_box = {{-0.35, -0.35}, {0.35, 0.35}},
    fast_replaceable_group = "container",
    selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
    inventory_size = 16,
    open_sound = { filename = "__base__/sound/wooden-chest-open.ogg" },
    close_sound = { filename = "__base__/sound/wooden-chest-close.ogg" },
    vehicle_impact_sound =  { filename = "__base__/sound/car-wood-impact.ogg", volume = 1.0 },
    picture =
    {
      filename = "__base__/graphics/entity/wooden-chest/wooden-chest.png",
      priority = "extra-high",
      width = 46,
      height = 33,
      shift = {0.25, 0.015625}
    },
    circuit_wire_connection_point =
    {
      shadow =
      {
        red = {0.734375, 0.453125},
        green = {0.609375, 0.515625},
      },
      wire =
      {
        red = {0.40625, 0.21875},
        green = {0.40625, 0.375},
      }
    },
    circuit_connector_sprites = get_circuit_connector_sprites({0.1875, 0.15625}, nil, 18),
    circuit_wire_max_distance = 9
  }