singe/assets/Forge/tutorials/09-rail.game
2026-09-14 22:32:53 -05:00

215 lines
5 KiB
Text

-- Written by Forge/AuthorCompile.singe. Edit by hand or in the editor; either is fine.
return {
types = {
camera = {
behaviours = {
{ kind = "camera", mode = "rail", track = "rail" }
},
look = { kind = "none" },
vars = {}
},
floor = {
behaviours = {
{ kind = "solid" }
},
look = { b = 90, d = 60, g = 75, h = 0.2, kind = "mesh", r = 70, shape = "box", w = 40 },
vars = {}
},
gun = {
behaviours = {
{ ammo = 6, kind = "gun", player = 1, reload = "offscreen" }
},
look = { kind = "none" },
vars = { ammo = 6 }
},
painting = {
behaviours = {},
look = { b = 255, d = 0.2, g = 255, h = 16, kind = "mesh", r = 255, shape = "box", texture = "Forge/kit/yard.png", unlit = true, w = 24 },
vars = {}
},
pillar = {
behaviours = {},
look = { d = 1.2, h = 8, kind = "mesh", occluder = true, shape = "box", w = 1.2 },
vars = {}
},
readout = {
look = { b = 245, g = 235, kind = "text", r = 235, text = "score 0" }
},
zombie = {
behaviours = {
{ kind = "health", linger = 2, max = 2, ragdoll = true },
{ kind = "seek", speed = 1.6, stopAt = 2.2, target = "camera" },
{ attack = "Run", idle = "Survey", kind = "animator", walk = "Walk" },
{ kind = "target" },
{ after = 1.5, kind = "timer", name = "bite", start = false }
},
look = { d = 1.4, file = "Forge/kit/fox.glb", h = 0.9, kind = "model", scale = 0.01, w = 0.8 },
vars = { health = 2 }
}
},
layers = {
{ fov = 60, kind = "scene3d" },
{ kind = "overlay" }
},
rooms = {
{
entities = {
{ id = "readout", type = "readout", x = 12, y = 12 },
{ id = "floor", type = "floor", x = 0.0, y = -0.1, z = -20.0 },
{ id = "painting", type = "painting", x = 0.0, y = 6.0, z = -30.0 },
{ id = "pillar", type = "pillar", x = 0.0, y = 4.0, z = -22.0 },
{ id = "camera", type = "camera", x = 0.0, y = 1.6, z = 0.0 },
{ id = "gun", type = "gun", x = 0.0, y = 0.0, z = 0.0 }
},
name = "start",
tracks = {
{
key = "time",
name = "rail",
points = {
{
at = 0,
look = { 0, 1.2, -10 },
stop = "nil",
x = 0,
y = 1.6,
z = 0
},
{
at = 4,
look = { 0, 1.2, -16 },
stop = "gate",
x = 0,
y = 1.6,
z = -6
},
{
at = 10,
look = { 2, 1.2, -24 },
stop = "pillar",
x = 2,
y = 1.6,
z = -14
},
{
at = 14,
look = { 2, 1.2, -28 },
stop = "nil",
x = 2,
y = 1.6,
z = -18
}
}
}
}
}
},
rules = {
{
act = {
{ "setText", entity = "readout", text = "\"score \" .. score .. \" health \" .. health .. \" ammo \" .. gun.ammo" }
},
note = "The readout, every frame",
on = "frame"
},
{
act = {
{ "spawn", type = "zombie", x = -2, y = 0, z = -14 },
{ "spawn", type = "zombie", x = 2, y = 0, z = -15 }
},
name = "gate",
note = "The gate: two come out of the dark",
on = "stopped",
when = {}
},
{
act = {
{ "spawn", type = "zombie", x = -1, y = 0, z = -23 },
{ "spawn", type = "zombie", x = 0, y = 0, z = -26 },
{ "spawn", type = "zombie", x = 4, y = 0, z = -24 }
},
name = "pillar",
note = "The pillar: three more, one from behind it",
on = "stopped",
when = {}
},
{
act = {
{ "setState", entity = "self", state = "walk" }
},
type = "zombie",
note = "A zombie walks the moment it is made",
on = "spawn",
when = {}
},
{
act = {
{ "damage", amount = 1, entity = "self" },
{ "addScore", amount = 100 },
{ "playSound", file = "Forge/kit/hit.wav" }
},
type = "zombie",
note = "A shot lands",
on = "hit",
when = {}
},
{
act = {
{ "setState", entity = "self", state = "attack" },
{ "timerStart", after = 1.5, entity = "self", name = "bite" }
},
type = "zombie",
note = "It reaches the camera and rears up",
on = "arrived",
when = {}
},
{
act = {
{ "addVar", amount = -1, name = "health" },
{ "flash", b = 40, g = 40, r = 255, seconds = 0.3 },
{ "shake", amount = 0.3, seconds = 0.4 },
{ "timerStart", after = 1.5, entity = "self", name = "bite" }
},
type = "zombie",
name = "bite",
note = "The bite lands unless it was killed in time",
on = "timer",
when = {
{ "inState", entity = "self", state = "attack" }
}
},
{
act = {
{ "pathNext", entity = "camera" }
},
note = "The stop is clear: move on",
on = "frame",
when = {
{ "waiting", entity = "camera" },
{ "test", expr = "count(\"zombie\") == 0" }
}
},
{
act = {
{ "say", seconds = 2, text = "\"YOU ARE DEAD\"" },
{ "gameOver" }
},
note = "Out of health",
on = "frame",
when = {
{ "test", expr = "health <= 0" },
{ "once", scope = "game", tag = "over" }
}
},
{
act = {
{ "say", seconds = 2, text = "\"STAGE CLEAR\"" }
},
note = "The end of the rail",
on = "railEnd",
when = {}
}
},
title = "The Dead Yard",
vars = { health = 3, score = 0 }
}