kts.PickLock – attempt to pick a lock
kts.PickLock(probability, waiting_time)
kts.Can_PickLock(probability, waiting_time)
kts.PickLock
will try to find a locked door or chest tile in the square directly in front of the current actor (cxt.actor
). If found, then with the given probability
(which must be a number between 0 and 1), the door or chest will immediately be unlocked and opened; otherwise, nothing happens.
Whether lock picking is successful or not, the actor will be stunned (unable to perform other actions) for the given waiting_time
. (If the actor is a knight with Quickness, then this time will be multiplied by 100 / Q, where Q is the quickness_factor
from the MISC_CONFIG table; this means that knights with Quickness can pick locks faster than normal.)
kts.Can_PickLock
returns true if a lock picking action is currently possible (e.g. this checks that cxt.actor
is not nil and that the square ahead of the actor does contain at least one valid "pickable" door or chest tile). The probability
and waiting_time
arguments are ignored in this case (although they must still be valid numbers).
kts.PickLock
returns nothing, and kts.Can_PickLock
returns a boolean as described above.
Errors will occur if probability
is not a number between 0 and 1 or waiting_time
is not a valid number.
"Special-locked" doors are ignored by this function (i.e. lock-picking them will not be possible). In general, the only way to open such doors is by using switches found in the dungeon. See also the special_lock
property of kts.Tile.
kts.PickLock
and kts.Can_PickLock
are usually used as the action
and possible
functions (respectively) of a Control.
In the standard Knights files, the action
function of the "Use Lock Picks" control calls kts.PickLock
, with a waiting time of 140 ms, and then plays a sound. In theory, this means the "lock picking" sound should play once every 140 ms in a regular rhythm. In practice, in network games, there are slight variations in ping times which means that the sound is played with a slightly irregular rhythm instead. This isn't a hugely serious bug, but it is annoying to listen to. Perhaps some way should be found to smooth this out on the client.
The standard Knights items.lua
file defines lock picks here; this shows a good example of kts.PickLock
and kts.Can_PickLock
being used.