Player
Defined in: client/api.d.ts:768
A KCDC player this client can see, and the body they occupy.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”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.
Parameters
Section titled “Parameters”number
Network entity identifier.
Returns
Section titled “Returns”Player
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”getDerivedStat()
Section titled “getDerivedStat()”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.
Parameters
Section titled “Parameters”"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.
Returns
Section titled “Returns”number
getNametagColor()
Section titled “getNametagColor()”getNametagColor():
number
Defined in: client/api.d.ts:5570
Reads this player’s nametag color.
Returns
Section titled “Returns”number
Packed 0xAARRGGBB color; opaque white when untinted.
Inherited from
Section titled “Inherited from”getNametagText()
Section titled “getNametagText()”getNametagText():
string
Defined in: client/api.d.ts:5564
Reads this player’s nametag text override.
Returns
Section titled “Returns”string
The override, or an empty string when the player’s own name is drawn.
Inherited from
Section titled “Inherited from”getStat()
Section titled “getStat()”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.
Parameters
Section titled “Parameters”"health" | "stamina" | "exhaust" | "hunger"
A PlayerStat value.
Returns
Section titled “Returns”number
getTrack()
Section titled “getTrack()”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.
Parameters
Section titled “Parameters”string
A track name, from Progression.tracks().
Returns
Section titled “Returns”TrackProgress | null
The progress, or null for any other player. Throws for a track name the tables do not carry.
hasPerk()
Section titled “hasPerk()”hasPerk(
perk):boolean
Defined in: client/api.d.ts:1059
Whether the player owns a perk.
Parameters
Section titled “Parameters”string
A perk’s name or GUID.
Returns
Section titled “Returns”boolean
True when they do; false for a perk they do not own, or a name the tables do not carry.
isNametagHealthVisible()
Section titled “isNametagHealthVisible()”isNametagHealthVisible():
boolean
Defined in: client/api.d.ts:5558
Checks whether the health bar under this player’s nametag is shown.
Returns
Section titled “Returns”boolean
True unless the health bar was hidden; false also when this game has no nametags.
Inherited from
Section titled “Inherited from”BasePlayer.isNametagHealthVisible
isNametagVisible()
Section titled “isNametagVisible()”isNametagVisible():
boolean
Defined in: client/api.d.ts:5552
Checks whether this player’s nametag is shown to other players.
Returns
Section titled “Returns”boolean
True unless the nametag was hidden; false also when this game has no nametags.
Inherited from
Section titled “Inherited from”toString()
Section titled “toString()”toString():
string
Defined in: client/api.d.ts:1033
Formats this player handle for logging and debugging.
Returns
Section titled “Returns”string
The player’s network entity ID, nickname, and whether they are the local player.
Inherited from
Section titled “Inherited from”Properties
Section titled “Properties”agility
Section titled “agility”
readonlyagility:number
Defined in: client/api.d.ts:895
Agility, in the game’s own units.
readonlyalive:boolean
Defined in: client/api.d.ts:805
Whether this player has health left. False also while no soul has been published.
appearance
Section titled “appearance”
readonlyappearance: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.
bleeding
Section titled “bleeding”
readonlybleeding:number
Defined in: client/api.d.ts:865
How heavily the body is bleeding; 0 when it is not.
readonlybuffs: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.
canAct
Section titled “canAct”
readonlycanAct:boolean
Defined in: client/api.d.ts:810
Whether the body can be driven at all: alive, conscious and not asleep.
combatZone
Section titled “combatZone”
readonlycombatZone: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.
consciousness
Section titled “consciousness”
readonlyconsciousness:number
Defined in: client/api.d.ts:875
How conscious the body is; 0 is knocked out.
crouched
Section titled “crouched”
readonlycrouched: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.
disguise
Section titled “disguise”
readonlydisguise: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.
drunkenness
Section titled “drunkenness”
readonlydrunkenness:number
Defined in: client/api.d.ts:880
How drunk the body is; 0 is sober.
entityId
Section titled “entityId”
readonlyentityId: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.
equipment
Section titled “equipment”
readonlyequipment: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.
exhaust
Section titled “exhaust”
readonlyexhaust:number
Defined in: client/api.d.ts:845
Current energy reserve, in the game’s own units. Higher means better rested.
fistsUp
Section titled “fistsUp”
readonlyfistsUp: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.
readonlyguard: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.
health
Section titled “health”
readonlyhealth:number
Defined in: client/api.d.ts:820
Current health, in the game’s own units. 0 while no soul has been published.
healthPercent
Section titled “healthPercent”
readonlyhealthPercent: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.
healthyStamina
Section titled “healthyStamina”
readonlyhealthyStamina:number
Defined in: client/api.d.ts:840
The stamina ceiling the body’s injuries currently allow, which is at or below maxStamina.
horseId
Section titled “horseId”
readonlyhorseId:number
Defined in: client/api.d.ts:1015
Network ID of the horse this player is riding, or 0 when they are on foot.
hunger
Section titled “hunger”
readonlyhunger:number
Defined in: client/api.d.ts:855
Current nourishment, in the game’s own units.
readonlyid:number
Defined in: client/api.d.ts:5462
Immutable network entity identifier.
Inherited from
Section titled “Inherited from”
readonlyinAir: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.
leftHandItem
Section titled “leftHandItem”
readonlyleftHandItem: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.
readonlylevel:number
Defined in: client/api.d.ts:975
The player’s main level, the one the game derives from the stats. 0 until known.
levels
Section titled “levels”
readonlylevels: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.
readonlylocal:boolean
Defined in: client/api.d.ts:1005
Whether this handle is the player sitting at this machine, rather than someone else’s copy.
lookDirection
Section titled “lookDirection”
readonlylookDirection: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.
maxExhaust
Section titled “maxExhaust”
readonlymaxExhaust:number
Defined in: client/api.d.ts:850
Maximum energy reserve, in the game’s own units.
maxHealth
Section titled “maxHealth”
readonlymaxHealth:number
Defined in: client/api.d.ts:825
Health capacity, in the game’s own units.
maxHunger
Section titled “maxHunger”
readonlymaxHunger:number
Defined in: client/api.d.ts:860
Nourishment capacity, in the game’s own units.
maxStamina
Section titled “maxStamina”
readonlymaxStamina: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.
mounted
Section titled “mounted”
readonlymounted:boolean
Defined in: client/api.d.ts:1020
Whether this player is in a saddle.
moveDirTag
Section titled “moveDirTag”
readonlymoveDirTag: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.
moveSpeedTag
Section titled “moveSpeedTag”
readonlymoveSpeedTag: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.
nickname
Section titled “nickname”
readonlynickname:string
Defined in: client/api.d.ts:778
The name this player connected under, or an empty string once their body is gone.
readonlyperks: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.
physicsProfile
Section titled “physicsProfile”
readonlyphysicsProfile:number
Defined in: client/api.d.ts:940
The ragdoll physics profile the body is in, or 255 when it has none to report.
playerIndex
Section titled “playerIndex”
readonlyplayerIndex: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.
poisoning
Section titled “poisoning”
readonlypoisoning:number
Defined in: client/api.d.ts:885
How poisoned the body is; 0 is clean.
position
Section titled “position”position:
Vector3
Defined in: client/api.d.ts:5472
Authoritative world-space position; assignment forces replicated state.
Inherited from
Section titled “Inherited from”
readonlyready: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.
relativeSkills
Section titled “relativeSkills”
readonlyrelativeSkills:SoulSkills
Defined in: client/api.d.ts:915
The same nine skills as the engine’s relative values.
relativeStats
Section titled “relativeStats”
readonlyrelativeStats: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.
rightHandItem
Section titled “rightHandItem”
readonlyrightHandItem: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
Section titled “rotation”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.
Inherited from
Section titled “Inherited from”skills
Section titled “skills”
readonlyskills: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.
sleeping
Section titled “sleeping”
readonlysleeping:number
Defined in: client/api.d.ts:870
Sleepiness the game has accumulated for this body; above 0 means asleep.
stamina
Section titled “stamina”
readonlystamina:number
Defined in: client/api.d.ts:830
Current stamina, in the game’s own units.
stanceTag
Section titled “stanceTag”
readonlystanceTag: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.
readonlystate: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.
Inherited from
Section titled “Inherited from”strength
Section titled “strength”
readonlystrength:number
Defined in: client/api.d.ts:890
Strength, in the game’s own units.
velocity
Section titled “velocity”
readonlyvelocity: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.
virtualWorld
Section titled “virtualWorld”
readonlyvirtualWorld:number
Defined in: client/api.d.ts:5467
Current virtual-world identifier.
Inherited from
Section titled “Inherited from”vitality
Section titled “vitality”
readonlyvitality:number
Defined in: client/api.d.ts:900
Vitality, in the game’s own units.