Table of Contents

Class Npc

Namespace
Exiled.API.Features
Assembly
Exiled.API.dll

Wrapper class for handling NPC players.

public class Npc : Player, IEntity, IWorldSpace, IPosition, IRotation
Inheritance
Npc
Implements
Inherited Members
Extension Methods

Constructors

Npc(ReferenceHub)

Represents the in-game player, by encapsulating a ReferenceHub.

public Npc(ReferenceHub referenceHub)

Parameters

referenceHub ReferenceHub

Npc(GameObject)

Represents the in-game player, by encapsulating a ReferenceHub.

public Npc(GameObject gameObject)

Parameters

gameObject GameObject

Fields

SpawnSetRoleDelay

The time it takes for the NPC to receive its CustomHumeShieldStat and Role.

public const float SpawnSetRoleDelay = 0.5

Field Value

float

Properties

FollowedPlayer

Gets or sets the player being followed.

public Player? FollowedPlayer { get; set; }

Property Value

Player

Remarks

The npc must have CommandSystem.Commands.RemoteAdmin.Dummies.PlayerFollower.

List

Gets a list of Npcs.

public static IReadOnlyCollection<Npc> List { get; }

Property Value

IReadOnlyCollection<Npc>

MaxDistance

Gets or sets the Max Distance of the npc.

public float? MaxDistance { get; set; }

Property Value

float?

Remarks

The npc must have CommandSystem.Commands.RemoteAdmin.Dummies.PlayerFollower.

MinDistance

Gets or sets the Min Distance of the npc.

public float? MinDistance { get; set; }

Property Value

float?

Remarks

The npc must have CommandSystem.Commands.RemoteAdmin.Dummies.PlayerFollower.

Position

Gets or sets the player's position.

public override Vector3 Position { get; set; }

Property Value

Vector3

Speed

Gets or sets the Speed of the npc.

public float? Speed { get; set; }

Property Value

float?

Remarks

The npc must have CommandSystem.Commands.RemoteAdmin.Dummies.PlayerFollower.

Methods

CancelUseItem(Item)

Forces the Npc to stop using item.

public void CancelUseItem(Item item)

Parameters

item Item

The Item to cancel usage of.

Destroy()

Destroys the NPC.

public void Destroy()

DestroyAll()

Destroys all NPCs currently spawned.

public static void DestroyAll()

EquipItem(Item)

public void EquipItem(Item item)

Parameters

item Item

The Item to equip.

Follow(Player)

Follow a specific player.

public void Follow(Player player)

Parameters

player Player

the Player to follow.

Follow(Player, float, float, float)

Follow a specific player.

public void Follow(Player player, float maxDistance, float minDistance, float speed = 30)

Parameters

player Player

the Player to follow.

maxDistance float

the max distance the npc will go.

minDistance float

the min distance the npc will go.

speed float

the speed the npc will go.

Get(CommandSender)

Retrieves the NPC associated with the specified CommandSender.

public static Npc? Get(CommandSender sender)

Parameters

sender CommandSender

The CommandSender to retrieve the NPC for.

Returns

Npc

The NPC associated with the CommandSender, or null if not found.

Get(ICommandSender)

Retrieves the NPC associated with the specified ICommandSender.

public static Npc? Get(ICommandSender sender)

Parameters

sender ICommandSender

The ICommandSender to retrieve the NPC for.

Returns

Npc

The NPC associated with the ICommandSender, or null if not found.

Get(Footprint)

Retrieves the NPC associated with the specified Footprint.

public static Npc? Get(Footprint footprint)

Parameters

footprint Footprint

The Footprint to retrieve the NPC for.

Returns

Npc

The NPC associated with the Footprint, or null if not found.

Get(NetworkConnection)

Retrieves the NPC associated with the specified NetworkConnection.

public static Npc? Get(NetworkConnection conn)

Parameters

conn NetworkConnection

The NetworkConnection to retrieve the NPC for.

Returns

Npc

The NPC associated with the NetworkConnection, or null if not found.

Get(ReferenceHub)

Retrieves the NPC associated with the specified ReferenceHub.

public static Npc? Get(ReferenceHub rHub)

Parameters

rHub ReferenceHub

The ReferenceHub to retrieve the NPC for.

Returns

Npc

The NPC associated with the ReferenceHub, or null if not found.

Get(int)

Retrieves the NPC associated with the specified ID.

public static Npc? Get(int id)

