diff --git a/CHANGELOG.md b/CHANGELOG.md index e598133..48f9d64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Macro: Request fear check specialization macro +- Macro: Fear Table to call the new fearTable api endpoint +- API: rulesVersion property +- API: fearTable(actor) calls the relevant premium core rules module's fear + table +- API: added requestFearRollFromTokens special helper +- Trait roll hooks for: + - Glow/Shroud + - Range modifiers + +### Changed + +- added a summary chat message for the roll results to requested rolls. +- added a target number option to requested rolls. + ## [2.3.0] 2023-12-19 ### Added diff --git a/macros/requestFearRoll.js b/macros/requestFearRoll.js new file mode 100644 index 0000000..0bc063c --- /dev/null +++ b/macros/requestFearRoll.js @@ -0,0 +1,39 @@ +const requestFearRollFromTokens = game.modules.get('swade-mb-helpers').api.requestRollFromTokens + +async function main () { + let tokens = Array.from(game.user.targets) + if (tokens.length < 1) { + tokens = canvas.tokens.controlled + } + if (tokens.length < 1) { + ui.notifications.error('Please target or select some tokens') + return + } + + const menuData = { + inputs: [ + { type: 'info', label: `Requesting Fear roll from ${tokens.map(t => t.name).join(', ')}` }, + { type: 'number', label: 'Fear Check Penalty', options: 0 } + ], + buttons: [ + { label: 'Request roll', value: 'ok', default: true }, + { label: 'Cancel', value: 'cancel' } + ] + } + const menuConfig = { + title: 'Request Fear roll...' + } + const result = await warpgate.menu(menuData, menuConfig) + + if (result.buttons !== 'ok') { + return + } + console.log(result) + const fear = result.inputs[1] || 0 + const targetNumber = 4 + const options = { targetNumber, fear } + + requestFearRollFromTokens(tokens, options) +} + +main() diff --git a/macros/requestRoll.js b/macros/requestRoll.js index 4372f1a..57aefdc 100644 --- a/macros/requestRoll.js +++ b/macros/requestRoll.js @@ -19,7 +19,8 @@ async function main () { options: [] }, { type: 'number', label: 'Roll Modifier', options: 0 }, - { type: 'text', label: 'Roll Modifier Description', options: 'Roll Modifier' } + { type: 'text', label: 'Roll Modifier Description', options: 'Roll Modifier' }, + { type: 'number', label: 'Target Number', options: 4 } ], buttons: [ { label: 'Request roll', value: 'ok', default: true }, @@ -59,7 +60,8 @@ async function main () { const rollParts = result.inputs[1].split('|') const rollType = (rollParts[0] === 'a' ? 'attribute' : 'skill') const rollDesc = rollParts[1] - const options = {} + const targetNumber = result.inputs[4] || 4 + const options = { targetNumber } if (rollMod !== 0) { options.mods = [{ label: rollModDesc, value: rollMod }] } diff --git a/packs/common-actions/CURRENT b/packs/common-actions/CURRENT index 23b73d9..1a84852 100644 --- a/packs/common-actions/CURRENT +++ b/packs/common-actions/CURRENT @@ -1 +1 @@ -MANIFEST-000014 +MANIFEST-000002 diff --git a/packs/common-actions/LOG b/packs/common-actions/LOG index d59dd93..1194ed8 100644 --- a/packs/common-actions/LOG +++ b/packs/common-actions/LOG @@ -1,3 +1,5 @@ -2023/12/19-22:11:46.585866 7f40dd7bc700 Recovering log #12 -2023/12/19-22:11:46.611108 7f40dd7bc700 Delete type=0 #12 -2023/12/19-22:11:46.611132 7f40dd7bc700 Delete type=3 #10 +2023/12/23-19:53:30.442930 7f73537bf700 Delete type=3 #1 +2023/12/23-19:53:30.445253 7f7351501700 Level-0 table #5: started +2023/12/23-19:53:30.448202 7f7351501700 Level-0 table #5: 12215 bytes OK +2023/12/23-19:53:30.451038 7f7351501700 Delete type=0 #3 +2023/12/23-19:53:30.451169 7f7351501700 Manual compaction at level-0 from '!folders!0nDRFmMBs5DBJU9M' @ 72057594037927935 : 1 .. '!items.effects!RC1Nz6iph8wPPK1B.g9W5hJisq3MsCpZW' @ 0 : 0; will stop at (end) diff --git a/packs/common-actions/LOG.old b/packs/common-actions/LOG.old deleted file mode 100644 index 8d8b6ad..0000000 --- a/packs/common-actions/LOG.old +++ /dev/null @@ -1,8 +0,0 @@ -2023/12/19-14:25:58.734016 7fb0acf3b700 Recovering log #8 -2023/12/19-14:25:58.748444 7fb0acf3b700 Delete type=3 #6 -2023/12/19-14:25:58.748474 7fb0acf3b700 Delete type=0 #8 -2023/12/19-22:08:59.600432 7fb086400700 Level-0 table #13: started -2023/12/19-22:08:59.600452 7fb086400700 Level-0 table #13: 0 bytes OK -2023/12/19-22:08:59.612412 7fb086400700 Delete type=0 #11 -2023/12/19-22:08:59.648733 7fb086400700 Manual compaction at level-0 from '!folders!0nDRFmMBs5DBJU9M' @ 72057594037927935 : 1 .. '!items.effects!RC1Nz6iph8wPPK1B.g9W5hJisq3MsCpZW' @ 0 : 0; will stop at (end) -2023/12/19-22:08:59.648868 7fb086400700 Manual compaction at level-1 from '!folders!0nDRFmMBs5DBJU9M' @ 72057594037927935 : 1 .. '!items.effects!RC1Nz6iph8wPPK1B.g9W5hJisq3MsCpZW' @ 0 : 0; will stop at (end) diff --git a/packs/common-actions/MANIFEST-000002 b/packs/common-actions/MANIFEST-000002 new file mode 100644 index 0000000..0916a64 Binary files /dev/null and b/packs/common-actions/MANIFEST-000002 differ diff --git a/packs/common-actions/MANIFEST-000014 b/packs/common-actions/MANIFEST-000014 deleted file mode 100644 index 5d83e41..0000000 Binary files a/packs/common-actions/MANIFEST-000014 and /dev/null differ diff --git a/packs/gear/CURRENT b/packs/gear/CURRENT index 23b73d9..1a84852 100644 --- a/packs/gear/CURRENT +++ b/packs/gear/CURRENT @@ -1 +1 @@ -MANIFEST-000014 +MANIFEST-000002 diff --git a/packs/gear/LOG b/packs/gear/LOG index 5eefaa0..b2a559c 100644 --- a/packs/gear/LOG +++ b/packs/gear/LOG @@ -1,3 +1,5 @@ -2023/12/19-22:11:46.716627 7f5d39ffb700 Recovering log #12 -2023/12/19-22:11:46.739685 7f5d39ffb700 Delete type=0 #12 -2023/12/19-22:11:46.739711 7f5d39ffb700 Delete type=3 #10 +2023/12/23-19:53:31.230991 7f2e1bfff700 Delete type=3 #1 +2023/12/23-19:53:31.233147 7f2e19ffb700 Level-0 table #5: started +2023/12/23-19:53:31.235972 7f2e19ffb700 Level-0 table #5: 6787 bytes OK +2023/12/23-19:53:31.238668 7f2e19ffb700 Delete type=0 #3 +2023/12/23-19:53:31.238744 7f2e19ffb700 Manual compaction at level-0 from '!items!JWyBQe4tnOYljFAF' @ 72057594037927935 : 1 .. '!items!tWWSfEMmLmws6Yb1' @ 0 : 0; will stop at (end) diff --git a/packs/gear/LOG.old b/packs/gear/LOG.old deleted file mode 100644 index 40a24c7..0000000 --- a/packs/gear/LOG.old +++ /dev/null @@ -1,8 +0,0 @@ -2023/12/19-14:25:58.761898 7fb0acf3b700 Recovering log #8 -2023/12/19-14:25:58.781218 7fb0acf3b700 Delete type=3 #6 -2023/12/19-14:25:58.781255 7fb0acf3b700 Delete type=0 #8 -2023/12/19-22:08:59.648947 7fb086400700 Level-0 table #13: started -2023/12/19-22:08:59.648972 7fb086400700 Level-0 table #13: 0 bytes OK -2023/12/19-22:08:59.658595 7fb086400700 Delete type=0 #11 -2023/12/19-22:08:59.677223 7fb086400700 Manual compaction at level-0 from '!items!JWyBQe4tnOYljFAF' @ 72057594037927935 : 1 .. '!items!tWWSfEMmLmws6Yb1' @ 0 : 0; will stop at (end) -2023/12/19-22:08:59.677310 7fb086400700 Manual compaction at level-1 from '!items!JWyBQe4tnOYljFAF' @ 72057594037927935 : 1 .. '!items!tWWSfEMmLmws6Yb1' @ 0 : 0; will stop at (end) diff --git a/packs/gear/MANIFEST-000002 b/packs/gear/MANIFEST-000002 new file mode 100644 index 0000000..aa2beac Binary files /dev/null and b/packs/gear/MANIFEST-000002 differ diff --git a/packs/gear/MANIFEST-000014 b/packs/gear/MANIFEST-000014 deleted file mode 100644 index 817e197..0000000 Binary files a/packs/gear/MANIFEST-000014 and /dev/null differ diff --git a/packs/helper-actors/CURRENT b/packs/helper-actors/CURRENT index 23b73d9..1a84852 100644 --- a/packs/helper-actors/CURRENT +++ b/packs/helper-actors/CURRENT @@ -1 +1 @@ -MANIFEST-000014 +MANIFEST-000002 diff --git a/packs/helper-actors/LOG b/packs/helper-actors/LOG index 29a0553..f057aed 100644 --- a/packs/helper-actors/LOG +++ b/packs/helper-actors/LOG @@ -1,3 +1,5 @@ -2023/12/19-22:11:46.843641 7ff2615a2700 Recovering log #12 -2023/12/19-22:11:46.864924 7ff2615a2700 Delete type=0 #12 -2023/12/19-22:11:46.864950 7ff2615a2700 Delete type=3 #10 +2023/12/23-19:53:31.842430 7f67a8d9f700 Delete type=3 #1 +2023/12/23-19:53:31.844543 7f67837fe700 Level-0 table #5: started +2023/12/23-19:53:31.847334 7f67837fe700 Level-0 table #5: 1751 bytes OK +2023/12/23-19:53:31.850174 7f67837fe700 Delete type=0 #3 +2023/12/23-19:53:31.850251 7f67837fe700 Manual compaction at level-0 from '!actors!U5v4gFHquo0Y1SAq' @ 72057594037927935 : 1 .. '!actors!U5v4gFHquo0Y1SAq' @ 0 : 0; will stop at (end) diff --git a/packs/helper-actors/LOG.old b/packs/helper-actors/LOG.old deleted file mode 100644 index 73332a3..0000000 --- a/packs/helper-actors/LOG.old +++ /dev/null @@ -1,8 +0,0 @@ -2023/12/19-14:25:58.750811 7fb087fff700 Recovering log #8 -2023/12/19-14:25:58.759586 7fb087fff700 Delete type=3 #6 -2023/12/19-14:25:58.759616 7fb087fff700 Delete type=0 #8 -2023/12/19-22:08:59.612497 7fb086400700 Level-0 table #13: started -2023/12/19-22:08:59.612518 7fb086400700 Level-0 table #13: 0 bytes OK -2023/12/19-22:08:59.622048 7fb086400700 Delete type=0 #11 -2023/12/19-22:08:59.648768 7fb086400700 Manual compaction at level-0 from '!actors!U5v4gFHquo0Y1SAq' @ 72057594037927935 : 1 .. '!actors!U5v4gFHquo0Y1SAq' @ 0 : 0; will stop at (end) -2023/12/19-22:08:59.648884 7fb086400700 Manual compaction at level-1 from '!actors!U5v4gFHquo0Y1SAq' @ 72057594037927935 : 1 .. '!actors!U5v4gFHquo0Y1SAq' @ 0 : 0; will stop at (end) diff --git a/packs/helper-actors/MANIFEST-000002 b/packs/helper-actors/MANIFEST-000002 new file mode 100644 index 0000000..e01a079 Binary files /dev/null and b/packs/helper-actors/MANIFEST-000002 differ diff --git a/packs/helper-actors/MANIFEST-000014 b/packs/helper-actors/MANIFEST-000014 deleted file mode 100644 index cf98f38..0000000 Binary files a/packs/helper-actors/MANIFEST-000014 and /dev/null differ diff --git a/packs/helper-macros/000005.ldb b/packs/helper-macros/000005.ldb index 4f5464a..a77123e 100644 Binary files a/packs/helper-macros/000005.ldb and b/packs/helper-macros/000005.ldb differ diff --git a/packs/helper-macros/CURRENT b/packs/helper-macros/CURRENT index 23b73d9..1a84852 100644 --- a/packs/helper-macros/CURRENT +++ b/packs/helper-macros/CURRENT @@ -1 +1 @@ -MANIFEST-000014 +MANIFEST-000002 diff --git a/packs/helper-macros/LOG b/packs/helper-macros/LOG index 948bac9..4632a61 100644 --- a/packs/helper-macros/LOG +++ b/packs/helper-macros/LOG @@ -1,3 +1,5 @@ -2023/12/19-22:11:46.967222 7fb6ee7bf700 Recovering log #12 -2023/12/19-22:11:46.993517 7fb6ee7bf700 Delete type=0 #12 -2023/12/19-22:11:46.993540 7fb6ee7bf700 Delete type=3 #10 +2023/12/23-19:53:32.597429 7efcc4fbd700 Delete type=3 #1 +2023/12/23-19:53:32.599577 7efcc3fbb700 Level-0 table #5: started +2023/12/23-19:53:32.602517 7efcc3fbb700 Level-0 table #5: 13110 bytes OK +2023/12/23-19:53:32.605253 7efcc3fbb700 Delete type=0 #3 +2023/12/23-19:53:32.605331 7efcc3fbb700 Manual compaction at level-0 from '!folders!hIbrWxg1nDutCSwt' @ 72057594037927935 : 1 .. '!macros!wU2mAUnw3RW9qMT8' @ 0 : 0; will stop at (end) diff --git a/packs/helper-macros/LOG.old b/packs/helper-macros/LOG.old deleted file mode 100644 index eb01f08..0000000 --- a/packs/helper-macros/LOG.old +++ /dev/null @@ -1,8 +0,0 @@ -2023/12/19-14:25:58.719315 7fb087fff700 Recovering log #8 -2023/12/19-14:25:58.732527 7fb087fff700 Delete type=3 #6 -2023/12/19-14:25:58.732555 7fb087fff700 Delete type=0 #8 -2023/12/19-22:08:59.638378 7fb086400700 Level-0 table #13: started -2023/12/19-22:08:59.638400 7fb086400700 Level-0 table #13: 0 bytes OK -2023/12/19-22:08:59.648647 7fb086400700 Delete type=0 #11 -2023/12/19-22:08:59.648837 7fb086400700 Manual compaction at level-0 from '!folders!hIbrWxg1nDutCSwt' @ 72057594037927935 : 1 .. '!macros!wU2mAUnw3RW9qMT8' @ 0 : 0; will stop at (end) -2023/12/19-22:08:59.677175 7fb086400700 Manual compaction at level-1 from '!folders!hIbrWxg1nDutCSwt' @ 72057594037927935 : 1 .. '!macros!wU2mAUnw3RW9qMT8' @ 0 : 0; will stop at (end) diff --git a/packs/helper-macros/MANIFEST-000002 b/packs/helper-macros/MANIFEST-000002 new file mode 100644 index 0000000..cedf5a9 Binary files /dev/null and b/packs/helper-macros/MANIFEST-000002 differ diff --git a/packs/helper-macros/MANIFEST-000014 b/packs/helper-macros/MANIFEST-000014 deleted file mode 100644 index ee8985e..0000000 Binary files a/packs/helper-macros/MANIFEST-000014 and /dev/null differ diff --git a/packs/helper-macros/_source/Fear_Table_S6HY6RqjPTt0z0yY.json b/packs/helper-macros/_source/Fear_Table_S6HY6RqjPTt0z0yY.json new file mode 100644 index 0000000..dae40e3 --- /dev/null +++ b/packs/helper-macros/_source/Fear_Table_S6HY6RqjPTt0z0yY.json @@ -0,0 +1,25 @@ +{ + "name": "Fear Table", + "type": "script", + "_id": "S6HY6RqjPTt0z0yY", + "author": "sVoCvBU1knmXzoYe", + "img": "icons/magic/death/undead-ghost-scream-teal.webp", + "scope": "global", + "command": "game.modules.get('swade-mb-helpers').api.fearTable(actor)", + "folder": null, + "sort": 0, + "ownership": { + "default": 0, + "sVoCvBU1knmXzoYe": 3 + }, + "flags": {}, + "_stats": { + "systemId": "swade", + "systemVersion": "3.2.5", + "coreVersion": "11.315", + "createdTime": 1703096862424, + "modifiedTime": 1703096940207, + "lastModifiedBy": "sVoCvBU1knmXzoYe" + }, + "_key": "!macros!S6HY6RqjPTt0z0yY" +} diff --git a/packs/helper-macros/_source/Request_Fear_Check_qQLM79NpAuilKFrh.json b/packs/helper-macros/_source/Request_Fear_Check_qQLM79NpAuilKFrh.json new file mode 100644 index 0000000..3077ea9 --- /dev/null +++ b/packs/helper-macros/_source/Request_Fear_Check_qQLM79NpAuilKFrh.json @@ -0,0 +1,25 @@ +{ + "name": "Request Fear Check", + "type": "script", + "_id": "qQLM79NpAuilKFrh", + "author": "sVoCvBU1knmXzoYe", + "img": "icons/magic/death/skull-energy-light-white.webp", + "scope": "global", + "command": "const requestFearRollFromTokens = game.modules.get('swade-mb-helpers').api.requestFearRollFromTokens\n\nasync function main () {\n let tokens = Array.from(game.user.targets)\n if (tokens.length < 1) {\n tokens = canvas.tokens.controlled\n }\n if (tokens.length < 1) {\n ui.notifications.error('Please target or select some tokens')\n return\n }\n\n const menuData = {\n inputs: [\n { type: 'info', label: `Requesting Fear roll from ${tokens.map(t => t.name).join(', ')}` },\n { type: 'number', label: 'Fear Check Penalty', options: 0 }\n ],\n buttons: [\n { label: 'Request roll', value: 'ok', default: true },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n const menuConfig = {\n title: 'Request Fear roll...'\n }\n const result = await warpgate.menu(menuData, menuConfig)\n\n if (result.buttons !== 'ok') {\n return\n }\n console.log(result)\n const fear = result.inputs[1] || 0\n const targetNumber = 4\n const options = { targetNumber, fear }\n\n requestFearRollFromTokens(tokens, options)\n}\n\nmain()", + "folder": null, + "sort": 0, + "ownership": { + "default": 0, + "sVoCvBU1knmXzoYe": 3 + }, + "flags": {}, + "_stats": { + "systemId": "swade", + "systemVersion": "3.2.5", + "coreVersion": "11.315", + "createdTime": 1703356535979, + "modifiedTime": 1703357189587, + "lastModifiedBy": "sVoCvBU1knmXzoYe" + }, + "_key": "!macros!qQLM79NpAuilKFrh" +} diff --git a/packs/helper-macros/_source/Request_Notice_Roll_pnLnFrfTTJeodFRy.json b/packs/helper-macros/_source/Request_Notice_Roll_pnLnFrfTTJeodFRy.json index 56853b4..5b43ad5 100644 --- a/packs/helper-macros/_source/Request_Notice_Roll_pnLnFrfTTJeodFRy.json +++ b/packs/helper-macros/_source/Request_Notice_Roll_pnLnFrfTTJeodFRy.json @@ -4,7 +4,7 @@ "scope": "global", "author": "sVoCvBU1knmXzoYe", "img": "icons/sundries/gaming/dice-pair-white-green.webp", - "command": "const requestRollFromTokens = game.modules.get('swade-mb-helpers').api.requestRollFromTokens\n\nconst traitName = 'Notice'\nconst traitType = 'skill' // or 'attribute'\n\nasync function main () {\n let tokens = Array.from(game.user.targets)\n if (tokens.length < 1) {\n tokens = canvas.tokens.controlled\n }\n if (tokens.length < 1) {\n ui.notifications.error('Please target or select some tokens')\n return\n }\n\n const menuData = {\n inputs: [\n { type: 'info', label: `Requesting roll from ${tokens.map(t => t.name).join(', ')}` },\n {\n type: 'info',\n label: `Requesting a ${traitName} roll`\n },\n { type: 'number', label: 'Roll Modifier', options: 0 },\n { type: 'text', label: 'Roll Modifier Description', options: 'Roll Modifier' }\n ],\n buttons: [\n { label: 'Request roll', value: 'ok', default: true },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n const menuConfig = {\n title: `Request ${traitName} roll...`\n }\n const result = await warpgate.menu(menuData, menuConfig)\n\n if (result.buttons !== 'ok') {\n return\n }\n console.log(result)\n const rollMod = result.inputs[2]\n const rollModDesc = result.inputs[3]\n const rollType = traitType\n const rollDesc = traitName\n const options = {}\n if (rollMod !== 0) {\n options.mods = [{ label: rollModDesc, value: rollMod }]\n }\n\n requestRollFromTokens(tokens, rollType, rollDesc, options)\n}\n\nmain()", + "command": "const requestRollFromTokens = game.modules.get('swade-mb-helpers').api.requestRollFromTokens\n\nconst traitName = 'Notice'\nconst traitType = 'skill' // or 'attribute'\n\nasync function main () {\n let tokens = Array.from(game.user.targets)\n if (tokens.length < 1) {\n tokens = canvas.tokens.controlled\n }\n if (tokens.length < 1) {\n ui.notifications.error('Please target or select some tokens')\n return\n }\n\n const menuData = {\n inputs: [\n { type: 'info', label: `Requesting roll from ${tokens.map(t => t.name).join(', ')}` },\n {\n type: 'info',\n label: `Requesting a ${traitName} roll`\n },\n { type: 'number', label: 'Roll Modifier', options: 0 },\n { type: 'text', label: 'Roll Modifier Description', options: 'Roll Modifier' },\n { type: 'number', label: 'Target Number', options: 4 },\n ],\n buttons: [\n { label: 'Request roll', value: 'ok', default: true },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n const menuConfig = {\n title: `Request ${traitName} roll...`\n }\n const result = await warpgate.menu(menuData, menuConfig)\n\n if (result.buttons !== 'ok') {\n return\n }\n console.log(result)\n const rollMod = result.inputs[2]\n const rollModDesc = result.inputs[3]\n const rollType = traitType\n const rollDesc = traitName\n const targetNumber = result.inputs[4] || 4\n const options = {targetNumber}\n if (rollMod !== 0) {\n options.mods = [{ label: rollModDesc, value: rollMod }]\n }\n\n requestRollFromTokens(tokens, rollType, rollDesc, options)\n}\n\nmain()", "folder": null, "ownership": { "default": 0, @@ -18,7 +18,7 @@ "systemVersion": "3.2.5", "coreVersion": "11.315", "createdTime": 1700430548162, - "modifiedTime": 1702959790712, + "modifiedTime": 1703297741362, "lastModifiedBy": "sVoCvBU1knmXzoYe" }, "_id": "pnLnFrfTTJeodFRy", diff --git a/packs/helper-macros/_source/Request_Roll_G9ksuYJo1512PTo9.json b/packs/helper-macros/_source/Request_Roll_G9ksuYJo1512PTo9.json index 3cae153..e8f208e 100644 --- a/packs/helper-macros/_source/Request_Roll_G9ksuYJo1512PTo9.json +++ b/packs/helper-macros/_source/Request_Roll_G9ksuYJo1512PTo9.json @@ -4,7 +4,7 @@ "scope": "global", "author": "R9ZgY0IvWl8ovIuT", "img": "icons/sundries/gaming/dice-runed-tan.webp", - "command": "const requestRollFromTokens = game.modules.get('swade-mb-helpers').api.requestRollFromTokens\n\nasync function main () {\n let tokens = Array.from(game.user.targets)\n if (tokens.length < 1) {\n tokens = canvas.tokens.controlled\n }\n if (tokens.length < 1) {\n ui.notifications.error('Please target or select some tokens')\n return\n }\n\n const menuData = {\n inputs: [\n { type: 'info', label: `Requesting roll from ${tokens.map(t => t.name).join(', ')}` },\n {\n type: 'select',\n label: 'Trait to roll',\n options: []\n },\n { type: 'number', label: 'Roll Modifier', options: 0 },\n { type: 'text', label: 'Roll Modifier Description', options: 'Roll Modifier' }\n ],\n buttons: [\n { label: 'Request roll', value: 'ok', default: true },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n const menuConfig = {\n title: 'Request roll...'\n }\n for (const attribute of ['Agility', 'Smarts', 'Spirit', 'Strength', 'Vigor']) {\n menuData.inputs[1].options.push(\n { html: `Attribute | ${attribute}`, value: `a|${attribute}` }\n )\n }\n const skillSet = new Set()\n for (const token of tokens) {\n const skills = token.actor.items.filter(i => i.type === 'skill' &&\n !['Untrained', 'Unskilled Attempt'].includes(i.name))\n for (const skill of skills) {\n skillSet.add(skill.name)\n }\n }\n for (const skill of Array.from(skillSet).sort()) {\n menuData.inputs[1].options.push(\n { html: `Skill | ${skill}`, value: `s|${skill}` })\n }\n menuData.inputs[1].options.push(\n { html: 'Skill | Untrained', value: 's|NOSKILL' })\n const result = await warpgate.menu(menuData, menuConfig)\n\n if (result.buttons !== 'ok') {\n return\n }\n console.log(result)\n const rollMod = result.inputs[2]\n const rollModDesc = result.inputs[3]\n const rollParts = result.inputs[1].split('|')\n const rollType = (rollParts[0] === 'a' ? 'attribute' : 'skill')\n const rollDesc = rollParts[1]\n const options = {}\n if (rollMod !== 0) {\n options.mods = [{ label: rollModDesc, value: rollMod }]\n }\n\n requestRollFromTokens(tokens, rollType, rollDesc, options)\n}\n\nmain()", + "command": "const requestRollFromTokens = game.modules.get('swade-mb-helpers').api.requestRollFromTokens\n\nasync function main () {\n let tokens = Array.from(game.user.targets)\n if (tokens.length < 1) {\n tokens = canvas.tokens.controlled\n }\n if (tokens.length < 1) {\n ui.notifications.error('Please target or select some tokens')\n return\n }\n\n const menuData = {\n inputs: [\n { type: 'info', label: `Requesting roll from ${tokens.map(t => t.name).join(', ')}` },\n {\n type: 'select',\n label: 'Trait to roll',\n options: []\n },\n { type: 'number', label: 'Roll Modifier', options: 0 },\n { type: 'text', label: 'Roll Modifier Description', options: 'Roll Modifier' },\n { type: 'number', label: 'Target Number', options: 4 },\n ],\n buttons: [\n { label: 'Request roll', value: 'ok', default: true },\n { label: 'Cancel', value: 'cancel' }\n ]\n }\n const menuConfig = {\n title: 'Request roll...'\n }\n for (const attribute of ['Agility', 'Smarts', 'Spirit', 'Strength', 'Vigor']) {\n menuData.inputs[1].options.push(\n { html: `Attribute | ${attribute}`, value: `a|${attribute}` }\n )\n }\n const skillSet = new Set()\n for (const token of tokens) {\n const skills = token.actor.items.filter(i => i.type === 'skill' &&\n !['Untrained', 'Unskilled Attempt'].includes(i.name))\n for (const skill of skills) {\n skillSet.add(skill.name)\n }\n }\n for (const skill of Array.from(skillSet).sort()) {\n menuData.inputs[1].options.push(\n { html: `Skill | ${skill}`, value: `s|${skill}` })\n }\n menuData.inputs[1].options.push(\n { html: 'Skill | Untrained', value: 's|NOSKILL' })\n const result = await warpgate.menu(menuData, menuConfig)\n\n if (result.buttons !== 'ok') {\n return\n }\n console.log(result)\n const rollMod = result.inputs[2]\n const rollModDesc = result.inputs[3]\n const rollParts = result.inputs[1].split('|')\n const rollType = (rollParts[0] === 'a' ? 'attribute' : 'skill')\n const rollDesc = rollParts[1]\n const targetNumber = result.inputs[4] || 4\n const options = {targetNumber}\n if (rollMod !== 0) {\n options.mods = [{ label: rollModDesc, value: rollMod }]\n }\n\n requestRollFromTokens(tokens, rollType, rollDesc, options)\n}\n\nmain()", "folder": null, "ownership": { "default": 0, @@ -18,7 +18,7 @@ "systemVersion": "3.2.5", "coreVersion": "11.315", "createdTime": 1700430548162, - "modifiedTime": 1702959790712, + "modifiedTime": 1703297742414, "lastModifiedBy": "sVoCvBU1knmXzoYe" }, "_id": "G9ksuYJo1512PTo9", diff --git a/packs/module-docs/000005.ldb b/packs/module-docs/000005.ldb new file mode 100644 index 0000000..2e76e60 Binary files /dev/null and b/packs/module-docs/000005.ldb differ diff --git a/packs/module-docs/000014.ldb b/packs/module-docs/000014.ldb deleted file mode 100644 index ae757ca..0000000 Binary files a/packs/module-docs/000014.ldb and /dev/null differ diff --git a/packs/module-docs/CURRENT b/packs/module-docs/CURRENT index 42c62b6..1a84852 100644 --- a/packs/module-docs/CURRENT +++ b/packs/module-docs/CURRENT @@ -1 +1 @@ -MANIFEST-000015 +MANIFEST-000002 diff --git a/packs/module-docs/LOG b/packs/module-docs/LOG index 614cd03..8389dd1 100644 --- a/packs/module-docs/LOG +++ b/packs/module-docs/LOG @@ -1,3 +1,5 @@ -2023/12/19-22:11:47.107915 7f81967fc700 Recovering log #12 -2023/12/19-22:11:47.129799 7f81967fc700 Delete type=0 #12 -2023/12/19-22:11:47.129819 7f81967fc700 Delete type=3 #10 +2023/12/23-19:53:33.321181 7f1ac1fbd700 Delete type=3 #1 +2023/12/23-19:53:33.323246 7f1ac0fbb700 Level-0 table #5: started +2023/12/23-19:53:33.326242 7f1ac0fbb700 Level-0 table #5: 14296 bytes OK +2023/12/23-19:53:33.328910 7f1ac0fbb700 Delete type=0 #3 +2023/12/23-19:53:33.328990 7f1ac0fbb700 Manual compaction at level-0 from '!journal!HbtPlHNFO1L6RVj0' @ 72057594037927935 : 1 .. '!journal.pages!YSuk1v59tLaL9XUK.BxFgDb91dqbkO9h4' @ 0 : 0; will stop at (end) diff --git a/packs/module-docs/LOG.old b/packs/module-docs/LOG.old deleted file mode 100644 index 4fbe5e2..0000000 --- a/packs/module-docs/LOG.old +++ /dev/null @@ -1,15 +0,0 @@ -2023/12/19-14:25:58.704299 7fb0acf3b700 Recovering log #8 -2023/12/19-14:25:58.717166 7fb0acf3b700 Delete type=3 #6 -2023/12/19-14:25:58.717190 7fb0acf3b700 Delete type=0 #8 -2023/12/19-22:08:59.583949 7fb086400700 Level-0 table #13: started -2023/12/19-22:08:59.590634 7fb086400700 Level-0 table #13: 7975 bytes OK -2023/12/19-22:08:59.600142 7fb086400700 Delete type=0 #11 -2023/12/19-22:08:59.600341 7fb086400700 Manual compaction at level-0 from '!journal!HbtPlHNFO1L6RVj0' @ 72057594037927935 : 1 .. '!journal.pages!YSuk1v59tLaL9XUK.BxFgDb91dqbkO9h4' @ 0 : 0; will stop at (end) -2023/12/19-22:08:59.622125 7fb086400700 Manual compaction at level-1 from '!journal!HbtPlHNFO1L6RVj0' @ 72057594037927935 : 1 .. '!journal.pages!YSuk1v59tLaL9XUK.BxFgDb91dqbkO9h4' @ 0 : 0; will stop at '!journal.pages!YSuk1v59tLaL9XUK.BxFgDb91dqbkO9h4' @ 17 : 1 -2023/12/19-22:08:59.622154 7fb086400700 Compacting 1@1 + 1@2 files -2023/12/19-22:08:59.629116 7fb086400700 Generated table #14@1: 17 keys, 11373 bytes -2023/12/19-22:08:59.629154 7fb086400700 Compacted 1@1 + 1@2 files => 11373 bytes -2023/12/19-22:08:59.638172 7fb086400700 compacted to: files[ 0 0 1 0 0 0 0 ] -2023/12/19-22:08:59.638243 7fb086400700 Delete type=2 #5 -2023/12/19-22:08:59.638324 7fb086400700 Delete type=2 #13 -2023/12/19-22:08:59.648805 7fb086400700 Manual compaction at level-1 from '!journal.pages!YSuk1v59tLaL9XUK.BxFgDb91dqbkO9h4' @ 17 : 1 .. '!journal.pages!YSuk1v59tLaL9XUK.BxFgDb91dqbkO9h4' @ 0 : 0; will stop at (end) diff --git a/packs/module-docs/MANIFEST-000002 b/packs/module-docs/MANIFEST-000002 new file mode 100644 index 0000000..982059d Binary files /dev/null and b/packs/module-docs/MANIFEST-000002 differ diff --git a/packs/module-docs/MANIFEST-000015 b/packs/module-docs/MANIFEST-000015 deleted file mode 100644 index c554a59..0000000 Binary files a/packs/module-docs/MANIFEST-000015 and /dev/null differ diff --git a/packs/module-docs/_source/API_Documentation_Q4iS1LIiyy7acuaF.json b/packs/module-docs/_source/API_Documentation_Q4iS1LIiyy7acuaF.json index 84c8383..b070f8b 100644 --- a/packs/module-docs/_source/API_Documentation_Q4iS1LIiyy7acuaF.json +++ b/packs/module-docs/_source/API_Documentation_Q4iS1LIiyy7acuaF.json @@ -83,7 +83,7 @@ "image": {}, "text": { "format": 1, - "content": "
async function requestRollFromTokens (tokens, rollType, rollDesc, options = {})

