Dog
Defined in: server/api.d.ts:3937
Replicated KCD2 dog companion handle.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Dog(
id):Dog
Defined in: server/api.d.ts:3942
Creates a script wrapper for an existing dog with this ID; use Dog.spawn() to spawn one.
Parameters
Section titled “Parameters”number
Network entity identifier.
Returns
Section titled “Returns”Dog
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”destroy()
Section titled “destroy()”destroy():
void
Defined in: server/api.d.ts:3993
Despawns this dog on every client after emitting dogDestroy.
Returns
Section titled “Returns”void
giveTo()
Section titled “giveTo()”giveTo(
player):void
Defined in: server/api.d.ts:3999
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.
Parameters
Section titled “Parameters”player
Section titled “player”Player | null
The dog’s new master, or null to leave it masterless.
Returns
Section titled “Returns”void
setVirtualWorld()
Section titled “setVirtualWorld()”setVirtualWorld(
world):void
Defined in: server/api.d.ts:9890
Moves this entity into another virtual world.
Parameters
Section titled “Parameters”number
Virtual-world identifier used to partition replication and visibility.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setVisibleTo()
Section titled “setVisibleTo()”setVisibleTo(
player):void
Defined in: server/api.d.ts:9896
Restricts replication of this entity to one owning connection while preserving normal range and visibility checks.
Parameters
Section titled “Parameters”player
Section titled “player”Entity | null
Player-owned entity whose connection should exclusively receive this entity, or null to clear the restriction.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”toString()
Section titled “toString()”toString():
string
Defined in: server/api.d.ts:3988
Formats this dog handle for logging and debugging.
Returns
Section titled “Returns”string
The dog ID, its soul, its owner and its mode.
Inherited from
Section titled “Inherited from”
staticall():Dog[]
Defined in: server/api.d.ts:4016
Lists every dog the server currently has.
Returns
Section titled “Returns”Dog[]
One handle per live dog, in no particular order.
getById()
Section titled “getById()”
staticgetById(id):Dog|null
Defined in: server/api.d.ts:4023
Looks a dog up by its network entity ID.
Parameters
Section titled “Parameters”number
Network entity identifier.
Returns
Section titled “Returns”Dog | null
The dog’s handle, or null when no live dog has that ID.
spawn()
Section titled “spawn()”
staticspawn(owner,position?,rotation?,soul?,name?):Dog
Defined in: server/api.d.ts:4010
Spawns and replicates a dog companion for a player.
Parameters
Section titled “Parameters”The player the dog belongs to. A dog is somebody’s from the moment it exists.
position?
Section titled “position?”Optional world-space spawn position; omitted spawns the dog on its owner.
rotation?
Section titled “rotation?”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.
Returns
Section titled “Returns”Dog
The newly spawned dog handle.
Properties
Section titled “Properties”destroyWithOwner
Section titled “destroyWithOwner”destroyWithOwner:
boolean
Defined in: server/api.d.ts:3967
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.
readonlyid:number
Defined in: server/api.d.ts:9858
Immutable network entity identifier.
Inherited from
Section titled “Inherited from”mode:
number
Defined in: server/api.d.ts:3972
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.
morale
Section titled “morale”
readonlymorale:number
Defined in: server/api.d.ts:3982
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:3952
Name every client shows for this dog. Assignment renames it on all of them; empty means the name its soul carries stands.
objective
Section titled “objective”
readonlyobjective:number
Defined in: server/api.d.ts:3977
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.
readonlyowner:Player|null
Defined in: server/api.d.ts:3962
The player this dog belongs to, or null when it has no master.
ownerId
Section titled “ownerId”
readonlyownerId:number
Defined in: server/api.d.ts:3957
Network ID of the player this dog belongs to, or 0 when it has no master.
position
Section titled “position”position:
Vector3
Defined in: server/api.d.ts:9868
Authoritative world-space position; assignment forces replicated state.
Inherited from
Section titled “Inherited from”rotation
Section titled “rotation”rotation:
Vector3|Quaternion
Defined in: server/api.d.ts:9873
Authoritative rotation; reads return a quaternion and assignments accept a quaternion or Euler angles in degrees.
Inherited from
Section titled “Inherited from”
readonlysoul:string
Defined in: server/api.d.ts:3947
GUID of the soul this dog was spawned against, which decides its appearance.
readonlystate:StateBag
Defined in: server/api.d.ts:9878
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”virtualWorld
Section titled “virtualWorld”
readonlyvirtualWorld:number
Defined in: server/api.d.ts:9863
Current virtual-world identifier.