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

    Class ItemPF<Model>

    Item document extension

    Provides baseline support for system data models and module added subtypes.

    Type Parameters

    • Model

    Hierarchy

    • any
      • ItemPF
    Index

    General

    Advanced

    Containers

    Deprecated

    Flags

    Internal

    Links

    User

    General

    actions: any
    changes: any
    constructor: typeof ItemPF
    links: Record<string, ItemPF<BaseItemModel>> | undefined

    An object containing links to other items.

    scriptCalls: any
    system: Model
    type:
        | "ammo"
        | "class"
        | "race"
        | "feat"
        | "attack"
        | "spell"
        | "loot"
        | "weapon"
        | "equipment"
        | "implant"
        | "consumable"
        | "container"
        | "buff"
    • get actionTypes(): string[]

      An array containing all action types from this item's actions.

      Returns string[]

    • get addonMaterial(): Set<string>

      The item's material addons.

      Returns Set<string>

    • get alignmentChange(): object | null

      Returns object | null

    • get alignmentChangePriority(): number

      Returns number

    • get alignments(): string | null

      The item's alignment attributes, or null if the item has no alignment attributes

      Returns string | null

    • get auraStrength(): number

      Aura strength as number from 0 to 4.

      Returns number

    • get autoDeductCharges(): boolean

      Consumes or adds charges by default.

      Returns boolean

    • get baseMaterial(): string | null

      Base material

      Returns string | null

    • get canUse(): boolean

      Is this item usable at base level, disregarding per-action details.

      Returns boolean

    • get charges(): number

      Remaining charges

      Returns number

    • get defaultAction(): Action | undefined

      Returns Action | undefined

    • get defaultAmmo(): any

      Linked ammunition item if any.

      Returns any

    • get effect(): any

      An active effect associated with this item.

      Returns any

      • Most item types don't have associated effect.
    • get hasAction(): boolean

      Returns boolean

    • get hasAttack(): boolean

      Returns true if any of this item's actions have an attack, see Action#hasAttack.

      Returns boolean

    • get hasDamage(): boolean

      Returns true if any of this item's actions have a damage roll, see Action#hasDamage.

      Returns boolean

    • get hasFiniteCharges(): boolean

      Finite charges

      Returns boolean

    • get isCharged(): boolean

      Returns boolean

    • get isPhysical(): boolean

      Whether or not this is a physical item.

      This queries system.isPhysical for actual truth.

      Returns boolean

    • get isSingleUse(): boolean

      Returns boolean

    • get normalMaterial(): string | null

      The item's actual material.

      Returns string | null

    • get subType(): ItemSubtypes | null

      The item's subtype, or null if the item has no subtype

      Returns ItemSubtypes | null

    • get system(): void

      Returns void

    • Protected

      Finalize data after actor and items are guaranteed to be ready.

      Other items may not have yet run _finalizeData() however.

      Returns void

    • Internal

      Prepare data dependent on other items

      This should be run in Item.prepareDerivedData() if no actor is present, or in actor's prepareDerivedData after document preparation is done.

      Returns void

    • Internal

      Update max uses

      Returns void

    • Protected Internal

      Updates protections and weaknesses with processed formulas.

      Called in ()

      Returns void

    • Generates lists of change targets this item can have.

      Parameters

      • target: string

        The target key, as defined in PF1.buffTargets.

      Returns Record<string, string>

      A list of changes

    • Finds, filters and alters changes relevant to a context, and returns the result (as an array)

      Parameters

      • context:
            | "mattack"
            | "nattack"
            | "rattack"
            | "tattack"
            | "wdamage"
            | "mwdamage"
            | "rwdamage"
            | "twdamage"
            | "rdamage"
            | "mdamage"
            | "ndamage"
            | "sdamage"
            | "tdamage" = ...

        The given context.

      Returns Change[]

      • The matching changes.
      • Always returns empty array if no actor is present.
    • Determines the starting data for an ActiveEffect based off this item.

      Parameters

      • options: { rollData: object } = {}

        Additional options

        • rollData: object

          Roll data

      Returns Promise<object>

      • Active Effect creation data
    • Returns labels for this item

      Parameters

      • Optionaloptions: { actionId?: string; isolated?: boolean; rollData?: object } = {}

        Additional options

        • OptionalactionId?: string

          ID of one of this item's actions to get labels for; defaults to first action

        • Optionalisolated?: boolean

          Is this isolated use? If true, more data is included.

        • OptionalrollData?: object

          Roll data to use.

      Returns Record<string, string>

      This item's labels

    • Internal

      Determine whether a given change set affects size

      Parameters

      • data: object

        Item data

      Returns boolean

      • Contains size targeting change
    • Internal

      Determine whether a given change set affect senses

      Parameters

      • updateData: object

        An object containing changeFlags and changes to be inspected.

      Returns boolean

      • Vision alteration detected
    • Experimental

      Get Container Tree

      Parameters

      • item: object | ItemPF<BaseItemModel>

        Root item

      • items: ItemPF<BaseItemModel>[] | object[]

        Items to limit searching nested items from

      • collection: DocumentCollection

        Collection the root item is in

      • Optional_ids: Set<string> = ...

        Internal use

      • Optional_depth: number = 0

        Internal use

      Returns object

    Advanced

    • Get full description.

      Parameters

      • options: {
            actionId?: string;
            body?: boolean;
            chatcard?: boolean;
            data?: object;
            header?: boolean;
            identified?: boolean;
            isolated?: boolean;
            rollData?: object;
        } = {}

        Item type dependant options for rendering the description.

        • OptionalactionId?: string

          Action ID

        • Optionalbody?: boolean

          Include main description body if such exists.

        • Optionalchatcard?: boolean

          Instruct template to render chat card in mind.

        • Optionaldata?: object

          Template data for rendering

        • Optionalheader?: boolean

          Include header if such exists.

        • Optionalidentified?: boolean

          Enforce identified description retrieval

        • Optionalisolated?: boolean

          Passed to getDescriptionData

        • OptionalrollData?: object

          Roll data for transforming description

      Returns Promise<string>

      • Full description.
    • Item name

      Parameters

      • OptionalasPlayer: boolean = false

        If true, return value players see.

      Returns string

      • Item name

    Containers

    • get container(): void | object | ItemPF<ContainerModel>

      Container

      Parent item this is stored inside of.

      Returns index entry for items in compendiums if the actual item is not cached.

      Returns void | object | ItemPF<ContainerModel>

    • get inContainer(): boolean

      Is this item inside a container?

      Returns boolean

      • Does not distinguish from the container existing or not, only that the item claims to be so.
    • Experimental

      Get Container for given Entry

      Parameters

      Returns void | object | ItemPF<PhysicalItemModel>

      const container = ItemPF.getContainer(itemlike, game.items);
      
      const container = ItemPF.getContainer(itemlike, actor.items);
      

      Example: Pack entry

      const pack = game.packs.get("pf1.items");
      const soap = pack.index.getName("Soap");
      const container = ItemPF.getContainer(soap, pack);
    • Is this item inside a container?

      Parameters

      • entry: any

      Returns boolean

      • Does not distinguish from the container existing or not, only that the item claims to be so.
      const inContainer = ItemPF.hasContainer(itemlike);
      

    Deprecated

    • get allDamageSources(): Change[] | undefined

      Generic damage source retrieval for default action, includes default conditionals and other item specific modifiers.

      Returns Change[] | undefined

      All relevant changes, or undefined if action was not found.

    • get attackSources(): object[] | undefined

      Return attack sources for default action.

      Returns object[] | undefined

      Array of value and label pairs for attack bonus sources on the main attack.

    • get baseArmorProficiency(): "med" | "lgt" | "hvy" | "shl" | "twr" | null

      Retrieve armor proficiency type required by this item.

      Returns "med" | "lgt" | "hvy" | "shl" | "twr" | null

      • Null if no relevant proficiency found. Possibly an error.
      • If used on item that is not an armor or a shield.

      PF1 v10

    • get canEquip(): boolean

      Can equip currently?

      Returns boolean

    • get fullDescription(): any

      Returns any

    • get hasActions(): any

      Returns any

    • get hasChanges(): boolean

      Returns boolean

    • get hasSlots(): boolean

      Does the equipment subtype use slots.

      Returns boolean

    • get hitDice(): number

      Hit Dice

      Returns number

    • get isBroken(): boolean

      Returns boolean

    • get isDomain(): boolean

      Determine if this spell is domain/school spell.

      Returns boolean

      Use pf1.models.item.SpellModel#domain instead.

    • get isProficient(): boolean

      Is the owning actor proficiency at using this as weapon.

      Returns boolean

      PF1 v10

    • get maxCharges(): number

      Maximum possible charges this item can have.

      Returns number

      • Can return zero. Usually signifying something has reduced the potential uses below usability.
      • Can return infinity, signifying lack of limits.
    • get mythicTier(): number

      Mythic Tier

      Returns number

    • get rootItem(): ItemPF<BaseItemModel>
      Internal

      Root item.

      Specifically the item at bottom of the container tree.

      Returns ItemPF<BaseItemModel>

      • May no longer be needed.
    • get spellbook(): object | undefined

      Linked spellbook

      Returns object | undefined

      Use pf1.models.item.SpellModel#spellbook instead.

    • get hasActions(): any

      Returns any

    • get hasChanges(): boolean

      Returns boolean

    • get isPhysical(): boolean

      Whether the item is tangible physical object in reality.

      Returns boolean

    • Returns any

      Use pf1.models.item.ContainerModel.getCoinWeight() instead.

    • Converts currencies to the given currency type

      Parameters

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

        Converts as much currency as possible to this type.

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

        Additional options

        • Optionalinteractive?: boolean

          Was this from user interaction?

      Returns Promise<ItemPF<Model>>

      The updated item

    • Parameters

      • actionId: any

      Returns any

    • Attack sources for a specific action.

      Parameters

      • actionId: string

        Action ID

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

        Additional options

        • OptionalrollData?: object

          Roll data instance

      Returns object[] | undefined

      Array of value and label pairs for attack bonus sources on the main attack, or undefined if the action is missing.

    • Returns any

    • Get default charge cost for all actions.

      Parameters

      • Optionaloptions: { rollData?: object }

        Additional options

        • OptionalrollData?: object

          Roll data instance

      Returns number

      Number for default cost.

    • Default charge formula.

      Returns string

      Charge formula

    • Internal

      Duration of the buff in seconds.

      Parameters

      • Optionaloptions: { interactive?: boolean; rollData?: object }

        Additional options

        • Optionalinteractive?: boolean

          Directly triggered from user interaction

        • OptionalrollData?: object

          Roll data

      Returns Promise<number | null>

      Duration in seconds or null if if it has no duration.

    • Parameters

      • Optionalweapon: boolean = true

        Get proficiency as a weapon. Armor otherwise.

      Returns boolean

      • Whether or not the owner of the item is proficient.
      • If item type does not support proficiency.

      PF1 v10

    • Determines the starting data for an ActiveEffect based off this item.

      Parameters

      • options: any

      Returns Promise<object>

    • Spell components

      Parameters

      • options: { compact?: boolean }

        Additional options

        • Optionalcompact?: boolean

          Remove redundant components (e.g. M/DF becomes DF for divine caster)

      Returns string[]

      • Component keys

      Example with Discern Lies on Cleric

      spell.getSpellComponents(); // => ["V", "S", "M/DF"]
      

      Same with compacted components

      spell.getSpellComponents({compact:true}); // => ["V","S", "DF"]
      
    • Parameters

      • ...args: any[]

      Returns any

      Use pf1.models.item.SpellModel#getUses instead.

    • Parameters

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

        Additional options affecting how the value is returned

        • OptionalinLowestDenomination?: boolean

          Whether to return the value in copper, or in gold (default)

      Returns number

      The total amount of currency this item contains, in gold pieces

    • Returns the displayed value of an item according to multiple options

      Parameters

      • Optionaloptions: {
            forceUnidentified?: boolean;
            identical?: boolean;
            inLowestDenomination?: boolean;
            maximized?: boolean;
            recursive?: boolean;
            sellValue?: number;
            single?: boolean;
        } = {}

        Various optional parameters affecting value calculations

        • OptionalforceUnidentified?: boolean

          Override whether the value should use the unidentified price

        • Optionalidentical?: boolean

          Treat all items in stack as identical (same number of charges).

        • OptionalinLowestDenomination?: boolean

          Whether the value should be returned in the lowest denomination

        • Optionalmaximized?: boolean

          Pretend as if the items were fresh (full charges)

        • Optionalrecursive?: boolean

          Whether the value of contained items should be included

        • OptionalsellValue?: number

          The sell value multiplier

        • Optionalsingle?: boolean

          Return value of singular item instead of the actual stack. Disables recursive option.

      Returns number

      The item's value

    • Returns any

    • Recharges item's uses, if any.

      Parameters

      • options: {
            commit?: boolean;
            context?: object;
            exact?: boolean;
            maximize?: boolean;
            period?: "round" | "minute" | "hour" | "day" | "week" | "combat" | "any";
            rollData?: object;
            value?: number;
        }

        Options

        • Optionalcommit?: boolean

          Commit update directly. If false, returns the update data instead.

        • Optionalcontext?: object

          Update context

        • Optionalexact?: boolean

          Use exact time period. Otherwise "week" for example will also recharge items with "day" period.

        • Optionalmaximize?: boolean

          Recharge to full regardless of recharge formula.

        • Optionalperiod?: "round" | "minute" | "hour" | "day" | "week" | "combat" | "any"

          Recharge period. Use "any" to ignore item's configuration.

        • OptionalrollData?: object

          Roll data instance to use for formulas.

        • Optionalvalue?: number

          Recharge to specific value, respecting maximum and minimum bounds.

      Returns Promise<object | ItemPF<Model> | undefined>

      • Promise for the update, update data object, or undefined (no update needed).
    • Creates attack from provided item.

      Parameters

      • item: any

        Source item

      Returns AttackData

      • Attack item data
      • Only supports weapon item type.
      • On unsupported type
    • Get the price of a consumable given the spell level and caster level.

      Parameters

      • ...args: any[]

      Returns any

    • Parameters

      • itemData: object

        A spell item's data.

      Returns [number, number]

      • A tuple containing the spell level and caster level in order.
    • Convert spell into a consumable item.

      Parameters

      • ...args: any[]

      Returns Promise<any>

    • Open Consumable conversion dialog.

      Parameters

      • ...args: any[]

      Returns Promise<any>

    Flags

    • Sets a boolean flag on this item.

      Parameters

      • flagName: string

        The name/key of the flag to set.

      • context: object = {}

        Update context

      Returns Promise<boolean>

      Whether something was changed.

    • Get all item boolean flags as array.

      Returns string[]

      • Flag keys
    • Parameters

      • flagName: string

        The name/key of the flag to get.

      Returns string | number | undefined

      The value stored in the flag.

    • Get all item dictionary flags as array of objects.

      Returns Record<string, any>

      • All dictionary flags
    • Parameters

      • flagName: string

        The name/key of the flag on this item.

      Returns boolean

      Whether the flag was found on this item.

    • Removes a boolean flag from this item.

      Parameters

      • flagName: string

        The name/key of the flag to remove.

      • context: object = {}

        Update context

      Returns Promise<boolean>

      Whether something was changed.

    • Removes a dictionary flag from this item.

      Parameters

      • flagName: string

        The name/key of the flag to remove.

      • context: object = {}

        Update context

      Returns Promise<boolean>

      Whether something was changed.

    • Sets a dictionary flag value on this item.

      Parameters

      • flagName: string

        The name/key of the flag to set.

      • value: string | number

        The flag's new value.

      • context: object = {}

        Update context

      Returns Promise<boolean>

      Whether something was changed.

    Internal

    • Internal

      Executes all script calls on this item of a specified category.

      Parameters

      • category: string

        The category of script calls to call.

      • OptionalextraParams: Record<string, any> = {}

        A dictionary of extra parameters to pass as variables for use in the script.

      • Optionalshared: object = {}

        Shared data object

      Returns Promise<object>

      The shared object between calls which may have been given data.

    Links

    • Internal

      Test if specified link can be created.

      Parameters

      • type: string

        The type of link.

      • item: any

        The target item to link to.

      • Optionaloptions: object = {}

        Additional options

      Returns Promise<boolean>

      Whether a link to the item is possible here.

    • Internal

      Parameters

      • type: string

        The type of link.

      • item: object

        The target item to link to.

      • uuid: string

        The link identifier for the item.

      Returns any[]

      An array to insert into this item's link data.

    • Creates a link to another item.

      Parameters

      • type: "children" | "charges" | "supplement" | "classAssociations"

        The type of link.

      • item: any

        The target item to link into this.

      • OptionalextraData: object

        Additional data to store int he link

      • Optionaloptions: object = {}

        Additional options

      Returns Promise<boolean>

      • Whether a link was created.
    • Get all items linked by any means.

      Returns Promise<any[]>

      • Linked items
    • Get item links of type

      Parameters

      • type: string

        Link type

      • includeLinkData: boolean = false

        Include link data, return value changes from item array to object array

      • Optionaloptions: { _results?: Set<any>; recursive?: boolean } = {}

        Additional options

        • Optional_results?: Set<any>

          Internal use only.

        • Optionalrecursive?: boolean

          Retrieved linked items recursively.

      Returns Promise<any[] | object[]>

      • Linked items, or objects with linked items and additional data
    • Retrieve list of linked items for a type, synchronously. Intended mainly for fetching child or charge links quickly.

      Parameters

      • type: string

        Link type, e.g. "children", "charges", or "classAssociations"

      • Optionaloptions: { _results?: Set<string>; recursive?: boolean } = {}

        Additional options

        • Optional_results?: Set<string>

          Internal use only

        • Optionalrecursive?: boolean

          Retrieve links recursively.

      Returns any[] | object[]

      Linked items or their compendium index data

      const childItems = item.getLinkedItemsSync("children");
      
    • Removes all link references to an item.

      Parameters

      • uuid: string

        The UUID of the item to remove links to.

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

        Additional options

        • Optionalcommit?: boolean

          Commit changes to database. If false, resulting update data is returned instead.

      Returns Promise<any>

      • Updated document, update data, or undefined

    User

    • get isActive(): boolean

      Is the item is fully functional.

      This returns composite result of if the item is equipped, has quantity, is not disabled, is not out of charges, etc. and is not representative if the item can be set active or not via setActive.

      Returns boolean

      • This queries this.system.isActive for the actual state.
    • Generic charge addition (or subtraction) function that either adds charges or quantity, based on item data.

      Parameters

      • value: number = 0

        The amount of charges to add.

      Returns Promise<void | ItemPF<Model>>

      • Updated document or undefined if no update is possible.
    • Display the chat card for an Item as a message in chat

      Parameters

      • OptionalmessageData: object = {}

        Optional data that will be merged into the message data.

      • Optionaloptions: { token?: any } = {}

        Additional options.

        • Optionaltoken?: any

          Relevant token if any.

      Returns Promise<any>

      Chat message instance if one was created.

      Move functionality to datamodels

    • Set item's active state.

      Parameters

      • active: boolean

        Active state

      • Optionalcontext: object

        Optional update context

      Returns Promise<ItemPF<Model>>

      • Update promise if item type supports the operation.

      ()

      • If item does not support the operation.
    • Use

      Triggers action use workflow.

      Parameters

      • options: {
            actionId?: string;
            chatMessage?: boolean;
            cost?: number;
            dice?: string;
            ev?: PointerEvent | null;
            options?: UseOptions;
            rollMode?: string;
            skipDialog?: boolean;
            token?: any;
        } = {}

        Options

        • OptionalactionId?: string

          The ID of the action to use, defaults to the first action

        • OptionalchatMessage?: boolean

          Whether to send a chat message for this action

        • Optionalcost?: number

          Cost override. Replaces charge cost or slot cost as appropriate.

        • Optionaldice?: string

          The base dice to roll for this action

        • Optionalev?: PointerEvent | null

          The event that triggered the use, if any

        • Optionaloptions?: UseOptions

          Additional use options.

        • OptionalrollMode?: string

          The roll mode to use for the chat message

        • OptionalskipDialog?: boolean

          Whether to skip the dialog for this action

        • Optionaltoken?: any

          Token this action is for, if any.

      Returns Promise<void | ActionUse | SharedActionData>

      • Action use, shared data, or nothing.
      • On some invalid inputs.