From b9538ad721e9b1fcfbd8202cd8b8727e8bfaafd4 Mon Sep 17 00:00:00 2001 From: Zhell <50169243+krbz999@users.noreply.github.com> Date: Sun, 15 Dec 2024 16:02:48 +0100 Subject: [PATCH] Create divine-smite.js --- dnd5e_spells/divine-smite.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 dnd5e_spells/divine-smite.js diff --git a/dnd5e_spells/divine-smite.js b/dnd5e_spells/divine-smite.js new file mode 100644 index 0000000..9f63ae8 --- /dev/null +++ b/dnd5e_spells/divine-smite.js @@ -0,0 +1,20 @@ +/** + * Use a weapon and roll attack, then optionally use Divine Smite. The damage of + * the spell will be configured depending on the activity but not rolled, instead + * it will be added on top of the weapon's damage roll. + * This macro assumes the use of the Divine Smite spell from the 24 PHB but is + * likely to work with similar setups. + */ + +const weapon = actor.items.get(""); +const smite = actor.items.get(""); + +/* ------------------------------------------------------- */ + +const weaponUse = await weapon.use({legacy: false}); +if (!weaponUse) return; +const smiteUse = await smite.use({legacy: false, subsequentActions: false}); +if (!smiteUse) return; +const {scaling, activity: {id: activityId}} = smiteUse.message.flags.dnd5e; +const config = smite.clone({"flags.dnd5e.scaling": scaling}, {keepId: true}).system.activities.get(activityId).getDamageConfig(); +return weapon.system.activities.get(weaponUse.message.flags.dnd5e.activity.id).rollDamage({rolls: config.rolls});