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 targetCharacter Fires:
-
addEffect(effect) → {boolean}
-
Parameters:
Name Type Description effectEffect Returns:
boolean -
addFollower(follower)
-
Parameters:
Name Type Description followerCharacter Fires:
-
addItem(item)
-
Move an item to the character's inventory
Parameters:
Name Type Description itemItem -
emit(event, …args)
-
Proxy all events on the player to effects
Parameters:
Name Type Attributes Description eventstring args* <repeatable>
-
equip(item, slot)
-
Parameters:
Name Type Description itemItem slotstring Slot to equip the item in
Fires:
Throws:
-
EquipSlotTakenError
-
EquipAlreadyEquippedError
-
-
evaluateIncomingDamage(damage) → {number}
-
Parameters:
Name Type Description damageDamage Returns:
number- See:
-
- EffectList.evaluateIncomingDamage
-
evaluateOutgoingDamage(damage, currentAmount) → {number}
-
Parameters:
Name Type Description damageDamage currentAmountnumber Returns:
number- See:
-
- EffectList.evaluateOutgoingDamage
-
follow(target)
-
Begin following another character. If the character follows itself they stop following.
Parameters:
Name Type Description targetCharacter -
getAttribute(attr) → {number}
-
Get the current value of an attribute (base modified by delta)
Parameters:
Name Type Description attrstring Returns:
number -
getBaseAttribute(attr) → {number}
-
Get the base value for a given attribute
Parameters:
Name Type Description attrstring Attribute name
Returns:
number -
getBroadcastTargets()
-
- See:
-
getMaxAttribute(attr) → {number}
-
Get current maximum value of attribute (as modified by effects.)
Parameters:
Name Type Description attrstring Returns:
number -
hasAttribute(attr) → {boolean}
-
Parameters:
Name Type Description attrstring Attribute name
Returns:
boolean -
hasEffectType(type) → {boolean}
-
Parameters:
Name Type Description typestring Returns:
boolean- See:
-
hasFollower(target) → {boolean}
-
Parameters:
Name Type Description targetCharacter Returns:
boolean -
hasItem(itemReference) → {Item|boolean}
-
Check to see if this character has a particular item by EntityReference
Parameters:
Name Type Description itemReferenceEntityReference -
hydrate(state)
-
Initialize the character from storage
Parameters:
Name Type Description stateGameState -
initiateCombat(target, lagnullable)
-
Start combat with a given target.
Parameters:
Name Type Attributes Default Description targetCharacter lagnumber <nullable>
0 Optional milliseconds of lag to apply before the first attack
Fires:
-
isFollowing(target) → {boolean}
-
Parameters:
Name Type Description targetCharacter 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 targetCharacter <nullable>
Returns:
-boolean
-
isInventoryFull() → {boolean}
-
Returns:
boolean -
lowerAttribute(attr, amount)
-
Lower an attribute by name
Parameters:
Name Type Description attrstring amountnumber Fires:
- See:
-
Attributes#lower
-
raiseAttribute(attr, amount)
-
Raise an attribute by name
Parameters:
Name Type Description attrstring amountnumber Fires:
- See:
-
Attributes#raise
-
removeCombatant(target)
-
Parameters:
Name Type Description targetCharacter Fires:
-
removeEffect(effect)
-
Parameters:
Name Type Description effectEffect - See:
-
removeFollower(follower)
-
Parameters:
Name Type Description followerCharacter 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 itemItem -
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 attrstring Attribute name
newBasenumber New base value
Fires:
-
setAttributeToMax(attr)
-
Clears any changes to the attribute, setting it to its base value.
Parameters:
Name Type Description attrstring Fires:
-
unequip(slot)
-
Remove equipment in a given slot and move it to the character's inventory
Parameters:
Name Type Description slotstring 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 attributeNamestring attributeAttribute -
combatantAdded
-
Parameters:
Name Type Description targetCharacter -
combatantRemoved
-
Parameters:
Name Type Description targetCharacter -
combatEnd
-
-
combatStart
-
Fired when Character#initiateCombat is called
-
damaged
-
Parameters:
Name Type Description damageDamage finalAmountNumber -
effectAdded
-
-
effectRemoved
-
-
equip
-
Parameters:
Name Type Description slotstring itemItem -
followed
-
Parameters:
Name Type Description targetCharacter -
gainedFollower
-
Parameters:
Name Type Description followerCharacter -
heal
-
-
healed
-
Parameters:
Name Type Description healHeal finalAmountnumber -
hit
-
-
lostFollower
-
Parameters:
Name Type Description followerCharacter -
unequip
-
Parameters:
Name Type Description slotstring itemItem -
unfollowed
-
Parameters:
Name Type Description followingCharacter