Skip to content

Wire pf2e auto-template into preCreateRegion for Foundry v14#311

Open
takaqiao wants to merge 1 commit into
Feu-Secret:masterfrom
takaqiao:feat/v14-pf2e-region-bridge
Open

Wire pf2e auto-template into preCreateRegion for Foundry v14#311
takaqiao wants to merge 1 commit into
Feu-Secret:masterfrom
takaqiao:feat/v14-pf2e-region-bridge

Conversation

@takaqiao
Copy link
Copy Markdown

@takaqiao takaqiao commented May 4, 2026

Summary

In Foundry v14 + PF2e v8 spell areas are placed as Regions rather than MeasuredTemplates (canvas.regions.placeRegion(...)). The existing autoTemplate flow only fires on preCreateMeasuredTemplate, so on v14 PF2e games auto-presets stop applying to spells.

flags.pf2e.origin keeps the same {name, slug, traits, ...} shape on regions, and flags.pf2e.areaShape carries one of the PF2e EFFECT_AREA_SHAPES values (burst, cone, cube, cylinder, emanation, line, square). This PR reuses the existing autoTemplate settings on the Region creation path with a small shape map so trait → preset lookups continue to work.

Changes

  • AutoTemplatePF2E gains preCreateRegion(region) and an areaShape → legacy template type map (burst/emanation/cylindercircle, cube/squarerect, lineray). Override-by-name still wins over category-by-trait, matching the template flow.
  • tokenmagic.js adds a preCreateRegion hook that mirrors the existing preCreateMeasuredTemplate flow: lets the system auto-template inject tmfx options, then converts them into flags.tokenmagic.filters and flags.tokenmagic.regionData.alpha so the existing createRegion hook picks them up at render time. placeableType is set to Region and the anchor is fixed to (0.5, 0.5) since regions have no direction/angle.
  • module.json compatibility.verified bumped to 14.360. minimum is left at 13 so v13 games keep installing it unchanged.

No bundle output is touched; running webpack will pick up the source edits.

Test plan

  • Foundry v13 + PF2e v6/v7: cast a damage-typed spell with a measured template, confirm the configured preset still applies (regression check).
  • Foundry v14.360 + PF2e v8.1.1: cast spells producing each EFFECT_AREA_SHAPES value (e.g. Burning Hands → cone, Fireball → burst, Lightning Bolt → line) and confirm trait-matched presets and tints apply to the resulting Region.
  • Auto-template overrides by item name still win over trait categories.
  • Manually adding/editing tmfx filters on a Region from the FX editor continues to render correctly.

In Foundry v14 + PF2e v8 spell areas are placed as Regions rather than
MeasuredTemplates. flags.pf2e.origin keeps the same shape and
flags.pf2e.areaShape carries one of the EFFECT_AREA_SHAPES values, so the
existing autoTemplate categories/overrides settings can be reused on the
Region creation path.

- AutoTemplatePF2E gains preCreateRegion(region) and a pf2e areaShape ->
  legacy template type map (burst/emanation/cylinder -> circle, cube/square
  -> rect, line -> ray) so each trait is matched against the right config
  bucket.
- tokenmagic.js adds a preCreateRegion handler that mirrors the existing
  preCreateMeasuredTemplate flow: it lets the system auto-template inject
  tmfx options, then converts them into flags.tokenmagic.filters and
  flags.tokenmagic.regionData.alpha so the existing createRegion hook
  picks them up at render time.
- module.json compatibility.verified bumped to 14.360 (minimum stays at 13).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant