macro to add effects to powers
This commit is contained in:
parent
cc14b28d40
commit
557cb6e546
28
macros/addEffectToPowers.js
Normal file
28
macros/addEffectToPowers.js
Normal file
@ -0,0 +1,28 @@
|
||||
const tokens = canvas.tokens.controlled;
|
||||
const actors = tokens.map((t) => t.actor);
|
||||
const EFFECT_OBJECT = {
|
||||
name: 'Effect',
|
||||
type: 'macro',
|
||||
dice: null,
|
||||
resourcesUsed: null,
|
||||
modifier: '',
|
||||
override: '',
|
||||
uuid: 'Compendium.swade-mb-helpers.helper-macros.Macro.AjuA11hQ48UJNwlH',
|
||||
macroActor: 'self',
|
||||
isHeavyWeapon: false,
|
||||
};
|
||||
for (const actor of actors) {
|
||||
const updates = [];
|
||||
for (const power of actor.items.filter((i) => i.type === 'power')) {
|
||||
if (Object.values(power.system.actions.additional).find((action) => action.name === 'Effect')) {
|
||||
continue;
|
||||
}
|
||||
const _id = power.id;
|
||||
const additional = foundry.utils.deepClone(power.system.actions.additional);
|
||||
additional[foundry.utils.randomID(8)] = foundry.utils.deepClone(EFFECT_OBJECT);
|
||||
updates.push({ _id, 'system.actions.additional': additional });
|
||||
}
|
||||
if (updates.length > 0) {
|
||||
actor.updateEmbeddedDocuments('Item', updates);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user