diff --git a/lethal-fantasy.mjs b/lethal-fantasy.mjs index a866266..0733b02 100644 --- a/lethal-fantasy.mjs +++ b/lethal-fantasy.mjs @@ -936,7 +936,8 @@ Hooks.on("createChatMessage", async (message) => { d30Bleed: d30Bleed ? "true" : "", d30DamageMultiplier: d30DamageMultiplier, d30DrMultiplier: d30DrMultiplier, - damageTier: damageTier || "standard" + damageTier: damageTier || "standard", + attackD30message }) } else { console.log("Skipping message creation", { attackerHandledBonus, defenderHandledBonus }) diff --git a/module/utils.mjs b/module/utils.mjs index ead9e5d..79a5ac0 100644 --- a/module/utils.mjs +++ b/module/utils.mjs @@ -1074,6 +1074,18 @@ export default class LethalFantasyUtils { /* -------------------------------------------- */ static async compareAttackDefense(data) { console.log("compareAttackDefense called with:", data) + + // Compute D30 effects from the attack D30 message directly. + // This is more reliable than depending on the caller-provided values, which are + // computed per-client and may differ between clients due to cross-client processing order. + const d30DamageMultiplier = data.attackD30message?.type === "damage_multiplier" + ? data.attackD30message.multiplier + : (data.d30DamageMultiplier || 1) + const d30Bleed = data.attackD30message?.type === "combo" + ? (data.attackD30message.effects?.some(e => e.type === "bleed" || e.type === "internal_injury") ? "true" : "") + : data.attackD30message?.type === "bleed" ? "true" : (data.d30Bleed || "") + const d30DrMultiplier = data.d30DrMultiplier || 1 + const outcome = data.outcome || (data.attackRoll > data.defenseRoll ? "hit" : "miss") const isAttackWin = outcome !== "miss" console.log("isAttackWin:", isAttackWin, "attackRoll:", data.attackRoll, "defenseRoll:", data.defenseRoll) @@ -1085,7 +1097,7 @@ export default class LethalFantasyUtils { if (data.attackRollType === "weapon-attack") { damageButton = `
-
@@ -1093,7 +1105,7 @@ export default class LethalFantasyUtils { } else if (data.attackRollType === "monster-attack") { damageButton = `
-
@@ -1118,9 +1130,9 @@ export default class LethalFantasyUtils { data-defender-token-id="${data.defenderTokenId || ""}" data-damage-type="spell" data-damage-formula="${escapedFormula}" - data-d30-bleed="${data.d30Bleed || ""}" - data-d30-damage-mult="${data.d30DamageMultiplier || 1}" - data-d30-dr-mult="${data.d30DrMultiplier || 1}"> + data-d30-bleed="${d30Bleed}" + data-d30-damage-mult="${d30DamageMultiplier}" + data-d30-dr-mult="${d30DrMultiplier}"> ${t.label} (${escapedFormula}) ` }).join("")