attempt at an automated evocations shape change

This commit is contained in:
Mike Bloy 2021-11-29 22:52:05 -06:00
parent 9b43f90901
commit 41da8193ab
2 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,3 @@
const macro = game.macros.getName("shapeshift_AE_form");
let value = await macro.execute(args[0]);
return value;

38
ae_shape_change_form.js Normal file
View File

@ -0,0 +1,38 @@
let summon = args[0].summon;
let duplicates = args[0].duplicates;
let assignedActor = args[0].assignedActor;
let data = {
actor: {},
token: {},
embedded: {Item: {}}
};
const name = `${assignedActor.data.token.name} (${summon.data.token.name})`;
const actorElements = ['wildcard', 'bennies', 'fatigue', 'wounds'];
const keptAttributes = ['smarts', 'spirit']
for (const elem of actorElements) {
data.actor[`data.${elem}`] = assignedActor.data.data[elem];
}
data.actor['name'] = name;
data.token['name'] = name;
for (const attr of keptAttributes) {
let attrData = assignedActor.data.data.attributes[attr];
data.actor[`data.attributes.${attr}`] = attrData;
let skills = assignedActor.items.filter(
i => i.type === 'skill' && i.data.data.attribute === attr)
for(const skill of skills) {
data.embedded['Item'][skill.name] = skill.data;
}
}
const otherItems = assignedActor.items.filter(
i => i.type === 'edge' || i.type === 'hindrance')
for(const item of otherItems) {
data.embedded['Item'][item.name] = item.data;
}
return data;