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

Properties

overrides: any = {}

An object that tracks which tracks the changes to the data model which were applied 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

  • 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 uuid(): any
  • inheritdoc

    Returns any

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

    Returns string[]

Methods

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

    Returns void

  • getActiveTokens(linked?: boolean, document?: boolean): Token[]
  • 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 Token[]

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

  • 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.

  • _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>

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

    Parameters

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

    Returns void

  • _onCreateEmbeddedDocuments(embeddedName: any, ...args: any[]): void
  • inheritdoc

    Parameters

    • embeddedName: any
    • Rest ...args: any[]

    Returns void

  • _onUpdateEmbeddedDocuments(embeddedName: any, ...args: any[]): void
  • inheritdoc

    Parameters

    • embeddedName: any
    • Rest ...args: any[]

    Returns void

  • _onDeleteEmbeddedDocuments(embeddedName: any, ...args: any[]): void
  • inheritdoc

    Parameters

    • embeddedName: any
    • Rest ...args: 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>

  • _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(embeddedName: string): void
  • Perform various actions on active tokens if embedded documents were changed.

    Parameters

    • embeddedName: string

      The type of embedded document that was modified.

    Returns void

  • 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.