This will request a roll from the tokens given using socketlib to request the roll from the currently logged on owner of the token.

Parameters

Options

The options object can be completely empty, but can have any or all of the following optional fields:

Returns

The return value is a list of promises which, if fulfilled, are the resulting roll objects from the token's rolls.

" + "content": "
async function requestRollFromTokens (tokens, rollType, rollDesc, options = {})

This will request a roll from the tokens given using socketlib to request the roll from the currently logged on owner of the token.

Parameters

Options

The options object can be completely empty, but can have any or all of the following optional fields:

Returns

The return value is a list of promises which, if fulfilled, are the resulting roll objects from the token's rolls.

" }, "video": { "controls": true, @@ -98,13 +98,119 @@ "flags": {}, "_stats": { "systemId": "swade", - "systemVersion": "3.2.2", + "systemVersion": "3.2.5", "coreVersion": "11.315", "createdTime": 1700439709611, - "modifiedTime": 1700440442904, - "lastModifiedBy": "R9ZgY0IvWl8ovIuT" + "modifiedTime": 1703375940967, + "lastModifiedBy": "sVoCvBU1knmXzoYe" }, "_key": "!journal.pages!Q4iS1LIiyy7acuaF.zvPWCYx402kk2hsE" + }, + { + "sort": 150000, + "name": "api.rulesVersion", + "type": "text", + "_id": "QdATvoUe4VuZrl7B", + "title": { + "show": true, + "level": 1 + }, + "image": {}, + "text": { + "format": 1, + "content": "

