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

Player

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

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

new Player(id): Player

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

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:1114

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:5874

Reads this player’s nametag color.

number

Packed 0xAARRGGBB color; opaque white when untinted.

BasePlayer.getNametagColor


getNametagText(): string

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

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:1108

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:1121

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:1128

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:5862

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:5856

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


setTargetable(targetable): void

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

Keeps another player’s body out of this machine’s combat lock-on and opponent picker, or lets it back in – for someone lying wounded, say. Only this client’s picker is affected, so a resource that wants it everywhere tells every client. It does not stop a swing that lands anyway; damage is the server’s to refuse. Lasts until changed or the session ends. Throws unless targetable is a boolean.

boolean

False to keep this player’s body out of the local lock-on, true to let it back.

void


toString(): string

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

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:959

Agility, in the game’s own units.


readonly alive: boolean

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

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


readonly appearance: Appearance

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

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:929

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


readonly buffs: BuffState[]

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

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:874

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


readonly combatZone: number

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

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:939

How conscious the body is; 0 is knocked out.


readonly crouched: boolean

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

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:854

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:944

How drunk the body is; 0 is sober.


readonly entityId: number

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

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:1034

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:909

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


readonly fistsUp: boolean

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

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:1014

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:884

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


readonly healthPercent: number

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

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:904

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


readonly horseId: number

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

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:919

Current nourishment, in the game’s own units.


readonly id: number

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

Immutable network entity identifier.

BasePlayer.id


readonly inAir: boolean

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

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:1029

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:1044

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:1049

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:1074

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:989

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:914

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


readonly maxHealth: number

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

Health capacity, in the game’s own units.


readonly maxHunger: number

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

Nourishment capacity, in the game’s own units.


readonly maxStamina: number

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

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:1089

Whether this player is in a saddle.


readonly moveDirTag: number

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

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:1059

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:837

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


readonly perks: string[]

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

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:1004

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:842

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:949

How poisoned the body is; 0 is clean.


position: Vector3

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

Authoritative world-space position; assignment forces replicated state.

BasePlayer.position


readonly ready: boolean

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

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:979

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


readonly relativeStats: SoulStats

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

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:1024

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:5781

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:974

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:934

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


readonly stamina: number

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

Current stamina, in the game’s own units.


readonly stanceTag: number

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

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:5786

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:954

Strength, in the game’s own units.


readonly velocity: Vector3

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

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:5771

Current virtual-world identifier.

BasePlayer.virtualWorld


readonly visible: boolean

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

Whether this player’s body is drawn at all – itself, what it wears and what it carries. True for everybody until something hides them. Published by their own client, so it follows setVisible once they have actually stopped drawing. A hidden player is only invisible: they still stand where they stand, still collide, can still be hit, and NPCs still see them.


readonly visorClosed: boolean

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

Whether this player has a helmet visor down, as their own game reports it. False when they wear no helmet with a visor, and once their body is gone. There is no setter: the player raises and lowers it in their own game.


readonly vitality: number

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

Vitality, in the game’s own units.