diff --git a/packs/pf2e/conditions/drained.json b/packs/pf2e/conditions/drained.json index d85ff7dbaa1..df17c41049c 100644 --- a/packs/pf2e/conditions/drained.json +++ b/packs/pf2e/conditions/drained.json @@ -45,8 +45,21 @@ }, { "key": "LoseHitPoints", + "predicate": [ + { + "not": "drained-hp-effective-minus-one" + } + ], "reevaluateOnUpdate": true, "value": "max(1,@actor.level) * @item.badge.value" + }, + { + "key": "LoseHitPoints", + "predicate": [ + "drained-hp-effective-minus-one" + ], + "reevaluateOnUpdate": true, + "value": "max(1,@actor.level) * max(0,@item.badge.value - 1)" } ], "traits": { diff --git a/packs/pf2e/feats/ancestry/versatile-heritages/dhampir/svetocher.json b/packs/pf2e/feats/ancestry/versatile-heritages/dhampir/svetocher.json index e6db18b17f8..8dbeb6835c1 100644 --- a/packs/pf2e/feats/ancestry/versatile-heritages/dhampir/svetocher.json +++ b/packs/pf2e/feats/ancestry/versatile-heritages/dhampir/svetocher.json @@ -34,19 +34,38 @@ "value": 1 }, { - "key": "AdjustModifier", - "mode": "add", - "selector": "fortitude", - "slug": "drained", - "value": 1 + "key": "RollOption", + "option": "svetocher" + }, + { + "key": "RollOption", + "option": "drained-hp-effective-minus-one" }, { "key": "FlatModifier", "predicate": [ - "self:condition:drained" + "self:condition:drained", + { + "not": "sanguine-tenacity" + } ], "selector": "hp", "value": "@actor.level" + }, + { + "key": "AdjustModifier", + "mode": "add", + "predicate": [ + "self:condition:drained", + { + "not": "sanguine-tenacity" + } + ], + "selectors": [ + "fortitude" + ], + "slug": "drained", + "value": 1 } ], "traits": { diff --git a/packs/pf2e/feats/general/level-11/sanguine-tenacity.json b/packs/pf2e/feats/general/level-11/sanguine-tenacity.json index a56de3081bd..8aeb57c5440 100644 --- a/packs/pf2e/feats/general/level-11/sanguine-tenacity.json +++ b/packs/pf2e/feats/general/level-11/sanguine-tenacity.json @@ -30,6 +30,22 @@ "title": "Pathfinder #213: Thirst for Blood" }, "rules": [ + { + "key": "RollOption", + "option": "sanguine-tenacity" + }, + { + "key": "RollOption", + "option": "drained-hp-effective-minus-one" + }, + { + "key": "FlatModifier", + "predicate": [ + "self:condition:drained" + ], + "selector": "hp", + "value": "@actor.level" + }, { "key": "Resistance", "type": "bleed", @@ -62,14 +78,6 @@ "str-damage" ], "value": 1 - }, - { - "key": "FlatModifier", - "predicate": [ - "self:condition:drained" - ], - "selector": "hp", - "value": "@actor.level" } ], "traits": { diff --git a/src/module/rules/rule-element/lose-hit-points.ts b/src/module/rules/rule-element/lose-hit-points.ts index acef8854a01..f6ee96d6195 100644 --- a/src/module/rules/rule-element/lose-hit-points.ts +++ b/src/module/rules/rule-element/lose-hit-points.ts @@ -18,14 +18,14 @@ class LoseHitPointsRuleElement extends RuleElement { } override onCreate(actorUpdates: Record): void { - if (this.ignored) return; + if (this.ignored || !this.test()) return; const value = Math.trunc(Math.abs(Number(this.resolveValue(this.value)) || 0)); const currentHP = this.actor._source.system.attributes.hp.value; actorUpdates["system.attributes.hp.value"] = Math.max(currentHP - value, 0); } override beforePrepareData(): void { - if (this.ignored) return; + if (this.ignored || !this.test()) return; const { actor } = this; if (!this.recoverable) { @@ -35,12 +35,19 @@ class LoseHitPointsRuleElement extends RuleElement { } override async preUpdate(changes: DeepPartial): Promise { - if (!this.reevaluateOnUpdate || this.ignored) return; + if (!this.reevaluateOnUpdate || this.ignored || !this.test()) return; const previousValue = Math.trunc(Math.abs(Number(this.resolveValue(this.value)) || 0)); const newItem = this.item.clone(changes); - const rule = newItem.system.rules.find((r): r is LoseHitPointsSource => r.key === this.key); + const ruleSource = typeof this.sourceIndex === "number" ? newItem.system.rules[this.sourceIndex] : undefined; + if (!ruleSource || ruleSource.key !== "LoseHitPoints") return; const newValue = Math.trunc( - Math.abs(Number(this.resolveValue(String(rule?.value), 0, { resolvables: { item: newItem } }))), + Math.abs( + Number( + this.resolveValue(String((ruleSource as LoseHitPointsSource).value), 0, { + resolvables: { item: newItem }, + }), + ) || 0, + ), ); const valueChange = newValue - previousValue; if (valueChange > 0) {