Actionable - reonZ/pf2e-toolbelt GitHub Wiki

Action Macro

When adding a macro to an action, a use button is added to the action in the actor sheet if one wasn't already added by the system, otherwise it will repurpose the existing one.

The action will not automatically be sent to chat (nor does its uses be updated), this gives you all the freedom needed to customize the behavior of your macro.

The following are forwarded to the macro for you to use:

  • actor: the owner of the action
  • item: the action item
  • use: function to send the action to chat (and consume 1 use if needed)
  • cancel: function to send a notification back to the user warning them that the action was canceled

Note

You cannot add a macro to a Passive action

Note

You cannot add a macro to an crafting action (i.e. Quick Alchemy)

Spell Macro

When adding a macro to a spell, the module intercept spell casting from any source and instead will execute the macro, holding on everything else that would normally happen.

The following are forwarded to the macro for you to use:

  • actor: the owner of the spell
  • spell: the spell item
  • options: the original CastOptions data
  • cast: function to actually cast the spell, it accepts an option argument of type CastOptions to customize the cast
  • cancel: function to send a notification back to the user warning them that the spell cast was canceled
interface CastOptions {
    slotId?: number;
    /** The rank at which to cast the spell */
    rank?: OneToTen;
    consume?: boolean;
    message?: boolean;
    rollMode?: RollMode;
}

Equipment & Consumable Macro

When adding a macro to an inventory item, a use button icon is added to the item in the actor sheet (compatible with the Use Consumable setting) to execute the macro.

The following are forwarded to the macro for you to use:

  • actor: the owner of the item
  • item: the inventory item
  • use: function to use/consume the item (compatible with the Use Consumable setting)
  • cancel: function to send a notification back to the user warning them that the item use was canceled

Note

You cannot add a macro to a Wand or Scroll consumable

Use Consumable

This feature adds a use button icon in the actor sheet, clicking on it will generate a custom and improved version of what the system normally generates when clicking on the Use button in the item description.

Virtual Actions

The module adds a custom rule element that can be added to physical items and will act like the system's GrantItem but instead of physically adding the item in your actor's data, the actions will be generated on the fly during data preparation.

