NPC

Extends
Actor
Methods
9
Fields
None

Getting one

bank:nearestBanker()
client:getHintArrowNpc()
client:getFollower()

Methods

MethodReturnsDescription
getId()numberThe id of the NPC's transformed composition (what it shows as), -1 once it has despawned.
getOverheadArchiveIds(){number}?The archives of the NPC's head icons (one per slot, -1 for an empty one): the ones the server set on it, else its transformed composition's…
getOverheadSpriteIds(){number}?The sprite indices of the NPC's head icons within their archives (one per slot, -1 for an empty one), as getOverheadArchiveIds() picks th…
interact(string)booleanAct on the NPC through the virtual mouse: option is one of its menu actions ("Attack", "Talk-to"; "" for the first). The scheduler reso…
health()NpcHealth?The NPC's health bar (getHealthRatio() of getHealthScale()), with the NPC type's hitpoints from an NPC info table and the hitpoints the…
getModelOverrides()NpcOverrides?The model override the server set on the NPC (its models, recolours and retextures), nil for none or once the NPC is gone; not its chathe…
getIndex()numberThe NPC's index in its world view.
getComposition()NPCComposition?The NPC's composition as the server set it (untransformed); nil once it has despawned.
getTransformedComposition()NPCComposition?The composition the NPC shows as: its composition transformed by its varbit (or varp) when it has configs, else the composition itself; `ni…

Returned by

MethodReturnsDescription
Bank.nearestBankerNPC?The nearest banker NPC exposing Bank.
Client.getFollowerNPC?The local player's follower (a pet, a familiar, a quest follower), or nil: the first follower varp the session changed (`VarPlayerID.FOLLOW…
Client.getHintArrowNpcNPC?The NPC an NPC hint arrow points at; nil for any other arrow, or one whose NPC is gone.
Client.getNpcs{NPC}The top-level world view's NPCs (also getTopLevelWorldView():npcs()).
HighlightedNpc.getNpcNPCThe NPC.
MenuEntry.getNpcNPC?The NPC the entry targets (an NPC option, a use on an NPC, Examine), by index getIdentifier() in the entry's world view, or nil.
NpcChanged.getNpcNPCThe NPC; never nil. From a legacy (differ) delivery read after the NPC left the map, the handle it had, with its last-known values.
NpcDespawned.getNpcNPCThe NPC, readable for the length of the event; never nil. From a legacy (differ) delivery, made after it left the map, the handle it had,…
NPCQuery.collect{ NPC }Every survivor, nearest first. Consumes the query.
NPCQuery.nearestNPC?The nearest survivor. Consumes the query.
NpcSet.byIndexNPC?The NPC at index, or nil.
NpcSimClass.attacksAt{NPC}The NPCs that attack you (certainly or possibly) on tick. An attack on another NPC does not count, here or in isCertain and `firstAttac…
NpcSpawned.getNpcNPCThe NPC; never nil. From a legacy (differ) delivery read after the NPC left the map, the handle it had, with its last-known values.
SlayerPluginService.getTargets{NPC}The current task's targets: the same NPC handles every other getter answers.

Method details

getId

getId: (NPC) -> number

The id of the NPC's transformed composition (what it shows as), -1 once it has despawned.

getOverheadArchiveIds

getOverheadArchiveIds: (NPC) -> {number}?

The archives of the NPC's head icons (one per slot, -1 for an empty one): the ones the server set on it, else its transformed composition's; nil with neither.

getOverheadSpriteIds

getOverheadSpriteIds: (NPC) -> {number}?

The sprite indices of the NPC's head icons within their archives (one per slot, -1 for an empty one), as getOverheadArchiveIds() picks them; nil with none.

interact

interact: (NPC, string) -> boolean

Act on the NPC through the virtual mouse: option is one of its menu actions ("Attack", "Talk-to"; "" for the first). The scheduler resolves the NPC by its world view, index and id, moves the virtual mouse and clicks. false when the NPC is gone, or it is outside the top level, the boat the player stands in and the NPC-owned boats in the scene (on another player's boat).

health

health: (NPC) -> NpcHealth?

The NPC's health bar (getHealthRatio() of getHealthScale()), with the NPC type's hitpoints from an NPC info table and the hitpoints the bar stands for, estimated from them; nil with no bar showing, or once the NPC has despawned.

getModelOverrides

getModelOverrides: (NPC) -> NpcOverrides?

The model override the server set on the NPC (its models, recolours and retextures), nil for none or once the NPC is gone; not its chathead override.

getIndex

getIndex: (NPC) -> number

The NPC's index in its world view.

getTransformedComposition

getTransformedComposition: (NPC) -> NPCComposition?

The composition the NPC shows as: its composition transformed by its varbit (or varp) when it has configs, else the composition itself; nil when the transform picks none, or once it has despawned.