kts.SetLockpickSpawn

Name

kts.SetLockpickSpawn – setup automatic spawning of lockpicks

Synopsis

kts.SetLockpickSpawn(item_type, initial_time, interval_time)

Description

This function causes lockpicks to automatically spawn at a random dungeon location every so often. The first lockpick will spawn at initial_time milliseconds after the game begins, and new lockpicks will spawn every interval_time milliseconds thereafter.

The item_type parameter should be the ItemType corresponding to the lockpicks.

The purpose of this is to provide a way out in case players get "stuck" because a certain door is locked, but the key or lockpick that will open it is not reachable. In that case, the players can wait for a random lockpick to spawn, and then use it to open the door.

Return Value

No value is returned.

Errors

Errors can occur if the inputs have the wrong types.

Notes

The dungeon generator does make an effort to e.g. not place keys behind the locked door that the key itself opens, but this might not always be 100% successful. Also, it is possible that keys and/or lockpicks might get destroyed during the game (e.g. by being dropped down a pit) – they should then respawn into the dungeon, but again, they might respawn in an awkward position where knights cannot get to them. In both cases, a "backup" mechanism is needed, to allow knights to be able to get through the door, and that is why the random spawning of lockpicks was implemented.

Examples

kts.SetLockpickSpawn(lockpicks, 1000 * 60 * 6, 1000 * 60 * 2)

The above code arranges for a lockpick to spawn at a random location 6 minutes after the game begins, and then an additional lockpick to spawn every 2 minutes thereafter. This code can be found in dungeon_setup.lua in the standard Knights Lua files. (It assumes that lockpicks is a reference to the correct ItemType for the lockpicks.)

See Also

kts.ConnectivityCheck

kts.ItemType

kts.SetStuffRespawning