Frostdev

KilnAPI reference Guide

The buffs registry

Every buff and debuff the game defines (food buffs, Well Rested, Poisoned, Burning, the slows and the shields of spells and potions): how long one lasts, what applying it again does, how strong it is and how often it acts, and (raw, for power users) every config it carries by id.

Schema version 0.1.2, experimental (KILNX031: may change in any release until it is marked stable). C# entry type Kiln.Registry.BuffEntry. What registries are, the stages, the conflict rules and how ids are made: README.

Edits per call: 4,096. One OnRegistry callback (one phase of one entry point) or one Registries.Change takes at most this many edits of this registry; a call with more is refused whole, with the reason in kiln.log and registry.json, and nothing of it applies (the other calls do). The default for a registry whose schema declares none (4,096).

Ids

  • Game entries: game:buff_<its 32-bit buff id as 8 hex digits>. Mod entries: <mod id>:<name>. All ids are lower case. The mod ids game and kiln are reserved: no mod's entries use them.
  • A game buff has no debug name: its stable name is buff_ and its 32-bit buff id in lower-case hex (the id kiln.gamedata shows, and the one saves and the network carry), so the buff kiln.gamedata calls buff_cdbe9c80 is game:buff_cdbe9c80. A buff a mod adds is :; a kiln.gamedata clone or status block of a mod is :<its name without the "." in front>.
  • Names: DisplayName (never empty; display names) is the game's text of the buff's name, else the name the mod that added a buff clone gives it, else one made from its id (game:buff_1a2b3c4d is "Buff 1a2b3c4d").

Fields

Applies: now = takes effect at the next use; worldLoad = takes effect when a world loads; restart = takes effect after a game restart. Ops: number = a value or the relative operations (mul, add, min, max, raiseOnly, lowerOnly); set = a value; list = clear, append, remove, replace; indexed = a list of fixed length, edited one element at a time (xpPerLevel[2]) with a value or a number operation. A field of a list's elements is named with [] in this table and with the element's index in an edit (entries[3].chance, or [*] for every element). Mapping: whether this Kiln maps the field onto the game; an unproven or unmapped field is refused per entry, with the reason, until a Kiln update maps it. Joined client: when a joined Kiln client consumes a server edit; see README.

Groups of fields:

  • tick: How often a buff that acts again and again (a burn, a shock, a poison that spawns its damage) acts while it runs.
