Skip to content

HealthBar

class HealthBar(
healthBar: HealthBarDefinition,
currentPercentage: Int = 100,
animationSpeed: Int = 0
) : OverheadBar(healthBar = healthBar, currentPercentage = currentPercentage, animationSpeed = animationSpeed)
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.findComponent<HealthBar>()?.currentPercentage = hp.current * 100 / hp.max
}