Castaway Isle: Island Survival and Crafting Kit
README.md
nightCreaturesKit
Things come out of the jungle when the sun goes down. They are scared of your fire, and they leave at dawn. For creators asking "how do I add monsters that come out at night", "make a survival game where you survive the night" or "enemies that fear fire". Eight creatures, two looks each, four threat sets and three densities, each switched with one setting. Multiplayer: the host decides, every player sees the same creatures.
Version 1.0.13 (built against aiKit 1.3.16 and navKit 1.5.0, so it installs beside them as one release of each). New in 1.0.13: released from the Castaway Isle main line together with the other survival kits, against aiKit 1.3.16; no behaviour change. New in 1.0.12: the night is dangerous off the paths too. A navKit map stops short of beaches, piers and camps, so a creature hunting a player standing there used to wait at the map's edge; now, within 14 m of a player in the dark, it drops its path and runs straight at them (the new rushed(id) event), and takes the path again once the player is 30 m away. Firelight and a held torch still turn it away at the edge of the light. Built on spawnerKit (each creature is a spawnerKit enemy: spawn effects, pooling, contact damage), SecondWind (their health, your damage) and worldClockKit (dusk and dawn from the shared clock). Reads firelight from survivalNeedsKit HeatSources when it is installed. When aiKit is installed, each creature gets an aiKit brain (the swarm preset for crabs, bats and wisps, chaser for the rest) that hunts players along navKit paths, round rocks, trees and buildings: the NightDirector bakes a navKit waypoint map of the island on every peer when play starts (navMap, navSize, navSpacing, navCell; about 5 to 12 seconds for the whole island), since a brain with no map never moves. Creatures prowl a clear 2.5 m outside the light. Near firelight the director switches the brain off and walks the creature round the edge of the light on navKit paths, circling for as long as a player stands inside it, and at dawn it walks every creature away into the dark the same way before spawnerKit removes it.
The dawn rule: at dawn no new group spawns, every creature walks or flies away from the nearest player into the dark, and any creature still in play leaveSeconds (12) after it was sent away is removed by the host through spawnerKit. Nothing stays on the beach in daylight.
Quick start
In build.luau, inside content(), and in entrypoint.luau:
local SK = require("spawnerKit.api")
local night = entity.spawnSynced("NightDirector")
SK.addSpawner(night, { pattern = "ring", effect = "auto", autoStart = false })
night.component.add(asset.resolve("nightCreaturesKit.NightDirector", "component"), {})
-- entrypoint.luau
local Creatures = require("~nightCreaturesKit.creatures")
function onLoad()
Creatures.setup({ threat = "island", density = "normal" })
end
You need a WorldClock in the scene (worldClockKit) so there is a dusk and a dawn.
Styles and choices
| Setting | Values |
|---|---|
threat | island (crabs, bats, drowned sailors, a jungle cat, wisps), forest (wolves, bats, spiders, a panther), haunted (stalkers, wisps, a drowned captain, vampire bats, ghost crabs), arctic (dire wolves, a smoke stalker, bats) |
density | calm, normal, swarming |
enabled | false keeps nights empty (creative) |
| Creature | Looks | Health | Speed | Group | Fear of fire |
|---|---|---|---|---|---|
| Crab swarm | sand, ghost | 18 | 3.4 | 6 | strong |
| Wolf pack | timber, dire | 45 | 4.6 | 3 | prowls the edge |
| Shadow stalker | void, smoke | 70 | 3.0 | 1 | never enters light |
| Bats | fruit, vampire | 10 | 5.5 (flying) | 5 | strong |
| Drowned sailor | deckhand, captain | 60 | 2.2 | 2 | dares the edge |
| Jungle cat | jaguar, panther | 55 | 5.2 | 1 | prowls the edge |
| Giant spider | huntsman, widow | 50 | 3.8 | 2 | strong |
| Will-o'-the-wisp | marsh, spectral | 20 | 2.6 (ranged) | 2 | none; burns out at dawn |
How the night runs
- When the clock's darkness passes
duskAt(0.55) the host's NightDirector starts night number N: every peer hearsdusk. - Every
intervalseconds it releases a group from the threat set: it moves its Spawner to a dry, dark spot about 30 m from a random player (never inside firelight) and spawns the group there with spawnerKit's ring pattern. - Four times a second it steers every creature: one that strays into firelight turns to wander just past the light's edge, so they circle your camp; out in the dark they chase the nearest player (with aiKit, their brain hunts along navKit paths).
- When darkness falls below
dawnAt(0.3) no new group is released and every creature walks away into the dark (with aiKit, its brain and navKit agent come off first, so nothing holds it in place); any still in playleaveSeconds(12) after it left is sent back to spawnerKit's pool. Every peer hearsdawn; the host firesretreatonce andfled(id)per creature.
Light comes from Creatures.lightAt: survivalNeedsKit HeatSources (campfires, torches) plus anything you register with Creatures.addLight(entity, radius), such as a torch in a player's hand.
API
creatures module
local Creatures = require("~nightCreaturesKit.creatures")
setup(opts): choosethreat,densityandenabled; call on every peer.config(): a copy of the current settings.catalogue(): every creature, look, threat set and density, for menus and agents.on(event, fn): listen todusk(night),dawn(night),spawned(kind, n),fled(id),retreat(),setup(cfg); spawned, fled and retreat fire on the host. Returns a function that stops listening.darkness(): how dark it is by the shared clock (0 day, 1 night).addLight(entity, radius): register a light creatures fear; returns a function that removes it.lightAt(x, y, z): light at a point (0..1): survivalNeedsKit fires plus registered lights.lights(): every light creatures fear,{ { x, z, r } }.build(root, creature, look?): draw a creature under any entity (a bestiary, a menu).kindId(creature): the spawnerKit enemy kind id ("night_wolfPack").creatureOf(kindId): the creature behind a spawnerKit kind id, or nil.defineAll(): register every creature as a spawnerKit enemy kind (setup calls it).pick(r?): pick a creature and look from the threat set by weight.dawnRemovals(sinceDawn, leaveSeconds?): the dawn rule as a pure function: given{ [id] = seconds since it was sent away }, the sorted ids that must be removed now (defaultLEAVE_SECONDS, 12).VERSION,EVENTS,DENSITY,PREFIX,LEAVE_SECONDS: the version, event names, density table, kind id prefix and default dawn window.
Components
NightDirector: on a synced entity with a spawnerKit Spawner; runs the nights on the host.
night(false): whether the creatures are out (host-written).nightNumber(0): how many nights have begun (host-written).groupsSent(0): groups released this night (host-written).spawnDistance(30): how far from a player a group appears.bringCreatures(true): off keeps nights empty (creative).leaveSeconds(12): seconds a creature has to walk away at dawn before the host removes it.- Methods:
startNight()(host; for testing and scripted events),endNight()(host; sends every creature away).
CreatureGallery: all eight creatures in both looks in a turning, labelled lineup.
spacing(3.2),rowGap(4),labels(true),floor(true),turn(true).
What it installs
Installing nightCreaturesKit brings these packages, each from its own world, at the versions it was built and tested with:
| Package | Version |
|---|---|
| spawnerKit | 1.1.8 |
| SecondWind | 1.4.7 |
| worldClockKit | 1.7.3 |
Gallery
Put a CreatureGallery on any entity to see all eight creatures in both looks in a turning, labelled lineup, with each threat set and density on a sign.
Guides
- How do I add monsters that come out at night and fear fire (
nightCreaturesKit.package/how-do-i-add-monsters-that-come-out-at-night-and-fear-fire.guide) - Example: survive the night on an island with a campfire (
nightCreaturesKit.package/example-survive-the-night-on-an-island-with-a-campfire.guide)
Tests
19 tests in nightCreaturesKit.testSuite. Run them with asset.resolve("nightCreaturesKit", "testSuite"):run().
Known limits
- Without aiKit, creatures walk straight at their target over the ground (spawnerKit's movement), so they do not path round cliffs. With aiKit they walk navKit paths; the NightDirector bakes that map itself when play starts (5 to 12 s), and until it is ready the creatures wait at their spawn.
- Creatures are drawn from simple shapes, with no animation rig.