Options
All
  • Public
  • Public/Protected
  • All
Menu

The client-side Actor document which extends the common BaseActor model.

mixes

ClientDocumentMixin

see

{@link documents.Actors} The world-level collection of Actor documents

see

{@link applications.ActorSheet} The Actor configuration application

example

Create a new Actor

let actor = await Actor.create({
name: "New Test Actor",
type: "character",
img: "artwork/character-profile.jpg"
});
example

Retrieve an existing Actor

let actor = game.actors.get(actorId);

Hierarchy

Index

Constructors

Methods

  • _configure(options?: {}): void
  • inheritdoc

    Parameters

    • options: {} = {}

      Returns void

    • applyActiveEffects(): void
    • Apply any transformations to the Actor data which are caused by ActiveEffects.

      Returns void

    • Retrieve an Array of active tokens which represent this Actor in the current canvas Scene. If the canvas is not currently active, or there are no linked actors, the returned Array will be empty. If the Actor is a synthetic token actor, only the exact Token which it represents will be returned.

      Parameters

      • linked: boolean = false
      • document: boolean = false

      Returns (TokenDocument | Token)[]

      An array of Token instances in the current Scene which reference this Actor.

    • Get all ActiveEffects that may apply to this Actor. If CONFIG.ActiveEffect.legacyTransferral is true, this is equivalent to actor.effects.contents. If CONFIG.ActiveEffect.legacyTransferral is false, this will also return all the transferred ActiveEffects on any of the Actor's owned Items.

      yields

      {ActiveEffect}

      Returns Generator<ActiveEffect, void, void>

    • getRollData(): any
    • Prepare a data object which defines the data schema used by dice roll commands against this Actor

      Returns any

    • Create a new Token document, not yet saved to the database, which represents the Actor.

      Parameters

      • data: any = {}

      Returns Promise<TokenDocument>

      The created TokenDocument instance

    • getTokenImages(): Promise<string[]>
    • Get an Array of Token images which could represent this Actor

      Returns Promise<string[]>

    • modifyTokenAttribute(attribute: string, value: number, isDelta?: boolean, isBar?: boolean): Promise<Actor>
    • Handle how changes to a Token attribute bar are applied to the Actor. This allows for game systems to override this behavior and deploy special logic.

      Parameters

      • attribute: string

        The attribute path

      • value: number

        The target attribute value

      • isDelta: boolean = false

        Whether the number represents a relative change (true) or an absolute change (false)

      • isBar: boolean = true

        Whether the new value is part of an attribute bar, or just a direct value

      Returns Promise<Actor>

      The updated Actor document

    • prepareEmbeddedDocuments(): void
    • inheritdoc

      Returns void

    • rollInitiative(options?: { createCombatants: boolean; rerollInitiative: boolean; initiativeOptions: any }): Promise<any>
    • Roll initiative for all Combatants in the currently active Combat encounter which are associated with this Actor. If viewing a full Actor document, all Tokens which map to that actor will be targeted for initiative rolls. If viewing a synthetic Token actor, only that particular Token will be targeted for an initiative roll.

      Parameters

      • options: { createCombatants: boolean; rerollInitiative: boolean; initiativeOptions: any } = {}

        Configuration for how initiative for this Actor is rolled.

        • createCombatants: boolean
        • rerollInitiative: boolean
        • initiativeOptions: any

      Returns Promise<any>

      A promise which resolves to the Combat document once rolls are complete.

    • Get this actor's dependent tokens. If the actor is a synthetic token actor, only the exact Token which it represents will be returned.

      Parameters

      Returns TokenDocument[]

    • Register a token as a dependent of this actor.

      internal

      Parameters

      Returns void

    • Remove a token from this actor's dependents.

      internal

      Parameters

      Returns void

    • _unregisterDependentScene(scene: Scene): void
    • Prune a whole scene from this actor's dependent tokens.

      internal

      Parameters

      Returns void

    • _preCreate(data: any, options: any, userId: any): Promise<void>
    • Perform preliminary operations before a Document of this type is created. Pre-creation operations only occur for the client which requested the operation. Modifications to the pending document before it is persisted should be performed with this.updateSource().

      Parameters

      • data: any

        The initial data object provided to the document creation request

      • options: any

        Additional options which modify the creation request

      • userId: any

        The User requesting the document creation

      Returns Promise<void>

      A return value of false indicates the creation operation should be cancelled.

    • _onUpdate(data: any, options: any, userId: any): void
    • override

      Parameters

      • data: any
      • options: any
      • userId: any

      Returns void

    • _onCreateDescendantDocuments(parent: any, collection: any, documents: any, data: any, options: any, userId: any): void
    • inheritdoc

      Parameters

      • parent: any
      • collection: any
      • documents: any
      • data: any
      • options: any
      • userId: any

      Returns void

    • _onUpdateDescendantDocuments(parent: any, collection: any, documents: any, changes: any, options: any, userId: any): void
    • inheritdoc

      Parameters

      • parent: any
      • collection: any
      • documents: any
      • changes: any
      • options: any
      • userId: any

      Returns void

    • _onDeleteDescendantDocuments(parent: any, collection: any, documents: any, ids: any, options: any, userId: any): void
    • inheritdoc

      Parameters

      • parent: any
      • collection: any
      • documents: any
      • ids: any
      • options: any
      • userId: any

      Returns void

    • _initializeSource(source: any, options: any): any
    • _preUpdate(changed: any, options: any, user: any): Promise<void>
    • Perform preliminary operations before a Document of this type is updated. Pre-update operations only occur for the client which requested the operation.

      Parameters

      • changed: any

        The differential data that is changed relative to the documents prior values

      • options: any

        Additional options which modify the update request

      • user: any

        The User requesting the document update

      Returns Promise<void>

      A return value of false indicates the update operation should be cancelled.

    • _applyDefaultTokenSettings(data: any, options?: { fromCompendium: boolean }): any
    • When an Actor is being created, apply default token configuration settings to its prototype token.

      Parameters

      • data: any

        Data explicitly provided to the creation workflow

      • options: { fromCompendium: boolean } = {}

        Options which configure creation

        • fromCompendium: boolean

      Returns any

    • _onEmbeddedDocumentChange(): void
    • Additional workflows to perform when any descendant document within this Actor changes.

      Returns void

    • _updateDependentTokens(update?: any, options?: DocumentModificationContext): void
    • Update the active TokenDocument instances which represent this Actor.

      Parameters

      • update: any = {}
      • options: DocumentModificationContext = {}

      Returns void

    • getDefaultArtwork(actorData: ActorData): { img: string; texture: { src: string } }
    • Determine default artwork based on the provided actor data.

      Parameters

      Returns { img: string; texture: { src: string } }

      Candidate actor image and prototype token artwork.

      • img: string
      • texture: { src: string }
        • src: string
    • canUserCreate(user: any): any
    • Test whether a given User has a sufficient role in order to create Documents of this type in general.

      Parameters

      • user: any

        The User being tested

      Returns any

      Does the User have a sufficient role to create?

    • migrateData(data: any): any
    • shimData(data: any, options: any): any
    • _requestTokenImages(actorId: string, options?: { pack: string }): Promise<string[]>
    • Request wildcard token images from the server and return them.

      Parameters

      • actorId: string

        The actor whose prototype token contains the wildcard image path.

      • options: { pack: string } = {}
        • pack: string

      Returns Promise<string[]>

      The list of filenames to token images that match the wildcard search.

    Properties

    overrides: any = ...

    An object that tracks which tracks the changes to the data model which were applied by active effects

    statuses: Set<string> = ...

    The statuses that are applied to this actor by active effects

    _lastWildcard: string = null

    Cache the last drawn wildcard token to avoid repeat draws

    _tokenImages: string[] = null

    A cached array of image paths which can be used for this Actor's token. Null if the list has not yet been populated.

    metadata: any = ...

    Default metadata which applies to each instance of this Document type.

    DEFAULT_ICON: string = CONST.DEFAULT_TOKEN

    The default icon used for newly created Actor documents.

    Accessors

    • get thumbnail(): string
    • Provide a thumbnail image path used to represent this document.

      Returns string

    • get itemTypes(): any
    • Provide an object which organizes all embedded Item instances by their type

      Returns any

    • get isToken(): boolean
    • Test whether an Actor document is a synthetic representation of a Token (if true) or a full Document (if false)

      Returns boolean

    • Retrieve the list of ActiveEffects that are currently applied to this Actor.

      Returns ActiveEffect[]

    • An array of ActiveEffect instances which are present on the Actor which have a limited duration.

      Returns ActiveEffect[]

    • Return a reference to the TokenDocument which owns this Actor as a synthetic override

      Returns TokenDocument

    • get inCombat(): boolean
    • Whether the Actor has at least one Combatant in the active Combat that represents it.

      Returns boolean

    • get TYPES(): string[]
    • The allowed set of Actor types which may exist.

      Returns string[]