Combat
The combat system gives actors health, lets them take damage and die, and reports what happened to every machine. It is built on the Gameplay Ability System (GAS): health is an attribute set, damage is a gameplay effect, and later attacks are gameplay abilities. It does not decide a combat style: blocking, dodging, stamina and critical hits are optional building blocks, so the same base works for an action game, a souls-like or a shooter.
| Module | Content |
|---|---|
PulseAttributes | Health, shield and stamina sets, regeneration, attribute view models (Attributes); needed by all combat modules, usable alone |
PulseCombat | Attribute sets, damage pipeline with modifiers, combat component (life, death, teams), hit reactions, targeting with lock-on, hit effects and filters, view models, messages, cheats |
PulseCombatMelee | Melee combos with hit shapes or weapon sockets, timed or animation driven (Melee) |
PulseCombatRanged | Projectiles, hitscan, spread, charging, area damage (Ranged) |
PulseCombatHUD | Damage numbers, health bars, boss bars, hit feedback (Combat HUD) |
PulseCombatInventory | Weapons, armor, ammunition, durability, loot on death (Combat and inventory) |
Enable only what the game needs: a shooter can leave out PulseCombatMelee, a brawler PulseCombatRanged.
At a glance
- Ability system with health. Give the actor an
UAbilitySystemComponent(on the pawn or on the player state). The combat component addsUPulseHealthAttributeSeton the authority (Default Attribute Sets); a set the game gives itself (a default subobject of the owner,AddAttributeSetSubobject, a PulseSkill grant) is used instead. - Combat component. Add Pulse Combat (
UPulseCombatComponent) to the pawn. It finds the ability system by itself, also when it is created later. Give enemies a Pulse Team component (Pulse Foundation) withPulse.Team.Enemy; players getPulse.Team.Playerfrom the automatic team component of Pulse Foundation. - Maximum health.
Set Max Health(authority) or an own gameplay effect onMaxHealth. - Deal damage.
Apply Damage/Apply Simple Damageon the authority, for example from a trap, a weapon or a projectile. - React. Bind
On Damaged,On DeathandOn Revivedof the combat component, or use the view modelUMVVMPulseCombatantfor health bars. Respawning is up to the game;Revivebrings a combatant back.
cpp title="A trap that burns everything that touches it" void ATrap::OnOverlap(AActor* Other) { FPulseDamageSpec damage; damage.Amount = 15.f; damage.DamageType = Pulse::Combat::Tags::DamageType_Fire; damage.Causer = this; Pulse::Combat::ApplyDamage(Other, damage); }
Multiplayer
- Damage, healing, death and revive run on the authority only (the functions do nothing on clients).
- Attributes replicate with the attribute set; the life state of the combat component replicates as one value (push model) with the killer ids, so clients know who killed a combatant also when the killer is not relevant to them.
On DamagedandOn Healedreach every machine through an unreliable multicast (turn off withbReplicateDamageEvents), so damage numbers and hit reactions work on all clients.- Messages (
Pulse.Message.Combat.*) are sent wherever the events fire.
Attacks and AI
Attacks are abilities that take their target from the activation event data first, then from lock-on and the soft target of UPulseTargetingComponent, then from the camera. So the same ability serves players and AI: an AI (or a script) activates it on the server with Pulse::Combat::PressAbilityInput (Blueprint Press Attack) and the target in the event data.
See Damage and life, Melee, Ranged, Combat HUD and Combat and inventory for the details.