Frostdev

KilnAPI reference Guide

The balance registry

The game's balance table: experience and levels, the flame's altars and water sources, base fog resistance, durability, sockets and perk unlock costs. Kiln writes it at the start, so an edit applies after a restart (the game reads most of it at each use; Kiln has no live back-end for it yet).

Schema version 0.1.5, experimental (KILNX031: may change in any release until it is marked stable). C# entry type Kiln.Registry.BalanceEntry. 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:balance. Mod entries: (none: one entry). All ids are lower case. The mod ids game and kiln are reserved: no mod's entries use them.
  • One entry, game:balance.
  • Names: DisplayName (never empty; display names) is the registry's name as words ("Balance"): its one entry is no game thing with a name of its own.

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:

  • xpCurve: The experience a level from 6 needs: base = min(start, end) + |end - start| * level / levelMax; need = round(base * seed * 1.5 + fromKnowledge).
  • fogResistance: A player's shroud time (also named shroudTime, the word the items registry uses: armor.shroud, damage.shroud).
  • durability: An item's maximum durability: (start + growth * (level - 1)) * rarityDurability[rarity]. Each copy computes it when it is loaded.
  • rarityDurability: The durability factor of each rarity.
  • socketChance: The chance a new weapon of each rarity gets a gem socket (0 to 1).
  • unlockCost: What unlocking a perk costs.
  • gear: The constants of the power and armour formulas (items.power, items.armor). Read-only in this version: Kiln's solver follows them.
  • salvage: What the game's salvage (an item's Trash) gives back for each unlocked upgrade, as a multiple of the upgrade's cost: start at level 0, end at level 100, in proportion between.
  • fishing: The fishing fight per difficulty: one set for each value of the world setting fishingDifficulty (very easy to very hard). Read at each bite, by the world's difficulty then.
  • fishing.veryEasy: The fishing fight at the difficulty very easy.
  • fishing.easy: The fishing fight at the difficulty easy.
  • fishing.normal: The fishing fight at the difficulty normal.
  • fishing.hard: The fishing fight at the difficulty hard.
  • fishing.veryHard: The fishing fight at the difficulty very hard.
  • skillPoints: Startup skill-point rewards for roots and wells. Per-entry knowledge reward edits take precedence.
