Log inGet started
World

Hold Your Breath: Horror FPS Kit with Flashlights, Scripted Scares and Stalkers (fork)

Branchmain
Commit6143ad305f

README.md

tensionKit

Version 1.0.3.

Named tensionKit since 1.0.1 (it was published as dreadKit in 1.0.0). Search for either name.

A tension director for horror games. Every player gets their own dread level (0..1) that builds from what happens to them, silence, darkness (faster with the torch off), noises and gunfire, a threat closing in, near misses, low health, a dying battery, scares, and eases when they are lit, calm or in a safe room. Dread drives music, ambience, heartbeat, breathing and the screen/camera feel, and gates a scare director with pacing rules (minimum gap, breather after a big scare, an intensity budget that ramps up). Pacing, look and audio palette are each switched by one field. Every sound is original, generated with the engine's audio generation and shipped inside the package.

Install

Search ZeroMind for tensionKit (or install the package by guid), it needs nothing else and installing it brings no other kit. It works with these kits when the game links them (tensionKit.links; require("~horrorKit.api") links them all for you):

KitWhat tensionKit uses it for
soundstagedread-driven music (it defines dread_industrial, dread_deepsea, dread_organic, dread_synth sets) and ducking on peaks
aiKitautomatic light level at the player (AI.lightAt) and noises (AI.onNoise: gunfire, slams)
SecondWindautomatic health (HK.state(player).fraction)
juiceKitcamera sway, tremor and the peak jolt (juiceKit.shake)

Link them yourself in a world that has those kits but not horrorKit:

local Links = require("~tensionKit.links")
Links.link("soundstage.music", require("~soundstage.music"))
Links.link("soundstage.mix", require("~soundstage.mix"))
Links.link("aiKit.api", require("~aiKit.api"))
Links.link("SecondWind.api", require("~SecondWind.api"))
Links.link("juiceKit.shake", require("~juiceKit.shake"))

Without them it still works: feed light, health and noises through the API.

First example

local Dread = require("~tensionKit.api")

-- once, for example in your scene entrypoint's onLoad:
Dread.start({ pacing = "slowBurn", look = "grain70s", palette = "deepSea" })

-- from your game:
Dread.stimulus("slam", 1, { at = vector.create(4, 1, 9) })   -- a door slammed there (weaker further away)
Dread.setThreat(12)                  -- the nearest monster is 12 m away (metres, or 0..1); call on change
Dread.setSafe(true)                  -- entering the safe room
Dread.on("peak", function() print("they're terrified") end)

-- a scare director asks before it fires:
if Dread.canScare(4) then
    print("play your scare here")
    Dread.scared(4)          -- starts the gap + breather, raises dread, plays a stinger
end

Or place the DreadDirector component on any entity and pick the styles in the inspector. Press F3 in play to show the tuning readout.

Styles (one field each)

Pacing, Dread.setPacing(name) / DreadDirector pacing

NameFeelMin gapBreather / intensityBudget start → ramp
slowBurnlong quiet build from silence and darkness, few scares75 s14 s1, +1 every 150 s
rollercoastertension swells in waves (70 s cycle); scare at the crest, then release35 s8 s2, +1 / 90 s
relentlessnever lets up: high floor (0.25), short gaps15 s3 s3, +1 / 45 s
quietDreadatmosphere over shocks; capped at 0.72, small scares60 s12 s1, +1 / 240 s
survivalClassic (default)readable explore → threat → fight/flight → safe room rhythm45 s10 s2, +1 / 120 s
arcadefast rise and fall, frequent scares, short sessions12 s2.5 s3, +1 / 30 s

Screen feel, Dread.setLook(name) / look

Every look scales with dread: vignette closing in, film grain, desaturation, colour tint, chromatic aberration, a slight FOV squeeze and a slow sway/tremor.

NameLook
clean (default)modern and restrained; soft vignette and desaturation only when it matters
grain70swarm faded 16 mm stock, heavy grain, amber tint that sours
vhsfound footage: strong colour bleed (aberration), noisy grain, cold cast
coldMonitorclinical blue-cyan, crisp contrast; dread drains to steel monochrome
sicklyfluorescent-rot green cast, heavy vignette, slow sway
bleachBypasssilvery, crushed, high contrast, little colour

Audio palette, Dread.setPalette(name) / palette

NameDrone, one-shots and music
industrial (default)machinery hum, pipe knocks, metal groans; distorted cello and metal percussion
deepSeahull pressure, sonar, drips; low brass and bowed metal
organicbreathing textures, whispers, creaks; folk-horror strings and choir
synthdetuned analog pads, cold arpeggios (80s horror score)
classicsoundstage's own horror set over the industrial drone

Each palette's music has three generated tracks: low (uneasy), high (building dread) and chase (terror), mapped to soundstage states explore (low/high) and action (high/chase).

Outputs, Dread.setOutputs{ ... }

music, ambience, heartbeat, breathing, screen, camera, stingers, each on by default, each switchable alone (also as DreadDirector fields).

