Add VAE helper buttons for bound/entangled

This commit is contained in:
Mike Bloy 2024-05-19 19:43:55 -05:00
parent 6a7dd696ca
commit 909457d1dd
4 changed files with 25 additions and 2 deletions

View File

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Optional Visual Active Effect integration for power descriptions
- Add VAE helper buttons for breaking free from Bound/Entangled
### Changed

View File

@ -158,3 +158,24 @@ export async function deleteActiveEffectsFromToken(sceneId, tokenId, effectIds)
const token = scene.tokens.get(tokenId);
await token.actor.deleteEmbeddedDocuments('ActiveEffect', effectIds);
}
export function SwadeVAEbuttons(effect, buttons) {
if (['Bound', 'Entangled'].includes(effect?.name)) {
buttons.push({
label: 'Break Free (Athletics)',
callback: function () {
const skillId = effect.parent.items.find((i) => i.type === 'skill' && i.system.swid === 'athletics')?.id;
effect.parent.rollSkill(skillId, { flavor: 'Breaking Free' });
},
});
buttons.push({
label: 'Break Free (Strength -2)',
callback: function () {
effect.parent.rollAttribute('strength', {
flavor: 'Breaking Free',
additionalMods: [{ label: 'Breaking Free with Strength', value: -2 }],
});
},
});
}
}

View File

@ -92,7 +92,7 @@ export function visualActiveEffectPowerButtons(effect, buttons) {
flavor: button?.flavor ?? `${effect.name} ${rollDesc} roll`,
};
if (button?.mods) {
options.mods = button.mods;
options.additionalMods = button.mods;
}
effect.parent[rollFunc](rollId, options);
};

View File

@ -4,7 +4,7 @@ import { registerSettings } from './settings.js';
import { preloadTemplates } from './preloadTemplates.js';
import { api } from './api.js';
import { initVisionModes } from './visionModes.js';
import { requestTokenRoll, addActiveEffectsToToken, deleteActiveEffectsFromToken } from './helpers.js';
import { requestTokenRoll, addActiveEffectsToToken, deleteActiveEffectsFromToken, SwadeVAEbuttons } from './helpers.js';
import { preDamageRollModifiers, preTraitRollModifiers } from './rollHelpers.js';
import { log, moduleHelpers } from './globals.js';
import { powerEffectManagementHook, visualActiveEffectPowerButtons } from './powers/powers.js';
@ -45,6 +45,7 @@ Hooks.on('swadePreRollSkill', preTraitRollModifiers);
Hooks.on('swadeRollDamage', preDamageRollModifiers);
Hooks.on('deleteActiveEffect', powerEffectManagementHook);
Hooks.on('visual-active-effects.createEffectButtons', visualActiveEffectPowerButtons);
Hooks.on('visual-active-effects.createEffectButtons', SwadeVAEbuttons);
Hooks.once('socketlib.ready', () => {
const _socket = socketlib.registerModule('swade-mb-helpers');