76 lines
1.8 KiB
JavaScript
76 lines
1.8 KiB
JavaScript
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: 'Cancel', value: 'cancel' }
|
|
]
|
|
}
|
|
|
|
const choice = await warpgate.buttonDialog(dialogOptions)
|
|
|
|
if (choice === 'ok') {
|
|
await createEffect(tokens)
|
|
}
|
|
}
|
|
|
|
async function createEffect (tokens) {
|
|
const icon = 'icons/magic/light/explosion-star-blue-large.webp'
|
|
const effectName = 'Glow'
|
|
for (const token of tokens) {
|
|
const effectData = {
|
|
icon,
|
|
id: effectName,
|
|
label: effectName,
|
|
duration: { rounds: 5 },
|
|
flags: {
|
|
swade: {
|
|
expiration: CONFIG.SWADE.CONST.STATUS_EFFECT_EXPIRATION.EndOfTurnPrompt,
|
|
loseTurnOnHold: true
|
|
}
|
|
}
|
|
}
|
|
// const roiling = CONFIG.Canvas.lightAnimations.roiling
|
|
const mutate = {
|
|
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
|
|
}
|
|
},
|
|
embedded: {
|
|
ActiveEffect: {
|
|
Glow: effectData
|
|
}
|
|
}
|
|
}
|
|
const mutateOptions = {
|
|
comparisonKeys: { ActiveEffect: 'label' },
|
|
name: effectName,
|
|
permanent: false,
|
|
description: effectName
|
|
}
|
|
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
|
}
|
|
}
|