PwQt/magic-items-2

Midi QoL effect application compatibility

Closed this issue · 1 comments

It seems that magic items does it's own effect application when casting spells/using features - however that application does not work with dnd5e/midi concentration and applies to the selected tokens not the targeted tokens.

Midi has functionality to auto apply effects, but a side effect of magic items is that it removes effects from the item when used.
I suggest the following to allow midi to apply effects when appropriate and take over in other cases.

  static isApplyItemEffectsMidiQolWorkflowOn() {
    // Test if midi is going to apply effects itself.
    return game.modules.get("midi-qol")?.active && game.settings.get("midi-qol", "ConfigSettings")?.autoItemEffects !== "off";
  }

And where the item is cloned I suggest

      if (spell.effects?.size > 0 && !MagicItemHelpers.isApplyItemEffectsMidiQolWorkflowOn()) {
        spell = spell.clone({ effects: {} }, { keepId: true });
         spell.prepareFinalAttributes();
      }

and

      if (this.ownedItem.effects?.size > 0 && !MagicItemHelpers.isApplyItemEffectsMidiQolWorkflowOn()) {
        this.activeEffectMessage(async () => {
          await this.applyActiveEffects(this.ownedItem);
         }) ;
      }

And at other places that isApplyConvenientEffectsMidiQolWorkflowOn is referenced.

I've tested these changes for spells, but not other items and they seem to work

PwQt commented

I have attempted something similar,

  static isApplyConvenientEffectsMidiQolWorkflowOn() {
    return (
      game.modules.get("midi-qol")?.active &&
      game.modules.get("dfreds-convenient-effects")?.active &&
      game.settings.get("midi-qol", "ConfigSettings")?.autoCEEffects !== "none"
    );
  }

but I didn't know about that setting, thanks, I'll test that during this week and if it's working then merge it.