diff --git a/macros/hinder.js b/macros/hinder.js new file mode 100644 index 0000000..0c1df96 --- /dev/null +++ b/macros/hinder.js @@ -0,0 +1,38 @@ +swadeMBHelpers.runOnTargetOrSelectedTokens(main) + +async function main (tokens) { + const tokenList = tokens.map(t => t.name).join(', ') + const dialogOptions = { + title: 'Hinder', + content: `Apply Hinder to ${tokenList}`, + default: 'cancel', + buttons: [ + { label: 'OK', value: 'ok' }, + { label: 'Cancel', value: 'cancel' } + ] + } + + const choice = await warpgate.buttonDialog(dialogOptions, 'column') + + if (choice === 'ok') { + await createEffect(tokens, choice) + } +} + +async function createEffect (tokens, choice) { + const icon = 'icons/magic/movement/abstract-ribbons-red-orange.webp' + const effectName = 'Hinder' + const changes = [ + { + key: 'system.stats.speed.value', + mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD, + value: -2, + priority: 0 + } + ] + for (const token of tokens) { + const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, changes) + const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName) + await warpgate.mutate(token.document, mutate, {}, mutateOptions) + } +} diff --git a/macros/hurry-hinder.js b/macros/hurry.js similarity index 63% rename from macros/hurry-hinder.js rename to macros/hurry.js index 4c6c863..6c5811f 100644 --- a/macros/hurry-hinder.js +++ b/macros/hurry.js @@ -3,26 +3,25 @@ swadeMBHelpers.runOnTargetOrSelectedTokens(main) async function main (tokens) { const tokenList = tokens.map(t => t.name).join(', ') const dialogOptions = { - title: 'Hurry/Hinder', - content: `Apply Hurry or Hinder to ${tokenList}`, + title: 'Hurry', + content: `Apply Hurry to ${tokenList}`, default: 'cancel', buttons: [ - { label: 'Hurry', value: 'hurry' }, - { label: 'Hinder', value: 'hinder' }, + { label: 'OK', value: 'ok' }, { label: 'Cancel', value: 'cancel' } ] } const choice = await warpgate.buttonDialog(dialogOptions, 'column') - if (choice && choice !== 'cancel') { + if (choice === 'ok') { await createEffect(tokens, choice) } } async function createEffect (tokens, choice) { - let icon = 'icons/skills/movement/feet-winged-boots-blue.webp' - let effectName = 'Hurry' + const icon = 'icons/skills/movement/feet-winged-boots-blue.webp' + const effectName = 'Hurry' const changes = [ { key: 'system.stats.speed.value', @@ -31,13 +30,8 @@ async function createEffect (tokens, choice) { priority: 0 } ] - if (choice === 'hinder') { - changes.value = '-2' - effectName = 'Hinder' - icon = 'icons/magic/movement/abstract-ribbons-red-orange.webp' - } for (const token of tokens) { - const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, []) + const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, changes) const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName) await warpgate.mutate(token.document, mutate, {}, mutateOptions) } diff --git a/packs/effect-macros.db b/packs/effect-macros.db index 4c81ab3..eb52da7 100644 --- a/packs/effect-macros.db +++ b/packs/effect-macros.db @@ -1,8 +1,9 @@ -{"name":"Boost/Lower Trait","type":"script","author":"ueJGUfSYuRRL3Ypr","img":"icons/magic/life/cross-embers-glow-yellow-purple.webp","scope":"global","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n let traitOptions = [\n 'Agility', 'Smarts', 'Spirit', 'Strength', 'Vigor'\n ]\n const allSkills = []\n const traits = {}\n for (const traitName of traitOptions) {\n const lower = traitName.toLowerCase()\n traits[traitName] = {\n name: traitName,\n type: 'attribute',\n modkey: `system.attributes.${lower}.die.modifier`,\n diekey: `system.attributes.${lower}.die.sides`\n }\n }\n\n const tokenList = tokens.map(t => t.name).join(', ')\n for (const token of tokens) {\n const skills = token.actor.items.filter(item => item.type === 'skill')\n for (const skill of skills) {\n const name = skill.name\n traits[name] = {\n type: 'skill',\n name,\n modkey: `@Skill{${name}}[system.die.modifier]`,\n diekey: `@Skill{${name}}[system.die.sides]`\n }\n if (name !== 'Unskilled' && !allSkills.find(v => v === name)) {\n allSkills.push(name)\n }\n }\n }\n traitOptions = traitOptions.concat(allSkills.sort())\n\n const menuOptions = {\n title: 'Boost/Lower Trait',\n defaultButton: 'Cancel',\n options: {}\n }\n const menuData = {\n inputs: [\n { type: 'header', label: 'Boost/Lower Trait' },\n { type: 'info', label: `Affected Tokens ${tokenList}` },\n { type: 'select', label: 'Trait', options: traitOptions },\n { type: 'info', label: 'Boost or Lower?' },\n { type: 'radio', label: 'Boost', options: ['isBoost', true] },\n { type: 'radio', label: 'Lower', options: ['isBoost', false] },\n { type: 'checkbox', label: 'Greater', options: false },\n { type: 'checkbox', label: 'Strong (lower only)', options: false }\n ],\n buttons: [\n { label: 'Apply', value: 'apply' },\n { label: 'Apply with raise', value: 'raise' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)\n if (buttons && buttons !== 'cancel') {\n const options = {\n action: buttons,\n name: inputs[2],\n trait: traits[inputs[2]],\n direction: inputs[4] || inputs[5],\n greater: inputs[6],\n strong: inputs[7]\n }\n createEffect(tokens, options)\n }\n}\n\nconst UPICON = 'icons/magic/life/cross-embers-glow-yellow-purple.webp'\nconst DOWNICON = 'icons/magic/movement/chevrons-down-yellow.webp'\n\nasync function createEffect (tokens, options) {\n const raise = (options.action === 'raise')\n const icon = (options.direction === 'Boost' ? UPICON : DOWNICON)\n let namePart = `${options.direction} ${options.trait.name}`\n const mode = CONST.ACTIVE_EFFECT_MODES.ADD\n const mods = []\n if (options.strong && options.direction === 'Lower') {\n mods.push('strong')\n }\n if (options.greater) {\n mods.push('greater')\n }\n if (mods.length > 0) {\n namePart = `${namePart} (${mods.join(', ')})`\n }\n const minorEffect = swadeMBHelpers.createEffectDocument(\n icon, `minor ${namePart}`, 5, [\n {\n key: options.trait.diekey,\n mode,\n value: (options.direction === 'Boost' ? '+2' : '-2'),\n priority: 0\n }\n ]\n )\n const majorEffect = swadeMBHelpers.createEffectDocument(\n icon, `major ${namePart}`, 5, [\n {\n key: options.trait.diekey,\n mode,\n value: (options.direction === 'Boost' ? '+2' : '-2'),\n priority: 0\n }\n ]\n )\n if (options.direction === 'Lower' && options.greater === 'Greater') {\n minorEffect.changes.push({\n key: options.trait.modkey,\n mode,\n value: '-2',\n priority: 0\n })\n }\n const mutate = {\n embedded: {\n ActiveEffect: {\n }\n }\n }\n mutate.embedded.ActiveEffect[minorEffect.id] = minorEffect\n if (raise) {\n mutate.embedded.ActiveEffect[majorEffect.id] = majorEffect\n }\n const mutateOptions = swadeMBHelpers.defaultMutationOptions(namePart)\n for (const token of tokens) {\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677458254287,"modifiedTime":1677802233982,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"1AqIFHAcX5TRdE8X","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}} -{"name":"Deflection","type":"script","scope":"global","author":"ueJGUfSYuRRL3Ypr","img":"icons/magic/defensive/shield-barrier-deflect-teal.webp","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const dialogOptions = {\n title: 'Deflection',\n content: `Apply Deflection to ${tokenList}`,\n default: 'cancel',\n buttons: [\n { label: 'Apply (melee)', value: 'melee' },\n { label: 'Apply (ranged)', value: 'ranged' },\n { label: 'Apply with raise (both)', value: 'raise' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const choice = await warpgate.buttonDialog(dialogOptions)\n\n if (choice && choice !== 'cancel') {\n await createEffect(tokens, choice)\n }\n}\n\nasync function createEffect (tokens, choice) {\n const icon = 'icons/magic/defensive/shield-barrier-deflect-teal.webp'\n let effectName = 'Deflection'\n if (choice === 'raise') {\n effectName = `${effectName} (all)`\n } else {\n effectName = `${effectName} (${choice})`\n }\n for (const token of tokens) {\n const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, [])\n const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677645552357,"modifiedTime":1677802233982,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"HYTiftQW0pwwOQGH","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}} -{"name":"Glow","type":"script","scope":"global","author":"ueJGUfSYuRRL3Ypr","img":"icons/magic/light/explosion-star-blue-large.webp","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const dialogOptions = {\n title: 'Glow',\n content: `Apply Glow to ${tokenList}`,\n default: 'cancel',\n buttons: [\n { label: 'OK', value: 'ok' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const choice = await warpgate.buttonDialog(dialogOptions)\n\n if (choice === 'ok') {\n await createEffect(tokens)\n }\n}\n\nasync function createEffect (tokens) {\n const icon = 'icons/magic/light/explosion-star-blue-large.webp'\n const effectName = 'Glow'\n for (const token of tokens) {\n const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, [])\n const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)\n mutate.token = {\n light: {\n alpha: 0.5,\n angle: 360,\n attenuation: 0.5,\n animation: {\n intensity: 5,\n reverse: false,\n speed: 5,\n type: 'starlight'\n },\n bright: 0,\n color: '#0f3fff',\n coloration: 1,\n contrast: 0,\n dim: 0.5,\n luminosity: 0.5,\n saturation: 0,\n shadows: 0\n }\n }\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677704975699,"modifiedTime":1677802233982,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"JcZ9kxBZJpw8KLQ6","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}} -{"name":"Shroud","type":"script","scope":"global","author":"ueJGUfSYuRRL3Ypr","img":"icons/magic/perception/silhouette-stealth-shadow.webp","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const dialogOptions = {\n title: 'Shroud',\n content: `Apply Shroud to ${tokenList}`,\n default: 'cancel',\n buttons: [\n { label: 'OK', value: 'ok' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const choice = await warpgate.buttonDialog(dialogOptions)\n\n if (choice === 'ok') {\n await createEffect(tokens)\n }\n}\n\nasync function createEffect (tokens) {\n const icon = 'icons/magic/perception/silhouette-stealth-shadow.webp'\n const effectName = 'Shroud'\n for (const token of tokens) {\n const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, [])\n const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)\n mutate.token = {\n light: {\n alpha: 0.5,\n angle: 360,\n attenuation: 0.1,\n animation: {\n intensity: 5,\n reverse: false,\n speed: 5,\n type: 'roiling'\n },\n bright: 0,\n color: null,\n coloration: 0,\n contrast: 0,\n dim: 0.1,\n luminosity: -0.15,\n saturation: 0,\n shadows: 0.25\n }\n }\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677649631598,"modifiedTime":1677802233982,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"QpillIBvZmuHeuTV","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}} -{"name":"Smite","type":"script","scope":"global","author":"ueJGUfSYuRRL3Ypr","img":"systems/swade/assets/icons/status/status_smite.svg","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const menuOptions = {\n title: 'Smite',\n defaultButton: 'Cancel',\n options: {}\n }\n\n const menuData = {\n inputs: [\n { type: 'header', label: 'Smite' },\n { type: 'info', label: `Apply Smite to ${tokenList}` },\n { type: 'checkbox', label: 'Greater', options: false }\n ],\n buttons: [\n { label: 'Apply', value: 'apply' },\n { label: 'Apply with Raise', value: 'raise' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const tokenWeapons = {}\n let index = 2\n for (const token of tokens) {\n index += 2\n tokenWeapons[token.id] = index\n menuData.inputs.push({ type: 'info', label: `

${token.name}

` })\n const weapons = token.actor.items.filter(i => i.type === 'weapon').map(\n i => { return { value: i.name, html: i.name } })\n weapons.unshift({ value: '', html: 'None' })\n menuData.inputs.push({ type: 'select', label: token.name, options: weapons })\n }\n const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)\n for (const tokenId in tokenWeapons) {\n tokenWeapons[tokenId] = inputs[tokenWeapons[tokenId]]\n }\n const greater = (inputs[2] === 'Greater')\n if (buttons && buttons !== 'cancel') {\n await createEffect(tokens, tokenWeapons, buttons, greater)\n }\n}\n\nasync function createEffect (tokens, tokenWeapons, choice, greater) {\n const baseEffect = CONFIG.statusEffects.find(se => se.label === 'SWADE.Smite')\n const effectIcon = baseEffect.icon\n const effectId = baseEffect.id\n let changeValue = (choice === 'raise' ? '+4' : '+2')\n if (greater) {\n changeValue = (choice === 'raise' ? '+6' : '+4')\n }\n for (const token of tokens) {\n const weaponName = tokenWeapons[token.id]\n const weaponId = token.actor.items.getName(weaponName)?.id\n const changeKey = `@Weapon{${weaponName}}[system.damage]`\n if (!weaponId) {\n continue\n }\n const effectName = `${choice === 'raise' ? 'major' : 'minor'} Smite${greater ? '(greater)' : ''} (${weaponName})`\n const changes = [\n {\n key: changeKey,\n mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD,\n value: changeValue,\n priority: 0\n }\n ]\n const mutate = swadeMBHelpers.createMutationWithEffect(\n effectIcon, effectName, 5, changes)\n const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","ownership":{"default":0,"i0JwRg5rHcVxEULv":3},"flags":{"core":{"sourceId":"Macro.1GnCpp1vjEucgNGk"}},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677548889704,"modifiedTime":1677802233982,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"folder":null,"sort":0,"_id":"evS3zE9XTE12DErz"} -{"name":"Protection","type":"script","scope":"global","author":"ueJGUfSYuRRL3Ypr","img":"systems/swade/assets/icons/status/status_protection.svg","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const dialogOptions = {\n title: 'Protection',\n content: `Apply Protection to ${tokenList}`,\n default: 'cancel',\n buttons: [\n { label: 'Apply (+2 armor)', value: 'apply' },\n { label: 'Apply with raise (+2 toughness)', value: 'raise' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const choice = await warpgate.buttonDialog(dialogOptions)\n\n if (choice && choice !== 'cancel') {\n await createEffect(tokens, choice)\n }\n}\n\nasync function createEffect (tokens, choice) {\n const baseEffect = CONFIG.statusEffects.find(se => se.label === 'SWADE.Protection')\n const changes = [\n {\n key: 'system.stats.toughness.armor',\n mode: foundry.CONST.ACTIVE_EFFECT_MODES.UPGRADE,\n value: 2,\n priority: 0\n }\n ]\n let effectName = 'minor Protection'\n if (choice === 'raise') {\n changes[0].key = 'system.stats.toughness.value'\n effectName = 'major Protection'\n }\n for (const token of tokens) {\n const mutate = swadeMBHelpers.createMutationWithEffect(\n baseEffect.icon, effectName, 5, changes)\n const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3},"flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677630174987,"modifiedTime":1677802233983,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"folder":null,"sort":0,"_id":"gMmJcjAhtDvEOOIZ"} -{"name":"Lingering Damage","type":"script","scope":"global","author":"ueJGUfSYuRRL3Ypr","img":"icons/magic/acid/dissolve-arm-flesh.webp","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const dialogOptions = {\n title: 'Lingering Damage',\n content: `Apply Lingering Damage to ${tokenList}`,\n default: 'cancel',\n buttons: [\n { label: 'Ok', value: 'ok' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const choice = await warpgate.buttonDialog(dialogOptions)\n\n if (choice === 'ok') {\n await createEffect(tokens)\n }\n}\n\nasync function createEffect (tokens) {\n const icon = 'icons/magic/acid/dissolve-arm-flesh.webp'\n const effectName = 'Lingering Damage'\n for (const token of tokens) {\n const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 1, [])\n mutate.embedded.ActiveEffect['Lingering Damage'].flags.swade.expiration =\n CONFIG.SWADE.CONST.STATUS_EFFECT_EXPIRATION.StartOfTurnPrompt\n const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677800587229,"modifiedTime":1677802233983,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"txJBrqgVNO3jpvFG","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}} -{"name":"Hurry/Hinder","type":"script","author":"ueJGUfSYuRRL3Ypr","img":"icons/skills/movement/feet-winged-boots-blue.webp","scope":"global","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const dialogOptions = {\n title: 'Hurry/Hinder',\n content: `Apply Hurry or Hinder to ${tokenList}`,\n default: 'cancel',\n buttons: [\n { label: 'Hurry', value: 'hurry' },\n { label: 'Hinder', value: 'hinder' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const choice = await warpgate.buttonDialog(dialogOptions, 'column')\n\n if (choice && choice !== 'cancel') {\n await createEffect(tokens, choice)\n }\n}\n\nasync function createEffect (tokens, choice) {\n let icon = 'icons/skills/movement/feet-winged-boots-blue.webp'\n let effectName = 'Hurry'\n const changes = [\n {\n key: 'system.stats.speed.value',\n mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD,\n value: 2,\n priority: 0\n }\n ]\n if (choice === 'hinder') {\n changes.value = '-2'\n effectName = 'Hinder'\n icon = 'icons/magic/movement/abstract-ribbons-red-orange.webp'\n }\n for (const token of tokens) {\n const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, [])\n const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{"core":{"sourceId":"Macro.yG1ZQO30ZlntYJp7"}},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677802063142,"modifiedTime":1677802233917,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"yG1ZQO30ZlntYJp7","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}} +{"name":"Boost/Lower Trait","type":"script","author":"ueJGUfSYuRRL3Ypr","img":"icons/magic/life/cross-embers-glow-yellow-purple.webp","scope":"global","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n let traitOptions = [\n 'Agility', 'Smarts', 'Spirit', 'Strength', 'Vigor'\n ]\n const allSkills = []\n const traits = {}\n for (const traitName of traitOptions) {\n const lower = traitName.toLowerCase()\n traits[traitName] = {\n name: traitName,\n type: 'attribute',\n modkey: `system.attributes.${lower}.die.modifier`,\n diekey: `system.attributes.${lower}.die.sides`\n }\n }\n\n const tokenList = tokens.map(t => t.name).join(', ')\n for (const token of tokens) {\n const skills = token.actor.items.filter(item => item.type === 'skill')\n for (const skill of skills) {\n const name = skill.name\n traits[name] = {\n type: 'skill',\n name,\n modkey: `@Skill{${name}}[system.die.modifier]`,\n diekey: `@Skill{${name}}[system.die.sides]`\n }\n if (name !== 'Unskilled' && !allSkills.find(v => v === name)) {\n allSkills.push(name)\n }\n }\n }\n traitOptions = traitOptions.concat(allSkills.sort())\n\n const menuOptions = {\n title: 'Boost/Lower Trait',\n defaultButton: 'Cancel',\n options: {}\n }\n const menuData = {\n inputs: [\n { type: 'header', label: 'Boost/Lower Trait' },\n { type: 'info', label: `Affected Tokens ${tokenList}` },\n { type: 'select', label: 'Trait', options: traitOptions },\n { type: 'info', label: 'Boost or Lower?' },\n { type: 'radio', label: 'Boost', options: ['isBoost', true] },\n { type: 'radio', label: 'Lower', options: ['isBoost', false] },\n { type: 'checkbox', label: 'Greater', options: false },\n { type: 'checkbox', label: 'Strong (lower only)', options: false }\n ],\n buttons: [\n { label: 'Apply', value: 'apply' },\n { label: 'Apply with raise', value: 'raise' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)\n if (buttons && buttons !== 'cancel') {\n const options = {\n action: buttons,\n name: inputs[2],\n trait: traits[inputs[2]],\n direction: inputs[4] || inputs[5],\n greater: inputs[6],\n strong: inputs[7]\n }\n createEffect(tokens, options)\n }\n}\n\nconst UPICON = 'icons/magic/life/cross-embers-glow-yellow-purple.webp'\nconst DOWNICON = 'icons/magic/movement/chevrons-down-yellow.webp'\n\nasync function createEffect (tokens, options) {\n const raise = (options.action === 'raise')\n const icon = (options.direction === 'Boost' ? UPICON : DOWNICON)\n let namePart = `${options.direction} ${options.trait.name}`\n const mode = CONST.ACTIVE_EFFECT_MODES.ADD\n const mods = []\n if (options.strong && options.direction === 'Lower') {\n mods.push('strong')\n }\n if (options.greater) {\n mods.push('greater')\n }\n if (mods.length > 0) {\n namePart = `${namePart} (${mods.join(', ')})`\n }\n const minorEffect = swadeMBHelpers.createEffectDocument(\n icon, `minor ${namePart}`, 5, [\n {\n key: options.trait.diekey,\n mode,\n value: (options.direction === 'Boost' ? '+2' : '-2'),\n priority: 0\n }\n ]\n )\n const majorEffect = swadeMBHelpers.createEffectDocument(\n icon, `major ${namePart}`, 5, [\n {\n key: options.trait.diekey,\n mode,\n value: (options.direction === 'Boost' ? '+2' : '-2'),\n priority: 0\n }\n ]\n )\n if (options.direction === 'Lower' && options.greater === 'Greater') {\n minorEffect.changes.push({\n key: options.trait.modkey,\n mode,\n value: '-2',\n priority: 0\n })\n }\n const mutate = {\n embedded: {\n ActiveEffect: {\n }\n }\n }\n mutate.embedded.ActiveEffect[minorEffect.id] = minorEffect\n if (raise) {\n mutate.embedded.ActiveEffect[majorEffect.id] = majorEffect\n }\n const mutateOptions = swadeMBHelpers.defaultMutationOptions(namePart)\n for (const token of tokens) {\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677458254287,"modifiedTime":1677959697398,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"1AqIFHAcX5TRdE8X","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}} +{"name":"Smite","type":"script","scope":"global","author":"ueJGUfSYuRRL3Ypr","img":"systems/swade/assets/icons/status/status_smite.svg","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const menuOptions = {\n title: 'Smite',\n defaultButton: 'Cancel',\n options: {}\n }\n\n const menuData = {\n inputs: [\n { type: 'header', label: 'Smite' },\n { type: 'info', label: `Apply Smite to ${tokenList}` },\n { type: 'checkbox', label: 'Greater', options: false }\n ],\n buttons: [\n { label: 'Apply', value: 'apply' },\n { label: 'Apply with Raise', value: 'raise' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const tokenWeapons = {}\n let index = 2\n for (const token of tokens) {\n index += 2\n tokenWeapons[token.id] = index\n menuData.inputs.push({ type: 'info', label: `

${token.name}

` })\n const weapons = token.actor.items.filter(i => i.type === 'weapon').map(\n i => { return { value: i.name, html: i.name } })\n weapons.unshift({ value: '', html: 'None' })\n menuData.inputs.push({ type: 'select', label: token.name, options: weapons })\n }\n const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)\n for (const tokenId in tokenWeapons) {\n tokenWeapons[tokenId] = inputs[tokenWeapons[tokenId]]\n }\n const greater = (inputs[2] === 'Greater')\n if (buttons && buttons !== 'cancel') {\n await createEffect(tokens, tokenWeapons, buttons, greater)\n }\n}\n\nasync function createEffect (tokens, tokenWeapons, choice, greater) {\n const baseEffect = CONFIG.statusEffects.find(se => se.label === 'SWADE.Smite')\n const effectIcon = baseEffect.icon\n const effectId = baseEffect.id\n let changeValue = (choice === 'raise' ? '+4' : '+2')\n if (greater) {\n changeValue = (choice === 'raise' ? '+6' : '+4')\n }\n for (const token of tokens) {\n const weaponName = tokenWeapons[token.id]\n const weaponId = token.actor.items.getName(weaponName)?.id\n const changeKey = `@Weapon{${weaponName}}[system.damage]`\n if (!weaponId) {\n continue\n }\n const effectName = `${choice === 'raise' ? 'major' : 'minor'} Smite${greater ? '(greater)' : ''} (${weaponName})`\n const changes = [\n {\n key: changeKey,\n mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD,\n value: changeValue,\n priority: 0\n }\n ]\n const mutate = swadeMBHelpers.createMutationWithEffect(\n effectIcon, effectName, 5, changes)\n const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{"core":{"sourceId":"Macro.1GnCpp1vjEucgNGk"}},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677548889704,"modifiedTime":1677959697399,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"C1vGk7AKQDpcvKyP","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}} +{"name":"Deflection","type":"script","scope":"global","author":"ueJGUfSYuRRL3Ypr","img":"icons/magic/defensive/shield-barrier-deflect-teal.webp","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const dialogOptions = {\n title: 'Deflection',\n content: `Apply Deflection to ${tokenList}`,\n default: 'cancel',\n buttons: [\n { label: 'Apply (melee)', value: 'melee' },\n { label: 'Apply (ranged)', value: 'ranged' },\n { label: 'Apply with raise (both)', value: 'raise' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const choice = await warpgate.buttonDialog(dialogOptions)\n\n if (choice && choice !== 'cancel') {\n await createEffect(tokens, choice)\n }\n}\n\nasync function createEffect (tokens, choice) {\n const icon = 'icons/magic/defensive/shield-barrier-deflect-teal.webp'\n let effectName = 'Deflection'\n if (choice === 'raise') {\n effectName = `${effectName} (all)`\n } else {\n effectName = `${effectName} (${choice})`\n }\n for (const token of tokens) {\n const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, [])\n const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677645552357,"modifiedTime":1677959697399,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"HYTiftQW0pwwOQGH","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}} +{"name":"Glow","type":"script","scope":"global","author":"ueJGUfSYuRRL3Ypr","img":"icons/magic/light/explosion-star-blue-large.webp","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const dialogOptions = {\n title: 'Glow',\n content: `Apply Glow to ${tokenList}`,\n default: 'cancel',\n buttons: [\n { label: 'OK', value: 'ok' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const choice = await warpgate.buttonDialog(dialogOptions)\n\n if (choice === 'ok') {\n await createEffect(tokens)\n }\n}\n\nasync function createEffect (tokens) {\n const icon = 'icons/magic/light/explosion-star-blue-large.webp'\n const effectName = 'Glow'\n for (const token of tokens) {\n const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, [])\n const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)\n mutate.token = {\n light: {\n alpha: 0.5,\n angle: 360,\n attenuation: 0.5,\n animation: {\n intensity: 5,\n reverse: false,\n speed: 5,\n type: 'starlight'\n },\n bright: 0,\n color: '#0f3fff',\n coloration: 1,\n contrast: 0,\n dim: 0.5,\n luminosity: 0.5,\n saturation: 0,\n shadows: 0\n }\n }\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677704975699,"modifiedTime":1677959697399,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"JcZ9kxBZJpw8KLQ6","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}} +{"name":"Shroud","type":"script","scope":"global","author":"ueJGUfSYuRRL3Ypr","img":"icons/magic/perception/silhouette-stealth-shadow.webp","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const dialogOptions = {\n title: 'Shroud',\n content: `Apply Shroud to ${tokenList}`,\n default: 'cancel',\n buttons: [\n { label: 'OK', value: 'ok' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const choice = await warpgate.buttonDialog(dialogOptions)\n\n if (choice === 'ok') {\n await createEffect(tokens)\n }\n}\n\nasync function createEffect (tokens) {\n const icon = 'icons/magic/perception/silhouette-stealth-shadow.webp'\n const effectName = 'Shroud'\n for (const token of tokens) {\n const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, [])\n const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)\n mutate.token = {\n light: {\n alpha: 0.5,\n angle: 360,\n attenuation: 0.1,\n animation: {\n intensity: 5,\n reverse: false,\n speed: 5,\n type: 'roiling'\n },\n bright: 0,\n color: null,\n coloration: 0,\n contrast: 0,\n dim: 0.1,\n luminosity: -0.15,\n saturation: 0,\n shadows: 0.25\n }\n }\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677649631598,"modifiedTime":1677959697399,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"QpillIBvZmuHeuTV","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}} +{"name":"Protection","type":"script","scope":"global","author":"ueJGUfSYuRRL3Ypr","img":"systems/swade/assets/icons/status/status_protection.svg","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const dialogOptions = {\n title: 'Protection',\n content: `Apply Protection to ${tokenList}`,\n default: 'cancel',\n buttons: [\n { label: 'Apply (+2 armor)', value: 'apply' },\n { label: 'Apply with raise (+2 toughness)', value: 'raise' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const choice = await warpgate.buttonDialog(dialogOptions)\n\n if (choice && choice !== 'cancel') {\n await createEffect(tokens, choice)\n }\n}\n\nasync function createEffect (tokens, choice) {\n const baseEffect = CONFIG.statusEffects.find(se => se.label === 'SWADE.Protection')\n const changes = [\n {\n key: 'system.stats.toughness.armor',\n mode: foundry.CONST.ACTIVE_EFFECT_MODES.UPGRADE,\n value: 2,\n priority: 0\n }\n ]\n let effectName = 'minor Protection'\n if (choice === 'raise') {\n changes[0].key = 'system.stats.toughness.value'\n effectName = 'major Protection'\n }\n for (const token of tokens) {\n const mutate = swadeMBHelpers.createMutationWithEffect(\n baseEffect.icon, effectName, 5, changes)\n const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677630174987,"modifiedTime":1677959697399,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"YETsNWOWfIxyLPdC","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}} +{"name":"Lingering Damage","type":"script","scope":"global","author":"ueJGUfSYuRRL3Ypr","img":"icons/magic/acid/dissolve-arm-flesh.webp","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const dialogOptions = {\n title: 'Lingering Damage',\n content: `Apply Lingering Damage to ${tokenList}`,\n default: 'cancel',\n buttons: [\n { label: 'Ok', value: 'ok' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const choice = await warpgate.buttonDialog(dialogOptions)\n\n if (choice === 'ok') {\n await createEffect(tokens)\n }\n}\n\nasync function createEffect (tokens) {\n const icon = 'icons/magic/acid/dissolve-arm-flesh.webp'\n const effectName = 'Lingering Damage'\n for (const token of tokens) {\n const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 1, [])\n mutate.embedded.ActiveEffect['Lingering Damage'].flags.swade.expiration =\n CONFIG.SWADE.CONST.STATUS_EFFECT_EXPIRATION.StartOfTurnPrompt\n const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677800587229,"modifiedTime":1677959697399,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"txJBrqgVNO3jpvFG","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}} +{"name":"Hinder","type":"script","author":"ueJGUfSYuRRL3Ypr","img":"icons/magic/movement/abstract-ribbons-red-orange.webp","scope":"global","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const dialogOptions = {\n title: 'Hinder',\n content: `Apply Hinder to ${tokenList}`,\n default: 'cancel',\n buttons: [\n { label: 'OK', value: 'ok' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const choice = await warpgate.buttonDialog(dialogOptions, 'column')\n\n if (choice === 'ok') {\n await createEffect(tokens, choice)\n }\n}\n\nasync function createEffect (tokens, choice) {\n const icon = 'icons/magic/movement/abstract-ribbons-red-orange.webp'\n const effectName = 'Hinder'\n const changes = [\n {\n key: 'system.stats.speed.value',\n mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD,\n value: -2,\n priority: 0\n }\n ]\n for (const token of tokens) {\n const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, changes)\n const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677802063142,"modifiedTime":1677959697462,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"uvHTdYUn5l3Z1rAV","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}} +{"name":"Hurry","type":"script","author":"ueJGUfSYuRRL3Ypr","img":"icons/skills/movement/feet-winged-boots-blue.webp","scope":"global","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const dialogOptions = {\n title: 'Hurry',\n content: `Apply Hurry to ${tokenList}`,\n default: 'cancel',\n buttons: [\n { label: 'OK', value: 'ok' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const choice = await warpgate.buttonDialog(dialogOptions, 'column')\n\n if (choice === 'ok') {\n await createEffect(tokens, choice)\n }\n}\n\nasync function createEffect (tokens, choice) {\n const icon = 'icons/skills/movement/feet-winged-boots-blue.webp'\n const effectName = 'Hurry'\n const changes = [\n {\n key: 'system.stats.speed.value',\n mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD,\n value: 2,\n priority: 0\n }\n ]\n for (const token of tokens) {\n const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, changes)\n const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677802063142,"modifiedTime":1677959697462,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"yG1ZQO30ZlntYJp7","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}}