From 41da8193ab3b8a890b94cda85ec0fef34aaef44a Mon Sep 17 00:00:00 2001 From: Mike Bloy Date: Mon, 29 Nov 2021 22:52:05 -0600 Subject: [PATCH] attempt at an automated evocations shape change --- AE_Companion_MacroNAMEINPARENS.js | 3 +++ ae_shape_change_form.js | 38 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 AE_Companion_MacroNAMEINPARENS.js create mode 100644 ae_shape_change_form.js diff --git a/AE_Companion_MacroNAMEINPARENS.js b/AE_Companion_MacroNAMEINPARENS.js new file mode 100644 index 0000000..20eb187 --- /dev/null +++ b/AE_Companion_MacroNAMEINPARENS.js @@ -0,0 +1,3 @@ +const macro = game.macros.getName("shapeshift_AE_form"); +let value = await macro.execute(args[0]); +return value; \ No newline at end of file diff --git a/ae_shape_change_form.js b/ae_shape_change_form.js new file mode 100644 index 0000000..07f8b23 --- /dev/null +++ b/ae_shape_change_form.js @@ -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; \ No newline at end of file