diff --git a/README.md b/README.md new file mode 100644 index 0000000..9c8b1fc --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# Immersive Crits for Daggerheart + +Enhance your Daggerheart games on FoundryVTT with immersive, fantasy-themed animations for critical hits! + +This module adds visually stunning effects to chat cardswhen a player or GM rolls a crit. +## Features + +- **Fantasy Themes**: Choose from a variety of animations to match your campaign's tone: + - **Embers**: Warm, drifting particles that float upwards like a campfire in the wind. Randomized speed, size, and drift. + - **Pulse**: A customizable glowing pulse effect. Choose any color to match your specific magic or mood. + - **Holy**: A slow, majestic golden burst of divine energy. + - **Necrotic**: Eerie green fumes that rise seamlessly from the darkness. + - **Arcane**: Mystical purple energy surges. + - **Nature**: Gentle leaves falling in the breeze. +- **Individual Customization**: + - **Pulse Color**: When the "Pulse" theme is active, use the color picker to set the perfect hue. +- **DiceSoNice Integration**: Automatically triggers special 3D dice effects on critical hits (fully configurable). + +## Installation + +1. Open FoundryVTT and go to the **Add-on Modules** tab. +2. Click **Install Module**. +3. In the "Manifest URL" field, paste the following link: + `https://github.com/cptn-cosmo/dh-immersive-crits/releases/latest/download/module.json` +4. Click **Install**. + +## Configuration + +Go to **Game Settings** -> **Configure Settings** -> **Module Settings** -> **Immersive Crits for Daggerheart**. + +- **Critical Hit Animation**: Select your preferred visual theme (None, Embers, Pulse, Arcane, Holy, Necrotic, Nature). +- **Pulse Color**: (Visible only when "Pulse" is selected) Choose the color for the pulse animation. +- **DiceSoNice Critical Effect**: Select a special effect for 3D dice rolls (Fire, Ice, Lightning, etc.). + +## Compatibility + +- **FoundryVTT**: v13+ +- **System**: Daggerheart + +## Credits + +Created by **CPTN Cosmo**. +Project URL: [GitHub](https://github.com/cptn-cosmo/dh-immersive-crits) diff --git a/scripts/module.js b/scripts/module.js index d42fe21..b9569f6 100644 --- a/scripts/module.js +++ b/scripts/module.js @@ -178,17 +178,37 @@ Hooks.on('renderChatMessage', (message, html, data) => { } }); +// Hook into DiceSoNice to trigger effects // Hook into DiceSoNice to trigger effects Hooks.on('diceSoNiceRollStart', (messageId, context) => { + // console.log('DSN Hook Fired', messageId, context); const roll = context.roll; + if (!roll) return; if (isCriticalHit(roll)) { + // console.log('DSN: Critical Hit Detected'); const effect = game.settings.get('dh-immersive-crits', 'dsnCritEffect'); + // console.log('DSN Effect:', effect); if (effect && effect !== 'none') { - roll.dice.forEach(die => { - if (!die.options) die.options = {}; - die.options.specialEffect = effect === 'default' ? 'Stars' : capitalize(effect); - }); + // Check if roll.dice exists and has elements + if (roll.dice && roll.dice.length > 0) { + roll.dice.forEach(die => { + if (!die.options) die.options = {}; + die.options.specialEffect = effect === 'default' ? 'Stars' : capitalize(effect); + // console.log('Applied effect to die:', die); + }); + } else { + // Determine if we need to iterate terms for Duality Rolls + // console.log('No roll.dice found. Checking terms:', roll.terms); + if (roll.terms) { + roll.terms.forEach(term => { + if (term.faces) { // It's a die + if (!term.options) term.options = {}; + term.options.specialEffect = effect === 'default' ? 'Stars' : capitalize(effect); + } + }); + } + } } } });