feat(rust): Dangerous Treasures — feed, map, Treasure Hunter, Start a Dangerous Treasures event (PLAN_REDESIGNS §14.3.4)
Stage 5 of the §14.3 integration plan, on protocol 14 (docs rust-link/PROTOCOL.md §20.8). - dt.started and dt.won are public kinds, dt.ended a staff kind. The new dangerousTreasures.js reads each row per viewer: grid and invaderCount for everyone, the winner's name for the presence audience (D376), the position, the step's key, the winner's Steam id and the invaders for staff. - Feed lines in the World events filter: "A Dangerous Treasures event has started · K12", "Alice won the treasure · K12 · 3 players fought for it". - Triggers rust.dt.started (with byEvent) and rust.dt.won, public, cooldown subject the server, names only. - eventDangerousTreasures.js: rust.dt.start, "Start a Dangerous Treasures event" (risk change, reversible none, budget rust.dt.events), server and difficulty. Refused at verify where the server said DT is not loaded or console.plugins is false (Rust-Plugins#34). dt-not-ready answers "Dangerous Treasures is not ready yet" with retryAfterMs 600000 (D365, D371); dt-no-spot retries on core's delay; DT's own refusals are permanent. - Treasure Hunter (D375): treasuresWon -> treasures_won, the title category treasureswon, and a sortable Treasures column shown where the server reports DT or a row counts one. - The map draws a running chest on the world layer; the server settings' plugin line names DT and whether a step can start one, from the integrations read's new `console`. - coreApi ^1.15.0, ci/core-ref.json pinned to website main at #215's merge. ci/bundle.json ships the two new files; swagger fragment and engagement manifest regenerated; README lists DT. Server 627/627 (16 new in test/dangerousTreasures.test.js) and every check; client 92/92, build and externals. Booted against the pinned core: 45 triggers, 13 actions, 11 budgets, 21 option sources; 89 routes unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
@@ -177,6 +177,16 @@ const HEADLINES = Object.freeze({
|
||||
title: `${d.boss} is down to ${d.percent}% on ${d.server}`,
|
||||
intro: `${d.boss} fell to ${d.percent}% of its health on ${d.server} and entered phase ${d.phase}.`,
|
||||
}),
|
||||
// Dangerous Treasures (protocol 14, §14.3.4). A missing grid drops out.
|
||||
'rust.dt.started': (d) => ({
|
||||
title: `A treasure event has started on ${d.server}`,
|
||||
intro: `A Dangerous Treasures chest opened${d.grid ? ` at ${d.grid}` : ''} on ${d.server}. It is guarded, and it is burning.`,
|
||||
}),
|
||||
'rust.dt.won': (d) => ({
|
||||
title: `The treasure was won on ${d.server}`,
|
||||
intro: `${d.player || 'Somebody'} won the treasure${d.grid ? ` at ${d.grid}` : ''} on ${d.server}`
|
||||
+ `${d.invaders > 1 ? `, with ${d.invaders} players fighting for it` : ''}.`,
|
||||
}),
|
||||
'rust.boss.killed': (d) => ({
|
||||
title: `${d.boss} was killed on ${d.server}`,
|
||||
intro: `${d.killer ? `${d.killer} landed the killing blow` : `${d.boss} fell`}`
|
||||
@@ -561,7 +571,43 @@ async function onWorld(server, item, frame) {
|
||||
}) ? 1 : 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Dangerous Treasures (protocol 14, §14.3.4): a chest opened, and one won.
|
||||
* Public news, so a replay older than a broadcast's window tells nobody (D63).
|
||||
* The grid comes from the map's geometry, as the feed's does; the winner by
|
||||
* in-game name only, never a Steam id. An ending raises nothing.
|
||||
*/
|
||||
async function onDangerousTreasures(server, item, frame) {
|
||||
const t = frameTime(item, frame)
|
||||
if (!stillNews(t, BROADCAST_MAX_AGE_MS)) return 0
|
||||
|
||||
const meta = frame.x !== undefined ? await mapDb.getMeta(server.id).catch(() => null) : null
|
||||
const grid = meta ? worldEvents.gridOf({ worldSize: Number(meta.worldSize), gridCells: Number(meta.gridCells), gridCellSize: Number(meta.gridCellSize) }, frame.x, frame.z) : null
|
||||
const data = { ...serverVars(server), subject: `${server.id}:${frame.kind}`, ...(grid ? { grid } : {}) }
|
||||
|
||||
if (frame.kind === 'dt.started') {
|
||||
return fire(T['rust.dt.started'], {
|
||||
data: { ...data, byEvent: Boolean(str(frame.key)) },
|
||||
dedupeKey: dedupeKey('dt.started', server.id, t, frame.x, frame.z),
|
||||
occurredAt: t,
|
||||
}) ? 1 : 0
|
||||
}
|
||||
|
||||
const invaders = Number(frame.invaderCount)
|
||||
return fire(T['rust.dt.won'], {
|
||||
data: {
|
||||
...data,
|
||||
...(str(frame.name) ? { player: str(frame.name) } : {}),
|
||||
invaders: Number.isInteger(invaders) && invaders >= 0 ? invaders : Array.isArray(frame.invaders) ? frame.invaders.length : 0,
|
||||
},
|
||||
dedupeKey: dedupeKey('dt.won', server.id, t, frame.steamId, frame.x, frame.z),
|
||||
occurredAt: t,
|
||||
}) ? 1 : 0
|
||||
}
|
||||
|
||||
const HANDLERS = Object.freeze({
|
||||
'dt.started': onDangerousTreasures,
|
||||
'dt.won': onDangerousTreasures,
|
||||
'world.event': onWorld,
|
||||
'npc.boss.spawned': onBoss,
|
||||
'npc.boss.phase': onBoss,
|
||||
|
||||
@@ -622,7 +622,54 @@ const WORLD = WORLD_EVENTS.map(([event, label, description, vars]) => ({
|
||||
variables: [...SERVER, ...HEADLINE, WORLD_SUBJECT, ...vars],
|
||||
}))
|
||||
|
||||
const TRIGGERS = Object.freeze([RAID, ...BROADCASTS, ACCOUNT, REWARD, ...CLANS, ...MODERATION, ...NPCS, ...BOSSES, ...WORLD])
|
||||
// ── Dangerous Treasures (protocol 14, PLAN_REDESIGNS §14.3.4, §14.3.9) ──────
|
||||
//
|
||||
// A treasure event opening and being won are triggers, as a world event is
|
||||
// (D355): public news, `everyone` the ceiling and `subscribers` the default.
|
||||
// The cooldown subject is the server, so a busy hour of treasures is one line
|
||||
// per cooldown. `player` is the winner's in-game name only; no Steam id is
|
||||
// declared. Its ending is staff's on the feed and raises nothing.
|
||||
|
||||
const DT_SUBJECT = { name: 'subject', type: 'string', required: true, example: 'main:dt.won',
|
||||
description: 'The server and the event. The cooldown subject; not meant for display.' }
|
||||
const DT_BY_EVENT = { name: 'byEvent', type: 'boolean', required: true, example: false,
|
||||
description: 'Whether one of this site\'s events started it (a Start a Dangerous Treasures event step).' }
|
||||
|
||||
const DANGEROUS_TREASURES = [
|
||||
{
|
||||
id: 'rust.dt.started',
|
||||
label: 'A treasure event started',
|
||||
description: 'Dangerous Treasures opened a guarded, burning treasure chest on a server: on its own schedule, by an admin, or by an event.',
|
||||
kind: 'event',
|
||||
subjectKey: 'subject',
|
||||
audience: 'subscribers',
|
||||
ceiling: 'everyone',
|
||||
version: V1,
|
||||
variables: [...SERVER, ...HEADLINE, DT_SUBJECT, WORLD_GRID, DT_BY_EVENT],
|
||||
},
|
||||
{
|
||||
id: 'rust.dt.won',
|
||||
label: 'A treasure was won',
|
||||
description: 'A player emptied a Dangerous Treasures chest on a server.',
|
||||
kind: 'event',
|
||||
subjectKey: 'subject',
|
||||
audience: 'subscribers',
|
||||
ceiling: 'everyone',
|
||||
version: V1,
|
||||
variables: [
|
||||
...SERVER,
|
||||
...HEADLINE,
|
||||
DT_SUBJECT,
|
||||
WORLD_GRID,
|
||||
{ name: 'player', type: 'string', required: false, example: 'Marisol',
|
||||
description: 'Who emptied the chest, by in-game name.' },
|
||||
{ name: 'invaders', type: 'int', required: true, example: 3,
|
||||
description: 'How many players fought for it, the winner included.' },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
const TRIGGERS = Object.freeze([RAID, ...BROADCASTS, ACCOUNT, REWARD, ...CLANS, ...MODERATION, ...NPCS, ...BOSSES, ...WORLD, ...DANGEROUS_TREASURES])
|
||||
|
||||
const TRIGGER_IDS = Object.freeze(Object.fromEntries(TRIGGERS.map((t) => [t.id, t.id])))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user