Spell item

Hierarchy (view full)

Constructors

Properties

Accessors

Methods

Constructors

  • Parameters

    • Rest...args: [data?: ItemDataConstructorData, context?: Context<ActorPF>]

    Returns ItemSpellPF

Properties

_memoryVariables: undefined | null | {}
actions: any

A Collection of ItemActions.

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

An object containing links to other items.

scriptCalls: any
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.

Type declaration

  • hasActions: true

    Whether this item has actions.

  • hasChanges: false
  • hasIdentifier: false
  • isPhysical: boolean

    Whether this item is a physical one, possessing properties like quantity or weight.

  • subtypeName: false

    Subtype name should be used as default name.

Accessors

  • 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 effect(): null | ActiveEffect
  • An active effect associated with this item.

    Returns null | ActiveEffect

    • 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 memoryVariables(): string[]
  • Returns string[]

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

  • 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

  • Internal

    Test if specified link can be created.

    Parameters

    • type: string

      The type of link.

    • item: Item

      The target item to link to.

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

  • 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: undefined | string;
          rollData: undefined | object;
      } = {}

      Options

      • exact: boolean

        Exact time period only

      • period: undefined | string

        Recharge only if matching this time period

      • rollData: undefined | 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: undefined | boolean;
          maximize: undefined | boolean;
          period: undefined | string;
          rollData: undefined | object;
          value: undefined | number;
      } = {}

      Options

      • exact: undefined | boolean

        Match only exact time period

      • maximize: undefined | boolean

        Maximize instead of using recharge formula

      • period: undefined | string

        Recharge only if it matches this time period

      • rollData: undefined | object

        Roll data instance

      • value: undefined | 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: undefined | boolean;
      } = {}

      Additional options

      • recursive: undefined | 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"
          | "classAssociatons"

      The type of link.

    • item: Item

      The target item to link into this.

    • OptionalextraData: object

      Additional data to store int he link

    Returns boolean

    • Whether a link was created.
  • Display the chat card for an Item as a message in chat

    Parameters

    • OptionalaltChatData: object = {}

      Optional data that will be merged into the chat data object.

    • Optionaloptions: {
          token: undefined | TokenDocument;
      } = {}

      Additional options.

      • token: undefined | TokenDocument

        Relevant token if any.

    Returns Promise<void | ChatMessage>

    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: undefined | object;
      } = {}

      Additional options

      • rollData: undefined | 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

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

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

    Parameters

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

      Additional options

      • rollData: undefined | object

        Roll data instance

    Returns number

    • Default cost.
  • Get full description.

    Parameters

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

      Item type dependant options for rendering the description.

      • body: undefined | boolean
      • chatcard: undefined | boolean
      • data: undefined | {}
      • header: undefined | boolean
      • isolated: undefined | boolean

    Returns Promise<string>

    • Full description.
  • Description Data

    Parameters

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

      Additional options

      • isolated: undefined | boolean

    Returns Promise<object>

    • Description context data
  • 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: undefined | Set<any>;
          recursive: undefined | boolean;
      } = {}

      Additional options

      • _results: undefined | Set<any>

        Internal use only.

      • recursive: undefined | boolean

        Retrieved linked items recursively.

    Returns object[] | Item[]

    • 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: undefined | Set<string>;
          recursive: undefined | boolean;
      } = {}

      Additional options

      • _results: undefined | Set<string>

        Internal use only

      • recursive: undefined | boolean

        Retrieve links recursively.

    Returns object[] | Item[]

    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 object

    • Active Effect creation data
  • Spell components

    Parameters

    • options: {
          compact: undefined | boolean;
      } = {}

      Additional options

      • compact: undefined | boolean

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

    Returns string[]

    • Component keys
    // Discern Lies on Cleric
    spell.getSpellComponents(); // V S M/DF
    spell.getSpellComponents({compact:true}); // V S DF
  • Per item type chat data.

    Parameters

    • data: any

      A partial of a chat data object that can be modified to add per item type data.

    • labels: any

      The labels for this item.

    • props: any

      Additional property strings

    • rollData: any

      A rollData object to be used for checks

    Returns void

  • Recharges item's uses, if any.

    Parameters

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

      Options

      • commit: undefined | boolean
      • exact: undefined | boolean
      • maximize: undefined | boolean
      • period: undefined | string

    Returns Promise<undefined | Item | {
        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: undefined | boolean;
      } = {}

      Additional options

      • commit: undefined | boolean

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

    Returns Promise<undefined | object | Item>

    • Updated document, update data, or undefined
  • 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.

  • Use an attack, using SharedActionData

    Parameters

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

      Options

      • actionId: undefined | string

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

      • chatMessage: undefined | boolean

        Whether to send a chat message for this action

      • cost: undefined | number

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

      • dice: undefined | string

        The base dice to roll for this action

      • ev: undefined | null | Event

        The event that triggered the use, if any

      • options: undefined | UseOptions

        Additional use options.

      • rollMode: undefined | string

        The roll mode to use for the chat message

      • skipDialog: undefined | boolean

        Whether to skip the dialog for this action

      • token: undefined | TokenDocument

        Token this action is for, if any.

    Returns Promise<void | ActionUse | SharedActionData>

    • Action use, shared data, or nothing.
    • On some invalid inputs.
  • 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
  • Internal

    Chat card actions

    Parameters

    • action: string

      Button action ID

    • options: {
          button: undefined | Element;
          event: undefined | Event;
          item: undefined | ItemPF;
      } = {}

      Additional options

      • button: undefined | Element

        Button element

      • event: undefined | Event

        Triggering event

      • item: undefined | ItemPF

        Item associated with card

    Returns any

    • ???
  • 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 form data

    • Optionalcontext: {
          options: undefined | object;
          pack: undefined | null | string;
          parent: undefined | null | Actor;
          types: undefined | string[];
      } = {}

      Additional options.

      • options: undefined | object

        Dialog context options.

      • pack: undefined | null | string

        Pack ID parameter passed to Item.create() options

      • parent: undefined | null | Actor

        Parent parameter passed to Item.create() options

      • types: undefined | string[]

        Item types to limit creation choices to.

    Returns Promise<null | Item>

    Synchronized with Foundry VTT v12.331

  • Override to provide naming by subType potential.

    Parameters

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

      Context where the name would be used

      • pack: undefined | null | string

        Pack this would be within

      • parent: undefined | null | Document

        Parent document

      • type: undefined | 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: "wand" | "scroll" | "potion"

      Consumable type

    • Optionaloptions: {
          spellType: undefined | string;
      } = {}

      Additional options

      • spellType: undefined | string

        Spell type

    Returns 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: undefined | object;
          allowSpell: undefined | boolean;
          spellType: undefined | string;
      } = {}

      Additional options

      • actor: undefined | object

        The actor the consumable is being created on.

      • allowSpell: undefined | boolean

        Allow spell creation

      • spellType: undefined | string

        Spell type

    Returns Promise<null | false | object>

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