[#4698] Auto-sync actor senses to prototype token vision#6864
Conversation
|
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 ( The Defaults to |
|
A high-level consideration: We might want to, instead of manually setting values on the token during base data prep, leverage |
- 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
I tried following through with this in the PR. I got things functioning, but two things came up that I want to ask about before updating the PR. First, the synthetic const effect = { _applyChangeShim: change => change};
changes.push({ effect, key: "sight.range", value: sight.range, type: "upgrade", priority: 0 });This works, but its clearly abusing Second, and the bigger one: even with that, the change can't move what actually governs darkvision. Am I missing a cleaner way to give these changes a real effect, or to get the range set before detection-mode prep? |
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.senseshas been expanded from string labels to objects so each sense can declare adetectionMode, whether itgrantsSight, and avisionMode: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 withfeelTremorandseeAlldetection modes.The prototype token is kept in sync through CRUD handlers (
preCreateSenses,preUpdateSensesonAttributesFields, and_syncTokenSensesonActor5ecalled from descendant hooks). Placed tokens on the canvas also get overrides applied duringTokenDocument5e.prepareBaseData, before V14 AE token changes run.A few notes:
senseVisionSyncworld setting (defaulttrue)systemVersion < 6.0.0)Closes #4698