Field Type Applies Ops Since Mapping Joined client About
xpPerLevel list of int 0..100000000, exactly 5 restart indexed 0.1.0 mapped restart The experience levels 1 to 5 need (later levels follow xpCurve). Exactly 5 values, edited one at a time (xpPerLevel[i]).
xpCurve.start int 0..100000000 restart number 0.1.0 mapped restart One end of the curve's base range (base = min(start, end) + /end - start/ * level / levelMax).
xpCurve.end int 0..100000000 restart number 0.1.0 mapped restart The other end of the curve's base range.
xpCurve.levelMax int 1..100000 restart number 0.1.0 mapped restart The level at which the base has moved the whole way from one end of the range to the other (also named playerLevelMax). The game reads it beyond the experience curve: the enemy damage formulas divide a player's level by it too (hits to kill and a player's expected health at a level), so a change moves how hard enemies hit at each level as well.
xpCurve.seed int 0..100000000 restart number 0.1.0 mapped restart The factor the base is multiplied by (with 1.5) to give the experience a level needs.
xpCurve.fromKnowledge int 0..100000000 restart number 0.1.0 mapped restart Experience added to every level's need after the factor.
levelCap int 1..1000 restart number 0.1.0 mapped restart The highest player level.
skillPointsPerLevel int 0..1000 restart number 0.1.0 mapped restart Skill points a level gives.
flameLevelMax int 0..1000 restart read-only 0.1.0 mapped restart The highest flame level. Read-only in this version: the per-flame-level lists are exactly flameLevelMax + 1 long.
altarsPerFlameLevel list of int 0..255, as long as flameLevelMax + 1 restart indexed 0.1.0 mapped restart Flame altars allowed at each flame level, one value per level from 0 to flameLevelMax. The game's code allows at most 16 whatever the table says; limits.maxAltars raises that (since dev.32): a level above limits.maxAltars allows limits.maxAltars, and kiln.log says so. Edited one level at a time (altarsPerFlameLevel[i]).
waterSourcesPerFlameLevel list of int 0..255, as long as flameLevelMax + 1 restart indexed 0.1.0 mapped restart Water sources allowed at each flame level, one value per level from 0 to flameLevelMax. Edited one level at a time.
buildzoneSizesPerAltarLevel list of entries, at most 1001 restart list 0.1.0 mapped restart The size of an altar's build zone at each altar level, in metres.
buildzoneSizesPerAltarLevel[].x float m 0..100000 restart number 0.1.0 mapped restart The build zone's size along x, in metres.
buildzoneSizesPerAltarLevel[].y float m 0..100000 restart number 0.1.0 mapped restart The build zone's size along y (height), in metres.
buildzoneSizesPerAltarLevel[].z float m 0..100000 restart number 0.1.0 mapped restart The build zone's size along z, in metres.
fogResistance.base int 0..100000 restart number 0.1.0 mapped restart A player's shroud time before any flame level.
fogResistance.perFlameLevel int 0..100000 restart number 0.1.0 mapped restart The shroud time each flame level adds.
durability.start float 0..1000000 restart number 0.1.0 mapped restart The maximum durability of a level 1 item, before the rarity factor.
durability.growth float 0..1000000 restart number 0.1.0 mapped restart The maximum durability each item level above 1 adds, before the rarity factor.
rarityDurability.common float 0..100 restart number 0.1.0 mapped restart The durability factor of common items.
rarityDurability.uncommon float 0..100 restart number 0.1.0 mapped restart The durability factor of uncommon items.
rarityDurability.rare float 0..100 restart number 0.1.0 mapped restart The durability factor of rare items.
rarityDurability.epic float 0..100 restart number 0.1.0 mapped restart The durability factor of epic items.
rarityDurability.legendary float 0..100 restart number 0.1.0 mapped restart The durability factor of legendary items.
socketChance.common float 0..1 restart number 0.1.0 mapped restart The chance a new common weapon gets a gem socket.
socketChance.uncommon float 0..1 restart number 0.1.0 mapped restart The chance a new uncommon weapon gets a gem socket.
socketChance.rare float 0..1 restart number 0.1.0 mapped restart The chance a new rare weapon gets a gem socket.
socketChance.epic float 0..1 restart number 0.1.0 mapped restart The chance a new epic weapon gets a gem socket.
socketChance.legendary float 0..1 restart number 0.1.0 mapped restart The chance a new legendary weapon gets a gem socket.
unlockCost.seed int 0..100000 restart number 0.1.0 mapped restart The base cost of a perk unlock, before the creep and the kind's factor.
unlockCost.creep float 0..100 restart number 0.1.0 mapped restart How much the cost grows with each unlock step, as a factor of the base.
unlockCost.weapons float 0..100 restart number 0.1.0 mapped restart The cost factor of weapon and shield perks.
unlockCost.armor float 0..100 restart number 0.1.0 mapped restart The cost factor of armour perks.
unlockCost.rings float 0..100 restart number 0.1.0 mapped restart The cost factor of ring perks.
unlockCost.advanced float 0..100000 restart number 0.1.0 mapped restart The numerator of an advanced perk's cost.
unlockCost.advancedFrom int 0..5 restart number 0.1.0 mapped restart The perk level (0 to 5) from which the advanced cost applies.
unlockCost.item ref items, optional restart read-only 0.1.2 mapped restart The item an upgrade costs and a salvage gives back (the runes).
gear.seed float 0..100000 restart read-only 0.1.0 mapped serverOnly The base of the damage power formula: base power = int(seed * creep * level + seed).
gear.creep float 0..100 restart read-only 0.1.0 mapped serverOnly The share of seed the base power grows by with each level.
gear.armorOffset float 0..100000 restart read-only 0.1.0 mapped serverOnly The armour formula's offset: armour = round((armorGradient * level + armorOffset) * share).
gear.armorGradient float 0..100000 restart read-only 0.1.0 mapped serverOnly The armour each level adds in the armour formula, before the item's share.
salvage.start int 0..1000 restart number 0.1.2 mapped restart The multiple of an unlocked upgrade's cost the salvage gives back at level 0.
salvage.end int 0..1000 restart number 0.1.2 mapped restart The multiple of an unlocked upgrade's cost the salvage gives back at level 100.
gemSalvage float 0..1000 restart number 0.1.4 mapped restart What recycling a gem at the Gem Forge gives back, as a share of what its upgrades cost (0.5: half, the game's own). Read at each recycle.
fishing.veryEasy.advancedMinigame bool restart set 0.1.4 mapped restart Whether a bite can start the harder fight (the game's own: off at very easy, on at the others).
fishing.veryEasy.fewerRounds int 0..255 restart number 0.1.4 mapped restart How many rounds fewer a fight has (the game's own: 6 at easy, 0 at the others).
fishing.veryEasy.rodStrength float 0..1000 restart number 0.1.4 mapped restart A factor on the rod's strength in the fight: higher is easier (the game's own: 1.5 at very easy, 1.25, 1, 0.9, 0.9 at very hard).
fishing.veryEasy.rodEndurance float 0..1000 restart number 0.1.4 mapped restart A factor on the rod's endurance in the fight: higher is easier (the game's own: 1.5 at very easy, 1.25, 1, 1, 0.8 at very hard).
fishing.veryEasy.quickTimeEvents float 0..1000 restart number 0.1.4 mapped restart A factor on the fight's quick-time prompts: higher is easier (the game's own: 1.5 at very easy, 1.25, 1.25, 1, 0.8 at very hard).
fishing.easy.advancedMinigame bool restart set 0.1.4 mapped restart Whether a bite can start the harder fight (the game's own: off at very easy, on at the others).
fishing.easy.fewerRounds int 0..255 restart number 0.1.4 mapped restart How many rounds fewer a fight has (the game's own: 6 at easy, 0 at the others).
fishing.easy.rodStrength float 0..1000 restart number 0.1.4 mapped restart A factor on the rod's strength in the fight: higher is easier (the game's own: 1.5 at very easy, 1.25, 1, 0.9, 0.9 at very hard).
fishing.easy.rodEndurance float 0..1000 restart number 0.1.4 mapped restart A factor on the rod's endurance in the fight: higher is easier (the game's own: 1.5 at very easy, 1.25, 1, 1, 0.8 at very hard).
fishing.easy.quickTimeEvents float 0..1000 restart number 0.1.4 mapped restart A factor on the fight's quick-time prompts: higher is easier (the game's own: 1.5 at very easy, 1.25, 1.25, 1, 0.8 at very hard).
fishing.normal.advancedMinigame bool restart set 0.1.4 mapped restart Whether a bite can start the harder fight (the game's own: off at very easy, on at the others).
fishing.normal.fewerRounds int 0..255 restart number 0.1.4 mapped restart How many rounds fewer a fight has (the game's own: 6 at easy, 0 at the others).
fishing.normal.rodStrength float 0..1000 restart number 0.1.4 mapped restart A factor on the rod's strength in the fight: higher is easier (the game's own: 1.5 at very easy, 1.25, 1, 0.9, 0.9 at very hard).
fishing.normal.rodEndurance float 0..1000 restart number 0.1.4 mapped restart A factor on the rod's endurance in the fight: higher is easier (the game's own: 1.5 at very easy, 1.25, 1, 1, 0.8 at very hard).
fishing.normal.quickTimeEvents float 0..1000 restart number 0.1.4 mapped restart A factor on the fight's quick-time prompts: higher is easier (the game's own: 1.5 at very easy, 1.25, 1.25, 1, 0.8 at very hard).
fishing.hard.advancedMinigame bool restart set 0.1.4 mapped restart Whether a bite can start the harder fight (the game's own: off at very easy, on at the others).
fishing.hard.fewerRounds int 0..255 restart number 0.1.4 mapped restart How many rounds fewer a fight has (the game's own: 6 at easy, 0 at the others).
fishing.hard.rodStrength float 0..1000 restart number 0.1.4 mapped restart A factor on the rod's strength in the fight: higher is easier (the game's own: 1.5 at very easy, 1.25, 1, 0.9, 0.9 at very hard).
fishing.hard.rodEndurance float 0..1000 restart number 0.1.4 mapped restart A factor on the rod's endurance in the fight: higher is easier (the game's own: 1.5 at very easy, 1.25, 1, 1, 0.8 at very hard).
fishing.hard.quickTimeEvents float 0..1000 restart number 0.1.4 mapped restart A factor on the fight's quick-time prompts: higher is easier (the game's own: 1.5 at very easy, 1.25, 1.25, 1, 0.8 at very hard).
fishing.veryHard.advancedMinigame bool restart set 0.1.4 mapped restart Whether a bite can start the harder fight (the game's own: off at very easy, on at the others).
fishing.veryHard.fewerRounds int 0..255 restart number 0.1.4 mapped restart How many rounds fewer a fight has (the game's own: 6 at easy, 0 at the others).
fishing.veryHard.rodStrength float 0..1000 restart number 0.1.4 mapped restart A factor on the rod's strength in the fight: higher is easier (the game's own: 1.5 at very easy, 1.25, 1, 0.9, 0.9 at very hard).
fishing.veryHard.rodEndurance float 0..1000 restart number 0.1.4 mapped restart A factor on the rod's endurance in the fight: higher is easier (the game's own: 1.5 at very easy, 1.25, 1, 1, 0.8 at very hard).
fishing.veryHard.quickTimeEvents float 0..1000 restart number 0.1.4 mapped restart A factor on the fight's quick-time prompts: higher is easier (the game's own: 1.5 at very easy, 1.25, 1.25, 1, 0.8 at very hard).
skillPoints.shroudRoot int 0..255 restart number 0.1.5 mapped restart Skill points from every Shroud Root. Classified from the game data, never the current point amount. Per-entry knowledge.skillPoints edits win over this family setting. Relative operations apply to each reward independently.
skillPoints.elixirWell int 0..255 restart number 0.1.5 mapped restart Skill points from every Elixir Well. Classified from the game data, never the current point amount. Per-entry knowledge.skillPoints edits win over this family setting. Relative operations apply to each reward independently.

