Skip to content
ASArcaneMP Scripting APIScripting reference
Runtime classServer APIGenerated

NPC

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

A server-spawned combat NPC handle; npcDied fires on death.

  • ServerEntity.ServerEntity

new NPC(id): NPC

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

Wraps an NPC entity id without spawning it.

number

Network id of the server entity to wrap.

NPC

destroy(): void

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

Despawns the NPC everywhere immediately, with no death anim.

void


follow(target, options?): boolean

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

Walks after the target with the game’s own pathfinding and locomotion until stop() or a new command, ending any running one as “replaced”. A fight it gets into holds the follow, which goes on once the NPC is calm again; pause(), aiPaused and movementFrozen hold it too. A followed player’s own client runs the NPC. npcMoveEnded “targetGone” when the target leaves. Throws on bad input.

Player | Character | Beast | NPC

Whom to follow.

NpcFollowOptions

gait (default “walk”), speedScale (0.25 to 3), distanceCm: it rests inside this distance and walks again once the target pulls 100 cm past it (100 to 3000, default 200), teleportBeyond: metres behind the target past which the server puts it beside them (default 60, 0 never), and then: the idle it takes up where it stands once the follow ends (default “stand”).

boolean

False when the NPC is gone or dead.


forceTarget(targetPlayerId, holdSeconds?, applyTicks?): void

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

Holds a forced combat target the way the game’s taunt does: the owner pins it once, then the target outscores every other candidate and the NPC’s attack keeps it. A target out of reach of the owner’s player (55 m) moves the NPC to that player’s client until the force ends. Read targetPlayerId back to see whether it held.

number

Player network id to force this NPC onto; 0 releases it back to native selection.

number

SetForcedPerceptionTarget window (default 3, max 60).

number

Ticks the NPC may stay off the target before its owner pins it again, after a native re-pick at 30 (default 1).

void


getRewardPolicy(): { experience: number; gameReward: boolean; loot: object[] | null; lootDelivery: "drop" | "inventory"; lootMode: "each" | "shared"; radius: number; recipients: "killer" | "damagers" | "nearby"; } | null

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

What this NPC’s death will pay: its own policy over the server default. Null once it has despawned.

{ experience: number; gameReward: boolean; loot: object[] | null; lootDelivery: "drop" | "inventory"; lootMode: "each" | "shared"; radius: number; recipients: "killer" | "damagers" | "nearby"; } | null


kill(): void

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

Runs the game’s death pipeline (death anim on every client), then despawns.

void


launch(x, y?, z?, opts?): boolean

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

Launches the NPC: sets its velocity in cm/s (added to the current one unless opts.overrideXY / overrideZ) and puts it in the air, on its owning client. True when sent, false on a dormant NPC. No effect while movementFrozen or before it has spawned.

number | Vector3

X component, or the whole vector.

number

Y component.

number

Z component.

PhysicsCommandOptions

space (‘world’ | ‘local’), at, velocityChange, addToCurrent, overrideXY, overrideZ.

boolean


moveAlong(waypoints, options?): boolean

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

Walks the waypoints with the game’s own pathfinding and locomotion, ending any running path as “replaced”. npcWaypoint fires on each arrival (before its wait), npcMoveEnded at the end. A fight it gets into holds the path, which continues once the NPC is calm again; aiPaused and movementFrozen hold it too. Throws on bad input.

MoveWaypoint[]

1 to 64 points, each a player’s origin (as player.position) with an optional wait (seconds) and the gait of the leg that arrives there.

NpcMoveOptions

gait (default “walk”), loop (“once”, “loop” or “pingpong”), radius: how near a point counts as reached (cm, default the game’s own, about 50), speedScale: the game’s own speed scale, 0.25 to 3, which jog and sprint follow, and then: the idle after a “once” path (default “stand”).

boolean

False when the NPC is gone or dead.


moveTo(x, y?, z?, options?): boolean

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

moveAlong with one waypoint.

number | Vector3Like

World x of a player’s origin.

number

World y.

number

World z.

NpcMoveOptions

As moveAlong’s.

boolean

False when the NPC is gone or dead.


pause(): void

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

Holds the running path or follow where it is; resume() walks on from there. A new command or stop() ends the hold.

void


relationTo(other): { pvpReason: string | null; reason: "native" | "pvp" | "friendlyNpc"; stance: "native" | "hostile" | "ally"; } | null

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

How this NPC and other stand: ally (they never hurt each other), hostile (the PvP rules let them fight) or native (the game’s own attitudes decide). pvpReason is the PvP relation’s reason when both answer to players. Null when either has despawned.

number | Player | NPC

A player, an NPC or either’s id.

