Fixed trigger conditions not working on rest

This commit is contained in:
Stefan Zermatten
2022-07-25 15:13:47 +02:00
parent bec65be170
commit 6ea882a053

View File

@@ -11,15 +11,9 @@ export default function applyTriggers(node, { creature, targets, scope, log }, t
const type = prop.type;
if (creature.triggers?.[type]?.[timing]) {
creature.triggers[type][timing].forEach(trigger => {
// Tags
if (!triggerMatchTags(trigger, prop)) return;
// Condition
if (trigger.condition?.parseNode) {
recalculateCalculation(trigger.condition, scope, log);
if (!trigger.condition.value) return;
if (triggerMatchTags(trigger, prop)) {
applyTrigger(trigger, { creature, targets, scope, log });
}
// Apply
applyTrigger(trigger, { creature, targets, scope, log });
});
}
}
@@ -57,6 +51,13 @@ function triggerMatchTags(trigger, prop) {
}
export function applyTrigger(trigger, { creature, targets, scope, log }) {
// Prevent triggers from firing if their condition is false
if (trigger.condition?.parseNode) {
recalculateCalculation(trigger.condition, scope, log);
if (!trigger.condition.value) return;
}
// Prevent triggers from firing themselves in a loop
if (trigger.firing) {
/*
log.content.push({