Extend the base Actor class to implement additional game system logic.

Hierarchy (view full)

Constructors

Properties

Accessors

Methods

_applyArmorPenalties _calculateCoinWeight _cleanItemLinksTo _computeEncumbrance _conditionToggleNotify _configure _finalizeTraits _generateSpellbookCache _getInherentTotalsKeys _handleConditionTracks _initialize _onCreateDescendantDocuments _onDeleteDescendantDocuments _onUpdate _prepareArmorData _prepareChanges _prepareClassSkills _prepareContainerItems _prepareCR _prepareItemFlags _prepareNaturalReach _prepareOverlandSpeeds _prepareSenses _prepareTraits _prepareTypeChanges _preUpdate _resetInherentTotals _restingHeal _setSourceDetails _updateSpellBook addTempHP applyActiveEffects applyDamage convertCurrency createSpellbook displayDefenseCard enrichContextNotes expireActiveEffects getCarriedWeight getCarryCapacity getCombatants getConditionImmunities getContextNotes getContextNotesParsed getCurrency getDefenseHeaders getFeatCount getInitiativeOptions getItemByTag getLabels getLevelExp getQuickActions getRollData getSkillInfo getTokenDocument getTotalCurrency getWoundThresholdData getWoundThresholdMultiplier hasArmorProficiency hasCondition hasItemBooleanFlag hasWeaponProficiency modifyTokenAttribute parseResistances performRest prepareBaseData prepareCMB prepareConditions prepareDerivedData prepareHealth prepareItemLinks prepareSpecificDerivedData rechargeItems refreshAbilityModifiers refreshDerivedData reset resetSpellbookUsage rollAbilityTest rollAttack rollBAB rollCL rollConcentration rollInitiative rollSavingThrow rollSkill setCondition setConditions toggleCondition toggleStatusEffect updateItemResources updateSpellbookInfo updateTokenSize updateVision updateWoundThreshold _getSourceLabel _onChatCardButtonAction applyDamage chatListeners getDefaultArtwork getReach getReducedMovementSpeed getSpellSlotIncrease

Constructors

  • Parameters

    • data: undefined | ActorDataConstructorData

      Initial data provided to construct the Actor document

    • Optionalcontext: Context<TokenDocument>

      The document context, see foundry.abstract.Document

    Returns ActorHauntPF

Properties

_initialized: undefined | boolean
_itemTypes: ItemTypesMap

Cached result of .itemTypes

_rollData: any
changeFlags: undefined | {}
changes: undefined | Collection<any>
classes: undefined | {}
containerItems: undefined | any[]
equipment: undefined | {
    armor: {
        id: undefined;
        type: 0;
    };
    shield: {
        id: undefined;
        type: 0;
    };
}
sourceDetails: undefined | {
    system.attributes.bab.total: any[];
}
sourceInfo: undefined | Record<string, SourceInfo>

Accessors

  • get _skillTargets(): string[]
  • Internal

    Retrieve valid skill change targets for this actor.

    Returns string[]

    • Skill target array
  • get _spellbookTargets(): string[]
  • Internal

    Change target paths for spellbooks on the actor.

    Returns string[]