(property) rulesVersion

This API property gives the premium rules version that is active, preferring Savage Pathfinder over SWADE if both are active. It returns the following key depending on the active premium module, if any.

Active Module

Key

Savage Pathfinder (SWPF)

swpf

Savage Worlds Adventure Edition (SWADE)

swade

None of the above (SWADE System only)

system

" + }, + "video": { + "controls": true, + "volume": 0.5 + }, + "src": null, + "system": {}, + "ownership": { + "default": -1, + "sVoCvBU1knmXzoYe": 3 + }, + "flags": {}, + "_stats": { + "systemId": "swade", + "systemVersion": "3.2.5", + "coreVersion": "11.315", + "createdTime": 1703097132367, + "modifiedTime": 1703097639786, + "lastModifiedBy": "sVoCvBU1knmXzoYe" + }, + "_key": "!journal.pages!Q4iS1LIiyy7acuaF.QdATvoUe4VuZrl7B" + }, + { + "sort": 500000, + "name": "api.fearTable(actor)", + "type": "text", + "_id": "oOCgnw1eVGu6Uj4U", + "title": { + "show": true, + "level": 1 + }, + "image": {}, + "text": { + "format": 1, + "content": "
async function fearTable (actor)

The fear table API property is the fear table macro helper from whichever premium module is currently installed and active. If only the system is active and no core rules premium module is active, this will throw an exception.

