Skip to content

Hitpoints

class Hitpoints(
max: Int,
current: Int = max,
boost: Int = 0
) : Component()
Example
on_npc_option(Assets.Npc.goblin.id, "Kick") { player ->
val hp = target.findComponent<Hitpoints>() ?: return@on_npc_option
hp.current = (hp.current - 2).coerceAtLeast(0)
target.showHitsplat("damage", 2, source = player as? Actor)
if (hp.isDepleted) player.message("The goblin collapses.")
}
var max: Int
var boost: Int
var current: Int
val isBoosted: Boolean
val isDepleted: Boolean