Methods

  • Internal

    Parameters

    • parent: Item | Actor

      Parent document

    • collection: "effects" | "items"

      Collection name

    • documents: ActiveEffect[] | Item[]

      Created documents

    • result: object[]

      Creation data for the documents

    • context: object

      Create context options

    • userId: string

      Triggering user's ID

    • Rest...args: any

    Returns void

  • Internal

    Parameters

    • parent: any
    • collection: "effects" | "items"

      Collection name

    • documents: Item | ActiveEffect[]

      Document array

    • ids: string[]

      Document ID array

    • context: object

      Delete context

    • userId: string

      User ID

    Returns void

  • Internal

    Prepare armor/shield data for roll data

    Parameters

    • equipment: {
          id: string;
          type: string;
      } = {}

      Equipment info

      • id: string

        Item ID

      • type: string

        Armor/Shield type

    • armorData: object

      Armor data object

    Returns void

  • Internal

    Update specific spellbook.

    Parameters

    • bookId: string

      Spellbook identifier

    • OptionalrollData: object

      Roll data instance

    • cache: object

      Pre-calculated data for re-use from _generateSpellbookCache

    Returns void

  • Adjust temporary hit points.

    Parameters

    • value: number

      Value to add to temp HP

    • Optionaloptions: {
          set: undefined | boolean;
      } = {}

      Additonal optons

      • set: undefined | boolean

        If true, the temporary hit points are set to the provide value instead of added to existing.

    Returns Promise<undefined | ActorHauntPF>

    • Updated document or undefined if no update occurred
    actor.addTempHP(50); // Gain 50 THP
    actor.addTempHP(-10); // Lose 10 THP
    actor.addTempHP(0, {set:true}); // Set THP to zero
  • Wrapper for the static function, taking this actor as the only target.

    Parameters

    • value: number

      Value to adjust health by.

    • options: object = {}

      Additional options.

    Returns Promise<any>

    await actor.applyDamage(10); // Cause 10 damage
    await actor.applyDamage(-10): // Heal 10 damage
    await actor.applyDamage(3, { asWounds: true }); // Apply 3 damage directly to Wounds instead of Vigor
  • Converts currencies of the given category to the given currency type

    Parameters

    • Optionalcategory: "currency" | "altCurrency" = "currency"

      Currency category, altCurrency is for weightless

    • Optionaltype:
          | "pp"
          | "gp"
          | "sp"
          | "cp" = "pp"

      Target currency.

    Returns undefined | Promise<ActorHauntPF>

    Updated document or undefined if no update occurred.

  • Enable and configure a new spellbook.

    Parameters

    • Optionalcasting: {
          ability: undefined | string;
          cantrips: undefined | boolean;
          class: undefined | string;
          domain: undefined | number;
          offset: undefined | number;
          progression:
              | undefined
              | "low"
              | "high"
              | "med";
          spells:
              | undefined
              | "arcane"
              | "divine"
              | "psychic"
              | "alchemy";
          type:
              | undefined
              | "prepared"
              | "spontaneous"
              | "hybrid";
      } = {}

      Book casting configuration

      • ability: undefined | string

        Spellcasting ability score ID

      • cantrips: undefined | boolean

        Has cantrips?

      • class: undefined | string

        Class tag

      • domain: undefined | number

        Domain/School slots

      • offset: undefined | number

        Level offset

      • progression:
            | undefined
            | "low"
            | "high"
            | "med"

        Casting progression type

      • spells:
            | undefined
            | "arcane"
            | "divine"
            | "psychic"
            | "alchemy"

        Spell/spellcasting type

      • type:
            | undefined
            | "prepared"
            | "spontaneous"
            | "hybrid"

        Spellbook type

    • __namedParameters: {
          commit: undefined | boolean;
      } = {}
      • commit: undefined | boolean

    Returns Promise<ActorHauntPF>

    • Promise to updated document
    // Create spellbook for inquisitor
    actor.createSpellbook({ type: "spontaneous", progression: "med", ability: "wis", spells: "divine", class: "inquisitor", cantrips: true, domain: 0 });
  • Show defenses in chat

    Parameters

    • Optionaloptions: {
          rollMode: undefined | null | string;
          token: undefined | TokenDocument;
      } = {}

      Additional options

      • rollMode: undefined | null | string

        The roll mode to use for the roll; defaults to the user's current preference when null.

      • token: undefined | TokenDocument

        Relevant token if any.

    Returns undefined | ChatMessage

    • Created message
  • Enrich context notes with item specific roll data.

    Adds enriched array to each note object.

    Parameters

    • notes: ItemContextNotes

      Context notes

    • OptionalrollData: object

      Roll data instance

    • Optionaloptions: {
          roll: undefined | boolean;
      } = {}

      Additional options

      • roll: undefined | boolean

        Handle rolls

    Returns Promise<void>

  • Deletes expired temporary active effects and disables linked expired buffs.

    Parameters

    • Optionaloptions: {
          combat: undefined | Combat;
          event: undefined | string;
          initiative: undefined | number;
          timeOffset: undefined | number;
          worldTime: undefined | number;
      } = {}

      Additional options

      • combat: undefined | Combat

        Combat to expire data in, if relevant

      • event: undefined | string

        Expiration event

      • initiative: undefined | number

        Initiative based expiration marker

      • timeOffset: undefined | number

        Time offset from world time

      • worldTime: undefined | number

        World time

    • Optionalcontext: DocumentModificationContext = {}

      Document update context

    Returns Promise<void>

    • With insufficient permissions to control the actor.
  • Calculate current carry capacity limits.

    Returns {
        heavy: number;
        light: number;
        medium: number;
    }

    • Capacity info
    • heavy: number
    • light: number
    • medium: number
  • Get total currency in category.

    Parameters

    • Optionalcategory: "currency" | "altCurrency" = "currency"

      Currency category.

    • Optionaloptions: {
          inLowestDenomination: undefined | boolean;
      } = {}

      Additional options

      • inLowestDenomination: undefined | boolean

        Return result in lowest denomination. If false, returns gold instead.

    Returns number

    • Total currency in category.
  • Protected

    Parameters

    • Optionaloptions: {
          damageResistances: undefined | boolean;
          damageVulnerabilities: undefined | boolean;
      } = {}

      Additional options

      • damageResistances: undefined | boolean

        If false, damage resistances (DR, ER) are omitted.

      • damageVulnerabilities: undefined | boolean

        If false, damage vulnerabilities are omitted.

    Returns any

    • Header data
  • Retrieve data used to fill in roll variables.

    Parameters

    • options: {
          refresh: boolean;
      } = ...

      Additional options

      • refresh: boolean

    Returns any

    • Roll data object
    await new Roll("1d20 + @abilities.wis.mod[Wis]", actor.getRollData()).toMessage();

    @override
  • Retrieve information about a skill.

    Parameters

    • skillId: string

      Skill ID

    • Optionaloptions: {
          rollData: undefined | {
              skills: {
                  [key: string]: SkillData;
              };
          };
      } = {}

      Additional options

      • rollData: undefined | {
            skills: {
                [key: string]: SkillData;
            };
        }

        Roll data instance to use.

    Returns SkillInfo

    • Skill information
    actor.getSkillInfo("per"); // Perception skill info
    actor.getSkillInfo("crf.alchemy"); // Craft (Alchemy) subskill info
    • If defined skill is not found.
  • Create a new Token document, not yet saved to the database, which represents the Actor, and apply actor size to it.

    Parameters

    • Optionaldata: object = {}

      Additional data, such as x, y, rotation, etc. for the created token data

    • Optionaloptions: object = {}

      The options passed to the TokenDocument constructor

    Returns Promise<TokenDocumentPF>

    The created TokenDocument instance

  • Total coinage in both weighted and weightless.

    Parameters

    • Optionaloptions: {
          inLowestDenomination: undefined | boolean;
      } = {}

      Additional options

      • inLowestDenomination: undefined | boolean

        Use copper for calculations and return.

    Returns number

    • The total amount of currency, in copper pieces.
  • Protected

    Returns Wound Threshold relevant data.

    Parameters

    • Optionaloptions: {
          healthConfig: undefined | object;
      } = {}

      Additional options

      • healthConfig: undefined | object

        PC/NPC health config variant data

    Returns {
        level: number;
        multiplier: number;
        penalty: number;
        valid: boolean;
    }

    • Wound threshold info
    • level: number
    • multiplier: number
    • penalty: number
    • valid: boolean
  • Protected

    Returns effective Wound Threshold multiplier with rules and overrides applied.

    Parameters

    • Optionaloptions: {
          healthConfig: undefined | object;
      } = {}

      Additional options

      • healthConfig: undefined | object

        PC/NPC health config variant data

    Returns number

    Multiplier

  • Easy way to determine whether this actor has a condition.

    Parameters

    • conditionId: string

      A direct condition key, as per pf1.registry.conditions, such as shaken or dazed.

    Returns boolean

    Condition state

    actor.hasCondition("grappled");
    

    This is identical to actor.statuses.has("conditionId")

  • Test if actor is proficient with specified weapon.

    Parameters

    • item: ItemPF

      Item to test

    • Optionaloptions: {
          override: undefined | boolean;
      } = {}

      Additional options

      • override: undefined | boolean

        Allow item's proficiency override to influence the result.

    Returns boolean

    • Proficiency state

    Natural attacks incorrectly do not count as proficient.

  • Protected

    Helper function for actor energy resistance and damage reduction feedback.

    Parameters

    • damage: string

      Value to check resistances for. Either "dr" or "eres".

    Returns object

    Entry to label mapping of resistances or reductions.

  • Restore spellbook used slots and spellpoints.

    Parameters

    • Optionaloptions: {
          commit: undefined | boolean;
          rollData: undefined | object;
      } = {}

      Additional options

      • commit: undefined | boolean

        If false, return update data object instead of directly updating the actor.

      • rollData: undefined | object

        Roll data

    Returns Promise<object | ActorHauntPF>

    Result of update or the update data.

  • Roll an Ability Test Prompt the user for input regarding Advantage/Disadvantage and any Situational Bonus

    Parameters

    • abilityId: string

      The ability ID (e.g. "str")

    • Optionaloptions: object = {}

      Additional options

    Returns Promise<void | object | ChatMessage>

    The chat message if one was created, or its data if not. void if the roll was cancelled.

    await actor.rollAbilityTest("str");
    
  • Roll a generic attack

    Parameters

    Returns Promise<void | object | ChatMessage>

    The chat message if one was created, or its data if not. void if the roll was cancelled.

    await actor.rollAttack({ ranged: true }); // Basic ranged attack
    await actor.rollAttack({ maneuver: true }); // Basic melee maneuver
  • Roll basic BAB check

    Parameters

    Returns Promise<void | object | ChatMessage>

    The chat message if one was created, or its data if not. void if the roll was cancelled.

  • Roll a Caster Level check using a particular spellbook of this actor

    Parameters

    • bookId: string

      Spellbook identifier

    • Optionaloptions: ActorRollOptions = {}

      Roll options

    Returns Promise<void | object | ChatMessage>

    The chat message if one was created, or its data if not. void if the roll was cancelled.

    await actor.rollCL("primary");
    
  • Roll a concentration check using a particular spellbook of this actor

    Parameters

    • bookId: string

      Spellbook identifier

    • Optionaloptions: ActorRollOptions = {}

      Roll options

    Returns Promise<void | object | ChatMessage>

    The chat message if one was created, or its data if not. void if the roll was cancelled.

  • Roll initiative for one or multiple Combatants associated with this actor. If no combat exists, GMs have the option to create one. 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

    • Optionaloptions: {
          bonus: undefined | null | string;
          createCombatants: undefined | boolean;
          dice: undefined | null | string;
          initiativeOptions: undefined | object;
          rerollInitiative: undefined | boolean;
          rollMode: undefined | string;
          skipDialog: undefined | boolean;
          token: undefined | TokenDocumentPF;
      } = {}

      Options which configure how initiative is rolled

      • bonus: undefined | null | string

        Formula for bonus to initiative

      • createCombatants: undefined | boolean

        Create new Combatant entries for tokens associated with this actor.

      • dice: undefined | null | string

        Formula override for dice to roll

      • initiativeOptions: undefined | object

        Options to pass to ()

      • rerollInitiative: undefined | boolean

        Reroll initiative for existing Combatants

      • rollMode: undefined | string

        Roll mode override

      • skipDialog: undefined | boolean

        Skip roll dialog

      • token: undefined | TokenDocumentPF

        For which token this initiative roll is for

    Returns Promise<null | CombatPF>

    The updated Combat document in which initiative was rolled, or null if no initiative was rolled

    await actor.rollInitiative({ dice: "2d20kh", createCombatants: true, skipDialog: true });

    @override
  • Roll a specific saving throw

    Parameters

    • savingThrowId: "fort" | "ref" | "will"

      Identifier for saving throw type.

    • Optionaloptions: ActorRollOptions = {}

      Roll options.

    Returns Promise<void | object | ChatMessage>

    The chat message if one was created, or its data if not. void if the roll was cancelled.

    await actor.rollSavingThrow("ref", { skipDialog: true, dice: "2d20kh", bonus: "4" });
    
  • Roll a Skill Check

    Parameters

    • skillId: string

      The skill id (e.g. "per", "prf.prf1", or "crf.alchemy")

    • Optionaloptions: ActorRollOptions = {}

      Options which configure how the skill check is rolled

    Returns Promise<void | object | ChatMessage>

    The chat message if one was created, or its data if not. void if the roll was cancelled.

    await actor.rollSkill("per", { skipDialog: true, bonus: "1d6", dice: "2d20kh" });
    
  • Easy way to set a condition.

    Parameters

    • conditionId: string

      A direct condition key, as per pf1.registry.conditions, such as shaken or dazed.

    • enabled: boolean | object

      Whether to enable (true) the condition, or disable (false) it. Or object for merging into the active effect as part of enabling.

    • Optionalcontext: object

      Update context

    Returns object

    Condition ID to boolean mapping of actual updates.

    await actor.setCondition("dazzled", true);
    await actor.setCondition("sleep", { duration: { seconds: 60 } });
  • Set state of multiple conditions. Also handles condition tracks to minimize number of updates.

    Parameters

    • conditions: object = {}

      Condition ID to boolean (or update data) mapping of new condition states. See ()

    • Optionalcontext: object = {}

      Update context

    Returns Record<string, boolean>

    Condition ID to boolean mapping of actual updates.

    await actor.setConditions({ blind: true, sleep: false, shaken:true });
    
  • Easy way to toggle a condition.

    Parameters

    • conditionId: boolean

      A direct condition key, as per pf1.registry.conditions, such as shaken or dazed.

    • OptionalaeData: object

      Extra data to add to the AE if it's being enabled

    Returns object

    Condition ID to boolean mapping of actual updates.

    await actor.toggleCondition("dazzled");
    
  • Internal

    Parameters

    • item: ItemPF

      the item to add to the actor's resources

    • Optionaloptions: {
          warnOnDuplicate: undefined | boolean;
      } = {}

      extra options

      • warnOnDuplicate: undefined | boolean

        Skips warning if item tag already exists in dictionary flags

    Returns boolean

    True if resources were set

  • Internal

    Resize token sizes based on actor size.

    Ignores tokens with static size set.

    Parameters

    • OptionalsizeKey: string = undefined

      Size key to update to. If not provided, will use actor's current size.

    • Optionaloptions: object = {}

      Additional options

    Returns null | Promise<TokenDocument[]>

    • Updated token documents, or null if no update was performed.

    Add option to update token size on all scenes.

    • On invalid parameters
  • Internal

    Synchronize actor and token vision

    Parameters

    • initializeVision: boolean = false

      Initialize vision

    • refreshLighting: boolean = false

      Refresh lightning

    Returns void

  • Apply rolled dice damage to the token or tokens which are currently controlled. This allows for damage to be scaled by a multiplier to account for healing, critical hits, or resistance If Shift is held, will prompt for adjustments based on damage reduction and energy resistances

    Parameters

    • value: number = 0

      The amount of damage to deal.

    • Optionaloptions: {
          asNonlethal: undefined | boolean;
          asWounds: undefined | boolean;
          critMult: undefined | number;
          dualHeal: undefined | boolean;
          element: undefined | Element;
          event: undefined | Event;
          forceDialog: undefined | boolean;
          instances: undefined | DamageInstance[];
          message: undefined | ChatMessage;
          reductionDefault: undefined | string;
          targets: undefined | (Token | Actor)[];
      } = {}

      Object containing default settings for overriding

      • asNonlethal: undefined | boolean

        Marks the damage as non-lethal

      • asWounds: undefined | boolean

        Apply damage to wounds directly instead of vigor, as needed for Wounds & Vigor variant health rule.

      • critMult: undefined | number

        Critical multiplier as needed for Wounds & Vigor variant health rule. Set to 0 for non-critical hits.

      • dualHeal: undefined | boolean

        Is this dual dealing? If enabled, healing affects both normal health and nonlethal.

      • element: undefined | Element

        Triggering element, if any.

      • event: undefined | Event

        Triggering event, if any

      • forceDialog: undefined | boolean

        Forces the opening of a Dialog as if Shift was pressed

      • instances: undefined | DamageInstance[]

        Individual instances of damage. This is not processed currently.

      • message: undefined | ChatMessage

        Chat message reference if any. This is to help modules, the system does not use it.

      • reductionDefault: undefined | string

        Default value for Damage Reduction

      • targets: undefined | (Token | Actor)[]

        Override the targets to apply damage to

    Returns Promise<false | Actor[]>

    • False if cancelled or array of updated actors.
  • Get melee and reach maximum ranges.

    Parameters

    • size:
          | number
          | "col"
          | "med"
          | "fine"
          | "dim"
          | "tiny"
          | "sm"
          | "lg"
          | "huge"
          | "grg" = "med"

      Actor size as size key or number

    • stature: "tall" | "long" = "tall"

      Actor stature

    Returns {
        melee: number;
        reach: number;
    }

    • Ranges
    • melee: number
    • reach: number
  • Return increased amount of spell slots by ability score modifier.

    Parameters

    • mod: number

      The associated ability modifier.

    • level: number

      Spell level.

    Returns number

    Amount of spell levels to increase.

    pf1.documents.actor.ActorPF.getSpellSlotIncrease(2, 1); // => 1
    pf1.documents.actor.ActorPF.getSpellSlotIncrease(6, 1); // => 2
    pf1.documents.actor.ActorPF.getSpellSlotIncrease(6, 7); // => 0