Skip to content
KCKingdoms Connected Scripting APIScripting guides and API
Runtime classClient APIGenerated

Player

Defined in: client/api.d.ts:768

A KCDC player this client can see, and the body they occupy.

new Player(id): Player

Defined in: client/api.d.ts:773

Creates a script wrapper for a player this client already knows about; it neither connects nor spawns anyone.

number

Network entity identifier.

Player

BasePlayer.constructor

getDerivedStat(stat): number

Defined in: client/api.d.ts:1045

Reads a computed stat from the latest body snapshot. Bleeding, Sleeping, Consciousness, Drunkenness and Poisoning follow the body as it changes; the others are sampled about every 250 ms to a hundredth of a native unit, then replicated. Values use native units and can be negative; they are not universally percentages. Returns zero without a valid snapshot. Throws for an unknown stat or invalid arguments. These readings do not override another player’s native calculations.

"bleeding" | "sleeping" | "consciousness" | "drunkenness" | "poisoning" | "charisma" | "visibility" | "conspicuousness" | "noise" | "dirtiness" | "bloodiness" | "smell" | "smellIntensity" | "fragrance" | "carriedWeight" | "inventoryCapacity" | "encumbrance" | "hangover" | "alcoholism" | "armorRating" | "overallArmorDefense" | "overallWeaponAttack" | "normalizedRunSpeed" | "runSpeedBase" | "morale"

A DerivedPlayerStat value.

number


getNametagColor(): number

Defined in: client/api.d.ts:5570

Reads this player’s nametag color.

number

Packed 0xAARRGGBB color; opaque white when untinted.

BasePlayer.getNametagColor


getNametagText(): string

Defined in: client/api.d.ts:5564

Reads this player’s nametag text override.

string

The override, or an empty string when the player’s own name is drawn.

BasePlayer.getNametagText


getStat(stat): number

Defined in: client/api.d.ts:1039

Reads the latest reported stat in native units. Returns zero when no valid body snapshot exists; check player.ready to distinguish that from a real zero. Throws for an unknown stat or invalid arguments.

"health" | "stamina" | "exhaust" | "hunger"

A PlayerStat value.

number


getTrack(track): TrackProgress | null

Defined in: client/api.d.ts:1052

Where the local player stands on one track: level, XP towards the next one, and unspent perk points. Only the local player carries XP and points; for anyone else this is null.

string

A track name, from Progression.tracks().

TrackProgress | null

The progress, or null for any other player. Throws for a track name the tables do not carry.


hasPerk(perk): boolean

Defined in: client/api.d.ts:1059

Whether the player owns a perk.

string

A perk’s name or GUID.

boolean

True when they do; false for a perk they do not own, or a name the tables do not carry.


isNametagHealthVisible(): boolean

Defined in: client/api.d.ts:5558

Checks whether the health bar under this player’s nametag is shown.

boolean

True unless the health bar was hidden; false also when this game has no nametags.

BasePlayer.isNametagHealthVisible


isNametagVisible(): boolean

Defined in: client/api.d.ts:5552

Checks whether this player’s nametag is shown to other players.

boolean

True unless the nametag was hidden; false also when this game has no nametags.

BasePlayer.isNametagVisible


toString(): string

Defined in: client/api.d.ts:1033

Formats this player handle for logging and debugging.

string

The player’s network entity ID, nickname, and whether they are the local player.

BasePlayer.toString

readonly agility: number

Defined in: client/api.d.ts:895

Agility, in the game’s own units.


readonly alive: boolean

Defined in: client/api.d.ts:805

Whether this player has health left. False also while no soul has been published.


readonly appearance: Appearance

Defined in: client/api.d.ts:790

What this player’s body looks like, as their own client last published it. Every part is empty until something chooses one, which is the default body – and why everyone looks the same until a resource says otherwise.

Read back rather than assumed after setAppearance: the owning client is authoritative for its own body, so a new look appears here once they have actually put it on.


readonly bleeding: number

Defined in: client/api.d.ts:865

How heavily the body is bleeding; 0 when it is not.


