Skip to content

Commit

Permalink
21 enhancement monkeypatch for midiqoldfreds incompatibility for reac…
Browse files Browse the repository at this point in the history
…tionsbonus action in midiqol 114401 11442 (#22)

v1.2.1
  • Loading branch information
thatlonelybugbear authored Jul 21, 2024
1 parent 4500280 commit 599e534
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v1.2.1
- Monkeypatch adding back `reaction` and `bonusaction` status effects when DFreds CE is set to REPLACE and MidiQOL verions higher than 11.4.40.1, until the release that fixes this.

## v1.2.0
- Compatibility bump for Foundry v12.329 and d&d 5e v3.3.0

Expand Down
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "bugs",
"title": "Bugbear's Scripts",
"description": "A small module for Foundry and Dnd5e which contains scripts thislonelybugbear finds useful.",
"version": "1.2.0",
"version": "1.2.1",
"authors": [
{
"name": "thatlonelybugbear",
Expand Down Expand Up @@ -59,6 +59,6 @@
"url": "https://github.com/thatlonelybugbear/bugs",
"license": "https://raw.githubusercontent.com/thatlonelybugbear/bugs/main/LICENSE",
"manifest": "https://github.com/thatlonelybugbear/bugs/releases/latest/download/module.json",
"download": "https://github.com/thatlonelybugbear/bugs/releases/download/v1.2.0/module.zip",
"download": "https://github.com/thatlonelybugbear/bugs/releases/download/v1.2.1/module.zip",
"changelog": "https://raw.githubusercontent.com/thatlonelybugbear/bugs/main/Changelog.md"
}
26 changes: 26 additions & 0 deletions scripts/bugs-main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,32 @@ function gameVersion (ver) {
return ver ? game.version == ver : game.version
}

//Monkeypatch, adding back the MidiQOL reaction/bonus action when DFreds is set to REPLACE.
Hooks.on('dfreds-convenient-effects.ready', () => {
if (game.settings.get('dfreds-convenient-effects','modifyStatusEffects') !== 'replace') return true;
const midiVersion = game.modules.get('midi-qol')?.version;
if (!midiVersion || midiVersion <= '11.4.40.1' || midiVersion > '11.4.42') return true;
console.warn('World script fix for MidiQOL reactions, midiVersion:' midiVersion);
const imgSource = game.version < 12 ? 'icon' : 'img';
const i18n = (string) => game.i18n.localize(string);
CONFIG.statusEffects.push({
id: 'reaction',
_id: staticID('reaction'),
name: i18n('midi-qol.reactionUsed'),
changes: [{ key: 'flags.midi-qol.actions.reaction', mode: CONST.ACTIVE_EFFECT_MODES.ADD, value: true }],
[imgSource]: 'modules/midi-qol/icons/reaction.svg',
flags: { dae: { specialDuration: ['turnStart', 'combatEnd', 'shortRest'] } },
});
CONFIG.statusEffects.push({
id: 'bonusaction',
_id: staticID('bonusaction'),
name: i18n('midi-qol.bonusActionUsed'),
changes: [{ key: 'flags.midi-qol.actions.bonus', mode: CONST.ACTIVE_EFFECT_MODES.ADD, value: true }],
[imgSource]: 'modules/midi-qol/icons/bonus-action.svg',
flags: { dae: { specialDuration: ['turnStart', 'combatEnd', 'shortRest'] } },
});
});

Hooks.once('midi-qol.ready', () => {
Hooks.on('preUpdateActiveEffect', (ae, updates) => {
if (shouldProceed(updates, 'update')) {
Expand Down

0 comments on commit 599e534

Please sign in to comment.