Parameters

id int

The ID to retrieve the NPC for.

Returns

Npc

The NPC associated with the ID, or null if not found.

Get(string)

Retrieves the NPC associated with the specified user ID.

public static Npc? Get(string userId)

Parameters

userId string

The user ID to retrieve the NPC for.

Returns

Npc

The NPC associated with the user ID, or null if not found.

Get(uint)

Retrieves the NPC associated with the specified net ID.

public static Npc? Get(uint netId)

Parameters

netId uint

The net ID to retrieve the NPC for.

Returns

Npc

The NPC associated with the net ID, or null if not found.

Get(Collider)

Retrieves the NPC associated with the specified Collider.

public static Npc? Get(Collider collider)

Parameters

collider Collider

The Collider to retrieve the NPC for.

Returns

Npc

The NPC associated with the Collider, or null if not found.

Get(GameObject)

Retrieves the NPC associated with the specified GameObject.

public static Npc? Get(GameObject gameObject)

Parameters

gameObject GameObject

The GameObject to retrieve the NPC for.

Returns

Npc

The NPC associated with the GameObject, or null if not found.

GetActions()

Gets actions that can be done by the Dummy.

public IReadOnlyList<DummyAction> GetActions()

Returns

IReadOnlyList<DummyAction>

IReadOnlyList<T>.

HolsterItem()

public void HolsterItem()

IsBeingDone(Item, ActionName)

Checks if certain action is currently active.

public bool IsBeingDone(Item item, ActionName name)

Parameters

item Item

The Item to check action for.

name ActionName

The name of action to check.

Returns

bool

True if action is actively executed and emulator is not null.

IsBeingDone(DummyKeyEmulator?, ActionName)

Checks if certain action is currently active.

public bool IsBeingDone(DummyKeyEmulator? emulator, ActionName name)

Parameters

emulator DummyKeyEmulator

The NetworkManagerUtils.Dummies.DummyKeyEmulator to check action for.

name ActionName

The name of action to check.

Returns

bool

True if action is actively executed and emulator is not null.

IsBeingDone<T>(T, ActionName)

Checks if certain action is currently active.

public bool IsBeingDone<T>(T subroutine, ActionName name) where T : SubroutineBase

Parameters

subroutine T

The PlayerRoles.Subroutines.SubroutineBase to check action for.

name ActionName

The name of action to check.

Returns

bool

True if action is actively executed and emulator is not null.

Type Parameters

T

PlayerRoles.Subroutines.SubroutineBase.

LateDestroy(float)

Schedules the destruction of the NPC after a delay.

public void LateDestroy(float time)

Parameters

time float

The delay in seconds before the NPC is destroyed.

Spawn(string, RoleTypeId, bool, Vector3?)

Spawns an NPC based on the given parameters.

public static Npc Spawn(string name, RoleTypeId role = RoleTypeId.None, bool ignored = false, Vector3? position = null)

Parameters

name string

The name of the NPC.

role RoleTypeId

The RoleTypeId of the NPC, defaulting to None.

ignored bool

Whether the NPC should be ignored by round ending checks.

position Vector3?

The position where the NPC should spawn. If null, the default spawn location is used.

Returns

Npc

The Npc spawned.

Spawn(string, RoleTypeId, Vector3)

Spawns an NPC based on the given parameters.

public static Npc Spawn(string name, RoleTypeId role, Vector3 position)

Parameters

name string

The name of the NPC.

role RoleTypeId

The RoleTypeId of the NPC.

position Vector3

The position where the NPC should spawn.

Returns

Npc

Docs4.

TryAddHorizontalLook(float)

Makes the Npc look more left or more right.

public bool TryAddHorizontalLook(float amount)

Parameters

amount float

Amount that will be added to horizontal (in degrees).

Returns

bool

True if successful.

TryAddVerticalLook(float)

Makes the Npc look more up or more down.

public bool TryAddVerticalLook(float amount)

Parameters

amount float

Amount that will be added to vertical (in degrees).

Returns

bool

True if successful.

TryEatCandy(Scp330, CandyKindID)

Makes the Npc eat certain kind of candy.

public bool TryEatCandy(Scp330 from, CandyKindID candyKind)

Parameters

from Scp330

The Scp330 bag.

candyKind CandyKindID

The kind of candy to eat.

Returns

bool

True if successful.

TryEatCandy(CandyKindID)

Makes the Npc eat certain kind of candy.

public bool TryEatCandy(CandyKindID candyKind)

Parameters

candyKind CandyKindID

The kind of candy to eat.

Returns

bool

True if successful.

TryJump(float?)

Makes the Npc jump by amount of strength.

public bool TryJump(float? jumpStrength = null)

Parameters

jumpStrength float?

The strength used to jump. Null will choose the default one.

Returns

bool

True if successful.

TryLookAtDirection(Vector3, float)

Forces Npc to look at a certain direction.

public bool TryLookAtDirection(Vector3 dir, float lerp = 1)

Parameters

dir Vector3

The direction to look at.

lerp float

The amount in percentage how much to look at the direction, 1 is full and will immediately look at the target direction.

Returns

bool

True if successful.

TryLookAtPoint(Vector3, float)

Forces Npc to look at certain point.

public bool TryLookAtPoint(Vector3 position, float lerp = 1)

Parameters

position Vector3

Position to look at.

lerp float

The amount in percentage how much to look at the position, 1 is full and will immediately look at the point.

Returns

bool

True if successful.

TryMoveRelative(Vector3, float)

Moves this Npc by a direction relative to where they are looking.

public bool TryMoveRelative(Vector3 dir, float distance)

Parameters

dir Vector3

Direction where Npc should move relative to where they are looking.

distance float

The distance that the Npc should move by.

Returns

bool

True if successful.

TryReload(bool)

Forces the Npc to reload.

public bool TryReload(bool hold)

Parameters

hold bool

Specifies if the reloading is to be held.

Returns

bool

True if successful.

TryRunAction(DummyKeyEmulator?, ActionName, bool)

Forces the Npc to run generic action with emulator.

public bool TryRunAction(DummyKeyEmulator? emulator, ActionName name, bool hold)

Parameters

emulator DummyKeyEmulator

The NetworkManagerUtils.Dummies.DummyKeyEmulator to run action for.

name ActionName

The name of action to force.

hold bool

Specifies if the action is to be held.

Returns

bool

True if successful.

TryRunItemAction(Item, ActionName, bool)

Forces the Npc to run generic action with item.

public bool TryRunItemAction(Item item, ActionName name, bool hold = true)

Parameters

item Item

The Item to run action for.

name ActionName

The name of action to force.

hold bool

Specifies if the action is to be held.

Returns

bool

True if successful.

TryRunSubroutineAction<T>(T, ActionName, bool)

Forces the Npc to run generic action with subroutine.

public bool TryRunSubroutineAction<T>(T subroutine, ActionName name, bool hold = true) where T : SubroutineBase

Parameters

subroutine T

The PlayerRoles.Subroutines.SubroutineBase to run action for.

name ActionName

The name of action to force.

hold bool

Specifies if the action is to be held.

Returns

bool

True if successful.

Type Parameters

T

PlayerRoles.Subroutines.SubroutineBase.

TryShoot(bool)

Forces the Npc to shoot.

public bool TryShoot(bool hold)

Parameters

hold bool

Specifies if the shooting is to be held.

Returns

bool

True if successful.

TryStopAction(DummyKeyEmulator?, ActionName)

Forces the Npc to stop generic action with emulator.

public bool TryStopAction(DummyKeyEmulator? emulator, ActionName name)

Parameters

emulator DummyKeyEmulator

The NetworkManagerUtils.Dummies.DummyKeyEmulator to stop action for.

name ActionName

The name of action to stop.

Returns

bool

True if successful.

TryStopItemAction(Item, ActionName)

Forces the Npc to stop generic action with item.

public bool TryStopItemAction(Item item, ActionName name)

Parameters

item Item

The Item to stop action for.

name ActionName

The name of action to stop.

Returns

bool

True if successful.

TryStopSubroutineAction<T>(T, ActionName)

Forces the Npc to stop generic action with subroutine.

public bool TryStopSubroutineAction<T>(T subroutine, ActionName name) where T : SubroutineBase

Parameters

subroutine T

The PlayerRoles.Subroutines.SubroutineBase to stop action for.

name ActionName

The name of action to stop.

Returns

bool

True if successful.

Type Parameters

T

PlayerRoles.Subroutines.SubroutineBase.

TryZoom(bool)

Forces the Npc to zoom.

public bool TryZoom(bool hold)

Parameters

hold bool

Specifies if the zooming is to be held.

Returns

bool

True if successful.