" + }, + "video": { + "controls": true, + "volume": 0.5 + }, + "src": null, + "system": {}, + "ownership": { + "default": -1, + "sVoCvBU1knmXzoYe": 3 + }, + "flags": {}, + "_stats": { + "systemId": "swade", + "systemVersion": "3.2.5", + "coreVersion": "11.315", + "createdTime": 1703097422432, + "modifiedTime": 1703097574374, + "lastModifiedBy": "sVoCvBU1knmXzoYe" + }, + "_key": "!journal.pages!Q4iS1LIiyy7acuaF.oOCgnw1eVGu6Uj4U" + }, + { + "sort": 300000, + "name": "api.requestFearRollFromTokens", + "type": "text", + "title": { + "show": true, + "level": 1 + }, + "image": {}, + "text": { + "format": 1, + "content": "
async function requestFearRollFromTokens (tokens, options = {})

This will request a fear roll from the tokens given using socketlib to request the roll from the currently logged on owner of the token. This is a special case of requestRollFromTokens.

Parameters

Options

The options object can be completely empty, but can have any or all of the following optional fields:

Returns

The return value is a list of promises which, if fulfilled, are the resulting roll objects from the token's rolls.

" + }, + "video": { + "controls": true, + "volume": 0.5 + }, + "src": null, + "system": {}, + "ownership": { + "default": -1, + "R9ZgY0IvWl8ovIuT": 3, + "sVoCvBU1knmXzoYe": 3 + }, + "flags": {}, + "_stats": { + "systemId": "swade", + "systemVersion": "3.2.5", + "coreVersion": "11.315", + "createdTime": 1700439709611, + "modifiedTime": 1703375850704, + "lastModifiedBy": "sVoCvBU1knmXzoYe" + }, + "_id": "J0HiPqdHqM27gwUw", + "_key": "!journal.pages!Q4iS1LIiyy7acuaF.J0HiPqdHqM27gwUw" } ], "folder": null, @@ -117,11 +223,11 @@ }, "_stats": { "systemId": "swade", - "systemVersion": "3.2.2", + "systemVersion": "3.2.5", "coreVersion": "11.315", "createdTime": 1700438778794, - "modifiedTime": 1700440473945, - "lastModifiedBy": "R9ZgY0IvWl8ovIuT" + "modifiedTime": 1703375940967, + "lastModifiedBy": "sVoCvBU1knmXzoYe" }, "_id": "Q4iS1LIiyy7acuaF", "sort": 100000, diff --git a/packs/module-docs/_source/Macros_Mw1g2Fx5dp4SoqVP.json b/packs/module-docs/_source/Macros_Mw1g2Fx5dp4SoqVP.json index a01f5e5..f81c991 100644 --- a/packs/module-docs/_source/Macros_Mw1g2Fx5dp4SoqVP.json +++ b/packs/module-docs/_source/Macros_Mw1g2Fx5dp4SoqVP.json @@ -249,6 +249,76 @@ "lastModifiedBy": "sVoCvBU1knmXzoYe" }, "_key": "!journal.pages!Mw1g2Fx5dp4SoqVP.mT3lMGUo9zvqQsOh" + }, + { + "sort": 500000, + "name": "Fear Table", + "type": "text", + "_id": "RxGaSpV6FStZyyBX", + "title": { + "show": true, + "level": 1 + }, + "image": {}, + "text": { + "format": 1, + "content": "

