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);
}

View file

@ -69,7 +69,6 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
getTargetList() {
const targets = this.system.hitTargets;
return targets.map(target => game.canvas.tokens.documentCollection.find(t => t.actor.uuid === target.actorId));
}
async onDamage(event) {
@ -77,7 +76,7 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
const targets = this.getTargetList();
if (this.system.onSave) {
const pendingingSaves = this.system.hitTargets.filter(t => t.saved.success === null);
const pendingingSaves = this.system.hitTargets.filter(t => t.saved.success === null);
if (pendingingSaves.length) {
const confirm = await foundry.applications.api.DialogV2.confirm({
window: { title: 'Pending Reaction Rolls found' },
@ -112,6 +111,17 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
}
}
getAction(actor, itemId, actionId) {
const item = actor.items.get(itemId),
action =
actor.system.attack?._id === actionId
? actor.system.attack
: item.system.attack?._id === actionId
? item.system.attack
: item?.system?.actions?.get(actionId);
return action;
}
async onApplyEffect(event) {
event.stopPropagation();
const actor = await foundry.utils.fromUuid(this.system.source.actor);