{ pvpReason: string | null; reason: "native" | "pvp" | "friendlyNpc"; stance: "native" | "hostile" | "ally"; } | null


resume(): void

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

Continues the path or follow pause() held.

void


setDamageGivenMultiplier(multiplier): void

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

Scales the damage this NPC deals to players. It multiplies with each player’s setDamageTakenMultiplier and stacks on the game’s own modifiers; every client applies it, so it holds across owner hand-off.

number | null

1 is native, 0 deals none; null restores 1.

void


setDamageTakenMultiplier(multiplier): void

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

Scales the damage players deal to this NPC. It multiplies with each player’s setDamageGivenMultiplier and stacks on the game’s own modifiers; every client applies it, so it holds across owner hand-off.

number | null

1 is native, 0 takes none; null restores 1.

void


setDisposition(disposition): void

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

Shorthand for its side. Friendly puts it on the players’ team (setTeam(“Player”)): it fights wild enemies and never targets a player, and no player can hurt it. Hostile clears its leader and team, back to its class’s own.

"hostile" | "friendly"

New disposition.

void


setHealth(health): void

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

Sets current health once. No-op on a dormant (unowned) NPC.

number

New current health; the game clamps to [0, max].

void


setLeader(player): boolean

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

Puts the NPC on a player’s side: it never targets that player, and to every other player it is what its leader is under the PvP rules (an enemy only to one its leader may fight). Its damage counts as its leader’s, kills and rewards included. It despawns when its leader leaves. False on a despawned NPC.

number | Player | null

The player it fights for; null for none.

boolean


setMaxHealth(maxHealth): void

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

Overrides the NPC’s max health (owner raises base health and fills current to the new max); persists across owner hand-off and level travel.

number

New max health; pass <= 0 to clear back to the pawn’s native max.

void


setRewardPolicy(policy): void

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

Sets what this NPC’s death pays, and to whom. Each recipient’s own client grants it, so it shows like any kill reward. A death from npc.kill() pays nobody. Throws a TypeError or RangeError for a malformed policy.

{ experience?: number; gameReward?: boolean; loot?: object[] | null; lootDelivery?: "drop" | "inventory"; lootMode?: "each" | "shared"; radius?: number; recipients?: "killer" | "damagers" | "nearby"; } | null

recipients: “killer” (the player whose hit finished it) or “damagers” (every player who hit it); gameReward: pay the game’s own kill reward; experience: flat XP on top. Fields left out come from NPC.setDefaultRewardPolicy; null clears them all.

void


setScale(scale, mode?): void

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

Sets the scale on every client’s copy; set it right after create so the NPC is sized before it first streams in.

number

Uniform scale (1 = native size).

"full" | "visual"

“full” (default) resizes the whole actor, collision included; “visual” resizes only the body and leaves collision native.

void


setTeam(team): boolean

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

Sets the native team the NPC fights for, so the game’s own attitudes decide whom it attacks; “Player” makes it friendly to every player. A leader’s side takes over while it has one. False on a despawned NPC.

string | null

A game team name such as “Goblin”, “Spider” or “Player”; null for its class’s own.

boolean


setVirtualWorld(world, map?): void

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

Moves this entity into another virtual world, within a map: there it meets the players in the same world of the same map, so world N of a dungeon is one instance of it.

number

Virtual-world identifier used to partition replication and visibility.

string

The map it is in, as player.location().areaId names it; “Overland” or “” for the shared map. Left out, it stays in its current map.

void


setVisibleTo(player): void

Defined in: shared.d.ts:82

Restricts replication to one player’s connection, within the usual range and visibility checks; null lifts it.

Entity | null

void


stop(): void

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

Ends the running path or follow as “stopped” and leaves the NPC where it is, to its idle.

void


toString(): string

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

Returns a debug string for this NPC.

string


static create(enemyId, opts, y?, z?, disposition?, preferredOwnerId?): NPC | undefined

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

Spawns a replicated combat NPC. Throws a TypeError when opts lacks a finite x, y or z.

string

Catalog id or class path.

number | NpcSpawnOptions

Where it spawns and how. A number starts the deprecated positional form, create(enemyId, x, y, z, disposition?, preferredOwnerId?), which has no yaw.

number

Deprecated positional form only.

number

Deprecated positional form only.

"hostile" | "friendly"

Deprecated positional form only.

number

Deprecated positional form only.

NPC | undefined


static getDefaultRewardPolicy(): object

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

The server-wide reward policy, with the built-in values filled in.

object

experience: number

gameReward: boolean

loot: object[] | null

lootDelivery: "drop" | "inventory"

lootMode: "each" | "shared"