This macro will call the Fear Table macro from whichever premium ruleset (SPWF or SWADE) is active, preferring SWPF.

It will not work if no premium module is active.

" + }, + "video": { + "controls": true, + "volume": 0.5 + }, + "src": null, + "system": {}, + "ownership": { + "default": -1, + "sVoCvBU1knmXzoYe": 3 + }, + "flags": {}, + "_stats": { + "systemId": "swade", + "systemVersion": "3.2.5", + "coreVersion": "11.315", + "createdTime": 1703097037538, + "modifiedTime": 1703097110707, + "lastModifiedBy": "sVoCvBU1knmXzoYe" + }, + "_key": "!journal.pages!Mw1g2Fx5dp4SoqVP.RxGaSpV6FStZyyBX" + }, + { + "sort": 500000, + "name": "Request Fear Check", + "type": "text", + "title": { + "show": true, + "level": 1 + }, + "image": {}, + "text": { + "format": 1, + "content": "

This macro will prompt for a fear penalty and request a spirit roll with that penalty from targeted or selected tokens.

" + }, + "video": { + "controls": true, + "volume": 0.5 + }, + "src": null, + "system": {}, + "ownership": { + "default": -1, + "sVoCvBU1knmXzoYe": 3 + }, + "flags": {}, + "_stats": { + "systemId": "swade", + "systemVersion": "3.2.5", + "coreVersion": "11.315", + "createdTime": 1703097037538, + "modifiedTime": 1703376053416, + "lastModifiedBy": "sVoCvBU1knmXzoYe" + }, + "_id": "CRgBHcoOmH5hvadF", + "_key": "!journal.pages!Mw1g2Fx5dp4SoqVP.CRgBHcoOmH5hvadF" } ], "flags": { @@ -261,7 +331,7 @@ "systemVersion": "3.2.5", "coreVersion": "11.315", "createdTime": 1678169291843, - "modifiedTime": 1702960233927, + "modifiedTime": 1703376053416, "lastModifiedBy": "sVoCvBU1knmXzoYe" }, "_id": "Mw1g2Fx5dp4SoqVP", diff --git a/packs/module-docs/_source/Setting_Adjustments_YSuk1v59tLaL9XUK.json b/packs/module-docs/_source/Setting_Adjustments_YSuk1v59tLaL9XUK.json index afa67b3..90ece84 100644 --- a/packs/module-docs/_source/Setting_Adjustments_YSuk1v59tLaL9XUK.json +++ b/packs/module-docs/_source/Setting_Adjustments_YSuk1v59tLaL9XUK.json @@ -48,7 +48,7 @@ "image": {}, "text": { "format": 1, - "content": "

