kts.HOOK_KNIGHT_DAMAGE – function called when a knight takes damage, suicides, or is poisoned
kts.HOOK_KNIGHT_DAMAGE = function() ... end
If kts.HOOK_KNIGHT_DAMAGE
is non-nil, then it is called as a Lua function (with no parameters) whenever a knight takes any damage (even if it is a zero amount), commits suicide, or is poisoned.
During the function call, the cxt table will be available; for example, cxt.pos
will give the position of the knight.
In the standard Knights data files, this hook is used to play the "ugh" sound that is heard when knights get damaged or hit. The code for this is in sounds.lua.
Other modules could replace kts.HOOK_KNIGHT_DAMAGE
(or any of the other "hook" functions) with their own code if desired.