Damage and life
Attribute sets
Health, shield and stamina are the attribute sets of PulseAttributes (UPulseHealthAttributeSet, UPulseStaminaAttributeSet, see Attributes), which every Pulse plugin reads as Pulse.Stat.Health, .Shield and .Stamina through the attribute contract of Pulse Foundation; combat adds damage types, modifiers, death and teams on top. A target with the Pulse Attributes component instead of an ability system (Health, MaxHealth, Shield, MaxShield in its profile) takes damage too: Change with the same shield rule (Pulse::Attributes::ApplyDamageToPools), so both paths give the same values. The damage execution hands its FPulseDamageResult to the health set as payload; the set reports what it did (FPulseHealthChange) and the combat component turns both into the final result (Pulse::Combat::MakeDamageResult).
The damage pipeline
Pulse::Combat::ApplyDamage(Target, Spec) (Blueprint: Apply Damage, Apply Simple Damage) runs on the authority:
- Friendly fire: damage from an instigator to a friend is dropped unless
bAllowFriendlyFireis set. - Target with ability system and health set: the damage effect (
UPulseDamageEffect, or the class in the settings or in the spec) is applied. Amount and crit permission travel as set-by-caller values, the damage type and the spec tags as dynamic asset tags, location and direction as hit result of the effect context. UPulseDamageExecutionruns the damage modifiers and writes the result toIncomingDamage. Dead targets take no damage.- The health set applies it, fills the result (shield absorbed, health damage, killed) and reports it.
- Targets without ability system implementing
IPulseDamageablegetReceivePulseDamage(Spec)instead.Evaluate Damageruns the same modifiers for them. WhenIsHitByAnyAttackerreturns true, attacks that only hit enemies (bOnlyHostile) hit them too, as resource nodes and breakable objects want; they decide themselves inReceivePulseDamagewhat a hit does.
FPulseDamageSpec: Amount, DamageType (Pulse.Combat.DamageType.*, empty = default type), Tags (for example Melee, Heavy, Pulse.Combat.Damage.Unblockable), Instigator, Causer, HitLocation, HitDirection, bCanCrit, EffectClass.
FPulseDamageResult: bApplied, BaseAmount, Amount, ShieldAbsorbed, HealthDamage, StaminaDamage, DamageType, Tags, bCritical, bBlocked, bImmune, bShieldBroken, bKilled, Instigator, Causer, Target, HitLocation, HitDirection, Direction (front, back, left, right of the target).
Other functions: Apply Healing (returns the health actually restored; the dead are not healed; a Change with Op Add on Pulse.Stat.Health of the contract, so it works for every attribute source), Kill (ignores modifiers and blocking), Revive (sets health to its share of the maximum with Change SetPercentOfMax), Set Max Health, Is Hostile, Is Alive (the combat state, without a combat component the health of the source is not depleted), Classify Hit Direction. The ability system of an actor comes from Pulse::Attributes::GAS::FindAbilitySystem of Pulse Foundation.
Damage types
Native types: Pulse.Combat.DamageType.Physical (default), .Fire, .Frost, .Lightning, .Poison, .Magic. Add your own below Pulse.Combat.DamageType in the tag settings.
Damage while an attribute is empty
Starving or drowning is not a damage of PulseCombat: a band at 0 of the empty attribute gives Pulse.Stat.Health a negative Rate (see Attributes that change on the game clock). The health falls on the game clock, and the combat component dies on Depleted of health as after a hit, without a killer. This loss passes no damage modifiers, takes no shield and shows no damage numbers.
Damage modifiers
Modifiers are instanced structs derived from FPulseDamageModifier. They come from three lists and run sorted by Priority (lowest first):
UPulseCombatSettings::GlobalDamageModifiers(every damage; default: immunity while invulnerable),OutgoingDamageModifiersof the attacker’s combat component,IncomingDamageModifiersof the target’s combat component.
| Modifier | Default priority | Does |
|---|---|---|
| Immunity | -100 | No damage while the target’s tags match TargetQuery (default Pulse.Combat.State.Invulnerable), optional DamageQuery. Stops the chain. |
| Adjust | 0 | (Amount + Add) * Multiplier when Condition (on damage type and tags) matches. |
| Type Resistance | 10 | Multiplier per damage type; parent types match children. |
| Critical | 20 | With Chance the damage is multiplied (bCanCrit of the spec must allow it). |
| Block | 30 | While the target has BlockTag (Pulse.Combat.State.Blocking) and the attacker is within MaxAngle in front: Amount * Multiplier; the blocked part can cost stamina (StaminaPerBlockedDamage). Unblockable damage ignores it. |
Damage with Pulse.Combat.Damage.IgnoreModifiers skips all modifiers. Write own modifiers in C++ by overriding Modify(Context, InOutResult); Pulse::Combat::CalculateDamage is a pure function and easy to test.
Every chain ends with Tuning (FPulseDamageModifier_Tuning, priority 1000, added by GatherAllDamageModifiers): the tuning knobs of PulseFoundation multiply what is left. Pulse.Tuning.Combat.DamageTaken counts when the target is a player, also with a value a player set for themselves; Pulse.Tuning.Combat.DamageDealt counts when the source is a player. The damage type and the tags of the damage are the tags of the context, so a value can change one type only (“fire hurts players twice as much”).
Damage calculator
Pulse::Combat::Calculator (Damage/PulseDamageCalculator.h) shows the damage of one hit line by line, without a world, for editors and tests. Calculate(Attacker, Target, Modifiers, Adjustments, Seed) returns an FPulseDamageBreakdown:
Lines: Base, one line per modifier in the order the chain runs them (kind Modifier, Resistance or Tuning, with itsSource,ModifierType,Priority,Before,Afterand the flags), Final. A modifier after an immunity, or every modifier of damage withPulse.Combat.Damage.IgnoreModifiers, isbSkipped.Result: theFPulseDamageResultof the whole chain,Targetafter the adjustments,ShieldAbsorbed,HealthDamage(byPulse::Attributes::ApplyDamageToPools, as the health set takes it: shield first, then health, a target at 0 health takes nothing) andHitsToKill(0 = never).
The calculator cannot drift from the real damage: every line is Pulse::Combat::CalculateDamage over the modifiers up to it, and the result is CalculateDamage over all of them, each call with a new random stream of Seed, so critical hits draw the same numbers in every line. After is at least 0, as at the end of the chain.
| Input | Fields |
|---|---|
FPulseDamageAttackerValues | BaseDamage, DamageType (empty = the default type), DamageTags, Tags, bCanCrit, bIsPlayer, HitDirection |
FPulseDamageTargetValues | Health, MaxHealth, Shield, Tags (Blocking, Invulnerable, kinds of enemies), Forward, bIsPlayer |
FPulseDamageCalculatorModifier | Source (Global, Outgoing, Incoming, a weapon) and the modifier; AddModifiers(List, Source, Out) copies a list such as GlobalDamageModifiers |
FPulseDamageAdjustments | What a difficulty level changes: DamageTaken, DamageDealt, EnemyHealth and Modifiers of its own |
Adjustments enter at one place, ApplyAdjustments: the modifiers of the level are added (source Adjustment), DamageTaken (target is a player) and then DamageDealt (attacker is a player) become Adjust modifiers with the priority of the Tuning modifier (source Tuning), and EnemyHealth scales health and max health of a target that is no player (the health keeps its share). MakeAdjustments(Tuning, Attacker, Target) reads the three factors from an FPulseTuningData with Pulse::Tuning::Evaluate, so a source of each difficulty level gives one column per level. Personal sources are left out there; players choose them for themselves.
Damage calculator in the editor
The previews of attack definitions and projectile definitions show the calculator with a column per difficulty level of Pulse Difficulty: Base is the hit without any adjustment, each level column puts in the knobs of the level (MakeAdjustments) and the adjustments of the workshop. Without levels, a column Adjusted appears as soon as the workshop adjusts something. The rows are damage, shield absorbed, health damage, target health and hits to kill; values that differ from Base are bright.
- Before and after: the chosen column against Base, one row per value that changes (the old value faint, the new one bright), in the look of the Before/After panel of the Pulse Editor Kit.
- Breakdown: the lines of the chosen column (
Calculate), with their source, the damage before and after each modifier and the flags (skipped, critical, blocked, immune). - Calculator (the live test tab next to the details): the attacker values the asset does not set (tags, player, hit direction), the target (health, max health, shield, tags such as Blocking or a kind of enemy, facing, player) and adjustments of your own (damage modifiers, the factors Damage Taken, Damage Dealt and Enemy Health). They are not saved; use them to try a change before you put it into a difficulty level.
The modifiers of the chain are the GlobalDamageModifiers of the settings; every column uses seed 0, so critical hits draw the same numbers in every column. The rules are pure functions of the editor module (Pulse::Combat::Editor: MakeMeleeAttacker, MakeRangedAttacker, CombineAdjustments, CalculateColumns, MakeDamageValues). Spec: PulseGameplay.Editor.CombatWorkshop.
The combat component
UPulseCombatComponent (Pulse Combat) turns an actor with health set into a combatant:
- Life:
Alive/Deadwith the last killer as one replicated value,FPulseLifeState(GetLifeState). On death it addsPulse.Combat.State.Dead(replicated loose tag), cancels abilities (CancelAbilitiesWithTagsOnDeath, empty = all) and remembers the killer twice: as reference (GetKiller, null on machines where the killer is not relevant or once it is gone) and as values every machine can read,FPulseKillerIds(GetKillerIds,GetKillerPlayerId):PlayerId: the player id of a player killer; empty for NPCs and for bots, even when they have a player state.ActorKey: the name-based save key of a killer placed in a level (with its streamed level) or with a Save Identity, the same on every machine and in later sessions; none for players and for actors spawned while playing.TeamandActorClass: what kind of killer it was.KillandReviveon the authority. Reviving clears killer and ids. The rules are pure functions inPulse::Combat::Life(PulseLifeState.h:MakeDead,MakeAlive,MakeKillerIds,DiffLifeStates; specsPulseCombat.Life).
- Hostility:
IsHostileTo. The teams come from Pulse Foundation (Pulse::Team::GetTeam: a Pulse Team component or the team interface on the actor or its player, see the Teams page of the Pulse Foundation docs). The rule isUPulseCombatSettings::HostilityRule(default Teams: same or allied teams are friends, actors without team are enemies of everyone unlessbNoTeamIsHostileis off,Pulse.Team.Neutralis no one’s enemy). Teams of Pulse Foundation:Pulse.Team.Player,Pulse.Team.Enemy,Pulse.Team.Neutral; games add their own belowPulse.Team. - Attribute sets:
Default Attribute Sets(default: the health set) are added to the ability system on the authority when it has none of their class, with their default values, so a Blueprint actor with an Ability System Component and Pulse Combat is a combatant without C++ or a data table. Clients get the sets with the ability system. - Startup effects: applied once the ability system is found (none by default).
- Down: before a new depletion kills the combatant the authority asks Should Go Down (a Blueprint override, or by default the native listeners of
OnShouldGoDownNative: the downed mode of the respawn component). A combatant that goes down stays alive at empty health (Is Downed) withPulse.Combat.State.Downed(owner tag on every machine, loose tag on the ability system; melee and ranged attacks are blocked by it) until its health comes back (a revive, healing) or it dies;OnDownedChangedNativetells both on the authority.Killends a down at once. - Death: health reaching its minimum (
DepletedofPulse.Stat.Health) kills the combatant. A dead player that is loaded, or that a joining client sees, only gets the dead state and the death tag (CatchUpLoadorReplication): no kill reward, no death bag, no second respawn. - Regeneration: a rate of the attribute rules (see Attributes). The combat component sets no regeneration tags any more: on death it puts
Pulse.Combat.State.Deadon the owner and callsPulse::Attributes::NotifyOwnerTagsChanged; list the tag in the Pause Tags of the profile to pause regeneration of the dead, with Pause ModeGainOnlyso a drain of a band (starving) is not held. - Events:
On Damaged(FPulseDamageEvent),On Healed,On Death,On Revived(dynamic and native), gameplay eventsPulse.Combat.Event.Damaged,.Died,.Revivedon the authority for ability triggers.OnDamageResultNativegives C++ listeners the fullFPulseDamageResulton the authority right beforeOn Damaged(the tags of the damage and those its modifiers added, also for immune and fully blocked hits), for add-ons that react to what a modifier decided. - Ability system later: call
Pulse::Attributes::GAS::NotifyAbilitySystemReady(Blueprint Notify Ability System Ready) afterInitAbilityActorInfo; the combat component calls it when it finds its ability system, andRefresh Ability Systemfinds it again when you give the ability system or the health set later.
Health of enemies: the tuning knob Pulse.Tuning.Combat.EnemyHealth scales the max health of every combatant that is no player (its owned tags are the tags of the context). The component applies it on the authority as a Multiply modifier on Pulse.Stat.MaxHealth with the source key Tuning: when the ability system binds, when a player takes or leaves the pawn, and at once when the knob changes (the combat subsystem listens to Pulse.Message.Tuning.Changed). The max change rule of the rules decides what happens to the health; a max that game code sets stays the base of the modifier.
Hit reactions
UPulseHitReactComponent (Pulse Hit React) picks one of its Reactions for every hit: side of the hit (Directions, none = all), minimum damage in percent of MaxHealth (the highest that is reached wins) and damage types. It plays the montage on every machine (character mesh, or the skeletal mesh with MeshComponentTag) and, on the authority, staggers for StaggerDuration (Pulse.Combat.State.Staggered, cancels CancelAbilitiesWithTagsOnStagger). The hit react holds the tag with a count of its own (Pulse::Combat::HoldStateTag): a stagger of another source, such as the poise of PulseCombatAction, keeps its count, and the tag stays until every source let go; a new hit while staggered only extends the time. The stagger replicates as a state of the component (IsStaggered, push model, every machine), and every machine adds its own local count from it. It is never a replicated loose tag: a client applies those with an absolute count, which would overwrite the counts other sources add on that client, so the end of a hit react stagger would end a running poise stagger there and the owner would predict attacks the server blocks. Kills, immune and (unless bReactWhenBlocked) blocked hits do not react. Event On Hit React.
Targeting
UPulseTargetingComponent (Pulse Targeting) finds combatants in front of the view (the controller’s view point, else the actor’s eyes):
Find Soft Target/Find Targets: inSearchDistanceandSearchAngle, ranked by angle and distance (DistanceWeight), only enemies (bOnlyHostile) and visible ones (bRequireLineOfSight).- Lock-on:
Toggle Lock On,Set Lock On Target,Switch Lock On Target(left/right),Get Lock On Target,On Lock On Changed. The lock breaks when the target dies or is farther thanLockOnBreakDistance. - The camera stays with the game;
Get Rotation To Targethelps to turn towards the target.
View models
| View model | For | Values |
|---|---|---|
UMVVMPulseCombatant | Health bars of the own player (create with the Pulse Player View Model Resolver) or of any actor (Set Combatant) | Health, MaxHealth, Shield, MaxShield, Stamina, MaxStamina, bIsDead, GetHealthPercent, GetShieldPercent, GetStaminaPercent, HasShield, HasStamina (the source knows Pulse.Stat.Stamina), GetHealthViewModel, GetShieldViewModel, GetStaminaViewModel; events On Damaged, On Death, On Revived |
UMVVMPulseAttributeValue (Pulse Foundation) | Any Pulse attribute of any source (mana, armor) | Value, MaxValue, MinValue, RatePerSecond, Band, GetPercent, HasAttribute; set Attribute (a tag below Pulse.Stat) |
UMVVMPulseCombatant reads health, shield and stamina through the attribute contract (Pulse.Stat.Health, .MaxHealth, Pulse.Stat.Shield, .MaxShield, Pulse.Stat.Stamina, .MaxStamina) and updates on the events of the attribute source (no polling), so it shows a target with the Pulse Attributes component like one with an ability system. The percents are FPulseAttributeValue::Percent of the source, the value between its bounds kept at most at the maximum. bIsDead comes from the combat component; without one the combatant is dead while its health is depleted (On Death and On Revived only come from a combat component). Both view models follow the player’s pawn after respawns.
Messages
| Channel | When | Payload |
|---|---|---|
Pulse.Message.Combat.Damaged | On Damaged | FPulseCombatMessage (Target, Instigator, Amount, DamageType, bCritical, bKilled, Team of the target) |
Pulse.Message.Combat.Healed | On Healed | FPulseCombatMessage |
Pulse.Message.Combat.Died | On Death | FPulseCombatMessage (Instigator = killer) |
Pulse.Message.Combat.Revived | On Revived | FPulseCombatMessage |
The context of the messages (Pulse::Combat::MakeMessageContext) has the combatant as Target, the attacker, healer or killer as Instigator, the damage type in Tags and the damage or healing in Amount (1 for Died and Revived). Player is the player the message is about: the instigator when it belongs to a player (a kill of the player), else the target when it does (the player took damage). Quests and achievements can count kills with them (for example “defeat the boss”) without a bridge. A client that joins (or sees the actor again) while a combatant is dead gets Died with CatchUp Replication, so kill feeds and counters leave it out; deaths after that are new events.
Settings
Project Settings > Pulse > Gameplay > Combat (UPulseCombatSettings): DamageEffectClass, DefaultDamageType, GlobalDamageModifiers, bAllowFriendlyFire, HostilityRule.
Debugging and cheats
The combat component is a snapshot provider: health, shield, stamina, state tags, modifiers and the last damage show in the Pulse Debugger and the gameplay debugger category Pulse. Damage, deaths and revives are written to the timeline.
| Cheat | Does |
|---|---|
PulseCombatGrant [max health] [stamina 1/0] | Ability system (if missing), health set, optional stamina set and combat component (team Player) for the pawn |
PulseCombatSpawnDummy [max health] [shield] [team] | Training dummy in front of the player; tips over when it dies and stands up after 3 s |
PulseCombatHit <amount> [type] | The player hits the combatant in front (or the nearest one) |
PulseCombatDamage <amount> [type] [target], PulseCombatHeal <amount> [target] | Damage or heal the player or the target |
PulseCombatKill [target], PulseCombatRevive [target or all] | Kill or revive |
PulseCombatGod, PulseCombatTag <state> [target] | Toggle invulnerability or any state tag (Blocking, Staggered, …) |
PulseCombatInfo [target] | Prints the snapshot |
PulseCombatLockOn | Toggles the lock-on of the local player |
In PIE, clients need EnableCheats first; damage cheats run on the server.