new Character()
Properties:
Name | Type | Description |
---|---|---|
name |
string | Name shown on look/who/login |
inventory |
Inventory | |
combatants |
Set | Enemies this character is currently in combat with |
level |
number | |
attributes |
Attributes | |
effects |
EffectList | List of current effects applied to the character |
room |
Room | Room the character is currently in |
- Mixes In:
Extends
- EventEmitter
Members
-
isNpc
-
Methods
-
addAttribute()
-
- See:
-
addCombatant(target)
-
Parameters:
Name Type Description target
Character Fires:
-
addEffect(effect) → {boolean}
-
Parameters:
Name Type Description effect
Effect Returns:
boolean -
addFollower(follower)
-
Parameters:
Name Type Description follower
Character Fires:
-
addItem(item)
-
Move an item to the character's inventory
Parameters:
Name Type Description item
Item -
emit(event, …args)
-
Proxy all events on the player to effects
Parameters:
Name Type Attributes Description event
string args
* <repeatable>
-
equip(item, slot)
-
Parameters:
Name Type Description item
Item slot
string Slot to equip the item in
Fires:
Throws:
-
EquipSlotTakenError
-
EquipAlreadyEquippedError
-
-
evaluateIncomingDamage(damage) → {number}
-
Parameters:
Name Type Description damage
Damage Returns:
number- See:
-
- EffectList.evaluateIncomingDamage
-
evaluateOutgoingDamage(damage, currentAmount) → {number}
-
Parameters:
Name Type Description damage
Damage currentAmount
number Returns:
number- See:
-
- EffectList.evaluateOutgoingDamage
-
follow(target)
-
Begin following another character. If the character follows itself they stop following.
Parameters:
Name Type Description target
Character -
getAttribute(attr) → {number}
-
Get the current value of an attribute (base modified by delta)
Parameters:
Name Type Description attr
string Returns:
number -
getBaseAttribute(attr) → {number}
-
Get the base value for a given attribute
Parameters:
Name Type Description attr
string Attribute name
Returns:
number -
getBroadcastTargets()
-
- See:
-
getMaxAttribute(attr) → {number}
-
Get current maximum value of attribute (as modified by effects.)
Parameters:
Name Type Description attr
string Returns:
number -
hasAttribute(attr) → {boolean}
-
Parameters:
Name Type Description attr
string Attribute name
Returns:
boolean -
hasEffectType(type) → {boolean}
-
Parameters:
Name Type Description type
string Returns:
boolean- See:
-
hasFollower(target) → {boolean}
-
Parameters:
Name Type Description target
Character Returns:
boolean -
hasItem(itemReference) → {Item|boolean}
-
Check to see if this character has a particular item by EntityReference
Parameters:
Name Type Description itemReference
EntityReference -
hydrate(state)
-
Initialize the character from storage
Parameters:
Name Type Description state
GameState -
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:
-
isFollowing(target) → {boolean}
-
Parameters:
Name Type Description target
Character Returns:
boolean -
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
-
isInventoryFull() → {boolean}
-
Returns:
boolean -
lowerAttribute(attr, amount)
-
Lower an attribute by name
Parameters:
Name Type Description attr
string amount
number Fires:
- See:
-
Attributes#lower
-
raiseAttribute(attr, amount)
-
Raise an attribute by name
Parameters:
Name Type Description attr
string amount
number Fires:
- See:
-
Attributes#raise
-
removeCombatant(target)
-
Parameters:
Name Type Description target
Character Fires:
-
removeEffect(effect)
-
Parameters:
Name Type Description effect
Effect - See:
-
removeFollower(follower)
-
Parameters:
Name Type Description follower
Character Fires:
-
removeFromCombat()
-
Fully remove this character from combat
-
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 -
serialize() → {Object}
-
Gather data to be persisted
Returns:
Object -
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:
-
setAttributeToMax(attr)
-
Clears any changes to the attribute, setting it to its base value.
Parameters:
Name Type Description attr
string Fires:
-
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
-
unfollow()
-
Stop following whoever the character was following
Fires:
Events
-
attributeUpdate
-
Fired when a Character's attribute is set, raised, or lowered
Parameters:
Name Type Description attributeName
string attribute
Attribute -
combatantAdded
-
Parameters:
Name Type Description target
Character -
combatantRemoved
-
Parameters:
Name Type Description target
Character -
combatEnd
-
-
combatStart
-
Fired when Character#initiateCombat is called
-
damaged
-
Parameters:
Name Type Description damage
Damage finalAmount
Number -
effectAdded
-
-
effectRemoved
-
-
equip
-
Parameters:
Name Type Description slot
string item
Item -
followed
-
Parameters:
Name Type Description target
Character -
gainedFollower
-
Parameters:
Name Type Description follower
Character -
heal
-
-
healed
-
Parameters:
Name Type Description heal
Heal finalAmount
number -
hit
-
-
lostFollower
-
Parameters:
Name Type Description follower
Character -
unequip
-
Parameters:
Name Type Description slot
string item
Item -
unfollowed
-
Parameters:
Name Type Description following
Character