Npc()

new Npc()

Properties:
Name Type Description
id number

Area-relative id (vnum)

area Area

Area npc belongs to (not necessarily the area they're currently in)

behaviors Map
Mixes In:
  • Scriptable

Extends

Members

isNpc

Overrides:

Methods

addAttribute()

Inherited From:
See:

addCombatant(target)

Parameters:
Name Type Description
target Character
Fires:
Inherited From:

addEffect(effect) → {boolean}

Parameters:
Name Type Description
effect Effect
Returns:
boolean
Inherited From:

addFollower(follower)

Parameters:
Name Type Description
follower Character
Fires:
Inherited From:

addItem(item)

Move an item to the character's inventory

Parameters:
Name Type Description
item Item
Inherited From:

emit(event, …args)

Proxy all events on the player to effects

Parameters:
Name Type Attributes Description
event string
args * <repeatable>
Inherited From:

equip(item, slot)

Parameters:
Name Type Description
item Item
slot string

Slot to equip the item in

Fires:
Throws:
  • EquipSlotTakenError

  • EquipAlreadyEquippedError

Inherited From:

evaluateIncomingDamage(damage) → {number}

Parameters:
Name Type Description
damage Damage
Returns:
number
Inherited From:
See:
  • EffectList.evaluateIncomingDamage

evaluateOutgoingDamage(damage, currentAmount) → {number}

Parameters:
Name Type Description
damage Damage
currentAmount number
Returns:
number
Inherited From:
See:
  • EffectList.evaluateOutgoingDamage

follow(target)

Begin following another character. If the character follows itself they stop following.

Parameters:
Name Type Description
target Character
Inherited From:

getAttribute(attr) → {number}

Get the current value of an attribute (base modified by delta)

Parameters:
Name Type Description
attr string
Returns:
number
Inherited From:

getBaseAttribute(attr) → {number}

Get the base value for a given attribute

Parameters:
Name Type Description
attr string

Attribute name

Returns:
number
Inherited From:

getBroadcastTargets()

Inherited From:
See:

getMaxAttribute(attr) → {number}

Get current maximum value of attribute (as modified by effects.)

Parameters:
Name Type Description
attr string
Returns:
number
Inherited From:

hasAttribute(attr) → {boolean}

Parameters:
Name Type Description
attr string

Attribute name

Returns:
boolean
Inherited From:

hasEffectType(type) → {boolean}

Parameters:
Name Type Description
type string
Returns:
boolean
Inherited From:
See:

hasFollower(target) → {boolean}

Parameters:
Name Type Description
target Character
Returns:
boolean
Inherited From:

hasItem(itemReference) → {Item|boolean}

Check to see if this character has a particular item by EntityReference

Parameters:
Name Type Description
itemReference EntityReference
Returns:
Item | boolean
Inherited From:

hydrate(state)

Initialize the character from storage

Parameters:
Name Type Description
state GameState
Overrides:

initiateCombat(target, lagnullable)

Start combat with a given target.

Parameters:
Name Type Attributes Default Description
target Character
lag number <nullable>
0

Optional milliseconds of lag to apply before the first attack

Fires:
Inherited From:

isFollowing(target) → {boolean}

Parameters:
Name Type Description
target Character
Returns:
boolean
Inherited From:

isInCombat(targetnullable)

Check to see if this character is currently in combat or if they are currently in combat with a specific character

Parameters:
Name Type Attributes Description
target Character <nullable>
Returns:
-

boolean

Inherited From:

isInventoryFull() → {boolean}

Returns:
boolean
Inherited From:

lowerAttribute(attr, amount)

Lower an attribute by name

Parameters:
Name Type Description
attr string
amount number
Fires:
Inherited From:
See:
  • Attributes#lower

moveTo(nextRoom, onMoved)

Move the npc to the given room, emitting events appropriately

Parameters:
Name Type Description
nextRoom Room
onMoved function

Function to run after the npc is moved to the next room but before enter events are fired

Fires:

raiseAttribute(attr, amount)

Raise an attribute by name

Parameters:
Name Type Description
attr string
amount number
Fires:
Inherited From:
See:
  • Attributes#raise

removeCombatant(target)

Parameters:
Name Type Description
target Character
Fires:
Inherited From:

removeEffect(effect)

Parameters:
Name Type Description
effect Effect
Inherited From:
See:

removeFollower(follower)

Parameters:
Name Type Description
follower Character
Fires:
Inherited From:

removeFromCombat()

Fully remove this character from combat

Inherited From:

removeItem(item)

Remove an item from the character's inventory. Warning: This does not automatically place the item in any particular place. You will need to manually add it to the room or another character's inventory

Parameters:
Name Type Description
item Item
Inherited From:

serialize() → {Object}

Gather data to be persisted

Returns:
Object
Inherited From:

setAttributeBase(attr, newBase)

Update an attribute's base value.

NOTE: You probably don't want to use this the way you think you do. You should not use this for any temporary modifications to an attribute, instead you should use an Effect modifier.

This will permanently update the base value for an attribute to be used for things like a player purchasing a permanent upgrade or increasing a stat on level up

Parameters:
Name Type Description
attr string

Attribute name

newBase number

New base value

Fires:
Inherited From:

setAttributeToMax(attr)

Clears any changes to the attribute, setting it to its base value.

Parameters:
Name Type Description
attr string
Fires:
Inherited From:

unequip(slot)

Remove equipment in a given slot and move it to the character's inventory

Parameters:
Name Type Description
slot string
Fires:
Throws:

InventoryFullError

Inherited From:

unfollow()

Stop following whoever the character was following

Fires:
Inherited From:

Events

attributeUpdate

Fired when a Character's attribute is set, raised, or lowered

Parameters:
Name Type Description
attributeName string
attribute Attribute
Inherited From:

combatantAdded

Parameters:
Name Type Description
target Character
Inherited From:

combatantRemoved

Parameters:
Name Type Description
target Character
Inherited From:

combatEnd

Inherited From:

combatStart

Fired when Character#initiateCombat is called

Inherited From:

damaged

Parameters:
Name Type Description
damage Damage
finalAmount Number
Inherited From:

effectAdded

Inherited From:

effectRemoved

Inherited From:

enterRoom

Parameters:
Name Type Description
room Room

equip

Parameters:
Name Type Description
slot string
item Item
Inherited From:

followed

Parameters:
Name Type Description
target Character
Inherited From:

gainedFollower

Parameters:
Name Type Description
follower Character
Inherited From:

heal

Parameters:
Name Type Description
heal Heal
target Character
finalAmount number
Inherited From:

healed

Parameters:
Name Type Description
heal Heal
finalAmount number
Inherited From:

hit

Parameters:
Name Type Description
damage Damage
target Character
finalAmount Number
Inherited From:

lostFollower

Parameters:
Name Type Description
follower Character
Inherited From:

spawn

unequip

Parameters:
Name Type Description
slot string
item Item
Inherited From:

unfollowed

Parameters:
Name Type Description
following Character
Inherited From:

updateTick

See: