swade-mb-helpers/packs/effect-macros.db

16 lines
33 KiB
Plaintext

{"name":"Invisibility","type":"script","author":"ueJGUfSYuRRL3Ypr","img":"icons/svg/invisible.svg","scope":"global","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const menuOptions = {\n title: 'Invisibility',\n defaultButton: 'Cancel',\n options: {}\n }\n\n const menuData = {\n inputs: [\n { type: 'header', label: 'Invisibility' },\n { type: 'info', label: `Apply Invisibility to ${tokenList}` },\n { type: 'checkbox', label: 'Duration', options: false }\n ],\n buttons: [\n { label: 'Apply', value: 'apply' },\n { label: 'Raise', value: 'raise' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)\n if (buttons && buttons !== 'cancel') {\n const options = {\n raise: (buttons === 'raise'),\n duration: (!!inputs[2])\n }\n await createEffect(tokens, options)\n }\n}\n\nasync function createEffect (tokens, options) {\n const effectName = `${options.raise ? 'major' : 'minor'} Invisibility`\n const baseEffect = CONFIG.statusEffects.find(se => se.label === 'EFFECT.StatusInvisible')\n const duration = (options.duration ? 5 * 6 * 60 : 5)\n for (const token of tokens) {\n const mutate = swadeMBHelpers.createMutationWithEffect(baseEffect.icon, effectName, duration, [])\n mutate.embedded.ActiveEffect[effectName].flags.core = { statusId: baseEffect.id }\n const mutateOptions = swadeMBHelpers.defaultMutationOptions('Blind')\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1678168163811,"modifiedTime":1678206183465,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"11GOryzx2Q8MXbT6","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":1678206183465,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"1AqIFHAcX5TRdE8X","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}}
{"name":"Entangle","type":"script","scope":"global","author":"ueJGUfSYuRRL3Ypr","img":"icons/magic/nature/root-vine-barrier-wall-brown.webp","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const menuOptions = {\n title: 'Entangle',\n defaultButton: 'Cancel',\n options: {}\n }\n\n const menuData = {\n inputs: [\n { type: 'header', label: 'Entangle' },\n { type: 'info', label: `Apply Entangle to ${tokenList}` },\n { type: 'radio', label: 'Not Damaging', options: ['dmg', true] },\n { type: 'radio', label: 'Damaging', options: ['dmg', false] },\n { type: 'radio', label: 'Deadly', options: ['dmg', false] },\n { type: 'checkbox', label: 'Tough', options: false }\n ],\n buttons: [\n { label: 'Entangled', value: 'apply' },\n { label: 'Bound (raise)', value: 'raise' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)\n if (buttons && buttons !== 'cancel') {\n const options = {\n apply: (buttons === 'raise' ? 'bound' : 'entangled'),\n damage: (inputs[3] ? '2d4' : (inputs[4] ? '2d6' : null)),\n tough: (!!inputs[5])\n }\n await createEffect(tokens, options)\n }\n}\n\nfunction getStatus (label, name) {\n const effect = JSON.parse(JSON.stringify(\n CONFIG.statusEffects.find(se => se.label === label)))\n effect.label = name\n if (!effect.flags) {\n effect.flags = {}\n }\n effect.flags.core = { statusId: effect.id }\n effect.id = name\n return effect\n}\n\nasync function createEffect (tokens, options) {\n const effectSearch = (options.apply === 'bound' ? 'SWADE.Bound' : 'SWADE.Entangled')\n const effectName = (options.apply === 'bound' ? 'Bound' : 'Entangled')\n const effect = getStatus(effectSearch, effectName)\n const extraIcon = 'icons/magic/nature/root-vine-barrier-wall-brown.webp'\n const extraEffect = swadeMBHelpers.createEffectDocument(extraIcon, 'Entangle Modifier', 1, [])\n\n if (options.damage) {\n extraEffect.id = `${extraEffect.id} - ${options.damage} dmg`\n extraEffect.label = `${extraEffect.label} - ${options.damage} dmg`\n }\n if (options.tough) {\n extraEffect.id = `Tough ${extraEffect.id}`\n extraEffect.label = `Tough ${extraEffect.label}`\n }\n for (const token of tokens) {\n const mutateOptions = swadeMBHelpers.defaultMutationOptions('Entangle')\n const mutate = { embedded: { ActiveEffect: {} } }\n mutate.embedded.ActiveEffect[effect.id] = effect\n if (options.damage || options.tough) {\n mutate.embedded.ActiveEffect[extraEffect.id] = extraEffect\n }\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1678164427219,"modifiedTime":1678206183466,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"2TOeRNCJT3T2px8D","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: `<h2>${token.name}</h2>` })\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: '<i>None</i>' })\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 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 mutate.embedded.ActiveEffect[effectName].flags.core = { statusId: baseEffect.id }\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":1678206183466,"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 <em>Deflection</em> 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":1678206183466,"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 <em>Glow</em> to ${tokenList}`,\n default: 'cancel',\n buttons: [\n { label: 'OK', value: 'ok' },\n { label: 'Mutate token lighting', value: 'mutate' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const choice = await warpgate.buttonDialog(dialogOptions)\n\n if (choice === 'ok' || choice === 'mutate') {\n await createEffect(tokens, choice)\n }\n}\n\nasync function createEffect (tokens, choice) {\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 await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n if (choice === 'mutate') {\n const mutate2 = {\n 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 }\n mutateOptions.permanent = false\n await warpgate.mutate(token.document, mutate2, {}, mutateOptions)\n }\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677704975699,"modifiedTime":1678206183466,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"JcZ9kxBZJpw8KLQ6","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}}
{"name":"Confusion","type":"script","author":"ueJGUfSYuRRL3Ypr","img":"icons/magic/control/hypnosis-mesmerism-swirl.webp","scope":"global","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const menuOptions = {\n title: 'Confusion',\n defaultButton: 'Cancel',\n options: {}\n }\n\n const menuData = {\n inputs: [\n { type: 'header', label: 'Confusion' },\n { type: 'info', label: `Apply Confusion to ${tokenList}` },\n { type: 'checkbox', label: 'Greater (adds shaken)', options: false }\n ],\n buttons: [\n { label: 'Distracted', value: 'distracted' },\n { label: 'Vulnerable', value: 'vulnerable' },\n { label: 'Raise (both)', value: 'raise' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)\n const greater = (inputs[2] === 'Greater (adds shaken)')\n if (buttons && buttons !== 'cancel') {\n await createEffect(tokens, buttons, greater)\n }\n}\n\nfunction getStatus (label, name) {\n const effect = JSON.parse(JSON.stringify(\n CONFIG.statusEffects.find(se => se.label === label)))\n effect.flags.core = { statusId: effect.id }\n effect.id = name\n return effect\n}\n\nasync function createEffect (tokens, choice, greater) {\n const effects = []\n if (choice === 'distracted' || choice === 'raise') {\n effects.push(getStatus('SWADE.Distr', 'Distracted'))\n }\n if (choice === 'vulnerable' || choice === 'raise') {\n effects.push(getStatus('SWADE.Vuln', 'Vulnerable'))\n }\n if (greater) {\n effects.push(getStatus('SWADE.Shaken', 'Shaken'))\n }\n for (const token of tokens) {\n const mutateOptions = swadeMBHelpers.defaultMutationOptions('Confusion')\n const mutate = {\n embedded: { ActiveEffect: {} }\n }\n for (const effect of effects) {\n mutate.embedded.ActiveEffect[effect.id] = effect\n }\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1678082334572,"modifiedTime":1678206183466,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"L2IstecV7ivcrgUI","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}}
{"name":"Intangibility","type":"script","author":"ueJGUfSYuRRL3Ypr","img":"icons/magic/control/debuff-energy-hold-levitate-blue-yellow.webp","scope":"global","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const menuOptions = {\n title: 'Intangibility',\n defaultButton: 'Cancel',\n options: {}\n }\n\n const menuData = {\n inputs: [\n { type: 'header', label: 'Intangibility' },\n { type: 'info', label: `Apply Intangibility to ${tokenList}` },\n { type: 'checkbox', label: 'Duration', options: false }\n ],\n buttons: [\n { label: 'Apply', value: 'apply' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)\n if (buttons && buttons !== 'cancel') {\n const options = {\n duration: (!!inputs[2])\n }\n await createEffect(tokens, options)\n }\n}\n\nasync function createEffect (tokens, options) {\n const effectName = 'Intangibility'\n const duration = (options.duration ? 5 * 6 * 60 : 5)\n const icon = 'icons/magic/control/debuff-energy-hold-levitate-blue-yellow.webp'\n for (const token of tokens) {\n const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, duration, [])\n const mutateOptions = swadeMBHelpers.defaultMutationOptions('Intangibility')\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1678168528898,"modifiedTime":1678206183466,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"OMDjgWLJyE9BJAwT","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 <em>Shroud</em> to ${tokenList}`,\n default: 'cancel',\n buttons: [\n { label: 'OK', value: 'ok' },\n { label: 'Mutate token lighting', value: 'mutate' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const choice = await warpgate.buttonDialog(dialogOptions)\n\n if (choice === 'ok' || choice === 'mutate') {\n await createEffect(tokens, choice)\n }\n}\n\nasync function createEffect (tokens, choice) {\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 await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n if (choice === 'mutate') {\n const mutate2 = {\n 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 }\n mutateOptions.permanent = false\n await warpgate.mutate(token.document, mutate2, {}, mutateOptions)\n }\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677649631598,"modifiedTime":1678206183466,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"QpillIBvZmuHeuTV","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}}
{"name":"Summon","type":"script","author":"ueJGUfSYuRRL3Ypr","img":"icons/magic/symbols/runes-star-orange.webp","scope":"global","command":"const ACTORFOLDER = 'Summonables'\nconst SUMMONICON = 'icons/magic/symbols/runes-star-orange.webp'\n\nswadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const token = tokens[0]\n const tokenList = token.name\n const folder = swadeMBHelpers.getActorFolderByPath(ACTORFOLDER)\n const actors = swadeMBHelpers.getActorsInFolder(folder)\n const menuOptions = {\n title: 'Summon Creature',\n defaultButton: 'cancel',\n options: {}\n }\n const menuData = {\n inputs: [\n { type: 'header', label: 'Summon Creature' },\n { type: 'info', label: `${tokenList} is summoning` },\n {\n type: 'select',\n label: 'Ally to summon',\n options: Object.keys(actors).sort().map(k => { return { value: actors[k].id, html: k } })\n },\n { type: 'number', label: 'Number to spawn (+half base cost per)', options: 1 }\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 summonData = {\n raise: (buttons === 'raise'),\n actorId: inputs[2],\n number: inputs[3]\n }\n summonData.actor = game.actors.get(summonData.actorId)\n summonData.actorName = summonData.actor.name\n summonData.icon = summonData.actor.prototypeToken.texture.src\n summonData.token = summonData.actor.prototypeToken\n\n doWork(summonData, token)\n }\n}\n\nasync function doWork (summonData, token) {\n console.log('Summon ', token, summonData)\n const effectName = `Summoned ${summonData.actorName} (${summonData.number})`\n const tokenEffectMutation = swadeMBHelpers.createMutationWithEffect(SUMMONICON, effectName, 5, [])\n const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)\n await warpgate.mutate(token.document, tokenEffectMutation, {}, mutateOptions)\n\n const spawnOptions = {\n controllingActor: token.actor,\n duplicates: summonData.number,\n comparisonKeys: { ActiveEffect: 'label' },\n crosshairs: {\n icon: summonData.icon,\n label: `Summon ${summonData.actorName}`,\n drawOutline: false,\n rememberControlled: true\n }\n }\n const spawnMutation = {\n token: {\n actorLink: false,\n name: `${token.name}'s ${summonData.token.name}`\n }\n }\n await warpgate.spawn(summonData.actorName, spawnMutation, {}, spawnOptions)\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1677996503821,"modifiedTime":1678206183466,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"RV09eJi9iG5bfupo","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 <em>Protection</em> 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 mutate.embedded.ActiveEffect[effectName].flags.core = { statusId: baseEffect.id }\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":1678206183467,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"YETsNWOWfIxyLPdC","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}}
{"name":"Blind","type":"script","author":"ueJGUfSYuRRL3Ypr","img":"icons/svg/blind.svg","scope":"global","command":"swadeMBHelpers.runOnTargetOrSelectedTokens(main)\n\nasync function main (tokens) {\n const tokenList = tokens.map(t => t.name).join(', ')\n const menuOptions = {\n title: 'Blind',\n defaultButton: 'Cancel',\n options: {}\n }\n\n const menuData = {\n inputs: [\n { type: 'header', label: 'Blind' },\n { type: 'info', label: `Apply Blind to ${tokenList}` },\n { type: 'checkbox', label: 'Strong', options: false }\n ],\n buttons: [\n { label: 'Apply', value: 'apply' },\n { label: 'Raise', value: 'raise' },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n\n const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)\n if (buttons && buttons !== 'cancel') {\n const options = {\n raise: (buttons === 'raise'),\n strong: (!!inputs[2])\n }\n await createEffect(tokens, options)\n }\n}\n\nasync function createEffect (tokens, options) {\n const effectDetails = (options.raise ? '-4' : '-2')\n const effectEnd = (options.strong ? 'Vigor -2' : 'Vigor')\n const effectName = `Blind (${effectDetails}) ${effectEnd} ends`\n const baseEffect = CONFIG.statusEffects.find(se => se.label === 'EFFECT.StatusBlind')\n for (const token of tokens) {\n const mutate = swadeMBHelpers.createMutationWithEffect(baseEffect.icon, effectName, 1, [])\n mutate.embedded.ActiveEffect[effectName].flags.core = { statusId: baseEffect.id }\n const mutateOptions = swadeMBHelpers.defaultMutationOptions('Blind')\n await warpgate.mutate(token.document, mutate, {}, mutateOptions)\n }\n}","flags":{},"_stats":{"systemId":"swade","systemVersion":"2.2.5","coreVersion":"10.291","createdTime":1678165762773,"modifiedTime":1678206183468,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"e9HvLMtaDw2qpcE8","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 <em>Lingering Damage</em> 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":1678206183468,"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 <em>Hinder</em> 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":1678206183468,"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 <em>Hurry</em> 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":1678206183468,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"_id":"yG1ZQO30ZlntYJp7","folder":null,"sort":0,"ownership":{"default":0,"ueJGUfSYuRRL3Ypr":3}}