7 lines
14 KiB
Plaintext
7 lines
14 KiB
Plaintext
{"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":1677714478849,"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 <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":1677714478849,"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: '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":1677714478850,"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 <em>Shroud</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/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":1677714478850,"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: `<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 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":1677714478849,"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 <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 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":1677714478850,"lastModifiedBy":"ueJGUfSYuRRL3Ypr"},"folder":null,"sort":0,"_id":"gMmJcjAhtDvEOOIZ"}
|