{"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: `