Item System


1 Overview

The item system is one of the most important system in our framework, as most of the character features are activated by the item system. For example, the character weapon system activated after picking up a weapon item.

This document will explain how to define and use an item based our framework.


2 Basic Setup

The item system of this framework is controlled by inventory manager component.

  • /Game/USGT/Framework/Items/BP_InventoryManager_USG

This is the component of player controller because the some items will be reversed when the controlled pawn is destroyed.

Setup the properties as follow.


inventorymgr


  • Verify Pickup Distance: For network vertion, we need to verify valid distance from server for picking up one item.

  • Depot Capacity: Max capacity of depot.

  • Item Definition Table: All the item will be defined here.


3 Item Creation Flow


3.1 Config Item Table


To add a new item, you need to add a line to item definition table.

itemtable


  • ID: Unique item id.

  • Type: Item type.

  • ItemClass: Item entity class (see section 3.2).

  • bConsumble: If true, item count will be reduced while using item. Otherwise, user can only drop it to discard item.

  • bCumulative: Indicate whether the count of this item can be added up.

  • CumulativeLimit: Max cumulative count.

  • bEquippable: If true, the item can be equipped and will not consume the capacity of depot.

  • bAutoUseWhenGain: if true, the item will be auto used after gained.

  • Operations: The supported operations for this item.

  • Tags: Specific tags for this item.

  • DisplayName: Display name of this item.

  • DisplayIcon: Display icon of this item.

  • DisplayWeight: The weight to sort items while displaying.


3.2 Create Item Entity Blueprint


For one type of item, create the base item entity blueprint with specific logic of this type.

The build-in types of item entities are given blew.

  • Weapon item:
    • /Game/USGT/Framework/Character/Weapon/Items/BP_WeaponItem_USG
  • Weapon bullet item:
    • /Game/USGT/Framework/Character/Weapon/Items/BP_BulletItem_USG
  • Character customization item for skeletal mesh:
    • Game/USGT/Framework/Character/Customizer/BP_SkeletalMeshPartItem_USG
  • Character customization item for static mesh:
    • Game/USGT/Framework/Character/Customizer/BP_StaticMeshPartItem_USG
  • Emote item:
    • /Game/USGT/Framework/Character/Effet/Items/BP_EmoteItem_USG

For new item type, you need to create you own base item entity class and override several interfaces, such as TryUseItem.

Then create the child blueprint of this base item entity blueprint for different configurations. For example, we create the weapon item entity as following.


itementity

  • PickupClass: See section 3.3.

  • GenPickupWhenDiscard: If true, a pickup actor(using PickupClass) will be generated on the groud after discarding this item.


3.3 Create Pickup Blueprint


For the item you need to pick up from groud, you need to create the pickup blueprint based on the BP_PickupEntity_USG.

From the pickup entity blueprint, you need to config the display mesh and item which we will get from this pickup.


pickupentity


  • DefaultPickupList: The list of item id that can be picked up. The item id is configured at the item table (See 3.3).

  • IsAutoPickup: If true, the items will be auto picked up when the player overlap this pickup actor.

  • IsDestroyAfterPickup: If true, this pick up actor will be destroyed after all items are picked up.

  • Sphere: config the sphere radius for overlapping. Listening to this event to show display ui.


3.4 Put Pickup to Level


Drag the pick up actor blueprint to the level and play, then the player will be enable to pick up the item.


previewpickup


4 Example


You can find the item example from following folder.

  • /Game/USGT/Game/CoreModules/Items

  • /Game/USGT/Game/CoreModules/Weapon