1.0 release #30

Merged
mike merged 7 commits from develop into main 2023-03-07 06:20:43 +00:00
12 changed files with 306 additions and 13 deletions

View File

@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## 1.0.0
### Added
- Added Documentation and README
- Confusion effect macro
- Entangle effect macro
- Blind effect macro
- Invisiblity macro
- Intangibility macro
### Changed
- Protection and Smite macros now linked to swade system effects
## 0.9.0
- Initial 'public' release

View File

@ -1,2 +1,5 @@
# swade-mb-helpers
# SWADE Helpers (MB)
This is a series of helper macros and other helpers to help run SWADE and
Savage Pathfinder games with some minimal help remembering token state, without
going overboard on the automation.

45
macros/blind.js Normal file
View File

@ -0,0 +1,45 @@
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)
}
}

62
macros/confusion.js Normal file
View File

@ -0,0 +1,62 @@
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)
}
}

74
macros/entangle.js Normal file
View File

@ -0,0 +1,74 @@
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)
}
}

41
macros/intangibility.js Normal file
View File

@ -0,0 +1,41 @@
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)
}
}

44
macros/invisibility.js Normal file
View File

@ -0,0 +1,44 @@
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)
}
}

View File

@ -38,6 +38,7 @@ async function createEffect (tokens, choice) {
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)
}

View File

@ -45,7 +45,6 @@ async function main (tokens) {
async function createEffect (tokens, tokenWeapons, choice, greater) {
const baseEffect = CONFIG.statusEffects.find(se => se.label === 'SWADE.Smite')
const effectIcon = baseEffect.icon
const effectId = baseEffect.id
let changeValue = (choice === 'raise' ? '+4' : '+2')
if (greater) {
changeValue = (choice === 'raise' ? '+6' : '+4')
@ -68,6 +67,7 @@ async function createEffect (tokens, tokenWeapons, choice, greater) {
]
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)
}

View File

@ -3,7 +3,7 @@
"name": "SWADE Helpers (MB)",
"title": "SWADE Helpers (MB)",
"description": "Mike's collection of swade helpers",
"version": "0.9.0",
"version": "1.0.0",
"authors": [
{
"name": "Mike"

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long