Skip to content

Commit

Permalink
Merge pull request #4902 from foundryvtt/npc-gear
Browse files Browse the repository at this point in the history
[#3798] Add gear to embedded NPCs
  • Loading branch information
arbron authored Jan 3, 2025
2 parents ec2afb6 + 625a2a7 commit 57b192f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions module/data/actor/npc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,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
Expand Down Expand Up @@ -509,8 +521,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" })} (${
Expand Down

0 comments on commit 57b192f

Please sign in to comment.