Conversation
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
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.
- fa-person-hiking -> fa-axe - Fix gear item section header height. - Add subtitle to items. - Hide gear item section if no gear.
There was a problem hiding this comment.
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).
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.
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.
|
@Fyorl Added the hook into I also added a |
|
If there a way to mark an incoming item as not gear, without first adding the item and then editing it afterwards? |
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
Closes #6528