radius: number

recipients: "killer" | "damagers" | "nearby"


static setDefaultRewardPolicy(policy): void

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

Sets what an NPC’s death pays when the NPC’s own policy (setRewardPolicy, or its camp’s) leaves a field out. Built in: the killing blow earns the game’s own kill reward (Field Guide knowledge, its experience and kill-challenge progress). Throws a TypeError or RangeError for a malformed policy.

{ experience?: number; gameReward?: boolean; loot?: object[] | null; lootDelivery?: "drop" | "inventory"; lootMode?: "each" | "shared"; radius?: number; recipients?: "killer" | "damagers" | "nearby"; } | null

Fields left out keep the built-in default; null restores it.

void

aiPaused: boolean

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

Enemies only: holds the NPC in the game’s scripted-pause state. It stops pathing and starts no new attack, dodge or patrol, and idles in place; hit reactions, Protego, death and an attack already mid-swing still play. Perception and targeting keep running.


readonly alive: boolean

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

Whether the NPC is currently alive.


animationFrozen: boolean

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

Freezes the NPC’s pose on every client.


combatEnabled: boolean

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

Off: the NPC stays hostile and keeps chasing its target but never starts an attack. It can still counter right after it blocks or dodges, and its Protego still deflects spells. A friendly NPC still fights wild enemies; turn this off to keep it out of fights. Enemies only.


readonly damageGivenMultiplier: number

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

The multiplier set by setDamageGivenMultiplier; 1 when native.


readonly damageTakenMultiplier: number

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

The multiplier set by setDamageTakenMultiplier; 1 when native.


readonly disposition: "hostile" | "friendly" | undefined

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

“friendly” when it fights for a leader or is on the players’ team, else “hostile”; undefined once the NPC has despawned.


readonly enemyId: string

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

Catalog id or class path this NPC was spawned from.


readonly health: number

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

Owner-reported actual current health (absolute game units); reads 0 until the owner client has embodied the pawn and polled it.


home: Vector3 | null

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

Where the stand and wander idles keep it, a player’s origin; a “once” path that arrives moves it to the last point, and a follow that ends to where it stands. Null until one is set.


readonly id: number

Defined in: shared.d.ts:65

Network id, stable for the entity’s lifetime.


idle: NpcIdle

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

What it does while no path or follow runs: “native” (the game’s own: it wanders where it spawned; the default), “stand” (holds at its home, walking back there after a fight) or “wander” (roams around its home). The first stand or wander makes where it stands its home.


readonly leaderId: number

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

The player it fights for (see setLeader), or 0.


readonly maxHealth: number

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

Owner-reported actual max health (absolute game units); reads 0 until the owner client has embodied the pawn and polled it.


readonly movement: NpcMovementState

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

The running command: mode (“idle”, “path” or “follow”), the waypoint it heads for or waits at, the path’s length, completed laps, whether pause() or aiPaused holds it, and the followed entity’s id (0 otherwise). The idle state once the NPC is gone.


movementFrozen: boolean

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

Locks the NPC’s position; animation and AI decisions continue.


readonly ownerId: number

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

Network id of the player whose client runs the AI (0 = server-owned/dormant).


perceptionEnabled: boolean

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

Off: the NPC stops perceiving players, drops every target and returns to idle, and acquires nothing until it is turned back on. Re-applied if the game wakes it (a hit, spawn); a forced target overrides it.


position: Vector3

Defined in: shared.d.ts:67

World position. Read, call set(...), then assign back.


rotation: Vector3 | Quaternion

Defined in: shared.d.ts:69

Reads as a quaternion; assignments also accept Euler angles in degrees.


readonly scale: number

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

Current uniform scale (1 = native size).


readonly scaleMode: "full" | "visual"

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

How the scale is applied: “full” resizes the whole actor, “visual” only the body (see setScale).


readonly state: StateBag

Defined in: shared.d.ts:71

This entity’s key/value state: the server writes it, and every client that can see the entity receives it. See StateBag.


readonly targetPlayerId: number

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

Owner-reported readback: the player NPC_Component::GetTarget() actually resolves to right now, or 0. Compare against the id passed to forceTarget to see native reversion.


readonly targetType: number

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

Owner-reported EEnemy_TargetType readback: 0 None, 1 Attack, 2 Flee.


readonly team: string

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

Its native team (see setTeam); “” for its class’s own.


readonly virtualWorld: number

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

The virtual world scripts put this entity in. Outside the shared map (Overland) replication combines it with the entity’s map, as it does a player’s.


readonly waypoints: MoveWaypoint[]

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

The running path’s points as given (gait resolved from the path’s default); empty when idle or following.