Ninja Bear Studio Plugins Help

Durability

Enables the durable trait, along with the accompanying Wear and Repair operations.

Durable items can be indestructible or break, which tags them as Inventory.Item.Trait.Indestructible and Inventory.Item.Trait.Broken, respectively.

Tracking Durability

The fragment provides the following ways to track an item's durability:

  1. Via the GetDurability function, for occasional queries on the current durability.

  2. Via the OnDurabilityChanged delegate, which broadcasts each time the value changes.

Broken Items

When the durability reaches zero, an item is considered Broken and is tagged as Inventory.Item.Trait.Broken. You can also query if an item is broken using the IsBroken function from this fragment.

Items can also have their wear effect disabled, making them indestructible. These items are tagged as Inventory.Item.Trait.Indestructible. and this feature can also be checked using the IsIndestructible function from this fragment.

Wear Operation

This fragment provides the Wear operation, which can be created via the CreateWearPayload function. It reduces the item's durability and marks the item as broken, by tagging as Inventory.Item.Broken.

Wear operation sample in Blueprints
void UInventoryExamples::Wear(UNinjaInventoryItem* Item, int32 WearAmount) { // If not set, the Wear Amount in the payload function will default to 10. const TInstancedStruct<FInventoryFragmentPayload>& Payload = UNinjaInventoryGameplayFunctionLibrary::CreateWearPayload(Item, WearAmount); InventoryManager->TryPerformOperation(Payload); }

If your design requires a direct approach to adding wear, you can use the function exposed by the fragment. Please note that it becomes your responsibility to manage network authority.

Wear function sample in Blueprints
void UDamageManager::AddWear(UNinjaInventoryItem* Item, int32 WearAmount) { UItemFragment_Durability* DurabilityFragment = Item->FindFragment<UItemFragment_Durability>(); DurabilityFragment->AddWear(Item, WearAmount); }

Repair Operation

This fragment provides the Restore operation, which can be created via the CreateRestoreRepair function. It restores the item's durability to its original value, and it removes the Inventory.Item.Broken Gameplay Tag.

Repair operation sample in Blueprints
void UInventoryExamples::Repair(UNinjaInventoryItem* Item) { const TInstancedStruct<FInventoryFragmentPayload>& Payload = UNinjaInventoryGameplayFunctionLibrary::CreateRepairPayload(Item); InventoryManager->TryPerformOperation(Payload); }
Last modified: 31 July 2024