|
{"name":"cure-wounds-callback","type":"script","scope":"global","author":"UmNkeoffjKCw89ui","img":"icons/magic/life/heart-cross-green.webp","command":"if (!game.modules.get(\"advanced-macros\")?.active) {\n ui.notifications.error(`This macro requires the \"Advanced Macros\" module to function!`);\n return;\n}\n\nif (!args.length) {\n ui.notifications.error(`This macro isn't called from the hotbar or executed from the window, it's executed by Item Piles as a part of buying the \"Cure Wounds\" service!`);\n return;\n}\n\nconst { buyer, seller, item, quantity } = args[0];\n\nconst sellerSpellCastingAttr = seller.system.attributes?.spellcasting || \"wis\";\nconst sellerSpellCastingBonus = seller.system.abilities[sellerSpellCastingAttr]?.mod || 0;\n\nconst healingRoll = new Roll(`${quantity}d8 + @mod`, { mod: sellerSpellCastingBonus }).evaluate({ async: false });\n\nconst buyerNewHealth = Math.min(buyer.system.attributes.hp.max, buyer.system.attributes.hp.value + healingRoll.total);\n\nawait buyer.update({\n \"system.attributes.hp.value\": buyerNewHealth\n});\n\nawait healingRoll.toMessage({\n flavor: `${seller.name} heals ${buyer.name}`\n});","flags":{"advanced-macros":{"runAsGM":false},"core":{"sourceId":"Macro.OgleD80MtKbPnSfb"}},"_stats":{"systemId":"dnd5e","systemVersion":"2.0.3","coreVersion":"10.286","createdTime":1665165283922,"modifiedTime":1665166351196,"lastModifiedBy":"UmNkeoffjKCw89ui"},"folder":null,"sort":0,"ownership":{"default":0,"UmNkeoffjKCw89ui":3},"_id":"DbtjC1s6QfGNHxKP"}
|