Skip to content

Commit

Permalink
Add ally/enemy roll option to damage-taken options (foundryvtt#16646)
Browse files Browse the repository at this point in the history
  • Loading branch information
stwlam authored Sep 23, 2024
1 parent 3d0ff1d commit 990fc77
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/module/chat-message/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ async function applyDamageFromMessage({

for (const token of tokens) {
if (!token.actor) continue;
// Add roll option for ally/enemy status
if (token.actor.alliance && message.actor) {
const allyOrEnemy = token.actor.alliance === message.actor.alliance ? "ally" : "enemy";
messageRollOptions.push(`origin:${allyOrEnemy}`);
}

// If no target was acquired during a roll, set roll options for it during damage application
if (!messageRollOptions.some((o) => o.startsWith("target"))) {
Expand All @@ -113,7 +118,7 @@ async function applyDamageFromMessage({
: [];
const contextClone = token.actor.getContextualClone(originRollOptions, ephemeralEffects);
const rollOptions = new Set([
...messageRollOptions.filter((o) => !/^(?:self|target):/.test(o)),
...messageRollOptions.filter((o) => !/^(?:self|target)(?::|$)/.test(o)),
...effectRollOptions,
...originRollOptions,
...contextClone.getSelfRollOptions(),
Expand Down

0 comments on commit 990fc77

Please sign in to comment.