ActiveEffect values can now specify ORIGIN. to grab the value from the origin (#534)

This commit is contained in:
WBHarry 2025-08-02 23:35:45 +02:00 committed by GitHub
parent ee5c3a9322
commit 5757db3f49
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 42 additions and 23 deletions

View file

@ -70,7 +70,17 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
/**@inheritdoc*/
static applyField(model, change, field) {
const evalValue = this.effectSafeEval(itemAbleRollParse(change.value, model, change.effect.parent));
const isOriginTarget = change.value.toLowerCase().includes('origin.@');
let parseModel = model;
if (isOriginTarget && change.effect.origin) {
change.value = change.value.replaceAll(/origin\.@/gi, '@');
try {
const doc = foundry.utils.fromUuidSync(change.effect.origin);
if (doc) parseModel = doc;
} catch (_) {}
}
const evalValue = this.effectSafeEval(itemAbleRollParse(change.value, parseModel, change.effect.parent));
change.value = evalValue ?? change.value;
super.applyField(model, change, field);
}