Field Type Applies Ops Since Mapping Joined client About
duration time s 0..86400 now number 0.1.0 mapped serverOnly How long the buff lasts when it is applied without a time of its own (an item, an ability or a program that gives one overrides it; a food buff's time is also scaled by the world's food buff duration setting). The next new application takes it; a buff already running keeps its end, and applying it again while it runs (refresh) restarts it with the length it started with.
stacking enum (keep, refresh, replace, replaceAtEnd) now set 0.1.0 mapped serverOnly What applying the buff again does while it runs: keep (the running one stays and the new one is refused), refresh (the running one starts its time again), replace (the running one ends and a new one starts, its effects with it). replaceAtEnd: on this game build the game applies it as replace. A buff in the same place as another buff (a food slot) always replaces it.
kind enum (food, buff, debuff, rested, terrain) now read-only 0.1.0 mapped serverOnly Where the buff sits on a character: a food slot, the buffs, the debuffs, the rested slot or the terrain debuff slot.
saved bool now read-only 0.1.0 mapped serverOnly The buff stays on a character through a save and a load.
magnitude float -1000000..1000000 now number 0.1.1 mapped now How strong the buff is: its one amount, whatever it changes (a slow's share of movement speed, below 0; a burn's damage per tick; the damage modifier of a shock's ticks; a regeneration's points; an attribute's change). A buff with no amount of its own, or with more than one (the food buffs, an explosion's damage and radius), has none: an edit of it is refused for that buff, and its value reads null. The next application takes it; a buff already running keeps the amount it started with. An item that applies the buff with an amount of its own overrides it every time that item applies it (the item's amount replaces the buff's as the buff starts): the buffs of the bandages and of the health and fog potions carry 0 for their item to fill, and a bad food's slow carries its food's, so an edit of such a buff is applied to the buff but changes nothing where its item applies it: edit the item's own amount instead (items.restore.health and healthShare, restore.manaGain, bonus.movement, bonus.attribute, gem.debuffDamageMod; since 0.2.0-dev.32's items 0.1.3 and 0.1.4; the fog potion's, bonus.fellDamage, since items 0.1.5). A buff whose game value is a whole number takes whole numbers only (a fraction is refused, never rounded); its tooltip row follows.
tick.interval time s 0..3600 now number 0.1.1 mapped serverOnly The time from one of the buff's ticks to the next, in seconds (0: every game step). Only the buffs whose way of ticking Kiln knows and that carry the time themselves have one; other buffs read null and refuse an edit. The next application takes it; a buff already running keeps its interval.
configs map: config id (0x and 8 hex digits) to the config's own kind, raw now number 0.1.2 mapped (raw: what a key means is not proven) unknown Raw: every config the buff's record carries, by the game's config id (an edit names one: configs.0x and its 8 hex digits), each valued by its own kind on that buff: a whole number (sint32, uint32: a fraction is refused, never rounded), a number (float), a time in seconds, true or false, or one of an enum config's value names as the game names them. A reference config (a buff, a template, an attribute) or a material id is read, never written, and a buff takes no key it does not carry. What a config does is the buff's program's, and one id means different things in different programs: Kiln proves on each game build that an edit is read, written and taken back, never what a key means, so mods use it at their own risk. A key that is the buff's magnitude or tick interval is that field: the two names are one value, the later edit wins and Conflicts shows both. The next application takes an edit; a buff already running keeps what it started with, and an item that applies the buff with a config of its own (a food, a potion) overrides it. The raw tier: an edit names one key (configs.0x<8 hex digits>); Kiln proves its read, write and revert per game build, never what a key means.

Entries

  • Add (stage add, id <your mod id>:<name>): yes. GameStart only. A copy of a game buff's record (its program, configs and look) under the mod's id, made by kiln.gamedata's buff clones (they take a record of the process's buff room). Buff clones a mod makes through kiln.gamedata or a status block are entries of their mod too.
  • Add requires GameStart and an explicit present Kiln like id; clone chains end at a game entry. Kiln retains the stable identity and pins the structural base install-wide. Use a new id for an incompatible base.
  • Remove: no. Buffs are never removed: a character's save and a running effect name a buff by its id.
  • Raw game paths in edits (the Advanced tier): refused.

Edit it from a data pack

