add quick damage roll macro
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
||||
|
||||
async function main (tokens) {
|
||||
const tokenList = tokens.map(t => t.name).join(', ')
|
||||
const menuOptions = {
|
||||
title: 'Blind',
|
||||
defaultButton: 'Cancel',
|
||||
options: {}
|
||||
}
|
||||
|
||||
const menuData = {
|
||||
inputs: [
|
||||
{ type: 'header', label: 'Blind' },
|
||||
{ type: 'info', label: `Apply Blind to ${tokenList}` },
|
||||
{ type: 'checkbox', label: 'Strong', options: false }
|
||||
],
|
||||
buttons: [
|
||||
{ label: 'Apply', value: 'apply' },
|
||||
{ label: 'Raise', value: 'raise' },
|
||||
{ label: 'Cancel', value: 'cancel' }
|
||||
]
|
||||
}
|
||||
|
||||
const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)
|
||||
if (buttons && buttons !== 'cancel') {
|
||||
const options = {
|
||||
raise: (buttons === 'raise'),
|
||||
strong: (!!inputs[2])
|
||||
}
|
||||
await createEffect(tokens, options)
|
||||
}
|
||||
}
|
||||
|
||||
async function createEffect (tokens, options) {
|
||||
const effectDetails = (options.raise ? '-4' : '-2')
|
||||
const effectEnd = (options.strong ? 'Vigor -2' : 'Vigor')
|
||||
const effectName = `Blind (${effectDetails}) ${effectEnd} ends`
|
||||
const baseEffect = CONFIG.statusEffects.find(se => se.label === 'EFFECT.StatusBlind')
|
||||
for (const token of tokens) {
|
||||
const mutate = swadeMBHelpers.createMutationWithEffect(baseEffect.icon, effectName, 1, [])
|
||||
mutate.embedded.ActiveEffect[effectName].flags.core = { statusId: baseEffect.id }
|
||||
const mutateOptions = swadeMBHelpers.defaultMutationOptions('Blind')
|
||||
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
||||
|
||||
async function main (tokens) {
|
||||
let traitOptions = [
|
||||
'Agility', 'Smarts', 'Spirit', 'Strength', 'Vigor'
|
||||
]
|
||||
const allSkills = []
|
||||
const traits = {}
|
||||
for (const traitName of traitOptions) {
|
||||
const lower = traitName.toLowerCase()
|
||||
traits[traitName] = {
|
||||
name: traitName,
|
||||
type: 'attribute',
|
||||
modkey: `system.attributes.${lower}.die.modifier`,
|
||||
diekey: `system.attributes.${lower}.die.sides`
|
||||
}
|
||||
}
|
||||
|
||||
const tokenList = tokens.map(t => t.name).join(', ')
|
||||
for (const token of tokens) {
|
||||
const skills = token.actor.items.filter(item => item.type === 'skill')
|
||||
for (const skill of skills) {
|
||||
const name = skill.name
|
||||
traits[name] = {
|
||||
type: 'skill',
|
||||
name,
|
||||
modkey: `@Skill{${name}}[system.die.modifier]`,
|
||||
diekey: `@Skill{${name}}[system.die.sides]`
|
||||
}
|
||||
if (name !== 'Unskilled' && !allSkills.find(v => v === name)) {
|
||||
allSkills.push(name)
|
||||
}
|
||||
}
|
||||
}
|
||||
traitOptions = traitOptions.concat(allSkills.sort())
|
||||
|
||||
const menuOptions = {
|
||||
title: 'Boost/Lower Trait',
|
||||
defaultButton: 'Cancel',
|
||||
options: {}
|
||||
}
|
||||
const menuData = {
|
||||
inputs: [
|
||||
{ type: 'header', label: 'Boost/Lower Trait' },
|
||||
{ type: 'info', label: `Affected Tokens ${tokenList}` },
|
||||
{ type: 'select', label: 'Trait', options: traitOptions },
|
||||
{ type: 'info', label: 'Boost or Lower?' },
|
||||
{ type: 'radio', label: 'Boost', options: ['isBoost', true] },
|
||||
{ type: 'radio', label: 'Lower', options: ['isBoost', false] },
|
||||
{ type: 'checkbox', label: 'Greater', options: false },
|
||||
{ type: 'checkbox', label: 'Strong (lower only)', options: false }
|
||||
],
|
||||
buttons: [
|
||||
{ label: 'Apply', value: 'apply' },
|
||||
{ label: 'Apply with raise', value: 'raise' },
|
||||
{ label: 'Cancel', value: 'cancel' }
|
||||
]
|
||||
}
|
||||
const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)
|
||||
if (buttons && buttons !== 'cancel') {
|
||||
const options = {
|
||||
action: buttons,
|
||||
name: inputs[2],
|
||||
trait: traits[inputs[2]],
|
||||
direction: inputs[4] || inputs[5],
|
||||
greater: inputs[6],
|
||||
strong: inputs[7]
|
||||
}
|
||||
createEffect(tokens, options)
|
||||
}
|
||||
}
|
||||
|
||||
const UPICON = 'icons/magic/life/cross-embers-glow-yellow-purple.webp'
|
||||
const DOWNICON = 'icons/magic/movement/chevrons-down-yellow.webp'
|
||||
|
||||
async function createEffect (tokens, options) {
|
||||
const raise = (options.action === 'raise')
|
||||
const icon = (options.direction === 'Boost' ? UPICON : DOWNICON)
|
||||
let namePart = `${options.direction} ${options.trait.name}`
|
||||
const mode = CONST.ACTIVE_EFFECT_MODES.ADD
|
||||
const mods = []
|
||||
if (options.strong && options.direction === 'Lower') {
|
||||
mods.push('strong')
|
||||
}
|
||||
if (options.greater) {
|
||||
mods.push('greater')
|
||||
}
|
||||
if (mods.length > 0) {
|
||||
namePart = `${namePart} (${mods.join(', ')})`
|
||||
}
|
||||
const minorEffect = swadeMBHelpers.createEffectDocument(
|
||||
icon, `minor ${namePart}`, 5, [
|
||||
{
|
||||
key: options.trait.diekey,
|
||||
mode,
|
||||
value: (options.direction === 'Boost' ? '+2' : '-2'),
|
||||
priority: 0
|
||||
}
|
||||
]
|
||||
)
|
||||
const majorEffect = swadeMBHelpers.createEffectDocument(
|
||||
icon, `major ${namePart}`, 5, [
|
||||
{
|
||||
key: options.trait.diekey,
|
||||
mode,
|
||||
value: (options.direction === 'Boost' ? '+2' : '-2'),
|
||||
priority: 0
|
||||
}
|
||||
]
|
||||
)
|
||||
if (options.direction === 'Lower' && options.greater === 'Greater') {
|
||||
minorEffect.changes.push({
|
||||
key: options.trait.modkey,
|
||||
mode,
|
||||
value: '-2',
|
||||
priority: 0
|
||||
})
|
||||
}
|
||||
const mutate = {
|
||||
embedded: {
|
||||
ActiveEffect: {
|
||||
}
|
||||
}
|
||||
}
|
||||
mutate.embedded.ActiveEffect[minorEffect.id] = minorEffect
|
||||
if (raise) {
|
||||
mutate.embedded.ActiveEffect[majorEffect.id] = majorEffect
|
||||
}
|
||||
const mutateOptions = swadeMBHelpers.defaultMutationOptions(namePart)
|
||||
for (const token of tokens) {
|
||||
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
||||
|
||||
async function main (tokens) {
|
||||
const tokenList = tokens.map(t => t.name).join(', ')
|
||||
const menuOptions = {
|
||||
title: 'Confusion',
|
||||
defaultButton: 'Cancel',
|
||||
options: {}
|
||||
}
|
||||
|
||||
const menuData = {
|
||||
inputs: [
|
||||
{ type: 'header', label: 'Confusion' },
|
||||
{ type: 'info', label: `Apply Confusion to ${tokenList}` },
|
||||
{ type: 'checkbox', label: 'Greater (adds shaken)', options: false }
|
||||
],
|
||||
buttons: [
|
||||
{ label: 'Distracted', value: 'distracted' },
|
||||
{ label: 'Vulnerable', value: 'vulnerable' },
|
||||
{ label: 'Raise (both)', value: 'raise' },
|
||||
{ label: 'Cancel', value: 'cancel' }
|
||||
]
|
||||
}
|
||||
|
||||
const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)
|
||||
const greater = (inputs[2] === 'Greater (adds shaken)')
|
||||
if (buttons && buttons !== 'cancel') {
|
||||
await createEffect(tokens, buttons, greater)
|
||||
}
|
||||
}
|
||||
|
||||
function getStatus (label, name) {
|
||||
const effect = JSON.parse(JSON.stringify(
|
||||
CONFIG.statusEffects.find(se => se.label === label)))
|
||||
effect.label = name
|
||||
effect.flags.core = { statusId: effect.id }
|
||||
effect.id = name
|
||||
return effect
|
||||
}
|
||||
|
||||
async function createEffect (tokens, choice, greater) {
|
||||
const effects = []
|
||||
if (choice === 'distracted' || choice === 'raise') {
|
||||
effects.push(getStatus('SWADE.Distr', 'Distracted'))
|
||||
}
|
||||
if (choice === 'vulnerable' || choice === 'raise') {
|
||||
effects.push(getStatus('SWADE.Vuln', 'Vulnerable'))
|
||||
}
|
||||
if (greater) {
|
||||
effects.push(getStatus('SWADE.Shaken', 'Shaken'))
|
||||
}
|
||||
for (const token of tokens) {
|
||||
const mutateOptions = swadeMBHelpers.defaultMutationOptions('Confusion')
|
||||
const mutate = {
|
||||
embedded: { ActiveEffect: {} }
|
||||
}
|
||||
for (const effect of effects) {
|
||||
mutate.embedded.ActiveEffect[effect.id] = effect
|
||||
}
|
||||
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
||||
|
||||
async function main (tokens) {
|
||||
const tokenList = tokens.map(t => t.name).join(', ')
|
||||
const dialogOptions = {
|
||||
title: 'Deflection',
|
||||
content: `Apply <em>Deflection</em> to ${tokenList}`,
|
||||
default: 'cancel',
|
||||
buttons: [
|
||||
{ label: 'Apply (melee)', value: 'melee' },
|
||||
{ label: 'Apply (ranged)', value: 'ranged' },
|
||||
{ label: 'Apply with raise (both)', value: 'raise' },
|
||||
{ label: 'Cancel', value: 'cancel' }
|
||||
]
|
||||
}
|
||||
|
||||
const choice = await warpgate.buttonDialog(dialogOptions)
|
||||
|
||||
if (choice && choice !== 'cancel') {
|
||||
await createEffect(tokens, choice)
|
||||
}
|
||||
}
|
||||
|
||||
async function createEffect (tokens, choice) {
|
||||
const icon = 'icons/magic/defensive/shield-barrier-deflect-teal.webp'
|
||||
let effectName = 'Deflection'
|
||||
if (choice === 'raise') {
|
||||
effectName = `${effectName} (all)`
|
||||
} else {
|
||||
effectName = `${effectName} (${choice})`
|
||||
}
|
||||
for (const token of tokens) {
|
||||
const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, [])
|
||||
const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)
|
||||
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
||||
|
||||
async function main (tokens) {
|
||||
const tokenList = tokens.map(t => t.name).join(', ')
|
||||
const menuOptions = {
|
||||
title: 'Entangle',
|
||||
defaultButton: 'Cancel',
|
||||
options: {}
|
||||
}
|
||||
|
||||
const menuData = {
|
||||
inputs: [
|
||||
{ type: 'header', label: 'Entangle' },
|
||||
{ type: 'info', label: `Apply Entangle to ${tokenList}` },
|
||||
{ type: 'radio', label: 'Not Damaging', options: ['dmg', true] },
|
||||
{ type: 'radio', label: 'Damaging', options: ['dmg', false] },
|
||||
{ type: 'radio', label: 'Deadly', options: ['dmg', false] },
|
||||
{ type: 'checkbox', label: 'Tough', options: false }
|
||||
],
|
||||
buttons: [
|
||||
{ label: 'Entangled', value: 'apply' },
|
||||
{ label: 'Bound (raise)', value: 'raise' },
|
||||
{ label: 'Cancel', value: 'cancel' }
|
||||
]
|
||||
}
|
||||
|
||||
const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)
|
||||
if (buttons && buttons !== 'cancel') {
|
||||
const options = {
|
||||
apply: (buttons === 'raise' ? 'bound' : 'entangled'),
|
||||
damage: (inputs[3] ? '2d4' : (inputs[4] ? '2d6' : null)),
|
||||
tough: (!!inputs[5])
|
||||
}
|
||||
await createEffect(tokens, options)
|
||||
}
|
||||
}
|
||||
|
||||
function getStatus (label, name) {
|
||||
const effect = JSON.parse(JSON.stringify(
|
||||
CONFIG.statusEffects.find(se => se.label === label)))
|
||||
effect.label = name
|
||||
if (!effect.flags) {
|
||||
effect.flags = {}
|
||||
}
|
||||
effect.flags.core = { statusId: effect.id }
|
||||
effect.id = name
|
||||
return effect
|
||||
}
|
||||
|
||||
async function createEffect (tokens, options) {
|
||||
const effectSearch = (options.apply === 'bound' ? 'SWADE.Bound' : 'SWADE.Entangled')
|
||||
const effectName = (options.apply === 'bound' ? 'Bound' : 'Entangled')
|
||||
const effect = getStatus(effectSearch, effectName)
|
||||
const extraIcon = 'icons/magic/nature/root-vine-barrier-wall-brown.webp'
|
||||
const extraEffect = swadeMBHelpers.createEffectDocument(extraIcon, 'Entangle Modifier', 1, [])
|
||||
|
||||
if (options.damage) {
|
||||
extraEffect.id = `${extraEffect.id} - ${options.damage} dmg`
|
||||
extraEffect.label = `${extraEffect.label} - ${options.damage} dmg`
|
||||
}
|
||||
if (options.tough) {
|
||||
extraEffect.id = `Tough ${extraEffect.id}`
|
||||
extraEffect.label = `Tough ${extraEffect.label}`
|
||||
}
|
||||
for (const token of tokens) {
|
||||
const mutateOptions = swadeMBHelpers.defaultMutationOptions('Entangle')
|
||||
const mutate = { embedded: { ActiveEffect: {} } }
|
||||
mutate.embedded.ActiveEffect[effect.id] = effect
|
||||
if (options.damage || options.tough) {
|
||||
mutate.embedded.ActiveEffect[extraEffect.id] = extraEffect
|
||||
}
|
||||
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
||||
|
||||
async function main (tokens) {
|
||||
const tokenList = tokens.map(t => t.name).join(', ')
|
||||
const dialogOptions = {
|
||||
title: 'Glow',
|
||||
content: `Apply <em>Glow</em> to ${tokenList}`,
|
||||
default: 'cancel',
|
||||
buttons: [
|
||||
{ label: 'OK', value: 'ok' },
|
||||
{ label: 'Mutate token lighting', value: 'mutate' },
|
||||
{ label: 'Cancel', value: 'cancel' }
|
||||
]
|
||||
}
|
||||
|
||||
const choice = await warpgate.buttonDialog(dialogOptions)
|
||||
|
||||
if (choice === 'ok' || choice === 'mutate') {
|
||||
await createEffect(tokens, choice)
|
||||
}
|
||||
}
|
||||
|
||||
async function createEffect (tokens, choice) {
|
||||
const icon = 'icons/magic/light/explosion-star-blue-large.webp'
|
||||
const effectName = 'Glow'
|
||||
for (const token of tokens) {
|
||||
const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, [])
|
||||
const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)
|
||||
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
||||
if (choice === 'mutate') {
|
||||
const mutate2 = {
|
||||
token: {
|
||||
light: {
|
||||
alpha: 0.5,
|
||||
angle: 360,
|
||||
attenuation: 0.5,
|
||||
animation: {
|
||||
intensity: 5,
|
||||
reverse: false,
|
||||
speed: 5,
|
||||
type: 'starlight'
|
||||
},
|
||||
bright: 0,
|
||||
color: '#0f3fff',
|
||||
coloration: 1,
|
||||
contrast: 0,
|
||||
dim: 0.5,
|
||||
luminosity: 0.5,
|
||||
saturation: 0,
|
||||
shadows: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
mutateOptions.permanent = false
|
||||
await warpgate.mutate(token.document, mutate2, {}, mutateOptions)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
||||
|
||||
async function main (tokens) {
|
||||
const tokenList = tokens.map(t => t.name).join(', ')
|
||||
const dialogOptions = {
|
||||
title: 'Hinder',
|
||||
content: `Apply <em>Hinder</em> 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)
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
||||
|
||||
async function main (tokens) {
|
||||
const tokenList = tokens.map(t => t.name).join(', ')
|
||||
const dialogOptions = {
|
||||
title: 'Hurry',
|
||||
content: `Apply <em>Hurry</em> 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/skills/movement/feet-winged-boots-blue.webp'
|
||||
const effectName = 'Hurry'
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
||||
|
||||
async function main (tokens) {
|
||||
const tokenList = tokens.map(t => t.name).join(', ')
|
||||
const menuOptions = {
|
||||
title: 'Intangibility',
|
||||
defaultButton: 'Cancel',
|
||||
options: {}
|
||||
}
|
||||
|
||||
const menuData = {
|
||||
inputs: [
|
||||
{ type: 'header', label: 'Intangibility' },
|
||||
{ type: 'info', label: `Apply Intangibility to ${tokenList}` },
|
||||
{ type: 'checkbox', label: 'Duration', options: false }
|
||||
],
|
||||
buttons: [
|
||||
{ label: 'Apply', value: 'apply' },
|
||||
{ label: 'Cancel', value: 'cancel' }
|
||||
]
|
||||
}
|
||||
|
||||
const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)
|
||||
if (buttons && buttons !== 'cancel') {
|
||||
const options = {
|
||||
duration: (!!inputs[2])
|
||||
}
|
||||
await createEffect(tokens, options)
|
||||
}
|
||||
}
|
||||
|
||||
async function createEffect (tokens, options) {
|
||||
const effectName = 'Intangibility'
|
||||
const duration = (options.duration ? 5 * 6 * 60 : 5)
|
||||
const icon = 'icons/magic/control/debuff-energy-hold-levitate-blue-yellow.webp'
|
||||
for (const token of tokens) {
|
||||
const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, duration, [])
|
||||
const mutateOptions = swadeMBHelpers.defaultMutationOptions('Intangibility')
|
||||
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
||||
|
||||
async function main (tokens) {
|
||||
const tokenList = tokens.map(t => t.name).join(', ')
|
||||
const menuOptions = {
|
||||
title: 'Invisibility',
|
||||
defaultButton: 'Cancel',
|
||||
options: {}
|
||||
}
|
||||
|
||||
const menuData = {
|
||||
inputs: [
|
||||
{ type: 'header', label: 'Invisibility' },
|
||||
{ type: 'info', label: `Apply Invisibility to ${tokenList}` },
|
||||
{ type: 'checkbox', label: 'Duration', options: false }
|
||||
],
|
||||
buttons: [
|
||||
{ label: 'Apply', value: 'apply' },
|
||||
{ label: 'Raise', value: 'raise' },
|
||||
{ label: 'Cancel', value: 'cancel' }
|
||||
]
|
||||
}
|
||||
|
||||
const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)
|
||||
if (buttons && buttons !== 'cancel') {
|
||||
const options = {
|
||||
raise: (buttons === 'raise'),
|
||||
duration: (!!inputs[2])
|
||||
}
|
||||
await createEffect(tokens, options)
|
||||
}
|
||||
}
|
||||
|
||||
async function createEffect (tokens, options) {
|
||||
const effectName = `${options.raise ? 'major' : 'minor'} Invisibility`
|
||||
const baseEffect = CONFIG.statusEffects.find(se => se.label === 'EFFECT.StatusInvisible')
|
||||
const duration = (options.duration ? 5 * 6 * 60 : 5)
|
||||
for (const token of tokens) {
|
||||
const mutate = swadeMBHelpers.createMutationWithEffect(baseEffect.icon, effectName, duration, [])
|
||||
mutate.embedded.ActiveEffect[effectName].flags.core = { statusId: baseEffect.id }
|
||||
const mutateOptions = swadeMBHelpers.defaultMutationOptions('Invisibility')
|
||||
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
||||
|
||||
async function main (tokens) {
|
||||
const tokenList = tokens.map(t => t.name).join(', ')
|
||||
const dialogOptions = {
|
||||
title: 'Lingering Damage',
|
||||
content: `Apply <em>Lingering Damage</em> to ${tokenList}`,
|
||||
default: 'cancel',
|
||||
buttons: [
|
||||
{ label: 'Ok', value: 'ok' },
|
||||
{ label: 'Cancel', value: 'cancel' }
|
||||
]
|
||||
}
|
||||
|
||||
const choice = await warpgate.buttonDialog(dialogOptions)
|
||||
|
||||
if (choice === 'ok') {
|
||||
await createEffect(tokens)
|
||||
}
|
||||
}
|
||||
|
||||
async function createEffect (tokens) {
|
||||
const icon = 'icons/magic/acid/dissolve-arm-flesh.webp'
|
||||
const effectName = 'Lingering Damage'
|
||||
for (const token of tokens) {
|
||||
const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 1, [])
|
||||
mutate.embedded.ActiveEffect['Lingering Damage'].flags.swade.expiration =
|
||||
CONFIG.SWADE.CONST.STATUS_EFFECT_EXPIRATION.StartOfTurnPrompt
|
||||
const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)
|
||||
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
||||
|
||||
async function main (tokens) {
|
||||
const tokenList = tokens.map(t => t.name).join(', ')
|
||||
const dialogOptions = {
|
||||
title: 'Protection',
|
||||
content: `Apply <em>Protection</em> to ${tokenList}`,
|
||||
default: 'cancel',
|
||||
buttons: [
|
||||
{ label: 'Apply (+2 armor)', value: 'apply' },
|
||||
{ label: 'Apply with raise (+2 toughness)', value: 'raise' },
|
||||
{ label: 'Cancel', value: 'cancel' }
|
||||
]
|
||||
}
|
||||
|
||||
const choice = await warpgate.buttonDialog(dialogOptions)
|
||||
|
||||
if (choice && choice !== 'cancel') {
|
||||
await createEffect(tokens, choice)
|
||||
}
|
||||
}
|
||||
|
||||
async function createEffect (tokens, choice) {
|
||||
const baseEffect = CONFIG.statusEffects.find(se => se.label === 'SWADE.Protection')
|
||||
const changes = [
|
||||
{
|
||||
key: 'system.stats.toughness.armor',
|
||||
mode: foundry.CONST.ACTIVE_EFFECT_MODES.UPGRADE,
|
||||
value: 2,
|
||||
priority: 0
|
||||
}
|
||||
]
|
||||
let effectName = 'minor Protection'
|
||||
if (choice === 'raise') {
|
||||
changes[0].key = 'system.stats.toughness.value'
|
||||
effectName = 'major Protection'
|
||||
}
|
||||
for (const token of tokens) {
|
||||
const mutate = swadeMBHelpers.createMutationWithEffect(
|
||||
baseEffect.icon, effectName, 5, changes)
|
||||
mutate.embedded.ActiveEffect[effectName].flags.core = { statusId: baseEffect.id }
|
||||
const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)
|
||||
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
new Dialog({
|
||||
title: 'Damage Roll Configuration',
|
||||
content: `
|
||||
<form>
|
||||
<div class="form-group">
|
||||
<label>Damage Roll:</label>
|
||||
<input type="text" name="damageRoll" value="2d4x" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>AP:</label>
|
||||
<input type="number" name="ap" value="0" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Flavor:</label>
|
||||
<input type="text" name="flavor" value="" />
|
||||
</div>
|
||||
</form>
|
||||
`,
|
||||
buttons: {
|
||||
ok: {
|
||||
label: 'Roll Damage',
|
||||
callback: (html) => {
|
||||
const damageRoll = html.find('input[name="damageRoll"]').val()
|
||||
let flavor = html.find('input[name="flavor"]').val()
|
||||
const ap = parseInt(html.find('input[name="ap"]').val()) || 0
|
||||
const options = {}
|
||||
if (ap > 0) {
|
||||
flavor = `${flavor ? flavor + ' - ' : ''}AP: ${ap}`
|
||||
options.ap = ap
|
||||
}
|
||||
// Perform the damage roll and send the message
|
||||
new CONFIG.Dice.DamageRoll(damageRoll, null, options).toMessage({ flavor })
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
label: 'Cancel'
|
||||
}
|
||||
}
|
||||
}).render(true)
|
||||
@@ -1,58 +0,0 @@
|
||||
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
||||
|
||||
async function main (tokens) {
|
||||
const tokenList = tokens.map(t => t.name).join(', ')
|
||||
const dialogOptions = {
|
||||
title: 'Shroud',
|
||||
content: `Apply <em>Shroud</em> to ${tokenList}`,
|
||||
default: 'cancel',
|
||||
buttons: [
|
||||
{ label: 'OK', value: 'ok' },
|
||||
{ label: 'Mutate token lighting', value: 'mutate' },
|
||||
{ label: 'Cancel', value: 'cancel' }
|
||||
]
|
||||
}
|
||||
|
||||
const choice = await warpgate.buttonDialog(dialogOptions)
|
||||
|
||||
if (choice === 'ok' || choice === 'mutate') {
|
||||
await createEffect(tokens, choice)
|
||||
}
|
||||
}
|
||||
|
||||
async function createEffect (tokens, choice) {
|
||||
const icon = 'icons/magic/perception/silhouette-stealth-shadow.webp'
|
||||
const effectName = 'Shroud'
|
||||
for (const token of tokens) {
|
||||
const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, [])
|
||||
const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)
|
||||
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
||||
if (choice === 'mutate') {
|
||||
const mutate2 = {
|
||||
token: {
|
||||
light: {
|
||||
alpha: 0.5,
|
||||
angle: 360,
|
||||
attenuation: 0.1,
|
||||
animation: {
|
||||
intensity: 5,
|
||||
reverse: false,
|
||||
speed: 5,
|
||||
type: 'roiling'
|
||||
},
|
||||
bright: 0,
|
||||
color: null,
|
||||
coloration: 0,
|
||||
contrast: 0,
|
||||
dim: 0.1,
|
||||
luminosity: -0.15,
|
||||
saturation: 0,
|
||||
shadows: 0.25
|
||||
}
|
||||
}
|
||||
}
|
||||
mutateOptions.permanent = false
|
||||
await warpgate.mutate(token.document, mutate2, {}, mutateOptions)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
||||
|
||||
async function main (tokens) {
|
||||
const tokenList = tokens.map(t => t.name).join(', ')
|
||||
const menuOptions = {
|
||||
title: 'Smite',
|
||||
defaultButton: 'Cancel',
|
||||
options: {}
|
||||
}
|
||||
|
||||
const menuData = {
|
||||
inputs: [
|
||||
{ type: 'header', label: 'Smite' },
|
||||
{ type: 'info', label: `Apply Smite to ${tokenList}` },
|
||||
{ type: 'checkbox', label: 'Greater', options: false }
|
||||
],
|
||||
buttons: [
|
||||
{ label: 'Apply', value: 'apply' },
|
||||
{ label: 'Apply with Raise', value: 'raise' },
|
||||
{ label: 'Cancel', value: 'cancel' }
|
||||
]
|
||||
}
|
||||
|
||||
const tokenWeapons = {}
|
||||
let index = 2
|
||||
for (const token of tokens) {
|
||||
index += 2
|
||||
tokenWeapons[token.id] = index
|
||||
menuData.inputs.push({ type: 'info', label: `<h2>${token.name}</h2>` })
|
||||
const weapons = token.actor.items.filter(i => i.type === 'weapon').map(
|
||||
i => { return { value: i.name, html: i.name } })
|
||||
weapons.unshift({ value: '', html: '<i>None</i>' })
|
||||
menuData.inputs.push({ type: 'select', label: token.name, options: weapons })
|
||||
}
|
||||
const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)
|
||||
for (const tokenId in tokenWeapons) {
|
||||
tokenWeapons[tokenId] = inputs[tokenWeapons[tokenId]]
|
||||
}
|
||||
const greater = (inputs[2] === 'Greater')
|
||||
if (buttons && buttons !== 'cancel') {
|
||||
await createEffect(tokens, tokenWeapons, buttons, greater)
|
||||
}
|
||||
}
|
||||
|
||||
async function createEffect (tokens, tokenWeapons, choice, greater) {
|
||||
const baseEffect = CONFIG.statusEffects.find(se => se.label === 'SWADE.Smite')
|
||||
const effectIcon = baseEffect.icon
|
||||
let changeValue = (choice === 'raise' ? '+4' : '+2')
|
||||
if (greater) {
|
||||
changeValue = (choice === 'raise' ? '+6' : '+4')
|
||||
}
|
||||
for (const token of tokens) {
|
||||
const weaponName = tokenWeapons[token.id]
|
||||
const weaponId = token.actor.items.getName(weaponName)?.id
|
||||
const changeKey = `@Weapon{${weaponName}}[system.damage]`
|
||||
if (!weaponId) {
|
||||
continue
|
||||
}
|
||||
const effectName = `${choice === 'raise' ? 'major' : 'minor'} Smite${greater ? '(greater)' : ''} (${weaponName})`
|
||||
const changes = [
|
||||
{
|
||||
key: changeKey,
|
||||
mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD,
|
||||
value: changeValue,
|
||||
priority: 0
|
||||
}
|
||||
]
|
||||
const mutate = swadeMBHelpers.createMutationWithEffect(
|
||||
effectIcon, effectName, 5, changes)
|
||||
mutate.embedded.ActiveEffect[effectName].flags.core = { statusId: baseEffect.id }
|
||||
const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)
|
||||
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
const ACTORFOLDER = 'Summonables'
|
||||
const SUMMONICON = 'icons/magic/symbols/runes-star-orange.webp'
|
||||
|
||||
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
||||
|
||||
async function main (tokens) {
|
||||
const token = tokens[0]
|
||||
const tokenList = token.name
|
||||
const folder = swadeMBHelpers.getActorFolderByPath(ACTORFOLDER)
|
||||
const actors = swadeMBHelpers.getActorsInFolder(folder)
|
||||
const menuOptions = {
|
||||
title: 'Summon Creature',
|
||||
defaultButton: 'cancel',
|
||||
options: {}
|
||||
}
|
||||
const menuData = {
|
||||
inputs: [
|
||||
{ type: 'header', label: 'Summon Creature' },
|
||||
{ type: 'info', label: `${tokenList} is summoning` },
|
||||
{
|
||||
type: 'select',
|
||||
label: 'Ally to summon',
|
||||
options: Object.keys(actors).sort().map(k => { return { value: actors[k].id, html: k } })
|
||||
},
|
||||
{ type: 'number', label: 'Number to spawn (+half base cost per)', options: 1 }
|
||||
],
|
||||
buttons: [
|
||||
{ label: 'Apply', value: 'apply' },
|
||||
{ label: 'Apply with raise', value: 'raise' },
|
||||
{ label: 'Cancel', value: 'cancel' }
|
||||
]
|
||||
}
|
||||
const { buttons, inputs } = await warpgate.menu(menuData, menuOptions)
|
||||
if (buttons && buttons !== 'cancel') {
|
||||
const summonData = {
|
||||
raise: (buttons === 'raise'),
|
||||
actorId: inputs[2],
|
||||
number: inputs[3]
|
||||
}
|
||||
summonData.actor = game.actors.get(summonData.actorId)
|
||||
summonData.actorName = summonData.actor.name
|
||||
summonData.icon = summonData.actor.prototypeToken.texture.src
|
||||
summonData.token = summonData.actor.prototypeToken
|
||||
|
||||
doWork(summonData, token)
|
||||
}
|
||||
}
|
||||
|
||||
async function doWork (summonData, token) {
|
||||
console.log('Summon ', token, summonData)
|
||||
const effectName = `Summoned ${summonData.actorName} (${summonData.number})`
|
||||
const tokenEffectMutation = swadeMBHelpers.createMutationWithEffect(SUMMONICON, effectName, 5, [])
|
||||
const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)
|
||||
await warpgate.mutate(token.document, tokenEffectMutation, {}, mutateOptions)
|
||||
|
||||
const spawnOptions = {
|
||||
controllingActor: token.actor,
|
||||
duplicates: summonData.number,
|
||||
comparisonKeys: { ActiveEffect: 'label' },
|
||||
crosshairs: {
|
||||
icon: summonData.icon,
|
||||
label: `Summon ${summonData.actorName}`,
|
||||
drawOutline: false,
|
||||
rememberControlled: true
|
||||
}
|
||||
}
|
||||
const spawnMutation = {
|
||||
token: {
|
||||
actorLink: false,
|
||||
name: `${token.name}'s ${summonData.token.name}`
|
||||
}
|
||||
}
|
||||
await warpgate.spawn(summonData.actorName, spawnMutation, {}, spawnOptions)
|
||||
}
|
||||
Reference in New Issue
Block a user