Skip to content

[#6528] Add separate gear data, gear configuration app#6713

Merged
arbron merged 8 commits into
5.3.xfrom
npc-gear
Feb 18, 2026
Merged

[#6528] Add separate gear data, gear configuration app#6713
arbron merged 8 commits into
5.3.xfrom
npc-gear

Conversation

@arbron

@arbron arbron commented Feb 11, 2026

Copy link
Copy Markdown
Collaborator

Rather than trying to infer NPCs' gear from their items, this makes the gear list an explicitly defined data structure to allow authors more control. The gear list includes a absolute or relative UUID to the available gear and an optional quantity.

Gear Configuration

A migration has been added that takes the existing logic for showing the gear list in stat block embeds and uses that to pre-populate the list of gear.

Minor breaking change in the signature of getGear, which is now an asynchronous method because it needs to fetch compendium items.

Todo

  • Automatically populate gear list when certain compendium items are dropped onto the NPC sheet
  • Add context option for adding/removing item from gear list
  • Make gear list entries draggable from NPC sheet

Closes #6528

Rather than trying to infer NPCs' gear from their items, this makes
the gear list an explicitly defined data structure to allow authors
more control. The gear list includes a absolute or relative UUID to
the available gear and an optional quantity.

A migration has been added that takes the existing logic for showing
the gear list in stat block embeds and uses that to pre-populate the
list of gear.

Minor breaking change in the signature of `getGear`, which is now an
asynchronous method because it needs to fetch compendium items.

 ### Todo
- [ ] Automatically populate gear list when certain compendium items
      are dropped onto the NPC sheet
- [ ] Add context option for adding/removing item from gear list
- [ ] Make gear list entries draggable from NPC sheet

Closes #6528
@arbron arbron added this to the D&D5E 5.3.0 milestone Feb 11, 2026
@arbron arbron self-assigned this Feb 11, 2026
@arbron arbron added breaking Breaking changes migration The feature involves a system migration system: actor sheets priority: high labels Feb 11, 2026
Adds "Add to Gear" and "Remove from Gear" context options for items
in NPC inventories.

Automatically adds compendium items to the gear list when they are
dropped onto the NPC sheet and the ability to drag gear from the
sidebar list to other actors.

Also automatically removes entries from the gear list when they are
deleted from the actor sheet.
@arbron
arbron requested a review from Fyorl February 11, 2026 21:08
 - fa-person-hiking -> fa-axe
 - Fix gear item section header height.
 - Add subtitle to items.
 - Hide gear item section if no gear.

@Fyorl Fyorl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a reasonable solution to me, but the quantities might be a problem. If you set up an Actor with, say, Javelin (5) in its gear entry, and in its inventory, then throughout the course of an encounter, it might throw several of those javelins. If the DM grabs the Javelin entry from the gear section in order to distribute loot, they will take the full 5 javelins, even if most of them had otherwise been thrown off a cliff.

I would propose that we instead add gear as a property to all physical items, keep the context menu toggle, keep the gear section in the sidebar. Instead of an explicit gear list, we instead derive it by filtering the list of items that are marked 'gear'. When dragging-and-dropping from an NPC, we check the gear property, and instead drag a compendium copy, using the same logic currently in the PR.

It has some advantages in that we don't need any _clearGear logic and extra round-trips, and we don't need a bespoke gear configuration app.

For Ember compatibility we would need a way to specify a subset of properties that are maintained on the item and are not replaced by the compendium source (we need to retain quantity anyway).

Comment thread module/applications/actor/npc-sheet.mjs Outdated
Comment thread module/applications/components/inventory.mjs Outdated
Comment thread module/data/actor/npc.mjs Outdated
Comment thread templates/actors/npc-sidebar.hbs
Moves gear data from being stored on the actor to being stored in
an item property. This property is only visible on items when they
are embedded on an NPC actor and is cleared automatically when
moved to other actor types.

Adds a new `asGear` method to physical items that clones the item
in place or from its compendium version depending on the metadata
property `compendiumGearSource`.

Removes `details.treasure.gear` from the NPC data model and the
gear config application.
Comment thread module/data/actor/npc.mjs Outdated
@arbron
arbron requested a review from Fyorl February 17, 2026 02:42
Comment thread module/data/item/consumable.mjs Outdated
Comment thread module/data/item/container.mjs Outdated
Comment thread module/data/item/equipment.mjs Outdated
Comment thread module/data/item/loot.mjs Outdated
Comment thread module/data/item/tool.mjs Outdated
Comment thread module/data/item/weapon.mjs Outdated
Comment thread module/migration.mjs
Comment thread module/migration.mjs
Comment thread module/applications/actor/npc-sheet.mjs
Comment thread module/data/actor/npc.mjs Outdated
@arbron
arbron requested a review from Fyorl February 18, 2026 01:06
Add `dnd5e.getAsGear` hook to allow modules a chance to customize
items when they are being converted into gear. This hook gets the
original item as well as a clone that can be modified.

Also added a `preserveGear` flag that can be set on an item that
will cause the whole item to be preserved as-is, rather than using
the compendium version. This is only necessary when the item has
`_stats.compendiumSource` set.

Finally automatically converts any physical items dropped onto an
actor sheet from an NPC into gear so other actors will get the
gear version when dragged from an NPCs inventory.
@arbron

arbron commented Feb 18, 2026

Copy link
Copy Markdown
Collaborator Author

@Fyorl Added the hook into asGear and handling of auto-converting gear when dropping onto actors

I also added a preserverGear flag allowing whole items to be preserved even if they have a _stats.compendiumSource set. I think the extra work to handle preserving only specific enchantments is a bit large and would probably be best handled in a followup PR rather than bloating this one further.

@arbron
arbron merged commit da4c73b into 5.3.x Feb 18, 2026
@arbron
arbron deleted the npc-gear branch February 18, 2026 21:32
@arbron arbron mentioned this pull request Feb 28, 2026
23 tasks
@TheGiddyLimit

Copy link
Copy Markdown
Contributor

If there a way to mark an incoming item as not gear, without first adding the item and then editing it afterwards?
From a quick test/skim of e.g. https://github.com/foundryvtt/dnd5e/pull/6713/changes#diff-36b59bb67b8c9af4fd5c684aee18793aa7e15157371426935f652a5c52f1a361R239 I'm not seeing it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaking changes migration The feature involves a system migration priority: high system: actor sheets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add method to more precisely control what appears in Gear list/Feature tab on NPC sheet

3 participants