Other names

An edit may name these fields by another name too. Kiln reads it as the field: the stage, its conflicts, kiln.log and registry.json name the field, an edit naming one field by both names is refused, and in C# the BalanceEntry property of the other name is the field's. A Kiln whose schema of this registry is older than the name's Since does not know it.

Name Is Since Why
playerLevelMax xpCurve.levelMax 0.1.3 The level the game's balance formulas count to, by a name that says so: xpCurve.levelMax is not the experience curve's alone, the enemy damage formulas (hits to kill, a player's expected health at a level) divide a player's level by it too.
shroudTime fogResistance (shroudTime.base, shroudTime.perFlameLevel) 0.1.3 The Shroud timer by the word the items registry uses (armor.shroud, damage.shroud): shroudTime.base and shroudTime.perFlameLevel are fogResistance.base and fogResistance.perFlameLevel.

Entries

  • Add (stage add, id <your mod id>:<name>): no.
  • Remove: no.
  • Raw game paths in edits (the Advanced tier): allowed.

Edit it from a data pack

The registry has one entry, game:balance, and every field applies at the next game start (restart): the game reads the table once. Edits use the same shape as every registry (items):

  • A number field: "field": "levelCap", "op": 60, or {"mul": 1.5}, {"add": 5}.
  • A list of fixed length is edited one element at a time: "field": "xpPerLevel[2]" (exactly 5 elements), "altarsPerFlameLevel[4]" (one value per flame level, 0 to flameLevelMax). [*] takes every element.
  • buildzoneSizesPerAltarLevel is a list of entries: edit one with "buildzoneSizesPerAltarLevel[3].x". It is edited in place: an edit that changes its length is refused at start.
  • flameLevelMax and gear.* are read-only (Kiln's gear formulas follow them).
  • salvage.start and salvage.end (since round 3): what a salvage (an item's Trash) gives back per unlocked upgrade, as a multiple of the upgrade's cost, at level 0 and at level 100. unlockCost.item (the rune an upgrade costs and a salvage gives) is read-only.
  • gemSalvage and fishing.<difficulty>.* (since 0.2.0-dev.32.1): what recycling a gem gives back (a share of its upgrades' cost), and the fishing fight for each value of the world setting fishingDifficulty (veryEasy, easy, normal, hard, veryHard): "field": "fishing.normal.rodStrength", "op": {"mul": 1.5}. The game reads both at use (each recycle, each bite), but they go through the start's write like the table's other fields.
  • An older data pack's gearRules (durability, rarity durability, socket chance, unlock cost) is a front-end of this registry since 0.2.0-dev.32: Kiln writes its values through this registry's mapping when that gives the game the same bytes (older paths as front-ends; gear rules guide).

Root and well skill-point rewards

skillPoints.shroudRoot and skillPoints.elixirWell apply to every reward of that family in the game's knowledge resource; skillPointsPerLevel controls levels. These are restart fields, applied to the served copy before the join check. For 2 / 4 / 3, use the data-only mods/samples/SkillPointRewards pack:

{"format":1,"registry":{"alter":[
  {"registry":"balance","select":"game:balance","field":"skillPoints.shroudRoot","op":2},
  {"registry":"balance","select":"game:balance","field":"skillPoints.elixirWell","op":4},
  {"registry":"balance","select":"game:balance","field":"skillPointsPerLevel","op":3}
]}}

Kind comes from the game's knowledge query names and flag ids, not the current amount: additional_skillpoint_NN and plant_N are roots, whole well_NN flags are wells. The unnamed legacy root entries remain roots. A well_15.N plant alias is not a whole-well reward. Changing the amounts in another loader does not change this classification.

Precedence: family controls compose in normal mod order. Every per-entry knowledge.skillPoints edit is above the family controls for that entry, regardless of which pack comes first. Relative per-entry edits read the family result. A family operation is atomic: if any matching reward cannot hold its result, that family edit is refused, not half-applied. The family value is a representative reward value; use the knowledge view for authoritative per-entry values when they differ. Both server and clients need the same pack and a restart.

Edit it from C#

[RegistryEntryPoints(RegistryEntryPoint.GameStart)]
public sealed class Levels : Mod
{
    public override void OnRegistry(RegistryContext context)
    {
        if (!Kiln.Registry.Registries.Available) return;                      // kiln.registry: the host's registry transport
        var registry = Kiln.Registry.Registries.For(context);
        registry.Alter(stage =>
        {
            var balance = stage.Balance;                    // the one entry, no id needed
            balance.LevelCap = 60;
            balance.XpPerLevel[2] = 3000;                  // a fixed list: set an element
            balance.SocketChance.Epic = 0.75;
            balance.Durability.Growth = balance.Durability.Growth * 2;
        });
    }
}

stage.Balance is a BalanceEntry (LevelCap, SkillPointsPerLevel, XpPerLevel, XpCurve, AltarsPerFlameLevel, BuildzoneSizesPerAltarLevel, Durability, RarityDurability, SocketChance, UnlockCost, FogResistance, Gear). Restart fields are written at GameStart (and, in a mod that declares ModLoad, WorldLoad or HotReload, such an edit is refused there with RestartRequired).

Views

RegistryViews.Find("balance") is the stable view with the one entry game:balance; it reads the values the stage composed.

Worked example

Level cap 60, more experience for level 3, and epic weapons socketed three times in four:

{
  "format": 1,
  "registry": {
    "alter": [
      { "registry": "balance", "select": { "id": "game:balance" }, "field": "levelCap", "op": 60 },
      { "registry": "balance", "select": { "id": "game:balance" }, "field": "xpPerLevel[2]", "op": { "add": 100 } },
      { "registry": "balance", "select": { "id": "game:balance" }, "field": "socketChance.epic", "op": 0.75 }
    ]
  }
}

The first two are what mods/tests/registry-stage-test runs in a lab. The values apply at the next start; the mod is "side": "both", "clients": "mod".

In multiplayer

Every field here is restart for a joined client: ContentSync does not carry it. Both sides need the same boot values at process start: the server and every client run the mod (side: both, clients: mod), and the join compares the resolved values (kiln.registry.boot: join compatibility). A rejoin alone does not change a value. gear.* is server-only (read-only).

Known limits

  • Saved characters keep their level, spent points and experience: lowering levelCap or skillPointsPerLevel, or changing the experience curve, is applied with a warning (edits that change existing saves); a shorter buildzoneSizesPerAltarLevel is refused.
  • The game's code allows at most 16 altars whatever altarsPerFlameLevel says; limits (maxAltars) raises that.
  • Not yet seen in a real game: the level cap and experience values in a client's UI after a join, and the base limits past 16.
  • Not yet seen in a real game: gem recycling and a fishing fight after an edit of gemSalvage or fishing.* (traced in the game's code only).
  • Every field applies at the next start, though the game reads most of them at each use (the level cap every step, the experience curve at each level, the skill points at each unlock, the altars at each placement, the Shroud timer every step, the upgrade costs, durability and socket chances when an item is made or upgraded: docs/re/content.md section 15 traces each). Kiln has no live back-end for the balance table yet; when it has one, these fields can apply at once.

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