Created
August 31, 2024 15:32
-
-
Save baronfel/98a3914ccef97698b27764905dc67a5b to your computer and use it in GitHub Desktop.
Update NPC Actors to work with WBHarry/pf2e-bestiary-tracking's NPC Tracker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Change this to whatever makes sense for your layout. | |
// For me, I have only a top-level of folders that I put all of the current NPCs into, so a simple single-level traversal works great. | |
let npcFolders = | |
game.actors.apps[0].folders.filter(f => f.name === "Classmates" || f.name === "Faculty"); | |
// dig into the folders chosen and make a single array of all actors in them | |
let npcs = | |
npcFolders.flatMap(f => f.contents); | |
function addNpcTrait(npc) { | |
if (npc.traits.has("npc")) { | |
return; | |
} | |
npc.system.traits.value.push("npc"); | |
} | |
function setUnique(npc) { | |
if (npc.rarity === "unique") { | |
return; | |
} | |
npc.system.traits.rarity = "unique"; | |
} | |
// apply modifications to each actor | |
npcs.forEach(n => { | |
addNpcTrait(n); | |
setUnique(n); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment