docs(runicnpc): stage 4 built and walked; protocol 13 §19.12; API 3
PROTOCOL.md §19.12: RunicNPC over the bridge — integrations.runicNpc, the npc.profiles, npc.profiles.set, npc.placements and npc.placement commands and their refusals, the npc.died, npc.health and npc.placement.changed frames, world.place with a profile, attackerNpc and attackerProfile, the tally's npcProfileKills, the four sidecar routes, and overlay.toml's runicnpc_api. API.md: API 3 — RunicNpc_AddPlacement, RunicNpc_RenamePlacement, RunicNpc_RespawnPlacement and OnRunicNpcPlacementChanged. PLAN.md stage 4: what was built in five repositories, the walk on both rigs row by row, what was not walked and why, and what building it found. rust-link/INSTALL.md: RunicNPC as the bundle's third file, by hand, the egg, doctor and uninstall. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
# RunicNPC — the API
|
||||
|
||||
**API version 2** (RunicNPC stage 2, 2026-09-30). This is the reference for other plugins. Why it has this
|
||||
shape is in [PLAN.md](PLAN.md) §4 and the decisions D221–D238.
|
||||
**API version 3** (RunicNPC stage 4, 2026-09-30). This is the reference for other plugins. Why it has this
|
||||
shape is in [PLAN.md](PLAN.md) §4 and the decisions D221–D238 and D249. **API 3 added** `RunicNpc_AddPlacement`,
|
||||
`RunicNpc_RenamePlacement`, `RunicNpc_RespawnPlacement` and the hook `OnRunicNpcPlacementChanged`, for a
|
||||
website that lists, edits and creates placements (PLAN.md stage 4); nothing of API 2 changed.
|
||||
|
||||
RunicNPC is called by name through `Call`, like any Oxide or Carbon plugin API. Every call is prefixed
|
||||
`RunicNpc_`, so no hook of another plugin is ever matched by accident. Every call is a non-public method, which is
|
||||
@@ -11,7 +13,7 @@ what Oxide's `Call` reaches by name (PLAN.md §1.2).
|
||||
[PluginReference] private Plugin RunicNPC;
|
||||
|
||||
int api = RunicNPC?.Call<int>("RunicNpc_ApiVersion") ?? 0;
|
||||
if (api < 2) { /* too old for this caller: say so */ }
|
||||
if (api < 3) { /* too old for this caller: say so */ }
|
||||
|
||||
BasePlayer npc = RunicNPC.Call("RunicNpc_Spawn", position, "warden", "plugin:MyPlugin", null) as BasePlayer;
|
||||
```
|
||||
@@ -41,7 +43,7 @@ Every NPC has an owner, and the owner decides its lifetime (PLAN.md §2).
|
||||
|
||||
### `RunicNpc_ApiVersion()` → `int`
|
||||
|
||||
The API version: `2`.
|
||||
The API version: `3`.
|
||||
|
||||
### `RunicNpc_Spawn(Vector3 at, string profile, string owner, JObject overrides)` → `BasePlayer`
|
||||
|
||||
@@ -117,6 +119,30 @@ in the air.
|
||||
|
||||
Removes a placement and its NPCs.
|
||||
|
||||
### `RunicNpc_AddPlacement(JObject placement)` → `Dictionary<string, object>`
|
||||
|
||||
API 3. **Creates a placement and names it as `rnpc place` does**: the profile's name and the first free
|
||||
number, `warden-3` (D241, D246). It is checked and refused exactly as `rnpc place` is, with the same
|
||||
sentences, so a placement made from a website and one made in game can never disagree.
|
||||
|
||||
- `placement` is a placement (below) without an id. **A `position` without `y` is a point on a map**
|
||||
(D245): it is put on the ground there by a ray down on terrain and rock, never a building or a tree (a
|
||||
roof is placed in game), then checked against the navmesh like any other. A point off the map, or under
|
||||
water, is refused.
|
||||
- The answer is `{id, position, built, cost}`: the name given, where it landed, whether that spot is on
|
||||
something players built (D239's warning), and the cost warning (D227). Or `{error}`, the sentence
|
||||
`rnpc place` would have said.
|
||||
|
||||
### `RunicNpc_RenamePlacement(string from, string to)` → `string`
|
||||
|
||||
API 3. Renames a placement, as `rnpc rename`: its live NPCs keep living under the new name. Null on
|
||||
success, or why not (no such placement, the name taken, not a name).
|
||||
|
||||
### `RunicNpc_RespawnPlacement(string id)` → `int`
|
||||
|
||||
API 3. Removes a placement's NPCs and spawns them again at once, as `rnpc respawn`. How many, or `-1` if
|
||||
there is no such placement.
|
||||
|
||||
### `RunicNpc_Routes()` → `JObject`
|
||||
|
||||
`{name: route, …}`.
|
||||
@@ -157,6 +183,7 @@ All are called on every plugin, and **none of them answers**: a return value is
|
||||
| `OnRunicNpcHealth(BasePlayer npc, string profile, float threshold)` | The first time its health falls to one of the profile's `healthThresholds`. |
|
||||
| `OnRunicNpcDied(BasePlayer npc, string profile, string owner, HitInfo info, Dictionary<ulong, float> contributors)` | When it dies. `contributors` maps each player's Steam id to the health that player took from it, the killing blow included, after Rust's protection. It never adds up to more than its health. |
|
||||
| `OnRunicNpcDespawned(BasePlayer npc, string owner)` | When it is removed without dying. Not raised as RunicNPC itself unloads. |
|
||||
| `OnRunicNpcPlacementChanged(string id, string change, string previous)` | API 3. Whenever a placement is set, removed or renamed, through the API or in game. `change` is `set`, `removed` or `renamed`; `previous` is the old name for a rename and null otherwise. |
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user