Health

This component adds life and death to your prefab. Required for combat [ADD LINK].

Component Health Fields

TypeNameDescription
numberminhealthsetting this above 0 prevents your creature from dying.
numbermaxhealththe health your creature can have at most
numbercurrenthealththe current amount of health points
booleaninvinciblewhether the creature can change it's health
booleanvulnerabletoheatdamagewhether your creature can burn alive
number (percent)fire_damage_scalehow deadly fire is
booleannofadeoutwhether your creature washes out after dying or stays in the world.
numberabsorbnatural armor
booleancanmurderwhether your creature can be killed from the inventory
string (path)murdersoundsoundpath for inventory-murder
booleancanhealwhether your creature can be healed
functionredirectoverride the health calculations using this! Args: inst, amount, overtime, cause
functionondeltafires at the end of the health calculations

Component Health Methods

NameParameterReturnsDescription
SetMaxHealthamountnilinitialize health
SetValval, causenilsets health to "val", if it's not above maxhealth or below 0
DoDeltaamount, overtime, cause, ignore_invinciblenilheal or hurt
KillnilnilPuts it out of its misery.

Component Health Events

NameDataFires in/when...
invincibletoggleinvincible (current one)Fires when invincibility is set, regardless of former state
startfiredamagenilFires when the instance comes in contact with fire
firedamagenilFires when the instance takes damage from nearby fire
stopfiredamagenilFires when the instance escapes a fire again
minhealthcauseFires when a new minimum health is set using SetVal
deathcauseFires when the instance reaches 0 percent health
healthdeltaoldpercent, newpercent, overtime, causeFires in DoDelta, after all calculations but before the ondelta function

Example

Notes

  • Unlike in Hunger or Sanity, the current value is not called current but currenthealth.
  • Health is used by walls, since it’s a requirement for Combat, but they don’t behave a lot like creatures. The “wall” tag is thus commonly checked for.