Ninja Bear Studio Plugins Help

Level

Defines the item level, optionally applying upgradeable trait, which enables the Upgrade operation.

Upgradeable items are tagged as Inventory.Item.Trait.Upgradeable.

Minimum and Maximum Values

An item's level must be between zero and whatever value is specified in the fragment as Maximum Level.

All values set to the SetLevel or Upgrade functions, or via the Upgrade Operation will always ensure that the incoming value is clamped to those limits.

Tracking Levels

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

  1. Via the GetLevel function, for occasional queries on the current level.

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

Level Attributes

The Attribute Set included with this inventory system provides two attributes related to the item level, the Equipment Level and the Average Equipment Level.

This fragment works in conjunction with those fragments. Whenever an item is added to an equipment slot, thus initializing an equipment, it will contribute to both attributes, increasing the total and average equipment level.

Gameplay Effects

Other objects in the system can use the item level as the effect level for a Gameplay Effect that must be applied. This is very useful if you want to the magnitudes in your Gameplay Effect to scale based on the item's power.

Upgrade Operation

During an upgrade, the level can be modified in two ways: absolute or incremental value.

  • Absolute: The value provided in the operation replaces the current level.

  • Incremental: The value provided is added to the current level.

Upgrade operation sample in Blueprints
void UInventoryExamples::Upgrade(UNinjaInventoryItem* Item, int32 Value, bIncrement) { const TInstancedStruct<FInventoryFragmentPayload>& Payload = UNinjaInventoryGameplayFunctionLibrary::CreateUpgradePayload(Item, Value, bIncrement); InventoryManager->TryPerformOperation(Payload); }

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

Upgrade function sample in Blueprints
void UWeaponManager::ImproveWeapon(UNinjaInventoryItem* Item, int32 Value, bIncrement) { UItemFragment_Level* LevelFragment = Item->FindFragment<UItemFragment_Level>(); if (bIncrement) { LevelFragment->Upgrade(Item, Value); } else { LevelFragment->SetLevel(Item, Value); } }
Last modified: 31 July 2024