SWADE Trait and Damage Rolls can now take into account common modifiers based on the target, if there is exactly one attacker and one target. Most will show up on all trait rolls if the target conditions are right. Gang up bonuses will only show up on Fighting rolls.

Any of the proposed modifiers may be ignored by checking the Ignore checkbox. Some modifiers are pre-ignored and must be unchecked to take effect.

The following target conditions are checked for before trait rolls:

  1. Vulnerable

  2. Deflection (as applied by the Deflection power effect from this module)

  3. Arcane Protection (as applied by the Arcane Protection power effect from this module)

  4. Arcane Resistance

  5. Scale Modifiers

  6. Gang Up, taking into account Block and Formation Fighter

The following target conditions are checked for before damage rolls:

  1. Arcane Protection (as applied by the Arcane Protection power effect from this module)

  2. Arcane Resistance

  3. Special Abilities with 'weakness' in the swid (ignored by default, +4 damage)

  4. Special Abilities with 'resistance' in the swid (ignored by default, -4 damage)

  5. Gang Up bonus if the attacker has Pack Tactics

" + "content": "

SWADE Trait and Damage Rolls can now take into account common modifiers based on the target, if there is exactly one attacker and one target. Most will show up on all trait rolls if the target conditions are right. Gang up bonuses will only show up on Fighting rolls.

