Skip to content

[#4351] Region Template auto targeting - #7181

Draft
thatlonelybugbear wants to merge 48 commits into
foundryvtt:6.0.xfrom
thatlonelybugbear:feature/regions-auto-targeting
Draft

[#4351] Region Template auto targeting#7181
thatlonelybugbear wants to merge 48 commits into
foundryvtt:6.0.xfrom
thatlonelybugbear:feature/regions-auto-targeting

Conversation

@thatlonelybugbear

@thatlonelybugbear thatlonelybugbear commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What this PR does. Probably too many things...

Relevant to #4351 for the Template Targeting

If I know how far the system is willing to go, I can adjust accordingly

  • Highlight targets before region placement and auto-target on placement
    • Per-item auto-target setting
    • Per-item walls behaviour setting
    • System-level default for auto-target behaviour
    • System-level setting for overriding targeting method, from matching targets to highlighted grid spaces only to using occupied-space overlap, working around the Foundry's grid-space center-point rule.
      • Match that logic to different region grid highlighting.
  • If an item creates a persistent region (probably based on the duration or checkbox?), update targets as tokens enter and leave the region.
  • 3D templates:
    • Elevation support
      • The region matches initial elevation to the source token elevation.
      • During template preview, the default keys handling elevation (Q and E) can be used to increase/decrease template elevation (the base elevation is shown alongside the template length).
        • Spheres and cones extend upwards and downwards to their radius.
          • For example, Caster at 20ft. Casts fireball, which has bottom at 0ft and top at 40ft (non inclusive).
        • Cubes upwards
    • Multi-level support
  • Walls interaction
    • Walls block: Templates targeting matching core's region/wall interactions
    • Spread around corners: For items like Fireball, if there is a way around walls or though gaps, the full template targets tokens
      • Match that logic to actual region grid highlighting
    • Ignore walls
  • Filter targets by
    • Self. Ally, Enemy
    • Object and Space do not target tokens.
    • Hidden targets are filtered out
    • Ethereal targets are only targeted if the source has also Ethereal status
    • No "Defeated" creatures handling, as that might have undesirable side-effects
    • Filter per creature type
  • Respect options for walls behaviour and grid aware_ness_ into created regions

arbron and others added 30 commits June 23, 2026 23:41
…mplate`

Adds a new `dnd5e.canvas.TemplatePlacement` API to handle placing
shapes within a scene. This base API deals with basic shape data
but the `fromActivity` factory method behaves similar to the old
method on `AbilityTemplate` to create a full measured template
region.

The created regions are set up to work as similar as possible to
the old measured templates, using `coverage` highlight mode and
the user's color. When the area of effect count is larger than one,
all of the shapes are combined into a single measured template.

`TokenPlacement` has been refactored and much of its code has been
shifted into a new `BasePlacement` class that is shared between the
two canvas placement systems.

Closes foundryvtt#6763
…egion`

Rewrites both placement APIs to rely on core's `placeToken` and
`placeRegion` mathods rather than a new implementation. Removes
`BasePlacement` since there is no longer much shared code.
Finds all applications that are not minimized, have a frame, and
are not detached and minimizes them until placement is completed.
This behavior can be disabled using the `minimizeWindows` option
in the placement configuration.

Also adds a `restoreLayer` option to the configuration to control
whether the original canvas layer is made active after placement.
Both of these options are enabled by default.

Closes foundryvtt#6763
@thatlonelybugbear
thatlonelybugbear force-pushed the feature/regions-auto-targeting branch from 1d82035 to f442dbb Compare June 23, 2026 22:46
arbron added 3 commits June 23, 2026 15:52
… to templates (foundryvtt#6761)

* [foundryvtt#5559, foundryvtt#6722] Add Activity Behaviors that attach to templates

Adds a new system for registering Activity Behaviors. These will
be automatically attached to any measured templates created from
that activity. An Activity Behavior represents a simplified data
model for configuring a Region Behavior, allowing for certain
parts of the Region Behavior's configuration to be automatically
populated based on activity settings (for example, the Difficult
Terrain behavior gets its "Magical" property set automatically
based on whether the item has the magical property set).

Since players cannot create region behaviors themselves, the
creation of these behaviors is handled by the active GM user after
the player places the template in the scene.

Closes foundryvtt#6722

* [foundryvtt#5559, foundryvtt#6722] Clean up behavior context, fix typos & localization

* [foundryvtt#6722] Fix applied behaviors section not appearing if empty

* [foundryvtt#6722] Switch to `TypeDataField5e` for configs, fix form

* [foundryvtt#6722] Remove some unused imports
…ior (foundryvtt#6798)

* [foundryvtt#5559] Add activity behavior for Apply Active Effect behavior

Adds a new activity behavior that creates core's Apply Active
Effect Region Behavior.

* [foundryvtt#5559] Swap to system behavior, add sizes & types support

* [foundryvtt#5559] Fix typo in config, JSDoc typos

* Fix issue with `TypeDataField5e#_migrate`
…ities (foundryvtt#6800)

* [foundryvtt#6641] Allow standalone AE documents to be linked to activities

Adds a new `uuid` field to applied effects data on activities which
allows the effect to be retrieved from a compendium rather than
from the item.

This is breaking change for `Activity#applicableEffects`, which now
returns the effect profiles rather than the effects themselves. A
new method `getApplicableEffects` has been added that retrieves the
actual effect documents and is async so it can get them from the
compendium.

Closes foundryvtt#6641

* [foundryvtt#6641] Clean up some code & docs issues

* [foundryvtt#6641] Add type restriction on UUID field

* [foundryvtt#6641] Expand remote support to Enchant activity

- Adds support for remote enchantments in `EnchantActivity`
- Activity sheets now define what AE types they support
- Removed separate enchantment template in favor of sharing the
  standard activity effects list template
- Reworked `EffectApplicationElement` to not use `async` in the
  `connectedCallback`
- Fixed application of effect start time

* [foundryvtt#6641] Move supported effects into data, adjust existing effects

* [foundryvtt#6641] Remove unused `SUPPORTED_EFFECT_TYPE`
@observer1236

Copy link
Copy Markdown
Contributor

Is there any feasibility in allowing evaluation of the system.target.affects.special field before auto selecting targets, or adding a new field to evaluate its contents for target filtering? In official rules, features like Turn Undead only target specific types of creatures.

@thatlonelybugbear

Copy link
Copy Markdown
Contributor Author

Is there any feasibility in allowing evaluation of the system.target.affects.special field before auto selecting targets, or adding a new field to evaluate its contents for target filtering? In official rules, features like Turn Undead only target specific types of creatures.

I have this working in my local version but not added in this PR yet (all of this was included in a module I was working on).

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.

4 participants