readonly buffs: BuffState[]

Defined in: client/api.d.ts:1027

The status effects on this body: potions, poison, drunkenness, injuries, illness, unconsciousness, and anything the server added. Perks and equipment effects are not in here – they follow state that already replicates.

Only the local player has this list. Nobody else’s client publishes their effects, because what everyone else’s body is wearing reaches this machine as the consequences already – so it reads empty for any other handle.


readonly canAct: boolean

Defined in: client/api.d.ts:810

Whether the body can be driven at all: alive, conscious and not asleep.


readonly combatZone: number

Defined in: client/api.d.ts:955

Which direction of the combat star this player is aiming at, as a row of the game’s zone table, or -1 when they are aiming at none.


readonly consciousness: number

Defined in: client/api.d.ts:875

How conscious the body is; 0 is knocked out.


readonly crouched: boolean

Defined in: client/api.d.ts:935

Whether this player is crouched, as their own game’s crouch action reports it. False once their body is gone.


readonly disguise: string | null

Defined in: client/api.d.ts:795

The prop-catalog mesh this player’s body is drawn as, by its objects/...cgf path, or null while they look like themselves. Published by their own client, so it follows setDisguise once they have actually put it on.


readonly drunkenness: number

Defined in: client/api.d.ts:880

How drunk the body is; 0 is sober.


readonly entityId: number

Defined in: client/api.d.ts:1010

The engine entity behind this player: the game’s own player entity for the local player, otherwise the entity the copy was spawned as, or 0 across a level load and before it exists. Not stable across a session: the engine reuses entity ids.


readonly equipment: string[]

Defined in: client/api.d.ts:970

Item classes this player is wearing, each as 32 hex digits. What they actually have on rather than a preset, so a bare body reads as an empty array.


readonly exhaust: number

Defined in: client/api.d.ts:845

Current energy reserve, in the game’s own units. Higher means better rested.


readonly fistsUp: boolean

Defined in: client/api.d.ts:945

Whether this player has their fists – or their weapon – up. Stays true after the arm comes down, which is how the engine holds it.


readonly guard: number

Defined in: client/api.d.ts:950

The arm guard in the engine’s own levels: 0 arms down, 1 the guard a player holds.


readonly health: number

Defined in: client/api.d.ts:820

Current health, in the game’s own units. 0 while no soul has been published.


readonly healthPercent: number

Defined in: client/api.d.ts:815

Health as a percentage from 0 to 100 – what the nametag bar draws. Derived from the pair behind it, so it survives a maximum that changes.


readonly healthyStamina: number

Defined in: client/api.d.ts:840

The stamina ceiling the body’s injuries currently allow, which is at or below maxStamina.


readonly horseId: number

Defined in: client/api.d.ts:1015

Network ID of the horse this player is riding, or 0 when they are on foot.


readonly hunger: number

Defined in: client/api.d.ts:855

Current nourishment, in the game’s own units.


readonly id: number

Defined in: client/api.d.ts:5462

Immutable network entity identifier.

BasePlayer.id


readonly inAir: boolean

Defined in: client/api.d.ts:930

Whether the body is off the ground – fallen or mid-jump – as its own physics reports it, debounced past the flicker a stair step causes.


readonly leftHandItem: string

Defined in: client/api.d.ts:965

Item class drawn in the left hand as 32 hex digits, or an empty string when the hand is empty.


readonly level: number

Defined in: client/api.d.ts:975

The player’s main level, the one the game derives from the stats. 0 until known.


readonly levels: TrackLevels

Defined in: client/api.d.ts:980

The level of every skill and stat, keyed by track name. The local player reads its own character; anyone else reads what the server last accepted from theirs, and all zero until it has.


readonly local: boolean

Defined in: client/api.d.ts:1005

Whether this handle is the player sitting at this machine, rather than someone else’s copy.


readonly lookDirection: Vector3

Defined in: client/api.d.ts:925

World-space direction the head and eyes are turned towards. Zero while the body has reported none.


readonly maxExhaust: number

Defined in: client/api.d.ts:850

Maximum energy reserve, in the game’s own units.


readonly maxHealth: number

Defined in: client/api.d.ts:825

Health capacity, in the game’s own units.


readonly maxHunger: number

Defined in: client/api.d.ts:860

Nourishment capacity, in the game’s own units.


readonly maxStamina: number

Defined in: client/api.d.ts:835

Stamina capacity, in the game’s own units. Collapses to 0 for a tick around death, which is real rather than a bad read.


readonly mounted: boolean

Defined in: client/api.d.ts:1020

Whether this player is in a saddle.


readonly moveDirTag: number

Defined in: client/api.d.ts:995

The movement direction tag this machine’s animation system picked for this body. Raw Mannequin tag ids; 255 means nothing is set.


readonly moveSpeedTag: number

Defined in: client/api.d.ts:990

The locomotion pace tag – walk, jog, sprint – this machine’s animation system picked for this body. Raw Mannequin tag ids; 255 means nothing is set.


readonly nickname: string

Defined in: client/api.d.ts:778

The name this player connected under, or an empty string once their body is gone.


readonly perks: string[]

Defined in: client/api.d.ts:985

Every perk the player owns, by name – the perk screen’s and the hidden ones the game grants on its own.


readonly physicsProfile: number

Defined in: client/api.d.ts:940

The ragdoll physics profile the body is in, or 255 when it has none to report.


readonly playerIndex: number

Defined in: client/api.d.ts:783

Connection slot this player holds, or 65535 when unassigned. Stable for the length of the session and reused afterwards.


readonly poisoning: number

Defined in: client/api.d.ts:885

How poisoned the body is; 0 is clean.


position: Vector3

Defined in: client/api.d.ts:5472

Authoritative world-space position; assignment forces replicated state.

BasePlayer.position


readonly ready: boolean

Defined in: client/api.d.ts:800

Whether this player’s body has both a pose and a soul, which is what everyone else waits for before spawning a puppet for them. False for the first moments of a connection.


readonly relativeSkills: SoulSkills

Defined in: client/api.d.ts:915

The same nine skills as the engine’s relative values.


readonly relativeStats: SoulStats

Defined in: client/api.d.ts:905

The same three attributes as the engine’s relative values, which is what its own modifiers are expressed in.


readonly rightHandItem: string

Defined in: client/api.d.ts:960

Item class drawn in the right hand as 32 hex digits, or an empty string when the hand is empty. A class rather than an item: no engine-local identifier crosses the wire.


rotation: Vector3 | Quaternion

Defined in: client/api.d.ts:5477

Authoritative rotation; reads return a quaternion and assignments accept a quaternion or Euler angles in degrees.

BasePlayer.rotation


readonly skills: SoulSkills

Defined in: client/api.d.ts:910

The nine combat and survival skills a hit or a draw is evaluated against. Read as a whole rather than one at a time: the snapshot carries them together.


readonly sleeping: number

Defined in: client/api.d.ts:870

Sleepiness the game has accumulated for this body; above 0 means asleep.


readonly stamina: number

Defined in: client/api.d.ts:830

Current stamina, in the game’s own units.


readonly stanceTag: number

Defined in: client/api.d.ts:1000

The stance tag – upright, sneaking, sitting, lying – this machine’s animation system picked for this body. Raw Mannequin tag ids; 255 means nothing is set.


readonly state: StateBag

Defined in: client/api.d.ts:5482

Arbitrary key/value state carried by this entity. The server writes it and every client that can see the entity receives it; see StateBag.

BasePlayer.state


readonly strength: number

Defined in: client/api.d.ts:890

Strength, in the game’s own units.


readonly velocity: Vector3

Defined in: client/api.d.ts:920

On the owning machine, the velocity the body’s own animation was driven by this frame, not the one its physics settled on. Everywhere else, measured from successive replicated positions.


readonly virtualWorld: number

Defined in: client/api.d.ts:5467

Current virtual-world identifier.

BasePlayer.virtualWorld


readonly vitality: number

Defined in: client/api.d.ts:900

Vitality, in the game’s own units.