buffs is kiln.gamedata's buff data under Kiln names. A game buff has no debug name: its id is game:buff_<its 32-bit id as 8 hex digits> (game:buff_5f425faf is the Poisoned debuff, the id kiln.gamedata shows). Fields: duration (seconds), stacking (what applying it again does), magnitude (its one amount) and tick.interval (a ticking buff's wait between ticks, seconds; both buffs 0.1.1), the raw map configs (every config the buff carries by the game's id; buffs 0.1.2), and the read-only kind and saved.

  • "field": "duration", "op": 20; "field": "stacking", "op": "refresh".
  • magnitude is the buff's one amount, whatever it changes (a slow's share of movement speed below 0, a burn's fire damage per tick, a regeneration's points). Only a buff that carries exactly one amount has it (56 of the game's 274 on this build); a buff with none or with several (the food buffs) reads null and refuses an edit for that buff alone, so a relative op needs a selection of buffs that have one. A whole-number amount refuses a fraction (not_exact).
  • An item that applies a buff with an amount of its own replaces the buff's amount every time it applies it: the bandages', the health and fog potions', a bad food's slow and the bleed and burn gems' buffs are edited through the item's field (items restore.*, bonus.*, gem.*), not magnitude (an edit of such a buff's magnitude is applied and reported applied, but changes nothing where its item applies it).
  • tick.interval is the config the buff's program waits on between two ticks (a burn, a shock, a poison that spawns its damage); Kiln maps the programs it has read, so a buff of another program, or one whose record leaves the time to its program, reads null.
  • magnitude and tick.interval are read when the buff starts: the next application takes an edit, a running buff keeps what it started with.
  • configs is raw (at your own risk): "field": "configs.0xf76e2e08", "op": {"mul": 2} edits one config by the game's id, in the kind it has on that buff (whole numbers refuse a fraction, enum takes the config's own value names, reference, scaled and other are read-only). Kiln proves the edit is read, written and taken back, never what a key does; a key that is the buff's magnitude or tick interval is that field (one value, two names: the later edit wins, Conflicts shows both). A buff without the key refuses the edit; the raw map adds no config (the raw map).
  • A buff applied with a time of its own (an item, an ability or a program that gives one) keeps it: duration is the time of an application that gives none. A food buff's time is also scaled by the world's food buff duration setting.
  • No raw paths and no entry remove. Entry add (0.2.0-dev.32, GameStart only): {"registry": "buffs", "entry": "add", "id": "<mod>:<name>", "like": "game:buff_5f425faf"} (C# Buffs.AddLike) is a kiln.gamedata buff clone of the like buff (one record of the process's buff room); the fields given are its own. A buff clone a mod makes through kiln.gamedata or a status block is an entry of its mod too (<mod>:<its name without "<mod>.">): registry.json lists it, other mods' edits reach it. The old buffs data-pack section (the game's own paths) keeps working; a registry edit is the later layer and wins (reported).

Edit it from C#

[RegistryEntryPoints(RegistryEntryPoint.GameStart | RegistryEntryPoint.WorldLoad | RegistryEntryPoint.HotReload)]
public sealed class Poison : Mod
{
    public override void OnRegistry(RegistryContext context)
    {
        if (!Kiln.Registry.Registries.Available) return;                      // kiln.registry: the host's registry transport
        Kiln.Registry.Registries.For(context).Alter(stage =>
        {
            var poisoned = stage.Buffs["game:buff_5f425faf"];
            poisoned.Duration = TimeSpan.FromSeconds(20);
            Log.Info($"Poisoned: {poisoned.Duration.TotalSeconds:0} s, {poisoned.Kind}, applied again: {poisoned.Stacking}");
        });
    }
}

stage.Buffs is a RegistryEntries<BuffEntry> (Duration a TimeSpan, Stacking a BuffStacking, Magnitude a double, Tick.Interval a TimeSpan, Configs a RegistryRawMap, Kind and Saved read-only; a buff without a value reads 0: tell such buffs by id, never by a 0). burn.Configs[0xf76e2e08] is one config (Kind, Value, Values) or null, burn.Configs.Set(key, value) sets it. The complete mod: SpellRegistry sample.

Views

RegistryViews.Find("buffs") is the stable view; abilities.timing.buff moves when an ability applies a buff, this registry says how long it lasts (abilities, views.md).

Worked example

Poisoned lasts 20 seconds and a second application restarts it:

{
  "format": 1,
  "registry": {
    "alter": [
      { "registry": "buffs", "select": { "id": "game:buff_5f425faf" }, "field": "duration", "op": 20 },
      { "registry": "buffs", "select": { "id": "game:buff_5f425faf" }, "field": "stacking", "op": "refresh" }
    ]
  }
}

The next new application takes the time; a buff already running keeps its end.

In multiplayer

Buff fields are the server's alone (serverOnly): the server applies the buff and a client shows the time the server gave it. magnitude is the exception (now): a buff's tooltip row that shows its amount follows on Kiln clients through the content sync. A pack of buff edits is clients: none, or kiln for magnitude's tooltip (choosing clients).

Known limits

  • replaceAtEnd is applied by the game as replace on this build. A buff in the same place as another (a food slot) always replaces it, whatever stacking says.
  • A running buff keeps its end; refresh restarts it with the length it started with.
  • A food buff's amounts are its food's (the buff reads null); see the items fields above for the buffs items fill.
  • tick.interval covers only the programs Kiln has read; a game update that changes a mapped program under the same id is checked by regmap_check.py --exe, not by the proof.
  • Not yet seen in a real game: a buff's timing on a joined client, a changed magnitude or tick rate in play.

Enshrouded is a trademark of Keen Games GmbH. Kiln is unofficial.