Any of the proposed modifiers may be ignored by checking the Ignore checkbox. Some modifiers are pre-ignored and must be unchecked to take effect.

The following target conditions are checked for before trait rolls:

  1. Vulnerable

  2. Deflection (as applied by the Deflection power effect from this module)

  3. Glow/Shroud (as applied by the power effect macros from this module)

  4. Arcane Protection (as applied by the Arcane Protection power effect from this module)

  5. Arcane Resistance

  6. Scale Modifiers

  7. Gang Up, taking into account Block and Formation Fighter

  8. Range modifiers

The following target conditions are checked for before damage rolls:

  1. Arcane Protection (as applied by the Arcane Protection power effect from this module)

  2. Arcane Resistance

  3. Special Abilities with 'weakness' in the swid (ignored by default, +4 damage)

  4. Special Abilities with 'resistance' in the swid (ignored by default, -4 damage)

  5. Gang Up bonus if the attacker has Pack Tactics

" }, "video": { "controls": true, @@ -66,7 +66,7 @@ "systemVersion": "3.2.5", "coreVersion": "11.315", "createdTime": 1703044226574, - "modifiedTime": 1703044226574, + "modifiedTime": 1703379713144, "lastModifiedBy": "sVoCvBU1knmXzoYe" }, "_key": "!journal.pages!YSuk1v59tLaL9XUK.BxFgDb91dqbkO9h4" @@ -85,7 +85,7 @@ "systemVersion": "3.2.5", "coreVersion": "11.315", "createdTime": 1695618001902, - "modifiedTime": 1703044226574, + "modifiedTime": 1703379713144, "lastModifiedBy": "sVoCvBU1knmXzoYe" }, "_id": "YSuk1v59tLaL9XUK", diff --git a/scripts/api.js b/scripts/api.js index c638e78..8bd119b 100644 --- a/scripts/api.js +++ b/scripts/api.js @@ -1,5 +1,5 @@ -import { log } from './shim.js' -import { requestRollFromTokens } from './helpers.js' +import { log, shim } from './shim.js' +import { requestFearRollFromTokens, requestRollFromTokens } from './helpers.js' import { powerEffects } from './powerEffects.js' export class api { @@ -11,8 +11,11 @@ export class api { static globals () { const moduleName = 'swade-mb-helpers' game.modules.get(moduleName).api = { + rulesVersion: shim.rulesVersion, + fearTable: shim.fearTableHelper, powerEffects, - requestRollFromTokens + requestRollFromTokens, + requestFearRollFromTokens } } } diff --git a/scripts/helpers.js b/scripts/helpers.js index 5e31f83..14e058f 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -1,5 +1,25 @@ import { shim } from './shim.js' +export async function requestFearRollFromTokens (tokens, options = {}) { + // tokens: list of tokens to request the roll from + // options: + // title: tile for the roll dialog. Will have "- {{ token name }}" appended + // flavour: flavor text for the roll card. Defaults to title + // fear: value of the fear modifier. Defaults to 0. Positive number. + const requestingUser = shim.user + const title = options?.title || `${requestingUser.name} requests a Fear check` + const flavour = options?.flavour || options?.flavor || title + const fear = options.fear || 0 + const rollOpts = { + title, + flavour, + mods: [ + { label: 'Fear Penalty', value: Math.abs(fear) * -1, ignore: false } + ] + } + return requestRollFromTokens(tokens, 'attribute', 'spirit', rollOpts) +} + export async function requestRollFromTokens (tokens, rollType, rollDesc, options = {}) { // tokens: list of tokens to request a roll from // rollType: 'attribute' or 'skill @@ -8,17 +28,20 @@ export async function requestRollFromTokens (tokens, rollType, rollDesc, options // title: title for the roll dialog. Will have "- {{ token name }}" // appended // flavour: flavor text for the roll card. Defaults to title + // targetNumber: defaults to 4 // mods: list of modifiers {label: "", value: 0, ignore: false} // modCallback: callback function that takes a token and returns a list of // modifiers in the same format as modifiers, above const requestingUser = shim.user const title = options?.title || `${requestingUser.name} requests a ${rollDesc} roll` const flavour = options?.flavour || options?.flavor || title + const targetNumber = options?.targetNumber || 4 const promises = [] for (const token of tokens) { const owner = shim.warpgateUtil.firstOwner(token.document) const rollOpts = { title: `${title} - ${token.name}`, + targetNumber, flavour } const additionalMods = [] @@ -39,7 +62,45 @@ export async function requestRollFromTokens (tokens, rollType, rollDesc, options promises.push(shim.socket.executeAsUser(requestTokenRoll, owner.id, token.scene.id, token.id, rollType, rollDesc, rollOpts)) } - const results = await Promise.allSettled(promises) + const results = (await Promise.allSettled(promises)).map(r => r.value) + const contentExtra = targetNumber === 4 ? '' : ` vs TN: ${targetNumber}` + const messageData = { + flavor: flavour, + speaker: { alias: 'Requested Roll Results' }, + whisper: [...shim.ChatMessage.getWhisperRecipients('GM'), requestingUser], + content: `

Results of ${rollDesc[0].toUpperCase()}${rollDesc.slice(1)} roll${contentExtra}:

