From d77c854e8de727eb7134013d9d2446e54d5f5d12 Mon Sep 17 00:00:00 2001 From: ardittristan Date: Sun, 8 Nov 2020 21:35:46 +0100 Subject: [PATCH] add pathfinder compat --- CHANGELOG.md | 4 ++++ README.md | 3 +++ module.json | 10 ++++++---- modules/pf2e.js | 31 +++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 modules/pf2e.js diff --git a/CHANGELOG.md b/CHANGELOG.md index cd07958..1ce0d04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Patch Notes +## Version 1.1.0 + +* Add Pathfinder 2e compatibility. + ## Version 1.0.14 * Push compatible core version. diff --git a/README.md b/README.md index 8b49803..b5191f2 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,9 @@ Check the [Changelog](https://github.com/ardittristan/VTTExternalActorViewer/blo If it's not in the current list it probably won't work or there won't be a site for it, feel free to make an extension for it! (read more [here](https://github.com/ardittristan/VTTExternalActorViewer/blob/master/CONTRIBUTING.md)) +* dnd5e +* pf2e + *** _Does not work when you connect to foundry via http://localhost or via the electron app._ diff --git a/module.json b/module.json index d3bc7e6..fc5fa3c 100644 --- a/module.json +++ b/module.json @@ -2,16 +2,18 @@ "name": "externalactor", "title": "External Actor Viewer", "description": "Makes you able to see characters from unloaded worlds.", - "version": "1.0.14", + "version": "1.1.0", "author": "ardittristan#0001", "esmodules": [ "actorviewer.js" ], "scripts": [ - "modules/dnd5e.js" + "modules/dnd5e.js", + "modules/pf2e.js" ], "systems": [ - "dnd5e" + "dnd5e", + "pf2e" ], "styles": [ "css/externalactor.css" @@ -28,5 +30,5 @@ "manifest": "https://raw.githubusercontent.com/ardittristan/VTTExternalActorViewer/master/module.json", "download": "https://github.com/ardittristan/VTTExternalActorViewer/releases/latest/download/actorViewer.zip", "minimumCoreVersion": "0.6.0", - "compatibleCoreVersion": "0.7.5" + "compatibleCoreVersion": "0.7.6" } diff --git a/modules/pf2e.js b/modules/pf2e.js new file mode 100644 index 0000000..b1c7689 --- /dev/null +++ b/modules/pf2e.js @@ -0,0 +1,31 @@ +Hooks.on("init", () => { + if (game.system.id === "pf2e") { + Hooks.on("actorViewerGenerate", () => { + const compatMode = game.settings.get("externalactor", "compatMode"); + let actors = {}; + game.actors.forEach((actor) => { + if (!compatMode) { + if (game.user.isGM) { + actor.setFlag("externalactor", "hasStamina", game.settings.get("pf2e", "staminaVariant") > 0); + actor.setFlag("externalactor", "ignoreCoinBulk", game.settings.get("pf2e", "ignoreCoinBulk")); + actor.setFlag("externalactor", "ignoreContainerOverflow", game.settings.get("pf2e", "ignoreContainerOverflow")); + actor.setFlag("externalactor", "proficiencyUntrainedModifier", game.settings.get("pf2e", "proficiencyUntrainedModifier")); + actor.setFlag("externalactor", "proficiencyVariant", game.settings.get("pf2e", "proficiencyVariant")); + actor.setFlag("externalactor", "proficiencyTrainedModifier", game.settings.get("pf2e", "proficiencyTrainedModifier")); + actor.setFlag("externalactor", "proficiencyExpertModifier", game.settings.get("pf2e", "proficiencyExpertModifier")); + actor.setFlag("externalactor", "proficiencyMasterModifier", game.settings.get("pf2e", "proficiencyMasterModifier")); + actor.setFlag("externalactor", "proficiencyLegendaryModifier", game.settings.get("pf2e", "proficiencyLegendaryModifier")); + } + } + + actors[actor.id] = JSON.parse(JSON.stringify(actor.data)); + }); + + ActorViewer.createActorsFile(actors); + + game.settings.set("externalactor", "systemSite", "https://ardittristan.github.io/VTTPF2eExternalActorSite/"); + + return false; + }); + } +});