Loot Management
The Loot System in the Ninja Inventory plugin enables actors to grant items to a requesting inventory—such as looting a defeated enemy, opening a chest, or collecting a reward.
The system supports both instanced items and default items, enabling flexible generation and transfer workflows.
Loot Workflow
Loot flows between a requester and a source Inventory Manager.
The requester initiates the process by invoking
GenerateLooton a source Inventory Manager.Loot is generated by a loot selector configured on the source, returning a list of
InventoryDefaultItementries.Loot is sent to the requester via
ReceiveLoot, which stores the loot for validation and broadcasts events that can be tracked by the user interface.Loot is visualized by the UI using the appropriate Inventory Loot ViewModel. It will convert loot entries into the UI-oriented
UNinjaInventoryDetachedItemViewobject.Selected loot is transferred back to the requester using
TransferLoot. This can also be done via the ViewModel.
Loot Generation
Loot is generated by a class that implements InventoryLootSelector. These classes are responsible for gathering potential loot options and presenting them back to the requester.
You can define the Loot Generation Strategy in the Inventory Manager. The system provides the following predefined strategies:
Strategy | Description |
|---|---|
| Selects loot based on a data table containing predefined items, drop chances, and loot costs. Uses the |
| Selects loot from the Inventory Manager’s existing items. Selection is based on the Loot Fragment. |
| Selects loot from containers that have the lootable trait. |
You can create custom strategies by extending InventoryLootSelector and implementing the GenerateLoot function.
When creating the resulting InventoryDefaultItem array, follow these rules:
Always set the Source Inventory in each entry, which is required to enable the transfer operation.
If the loot originates from an actual Inventory Item, also set the Source Item reference in the entry.
Loot Events
The Inventory Manager broadcasts the following events to support gameplay systems, UI, and scripting integration:
Event | Description |
|---|---|
| Broadcast when loot is discarded by the receiver (but can be used later). |
| Broadcast when loot is received by the requester (both authority and local client). |
| Broadcast after loot is selected for a player. |
| Broadcast after loot is successfully transferred from the source. |
All loot events will provide the following properties:
Requester: Inventory that requested the loot.
EventTag: Gameplay Tag representing the loot event.
Loot: Array containing the selected loot, if applicable.