Skip to content

Commit

Permalink
Fix up midi setting defaults for effect generation
Browse files Browse the repository at this point in the history
  • Loading branch information
MrPrimate committed Jan 13, 2024
1 parent 45e5ee4 commit 7bf749d
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# NEXT UP

- If generating effects the MidiQoL Confirm Targets and Remove Chat card button settings will be set to "Midi Settings".

# 3.7.13

- Featues which should be weapon attacks such as the Soul Knifes blades were coming in as Other features rather than weapons.
Expand Down
9 changes: 9 additions & 0 deletions src/effects/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,15 @@ export function getMidiCEOnFlags(midiFlags = {}) {
return midiFlags;
}

export function applyDefaultMidiFlags(document) {
setProperty(document, "flags.midi-qol.removeAttackDamageButtons", "default");
setProperty(document, "flags.midiProperties.confirmTargets", "default");
return document;
}

export function forceItemEffect(document) {
if (document.effects.length > 0 || hasProperty(document.flags, "dae") || hasProperty(document.flags, "midi-qol.onUseMacroName")) {
document = applyDefaultMidiFlags(document);
setProperty(document, "flags.ddbimporter.effectsApplied", true);
setProperty(document, "flags.midi-qol.forceCEOff", true);
}
Expand Down Expand Up @@ -1539,6 +1546,8 @@ function addACEffect(ddb, character, ddbItem, foundryItem, isCompendiumItem, eff
}

export function generateEffects(ddb, character, ddbItem, foundryItem, isCompendiumItem, type) {
// set flags if using effects
foundryItem = applyDefaultMidiFlags(foundryItem);
let label;

if (type === "item" && hasProperty(ddbItem, "definition.grantedModifiers")) {
Expand Down
4 changes: 2 additions & 2 deletions src/effects/feats/maneuvers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { baseFeatEffect } from "../specialFeats.js";
import { generateStatusEffectChange } from "../effects.js";
import { forceManualReaction, generateStatusEffectChange } from "../effects.js";
import DDBMacros from "../DDBMacros.js";
import logger from "../../logger.js";

Expand Down Expand Up @@ -112,7 +112,7 @@ export async function maneuversEffect(ddb, character, document) {
case "Maneuvers: Riposte":
case "Maneuvers: Brace": {
// manual reaction types
setProperty(document, "system.activation.type", "reactionmanual");
document = forceManualReaction(document);
effect.changes.push(damageEffect);
document.effects.push(effect);
break;
Expand Down
1 change: 0 additions & 1 deletion src/effects/feats/ragingStormSea.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export async function ragingStormSeaEffect(document) {
const effect = baseFeatEffect(document, document.name);
effect.changes.push(generateStatusEffectChange("Convenient Effect: Prone", 20, true));
document.effects.push(effect);
// setProperty(document, "system.activation.type", "reactionmanual");

const evaluationEffect = baseFeatEffect(document, `${document.name} (Trigger Checker)`, { transfer: true });

Expand Down
10 changes: 3 additions & 7 deletions src/effects/feats/sharpShooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,12 @@ export function sharpShooterEffect(document) {
const midiFlags = {
"effectActivation": false,
"forceCEOff": false,
"forceCEOn": true
"forceCEOn": true,
"removeAttackDamageButtons": "default",
};

setProperty(document, "flags.midi-qol", midiFlags);

const midiProperties = {
"toggleEffect": true,
};

setProperty(document, "flags.midiProperties", midiProperties);
setProperty(document, "flags.midiProperties.toggleEffect", true);

return document;
}
2 changes: 2 additions & 0 deletions src/effects/specialEquipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
generateCustomChange,
forceItemEffect,
effectModules,
applyDefaultMidiFlags,
} from "./effects.js";
// load item effects
import { bootsOfSpeedEffect } from "./items/bootsOfSpeed.js";
Expand All @@ -18,6 +19,7 @@ import { hasteEffect } from "./spells/haste.js";

export async function midiItemEffects(document) {
if (!effectModules().hasCore) return document;
document = applyDefaultMidiFlags(document);
const name = document.flags.ddbimporter?.originalName || document.name;
switch (name) {
case "Cloak of Displacement": {
Expand Down
5 changes: 3 additions & 2 deletions src/effects/specialFeats.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { baseEffect, effectModules, forceItemEffect, forceManualReaction } from "./effects.js";
import { applyDefaultMidiFlags, baseEffect, effectModules, forceItemEffect, forceManualReaction } from "./effects.js";

// effect loads
import { alertEffect } from "./feats/alert.js";
Expand Down Expand Up @@ -160,6 +160,7 @@ export async function featureEffectAdjustment(ddb, character, document) {
}

if (deps.daeInstalled && deps.midiQolInstalled) {
document = applyDefaultMidiFlags(document);
switch (name) {
case "Arcane Recovery": {
document = await arcaneRecoveryEffect(document);
Expand Down Expand Up @@ -227,7 +228,7 @@ export async function featureEffectAdjustment(ddb, character, document) {
break;
}
case "Glide (Reaction)": {
setProperty(document, "system.activation.type", "reactionmanual");
document = forceManualReaction(document);
break;
}
case "Hadozee Dodge": {
Expand Down
3 changes: 2 additions & 1 deletion src/effects/specialMonsters.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-await-in-loop */
/* eslint-disable require-atomic-updates */
import { baseEffect, effectModules, forceItemEffect, generateStatusEffectChange } from "./effects.js";
import { applyDefaultMidiFlags, baseEffect, effectModules, forceItemEffect, generateStatusEffectChange } from "./effects.js";
import { uncannyDodgeEffect } from "./feats/uncannyDodge.js";

import { absorptionEffect } from "./monsterFeatures/absorbtion.js";
Expand Down Expand Up @@ -66,6 +66,7 @@ export async function monsterFeatureEffectAdjustment(ddbMonster) {

// damage over time effects
for (let [index, item] of npc.items.entries()) {
item = applyDefaultMidiFlags(item);
// Legendary Resistance Effects
if (item.name.startsWith("Legendary Resistance")) item = generateLegendaryEffect(item);
else if (item.name.startsWith("Pack Tactics")) item = generatePackTacticsEffect(item);
Expand Down
3 changes: 3 additions & 0 deletions src/effects/specialSpells.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
effectModules,
forceManualReaction,
baseEffect,
applyDefaultMidiFlags,
} from "./effects.js";

// spell effects load start
Expand Down Expand Up @@ -165,6 +166,8 @@ export async function spellEffectAdjustment(document) {
return document;
}

document = applyDefaultMidiFlags(document);

const name = document.flags.ddbimporter?.originalName ?? document.name;
logger.debug(`Adding effects to ${name}`);
switch (name) {
Expand Down
4 changes: 4 additions & 0 deletions src/parser/spells/parseSpell.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ export async function parseSpell(data, character) {
tags: data.definition.tags,
version: CONFIG.DDBI.version,
},
"midi-qol": {
removeAttackDamageButtons: "default",
},
midiProperties: {
confirmTargets: "default",
magicdam: true,
magiceffect: true,
},
Expand Down

0 comments on commit 7bf749d

Please sign in to comment.