kts.Damage

Name

kts.Damage – apply damage to the current actor

Synopsis

kts.Damage(amount, stun_time)

kts.Damage(amount, stun_time, inhibit_squelch)

Description

This function damages the current actor (cxt.actor) for the given amount. The actor will lose amount hitpoints, and (if they are still alive after receiving the damage) they will be stunned for stun_time milliseconds (this means they cannot perform any actions during the stun period).

If the actor has Invulnerability, then they are immune to damage, so neither the hitpoint loss nor the stun time will apply.

If the actor is a knight then HOOK_KNIGHT_DAMAGE will be run.

If the actor is a knight and the damage amount is greater than zero and inhibit_squelch is false (or not specified), then HOOK_CREATURE_SQUELCH will run.

Return Value

None.

Examples

In the standard Knights data files, this is used as part of the on_walk_over action for a bear trap, to cause the actor to become damaged (and stunned for a significant time) when they walk over a bear trap. See items.lua.

See Also

The cxt table