From 625a2a7ea7d7d69b2b794021adaada1824e9ddbc Mon Sep 17 00:00:00 2001 From: Jeff Hitchcock Date: Wed, 18 Dec 2024 14:52:31 -0800 Subject: [PATCH] [#3798] Add gear to embedded NPCs Populates the gear least within NPC embeds with equipment that: - Has a quantity of at least 1 - Doesn't have the "natural" subtype (weapons or armor) --- module/data/actor/npc.mjs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/module/data/actor/npc.mjs b/module/data/actor/npc.mjs index 057c0d110c..fe5f7d38e6 100644 --- a/module/data/actor/npc.mjs +++ b/module/data/actor/npc.mjs @@ -407,6 +407,18 @@ export default class NPCData extends CreatureTemplate { /* -------------------------------------------- */ + /** + * Create a list of gear that can be collected from this NPC. + * @type {Item5e[]} + */ + getGear() { + return this.parent.items + .filter(i => i.system.quantity && (i.system.type?.value !== "natural")) + .sort((lhs, rhs) => lhs.sort - rhs.sort); + } + + /* -------------------------------------------- */ + /** @override */ async recoverCombatUses(periods, updates) { // Reset legendary actions at the start of a combat encounter or at the end of the creature's turn @@ -493,8 +505,9 @@ export default class NPCData extends CreatureTemplate { formatNumber(this.attributes.prof, { signDisplay: "always" })})`, // Gear - // TODO: Handle once gear is implemented by system - gear: "", + gear: formatter.format( + this.getGear().map(i => i.system.quantity > 1 ? `${i.name} (${formatNumber(i.system.quantity)})` : i.name) + ), // Initiative (e.g. `+0 (10)`) initiative: `${formatNumber(this.attributes.init.total, { signDisplay: "always" })} (${