Prototype/EntityWithHealth: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(→‎Extensions: fixed indentation)
(0.16)
Line 6: Line 6:
<div class="factorio-list">
<div class="factorio-list">
* [[Prototype/Accumulator]] '''accumulator'''
* [[Prototype/Accumulator]] '''accumulator'''
* [[Prototype/ArtilleryTurret]] '''artillery-turret'''
* [[Prototype/Beacon]] '''beacon'''
* [[Prototype/Beacon]] '''beacon'''
* [[Prototype/Boiler]] '''boiler'''
* [[Prototype/Boiler]] '''boiler'''
Line 16: Line 17:
** [[Prototype/LegacySmartContainer]] '''smart-container''' (unused in the base-game, but exists for migration)
** [[Prototype/LegacySmartContainer]] '''smart-container''' (unused in the base-game, but exists for migration)
** [[Prototype/LogisticContainer]] '''logistic-container'''
** [[Prototype/LogisticContainer]] '''logistic-container'''
*** [[Prototype/InfinityContainer]] '''infinity-container'''
* [[Prototype/CraftingMachine]] <abstract>
* [[Prototype/CraftingMachine]] <abstract>
** [[Prototype/AssemblingMachine]] '''assembling-machine'''
** [[Prototype/AssemblingMachine]] '''assembling-machine'''
Line 75: Line 77:
** [[Prototype/Car]] '''car'''
** [[Prototype/Car]] '''car'''
** [[Prototype/RollingStock]] <abstract>
** [[Prototype/RollingStock]] <abstract>
*** [[Prototype/ArtilleryWagon]] '''artillery-wagon'''
*** [[Prototype/CargoWagon]] '''cargo-wagon'''
*** [[Prototype/CargoWagon]] '''cargo-wagon'''
*** [[Prototype/FluidWagon]] '''fluid-wagon'''
*** [[Prototype/FluidWagon]] '''fluid-wagon'''
*** [[Prototype/Locomotive]] '''locomotive'''
*** [[Prototype/Locomotive]] '''locomotive'''
* [[Prototype/Wall]] '''wall'''
* [[Prototype/Wall]] '''wall'''
</div>
</div>


Line 85: Line 87:
=== max_health ===
=== max_health ===
'''Type''': [[Types/float]]
'''Type''': [[Types/float]]
'''Default''': 10


The unit health can never go over the maxmum. Default health of units on creation is set to max.
The unit health can never go over the maxmum. Default health of units on creation is set to max.
Line 91: Line 95:
=== healing_per_tick ===
=== healing_per_tick ===
'''Type''': [[Types/float]]
'''Type''': [[Types/float]]
'''Default''': 0


The amount of health cured by tick naturally.
The amount of health cured by tick naturally.
Works only on active entities. (Todo explain)
Works only on active entities. (Todo explain)
   healing_per_tick = 0.01
   healing_per_tick = 0.01
=== repair_speed_modifier ===
'''Type''': [[Types/float]]
'''Default''': 1
=== flammability ===
'''Type''': [[Types/float]]
'''Default''': 0


=== dying_explosion ===
=== dying_explosion ===
'''Type''': [[Types/EntityName]]
'''Type''': [[Types/string]]


Todo, this should be removed and [[Type/AttackResult]] should be used for dying event.
The entity that is spawned in place of this one when it dies.
This would allow much more variability.


=== loot ===
=== loot ===
'''Type''': [[Types/LootSpecification]]
'''Type''': [[Types/Loot]]
The loot is generated when the entity is killed.
The loot is generated when the entity is killed.
    loot =
<syntaxhighlight lang="lua">loot =
    {
{
      {
  {
        count_max = 10,
    count_max = 10,
        count_min = 2,
    count_min = 2,
        item = "alien-artifact",
    item = "stone",
        probability = 1
    probability = 1
      }
  }
    }
}</syntaxhighlight>
=== resistances ===
=== resistances ===
'''Type''': [[Types/Resistances]]
'''Type''': [[Types/Resistances]]


'''See''': [[Damage]]
'''See''': [[Damage]]
    resistances =  
<syntaxhighlight lang="lua">resistances =  
    {
{
      {
  {
        type = "fire",
    type = "fire",
        percent = 80
    percent = 80
      },
  },
      {
  {
        type = "explosion",
    type = "explosion",
        percent = 30
    percent = 30
      }
  }
    }
}</syntaxhighlight>


=== attack_reaction ===
=== attack_reaction ===
Line 134: Line 149:


'''Default''': Empty
'''Default''': Empty
=== repair_sound ===
'''Type''': [[Types/Sound]]
'''Default''': Utility sound (defaultManualRepair)
=== alert_when_damaged ===
'''Type''': [[Types/bool]]
'''Default''': true
=== hide_resistances ===
'''Type''': [[Types/bool]]
'''Default''': true
=== corpse ===
=== corpse ===
'''Type''': [[Types/EntityName]] (single value or list)
'''Type''': [[Types/string]] or [[Types/table]] of [[Types/string]]s


'''Default''': Empty
'''Default''': Empty


Specifies the name of the [[Prototypes/Corpse]] entity to be used when this entity dies.
Specifies the name(s) of the [[Prototypes/Corpse]] entity to be used when this entity dies.
 
=== integration_patch ===
'''Type''': [[Types/Sprite4Way]]


== Example ==
== Example ==
<syntaxhighlight lang="lua">{
    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 =
     {
     {
       type = "container",
       filename = "__base__/graphics/entity/wooden-chest/wooden-chest.png",
      name = "wooden-chest",
       priority = "extra-high",
      icon = "__base__/graphics/icons/wooden-chest.png",
       width = 46,
       flags = {"placeable-neutral", "player-creation"},
      height = 33,
       minable = {mining_time = 1, result = "wooden-chest"},
       shift = {0.25, 0.015625}
       collision_box = {{-0.4, -0.4}, {0.4, 0.4}},
    },
       selection_box = {{-0.5, -0.5}, {0.5, 0.5}},
    circuit_wire_connection_point =
       max_health = 50,
    {
      corpse = "small-remnants",
       shadow =
      fast_replaceable_group = "container",
      {
      inventory_size = 16,
        red = {0.734375, 0.453125},
       picture =
        green = {0.609375, 0.515625},
       },
       wire =
       {
       {
         filename = "__base__/graphics/entity/wooden-chest/wooden-chest.png",
         red = {0.40625, 0.21875},
        priority = "extra-high",
         green = {0.40625, 0.375},
        width = 46,
         height = 33,
        shift = {0.3, 0}
       }
       }
     }
     },
    circuit_connector_sprites = get_circuit_connector_sprites({0.1875, 0.15625}, nil, 18),
    circuit_wire_max_distance = 9
  }</syntaxhighlight>

Revision as of 16:03, 22 December 2017

Basics

The common properties of all entities with health in the game. Extends the Prototype/Entity

Extensions

Properties

max_health

Type: Types/float

Default: 10

The unit health can never go over the maxmum. Default health of units on creation is set to max.

   max_health = 50

healing_per_tick

Type: Types/float

Default: 0

The amount of health cured by tick naturally. Works only on active entities. (Todo explain)

  healing_per_tick = 0.01

repair_speed_modifier

Type: Types/float

Default: 1

flammability

Type: Types/float

Default: 0

dying_explosion

Type: Types/string

The entity that is spawned in place of this one when it dies.

loot

Type: Types/Loot The loot is generated when the entity is killed.

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

resistances

Type: Types/Resistances

See: Damage

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

attack_reaction

Type: Types/AttackReaction

Default: Empty

repair_sound

Type: Types/Sound

Default: Utility sound (defaultManualRepair)

alert_when_damaged

Type: Types/bool

Default: true

hide_resistances

Type: Types/bool

Default: true

corpse

Type: Types/string or Types/table of Types/strings

Default: Empty

Specifies the name(s) of the Prototypes/Corpse entity to be used when this entity dies.

integration_patch

Type: Types/Sprite4Way

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
  }