+`, + rolls: [] + } + for (const result of results) { + const token = shim.game.scenes.get(result.sceneId).tokens.get(result.tokenId) + const roll = ( + result.result instanceof shim.CONFIG.Dice.SwadeRoll + ? result.result + : shim.CONFIG.Dice[result.result.class].fromData(result.result) + ) + roll.targetNumber = targetNumber + let textResult = '' + if (roll.successes === -1) { + textResult = 'CRITICAL FAILURE' + } else if (roll.successes === 0) { + textResult = 'failed' + } else if (roll.successes === 1) { + textResult = 'success' + } else { + textResult = `success and ${roll.successes - 1} raise${roll.successes > 2 ? 's' : ''}` + } + messageData.content += ('' + + `` + + `` + + `` + + '') + if (roll) { + messageData.rolls.unshift(roll) + } + } + messageData.content += '
TokenRollResult
${token.name}${roll ? roll.total : 'Canceled'}${textResult}
' + shim.ChatMessage.create(messageData, {}) return results } diff --git a/scripts/module.js b/scripts/module.js index 9e81b1e..d0eec1c 100644 --- a/scripts/module.js +++ b/scripts/module.js @@ -51,7 +51,7 @@ Hooks.on('init', () => { vision: { darkness: { adaptive: false }, defaults: { attenuation: 0.1, contrast: 0, saturation: 0, brightness: 0.75 }, - preferred: true + preferred: false } }) CONFIG.Canvas.visionModes.lowlight = new VisionMode({ @@ -67,7 +67,7 @@ Hooks.on('init', () => { vision: { darkness: { adaptive: false }, defaults: { attenuation: 0.1, contrast: 0, saturation: -0.5, brightness: -0.2 }, - preferred: true + preferred: false } }) }) diff --git a/scripts/powerEffects.js b/scripts/powerEffects.js index 0bb816d..e34bd0b 100644 --- a/scripts/powerEffects.js +++ b/scripts/powerEffects.js @@ -1,5 +1,5 @@ import { CONST, log, shim } from './shim.js' -import { requestRollFromTokens } from './helpers.js' +import { requestFearRollFromTokens, requestRollFromTokens } from './helpers.js' class PowerEffect { constructor (token, targets) { @@ -546,6 +546,34 @@ class EntangleEffect extends TargetedPowerEffect { } } +class FearEffect extends TargetedPowerEffect { + get name () { + return 'Fear' + } + + get baseDurationRounds () { + return 1 + } + + async prepResult () { + this.raise = (this.buttons === 'raise') + } + + async applyResult () { + await super.applyResult() + await shim.wait(1000) + const options = { + title: 'Fear check!', + flavor: 'Failure: roll on the Fear Table if wildcard, Panicked if extra', + mods: [] + } + if (this.raise) { + options.fear = '-2' + } + await requestFearRollFromTokens(this.targets, options) + } +} + class HavocEffect extends TargetedPowerEffect { get name () { return 'Havoc' @@ -1555,6 +1583,7 @@ const PowerClasses = { 'detectconceal-aracana': DetectConcealArcanaEffect, disguise: DisguiseEffect, entangle: EntangleEffect, + fear: FearEffect, havoc: HavocEffect, intangibility: IntangibilityEffect, invisibility: InvisibilityEffect, diff --git a/scripts/rollHelpers.js b/scripts/rollHelpers.js index 8bbf41c..8a606a5 100644 --- a/scripts/rollHelpers.js +++ b/scripts/rollHelpers.js @@ -19,9 +19,30 @@ export async function preTraitRollModifiers (actor, trait, roll, modifiers, opti ) { modifiers.push({ label: 'Target has Deflection', value: '-2', ignore: false }) } + if (targets.some( + target => target.actor.effects.filter( + e => !e.disabled && e.name.toLowerCase().includes('glow')).length > 0) + ) { + modifiers.push({ + label: 'Glowing target (negate 1 point of illumination penalty)', + value: '+1', + ignore: true + }) + } + if (targets.some( + target => target.actor.effects.filter( + e => !e.disabled && e.name.toLowerCase().includes('shroud')).length > 0) + ) { + modifiers.push({ + label: 'Shrouded target', + value: '-1', + ignore: false + }) + } if (targets.length === 1 && token) { const target = targets[0] _addArcaneModifiers(target, modifiers) + _addRangeModifiers(token, target, options, modifiers) const scaleMod = calcScaleMod(token, target) if (scaleMod !== 0) { modifiers.push({ label: 'Scale', value: scaleMod, ignore: false }) @@ -67,6 +88,25 @@ export async function preDamageRollModifiers (actor, item, roll, modifiers, opti } } +function _addRangeModifiers (token, target, options, modifiers) { + if (options?.item?.type !== 'weapon' || !options?.item?.system?.range.includes('/')) { + return + } + const ranges = options.item.system.range.split('/').map(x => parseInt(x)) + const distance = getDistance(token, target) + const rollmods = shim.CONFIG.SWADE.prototypeRollGroups.find(g => g.name === 'Range').modifiers + log('ITEM RANGES:', ranges) + if (distance <= ranges[0]) { + // nothing here + } else if (ranges.length >= 2 && distance <= ranges[1]) { + modifiers.push(rollmods[0]) + } else if (ranges.length >= 3 && distance <= ranges[2]) { + modifiers.push(rollmods[1]) + } else { + modifiers.push(rollmods[2]) // extreme range + } +} + function _addArcaneModifiers (target, modifiers) { if (_findItem(target.actor, 'edge', 'improved-arcane-resistance')) { modifiers.push({ label: 'Arcane Resistance', value: '-4', ignore: true }) @@ -86,12 +126,21 @@ function _addArcaneModifiers (target, modifiers) { } } -function withinRange (origin, target, range) { +function getScaleDistanceMod (token) { + const scale = token.actor.system.stats.scale + return (scale > 0 ? (scale / 2) : 0) +} + +function getDistance (origin, target) { const ray = new Ray(origin, target) + const originScale = getScaleDistanceMod(origin) + const targetScale = getScaleDistanceMod(target) const distance = shim.canvas.grid.measureDistances([{ ray }], { gridSpaces: true })[0] - const originScale = origin.actor.system.stats.scale - const targetScale = target.actor.system.stats.scale - range += (originScale > 0 ? originScale / 2 : 0) + (targetScale > 0 ? targetScale / 2 : 0) + return distance - (originScale + targetScale) +} + +function withinRange (origin, target, range) { + const distance = getDistance(origin, target) return range >= distance } diff --git a/scripts/shim.js b/scripts/shim.js index f8beeb1..affd294 100644 --- a/scripts/shim.js +++ b/scripts/shim.js @@ -17,10 +17,22 @@ export class shim { return ActiveEffect } + static get CONFIG () { + return CONFIG + } + static get Actor () { return Actor } + static get ChatMessage () { + return ChatMessage + } + + static get game () { + return game + } + static get canvas () { return game.canvas } @@ -63,6 +75,16 @@ export class shim { return shim._socket } + static get rulesVersion () { + if (game.modules.get('swpf-core-rules')?.active) { + return 'swpf' + } + if (game.modules.get('swade-core-rules')?.active) { + return 'swade' + } + return 'system' + } + static mergeObject (...args) { return mergeObject(...args) } @@ -136,6 +158,14 @@ export class shim { return warpgate.util } + static get fearTableHelper () { + switch (shim.rulesVersion) { + case 'swade': return coreFearDialog + case 'swpf': return swpfFearDialog + } + throw new ReferenceError('No premium module active. No fear table found') + } + static getActorFolderByPath (path) { const names = path.split('/') if (names[0] === '') {