set token vision macro
This commit is contained in:
parent
66ee916572
commit
d5cc256c4f
7
.gitattributes
vendored
7
.gitattributes
vendored
@ -1,5 +1,8 @@
|
||||
packs/** binary
|
||||
packs/**/_source text
|
||||
packs/**/*.ldb binary
|
||||
packs/**/MANIFEST-* binary
|
||||
packs/**/CURRENT binary
|
||||
packs/**/LOCK binary
|
||||
packs/**/LOG* binary
|
||||
*.webp filter=lfs diff=lfs merge=lfs -text
|
||||
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
||||
*.jpg filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Added
|
||||
|
||||
- New Macro: Set token vision
|
||||
- New Common Action: Illumination (for the darkness penalty effects)
|
||||
- New macro: Quick Damage Roll
|
||||
- New Vision mode: Low Light Vision
|
||||
- Power Effect for Zombie
|
||||
|
||||
115
macros/setTokenVision.js
Normal file
115
macros/setTokenVision.js
Normal file
@ -0,0 +1,115 @@
|
||||
const argBright = typeof args === 'undefined' ? null : args.length > 0 ? args[0] : null
|
||||
// argument can be one of 'bright', 'dim', 'dark', 'pitchdark'. Other values
|
||||
// will guess based on scene darkness
|
||||
const BRIGHT_LEVELS = ['bright', 'dim', 'dark', 'pitchdark']
|
||||
const THRESHOLDS = {
|
||||
dim: 0.4,
|
||||
dark: 0.6,
|
||||
pitchdark: 0.8
|
||||
}
|
||||
const RANGES = {
|
||||
basic: {
|
||||
bright: 25,
|
||||
dim: 25,
|
||||
dark: 10,
|
||||
pitchdark: 0
|
||||
},
|
||||
lowlight: {
|
||||
bright: 25,
|
||||
dim: 25,
|
||||
dark: 10,
|
||||
pitchdark: 0
|
||||
},
|
||||
darkvision: {
|
||||
bright: 25,
|
||||
dim: 25,
|
||||
dark: 10,
|
||||
pitchdark: 10
|
||||
},
|
||||
nightvision: {
|
||||
bright: 200,
|
||||
dim: 200,
|
||||
dark: 200,
|
||||
pitchdark: 200
|
||||
}
|
||||
}
|
||||
const SIGHT_NAMES = {
|
||||
lowlight: 'low-light-vision',
|
||||
darkvision: 'darkvision',
|
||||
nightvision: 'night-vision'
|
||||
}
|
||||
const SIGHT_MODES = {
|
||||
lowlight: 'lowlight',
|
||||
darkvision: 'darkvision',
|
||||
nightvision: 'darkvision',
|
||||
basic: 'basic'
|
||||
}
|
||||
|
||||
function findAbility (token, swid) {
|
||||
return token.actor.items.find(i => i.type === 'ability' && i.system.swid === swid)
|
||||
}
|
||||
|
||||
async function main () {
|
||||
const scene = game.scenes.current
|
||||
let sceneBright = BRIGHT_LEVELS[0]
|
||||
if (scene.darkness > THRESHOLDS.pitchdark) {
|
||||
sceneBright = BRIGHT_LEVELS[3]
|
||||
} else if (scene.darkness > THRESHOLDS.dark) {
|
||||
sceneBright = BRIGHT_LEVELS[2]
|
||||
} else if (scene.darkness > THRESHOLDS.dim) {
|
||||
sceneBright = BRIGHT_LEVELS[1]
|
||||
}
|
||||
let bright = sceneBright
|
||||
if (argBright && BRIGHT_LEVELS.includes(argBright)) {
|
||||
bright = argBright
|
||||
}
|
||||
const menuData = {
|
||||
inputs: [
|
||||
{ type: 'radio', label: 'Bright Light', options: ['bright', bright === BRIGHT_LEVELS[0]] },
|
||||
{ type: 'radio', label: 'Dim Light', options: ['bright', bright === BRIGHT_LEVELS[1]] },
|
||||
{ type: 'radio', label: 'Dark', options: ['bright', bright === BRIGHT_LEVELS[2]] },
|
||||
{ type: 'radio', label: 'Pitch Dark', options: ['bright', bright === BRIGHT_LEVELS[3]] }
|
||||
],
|
||||
buttons: [
|
||||
{ label: 'Select Scene Brightness', value: 'ok', default: true },
|
||||
{ label: 'Cancel', value: 'cancel' }
|
||||
]
|
||||
}
|
||||
const menuConfig = { title: 'Select scene brightness' }
|
||||
const result = await warpgate.menu(menuData, menuConfig)
|
||||
if (result.buttons !== 'ok') { return }
|
||||
|
||||
for (let i = 0; i < 4; i++) {
|
||||
if (result.inputs[i]) { bright = BRIGHT_LEVELS[i] }
|
||||
}
|
||||
|
||||
for (const tokenId of scene.tokens.map(t => t.id)) {
|
||||
const token = scene.tokens.get(tokenId)
|
||||
if (!token.sight.enabled) {
|
||||
console.log(`Skipping ${token.name}, vision not enabled`)
|
||||
continue
|
||||
// don't set sight on a token where it's not enabled
|
||||
}
|
||||
let sightType = 'basic'
|
||||
for (const sight in SIGHT_NAMES) {
|
||||
if (findAbility(token, SIGHT_NAMES[sight])) {
|
||||
sightType = sight
|
||||
}
|
||||
}
|
||||
const range = RANGES[sightType][bright]
|
||||
const sightMode = SIGHT_MODES[sightType]
|
||||
const visionModeData = CONFIG.Canvas.visionModes[sightMode].vision.defaults
|
||||
const data = {
|
||||
'sight.range': range,
|
||||
'sight.visionMode': sightMode,
|
||||
'sight.attenuation': visionModeData.attenuation,
|
||||
'sight.brightness': visionModeData.brightness,
|
||||
'sight.saturation': visionModeData.saturation,
|
||||
'sight.contrast': visionModeData.contrast
|
||||
}
|
||||
console.log(`Updating ${token.name}:`, sightType, bright, data)
|
||||
await token.update(data)
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
2023/12/18-15:37:09.644182 7f63a67bd700 Delete type=3 #1
|
||||
2023/12/18-15:37:09.646809 7f63a5542700 Level-0 table #5: started
|
||||
2023/12/18-15:37:09.654066 7f63a5542700 Level-0 table #5: 11401 bytes OK
|
||||
2023/12/18-15:37:09.663437 7f63a5542700 Delete type=0 #3
|
||||
2023/12/18-15:37:09.663538 7f63a5542700 Manual compaction at level-0 from '!folders!0nDRFmMBs5DBJU9M' @ 72057594037927935 : 1 .. '!items!xA7qKMmugJv7z6j1' @ 0 : 0; will stop at (end)
|
||||
2023/12/18-23:38:01.173251 7fb80df3c700 Delete type=3 #1
|
||||
2023/12/18-23:38:01.175935 7fb80d481700 Level-0 table #5: started
|
||||
2023/12/18-23:38:01.183313 7fb80d481700 Level-0 table #5: 12215 bytes OK
|
||||
2023/12/18-23:38:01.192571 7fb80d481700 Delete type=0 #3
|
||||
2023/12/18-23:38:01.192679 7fb80d481700 Manual compaction at level-0 from '!folders!0nDRFmMBs5DBJU9M' @ 72057594037927935 : 1 .. '!items.effects!RC1Nz6iph8wPPK1B.g9W5hJisq3MsCpZW' @ 0 : 0; will stop at (end)
|
||||
|
||||
Binary file not shown.
156
packs/common-actions/_source/Illumination_RC1Nz6iph8wPPK1B.json
Normal file
156
packs/common-actions/_source/Illumination_RC1Nz6iph8wPPK1B.json
Normal file
@ -0,0 +1,156 @@
|
||||
{
|
||||
"folder": null,
|
||||
"name": "Illumination",
|
||||
"type": "action",
|
||||
"img": "icons/magic/light/explosion-star-blue-large.webp",
|
||||
"system": {
|
||||
"description": "",
|
||||
"notes": "",
|
||||
"source": "",
|
||||
"swid": "lighting",
|
||||
"additionalStats": {},
|
||||
"favorite": false,
|
||||
"category": "Savage Pathfinder",
|
||||
"templates": {
|
||||
"cone": false,
|
||||
"stream": false,
|
||||
"small": false,
|
||||
"medium": false,
|
||||
"large": false
|
||||
},
|
||||
"actions": {
|
||||
"trait": "",
|
||||
"traitMod": "",
|
||||
"dmgMod": "",
|
||||
"additional": {}
|
||||
}
|
||||
},
|
||||
"effects": [
|
||||
{
|
||||
"name": "Dim Lighting",
|
||||
"icon": "icons/magic/light/light-lantern-lit-white.webp",
|
||||
"changes": [
|
||||
{
|
||||
"key": "system.stats.globalMods.trait",
|
||||
"mode": 2,
|
||||
"value": "-2",
|
||||
"priority": null
|
||||
}
|
||||
],
|
||||
"transfer": true,
|
||||
"_id": "fpSigRcCCADmisXP",
|
||||
"disabled": true,
|
||||
"duration": {
|
||||
"startTime": 0,
|
||||
"seconds": null,
|
||||
"combat": "bLRI8G4dAxvCnqbC",
|
||||
"rounds": null,
|
||||
"turns": null,
|
||||
"startRound": null,
|
||||
"startTurn": null
|
||||
},
|
||||
"description": "",
|
||||
"origin": null,
|
||||
"statuses": [],
|
||||
"flags": {
|
||||
"swade": {
|
||||
"favorite": true,
|
||||
"expiration": null,
|
||||
"loseTurnOnHold": false
|
||||
}
|
||||
},
|
||||
"tint": null,
|
||||
"_key": "!items.effects!RC1Nz6iph8wPPK1B.fpSigRcCCADmisXP"
|
||||
},
|
||||
{
|
||||
"name": "Dark Lighting",
|
||||
"icon": "icons/magic/light/light-candles-lit-white.webp",
|
||||
"changes": [
|
||||
{
|
||||
"key": "system.stats.globalMods.trait",
|
||||
"mode": 2,
|
||||
"value": "-4",
|
||||
"priority": null
|
||||
}
|
||||
],
|
||||
"transfer": true,
|
||||
"_id": "g9W5hJisq3MsCpZW",
|
||||
"disabled": true,
|
||||
"duration": {
|
||||
"startTime": 0,
|
||||
"seconds": null,
|
||||
"combat": "bLRI8G4dAxvCnqbC",
|
||||
"rounds": null,
|
||||
"turns": null,
|
||||
"startRound": null,
|
||||
"startTurn": null
|
||||
},
|
||||
"description": "",
|
||||
"origin": null,
|
||||
"statuses": [],
|
||||
"flags": {
|
||||
"swade": {
|
||||
"expiration": null,
|
||||
"loseTurnOnHold": false,
|
||||
"favorite": true
|
||||
}
|
||||
},
|
||||
"tint": null,
|
||||
"_key": "!items.effects!RC1Nz6iph8wPPK1B.g9W5hJisq3MsCpZW"
|
||||
},
|
||||
{
|
||||
"name": "Pitch Darkness",
|
||||
"icon": "icons/magic/unholy/barrier-shield-glowing-pink.webp",
|
||||
"changes": [
|
||||
{
|
||||
"key": "system.stats.globalMods.trait",
|
||||
"mode": 2,
|
||||
"value": "-6",
|
||||
"priority": null
|
||||
}
|
||||
],
|
||||
"transfer": true,
|
||||
"_id": "NI4hfxplfJ5pqImL",
|
||||
"disabled": true,
|
||||
"duration": {
|
||||
"startTime": 0,
|
||||
"seconds": null,
|
||||
"combat": "bLRI8G4dAxvCnqbC",
|
||||
"rounds": null,
|
||||
"turns": null,
|
||||
"startRound": null,
|
||||
"startTurn": null
|
||||
},
|
||||
"description": "",
|
||||
"origin": null,
|
||||
"statuses": [],
|
||||
"flags": {
|
||||
"swade": {
|
||||
"expiration": null,
|
||||
"loseTurnOnHold": false,
|
||||
"favorite": true
|
||||
}
|
||||
},
|
||||
"tint": null,
|
||||
"_key": "!items.effects!RC1Nz6iph8wPPK1B.NI4hfxplfJ5pqImL"
|
||||
}
|
||||
],
|
||||
"ownership": {
|
||||
"default": 0,
|
||||
"sVoCvBU1knmXzoYe": 3
|
||||
},
|
||||
"flags": {
|
||||
"core": {}
|
||||
},
|
||||
"_stats": {
|
||||
"systemId": "swade",
|
||||
"systemVersion": "3.2.5",
|
||||
"coreVersion": "11.315",
|
||||
"createdTime": 1702939897892,
|
||||
"modifiedTime": 1702960438222,
|
||||
"lastModifiedBy": "sVoCvBU1knmXzoYe"
|
||||
},
|
||||
"_id": "RC1Nz6iph8wPPK1B",
|
||||
"sort": 0,
|
||||
"_key": "!items!RC1Nz6iph8wPPK1B"
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
2023/12/18-15:37:12.778941 7fed4efbf700 Delete type=3 #1
|
||||
2023/12/18-15:37:12.781115 7fed4cfbb700 Level-0 table #5: started
|
||||
2023/12/18-15:37:12.803917 7fed4cfbb700 Level-0 table #5: 6787 bytes OK
|
||||
2023/12/18-15:37:12.812861 7fed4cfbb700 Delete type=0 #3
|
||||
2023/12/18-15:37:12.812959 7fed4cfbb700 Manual compaction at level-0 from '!items!JWyBQe4tnOYljFAF' @ 72057594037927935 : 1 .. '!items!tWWSfEMmLmws6Yb1' @ 0 : 0; will stop at (end)
|
||||
2023/12/18-23:38:02.394612 7fa8daffd700 Delete type=3 #1
|
||||
2023/12/18-23:38:02.397080 7fa8d9d82700 Level-0 table #5: started
|
||||
2023/12/18-23:38:02.404288 7fa8d9d82700 Level-0 table #5: 6787 bytes OK
|
||||
2023/12/18-23:38:02.413227 7fa8d9d82700 Delete type=0 #3
|
||||
2023/12/18-23:38:02.413348 7fa8d9d82700 Manual compaction at level-0 from '!items!JWyBQe4tnOYljFAF' @ 72057594037927935 : 1 .. '!items!tWWSfEMmLmws6Yb1' @ 0 : 0; will stop at (end)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
2023/12/18-15:37:14.322677 7f3e267fc700 Delete type=3 #1
|
||||
2023/12/18-15:37:14.324789 7f3e25ffb700 Level-0 table #5: started
|
||||
2023/12/18-15:37:14.331866 7f3e25ffb700 Level-0 table #5: 1751 bytes OK
|
||||
2023/12/18-15:37:14.340858 7f3e25ffb700 Delete type=0 #3
|
||||
2023/12/18-15:37:14.340981 7f3e25ffb700 Manual compaction at level-0 from '!actors!U5v4gFHquo0Y1SAq' @ 72057594037927935 : 1 .. '!actors!U5v4gFHquo0Y1SAq' @ 0 : 0; will stop at (end)
|
||||
2023/12/18-23:38:03.189021 7f306ffff700 Delete type=3 #1
|
||||
2023/12/18-23:38:03.191864 7f306e7fc700 Level-0 table #5: started
|
||||
2023/12/18-23:38:03.198720 7f306e7fc700 Level-0 table #5: 1751 bytes OK
|
||||
2023/12/18-23:38:03.207506 7f306e7fc700 Delete type=0 #3
|
||||
2023/12/18-23:38:03.207610 7f306e7fc700 Manual compaction at level-0 from '!actors!U5v4gFHquo0Y1SAq' @ 72057594037927935 : 1 .. '!actors!U5v4gFHquo0Y1SAq' @ 0 : 0; will stop at (end)
|
||||
|
||||
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
2023/12/18-15:37:18.058346 7f04d3fff700 Delete type=3 #1
|
||||
2023/12/18-15:37:18.060818 7f04d1d82700 Level-0 table #5: started
|
||||
2023/12/18-15:37:18.070119 7f04d1d82700 Level-0 table #5: 10218 bytes OK
|
||||
2023/12/18-15:37:18.078948 7f04d1d82700 Delete type=0 #3
|
||||
2023/12/18-15:37:18.079042 7f04d1d82700 Manual compaction at level-0 from '!folders!hIbrWxg1nDutCSwt' @ 72057594037927935 : 1 .. '!macros!wU2mAUnw3RW9qMT8' @ 0 : 0; will stop at (end)
|
||||
2023/12/18-23:38:03.938107 7f566efbe700 Delete type=3 #1
|
||||
2023/12/18-23:38:03.940484 7f566d542700 Level-0 table #5: started
|
||||
2023/12/18-23:38:03.948092 7f566d542700 Level-0 table #5: 12050 bytes OK
|
||||
2023/12/18-23:38:03.956941 7f566d542700 Delete type=0 #3
|
||||
2023/12/18-23:38:03.957060 7f566d542700 Manual compaction at level-0 from '!folders!hIbrWxg1nDutCSwt' @ 72057594037927935 : 1 .. '!macros!wU2mAUnw3RW9qMT8' @ 0 : 0; will stop at (end)
|
||||
|
||||
Binary file not shown.
@ -26,14 +26,14 @@
|
||||
},
|
||||
"_stats": {
|
||||
"systemId": "swade",
|
||||
"systemVersion": "3.2.2",
|
||||
"systemVersion": "3.2.5",
|
||||
"coreVersion": "11.315",
|
||||
"createdTime": 1680966567327,
|
||||
"modifiedTime": 1700436589221,
|
||||
"lastModifiedBy": "R9ZgY0IvWl8ovIuT"
|
||||
"modifiedTime": 1702959790712,
|
||||
"lastModifiedBy": "sVoCvBU1knmXzoYe"
|
||||
},
|
||||
"folder": null,
|
||||
"sort": 300000,
|
||||
"sort": 600000,
|
||||
"_id": "QMnx9cuyw81kRS2o",
|
||||
"_key": "!macros!QMnx9cuyw81kRS2o"
|
||||
}
|
||||
|
||||
@ -15,13 +15,13 @@
|
||||
},
|
||||
"_stats": {
|
||||
"systemId": "swade",
|
||||
"systemVersion": "3.2.2",
|
||||
"systemVersion": "3.2.5",
|
||||
"coreVersion": "11.315",
|
||||
"createdTime": 1693853383361,
|
||||
"modifiedTime": 1700436589221,
|
||||
"lastModifiedBy": "R9ZgY0IvWl8ovIuT"
|
||||
"modifiedTime": 1702959790712,
|
||||
"lastModifiedBy": "sVoCvBU1knmXzoYe"
|
||||
},
|
||||
"_id": "AjuA11hQ48UJNwlH",
|
||||
"sort": 200000,
|
||||
"sort": 500000,
|
||||
"_key": "!macros!AjuA11hQ48UJNwlH"
|
||||
}
|
||||
|
||||
@ -18,10 +18,10 @@
|
||||
"systemVersion": "3.2.5",
|
||||
"coreVersion": "11.315",
|
||||
"createdTime": 1702933790652,
|
||||
"modifiedTime": 1702934856387,
|
||||
"modifiedTime": 1702959790712,
|
||||
"lastModifiedBy": "sVoCvBU1knmXzoYe"
|
||||
},
|
||||
"_id": "NANSnFATVJntUfL7",
|
||||
"sort": 0,
|
||||
"sort": 200000,
|
||||
"_key": "!macros!NANSnFATVJntUfL7"
|
||||
}
|
||||
|
||||
@ -18,10 +18,10 @@
|
||||
"systemVersion": "3.2.5",
|
||||
"coreVersion": "11.315",
|
||||
"createdTime": 1700430548162,
|
||||
"modifiedTime": 1702860052587,
|
||||
"modifiedTime": 1702959790712,
|
||||
"lastModifiedBy": "sVoCvBU1knmXzoYe"
|
||||
},
|
||||
"_id": "pnLnFrfTTJeodFRy",
|
||||
"sort": 0,
|
||||
"sort": 300000,
|
||||
"_key": "!macros!pnLnFrfTTJeodFRy"
|
||||
}
|
||||
|
||||
@ -15,13 +15,13 @@
|
||||
},
|
||||
"_stats": {
|
||||
"systemId": "swade",
|
||||
"systemVersion": "3.2.2",
|
||||
"systemVersion": "3.2.5",
|
||||
"coreVersion": "11.315",
|
||||
"createdTime": 1700430548162,
|
||||
"modifiedTime": 1700436589221,
|
||||
"lastModifiedBy": "R9ZgY0IvWl8ovIuT"
|
||||
"modifiedTime": 1702959790712,
|
||||
"lastModifiedBy": "sVoCvBU1knmXzoYe"
|
||||
},
|
||||
"_id": "G9ksuYJo1512PTo9",
|
||||
"sort": 100000,
|
||||
"sort": 400000,
|
||||
"_key": "!macros!G9ksuYJo1512PTo9"
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
2023/12/18-15:37:20.266975 7f00037bf700 Delete type=3 #1
|
||||
2023/12/18-15:37:20.269045 7f0001542700 Level-0 table #5: started
|
||||
2023/12/18-15:37:20.276064 7f0001542700 Level-0 table #5: 9796 bytes OK
|
||||
2023/12/18-15:37:20.285028 7f0001542700 Delete type=0 #3
|
||||
2023/12/18-15:37:20.285119 7f0001542700 Manual compaction at level-0 from '!journal!HbtPlHNFO1L6RVj0' @ 72057594037927935 : 1 .. '!journal.pages!YSuk1v59tLaL9XUK.BlDoYgdTxhyCBP3Y' @ 0 : 0; will stop at (end)
|
||||
2023/12/18-23:38:04.812110 7f4d227be700 Delete type=3 #1
|
||||
2023/12/18-23:38:04.814586 7f4d20fbb700 Level-0 table #5: started
|
||||
2023/12/18-23:38:04.821794 7f4d20fbb700 Level-0 table #5: 10624 bytes OK
|
||||
2023/12/18-23:38:04.830506 7f4d20fbb700 Delete type=0 #3
|
||||
2023/12/18-23:38:04.830630 7f4d20fbb700 Manual compaction at level-0 from '!journal!HbtPlHNFO1L6RVj0' @ 72057594037927935 : 1 .. '!journal.pages!YSuk1v59tLaL9XUK.BlDoYgdTxhyCBP3Y' @ 0 : 0; will stop at (end)
|
||||
|
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user