Skip to content

[#4698] Auto-sync actor senses to prototype token vision#6864

Open
Sayshal wants to merge 1 commit intofoundryvtt:5.3.xfrom
Sayshal:fix/4698
Open

[#4698] Auto-sync actor senses to prototype token vision#6864
Sayshal wants to merge 1 commit intofoundryvtt:5.3.xfrom
Sayshal:fix/4698

Conversation

@Sayshal
Copy link
Copy Markdown
Contributor

@Sayshal Sayshal commented Apr 1, 2026

Updates the prototype token's sight range, vision mode, and detection modes when an actor's senses change. Works for direct edits on the actor sheet, senses inherited from species items, and Active Effects that modify sense ranges.

CONFIG.DND5E.senses has been expanded from string labels to objects so each sense can declare a detectionMode, whether it grantsSight, and a visionMode:

DND5E.senses = {
  blindsight: { label: "DND5E.SenseBlindsight", detectionMode: "blindsight" },
  darkvision: { label: "DND5E.SenseDarkvision", grantsSight: true, visionMode: "darkvision" },
  tremorsense: { label: "DND5E.SenseTremorsense", detectionMode: "feelTremor" },
  truesight: { label: "DND5E.SenseTruesight", detectionMode: "seeAll", grantsSight: true, visionMode: "darkvision" }
};

Modules can extend this config to add custom senses with their own detection/vision mode mappings.

Vision range is the max of all senses with grantsSight. Senses without it only add detection modes. So an actor with darkvision 10, truesight 30, and tremorsense 60 gets a sight range of 30 with feelTremor and seeAll detection modes.

The prototype token is kept in sync through CRUD handlers (preCreateSenses, preUpdateSenses on AttributesFields, and _syncTokenSenses on Actor5e called from descendant hooks). Placed tokens on the canvas also get overrides applied during TokenDocument5e.prepareBaseData, before V14 AE token changes run.

A few notes:

  • Controlled by a new senseVisionSync world setting (default true)
  • Compendium imports and explicit prototype token edits are left alone
  • Non-sense detection modes the user has configured manually are preserved
  • Includes a migration for existing actors (systemVersion < 6.0.0)

Closes #4698

- Expand CONFIG.DND5E.senses from string labels to SenseConfiguration objects with detectionMode, grantsSight, and visionMode properties
- Add TokenDocument5e.prepareBaseData to apply sense-derived sight and detection mode overrides to placed tokens
- Add CRUD handlers (preCreateSenses, preUpdateSenses) on AttributesFields to persist prototype token sync
- Add Actor5e._syncTokenSenses for descendant hook sync when items or effects change
- Add senseVisionSync world setting to control the feature
- Add migration for existing actors (systemVersion < 6.0.0)
- Update all label references to use the new object structure

Closes foundryvtt#4698
@thatlonelybugbear
Copy link
Copy Markdown
Contributor

Is there a need for this to be gated behind a setting?

@Sayshal
Copy link
Copy Markdown
Contributor Author

Sayshal commented Apr 1, 2026

Is there a need for this to be gated behind a setting?

I think so, it's automation that writes to tokens, and the system already gates similar behavior behind toggles (disableConcentration, disableAdvancements, movementAutomation). It also gates the migration, so existing worlds with manually configured token vision don't get overwritten on upgrade.

The DND5E.senses config restructuring itself isn't gated — the detectionMode, grantsSight, visionMode metadata is always available. The setting only controls whether the system acts on it (writing to prototype tokens and applying runtime overrides on placed tokens).

Defaults to true so it just works unless someone explicitly turns it off. That said, I'm not strongly attached to it, so if the consensus is it's unnecessary overhead I'm fine to drop it.

@Fyorl Fyorl added the strategic Requires sign-off from a core Foundry VTT developer before merge. label Apr 2, 2026
@roth-michael
Copy link
Copy Markdown
Contributor

A high-level consideration: We might want to, instead of manually setting values on the token during base data prep, leverage Actor#tokenActiveEffectChanges for handling the downstream effects. If we did that, I don't think we'd need to touch the Token code at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api priority: high strategic Requires sign-off from a core Foundry VTT developer before merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update prototype token with the appropriate vision mode when darkvision or other special vision traits are set on the character sheet

5 participants