This come with the adventage of circumventing the limitation of the system but comes with its own, mainlythe fact that virtual actions cannot themselves have rule elements (they can but they won't work).

Other than that, phe module reproduces pretty much every aspect of a regular action, from the Send to Chat feature to the frequency updating on turn change/rest.

The rule element format is as follow:

{
  "key": "Actionable",
  "uuid": "<source-uuid-of-the-action>"
}

Note

Virtual actions can be affected by some rule elements (e.g. AdjustModifier, ItemAlteration)

Note

The virtual data is kept inside the Actionable RE itself, it is auto generated once the item is saved, you should not touch the data property inside the RE. This also means that literally no data will linger in the actor or the item if you decide to remove the RE.

Virtual Spells

The module adds a custom rule element that can be added to physical items and will generate virtual spellcasting entry and spells in the Activations tab where you can normally find scrolls and spells.

The module reproduce everything you would expect from a regular spellcasting entry and spells. Uses will be reset during long rest.

The rule element format is as follow with only the key and uuid required:

{
  "key": "ItemCast",
  "uuid": "<source-uuid-of-the-spell>",
  "attribute": "cha",
  "dc": 15,
  "max": 1,
  "rank": 1,
  "statistic": "kineticist",
  "tradition": "arcane"
}
  • If you provide a statistic slug, the module will look for it on the character and if found used for the entry.

  • If no statistic was provided/found and a dc is provided, the module will create a custom statistic for it.

  • If no statistic nor dc are provided, the module will look for a valid spellcasting entry already existing on the character and use its statistic. It will give priority to one that could normally cast the spell if any.

  • if you provide a max value greater than 0, it will be used to limit the amount of times the spell can be cast per day (it will recharge during long rest).

  • if you provide a rank value greater than 0, it will be used to heightened the spell.

Important

The module has to go beyond what the system normally do, it creates a virtual consumable to host the spell. Because it is virtual, it cannot be accessed using actor.items or actor.itemTypes.consumable.

Note

While it can be added to any item in your world/compendiums, the RE will only be active if the item is in a Character inventory.

Note

The module prevents the user from casting any virtual spell if the parent item isn't equipped/invested.

Tip

If you provide a rank value to a cantrip, the module will override the default autoscaling behavior.

Tip

You can override the generated spellcasting entry attribute and tradition by providing them in the RE.

The module adds a convenient button to automatically parse the item's description and find any spell in it. It will try to infer a few of the properties that should be added to the rule element (as shown in the screenshot above) but this is limited. You can fill the missing data in the popup window (here, it would require you to set the max to 1).

Settings

Action Macro 🌎

Adds a way to link a macro to actions/feats.

Item Macro 🌎

Adds a way to link a macro to equipment & consumable items.

Spell Macro 🌎

Adds a way to link a macro to spells.

Physical Actions 🔃

Adds a new RuleElement that generates virtual actions whenever a physical item is equipped/invested.

Item Spell Casting 🔃

Adds a new RuleElement that generates virtual spellcasting entries whenever a physical item is equipped/invested.

Use Consumable 👤

Will add an extra use button for consumables and generate a custom message when used

Auto Self-Applied 👤

The use button for self-applied effect will automatically apply the effect.

API

game.toolbelt?.api.actionable = {
    /**
     * This is useful if you need to add multiple ItemCast rule elements to an item at the same time
     * to avoid some very annoying loop of updates.
     */
    generateItemCastRuleSource(spell: SpellPF2e, data: ItemCastRuleSourceData): RuleElementSource,
    /** Return null if the action has a self-applied effect or is a crafting action */
    getActionMacro(action: AbilityItemPF2e | FeatPF2e): Promise<Maybe<MacroPF2e>>,
    getItemMacro(item: ItemPF2e): Promise<MacroPF2e | undefined>,
    getVirtualAction(data: ActionableData): Promise<AbilityItemPF2e | null>,
    getVirtualActionsData(actor: ActorPF2e): Record<string, VirtualActionData>,
    getVirtualSpellData(actor: ActorPF2e, id: string): VirtualSpellData | undefined,
    getVirtualSpellcastingData(actor: ActorPF2e, id: string): VirtualSpellData | undefined,
    rechargeVirtualSpell: (
        parent: PhysicalItemPF2e<CharacterPF2e>,
        ruleIndex: number,
    ) => Promise<ItemPF2e<CharacterPF2e>[]> | undefined,
    updateVirtualSpellValue: (
        parent: PhysicalItemPF2e<CharacterPF2e>,
        ruleIndex: number,
        value: number,
    ) => Promise<ItemPF2e<CharacterPF2e>[]> | undefined,
    updateActionFrequency(
        event: Event,
        item: AbilityItemPF2e<ActorPF2e> | FeatPF2e<ActorPF2e>,
        virtualData?: VirtualActionData,
    ): Promise<unknown> | undefined,
    useAction(
        event: Event,
        item: AbilityItemPF2e<ActorPF2e> | FeatPF2e<ActorPF2e>,
        virtualData?: VirtualActionData,
    ): Promise<unknown>,
}
type VirtualActionData = {
    data: ActionableData;
    parent: PhysicalItemPF2e<CharacterPF2e>;
    ruleIndex: number;
};

type VirtualSpellData = {
    attribute: "str" | "dex" | "con" | "int" | "wis" | "cha" | null | undefined;
    dc: number | null | undefined;
    max: number | null | undefined;
    statistic: string | null | undefined;
    tradition: "arcane" | "divine" | "occult" | "primal" | null | undefined;
    entryId: string;
    item: ConsumablePF2e<CharacterPF2e>;
    parent: PhysicalItemPF2e<CharacterPF2e>;
    ruleIndex: number;
    spellId: string;
    value: number | undefined;
};

type ItemCastRuleSourceData = {
    attribute?: "str" | "dex" | "con" | "int" | "wis" | "cha" | null;
    dc?: number | null;
    max?: number | null;
    rank?: OneToTen | null;
    statistic?: string | null;
    tradition?: "arcane" | "divine" | "occult" | "primal" | null;
};

type ActionableData = {
    frequency?: number;
    id: string;
    sourceId: ItemUUID;
};
⚠️ **GitHub.com Fallback** ⚠️