feat(rust): RaidableBases — feed, raids map layer, Warlord, Spawn a raid base, profiles (PLAN_REDESIGNS §11.4)
All checks were successful
PR Checks / server-tests (pull_request) Successful in 37s
PR Checks / client-build (pull_request) Successful in 24s
PR Checks / frozen-manifest (pull_request) Successful in 49s

PLAN_REDESIGNS §11.4 (D202-D208, D386-D391), protocol 14. Spec: docs
rust-link/PROTOCOL.md §20.12.

- raid.started, raid.completed, raid.purchased and raid.locked public,
  raid.ended staff's; raidableBases.js reads each row per viewer (raiders'
  and a buyer's names only for the presence audience, D376/D390; Steam ids,
  position and a run's key only for staff). Feed lines in the World filter.
- The step rust.raidbase.spawn, "Spawn a raid base" (ledgered, budget
  rust.raids): difficulty, profile and base from option sources listing each
  server's own names (D386), a spot as a world call's location with a height
  adjustment or an exact height, and PvP/NPCs/lock as on/off/blank. A base
  the raids helper made is a world resource, so eventWorld's revert and
  reconcile serve it and world.expired marks it expired; one it did not make
  records nothing and the run log says it despawns on its own timer. Refused
  at verify for a server that said it cannot; a dry run with a spot returns
  the spot check as detail.warnings (MODULE_API 1.16.0, D391). rb-not-ready
  retries in ten minutes.
- Warlord: raids_completed, title category raidscompleted, the leaderboard's
  Raid bases column (sort=raidsCompleted).
- The map's raids layer (D114), public by default with its own audience; the
  run's key is dropped before any viewer gets it.
- Server settings' line for RaidableBases; its profiles in Mod configuration
  under a virtual path (D205).
- Swagger fragment, bundle and README.

Tests: server 684/684 (raidableBases.test.js new, every name in it invented);
client 99/99, build and externals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
2026-10-16 15:18:52 -05:00
parent 49d9e42a23
commit 481837e937
34 changed files with 1996 additions and 38 deletions

View File

