Skip to content

Quickstart guide for rule elements

Shark that walks like a man edited this page Nov 21, 2021 · 86 revisions

[[TOC]]

Introduction

A short guide to using rule elements:

Note: This document refers to items, items are feats/ class features, spell effects, weapons basically anything that can be added to a character Note: This interface is currently being developed and subject to change Note: Take care when adding rule elements, make sure to do any troubleshooting/experimenting on a spare/blank token/actor Note: People love to talk rule elements on the discord! Ask for help or questions Note: This is document is not exhaustive

What are they?

A series of instructions applied to an item that modifies the character sheet in some way. It another way to create change without coding!

When would I use them?

For setting up modifiers, conditions that apply to a character for example a barbarians Rage, bless/ inspire courage, etc.

How do they work

  1. Enable the rules elements in-game settings -> configure settings -> system settings -> Advanced Rule Element using
  2. Check that they have been activated:
    • Open any item and check that the "rules" tab is revealed
  3. Try some out, head to the compendia, and find spell effects, pick one and drag it to your character.
    • inspire courage is a good place to start.
  4. Open up the spell effect you chose and look at Rules Tab notice text in the boxes, that is a rule element

A correctly created rule element will do the work of several lines of macro. Once you get the hang of them it allows for easy automation.

My First Rule Element

The first Rule Element for this guide is the Item Bonus of the Armbands of Athleticism

{
    "key": "FlatModifier",
    "label": "Armbands of Athleticism",
    "selector": "athletics",
    "type": "item",
    "value": 2
}

They might be tricky to get the hang of. These once set up, will save you lines and lines of code.

Let's break these down:

  1. Key: This is the name given to the rule element within the code.
    • If this is not correct your rule with do nothing!
  2. Label: Name your rule. Some rule elements will use this for displaying in the UI: e.g., FlatModifier, which will use the label for the modifier appearing in roll cards. If a label is omitted, the name of the rule element's parent item is used instead.
  3. Selector: Specifies, or selects, what to apply your modifier to.
    • There is a list at the bottom of the document.
    • An incorrect selector will make your rule do nothing
    • Add the _id/ of an item to the selector to target a specific item or item type
  4. Type: This is the modifier type,
    • With this set appropriately the modifier will be taken into account for bonus stacking rules
  5. Value: the value can be minus if you are applying a penalty

A slightly more advanced case appears in inspire courage, only one of these contains the new element, so this guide will keep the other two "minified"

{"key":"FlatModifier","label":"Inspire Courage","selector":"attack","type":"status","value":1}

{"key":"FlatModifier","label":"Inspire Courage","selector":"damage","type":"status","value":1}

{
    "key":"FlatModifier",
    "label":"Inspire Courage (vs fear)",
    "predicate":{
        "all":[
            "fear"
        ]
    },
    "selector":"will",
    "type":"status",
    "value":1
}
  1. Predicate: If you want your bonus to apply only at certain times, like only vs. fear, you can use a predicate, which comes in three modes:
    • "all": if everything in the list is present for a roll the modifier is applied
    • "any": if at least one in the list is present the modifier is applied
    • "not": if at least one item in the list is present the modifier is not applied
    • an incorrect predicate will make your rule act unexpectedly, these are case sensitive.
    • predicates currently enjoy automation from the spell save button and weapon attacks/damage by querying all their traits. They can also be set in Macros.

Basic Rule Elements

This and the following section will present basic variations of all Rule Elements, most of these can be enhanced with the advanced Rule Element controls later in this guide.

Flat Modifier

In the introduction Flat Modifiers got a lot of spotlights already, but they are good to introduce one more of the major automation features, brackets:

FlatModifier

{
    "key": "FlatModifier",
    "selector": "damage",
    "label": "Rage",
    "predicate": {
        "not": [
            "agile", 
            "rage"
        ]
    },
    "value": {
        "brackets": [
            { 
                "end": 6, 
                "value": 2 
            },
            { 
                "start": 7,
                "end": 14,
                "value": 6
            },
            { 
                "start": 15, 
                "value": 12 
            }
        ]
    }
}

