Pathfinder 1e for Foundry VTT
    Preparing search index...

    Shared functionality for PCs and NPCs.

    Move PC/NPC functionality from ActorPF here.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Accessors

    Methods

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

    Constructors

    • Parameters

      • data: CreateData

        Initial data from which to construct the Actor

      • Optionalcontext: ConstructionContext

        Construction context options

      Returns ActorNPCPF

    Properties

    _rollData: any
    changeFlags: Record<string, boolean>

    Change flags

    changeOverrides: Record<keyof typeof buffTargets, Record<"add" | "set", any>>

    Overrides applied by changes

    changes: Collection<ItemChange>

    All changes from carried items and virtual ones.

    classes: Record<string, ClassInfo>
    itemFlags: {
        boolean: Record<string, { sources: ItemPF[] }>;
        dictionary: Record<string, Record<any>>;
    }

    Item dictionary and boolean flags

    sourceInfo: Record<string, SourceInfoGroup>

    Source info

    Partial duplicate of changes and manual adjustments.

    This structure should be removed in favor of storing the info in changes.

    BASE_10_VALUES: Set<
        | "system.attributes.ac.normal.total"
        | "system.attributes.ac.flatFooted.total"
        | "system.attributes.ac.touch.total"
        | "system.attributes.cmd.total"
        | "system.attributes.cmd.flatFootedTotal",
    > = ...

    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[]

    • get activeOwner(): null | User

      Returns first active owner, favoring players and GM as fallback.

      Returns null | User

    Methods

    • Internal

      Parameters

      • parent: Actor<"base" | ModuleSubType> | Item<"base" | ModuleSubType>

        Parent document

      • collection: "items" | "effects"

        Collection name

      • documents: ActiveEffect<"base" | ModuleSubType>[] | Item<"base" | ModuleSubType>[]

        Created documents

      • result: object[]

        Creation data for the documents

      • context: object

        Create context options

      • userId: string

        Triggering user's ID

      • ...args: any

      Returns void

    • Internal

      Parameters

      • parent: any

        Parent document

      • collection: "items" | "effects"

        Collection name

      • documents: Item<"base" | ModuleSubType> | ActiveEffect<"base" | ModuleSubType>[]

        Document array

      • ids: string[]

        Document ID array

      • context: object

        Delete context

      • userId: string

        User ID

      Returns void

    • Internal

      Parameters

      • data: object

        Creation data

      • context: object

        Context

      • user: User

        Triggering user

      Returns Promise<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 undefined

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

      Returns Promise<null | TokenDocument[]>

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

      Add option to update token size on all scenes.

      • On invalid parameters
    • Adjust temporary hit points.

      Parameters

      • value: number

        Value to add to temp HP

      • Optionaloptions: { set?: boolean } = {}

        Additional options

        • Optionalset?: boolean

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

      Returns Promise<undefined | ActorNPCPF>

      • Updated document or undefined if no update occurred

      Gain 50 THP

      actor.addTempHP(50);
      

      Lose 10 THP

      actor.addTempHP(-10);
      

      Set THP to zero

      actor.addTempHP(0, { set: true });
      
    • Apply damage or healing to actor.

      Does not handle ER/DR or anything else special.

      Parameters

      • value: number = 0

        Value to adjust health by. Positive values deal damage, negative values heal.

      • Optionaloptions: ApplyDamageOptions = {}

        Additional options. This object will be transformed in-place as the damage application is processed.

      Returns Promise<false | Actor<"base" | ModuleSubType>>

      • Updated actor or false.

      ActorPF.applyDamage - For more general use.

      Cause 10 damage

      await actor.applyDamage(10);
      

      Heal 10 damage

      await actor.applyDamage(-10);
      

      Apply 3 damage directly to Wounds instead of Vigor

      await actor.applyDamage(3, { asWounds: true });
      
      • pf1ApplyDamage
    • Enable and configure a new spellbook.

      Parameters

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

        Book casting configuration

        • Optionalability?: string

          Spellcasting ability score ID

        • Optionalcantrips?: boolean

          Has cantrips?

        • Optionalclass?: string

          Class tag

        • Optionaldomain?: number

          Domain/School slots

        • Optionaloffset?: number

          Level offset

        • Optionalprogression?: "high" | "med" | "low"

          Casting progression type

        • Optionalspells?: "arcane" | "divine" | "psychic" | "alchemy"

          Spell/spellcasting type

        • Optionaltype?: "prepared" | "spontaneous" | "hybrid"

          Spellbook type

      • Optionaloptions: { commit?: boolean } = {}

        Additional options

        • Optionalcommit?: boolean

          Commit modifications. If false, update data is returned instead of committing.

      Returns Promise<ActorNPCPF>

      • 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?: null | string; token?: TokenDocument } = {}

        Additional options

        • OptionalrollMode?: null | string

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

        • Optionaltoken?: TokenDocument

          Relevant token if any.

      Returns Promise<undefined | ChatMessage<"base" | ModuleSubType>>

      • 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?: boolean } = {}

        Additional options

        • Optionalroll?: boolean

          Handle rolls

      Returns Promise<void>

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

      Parameters

      • Optionaloptions: {
            combat?: Combat<"base" | ModuleSubType>;
            event?: string;
            initiative?: number;
            timeOffset?: number;
            worldTime?: number;
        } = {}

        Additional options

        • Optionalcombat?: Combat<"base" | ModuleSubType>

          Combat to expire data in, if relevant

        • Optionalevent?: string

          Expiration event

        • Optionalinitiative?: number

          Initiative based expiration marker

        • OptionaltimeOffset?: number

          Time offset from world time

        • OptionalworldTime?: number

          World time

      • Optionalcontext: any = {}

        Document update context

      Returns Promise<void>

      • With insufficient permissions to control the actor.
    • Get related combatants.

      Parameters

      • Optionalcombat: Combat<"base" | ModuleSubType> = game.combat

        Combat instance

      Returns Combatant<"base" | ModuleSubType>[]

      Related combatants.

    • Get total currency in category.

      Parameters

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

        Currency category.

      • Optionaloptions: { inLowestDenomination?: boolean } = {}

        Additional options

        • OptionalinLowestDenomination?: boolean

          Return result in lowest denomination (default copper). If false, returns standard currency (default gold) instead.

      Returns number

      • Total currency in category.
    • Protected

      Parameters

      • Optionaloptions: { damageResistances?: boolean; damageVulnerabilities?: boolean } = {}

        Additional options

        • OptionaldamageResistances?: boolean

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

        • OptionaldamageVulnerabilities?: boolean

          If false, damage vulnerabilities are omitted.

      Returns any

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

      Parameters

      • Optionaloptions: { cache?: boolean; refresh?: boolean } = ...

        Additional options

        • Optionalcache?: boolean

          Use cache. If set to false, new fresh copy is returned without caching it.

        • Optionalrefresh?: boolean

          Refresh cache

      Returns object

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

      Parameters

      • skillId: string

        Skill ID

      • Optionaloptions: { rollData?: { skills: Record<string, SkillData> } } = {}

        Additional options

        • OptionalrollData?: { skills: Record<string, SkillData> }

          Roll data instance to use.

      Returns null | SkillInfo

      • Skill information or null if the skill was not found
      actor.getSkillInfo("per"); // Perception skill info
      actor.getSkillInfo("crf.alchemy"); // Craft (Alchemy) subskill info
    • 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?: boolean } = {}

        Additional options

        • OptionalinLowestDenomination?: boolean

          Use copper for calculations, otherwise pf1.config.currency.standard standard denomination is used.

      Returns number

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

      Returns Wound Threshold relevant data.

      Parameters

      • Optionaloptions: { healthConfig?: object } = {}

        Additional options

        • OptionalhealthConfig?: object

          PC/NPC health config variant data

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

      • Wound threshold info
    • Protected

      Returns effective Wound Threshold multiplier with rules and overrides applied.

      Parameters

      • Optionaloptions: { healthConfig?: object } = {}

        Additional options

        • OptionalhealthConfig?: 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

      Test if user is grappled

      actor.hasCondition("grappled");
      

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

    • Restore spellbook used slots and spellpoints.

      Parameters

      • Optionaloptions: { commit?: boolean; rollData?: object } = {}

        Additional options

        • Optionalcommit?: boolean

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

        • OptionalrollData?: object

          Roll data

      Returns Promise<object | ActorNPCPF>

      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: AbilityId

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

      • Optionaloptions: ActorRollOptions = {}

        Additional options

      Returns Promise<void | object | ChatMessage<"base" | ModuleSubType>>

      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

      • Optionaloptions: ActorRollOptions = {}

        Roll options

        • Optionalaction?: string

          The selected sub-action depending on the context.

        • actions: unknown
        • Optionalbonus?: string

          Bonus to the roll.

        • OptionalchatMessage?: boolean

          Whether a chat message should be created.

          true

        • Optionaldc?: number

          DC threshold

        • Optionaldice?: string

          The roll's d20 die (replacement), or the static result the d20 should have.

          "1d20"

        • Optionalmaneuver?: any
        • OptionalmessageData?: object

          Additional data to add to the chat message.

        • OptionalnoSound?: boolean

          Whether no dice sound should be played when the chat message is created.

          false

        • OptionalrollMode?: string

          The rollMode with which the chat message is created.

          game.settings.get("core", "rollMode")

        • OptionalskipDialog?: boolean

          Whether a user facing dialog should be shown.

          true

        • OptionalstaticRoll?: number

          A number used as a static roll result of the d20. If null, the d20 is rolled normally and the result is used.

          undefined

        • Optionaltoken?: TokenDocument

          Associated token if any.

      Returns Promise<void | object | ChatMessage<"base" | ModuleSubType>>

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

      Basic ranged attack

      await actor.rollAttack({ ranged: true });
      

      Basic melee maneuver

      await actor.rollAttack({ maneuver: true });
      
    • 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<"base" | ModuleSubType>>

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

      Roll caster level check for primary spellbook.

      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<"base" | ModuleSubType>>

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

      Add support for concentration check type, e.g. defensive casting

    • 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?: null | string;
            createCombatants?: boolean;
            dice?: null | string;
            initiativeOptions?: object;
            rerollInitiative?: boolean;
            rollMode?: string;
            skipDialog?: boolean;
            token?: TokenDocumentPF;
        } = {}

        Options which configure how initiative is rolled

        • Optionalbonus?: null | string

          Formula for bonus to initiative

        • OptionalcreateCombatants?: boolean

          Create new Combatant entries for tokens associated with this actor.

        • Optionaldice?: null | string

          Formula override for dice to roll

        • OptionalinitiativeOptions?: object

          Options to pass to ()

        • OptionalrerollInitiative?: boolean

          Reroll initiative for existing Combatants

        • OptionalrollMode?: string

          Roll mode override

        • OptionalskipDialog?: boolean

          Skip roll dialog

        • Optionaltoken?: 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 });
      
    • Roll a specific saving throw

      Parameters

      • savingThrowId: SaveId

        Identifier for saving throw type.

      • Optionaloptions: ActorRollOptions = {}

        Roll options.

      Returns Promise<void | object | ChatMessage<"base" | ModuleSubType>>

      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<"base" | ModuleSubType>>

      • 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 Promise<object>

      Condition ID to boolean mapping of actual updates.

      Enable Dazzled

      await actor.setCondition("dazzled", true);
      

      Enable Sleep for 10 rounds

      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.

      Enable Blinded and Shaken conditions but disable Sleeping

      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 Promise<object>

      Condition ID to boolean mapping of actual updates.

      Toggle Dazzled

      await actor.toggleCondition("dazzled");
      

      Toggle Blinded, set duration for 3 rounds if it's being enabled.

      await actor.toggleCondition("blinded", { duration: { seconds: 18 } });
      
    • Override to support toggling buffs and operating the system's condition tracks

      Called by TokenHUD

      Parameters

      • statusId: string

        Status/condition ID

      • Optionaloptions: { active?: boolean; interaction?: boolean; overlay?: boolean } = {}

        Additional options

        • Optionalactive?: boolean

          Force active state

        • Optionalinteraction?: boolean

          Nonstandard. Is this triggered by user interaction?

        • Optionaloverlay?: boolean

          Overlay effect

      Returns Promise<undefined | boolean | ActiveEffect<"base" | ModuleSubType>>

      Synced with Foundry v13.342

      Add separate listener for buffs

    • Internal

      Parameters

      • item: ItemPF

        the item to add to the actor's resources

      • Optionaloptions: { warnOnDuplicate?: boolean } = {}

        extra options

        • OptionalwarnOnDuplicate?: boolean

          Skips warning if item tag already exists in dictionary flags

      Returns boolean

      True if resources were set

    • Apply damage to the token or tokens which are currently controlled.

      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. Negative values heal instead.

      • Optionaloptions: TargetedApplyDamageOptions = {}

        Object containing default settings for overriding

      Returns Promise<false | Actor<"base" | ModuleSubType>[]>

      • False if cancelled or array of updated actors.
      • If no valid targets are provided.
    • Get melee and reach maximum ranges.

      Parameters

      • size: any = "med"

        Actor size as size key or number

      • stature: ActorStature = "tall"

        Actor stature

      Returns { melee: number; reach: number }

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