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

Dog

Defined in: server/api.d.ts:3639

Replicated KCD2 dog companion handle.

new Dog(id): Dog

Defined in: server/api.d.ts:3644

Creates a script wrapper for an existing dog with this ID; use Dog.spawn() to spawn one.

number

Network entity identifier.

Dog

Entity.constructor

destroy(): void

Defined in: server/api.d.ts:3695

Despawns this dog on every client after emitting dogDestroy.

void


giveTo(player): void

Defined in: server/api.d.ts:3701

Hands this dog to another player. Every client re-possesses the body onto the new master’s soul, and authority over its pose moves with it. Throws when player is not a connected player.

Player | null

The dog’s new master, or null to leave it masterless.

void


setVirtualWorld(world): void

Defined in: server/api.d.ts:8797

Moves this entity into another virtual world.

number

Virtual-world identifier used to partition replication and visibility.

void

Entity.setVirtualWorld


setVisibleTo(player): void

Defined in: server/api.d.ts:8803

Restricts replication of this entity to one owning connection while preserving normal range and visibility checks.

Entity | null

Player-owned entity whose connection should exclusively receive this entity, or null to clear the restriction.

void

Entity.setVisibleTo


toString(): string

Defined in: server/api.d.ts:3690

Formats this dog handle for logging and debugging.

string

The dog ID, its soul, its owner and its mode.

Entity.toString


static all(): Dog[]

Defined in: server/api.d.ts:3718

Lists every dog the server currently has.

Dog[]

One handle per live dog, in no particular order.


static getById(id): Dog | null

Defined in: server/api.d.ts:3725

Looks a dog up by its network entity ID.

number

Network entity identifier.

Dog | null

The dog’s handle, or null when no live dog has that ID.


static spawn(owner, position?, rotation?, soul?, name?): Dog

Defined in: server/api.d.ts:3712

Spawns and replicates a dog companion for a player.

Player

The player the dog belongs to. A dog is somebody’s from the moment it exists.

Vector3 | Partial<Vector3>

Optional world-space spawn position; omitted spawns the dog on its owner.

Vector3 | Quaternion

Optional initial orientation: a Quaternion, or a Vector3 of Euler angles in degrees.

string

Optional soul GUID from the game’s tables; omitted spawns the generic dog.

string

Optional name every client shows for the dog; omitted leaves the name its soul carries.

Dog

The newly spawned dog handle.

destroyWithOwner: boolean

Defined in: server/api.d.ts:3669

Whether this dog is despawned when its owner disconnects. True by default. Set it to false to keep the dog in the world: it is left masterless instead (dogOwnerChanged with a null player), and with nobody’s game running its brain it stands where it was until giveTo hands it to someone. Saving it across server restarts is the script’s own business.


readonly id: number

Defined in: server/api.d.ts:8765

Immutable network entity identifier.

Entity.id


mode: number

Defined in: server/api.d.ts:3674

The dog’s companion mode: 0 Wait, 1 Follow, 2 Free, 3 Aggressive, 4 Search, 5 Hunt, 6 Guard, 7 Ambush. Assignment applies it on every client.


readonly morale: number

Defined in: server/api.d.ts:3684

The dog’s morale as its owner last read it off the game, or 0 before any report. Below the game’s own threshold the dog stops obeying commands. Owner-reported, so read-only.


name: string

Defined in: server/api.d.ts:3654

Name every client shows for this dog. Assignment renames it on all of them; empty means the name its soul carries stands.


readonly objective: number

Defined in: server/api.d.ts:3679

What the owner’s game currently has this dog doing, as an E_DogObjective ordinal: 0 Wait, 2 Bark, 4 Follow, 5 FollowHeel, 7 Search, 8 MeleeCombat, 9 Fetch, 10 Hunt, 19 Eat, 21 Distract, 22 Pet, 25 Invalid when idle. Reported by the owner, so read-only.


readonly owner: Player | null

Defined in: server/api.d.ts:3664

The player this dog belongs to, or null when it has no master.


readonly ownerId: number

Defined in: server/api.d.ts:3659

Network ID of the player this dog belongs to, or 0 when it has no master.


position: Vector3

Defined in: server/api.d.ts:8775

Authoritative world-space position; assignment forces replicated state.

Entity.position


rotation: Vector3 | Quaternion

Defined in: server/api.d.ts:8780

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

Entity.rotation


readonly soul: string

Defined in: server/api.d.ts:3649

GUID of the soul this dog was spawned against, which decides its appearance.


readonly state: StateBag

Defined in: server/api.d.ts:8785

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

Entity.state


readonly virtualWorld: number

Defined in: server/api.d.ts:8770

Current virtual-world identifier.

Entity.virtualWorld