mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-06 04:44:16 +02:00
Fixed so that ORIGIN effect values are handled differently depending on if they target the item or the origin
This commit is contained in:
parent
da11510e02
commit
610d263e19
2 changed files with 68 additions and 44 deletions
|
|
@ -172,24 +172,33 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
||||||
static getChangeValue(model, change, effect) {
|
static getChangeValue(model, change, effect) {
|
||||||
let key = change.value.toString();
|
let key = change.value.toString();
|
||||||
const isOriginTarget = key.toLowerCase().includes('origin.@');
|
const isOriginTarget = key.toLowerCase().includes('origin.@');
|
||||||
let parseModel = model;
|
let actorModel = model;
|
||||||
|
let itemModel = effect.parent;
|
||||||
if (isOriginTarget && effect.origin) {
|
if (isOriginTarget && effect.origin) {
|
||||||
key = change.key.replaceAll(/origin\.@/gi, '@');
|
|
||||||
try {
|
try {
|
||||||
const originEffect = foundry.utils.fromUuidSync(effect.origin);
|
const originEffect = foundry.utils.fromUuidSync(effect.origin);
|
||||||
const doc =
|
const doc =
|
||||||
originEffect.parent?.parent instanceof game.system.api.documents.DhpActor
|
originEffect.parent?.parent instanceof game.system.api.documents.DhpActor
|
||||||
? originEffect.parent
|
? originEffect.parent
|
||||||
: originEffect.parent.parent;
|
: originEffect.parent.parent;
|
||||||
if (doc) parseModel = doc;
|
if (doc) {
|
||||||
|
if (doc instanceof game.system.api.documents.DHItem) {
|
||||||
|
itemModel = doc;
|
||||||
|
key = key.replaceAll(/origin\.@/gi, '');
|
||||||
|
} else {
|
||||||
|
actorModel = doc;
|
||||||
|
key = key.replaceAll(/origin\.@/gi, '@');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const stackingParsedValue = effect.system.stacking
|
const stackingParsedValue = effect.system.stacking
|
||||||
? Roll.replaceFormulaData(key, { stacks: effect.system.stacking.value })
|
? Roll.replaceFormulaData(key, { stacks: effect.system.stacking.value })
|
||||||
: key;
|
: key;
|
||||||
const evalValue = itemAbleRollParse(stackingParsedValue, parseModel, effect.parent);
|
const evalValue = itemAbleRollParse(stackingParsedValue, actorModel, itemModel);
|
||||||
return evalValue ?? key;
|
return evalValue ? evalValue : key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -67,49 +67,54 @@
|
||||||
"type": "withinRange",
|
"type": "withinRange",
|
||||||
"target": "hostile",
|
"target": "hostile",
|
||||||
"range": "melee"
|
"range": "melee"
|
||||||
|
},
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"key": "system.bonuses.damage.physical.bonus",
|
||||||
|
"type": "add",
|
||||||
|
"value": "ORIGIN.@item.@system.resource.value",
|
||||||
|
"priority": null,
|
||||||
|
"phase": "initial"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "system.bonuses.damage.magical.bonus",
|
||||||
|
"type": "add",
|
||||||
|
"value": "ORIGIN.@item.@system.resource.value",
|
||||||
|
"priority": null,
|
||||||
|
"phase": "initial"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "system.rules.damageReduction.reduceSeverity.physical",
|
||||||
|
"type": "add",
|
||||||
|
"value": 1,
|
||||||
|
"priority": null,
|
||||||
|
"phase": "initial"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "system.rules.conditionImmunities.vulnerable",
|
||||||
|
"type": "override",
|
||||||
|
"value": 1,
|
||||||
|
"priority": null,
|
||||||
|
"phase": "initial"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "system.rules.conditionImmunities.restrained",
|
||||||
|
"type": "override",
|
||||||
|
"value": 1,
|
||||||
|
"priority": null,
|
||||||
|
"phase": "initial"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"duration": {
|
||||||
|
"type": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"changes": [
|
|
||||||
{
|
|
||||||
"key": "system.bonuses.damage.physical.bonus",
|
|
||||||
"mode": 2,
|
|
||||||
"value": "ORIGIN.@item.resource.value",
|
|
||||||
"priority": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "system.bonuses.damage.magical.bonus",
|
|
||||||
"mode": 2,
|
|
||||||
"value": "ORIGIN.@item.resource.value",
|
|
||||||
"priority": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "system.rules.damageReduction.reduceSeverity.physical",
|
|
||||||
"mode": 2,
|
|
||||||
"value": "1",
|
|
||||||
"priority": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "system.rules.conditionImmunities.vulnerable",
|
|
||||||
"mode": 5,
|
|
||||||
"value": "1",
|
|
||||||
"priority": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "system.rules.conditionImmunities.restrained",
|
|
||||||
"mode": 5,
|
|
||||||
"value": "1",
|
|
||||||
"priority": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"disabled": false,
|
"disabled": false,
|
||||||
"duration": {
|
"duration": {
|
||||||
"startTime": null,
|
"value": null,
|
||||||
"combat": null,
|
"units": "seconds",
|
||||||
"seconds": null,
|
"expiry": null,
|
||||||
"rounds": null,
|
"expired": false
|
||||||
"turns": null,
|
|
||||||
"startRound": null,
|
|
||||||
"startTurn": null
|
|
||||||
},
|
},
|
||||||
"description": "",
|
"description": "",
|
||||||
"tint": "#ffffff",
|
"tint": "#ffffff",
|
||||||
|
|
@ -119,6 +124,16 @@
|
||||||
"_stats": {
|
"_stats": {
|
||||||
"compendiumSource": null
|
"compendiumSource": null
|
||||||
},
|
},
|
||||||
|
"start": {
|
||||||
|
"time": 0,
|
||||||
|
"combat": null,
|
||||||
|
"combatant": null,
|
||||||
|
"initiative": null,
|
||||||
|
"round": null,
|
||||||
|
"turn": null
|
||||||
|
},
|
||||||
|
"showIcon": 1,
|
||||||
|
"folder": null,
|
||||||
"_key": "!items.effects!PnD2UCgzIlwX6cY3.xzQtFSuDS48kUdAZ"
|
"_key": "!items.effects!PnD2UCgzIlwX6cY3.xzQtFSuDS48kUdAZ"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue