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

    Spell item

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Accessors

    Methods

    _activeStateChange _addTypeRollData _buildEmbedHTML _canCreateItemLink _configure _createInlineEmbed _embedDescription _generateLinkData _onCreate _onDelete _onMemorizedUpdate _onUpdate _preCreate _prepareActions _prepareChanges _prepareDependentData _prepareIdentifier _prepareScriptCalls _prepareTraits _preUpdate _preUpdateNumericValueGuard _rechargeActions _rechargeUses _transformContainerUpdateData _updateInheritedCharges _updateMaxUses _updateProtectionsAndWeaknesses addCharges addItemBooleanFlag adjustContained createItemLink displayCard executeScriptCalls getAllDamageSources getAllLinkedItems getAttackSources getChangeTargets getChatData getConcentrationDC getConditionalSubTargets getConditionalTargets getContextChanges getDefaultChargeCost getDefaultChargeFormula getDescription getDescriptionData getEmbeddedDocument getItemBooleanFlags getItemDictionaryFlag getItemDictionaryFlags getLabels getLinkedItems getLinkedItemsSync getName getProficiency getRawEffectData getRollData getScriptCalls getSpellComponents getSpellUses hasItemBooleanFlag memorizeVariables prepareBaseData prepareDerivedData prepareLinks recharge removeItemBooleanFlag removeItemDictionaryFlag removeItemLink setActive setItemDictionaryFlag update use useSpellPoints _adjustNewItem _createSupplements _hasSizeUpdate _hasVisionUpdate _onCreateOperation _onDeleteOperation _onUpdateOperation _replaceConsumableConversionString createDialog defaultName getDefaultArtwork getMinimumCasterLevelBySpellData toConsumable toConsumablePrompt

    Constructors

    • Parameters

      • data: CreateData

        Initial data from which to construct the Item

      • Optionalcontext: ConstructionContext

        Construction context options

      Returns ItemSpellPF

    Properties

    _memoryVariables: undefined | null | {}
    actions: undefined | Collection<ItemAction, Methods<ItemAction>>

    A Collection of ItemActions.

    changes: undefined | Collection<any, Methods<any>>
    links: undefined | Record<string, ItemPF>

    An object containing links to other items.

    scriptCalls: undefined | Collection<string, ItemScriptCall>
    system: Readonly<
        {
            hasActions: true;
            hasChanges: false;
            hasIdentifier: false;
            isPhysical: boolean;
            subtypeName: false;
        },
    > = ...

    A static object holding system-specific metadata applicable to all instances of this Document class.

    Accessors

    • get actionTypes(): string[]

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

      Returns string[]

      config.itemActionTypes

    • get alignments(): null | string

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

      Returns null | string

    • get allDamageSources(): undefined | ItemChange[]

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

      Returns undefined | ItemChange[]

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

    • get attackSources(): undefined | object[]

      Return attack sources for default action.

      Returns undefined | object[]

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

    • get casterLevel(): null | number

      Effective caster level

      Returns null | number

      • Accounts for offset
      • Returns null if not linked to a valid spellbook.
    • get defaultAmmo(): undefined | Item<"base" | ModuleSubType>

      Linked ammunition item if any.

      Returns undefined | Item<"base" | ModuleSubType>

    • get effect(): null | ActiveEffect<"base" | ModuleSubType>

      An active effect associated with this item.

      Returns null | ActiveEffect<"base" | ModuleSubType>

      • Most item types don't have associated effect.
    • get hasChanges(): any

      Whether the item is tangible physical object in reality.

      Returns any

      • You can utilize this with raw data via CONFIG.Item.documentClasses[type]?.isPhysical
    • 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

    • get isPhysical(): any

      Whether the item is tangible physical object in reality.

      Returns any

      • You can utilize this with raw data via CONFIG.Item.documentClasses[type]?.isPhysical
    • 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 memoryVariables(): string[]

      Returns string[]

      The keys of data variables to memorize between updates, for e.g. determining the difference in update.

    • get rootItem(): Item<"base" | ModuleSubType>
      Internal

      Root item.

      Specifically the item at bottom of the container tree.

      Returns Item<"base" | ModuleSubType>

    • get slotCost(): number

      Number of slots the spell takes to prepare.

      Quick access to .system.slotCost with additional considerations such as at-will toggle.

      Defaults to 1 if the data is not present, 0 if the spell is at-will.

      Returns number

    • get isPhysical(): boolean

      Whether the item is tangible physical object in reality.

      Returns boolean

      • You can utilize this with raw data via CONFIG.Item.documentClasses[type]?.isPhysical

    Methods

    • Parameters

      • config: any
      • options: {} = {}

      Returns Promise<HTMLElement | HTMLCollection | DocumentFragment>

    • Internal

      Test if specified link can be created.

      Parameters

      • type: string

        The type of link.

      • item: Item<"base" | ModuleSubType>

        The target item to link to.

      • Optionaloptions: object = {}

        Additional options

      Returns Promise<boolean>

      Whether a link to the item is possible here.

    • Copy from foundry.documents.JournalEntryPage#_embedTextPage

      Parameters

      • config: any
      • options: {} = {}

      Returns Promise<DocumentFragment>

      foundry.documents.JournalEntryPage#_embedTextPage

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

    • Parameters

      • data: object

        Creation data

      • context: object

        Creation context options

      • userId: string

        Triggering user ID

      Returns void

    • Prepare data potentially dependent on other items.

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

      Parameters

      • final: boolean = false

        Is this final call to this?

      Returns void

    • Internal

      Recharges item's uses, if any.

      Parameters

      • options: { exact: boolean; period?: string; rollData?: object } = {}

        Options

        • exact: boolean

          Exact time period only

        • Optionalperiod?: string

          Recharge only if matching this time period

        • OptionalrollData?: object

          Roll data

      Returns undefined | object

      • Update data or undefined if no update is needed.
    • Internal

      Recharges item's uses, if any.

      Parameters

      • options: {
            exact?: boolean;
            maximize?: boolean;
            period?: string;
            rollData?: object;
            value?: number;
        } = {}

        Options

        • Optionalexact?: boolean

          Match only exact time period

        • Optionalmaximize?: boolean

          Maximize instead of using recharge formula

        • Optionalperiod?: string

          Recharge only if it matches this time period

        • OptionalrollData?: object

          Roll data instance

        • Optionalvalue?: number

          Set charges to specific value

      Returns Promise<undefined | object>

      • Update data or undefined if no update is necessary.
    • Internal

      Transform given data so it becomes valid update data within parent item.

      This can, for example, be used to generate batched update to the real item.

      Parameters

      • data: object

        Update data

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

        Additional options

        • Optionalrecursive?: boolean

          Create data recursively, meant for the real item document.

      Returns object

      • Transformed update data
      _transformContainerUpdateData({ name: "new name" })
      // => { system: { items: { [itemID]: { name: "new name" } } } }
    • Add charges to the spell or its relevant resource pool (spell points or spontaneous spells).

      Parameters

      • value: number

        Number of charges to add

      • Optionaldata: object = null

        Additional data to pass to the update

      Returns Promise<void | ItemSpellPF>

      Updated document or undefined if no update is possible or required.

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

    • Creates a link to another item.

      Parameters

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

        The type of link.

      • item: Item<"base" | ModuleSubType>

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

        Additional options.

        • Optionaltoken?: TokenDocument

          Relevant token if any.

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

      Chat message instance if one was created.

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

    • Attack sources for a specific action.

      Parameters

      • actionId: string

        Action ID

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

        Additional options

        • OptionalrollData?: object

          Roll data instance

      Returns undefined | object[]

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

    • 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

    • Concentration DC

      Parameters

      • type: string = "defensive"

        Type of concentration check

      • Optionaloptions: object = {}

        Additional options

      Returns number

      • DC
      • If type is invalid
    • Finds, filters and alters changes relevant to a context, and returns the result (as an array)

      Parameters

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

        The given context.

      Returns ItemChange[]

      • The matching changes.
      • Always returns empty array if no actor is present.
    • Get default charge cost for spell actions.

      Parameters

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

        Additional options

        • OptionalrollData?: object

          Roll data instance

      Returns number

      • Default cost.
    • Get full description.

      Parameters

      • __namedParameters: {
            body?: boolean;
            chatcard?: boolean;
            data?: {};
            header?: boolean;
            isolated?: boolean;
        } = {}

        Item type dependant options for rendering the description.

      Returns Promise<string>

      • Full description.
    • 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<object[] | Item<"base" | ModuleSubType>[]>

      • 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 object[] | Item<"base" | ModuleSubType>[]

      Linked items or their compendium index data

      const childItems = item.getLinkedItemsSync("children");
      
    • 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: { rollData: object } = {}

        Additional options

        • rollData: object

          Roll data

      Returns Promise<object>

      • Active Effect creation data
    • 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"]
      
    • Recharges item's uses, if any.

      Parameters

      • __namedParameters: { commit?: boolean; exact?: boolean; maximize?: boolean; period?: string } = {}

        Options

      Returns Promise<
          | undefined
          | Item<"base" | ModuleSubType>
          | { system: { preparation: { value: any } } },
      >

      • Promise for the update, update data object, or undefined (no update needed).
    • 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.

    • 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<undefined | object | Item<"base" | ModuleSubType>>

      • Updated document, update data, or undefined
    • Set item's active state.

      Parameters

      • active: boolean

        Active state

      • Optionalcontext: object

        Optional update context

      Returns Promise<ItemSpellPF>

      • Update promise if item type supports the operation.
      • If item does not support the operation.
    • 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.

    • Parameters

      • data: object

        Update data

      • context: object = {}

        Context

      Returns Promise<Item<"base" | ModuleSubType>>

      • Updated item
    • Use an attack, using SharedActionData

      Parameters

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

        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?: null | Event

          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?: TokenDocument

          Token this action is for, if any.

      Returns Promise<void | ActionUse | SharedActionData>

      • Action use, shared data, or nothing.
      • On some invalid inputs.
    • Adjust temporary item before creation

      Parameters

      • item: any

        Temporary document

      • data: any

        Creation data

      • override: boolean = false

        Override values even if defined

      Returns void

    • Internal

      Collect information on supplemental items and create them

      Parameters

      • items: Item<"base" | ModuleSubType>[]

        Array of items to draw supplemental data from

      • actor: Actor<"base" | ModuleSubType>

        Owner

      Returns Promise<void>

    • Internal

      Determine whether a given change set affect senses

      Parameters

      • changes: object

        An object containing changeFlags and changes to be inspected.

      Returns boolean

      • Vision alteration detected
    • On-Create Operation

      Post-create processing so awaiting the original operation has all secondary updates completed when it returns.

      Parameters

      • documents: Document[]

        Documents

      • operation: any

        Operations and context data

      • user: User

        Triggering user

      Returns Promise<void>

    • On-Delete Operation

      Post-delete processing so awaiting the original operation has all secondary updates completed when it returns.

      Parameters

      • documents: Document[]

        Documents

      • operation: any

        Operations and context data

      • user: User

        Triggering user

      Returns Promise<void>

    • On-Update Operation

      Post-update processing so awaiting the original operation has all secondary updates completed when it returns.

      Parameters

      • documents: Document[]

        Documents

      • operation: any

        Operations and context data

      • user: User

        Triggering user

      Returns Promise<void>

    • Internal

      Used in consumable creation

      Parameters

      • string: string

        String to convert

      • rollData: object

        Roll data instance

      Returns string

      • Converted string
    • Item create dialog.

      Parameters

      • data: object = {}

        Initial item data

      • createOptions: {} = {}
      • __namedParameters: {} = {}

      Returns Promise<null | Item<"base" | ModuleSubType>>

      Synchronized with Foundry VTT v13.347

    • Override to provide naming by subType potential.

      Parameters

      • context: {
            pack?: null | string;
            parent?: null | Document;
            subType?: string;
            type?: string;
        } = {}

        Context where the name would be used

        • Optionalpack?: null | string

          Pack this would be within

        • Optionalparent?: null | Document

          Parent document

        • OptionalsubType?: string

          Document subtype. Nonstandard option.

        • Optionaltype?: string

          Type

      Returns string

      Synced with Foundry v12.331

    • 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

      • origData: object

        Spell item data

      • type: "potion" | "scroll" | "wand"

        Consumable type

      • Optionaloptions: { spellType?: string } = {}

        Additional options

        • OptionalspellType?: string

          Spell type

      Returns Promise<null | object>

      • Item data for appropriate consumable, or null if dialog option was used and it was cancelled.
    • Open Consumable conversion dialog.

      Automatically calls this.toConsumable as appropriate.

      Parameters

      • itemData: object

        Spell item data

      • Optionaloptions: { actor?: object; allowSpell?: boolean; spellType?: string } = {}

        Additional options

        • Optionalactor?: object

          The actor the consumable is being created on.

        • OptionalallowSpell?: boolean

          Allow spell creation

        • OptionalspellType?: string

          Spell type

      Returns Promise<null | false | object>

      • Returns null if cancelled, false if no conversion is to take place, or converted data.