Changed task triggers to be stored differently so that attribute check and damage triggers don't overlap

This commit is contained in:
Thaum Rystra
2024-05-21 17:41:20 +02:00
parent 8eb702cde3
commit 772e55ece5
9 changed files with 154 additions and 173 deletions

View File

@@ -22,7 +22,11 @@ export default async function applyItemAsAmmoTask(task: ItemAsAmmoTask, action:
result.pushScope = { ['~ammoConsumed']: { value } };
// Apply the before triggers
await applyTriggers(action, item, [action.creatureId], 'ammo.before', userInput);
await applyTriggers(action, item, task.targetIds, 'ammoTriggerIds.before', userInput);
// Create a new result after before triggers have run
result = new TaskResult(task.prop._id, task.targetIds);
action.results.push(result);
// Refetch the scope properties
const scope = await getEffectiveActionScope(action);
@@ -52,11 +56,12 @@ export default async function applyItemAsAmmoTask(task: ItemAsAmmoTask, action:
},
});
await applyTriggers(action, item, [action.creatureId], 'ammo.after', userInput);
await applyTriggers(action, item, task.targetIds, 'ammoTriggerIds.after', userInput);
if (task.params.skipChildren) {
return applyAfterTasksSkipChildren(action, item, task.targetIds, userInput);
await applyAfterTasksSkipChildren(action, item, task.targetIds, userInput);
} else {
return applyDefaultAfterPropTasks(action, item, task.targetIds, userInput);
await applyDefaultAfterPropTasks(action, item, task.targetIds, userInput);
}
return applyTriggers(action, item, task.targetIds, 'ammoTriggerIds.afterChildren', userInput);
}