NPCComposition

Methods
21
Fields
6

Getting one

client:getNpcDefinition(…)
bank:nearestBanker():getComposition()
bank:nearestBanker():getTransformedComposition()

Methods

MethodReturnsDescription
getName()stringThe type's name ("null" for one with none, as the cache stores it).
getId()numberThe type's id.
getActions(){ n: number, [number]: string? }The type's five right-click actions, nil where one is empty. Holes are nil and the array carries n, its length: walk it `for i = 1, a…
getConfigs(){number}?The type's transform table (ids by varbit value), nil for a type with none.
transform()NPCComposition?The type this one shows as now: the configs entry its varbit (or varp) value picks, the last one when the value is out of range; nil when…
getSize()numberThe type's size in tiles.
getCombatLevel()numberThe type's combat level.
isFollower()booleanWhether the type is a follower (a pet).
isInteractible()booleanWhether the type can be interacted with.
isMinimapVisible()booleanWhether the type shows on the minimap.
getStats(){number}The type's six levels, in STAT_* order: attack, defence, strength, hitpoints, ranged, magic (1 each where the cache sets none). Raises on…
getCombatStats()NpcCombatStatsBento-only: the type's levels and bonuses by name (an NpcCombatStats). The bonuses are the params the game cache sets on the type; the ga…
getAttackSpeedTicks()numberBento-only: game ticks between the type's attacks, as the game cache sets it (param 14, 4 where it sets none). A boss whose script paces it…
getAttackType()string?Bento-only: the kind of hit the type's attack is, as the game cache sets it (param 26): "stab", "slash", "crush" (where it sets none)…
getSlayerTaskId()number?Bento-only: the slayer task the type counts for, as the id the SLAYER_TARGET var holds for that task (42 abyssal demons; Vorkath's is 25,…
getDeathItem()number?Bento-only: the item id the type leaves on death, its bones or ashes (param 46: Bones, 526, where the cache sets none), nil for an NPC th…
isDragon()booleanBento-only: whether the cache marks the type a dragon (the dragonbane weapons).
isKalphite()booleanBento-only: whether the cache marks the type a kalphite (the keris), scarabs included.
isGolem()booleanBento-only: whether the cache marks the type a golem (the barronite mace), gargoyles included.
isXerician()booleanBento-only: whether the cache marks the type xerician (a Chambers of Xeric monster).
equals(any)booleanWhether other equals this NPCComposition, as == answers it (false for a value of another class).

Fields

FieldTypeDescription
STAT_ATTACKnumbergetStats()'s attack level index (0; Luau's array is 1-based, so getStats()[NPCComposition.STAT_ATTACK + 1]).
STAT_DEFENCEnumbergetStats()'s defence level index (1).
STAT_STRENGTHnumbergetStats()'s strength level index (2).
STAT_HITPOINTSnumbergetStats()'s hitpoints level index (3).
STAT_RANGEDnumbergetStats()'s ranged level index (4).
STAT_MAGICnumbergetStats()'s magic level index (5).

Returned by

MethodReturnsDescription
Client.getNpcDefinitionNPCComposition?NPC type id's definition (without the varbit transform), loaded on demand; nil when the client has none to give.
NPC.getCompositionNPCComposition?The NPC's composition as the server set it (untransformed); nil once it has despawned.
NPC.getTransformedCompositionNPCComposition?The composition the NPC shows as: its composition transformed by its varbit (or varp) when it has configs, else the composition itself; `ni…
NpcChanged.getOldNPCComposition?The composition the NPC had before the change.
ServerNpcLoot.getCompositionNPCComposition?The NPC's definition: client.getNpcDefinition(id) of the id the loot script named when it ran, loaded through the client's own loader whe…

Method details

getName

getName: (NPCComposition) -> string

The type's name ("null" for one with none, as the cache stores it).

getActions

getActions: (NPCComposition) -> { n: number, [number]: string? }

The type's five right-click actions, nil where one is empty. Holes are nil and the array carries n, its length: walk it for i = 1, actions.n. table.find stops at the first hole, so search it with your own contains(actions, x) that walks to n.

getConfigs

getConfigs: (NPCComposition) -> {number}?

The type's transform table (ids by varbit value), nil for a type with none.

transform

transform: (NPCComposition) -> NPCComposition?

The type this one shows as now: the configs entry its varbit (or varp) value picks, the last one when the value is out of range; nil when that entry is -1, or the type has no configs.

getStats

getStats: (NPCComposition) -> {number}

The type's six levels, in STAT_* order: attack, defence, strength, hitpoints, ranged, magic (1 each where the cache sets none). Raises on a client build whose offset table does not place them. getCombatStats() has them by name, with the type's bonuses.

getCombatStats

getCombatStats: (NPCComposition) -> NpcCombatStats

Bento-only: the type's levels and bonuses by name (an NpcCombatStats). The bonuses are the params the game cache sets on the type; the game server keeps its own copy, which a script can override. Raises where getStats() does, and when the client no longer holds the type.

getAttackSpeedTicks

getAttackSpeedTicks: (NPCComposition) -> number

Bento-only: game ticks between the type's attacks, as the game cache sets it (param 14, 4 where it sets none). A boss whose script paces its attacks itself can differ: TzTok-Jad's reads 4 although he attacks every 8 ticks.

getAttackType

getAttackType: (NPCComposition) -> string?

Bento-only: the kind of hit the type's attack is, as the game cache sets it (param 26): "stab", "slash", "crush" (where it sets none), "ranged" or "magic", nil for a value that is not known. A monster with several attacks has one here.

getSlayerTaskId

getSlayerTaskId: (NPCComposition) -> number?

Bento-only: the slayer task the type counts for, as the id the SLAYER_TARGET var holds for that task (42 abyssal demons; Vorkath's is 25, blue dragons), nil for none (param 50).

getDeathItem

getDeathItem: (NPCComposition) -> number?

Bento-only: the item id the type leaves on death, its bones or ashes (param 46: Bones, 526, where the cache sets none), nil for an NPC that leaves nothing.

isDragon

isDragon: (NPCComposition) -> boolean

Bento-only: whether the cache marks the type a dragon (the dragonbane weapons).

isKalphite

isKalphite: (NPCComposition) -> boolean

Bento-only: whether the cache marks the type a kalphite (the keris), scarabs included.

isGolem

isGolem: (NPCComposition) -> boolean

Bento-only: whether the cache marks the type a golem (the barronite mace), gargoyles included.

isXerician

isXerician: (NPCComposition) -> boolean

Bento-only: whether the cache marks the type xerician (a Chambers of Xeric monster).

equals

equals: (NPCComposition, any) -> boolean

Whether other equals this NPCComposition, as == answers it (false for a value of another class).