Combat and Inventory
Ninja Combat can defer Weapon Management and Ammo Management to Ninja Inventory. You can also create custom fragments that define weapon behavior, such as weapon damage, critical hit chance and bonus, fire rate, ammo capacity, and so on.
This integration is automatically enabled when both plugins are available and active in the project, regardless of whether they are installed locally or in the engine.
Once set up:
Weapon spawning, attachment, features, and configuration are handled by the Inventory system.
The Combat system no longer directly manages weapons. Instead, it requests the correct weapon actor for each equipment slot.
You can define weapon-specific behavior through item fragments, such as gameplay elements, dynamic attributes, off-hand attachments, and so on.
Weapon Manager
Ninja Combat uses a Weapon Manager to retrieve weapons available to a combatant. With Ninja Inventory, this responsibility is assigned to the Inventory Manager, and the Weapon Manager simply forwards requests to it.
Instead of adding the usual NinjaCombatWeaponManagerComponent, use the equipment-aware variant, NinjaCombatEquipmentAdapterComponent. This version implements CombatWeaponManagerInterface, as expected by Ninja Combat, but forwards requests to an Equipment Manager that should also be present in the character.
Make sure to return the correct component from GetWeaponManager, in the Combat System Interface.
Configure the Equipment Weapon Manager
Add the Equipment Manager,
NinjaEquipmentManagerComponent, to your character. Check the Equipment Management documentation for additional details.Add the Equipment Weapon Adapter,
NinjaCombatEquipmentAdapterComponent, to your character. Check the Weapon Management documentation for additional details.Return the new Equipment Adapter Component from
GetWeaponManager, which is a function fromCombatSystemInterface.
Weapon Actor
Weapon Actors can also benefit from a closer integration with Ninja Inventory. Specifically, they can access the Equipment Instance that contains relevant item data, such as the Item Instance and its Fragments. This is exposed by the NinjaEquipmentActorComponent, which is added to each actor used as an Equipment Presence.
To leverage this, either use ANinjaCombatEquipmentWeaponActor as your base Weapon Class, or add NinjaEquipmentActorComponent to your own Weapon Actor hierarchy. Keep in mind that the provided base class includes additional features, such as using the Item Level as the Weapon Level when applying Gameplay Effects.
Create Inventory Weapons
For your weapon actors, use
NinjaCombatEquipmentWeaponActoras your base class.Create a new Item Definition for your weapon. Check the Inventory Items documentation for additional details.
Add an Equipment Fragment to your Item Definition and configure the Equipped State, at minimum.
Set the Equipment Type to Actor and set the Weapon Actor as the Actor Class.
Ammo Storage
Similar to the Weapon Manager, Ninja Combat uses an Ammo Storage component to manage ammunition for firearms during reloads. When using Ninja Inventory, ammo can be managed using Item Stacks.
Instead of using the default NinjaCombatAmmoStorageComponent, use NinjaCombatInventoryAmmoAdapterComponent and set its AllAmmoTypesQuery to a query that covers all items that represent ammo. For example, if your ammo items use identification tags such as Item.Type.Ammo.Rifle and Item.Type.Ammo.Shotgun, set this query to find Item.Type.Ammo.
Configure the Ammo Storage
Add the Ammo Storage Adapter,
NinjaCombatInventoryAmmoAdapterComponent, to your character. Check the Firearms documentation for additional details.Configure the Adapter's
AllAmmoTypesQueryproperty to catch all ammo types in your Inventory.Create Inventory Items representing Ammunition, including a Stack Fragment set to be observable. This allows you to get a global count in addition to the per-stack count.
Create Inventory Items representing Firearms, including a Firearm Component, which provides specialized ammo functions.
Item Fragments
Multiple Item Fragments can be used to enhance weapons in many ways.
Fragment | Description |
|---|---|
Firearm | Identifies a firearm and becomes aware of compatible ammo. |
Equipment | Configures an actor presence for a weapon, which can be used as the Weapon Actor. |
Offhand Position | Allows two-handed weapons to properly place the off-hand. |
Dynamic Attributes | Can be used to set magnitudes for weapons, such as damage, critical hit chance, and critical damage bonus. |
When using Dynamic Attributes in your weapons, override GetAdditionalCombatMagnitudes, from CombatMagnitudeProviderInterface, to expose your dynamic attributes, such as Damage and Critical Hit Chance, using the proper data tags.