Nik's Retroactive Advantage
This module is a fork of foundryvtt-retroactive-advantage-5e by Andrew Krigline (ElfFriend-DnD), later maintained by Zhell (krbz999). Huge thanks to both for their foundational work — this module would not exist without them.
This module allows a user to retroactively change a d20 roll's advantage status directly from the chat card, without affecting any other module logic based on the original roll.

Features
- Adds Advantage, Normal, and Disadvantage buttons to any d20 roll chat card
- The current mode is highlighted (disabled button), making the active state immediately clear
- As much as possible, previously rolled dice are reused — only a new die is rolled when strictly necessary (e.g., moving from Normal to Advantage)
- Works with standard attack rolls, ability checks, saving throws, and any other d20 rolls handled by the dnd5e system
- Hover-only mode (optional): buttons can be configured to appear only when hovering over a message, reducing visual clutter
Actor Special Trait Support
- ✅ Halfling Luck
- ✅ Reliable Talent
- ✅ Elven Accuracy (requires actor to have the trait and the roll to use DEX/INT/WIS/CHA)
Settings
| Setting | Scope | Default | Description |
|---|---|---|---|
| Show Buttons on Hover | User | Off | When enabled, the advantage/disadvantage buttons are hidden until you hover over a chat message |
Changes & Improvements Over the Original
The following changes have been made in this fork relative to the krbz999 maintained version:
Foundry V13 / V14 Compatibility
- Updated the module manifest (
module.json) to declare compatibility with Foundry VTT V13 and V14 ("minimum": "13","verified": "14") - Uses the modern
dnd5e.renderChatMessagehook (introduced in dnd5e 3.x+), which is the correct V13/V14 lifecycle hook for injecting chat card UI - Replaced legacy advantage modifier injection with a call to
configureModifiers()on the newD20Rollinstance, deferring advantage/disadvantage setup entirely to the system. A safe fallback is still included for older system versions
Roll Logic Improvements
- Cleaner base formula generation: The d20 term is now reconstructed as a pristine
1d20before re-applying system modifiers, preventing stalekh/klmodifiers from accumulating across repeated button presses - Backup roll management: The module intelligently decides what to save as the backup roll — if the new roll has more dice than the original (e.g., adding a second d20 for advantage), the richer roll is saved as the backup to preserve all results for future mode switches
- Correct dice result restoration: Historic die results are restored from the baseline roll, and modifier re-evaluation (
_evaluateModifiers()) is called to correctly activate/discard dice according to the new mode
Elven Accuracy Support
- Retroactive advantage now fully supports Elven Accuracy — when switching to Advantage, the module checks whether the roll's actor has the trait enabled (
actor.system.traits.elvenAccuracy) and whether the roll targets an eligible ability (DEX, INT, WIS, or CHA) - When EA applies,
configureModifiers()is called withelvenAccuracy: true, which causes the dnd5e system to natively apply theadv2modifier — rolling 3d20kh1 instead of 2d20kh1 - If the original roll was already flagged with
elvenAccuracy: true(i.e. it was an EA roll from the start), that flag is honoured directly without re-checking the actor - When switching away from an EA advantage roll (e.g. to Disadvantage or Normal), the 3-die result set is trimmed to the correct count (2 for dis/adv, 1 for normal) before modifier re-evaluation, preventing incorrect totals
- If the actor cannot be resolved from the message speaker (e.g. unlinked token, no speaker), EA detection gracefully falls back to
falseand normal advantage is applied instead
Dice So Nice Integration
- When a new die needs to be rolled (e.g., upgrading a Normal roll to Advantage), Dice So Nice is invoked to animate only the newly introduced die — not the full roll — for a natural visual result
- The DSN filter correctly handles EA rolls: when 2 new dice are rolled (Normal → EA advantage), both are animated; when 1 new die is added (Advantage → EA advantage), only that die animates
Hover-Only Button Mode
- Added a per-user module setting (
showOnHover) that, when enabled, applies ahover-onlyCSS class to the button menu - The CSS smoothly transitions buttons in and out using
opacityandmax-heightwith a0.15s easetransition, avoiding layout jumps
CSS Improvements
- Button styling uses dnd5e design tokens (
--dnd5e-color-hd-1,--dnd5e-color-hd-2) for the active/disabled state, blending naturally with the system's UI - Buttons use nested CSS (modern syntax) for clean, maintainable styling
- The button menu correctly inserts inside
.dnd5e2.chat-cardcontainers (system chat cards), with a fallback insertion before.dice-rollfor other d20 roll messages
Compatibility
| Software | Version |
|---|---|
| Foundry VTT | V13–V14 |
| dnd5e system | 4.2.2+ (5.x recommended) |
License
This module is released under the MIT License, in accordance with the original module's licensing terms.
Original copyright © 2022 Andrew Krigline (ElfFriend-DnD). See LICENSE for the full license text.
Credits
- Original author: Andrew Krigline (ElfFriend-DnD) — creator of the original module
- Previous maintainer: Zhell (krbz999) — maintained the module through V11/V12 with significant refactors
- This fork: Nik (nschoenwald) — V13/V14 compatibility, UI improvements, and ongoing maintenance