Skip to content

Quickstart guide for rule elements

Gunnar Busch edited this page Jan 15, 2021 · 133 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: a. 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. a. 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.

Rule Elements

Flat Modifier

Let's look at an example, inspire courage:

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

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

{"key":"PF2E.RuleElement.FlatModifier","label":"Inspire Courage (vs fear)","predicate":{"all":["fear"]},"selector":"will","type":"status","value":1}

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. For flat modifiers text will show up when you look at the modifiers of a given roll
    • To see this in action apply the rule effect then look at the ac modifiers, you should see "Inspire courage"
  3. Predicate: If you want your bonus to only apply at certain times, only vs. fear, you 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.
  4. Selector: Specifies, or selects, what to apply your modifier to.
    • There will be 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
  5. Type: This is the modifier type,
    • With this set appropriately the modifier will be taken into account for bonus stacking rules
  6. Value: the value can be minus if you are applying a penalty

Flat modifiers are just the tip of the iceberg. Here some more examples of slightly more complicated rules:

{
  "key": "PF2E.RuleElement.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 }
    ]
  }
}

It's possible to add level-scaling with the value of a modifier!

Even Though the Flat Modifier is one of the most "Basic" Rule elements, it sees one of the widest ranges of application. 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":"PF2E.RuleElement.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"
  }
}

There are several more rule types with examples littered throughout the compendium, without being exhaustive:

Dexterity Modifier Cap

PF2E.RuleElement.DexterityModifierCap

    example rule:
    {
        "key": "PF2E.RuleElement.DexterityModifierCap",
        "value": 5
    }
    example use: bracers of armor

Temp HP

Something to note about Temp HP: they can't be applied using a toggle mechanic. This rule element is at it's most powerful on Effect items.

PF2E.RuleElement.TempHP

    example rule:
        {
            "key": "PF2E.RuleElement.TempHP",
            "value": 15
        }
    example use: "Aeon Stone (Pink Rhomboid)"
    example rule:
        {
            "key": "PF2E.RuleElement.TempHP",
            "value": "@details.level.value + @abilities.con.mod"
        }
    example use: "Rage"

In the second example, the actors Level and con modifier are used to calculate the tempHP of the effect when the player gains the Effect.

Damage Dice

PF2E.RuleElement.DamageDice

    Example rule:
        {
            "key": "PF2E.RuleElement.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
                        }
                    }
                ]
            }
        }
    example use: Feat power attack
   Example Rule: Shattering Strike (Weapon Improviser)
      {
        "critical": true
        "key": "PF2E.RuleElement.DamageDice",
        "selector": "damage",
        "diceNumber": 3,
        "dieSize": "d6",
        "damageType": "piercing",
        "predicate": {
          "all": [
            "improvised"
          ]
        },
        "label": "Shattering Strike"
      }
   Example Rule: Fire Poi added damage
      {
        "key": "PF2E.RuleElement.DamageDice",
        "selector": "{item|_id}-damage",
        "diceNumber": 1,
        "dieSize": "d4",
        "damageType": "fire",
        "predicate": {
          "all": [
            "on-fire"
          ]
        },
        "label": "Ignited"
      }

in this third example: Notice how the selector references the Items damage. The Rule Element only works on the Fire Poi itself this way, but must be placed on the Pire Poi. The 'on-fire' predicate would be a Toggle Property, which brings us to the next rule element:

Toggle Property

PF2E.RuleElement.ToggleProperty

    example rule:
    {
        "key": "PF2E.RuleElement.ToggleProperty",
        "property": "flags.pf2e.rollOptions.damage-roll.power-attack"
    }
    example use: Power attack feat

Base Speed

PF2E.RuleElement.BaseSpeed

    example rule:
    {
        "key": "PF2E.RuleElement.BaseSpeed",
        "selector": "fly",
        "value": 30
    }
    example use: Effect: Barding of the Zephyr

Sense

PF2E.RuleElement.Sense

  example rule:
    {
        "key": "PF2E.RuleElement.Sense",
        "label": "PF2E.SensesDarkvision",
        "selector": "darkvision"
    }
  example use: spell effect bloodhound mask
  example rule:
    {
      "acuity":"imprecise",
      "key":"PF2E.RuleElement.Sense",
      "label":"PF2E.SensesScent",
      "range":30,
      "selector":"scent"
    }
  this example can be used for Sensate Gnome or similar

Token Effect Icon

PF2E.RuleElement.TokenEffectIcon

This will apply an effects icon to the token it is applied to

{"key":"PF2E.RuleElement.TokenEffectIcon"}

Token Image

PF2E.RuleElement.TokenImage

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

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.

Token Size

PF2E.RuleElement.TokenSize

{
  "key":"PF2E.RuleElement.TokenSize",
  "value":2
}

or:

{
  "key":"PF2E.RuleElement.TokenSize",
  "value":"large"
}

This rule element can be used on a 2nd level enlarge spell effect to resize the token. Deleting the latest TokenSize effect from the token will reset the size to the original token size again.

Fixed Proficiency

PF2E.RuleElement.FixedProficiency

{
  "key":"PF2E.RuleElement.FixedProficiency",
  "selector":"athletics",
  "value":9
}

This rule element can be used well for Animal Form, 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.

Set Property

PF2E.RuleElement.SetProperty

{
  "key": "PF2E.RuleElement.SetProperty",
  "property": "flags.pf2e.rollOptions.all.rage",
  "on": {
    "added": true,
    "removed": false
  },
  "retain": true
}

This works as a toggle property or with a toggle property to toggle it off/on.

Rage has a lot of different mechanics depending on the instinct and some feats, some of these need to be on an effect item, like the temp HP and token size or even image changes. to avoid clutter it's easier to use predicated rules on feats and features and set them active with a rage effect using the setProperty rule element. Some breakdown:

  1. property: this works the same way as in the toggleProperty "flags.pf2e.rollOptions..name"
  2. on -> added: technically optional but mostly useless without it
  3. on -> removed: optional, will disable the "retain" field if present
  4. retain: optional, will restore the old value when an item with this rule elements is deleted from the character.

Strike

PF2E.RuleElement.Strike

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

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 monks Tiger Claw strike here.

If necessary an "ability": "int" could be used for a strike that scales its to-hit with intelligence, also works with other 3 character ability shorthand. (like the "Spiritual Weapon" Spell of a witch could)

List of valid selectors

List of valid selectors

all

str-based
dex-based
con-based
int-based
wis-based
cha-based
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

Clone this wiki locally