The pack
survivorRules
function survivorRules(): Pack<{ survivors: SurvivorRulesApi }>
The survivor-rules pack: game.survivors, Vampire Survivors' rules. No options.
Helpers
createSurvivorAutopilot
function createSurvivorAutopilot(game: SurvivorGame, options: SurvivorAutopilotOptions = {}): SurvivorAutopilot
A survivors run's autopilot. It only reads game.
createSurvivors
function createSurvivors(options: SurvivorOptions = {}): SurvivorGame
Start a run. Throws, with every fault, on options validateSurvivors refuses.
survivorEnemies
const survivorEnemies: EnemyDef[]
The built-in enemies.
survivorEvents
const survivorEvents: SpawnEvent[]
The built-in events: an elite every minute and a half, a giant bat at five minutes, the reaper at the end.
survivorPassives
const survivorPassives: PassiveDef[]
The built-in passive items.
survivorSet
const survivorSet: SurvivorSet
The built-in set: Vampire Survivors' early game.
survivorWaves
const survivorWaves: SpawnWave[]
The built-in spawn table: ten minutes, rising.
survivorWeapons
const survivorWeapons: WeaponDef[]
The built-in weapons.
survivorXp
const survivorXp = (level: number): number=> …
Experience for each level, as Vampire Survivors counts it.
validateSurvivors
function validateSurvivors(options: SurvivorOptions = {}): string[]
Check a run's options and set. Empty when it can be played.
Types
EnemyDef
interface EnemyDef
An enemy.
id: string— Unique id; waves and events refer to it.hp: number— Hit points; above 0.speed: number— Units a second.damage: number— Damage on contact (the hero then has a moment's grace:hero.grace).radius: number— Its size.xp: number— The gem it drops: experience.move?: 'walk' | 'flutter'— How it moves: straight at the hero, or in a weaving flight (a bat). Default'walk'.knock?: number— How far knockback moves it, as a fraction. Default 1; a boss shrugs it off with less.
HeldWeapon
interface HeldWeapon
A held weapon.
id: string— Id of the weapon in the set.level: number— Its level, from 1; level N uses entry N - 1 of the weapon'slevels.cooldown: number— Seconds until it fires next.side: number— Count of whip volleys fired so far; only the whip advances it.
PassiveDef
interface PassiveDef
A passive item.
id: string— Unique id;evolves.withrefers to it.name: string— The name shown to the player.stat: PassiveStat— The stat it raises.perLevel: number— Per level: a fraction for might, area, cooldown (taken off), speed, duration, magnet, move and growth; an amount for amount, maxHp, armor and recovery (per second).maxLevel?: number— Its last level. Default 5.
PassiveStat
type PassiveStat = 'might' | 'area' | 'cooldown' | 'speed' | 'duration' | 'amount' | 'magnet' | 'maxHp' | 'armor' | 'recovery' | 'move' | 'growth'
What a passive raises, per level, as a fraction or an amount.
SpawnEvent
interface SpawnEvent
One-off arrivals: elites (which drop a chest) and bosses (which drop one too).
at: number— Seconds in.enemy: string— The enemy.count?: number— How many. Default 1.scale?: number— Hit points times this. Default 1.chest?: boolean— Drops a chest. Default true.
SpawnWave
interface SpawnWave
A stretch of the spawn table.
from: number— From this many seconds in.until: number— To this many.enemies: { id: string; weight?: number }[]— Which enemies, by weight.rate: [number, number]— Enemies a second at its start and at its end.cap?: number— Most alive at once. Default 300.
SurvivorAutopilot
interface SurvivorAutopilot
A player that picks the way to walk and the level-up choices.
next(): { x: number; y: number; choose: number | null }— The way to walk now; give it tomove. When a choice waits,chooseis its pick.
SurvivorAutopilotOptions
interface SurvivorAutopilotOptions
How the autopilot plays.
prefer?: string[]— Weapon and passive ids in the order it takes them; anything else after. Default the evolutions' pairs first.wary?: number— How close it lets enemies come before it backs off. Default 140.
SurvivorChoice
type SurvivorChoice = | { kind: 'weapon'; id: string; level: number } | { kind: 'passive'; id: string; level: number } | { kind: 'gold' } | { kind: 'heal' }
A level-up choice.
SurvivorEvent
type SurvivorEvent = | { kind: 'level'; level: number } | { kind: 'choose'; choice: SurvivorChoice } | { kind: 'kill'; enemy: string; x: number; y: number; elite: boolean } | { kind: 'hurt'; damage: number; hp: number } | { kind: 'gem'; value: number } | { kind: 'chest'; result: string } | { kind: 'evolve'; from: string; into: string } | { kind: 'pickup'; what: 'chicken' | 'vacuum' } | { kind: 'fire'; weapon: string } | { kind: 'boss'; enemy: string } | { kind: 'over' } | { kind: 'won' }
Something that happened.
SurvivorGame
interface SurvivorGame
A run.
readonly state: SurvivorState— The live state; the game changes it in place as it steps, so read it or take aview().readonly options: Readonly<{ hero: SurvivorHero; duration: number; choices: number; slots: { weapons: number; passives: number }; set: SurvivorSet }>— The options, defaults filled in.move(x: number, y: number): void— Which way to walk: a direction (it is normalised); zero stands still.choose(index: number): boolean— Take a level-up choice by its place instate.choosing.stat(stat: PassiveStat): number— The stat a passive gives now, summed: what the HUD shows.step(dt: number): void— Advancedtseconds, in fixed steps of 1/60 s. Paused while a level-up waits.view(): SurvivorView— What is where, for a presenter: a copy of the state and every enemy, shot, flash, gem and thing.drain(): SurvivorEvent[]— The events since the last call, oldest first (at most the latest 1024 are kept).snapshot(): SurvivorSave— A plain-data copy of the whole run, whichrestoreaccepts.restore(save: SurvivorSave): void— Return to a saved run. Replaces the state, and clears undrained events.
SurvivorHero
interface SurvivorHero
The hero's own numbers, before passives.
hp: number— Hit points. Default 100.speed: number— Units a second. Default 110.radius: number— Its size. Default 12.magnet: number— Gems this close fly in. Default 45.armor: number— Taken off each hit. Default 0.recovery: number— Hit points a second. Default 0.grace: number— Seconds after a hit in which it cannot be hit again. Default 0.35.
SurvivorOptions
interface SurvivorOptions
A run's options.
seed?: number— The seed. Default 1.set?: SurvivorSet— The weapons, passives, enemies, waves and events. DefaultsurvivorSet.start?: string— The weapon the hero starts with. Default'whip'.hero?: Partial<SurvivorHero>— The hero.slots?: { weapons?: number; passives?: number }— How many weapons and passives can be held. Default 6 each.choices?: number— Choices offered on a level-up. Default 3.duration?: number— Seconds to survive. Default 600.view?: { width: number; height: number }— The screen's size in world units: enemies spawn just beyond it. Default 960 by 640.xpFor?: (level: number) => number— Experience for each level, from level 1. Default Vampire Survivors': 5, then 10 more a level, 13 from level 20, 16 from 40.pace?: number— Spawn rates times this. Default 1.
SurvivorRulesApi
interface SurvivorRulesApi
What the survivor-rules pack adds to a game: game.survivors.
create: typeof createSurvivors— Start a run.validate: typeof validateSurvivors— Check a run's options.set: typeof survivorSet— The built-in set.autopilot: typeof createSurvivorAutopilot— A player for an attract mode or a test.
SurvivorSave
interface SurvivorSave
A run saved as plain JSON.
state: SurvivorState— The hero's state.enemies: Enemy[]— Every live enemy.shots: Shot[]— Every projectile and orbiting orb.gems: Gem[]— Every gem on the ground.things: Thing[]— Chests, chickens and vacuums waiting to be picked up.flashes: Flash[]— Brief effects of whip lashes, aura pulses and lightning strikes.serial: number— The last id handed out to an enemy, shot, gem, thing or flash; the next is one more.grace: number— Seconds of grace left after the last hit, in which the hero cannot be hit again.spawnCredit: number— The part of an enemy accumulated toward the next spawn of the wave.events: number— How many of the set's one-off events (sorted by time) have already happened.rng: RngState— The seeded random stream's state, from the kernel'srng.snapshot().
SurvivorSet
interface SurvivorSet
A whole run's data.
weapons: WeaponDef[]— The weapons, with their evolutions.passives: PassiveDef[]— The passive items.enemies: EnemyDef[]— The enemies, which the waves and events name by id.waves: SpawnWave[]— The spawn table: stretches of seconds into the run with enemy weights and rates.events: SpawnEvent[]— One-off arrivals at set times: elites and bosses.
SurvivorState
interface SurvivorState
Where the run stands.
time: number— Seconds of play since the run began; paused while a level-up waits.x: number— The hero's position, world units across.y: number— The hero's position, world units down.hp: number— Hit points left; the run is lost at 0.maxHp: number— Most hit points the hero can have now:hero.hpplus the max-HP passives.facing: number— The way it faces across: -1 or 1.aim: { x: number; y: number }— The last way it moved, a unit vector.level: number— The hero's level, from 1.xp: number— Experience gathered toward the next level; it starts again from the surplus at each level-up.nextXp: number— Experience needed to finish the current level.kills: number— Enemies killed.gold: number— Gold collected from chests and level-up choices.weapons: HeldWeapon[]— The weapons held, up to the weapon slots.passives: { id: string; level: number }[]— The passive items held, each with its level.choosing: SurvivorChoice[] | null— The choices on offer, while a level-up waits; the run is paused.pending: number— Level-ups still to choose after this one.alive: boolean— Whether the hero is alive; false once its hit points reach 0.won: boolean— Whether the run has been survived to its duration.
SurvivorView
interface SurvivorView
What is where, for a presenter.
state: SurvivorState— The hero's state, a copy.radius: number— The hero's size in world units.enemies: { id: number; kind: string; x: number; y: number; r: number; flash: boolean; elite: boolean; hp: number; maxHp: number }[]— Every live enemy: its id, its enemy kind id, position, drawn radius in world units (elites are 1.5 times larger), whether it was just hit, whether it is an elite, and its hit points and maximum.shots: { id: number; weapon: string; x: number; y: number; r: number; angle: number }[]— Every projectile and orbiting orb: its id, weapon id, position, radius in world units, and the heading angle in radians.flashes: { id: number; weapon: string; kind: 'whip' | 'strike' | 'aura'; x: number; y: number; w: number; h: number; side: number; t: number }[]— Brief effects of whip lashes, aura pulses and lightning strikes: size in world units, the side a lash falls on, andt, how far through its life it is (0 to 1).gems: { id: number; x: number; y: number; value: number }[]— Every gem on the ground and the experience it is worth.things: { id: number; x: number; y: number; kind: 'chest' | 'chicken' | 'vacuum' }[]— Chests, chickens and vacuums waiting to be picked up.
WeaponDef
interface WeaponDef
A weapon.
id: string— Unique id;SurvivorOptions.startandevolves.intorefer to it.name: string— The name shown to the player.kind: WeaponKind— How the weapon behaves.levels: WeaponLevel[]— Its levels, from level 1.evolves?: { with: string; into: string }— Turned into another weapon by a chest, at its last level, while the hero holds a passive.evolution?: boolean— Only from an evolution, never offered on a level-up.
WeaponKind
type WeaponKind = /** A lash across the front, left and right in turn (the whip). */ | 'whip' /** Projectiles at the nearest enemies (the magic wand). */ | 'seek' /** Projectiles the way the hero faces (knives). */ | 'facing' /** Damage to everything within reach, on a tick (garlic). */ | 'aura' /** Orbs circling the hero for a while (the bible). */ | 'orbit' /** Thrown up, falling in an arc (the axe). */ | 'arc' /** Strikes on random enemies nearby (lightning). */ | 'strike'
How a weapon behaves.
WeaponLevel
interface WeaponLevel
A weapon's numbers at one level (each level's are its own, not added).
damage: number— Damage per hit.cooldown: number— Seconds between volleys.amount?: number— How many: projectiles, orbs, strikes, whip lashes. Default 1.area: number— Size: a whip's reach, an aura's radius, an orbit's radius, a projectile's radius.speed?: number— Projectile or orbit speed, units a second (orbits: radians a second). Default 0.duration?: number— Seconds a projectile or orbit lasts. Default 1.pierce?: number— Enemies a projectile goes through before it is spent; Infinity for all. Default 1.knockback?: number— Knockback, units. Default 0.


