Player
Defined in: client/api.d.ts:827
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:832
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: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.
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:5874
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:5868
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: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.
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: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.
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:1128
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:5862
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:5856
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”setTargetable()
Section titled “setTargetable()”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.
Parameters
Section titled “Parameters”targetable
Section titled “targetable”boolean
False to keep this player’s body out of the local lock-on, true to let it back.
Returns
Section titled “Returns”void
toString()
Section titled “toString()”toString():
string
Defined in: client/api.d.ts:1102
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:959
Agility, in the game’s own units.
readonlyalive:boolean
Defined in: client/api.d.ts:869
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: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.
bleeding
Section titled “bleeding”
readonlybleeding:number
Defined in: client/api.d.ts:929
How heavily the body is bleeding; 0 when it is not.
readonlybuffs: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.
canAct
Section titled “canAct”
readonlycanAct:boolean
Defined in: client/api.d.ts:874
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: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.
consciousness
Section titled “consciousness”
readonlyconsciousness:number
Defined in: client/api.d.ts:939
How conscious the body is; 0 is knocked out.
crouched
Section titled “crouched”
readonlycrouched: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.
disguise
Section titled “disguise”
readonlydisguise: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.
drunkenness
Section titled “drunkenness”
readonlydrunkenness:number
Defined in: client/api.d.ts:944
How drunk the body is; 0 is sober.
entityId
Section titled “entityId”
readonlyentityId: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.
equipment
Section titled “equipment”
readonlyequipment: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.
exhaust
Section titled “exhaust”
readonlyexhaust:number
Defined in: client/api.d.ts:909
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: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.
readonlyguard: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.
health
Section titled “health”
readonlyhealth:number
Defined in: client/api.d.ts:884
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: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.
healthyStamina
Section titled “healthyStamina”
readonlyhealthyStamina:number
Defined in: client/api.d.ts:904
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:1084
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:919
Current nourishment, in the game’s own units.
readonlyid:number
Defined in: client/api.d.ts:5766
Immutable network entity identifier.
Inherited from
Section titled “Inherited from”
readonlyinAir: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.
leftHandItem
Section titled “leftHandItem”
readonlyleftHandItem: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.
readonlylevel:number
Defined in: client/api.d.ts:1044
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: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.
readonlylocal:boolean
Defined in: client/api.d.ts:1074
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:989
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:914
Maximum energy reserve, in the game’s own units.
maxHealth
Section titled “maxHealth”
readonlymaxHealth:number
Defined in: client/api.d.ts:889
Health capacity, in the game’s own units.
maxHunger
Section titled “maxHunger”
readonlymaxHunger:number
Defined in: client/api.d.ts:924
Nourishment capacity, in the game’s own units.
maxStamina
Section titled “maxStamina”
readonlymaxStamina: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.
mounted
Section titled “mounted”
readonlymounted:boolean
Defined in: client/api.d.ts:1089
Whether this player is in a saddle.
moveDirTag
Section titled “moveDirTag”
readonlymoveDirTag: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.
moveSpeedTag
Section titled “moveSpeedTag”
readonlymoveSpeedTag: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.
nickname
Section titled “nickname”
readonlynickname:string
Defined in: client/api.d.ts:837
The name this player connected under, or an empty string once their body is gone.
readonlyperks: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.
physicsProfile
Section titled “physicsProfile”
readonlyphysicsProfile:number
Defined in: client/api.d.ts:1004
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:842
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:949
How poisoned the body is; 0 is clean.
position
Section titled “position”position:
Vector3
Defined in: client/api.d.ts:5776
Authoritative world-space position; assignment forces replicated state.
Inherited from
Section titled “Inherited from”
readonlyready: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.
relativeSkills
Section titled “relativeSkills”
readonlyrelativeSkills:SoulSkills
Defined in: client/api.d.ts:979
The same nine skills as the engine’s relative values.
relativeStats
Section titled “relativeStats”
readonlyrelativeStats: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.
rightHandItem
Section titled “rightHandItem”
readonlyrightHandItem: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
Section titled “rotation”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.
Inherited from
Section titled “Inherited from”skills
Section titled “skills”
readonlyskills: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.
sleeping
Section titled “sleeping”
readonlysleeping:number
Defined in: client/api.d.ts:934
Sleepiness the game has accumulated for this body; above 0 means asleep.
stamina
Section titled “stamina”
readonlystamina:number
Defined in: client/api.d.ts:894
Current stamina, in the game’s own units.
stanceTag
Section titled “stanceTag”
readonlystanceTag: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.
readonlystate: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.
Inherited from
Section titled “Inherited from”strength
Section titled “strength”
readonlystrength:number
Defined in: client/api.d.ts:954
Strength, in the game’s own units.
velocity
Section titled “velocity”
readonlyvelocity: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.
virtualWorld
Section titled “virtualWorld”
readonlyvirtualWorld:number
Defined in: client/api.d.ts:5771
Current virtual-world identifier.
Inherited from
Section titled “Inherited from”visible
Section titled “visible”
readonlyvisible: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.
visorClosed
Section titled “visorClosed”
readonlyvisorClosed: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.
vitality
Section titled “vitality”
readonlyvitality:number
Defined in: client/api.d.ts:964
Vitality, in the game’s own units.