@@ -50,6 +50,10 @@ const TREASURES = { key: 'treasuresWon', label: 'Treasures', sort: 'treasuresWon
// same rule from the server's `guardedCrate`.
const GUARDED = { key: 'guardedWon', label: 'Crates cleared', sort: 'guardedWon', value: (r) => count(r.guardedWon) }
// Warlord (PLAN_REDESIGNS §11.4, D202): RaidableBases bases completed, shown on
// the same rule from the server's `raidableBases`.
const RAIDS = { key: 'raidsCompleted', label: 'Raid bases', sort: 'raidsCompleted', value: (r) => count(r.raidsCompleted) }
const BALANCE = { key: 'balance', label: 'Coins', sort: 'balance', value: (r) => coins(r.balance) }
export default function Leaderboard({ serverId, wipeId, sort, onSort }) {
@@ -109,6 +113,7 @@ function Overall({ serverId, wipeId, sort, onSort }) {
...COLUMNS,
...(data && data.dangerousTreasures ? [TREASURES] : []),
...(data && data.guardedCrate ? [GUARDED] : []),
...(data && data.raidableBases ? [RAIDS] : []),
...(data && data.economics ? [BALANCE] : []),
]
// Present on every row or on none — the server decides per request.

View File

@@ -21,7 +21,7 @@ import Empty from './Empty.jsx'
import usePolled from '../hooks/usePolled.js'
import { ago } from '../lib/format.js'
import { boundsOf, countdown, fromLatLng, grid, gridLabel, toLatLng } from '../lib/mapGeometry.js'
import { eventTip, isBoss, pvpTip, titlesFrom, unknownRuns } from '../lib/mapEvents.js'
import { eventTip, isBoss, pvpTip, raidTip, titlesFrom, unknownRuns } from '../lib/mapEvents.js'
import api, { BASE } from '../api.js'
const STYLE_ID = 'rust-leaflet-css'
@@ -36,6 +36,7 @@ const LAYERS = [
{ id: 'players', label: 'Players' },
{ id: 'bases', label: 'Bases' },
{ id: 'pvp', label: 'PvP zones' },
{ id: 'raids', label: 'Raid bases' },
]
const COLOURS = {
@@ -57,6 +58,8 @@ const COLOURS = {
self: '#00e5ff',
mate: '#7cffb2',
pvp: '#ff1744',
raid: '#ff9100',
raidOurs: '#ffd600',
}
const WORLD_NAMES = {
@@ -87,7 +90,7 @@ export default function MapView({ serverId, online, onPick = null, pins = null }
const [leaflet, setLeaflet] = useState(null)
const [leafletError, setLeafletError] = useState(null)
const [shown, setShown] = useState({ grid: true, world: true, events: true, players: true, bases: true, pvp: true, mates: true })
const [shown, setShown] = useState({ grid: true, world: true, events: true, players: true, bases: true, pvp: true, raids: true, mates: true })
useEffect(() => {
let alive = true
@@ -168,7 +171,7 @@ export default function MapView({ serverId, online, onPick = null, pins = null }
map.fitBounds(bounds)
const made = {}
for (const id of ['grid', 'monuments', 'world', 'events', 'players', 'bases', 'pvp', 'mates', 'pins']) made[id] = L.layerGroup().addTo(map)
for (const id of ['grid', 'monuments', 'world', 'events', 'players', 'bases', 'pvp', 'raids', 'mates', 'pins']) made[id] = L.layerGroup().addTo(map)
// The labels are a layer of their own inside the grid's, shown only when a cell
// is wide enough on screen to hold one: at the fitted zoom a 20-cell map's
// labels overlap into a wall of text (found on the phase 14 walk).
@@ -246,7 +249,7 @@ export default function MapView({ serverId, online, onPick = null, pins = null }
const { L } = leaflet
const answer = live.data || {}
const at = (p) => toLatLng(geometry, p.x, p.z)
for (const id of ['world', 'events', 'players', 'bases', 'pvp', 'mates']) made[id].clearLayers()
for (const id of ['world', 'events', 'players', 'bases', 'pvp', 'raids', 'mates']) made[id].clearLayers()
for (const w of answer.world || []) {
let tip = WORLD_NAMES[w.kind] || w.kind
@@ -289,6 +292,13 @@ export default function MapView({ serverId, online, onPick = null, pins = null }
.addTo(made.pvp)
}
// RaidableBases' bases (§11.4): orange, and yellow for one this site's event spawned.
for (const r of answer.raids || []) {
dot(L, at(r), r.runId ? COLOURS.raidOurs : COLOURS.raid, 7, 2)
.bindTooltip(escape(raidTip(r, Date.now())))
.addTo(made.raids)
}
for (const m of answer.mates || []) {
dot(L, at(m), m.self ? COLOURS.self : COLOURS.mate, m.self ? 8 : 6, 2)
.bindTooltip(escape(m.self ? `You${m.online ? '' : ' (asleep, offline)'}` : m.name || 'Clan mate'))
@@ -314,7 +324,7 @@ export default function MapView({ serverId, online, onPick = null, pins = null }
const map = mapRef.current
const made = groups.current
if (!map || !made) return
const want = { grid: shown.grid, monuments: shown.world, world: shown.world, events: shown.events, players: shown.players, bases: shown.bases, pvp: shown.pvp, mates: shown.mates }
const want = { grid: shown.grid, monuments: shown.world, world: shown.world, events: shown.events, players: shown.players, bases: shown.bases, pvp: shown.pvp, raids: shown.raids, mates: shown.mates }
for (const [id, on] of Object.entries(want)) {
if (on && !map.hasLayer(made[id])) made[id].addTo(map)
if (!on && map.hasLayer(made[id])) map.removeLayer(made[id])
@@ -397,6 +407,7 @@ function Legend({ meta, live, shown, onToggle }) {
players: [COLOURS.online, COLOURS.sleeping],
bases: [COLOURS.tc, COLOURS.vending],
pvp: [COLOURS.pvp],
raids: [COLOURS.raid, COLOURS.raidOurs],
}
return (

View File

@@ -59,6 +59,12 @@ export const FEED_KINDS = Object.freeze([
// like a treasure. A timeout (`gc.failed`) is staff's; the map shows it go.
'gc.started',
'gc.ended',
// RaidableBases (§11.4): a base appearing, raided, bought or locked to a
// player, read per viewer; its despawn (`raid.ended`) is staff's, and the map shows it go.
'raid.started',
'raid.completed',
'raid.purchased',
'raid.locked',
])
/** The filters the feed offers, and the kinds each one asks the API for. */
@@ -73,7 +79,7 @@ export const FILTERS = Object.freeze([
},
{ id: 'server', label: 'Server', kinds: ['server.wipe', 'server.initialized', 'server.shutdown'] },
{ id: 'bosses', label: 'Bosses', kinds: ['npc.boss.spawned', 'npc.boss.died'] },
{ id: 'world', label: 'World events', kinds: ['world.event', 'pvp.zone.created', 'dt.started', 'dt.won', 'gc.started', 'gc.ended'] },
{ id: 'world', label: 'World events', kinds: ['world.event', 'pvp.zone.created', 'dt.started', 'dt.won', 'gc.started', 'gc.ended', 'raid.started', 'raid.completed', 'raid.purchased', 'raid.locked'] },
])
export function kindsFor(filterId) {
@@ -177,6 +183,13 @@ export function describe(row) {
case 'gc.failed':
return guardedLine(row.kind, frame)
case 'raid.started':
case 'raid.completed':
case 'raid.ended':
case 'raid.purchased':
case 'raid.locked':
return raidLine(row.kind, frame)
default:
return { tone: 'other', actor: name, verb: String((row && row.kind) || 'unknown'), subject: null, detail: '' }
}
@@ -407,4 +420,46 @@ function guardedLine(kind, frame) {
: { tone: 'kill', actor: null, verb: 'The guarded crate was cleared', subject: null, detail }
}
/** "Alice", "Alice and Bob", "Alice, Bob and 3 others". */
export function raiderNames(names, count) {
const shown = (names || []).slice(0, 2)
const rest = Math.max(0, (Number(count) || shown.length) - shown.length)
if (shown.length === 0) return null
if (rest === 0) return shown.length === 2 ? `${shown[0]} and ${shown[1]}` : shown[0]
return `${shown.join(', ')} and ${rest} other${rest === 1 ? '' : 's'}`
}
/**
* RaidableBases (protocol 14, PLAN_REDESIGNS §11.4). The server has read the
* frame for this viewer: `grid`, the plugin's own `difficulty` name (D386), `pvp`,
* and the raiders' `names` or a buyer's `name` only for the presence audience
* (D376, D390); `raiderCount` for everyone.
*/
function raidLine(kind, frame) {
const base = frame.difficulty ? `${frame.difficulty} raid base` : 'raid base'
const a = /^[aeiou]/i.test(base) ? 'An' : 'A'
const detail = [frame.grid || null, frame.pvp === true ? 'PvP' : null].filter(Boolean).join(' · ')
if (kind === 'raid.started') return { tone: 'server', actor: null, verb: `${a} ${base} appeared`, subject: null, detail }
if (kind === 'raid.ended') return { tone: 'server', actor: null, verb: `${a} ${base} despawned`, subject: null, detail }
if (kind === 'raid.completed') {
const who = raiderNames(frame.names, frame.raiderCount)
if (who) return { tone: 'kill', actor: who, verb: `raided ${a.toLowerCase()} ${base}`, subject: null, detail }
const count = Number(frame.raiderCount) || 0
const by = count > 0 ? `by ${count} player${count === 1 ? '' : 's'}` : null
return { tone: 'kill', actor: null, verb: `${a} ${base} was raided`, subject: null, detail: [detail, by].filter(Boolean).join(' · ') }
}
if (kind === 'raid.purchased') {
return frame.name
? { tone: 'server', actor: frame.name, verb: `bought ${a.toLowerCase()} ${base}`, subject: null, detail }
: { tone: 'server', actor: null, verb: `${a} ${base} was bought`, subject: null, detail }
}
return frame.name
? { tone: 'server', actor: null, verb: `${a} ${base} was locked to ${frame.name}`, subject: null, detail }
: { tone: 'server', actor: null, verb: `${a} ${base} was locked to a player`, subject: null, detail }
}
export default { describe, FEED_KINDS, FILTERS, kindsFor }

View File

@@ -65,3 +65,21 @@ export function pvpTip(z) {
const name = PVP_NAMES[z.event] || z.event
return name ? `PvP zone · ${name}` : 'PvP zone'
}
// ── RaidableBases' bases (protocol 14, PLAN_REDESIGNS §11.4) ───────────────
/**
* A raid base's tooltip: "Raid base · Hard · raidhard2 · PvP · despawns in 42 min",
* and "· this site's event" for one a run spawned. The difficulty and base names are
* the plugin's own (D386).
*/
export function raidTip(r, now = Date.now()) {
const parts = ['Raid base']
if (r.difficulty) parts.push(r.difficulty)
if (r.base) parts.push(r.base)
if (r.pvp === true) parts.push('PvP')
const left = Number(r.despawnAt) - now
if (Number.isFinite(left) && left > 0) parts.push(`despawns in ${Math.max(1, Math.round(left / 60000))} min`)
if (r.runId) parts.push('this site’s event')
return parts.join(' · ')
}

View File

@@ -266,7 +266,42 @@ export function integrationsLine(r) {
const withDynamicPvp = r.integrations.dynamicPvp ? `${withTruePve} ${dynamicPvpLine(r.integrations.dynamicPvp)}` : withTruePve
const withDt = r.integrations.dangerousTreasures ? `${withDynamicPvp} ${dangerousTreasuresLine(r.integrations.dangerousTreasures, r.console)}` : withDynamicPvp
const withGc = r.integrations.guardedCrate ? `${withDt} ${guardedCrateLine(r.integrations.guardedCrate, r.console)}` : withDt
return r.integrations.zLevels ? `${withGc} ${zLevelsLine(r.integrations.zLevels)}` : withGc
const withZ = r.integrations.zLevels ? `${withGc} ${zLevelsLine(r.integrations.zLevels)}` : withGc
return r.integrations.raidableBases ? `${withZ} ${raidableBasesLine(r.integrations.raidableBases, r.console)}` : withZ
}
/**
* RaidableBases (PLAN_REDESIGNS §11.4), from protocol 14: its edition, its own
* difficulties (D386), CopyPaste, and the raids helper that makes a step's base the
* run's (D204) — and what a step may do without it (D348, D387).
*/
export function raidableBasesLine(rb, probe) {
if (!rb.loaded) {
return `RaidableBases is not loaded — no raid bases on the feed or the map, and a step cannot spawn one.${rb.helper && rb.helper.state !== 'missing' ? ' RunicGatewayRaids.cs is installed and waits for it.' : ''}`
}
const name = `RaidableBases ${rb.version || ''} (${rb.premium ? 'paid' : 'free'} edition)`.replace(' ()', '').trim()
const difficulties = Array.isArray(rb.difficulties) && rb.difficulties.length
? ` Its difficulties: ${rb.difficulties.map((d) => d.name).join(', ')}.`
: ''
if (rb.copyPaste && !rb.copyPaste.loaded) {
return `${name} is loaded but CopyPaste is missing: it cannot paste a base, and a step cannot spawn one.`
}
const state = rb.helper ? rb.helper.state : 'missing'
if (state === 'patched') {
const grid = rb.gridReady === false ? ' It is still building its spawn grid (up to ten minutes after it loads); a step waits for it.' : ''
const profiles = Array.isArray(rb.profiles) ? ` ${rb.profiles.length} profile${rb.profiles.length === 1 ? '' : 's'}.` : ''
return `${name} is loaded with RunicGatewayRaids.cs — its bases show on the feed and the map, and a step may spawn one that is the event’s: at a spot, with its own settings and lock, despawned when the event ends.${difficulties}${profiles}${grid}`
}
const helper = state === 'missing'
? 'RunicGatewayRaids.cs is not installed'
: `RunicGatewayRaids.cs could not patch it${rb.helper && rb.helper.reason ? ` (${rb.helper.reason})` : ''}`
if (rb.spawnCall) {
return `${name} is loaded — its bases show on the feed and the map. ${helper}, so a step may spawn one only where RaidableBases picks, at a difficulty, and it despawns on its own timer.${difficulties}`
}
if (probe && probe.plugins === false) {
return `${name} is loaded — its bases show on the feed and the map. ${helper}, and this framework cannot run its console command, so a step cannot spawn one (Rust-Plugins#34).`
}
return `${name} is loaded — its bases show on the feed and the map. ${helper}, so a step may spawn one only where RaidableBases picks, and it despawns on its own timer.${difficulties}`
}
/**

View File

@@ -444,7 +444,8 @@ export default function ModConfig() {
setTier('form')
}}
>
{entry.path}
{/* A RaidableBases profile (D205) travels under a virtual path; show its name. */}
{entry.profile ? `Profile · ${entry.path.split('/').pop()}` : entry.path}
</button>
<span className="sans dim" style={{ fontSize: '0.72rem' }}>
{Math.round(entry.bytes / 102.4) / 10} KB

View File

@@ -385,6 +385,7 @@ const MAP_LAYERS = [
{ id: 'players', label: 'Players', hint: 'Where everybody is, with names, and the sleepers.' },
{ id: 'bases', label: 'Bases', hint: 'Tool cupboards and vending machines, as positions only.' },
{ id: 'pvp', label: 'PvP zones', hint: 'Dynamic PVP’s own PvP zones around a downed helicopter, a Bradley, cargo and the rest. Needs Dynamic PVP on the server.' },
{ id: 'raids', label: 'Raid bases', hint: 'RaidableBases’ live bases, their difficulty and when they despawn, and which an event of this site spawned. Needs RaidableBases on the server.' },
]
const RANK = { public: 0, signed_in: 1, staff: 2 }

View File

@@ -203,8 +203,9 @@ test('every type the server knows has its own words, and an unknown one says its
assert.equal(describe(world({ event: 'meteor.landed' })).verb, 'meteor.landed')
})
test('the world filter asks for world events, Dynamic PVP zones opening, Dangerous Treasures and Guarded Crate, which the server serves publicly', () => {
assert.deepEqual(kindsFor('world'), ['world.event', 'pvp.zone.created', 'dt.started', 'dt.won', 'gc.started', 'gc.ended'])
test('the world filter asks for world events, Dynamic PVP zones opening, Dangerous Treasures, Guarded Crate and RaidableBases, which the server serves publicly', () => {
assert.deepEqual(kindsFor('world'), ['world.event', 'pvp.zone.created', 'dt.started', 'dt.won', 'gc.started', 'gc.ended', 'raid.started', 'raid.completed', 'raid.purchased', 'raid.locked'])
assert.ok(!FEED_KINDS.includes('raid.ended'), 'a raid base despawning is a staff line')
assert.ok(!FEED_KINDS.includes('dt.ended'), 'a treasure event ending is a staff line')
assert.ok(!FEED_KINDS.includes('gc.failed'), 'a guarded crate timing out is a staff line')
assert.ok(FEED_KINDS.includes('pvp.zone.created'))
@@ -299,3 +300,41 @@ test('an ending with nobody clearing it, and a timeout for a staff reader, are t
assert.equal(describe(guarded('gc.ended', { grid: 'M4', won: false })).verb, 'A guarded crate ended with nobody clearing it')
assert.equal(describe(guarded('gc.failed', { grid: 'M4' })).verb, 'A guarded crate timed out with its guards standing')
})
// ── RaidableBases (protocol 14, PLAN_REDESIGNS §11.4) ─────────────────────
//
// Every difficulty here is invented (D386): the line says the plugin's own name.
const raid = (kind, frame) => row(kind, { kind, ...frame })
test('a raid base appearing says its difficulty as the plugin named it, where, and whether it is PvP', () => {
const line = describe(raid('raid.started', { difficulty: 'Wobbly', grid: 'G7', pvp: true }))
assert.equal(line.verb, 'A Wobbly raid base appeared')
assert.equal(line.detail, 'G7 · PvP')
assert.equal(line.actor, null)
assert.equal(describe(raid('raid.started', { difficulty: 'Eerie', grid: 'G7' })).verb, 'An Eerie raid base appeared')
assert.equal(describe(raid('raid.started', { grid: 'G7' })).verb, 'A raid base appeared')
})
test('a raid names its raiders only when the server sent the names, and otherwise counts them', () => {
const named = describe(raid('raid.completed', { difficulty: 'Wobbly', grid: 'G7', names: ['Alice', 'Bob', 'Cy'], raiderCount: 4 }))
assert.equal(named.actor, 'Alice, Bob and 2 others')
assert.equal(named.verb, 'raided a Wobbly raid base')
const two = describe(raid('raid.completed', { difficulty: 'Wobbly', names: ['Alice', 'Bob'], raiderCount: 2 }))
assert.equal(two.actor, 'Alice and Bob')
const unnamed = describe(raid('raid.completed', { difficulty: 'Wobbly', grid: 'G7', raiderCount: 3 }))
assert.equal(unnamed.actor, null)
assert.equal(unnamed.verb, 'A Wobbly raid base was raided')
assert.equal(unnamed.detail, 'G7 · by 3 players')
})
test('a purchase and an admin lock name the player only when the server sent the name (D390), and a despawn is its own line', () => {
assert.equal(describe(raid('raid.purchased', { difficulty: 'Wobbly', name: 'Alice' })).actor, 'Alice')
assert.equal(describe(raid('raid.purchased', { difficulty: 'Wobbly', name: 'Alice' })).verb, 'bought a Wobbly raid base')
assert.equal(describe(raid('raid.purchased', { difficulty: 'Wobbly' })).verb, 'A Wobbly raid base was bought')
assert.equal(describe(raid('raid.locked', { difficulty: 'Wobbly', name: 'Alice' })).verb, 'A Wobbly raid base was locked to Alice')
assert.equal(describe(raid('raid.locked', { difficulty: 'Wobbly' })).verb, 'A Wobbly raid base was locked to a player')
assert.equal(describe(raid('raid.ended', { difficulty: 'Wobbly' })).verb, 'A Wobbly raid base despawned')
})

View File

@@ -8,7 +8,7 @@ import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
import { eventTip, isBoss, pvpTip, PVP_NAMES, titlesFrom, unknownRuns } from '../src/lib/mapEvents.js'
import { eventTip, isBoss, pvpTip, PVP_NAMES, raidTip, titlesFrom, unknownRuns } from '../src/lib/mapEvents.js'
const CALENDAR = {
entries: [
@@ -59,3 +59,10 @@ test('a Dynamic PVP ring says what it is around', () => {
const { GENERAL_EVENTS } = createRequire(import.meta.url)('../../server/dynamicPvp.js')
assert.deepEqual(Object.keys(PVP_NAMES).sort(), [...GENERAL_EVENTS].sort())
})
test('a raid base’s tooltip says its own difficulty and base, PvP, when it despawns, and whether an event of this site spawned it', () => {
const now = 1_000_000
assert.equal(raidTip({ difficulty: 'Wobbly', base: 'wobble3', pvp: true, despawnAt: now + 42 * 60000 }, now), 'Raid base · Wobbly · wobble3 · PvP · despawns in 42 min')
assert.equal(raidTip({ difficulty: 'Wobbly', runId: '7' }, now), 'Raid base · Wobbly · this site’s event')
assert.equal(raidTip({ despawnAt: now - 1 }, now), 'Raid base')
})