How dread moves

  • Builds: darkness below ~0.35 light (×1.6 with the torch off, ×0.6 with it on), silence after the pacing's silenceDelay, threat (pulls up and holds a floor at 0.85 × threat), health under 50 % (and a floor), battery under 25 % in the dark, every stimulus at once.
  • Eases: when there is no threat and nothing happened for 4 s, at the pacing's decay rate, up to 3× faster in light; slower while hiding. Safe rooms drain fast and block building.
  • Bands: calm < 0.2 ≤ uneasy < 0.4 ≤ tense < 0.6 ≤ terror < 0.8 ≤ panic. peak fires when dread crosses 0.85 (re-arms below 0.65): tinnitus, a duck of music and ambience, a camera jolt.
  • Music is silent while calm with pacings that say so (slowBurn, rollercoaster, survivalClassic) and in safe rooms; explore below 0.72, action above (or when the threat is above 0.6).

API (require("~tensionKit.api"))

CallDoes
start(opts?) / configure(opts){ pacing, look, palette, outputs = {...}, autoSense, debugKey }; start also makes sure the director runs
stimulus(kind, amount?, opts?)kinds: noise, gunshot, slam, scream, nearMiss, scare, sighting, hurt, darkness, battery, torchFail, custom, and negative calm, relief. opts.at + opts.radius (25 m) fade it with distance, opts.weight overrides
setThreat(v, opts?)metres (> 1: ≤ 3 m full, ≥ 25 m none) or 0..1; held 5 s (opts.hold) then fades
setSafe(on) / setHiding(on)safe room: no build, fast drain, no scares, music quiet. Hiding: breathing and heartbeat audible, dread holds
setTorch(on), setBattery(0..1), setHealth(0..1), setLight(v or nil)inputs when the soft links are absent or you want to override
get(), band(), state()level, band, everything (threat, light, silence, budget, recent stimuli, …)
canScare(i), scared(i, opts?), suggestScare()the pacing gate; opts.stinger = false skips the stinger
setPacing, setLook, setPalette, setOutputs, styles(), config()the switches
set(v), reset()force a level (cutscene, checkpoint), back to calm
debug(on?), isDebug()the readout (also the debug key, F3)
on(event, fn) -> disconnectevents below

require("~tensionKit.outputs").report() reads every voice's volume and mixer state, the post-process passes, music and FOV, useful in tests. outputs.sting("soft"|"swell"|"hard") plays a stinger by hand.

Events

EventPayloadWhen
level{ value, band }band changes, and every 0.05 of movement
band{ band, previous, value }band changes
peak{ value }dread crosses 0.85
safe{ on }setSafe changes
stimulus{ kind, amount, value }each stimulus
scare{ intensity }scared()

Wiring with the other horror kits (horrorKit does this)

In a world that also has flashlightKit, stalkerKit and scaresKit (horrorKit installs them all and runs this wiring for you):

local Dread = require("~tensionKit.api")
local Torch = require("~flashlightKit.api")
local Stalker = require("~stalkerKit.api")
local Scares = require("~scaresKit.api")
local me = multiplayer.getPeerId()
Torch.on("toggled", function(e) if e.player == me then Dread.setTorch(e.on) end end)
Torch.on("batteryLow", function(e) Dread.setBattery(e.charge) end)
Torch.on("failed", function() Dread.stimulus("torchFail", 1) end)
Stalker.on("state", function(e) if e.state == "chase" then Dread.stimulus("sighting", 1) end end)
Scares.setGate(function(i) return Dread.canScare(i) end); Scares.on("scare", function(s) Dread.scared(s.intensity) end)

Multiplayer

Dread is per player and local: every engine runs its own director for its own player and nothing is sent over the network. Each player hears their own heartbeat and breathing, sees their own screen feel, and tensionKit switches soundstage music to shared = false while it drives it, so two players in different rooms hear different music. Stimuli with at fade with each player's own distance. Tested with the sub-client and the user's client in one play session.

Performance

One small update per frame: a handful of arithmetic, the light probe and health read every 0.4 s, music decisions every 0.5 s, post-process properties written only when they change by more than 0.002, the readout rebuilt at 5 Hz only while shown. Uses the engine's built-in vignette, chromatic aberration, colour correction and lensFx film grain, no custom shaders, so it runs on web and tablets.

Known limits

  • The screen feel uses the client's whole post-process chain, so it also grades anything else drawn on the scene layer (not the UI).
  • FOV squeeze writes the active camera's fov; a controller that rewrites fov every frame wins (tensionKit then rebases on its value).
  • Sway and tremor need juiceKit; without it only the FOV squeeze moves the camera.
  • Without aiKit, light reads 1 (lit) unless you call setLight.
  • soundstage music is switched to local-only while tensionKit drives it; turn the music output off if your game wants shared music.

1.0.1

Renamed from dreadKit. The screen grade and grain never lift pure black. Test suite renamed tensionKitTests.

1.0.2

Installs alone: soundstage, aiKit, SecondWind and juiceKit are no longer required by name (a published literal require made each a dependency of every install). The game links them through tensionKit.links; require("~horrorKit.api") does it for you.

1.0.3

README: the first example runs as written (no placeholder door, distance or scare function); the wiring example requires the kits it uses.