Brackets, by default, use the Level of the player or monster the Rule is attached to. This Modifier adds the Barbarian Rage Damage the way a Fury Instinct Barbarian does.

For some cases, like a swashbuckler's precise strikes, "damageCategory" can be used to change the damage to precision damage, "damageType" can be used to change the damage to "fire" for certain barbarians.

It is possible to query different values, as is explained in the advanced controls sections.

Immunity, Weakness, Resistance

You can add immunity, weakness, resistance (IWR) to a creature with rule elements. The automation for application of damage is not complete yet but this rule element lets you easily track your IWR. Using any of them is quite straightforward.

example (fire weakness)

{
    "key": "Weakness",
    "type": "fire",
    "value": 5
}

But they can also be handed roll syntax to evaluate the value.

example (negative resist equal to half level minimum 1)

{
    "key": "Resistance",
    "type": "negative",
    "value": "max(1,floor(@details.level.value/2))"
}

Immunity can be to a damage type or a condition.

example (bleed immunity)

{
    "key": "Immunity",
    "type": "bleed"
}

You can also set exceptions.

example (resist all except force)

{
    "key": "Resistance",
    "type": "all",
    "value": 5,
    "except": "force"
}

You cannot set the type to a damage type or condition that does not exist however, if you added a resistance to "holy" damage the resistance would not appear, but changing the type to "good" would allow it to show up. Unique resistances, such as resistance 10 to ranged weapons, need to be handled as unique abilities instead.

Toggle Property

A Toggle Property adds a checkbox to the Character's action sheet. The path in the property follows the schema "flags.pf2e.rollOptions.." where corresponds to the selector of another Rule Element that gets activated or deactivated with the toggle and is a unique name for the toggle that is used in the predicate of the other Rule Element.

ToggleProperty

{
    "key": "ToggleProperty",
    "property": "flags.pf2e.rollOptions.damage-roll.power-attack"
}

A toggle Property may also have a label to change the text beside the checkbox from the item's name to a more fitting one. For Power Attack, the label is the name of the feat and doesn't need to be changed.

Damage Dice

A Damage Dice Rule element adds additional Dice to damage or critical damage rolls. The example adds 3d6 piercing damage to a critical strike with an improvised weapon.

DamageDice

{
    "critical": true,
    "key": "DamageDice",
    "selector": "damage",
    "diceNumber": 3,
    "dieSize": "d6",
    "damageType": "piercing",
    "predicate": {
        "all": [
            "improvised"
        ]
    },
    "label": "Shattering Strike"
}

dieSize and damageType can be omitted to add additional damage dice of the type and size that the weapon already has to the damage.

The diceNumber or dieSize properties can be set in a value brackets object, examples for such use are in the advanced section. Targeting a very specific weapon with this rule is also explained in the advanced section.

The DamageDice rule element can also pass traits to the roll.

{
    "key": "DamageDice",
    "selector": "jaws-damage",
    "traits": ["poison"]
}

These can be used regardless of whether dice are added or not. However, these traits are not "functional" in the way normally added traits are. So adding deadly-d8 would show on the chat card but would not be factored into the damage on a critical. Since they only add on damage they also cannot be used to trigger parts of the attack roll, for example a weapon being given the poison trait vs an NPC with a bonus to AC vs poison would not be automated using this. A more comprehensive and functional trait adding rule element will be added later.

Base Speed

To add a base speed value, maybe with a Fly Spell Effect or with a feat granting a climbing speed a Base Speed Rule can be used.

The speed rule elements were built for the familiars, with the intention of refactoring the PCs to use the same data structure for speed. That refactoring has not (yet?) happened.

BaseSpeed

{
    "key": "BaseSpeed",
    "selector": "fly",
    "value": 30
}

The selector for the Base Speed Element differs from the list of selectors at the end of this file by omitting the "-speed" part.

Fixed Proficiency

This Rule Element can be used well for Animal Form and similar spells, as the name suggests it sets the proficiency to the given value. It appears in the game as a modifier to the skill that makes up for the difference.

