Combat and inventory

Module PulseCombatInventory (PulseCombat + PulseInventory + PulseInventoryEffects). Weapons, armor, ammunition, durability and loot on death, on top of the equipment, loot and item effects.

Setup

Put Pulse Combat Equipment (UPulseCombatEquipmentComponent) on the avatar, next to the ability system, the combat component and the equipment (the equipment may also sit on the player state). It follows the equipment on the authority. For stats like maximum health also add Pulse Equipment Effects (see Item effects).

Weapons

Give the item the trait Weapon (FPulseItemTrait_Weapon) next to Equippable:

Field Meaning
Abilities Granted while the weapon is equipped, e.g. UPulseMeleeAttackAbility, UPulseRangedAttackAbility
AttackSource Source object of the abilities: the attack (UPulseAttackDefinition) or shot (UPulseProjectileDefinition) of this weapon
InputID Input id of the granted abilities
Costs Costs of every attack (Pulse costs, FPulseCostList), e.g. Items for arrows, Weapon Item for bombs
bOnlyWhileActive In a hotbar slot only while it is the active slot

Weapons outside the hotbar (main hand) are always in use; in the hotbar the active slot switches weapons. While the same weapon stays in use its abilities stay (a combo goes on while its durability drops).

Ammunition and throwing items

Attack costs are Pulse costs (see Conditions, costs and rewards), so every cost of the other plugins works for attacks too:

  • Items (FPulseCost_Items, module PulseInventory) uses up items of the attacker: a definition (Item) or any item with a tag (ItemTag), from the inventory first and, with bIncludeEquipped, then from equipped stacks (a quiver slot). Arrows of the bow.
  • Weapon Item (FPulseCost_WeaponItem) uses up the weapon’s own stack: a bomb in the hotbar is a weapon with a ranged ability and this cost, and the last bomb leaves the slot. It only costs something for attacks; thrown items are not given back.

The melee and ranged abilities check all costs before they start and pay them on the server, all or nothing; the costs come from the ability (AttackCosts) and from the system that granted it (UPulseCombatComponent::SetAbilityCosts, the weapon trait). The context of an attack names the attacker’s avatar as Player and Instigator, the source object of the ability (the weapon, attack or shot, else the ability) as Source, and the ability’s spec handle as extra data (FPulseAttackCostExtra). Own costs (mana from an attribute, charges of a wand) derive from FPulseCost. GetAmmoCount(Slot) gives the ammunition left for a HUD: the items of the weapon’s Items cost (with equipped stacks when the cost includes them) or its own stack for Weapon Item, -1 when the weapon needs no items.

Armor and combat stats

  • Combat Modifiers (FPulseItemTrait_CombatModifiers): damage modifiers while equipped, e.g. a type resistance on incoming damage or a critical chance on outgoing damage.
  • Combat stats in percent, fixed (Equipped Stats) or rolled (Rolled Stats), summed over all items: Pulse.Stat.CriticalChance, .DamageBonus, .DamageReduction, .Resistance.Fire (and .Physical, .Frost, .Lightning, .Poison, .Magic). What a stat does is set in Project Settings > Pulse > Core > Combat Inventory > Combat Stats; add own stats there.

The modifiers go to the combat component as modifier sources (SetModifierSource), which every damage calculation reads next to the component’s own modifiers.

Durability

Items with Durability (FPulseItemTrait_Durability, module PulseInventory) wear: weapons when they hit (Pulse.Combat.Event.AttackHit), armor when its wearer takes damage (settings bWeaponsWearOnHit, bArmorWearsOnDamage). Broken items stay equipped but give no abilities, stats or modifiers. WearItem(Slot) wears through FPulseItemTrait_Durability::Wear and writes the instance trait only when the item lost something; OnItemBroken fires when an item breaks. RepairItem(Slot, Inventory) pays RepairItem x RepairItemCount as one Items cost from the given inventory, all or nothing (lent stacks never pay), and repairs only when the payment went through. The repair data comes from the item as it sees it (Pulse::Inventory::FindRepairRules): an instance durability with its own repair item (an upgraded item) pays that item; an instance copy without repair item (a saved item whose repair item moved) falls back to the definition’s, so it still needs it.

The combat stats of equipped items are summed with Pulse::Inventory::GatherItemStats, the same rules the Equipment Effects use (see Item effects); stats with an invalid tag are skipped.

Loot on death

Pulse Loot Drop (UPulseLootDropComponent) on an enemy rolls its LootTable when its combat component dies and spawns the items around the body. Context sets level and tags of the roll; the killer is the roll’s Player when it is a player, so loot entries can have conditions about that player (a quest item only while its quest runs). bDropOwnInventory lets players lose their items, DropLoot() drops on demand (a chest). OnLootDropped tells what was dropped.

Examples

/PulseCore/Combat/Examples has example items for tests: a sword (melee, durability), a bow with arrows, fire bombs, a healing potion, fire armor (maximum health +20, fire resistance 50 %), a ring with random combat stats and a loot table with all of them.

Cheats

Command Does
PulseCombatInventorySetup [max health] Makes the pawn ready: combatant, inventory, equipment, item user, equipment effects, combat equipment
PulseCombatEquipmentInfo Weapons, ammunition, durability and modifier sources
PulseCombatWear <slot> [amount], PulseCombatRepair <slot> Durability
PulseCombatLootOnDeath <table> The nearest combatant drops this table when it dies

PulseCore plugin documentation.

This site uses Just the Docs, a documentation theme for Jekyll.