From f925171509f556d71583bfaa88ff6cb466be300a Mon Sep 17 00:00:00 2001 From: Gambit Date: Tue, 15 Oct 2024 10:55:41 -0400 Subject: [PATCH] 0.5.63 --- .github/workflows/main.yml | 5 +---- scripts/helpers.js | 9 +++++++-- scripts/macros/counterspell.js | 15 ++++++++++----- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7c9800d..688d8c0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,11 +18,8 @@ jobs: - name: Set Release Notes for Github id: set-release-notes-github run: | - echo "- Updates:" >> release_notes.txt - echo " - Counterspell: Added animation, if cpr installed can also be enabled/disabled via the medkit" >> release_notes.txt - echo " - Silvery Barbs: Added animation, if cpr installed can also be enabled/disabled via the medkit" >> release_notes.txt echo "- Bugfixes:" >> release_notes.txt - echo " - Counterspell: Resolve issue with socketed rolls not accounting for the cast level correctly" >> release_notes.txt + echo " - Counterspell: Couple fixes for last update" >> release_notes.txt echo "release-notes-github<> $GITHUB_ENV cat release_notes.txt >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV diff --git a/scripts/helpers.js b/scripts/helpers.js index 508b161..3e6c21e 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -1121,7 +1121,12 @@ export async function remoteAbilityTest({spellcasting, actorUuid}) { let actor = await fromUuid(actorUuid) - let skillCheck = await actor.rollAbilityTest(spellcasting) + let rollId; + Hooks.once("createChatMessage", async (chatMessage, options, userId) => { + rollId = chatMessage.id; + }); + + await actor.rollAbilityTest(spellcasting); - return {skillRoll: skillCheck}; + return {skillRoll: rollId}; } \ No newline at end of file diff --git a/scripts/macros/counterspell.js b/scripts/macros/counterspell.js index 80beaf2..c9eb970 100644 --- a/scripts/macros/counterspell.js +++ b/scripts/macros/counterspell.js @@ -29,6 +29,7 @@ export async function counterspell({ workflowData,workflowType,workflowCombat }) let csFailure = false; let chatContent = []; let skillCheck; + let skillRoll; let browserUser; await initialCounterspellProcess(workflow, lastMessage, castLevel, selectedToken); @@ -144,7 +145,10 @@ export async function counterspell({ workflowData,workflowType,workflowCombat }) if(itemRollCastLevel < castLevel) { if(source && source === "user") skillCheck = await socket.executeAsUser("remoteAbilityTest", browserUser, { spellcasting: validTokenPrimary.actor.system.attributes.spellcasting, actorUuid: validTokenPrimary.actor.uuid }); if(source && source === "gm") skillCheck = await socket.executeAsUser("remoteAbilityTest", gmUser, { spellcasting: validTokenPrimary.actor.system.attributes.spellcasting, actorUuid: validTokenPrimary.actor.uuid }); - let { skillTotal = skillCheck.skillRoll.total, skillFlavor = skillCheck.skillRoll.options.flavor } = skillCheck; + skillRoll = game.messages.get(skillCheck.skillRoll)?.rolls[0]; + let skillTotal = skillRoll.total; + let skillFlavor = skillRoll.options.flavor; + let abjurationCheck = validTokenPrimary.actor.items.some(i => i.name.toLowerCase() === "improved abjuration"); abjurationCheck ? skillTotal = skillTotal + validTokenPrimary.actor.system?.attributes?.prof : skillTotal = skillTotal; if (skillTotal >= spellThreshold) { @@ -163,7 +167,7 @@ export async function counterspell({ workflowData,workflowType,workflowCombat }) await helpers.addReaction({actorUuid: `${validTokenPrimary.actor.uuid}`}); - await socket.executeAsUser("replaceChatCard", gmUser, {actorUuid: validTokenPrimary.actor.uuid, itemUuid: chosenSpell.uuid, chatContent: chatContent, rollData: skillCheck.skillRoll}); + await socket.executeAsUser("replaceChatCard", gmUser, {actorUuid: validTokenPrimary.actor.uuid, itemUuid: chosenSpell.uuid, chatContent: chatContent, rollData: skillRoll}); if(csFailure === true) continue; @@ -294,9 +298,10 @@ export async function counterspell({ workflowData,workflowType,workflowCombat }) if(itemRollCastLevel < castLevel) { if(source && source === "user") skillCheck = await socket.executeAsUser("remoteAbilityTest", browserUser, { spellcasting: validTokenSecondary.actor.system.attributes.spellcasting, actorUuid: validTokenSecondary.actor.uuid }); if(source && source === "gm") skillCheck = await socket.executeAsUser("remoteAbilityTest", gmUser, { spellcasting: validTokenSecondary.actor.system.attributes.spellcasting, actorUuid: validTokenSecondary.actor.uuid }); - let { skillTotal = skillCheck.skillRoll.total, skillFlavor = skillCheck.skillRoll.options.flavor } = skillCheck; + skillRoll = game.messages.get(skillCheck.skillRoll)?.rolls[0]; + let skillTotal = skillRoll.total; + let skillFlavor = skillRoll.options.flavor; - skillCheck = await validTokenSecondary.actor.rollAbilityTest(validTokenSecondary.actor.system.attributes.spellcasting); let abjurationCheck = validTokenSecondary.actor.items.some(i => i.name.toLowerCase() === "improved abjuration"); abjurationCheck ? skillTotal = skillTotal + validTokenSecondary.actor.system?.attributes?.prof : skillTotal = skillTotal; if (skillTotal >= spellThreshold) { @@ -315,7 +320,7 @@ export async function counterspell({ workflowData,workflowType,workflowCombat }) await helpers.addReaction({actorUuid: `${validTokenSecondary.actor.uuid}`}); - await socket.executeAsUser("replaceChatCard", gmUser, {actorUuid: validTokenSecondary.actor.uuid, itemUuid: chosenSpell.uuid, chatContent: chatContent, rollData: skillCheck.skillRoll}); + await socket.executeAsUser("replaceChatCard", gmUser, {actorUuid: validTokenSecondary.actor.uuid, itemUuid: chosenSpell.uuid, chatContent: chatContent, rollData: skillRoll}); if(csFailure === true) continue;