FixedProficiency

{
    "key": "FixedProficiency",
    "selector": "athletics",
    "value": 9
}

The Fixed Proficiency Rule supports a label and a name if the label is not unique.

Strike

This rule element is a bit trickier in that there are a lot of necessary fields. The easiest way to create your own custom strike would be to start from a finished strike like the monk's Tiger Claw strike here.

Strike

{
    "key": "Strike",
    "category": "unarmed",
    "damage": {
        "base": {
            "damageType": "slashing",
            "dice": 1,
            "die": "d8"
        }
    },
    "group": "brawling",
    "label": "Tiger Claw",
    "traits": [
        "agile",
        "finesse",
        "unarmed",
        "nonlethal"
    ]
}

If necessary an "ability": "int"-entry could be used for a strike that scales its to-hit with intelligence, as the "Spiritual Weapon" Spell could. This works with the other 3 character ability shorthands too. To add a Flat part to the damage like an ability modifier, add an additional Flat Modifier Element. An optional "range": 30 parameter can be given to denote the range of an attack. This only accepts a number or null. It no longer needs to specify melee.

Note

The Note Rule Element adds additional text to the chat output of a roll. The Example (taken from the Alchemist's Evasion Feat) adds a reminder to all reflex saves about the feat.

Note

{
    "key":"Note",
    "selector":"reflex",
    "text":"<p class='compact-text'><strong>{item|name}</strong> When you roll a success on a Reflex save, you get a critical success instead.</p>"
}

for damage Rolls, it is possible to set a message only on a critical roll or only on a normal hit.

{
  "key": "Note",
  "selector": "damage",
  "text": "<p class='compact-text'><strong>Axiomatic Rune</strong> When you critically succeed at an attack roll with this weapon against a chaotic creature, instead of rolling, count each weapon damage die as average damage rounded up (3 for d4, 4 for d6, 5 for d8, 6 for d10, 7 for d12).</p>",
  "outcome": ["criticalSuccess"]
}

Dexterity Modifier Cap

Some spells and items, while not armor, do impose a cap on the dexterity modifier. For those, a Dexterity Modifier Cap can be set per Rule Element.

DexterityModifierCap

{
    "key": "DexterityModifierCap",
    "value": 5
}

Sense

A Rule Element for Feats, Spells, and Items that grant additional senses or increase the acuity of existing ones. For an unusual sense, a label should be provided.

Sense

{
    "key": "Sense",
    "selector": "darkvision"
}
{
    "acuity":"imprecise",
    "key":"Sense",
    "range":30,
    "selector":"scent"
}

For these Rules, the Label is queried from the language database.

Weapon Potency and Striking

The weapon potency and striking rule elements do basically the same as the flat modifier and damage dice rule elements, but with the additional feature of properly changing the damage rolls for things like backstabber (+2 to damage with a +3 potency rune) and deadly (more dice if striking rune).

WeaponPotency

{
    "key": "WeaponPotency",
    "selector": "{item|_id}-attack",
    "value": 1
}

Striking

{
    "key": "Striking",
    "selector": "{item|_id}-damage",
    "value": 1
}

Another Example would be the Handwraps of mighty blows at +1 striking:

{
    "key": "WeaponPotency",
    "predicate":{
        "all":[
            "unarmed"
        ]
    },
    "selector": "attack",
    "value": 1
}

Striking

{
    "key": "Striking",
    "predicate":{
        "all":[
            "unarmed"
        ]
    },
    "selector": "damage",
    "value": 1
}

Multiple Attack Penalty

The Multiple Attack Penalty rule element can change the MAP Progression of specific strikes, or the character as a whole. The two sample Rule Elements implement a flurry ranger, put them on an Effect item and they'll make you hit very often

MultipleAttackPenalty

{
    "key":"MultipleAttackPenalty",
    "predicate": {
        "all": [
            "agile",
            "hunted-prey"
        ]
    },
    "roll-options": [
        "all"
    ],
    "selector":"attack",
    "value":-2
}
{
    "key":"MultipleAttackPenalty",
    "predicate": {
        "all": [
            "hunted-prey"
        ],
        "not": [
            "agile"
        ]
    },
    "roll-options": [
        "all"
    ],
    "selector":"attack",
    "value":-3
}

ActiveEffect-Like

The ActiveEffect-Like Rule Element is incredibly powerful. It is more performant, flexible, and reliable than core Foundry active effects. The values it writes are done before many of the other steps of data preparation, making it safe to set flags that other rule elements can read from. This rule element from the barbarian dedication feat sets a flag that the barbarian instincts can pick up in their predicates to change the damage dealt to be correct for the dedication. By setting the flag under flags.pf2e.rollOptions... it can be read by predicates like those set by ToggleProperty or FlatModifier. Setting flags with this should be considered more reliable than the other rule elements since we know it comes before all other rule elements in data preparation. Best practice is also camelCaseForPropertyNames.

Example (Barbarian Dedication flag) (See RollOption below for an easier implementation of some types of flags)

{
	"key": "ActiveEffectLike",
	"mode": "upgrade",
	"path": "flags.pf2e.rollOptions.all.barbarianDedication",
	"value": 1
}

These flags can be stored as boolean, but JavaScript interprets non-zero numbers as true, and 0 as false. So a value of "@data.details.level.value - 15" would be read as true until the actor reached level 15, then turn false. At level 16 the flag would again be read as true.

We can also store custom modifiers. Each feat in the barbarian dedication has this rule element on it using the add mode to count the number of feats taken from the dedication.

{
	"key": "ActiveEffectLike",
	"mode": "add",
	"path": "data.custom.modifiers.barbarianDedicationCount",
	"value": 1
}

This is paired with a flat modifier rule element on the Barbarian Resiliency feat to add 3 HP for every taken feat.

{
	"key": "FlatModifier",
	"selector": "hp",
	"value": "3*@custom.modifiers.barbarianDedicationCount"
}

The upgrade mode can also be used to increase ranks like so

{
	"key": "ActiveEffectLike",
	"mode": "upgrade",
	"path": "data.skills.rel.rank",
	"value": 1
}

Lastly this rule element is able to use brackets, like this rule element from Acrobat Dedication

{
	"key": "ActiveEffectLike",
	"mode": "upgrade",
	"path": "data.skills.acr.rank",
	"value": {
		"brackets": [{
			"end": 6,
			"start": 1,
			"value": 2
		}, {
			"end": 14,
			"start": 7,
			"value": 3
		}, {
			"start": 15,
			"value": 4
		}]
	}
}

The brackets used in this are the same as any other rule element, however care should be taken to not rely on other rule elements or active effects to modify the bracketed value. Character level, item level, ability scores, and other values not modified by rule elements should be safe to bracket on. Bracketing on the rank of a skill or weapon proficiency will not be safe since these are modified by other rule elements and the order of data preparation may yield unreliable results.

The modes available for use are 'multiply', 'add', 'downgrade', 'upgrade', and 'override'. It can write numbers, strings, and booleans and the value field accepts roll syntax similar to other rule elements.

you can add a field "priority" to control the order of application of the AE-likes. The lower the value the earlier the AE like gets applied during data preparation. without specifying they will default to 10 for multiply, 20 for add, 30 for downgrade, 40 for upgrade and 50 for override, making override usually effectively ignore all other AElikes.

RollOption

RollOption is an new extension of the AE-like rule element, but made to be easier to use for setting roll options. It should be seen as the successor to the now depreciated SetProperty RE. A RollOption RE has two mandatory fields: domain and option. These correspond to the place under pf2e.flags.roll-options that the property is set. The option is the thing that gets predicated on in other rule elements. So unlike ToggleProperty or the AE like example barbarian flag above you don't need to type out the entire path, or even set mod, value, etc. Only the domain and the name of the option have to be set up. Below is an alternative to the system's current rage effect RE.

Example RollOption (rage effect)

{
    "key": "RollOption",
    "domain": "all",
    "option": "rage"
}

You can use any domain or option, but not all types of rolls check all domains for options. For example an Athletics roll does not check the damage-roll or ac domains. All rolls check the all domain, however we want to avoid overstuffing one domain. As a general rule use all if unsure or if multiple types of roll will predicate off this option. Other rule elements can be told to check non-standard domains by adding the line `"roll-options":["domain1"]". Notice that the brackets indicate an array, so you can include multiple domains to check, but you must have the brackets there.

Effect Rule Elements

While these Rule Elements can be used anywhere, just like the rest, they are usually used for temporary Effects and for technical reasons work better when used on an Effect item than with a Toggle Property.

Temp HP

Just as the name implies this Rule element adds Temporary HP to a character the moment it is added. Many Temp HP Effects derive their value from player stats, the Rage Element is a prime example of how this can be done with the system. The first example is from the Aeon Stone (Pink Rhomboid).

TempHP

{
    "key": "TempHP",
    "value": 15
}
{
    "key": "TempHP",
    "value": "@details.level.value + @abilities.con.mod"
}

Token Effect Icon

This will apply an effect icon to the token it is applied to.

TokenEffectIcon

{
    "key":"TokenEffectIcon"
}

By Default the Effect Icon is the Icon of the Item/feat/Effect that carries the Rule element, to change that an additional field can be used.

{
    "key":"TokenEffectIcon",
    "value":"systems/pf2e/icons/spells/all-is-one-one-is-all.jpg"
}

Token Image

This rule element will change the token of an actor to the boar token that is included in the system. It is useful for Wild Shape or can be customized to set expressions on PCs per effect item.

TokenImage

{
    "key":"TokenImage",
    "value":"systems/pf2e/icons/bestiary-1/boar.webp"
}

Creature Size

This rule element can be used on a 2nd level enlarge spell effect to resize an actor and its token. Removing the item with this rule element will reset the size to the original token size again.

CreatureSize

{
    "key": "CreatureSize",
    "value": "large"
}

Effect Target

The effect target rule element will add a dropdown to the effect sheet, so you can make a selection - for example for a weapon. You can then use that for creating a dynamic selector to target an effect to a single weapon.

EffectTarget

{
    "key": "EffectTarget",
    "scope": "weapon"
}

Adding Traits

{
  "key": "ActorTraits",
  "add": ["humanoid", "human", "elf"]
}

Advanced Rule Element Controls

Bracket using Item Attribute

This Rule Element uses brackets that do not depend on the players level but on the carrier items level instead (In this case the Spell Effect for Heroism)

{
    "key":"FlatModifier",
    "label":"Heroism",
    "selector":"saving-throw",
    "type":"status",
    "value":{
        "brackets":[
            {
                "end":5,
                "start":3,
                "value":1
            },
            {
                "end":8,
                "start":6,
                "value":2
            },
            {
                "start":9,
                "value":3
            }
        ],
        "field":"item|data.level.value"
    }
}

Character stats in value formula

in a value, the @ notation can be used to query anything under the actor.data path.

{
    "key": "TempHP",
    "value": "@details.level.value + @abilities.con.mod"
}

Bracketed Properties

"value":{"brackets":[]} can be used to edit properties that are not the value property by declaring the properties in an object under "value". This example acts as a diceNumber Property on the lowest level of the Rule ELement.

{
    "key": "DamageDice",
    "predicate": {
        "all": [
            "melee",
            "power-attack"
        ]
    },
    "selector": "damage",
    "value": {
        "brackets": [
            {
                "end": 9,
                "value": {
                    "diceNumber": 1
                }
            },
            {
                "end": 17,
                "start": 10,
                "value": {
                    "diceNumber": 2
                }
            },
            {
                "start": 18,
                "value": {
                    "diceNumber": 3
                }
            }
        ]
    }
}

Damage Dice override

It is possible to override damage dice properties by using an override field. In this case the Rule element will model the effect of a critical fatal d12 strike against a creature that is immune to critical damage, by increasing the number of dice by one undeclared (weapon) die and the range of the die to d12, regardless of the base damage die size.

{
    "key": "DamageDice",
    "selector": "{item|_id}-damage",
    "critical": true,
    "diceNumber": 1,
    "override": {
        "dieSize": "d12"
    }
}

Advanced Selectors

To edit rolls derived from an item (only strikes and damage right now) you can prepend the selector with either a "slugified" version of the name (only small letters and "-") or the ID of the item. If you place the rule on the item you can use "{item|_id}" as part of the selector, this will be translated to the items ID without the hassle to look it up and is portable between items.

{
    "key": "DamageDice",
    "selector": "{item|_id}-damage",
    "diceNumber": 1,
    "dieSize": "d4",
    "damageType": "fire",
    "predicate": {
        "all": [
            "on-fire"
        ]
    },
    "label": "Ignited"
}

Another way to prepend the selector is to use the "slugified" name of the weapon group or the weapon name like these:

{
    "key": "FlatModifier",
    "selector": "brawling-weapon-group-damage",
    "value": 1,
    "label": "Ignited"
}
{
    "selector":"smoking-sword-damage",
    "critical":false,
    "key":"DamageDice",
    "diceNumber":1,
    "dieSize":"d6",
    "damageType":"fire",
    "label":"Stoke Flames"
}

Predicate by proficiency

Some Rule Elements should only work if the character uses a specific proficiency, this can be done with brackets over "actor.data.skills.at.rank" or with predicates. An Example is the Rangers Masterful Hunter Feature.

{
    "key":"MultipleAttackPenalty",
    "predicate": {
        "all": [
            "hunted-prey"
        ],
        "not": [
            "agile"
        ],
        "any": [
            "proficiency:master",
            "proficiency:legendary"
        ]
    },
    "roll-options": [
        "all"
    ],
    "selector":"attack",
    "value":-2
}

Options vs. Traits for Strikes

For Strike rules elements, you can add options, e.g. "options": ["dragon-jaws"]. Other rules elements can then target this with predicates. This is basically the same as giving a strike a trait, but it doesn't show up in the UI, which can be handy!

Changing Degree of Success

The type can be save, skill or attribute (attribute can only take perception as a selector). Adjustment has the same format as

interface PF2CheckDCModifiers {
    all?: 'one-degree-better' | 'one-degree-worse';
    criticalFailure?: 'one-degree-better' | 'one-degree-worse';
    failure?: 'one-degree-better' | 'one-degree-worse';
    success?: 'one-degree-better' | 'one-degree-worse';
    criticalSuccess?: 'one-degree-better' | 'one-degree-worse';
}

Example (Juggernaut Feat):

{"key":"AdjustDegreeOfSuccess","type":"save","selector":"fortitude","adjustment":{"success":"one-degree-better"}}

Example (Risky Surgery Feat):

{"key":"AdjustDegreeOfSuccess","type":"skill","selector":"medicine","predicate":{"all":["risky-surgery"]},"adjustment":{"success":"one-degree-better"}}

Rule Elements and Macros

Macros can fill many purposes in conjunction with Rule Elements. three of these uses are included in this guide:

  1. Adding an Effect Item (that usually will have rule elements on it) directly from the compendium or the Item Directory (this Macro can be used to add any other items as well once you get the hang of it)

To find the ITEM_UUID of the Effect, just drag it into an items description, you'll get something like this: @Compendium[pf2e.equipment-srd.Kf4eJEXnFPuAsseP]{Chain Mail}

To add this Item then to your Inventory (or delete it if you have it) set the ITEM_UUID to 'Compendium.pf2e.equipment-srd.Kf4eJEXnFPuAsseP'

const ITEM_UUID = 'Compendium.pf2e.spell-effects.Jemq5UknGdMO7b73'; // Spell Effect: Shield

(async () => {
  const item = await fromUuid(ITEM_UUID);
  for (const token of canvas.tokens.controlled) {
    let existing = token.actor.items.filter(i => i.type === item.type).find(e => e.name === item.name);
    if (existing) {
      await token.actor.deleteOwnedItem(existing._id);
    } else {
      item = duplicate(item);
      await token.actor.createOwnedItem(item);
    }
  }
})();
  1. toggling a toggle (not really a high value for a macro, but some people like the keyboard)
actor.toggleRollOption('all', 'target:flatFooted');

To not toggle but fix the state of the toggle this line can be used:

actor.setRollOption('all', 'target:flatFooted', true);
  1. Activate a Predicate using a Rule element. As written this macro and Effect will only work if the Effect is on a weapon with a base type of "greataxe".
{
  "key":"FlatModifier",
  "label":"Sweep",
  "selector":"{item|_id}-attack",
  "type":"circumstance",
  "value":1,
  "predicate":{"all":["trait:sweep"]}
}
const options = [...actor.getRollOptions(["attack"]), "trait:sweep"];
const strikeItem = (actor.data.data.actions ?? [])
  .filter((action) => action.type === "strike")
  .find((strike) => strike.baseItem === "greataxe");
strikeItem?.variants?.[1]?.roll(event, options);
  1. adding a condition and an effect with a single macro, using the giant rage as an example.
const ITEM_UUID = 'Compendium.pf2e.feature-effects.z3uyCMBddrPK5umr'; // const ITEM_UUID = 'Compendium.pf2e.feature-effects.z3uyCMBddrPK5umr'; // Effect: Rage
const conditionType = game.pf2e.ConditionManager.getCondition("Clumsy"); // condition clumsy

// Clumsy first, the Spell effect follows clumsy
const conditionName = conditionType.name;
const conditionValue = (token.actor.data.items.find((x) => x.name === conditionType.name)) ? 0 : 1; // set the value of a valued condition here
if (conditionValue) await game.pf2e.ConditionManager.addConditionToToken(conditionType, token); 
await game.pf2e.ConditionManager.updateConditionValue(token.actor.data.items.find((x) => x.name === conditionType.name).id, token, conditionValue); // only for conditions with a value

// make the effect follow the condition
const item = await fromUuid(ITEM_UUID);
for (const token of canvas.tokens.controlled) {
    const existing = token.actor.itemTypes[item.type].find(e => e.name === item.name);
    if (conditionValue && !existing) {
        await token.actor.createEmbeddedDocuments("Item"], [item.toObject()]);
    } else if (existing) {
        await token.actor.deleteOwnedItem(existing.id);
    }
}
  1. A full example of how to create a fully automation integrated action macro.

The system is currently in the process of getting full action support. A supported action can be called in a macro like this:

game.pf2e.actions.feint({ event });

Actions that have not yet gotten support or that you want to modify slightly for your game can be automated like this:

const a = token.actor ?? game.user.character;
const traits = ['concentrate', 'secret'];
const options = a.getRollOptions([
  'all',
  'skill-check',
  'arcana',
  'action:recall-knowledge'
]);
options.push(...traits);
options.push('action:recall-knowledge');

PF2Check.roll(
  new PF2CheckModifier('Recall Knowledge: Arcana', a.data.data.skills.arc),
  {
    actor: a,
    type: 'skill-check',
    options,
    notes: a.data.data.skills.arc.notes,
    traits,
  },
  event
);

List of valid selectors

List of valid selectors

all

str-based
dex-based
con-based
int-based
wis-based
cha-based
attack
mundane-attack
spell-attack
attack-roll
str-attack
dex-attack
con-attack
int-attack
wis-attack
cha-attack

damage

saving-throw
fortitude
reflex
will

initiative
perception
class (still subject to change)

ac

hp
hp-per-level

speed
land-speed
burrow-speed
climb-speed
fly-speed
swim-speed

skill-check
acrobatics
arcana
athletics
crafting
deception
diplomacy
intimidation
medicine
nature
occultism
performance
religion
society
stealth
survival
thievery

spell dcs
${tradition}-spell-dc
spell-dc
${ability}-based
all\

Clone this wiki locally