diff --git a/lethal-fantasy.mjs b/lethal-fantasy.mjs index c02accd..fe45fbf 100644 --- a/lethal-fantasy.mjs +++ b/lethal-fantasy.mjs @@ -262,6 +262,7 @@ Hooks.on("renderChatMessageHTML", (message, html, data) => { const isRangedAttack = (rollTargetOptions?.attackMode === "ranged") || (attacker?.type === "monster" && attacker.system.attackMode === "ranged") || (attackerWeapon?.system?.weaponType === "ranged") + || (rollTargetOptions?.isRangedAttack === true) const defenseMsg = { type: "requestDefense", @@ -403,6 +404,7 @@ Hooks.on("renderChatMessageHTML", (message, html, data) => { } roll.options.diceResults = diceResults roll.options.rollTotal = roll.total + if (game?.dice3d) await game.dice3d.showForRoll(roll, game.user, true) await roll.toMessage() return } diff --git a/module/applications/sheets/character-sheet.mjs b/module/applications/sheets/character-sheet.mjs index 5af6826..70d66f6 100644 --- a/module/applications/sheets/character-sheet.mjs +++ b/module/applications/sheets/character-sheet.mjs @@ -296,6 +296,7 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet } roll.options.diceResults = diceResults roll.options.rollTotal = roll.total + if (game?.dice3d) await game.dice3d.showForRoll(roll, game.user, true) await roll.toMessage() } diff --git a/module/documents/actor.mjs b/module/documents/actor.mjs index 3123a67..2355b09 100644 --- a/module/documents/actor.mjs +++ b/module/documents/actor.mjs @@ -261,7 +261,8 @@ export default class LethalFantasyActor extends Actor { weapon: weapon, weaponSkillModifier: skill.weaponSkillModifier, rollKey: rollKey, - combat: foundry.utils.duplicate(this.system.combat) + combat: foundry.utils.duplicate(this.system.combat), + isRangedAttack: weapon.system.weaponType === "ranged" } if (rollType === "weapon-damage-small" || rollType === "weapon-damage-medium") { rollTarget.grantedDice = this.system.granted.damageDice diff --git a/module/documents/d30-roll.mjs b/module/documents/d30-roll.mjs index 950dc89..501dcf0 100644 --- a/module/documents/d30-roll.mjs +++ b/module/documents/d30-roll.mjs @@ -111,17 +111,16 @@ export default class D30Roll { if (externalType === "weapon-attack") { if (!weapon) { console.warn("D30Roll | Weapon object required for weapon-attack type") - return this.ROLL_TYPES.MELEE_ATTACK // Default to melee + // Fall through to use options.isRanged if available, otherwise default melee } - return weapon.system?.weaponType === "ranged" + return (options.isRanged || weapon?.system?.weaponType === "ranged") ? this.ROLL_TYPES.RANGED_ATTACK : this.ROLL_TYPES.MELEE_ATTACK } - // Monster attacks - default to melee + // Monster attacks - check options.isRanged (set from rollTarget.attackMode) or weapon type if (externalType === "monster-attack") { - // Check if weapon object has range information - if (weapon?.system?.weaponType === "ranged") { + if (options.isRanged || weapon?.system?.weaponType === "ranged") { return this.ROLL_TYPES.RANGED_ATTACK } return this.ROLL_TYPES.MELEE_ATTACK diff --git a/module/documents/roll.mjs b/module/documents/roll.mjs index 1fa827c..f08ae29 100644 --- a/module/documents/roll.mjs +++ b/module/documents/roll.mjs @@ -237,6 +237,7 @@ export default class LethalFantasyRoll extends Roll { baseFormula = "D20" hasModifier = true hasChangeDice = false + hasFavor = true options.rollTarget.value = options.rollTarget.actorModifiers.levelSpellModifier + options.rollTarget.actorModifiers.intSpellModifier options.rollTarget.charModifier = options.rollTarget.actorModifiers.intSpellModifier hasStaticModifier = options.rollType === "spell-power" @@ -253,6 +254,7 @@ export default class LethalFantasyRoll extends Roll { dice = "1D20" baseFormula = "D20" hasChangeDice = false + hasFavor = true options.rollTarget.value = options.rollTarget.actorModifiers.levelMiracleModifier + options.rollTarget.actorModifiers.chaMiracleModifier options.rollTarget.charModifier = options.rollTarget.actorModifiers.chaMiracleModifier hasStaticModifier = options.rollType === "miracle-power" @@ -592,12 +594,17 @@ export default class LethalFantasyRoll extends Roll { } options.D30result = rollD30.total - // Récupérer le message D30 correspondant + // Compute isRanged for D30: covers defense (isRangedDefense), monster ranged attacks (attackMode), + // and PC weapon attacks (isRangedAttack or weaponType) + const isRangedForD30 = options.isRangedDefense + || options.rollTarget?.attackMode === "ranged" + || options.rollTarget?.isRangedAttack === true + || options.rollTarget?.weapon?.system?.weaponType === "ranged" const d30Message = D30Roll.getResult( rollD30.total, options.rollType, options.rollTarget?.weapon, - { isRanged: options.isRangedDefense } + { isRanged: isRangedForD30 } ) options.D30message = d30Message } @@ -980,7 +987,7 @@ export default class LethalFantasyRoll extends Roll { } // Range weapon loading if (!currentAction.weaponLoaded && currentAction.rangedLoad) { - if (currentAction.progressionCount <= currentAction.rangedLoad) { + if (currentAction.progressionCount < currentAction.rangedLoad) { let message = `Ranged weapon ${currentAction.name} is loading, loading count : ${currentAction.progressionCount}/${currentAction.rangedLoad}` ChatMessage.create({ content: message, speaker: ChatMessage.getSpeaker({ actor: combatant.actor }) }) currentAction.progressionCount += 1