Status effects and attribute bars

Module PulseStatusHUD (depends on PulseAttributes, PulseHUD and the Gameplay Ability System). It adds two things to the Pulse HUD of every local player:

  • the effect bar: the active gameplay effects of the player’s pawn with icon, remaining time and stacks;
  • attribute bars: one bar for any gameplay attribute (mana, hunger, thirst, …), with name, icon and value.

Both follow the pawn of the player, also after a respawn, and work the same on a listen server, a dedicated server’s clients and in single player. Neither ticks: the effect bar updates its times on a timer while a timed effect shows, attribute bars update when the attribute changes.

Overview

Type What it is
UPulseStatusEffectUIData Status Effect UI Data: icon, name, text, kind and priority per effect tag
FPulseStatusEffectInfo One active effect as plain data (tags, start, duration, stacks)
FPulseStatusEffectEntry One icon of the effect bar: the effects with one UI entry, merged
Pulse::StatusHUD::BuildEntries Pure rule: filter by UI entry, merge, sort
UMVVMPulseStatusEffects Pulse Status Effects View Model: the list of entries for own widgets
UPulseStatusEffectBar, UPulseStatusEffectIcon Pulse Status Effect Bar and its icons
FPulseAttributeBarInfo One attribute bar: attribute, maximum, name, icon, color role, priority
UPulseAttributeBarWidget, UPulseAttributeBarList Pulse Attribute Bar and the list of all bars of a player
UPulseStatusHUDSubsystem Local player subsystem: puts both on the HUD, keeps the bars of the player
UPulseStatusHUDSettings Project Settings > Pulse > Core > Status HUD

Setup

  1. The Pulse HUD has to be on (bEnableHUD). The status HUD subsystem then adds the effect bar (top left) and the list of attribute bars (bottom left, above the health bar) to the Gameplay Root of the HUD layout. A layout that already contains a Pulse Status Effect Bar or a Pulse Attribute Bar List keeps its own.
  2. The pawn (or its player state) needs an ability system component, as for combat.
  3. Make a Status Effect UI Data asset (Add > Pulse > Core > Status Effect UI Data) with an entry per effect tag and add it to Effect UI Data in the Status HUD settings.
  4. For attribute bars, add entries to Attribute Bars in the settings, or let a plugin register them (below).

Which effects show

Only effects the player should see show up: an active effect is shown when one of its tags (asset tags, granted tags, also the dynamic tags of its spec) has an entry in a Status Effect UI Data asset of the settings. Cooldowns and internal effects without an entry stay hidden.

Entry field What it does
EffectTag Effects with this tag or a child of it use the entry. An exact tag wins over a parent; on a tie the first entry
DisplayName, Description Name and text (tooltip of the icon, own widgets)
Icon Icon (soft reference, loaded when shown)
Kind Buff, Debuff or Neutral: the color of the frame (Pulse.UI.Color.Positive, .Negative, .Outline)
SortPriority Higher comes first in the bar
bShowStacks, bShowRemaining Show the stacks (from 2 on) and the remaining time

Effects with the same entry become one icon: their stacks add up, and the icon shows the time of the effect that lasts longest (an effect without duration wins). The bar is sorted by priority, then by start (older first). Inhibited effects (their ongoing tag requirements fail) are not shown.

Remaining time

Gameplay effects run on the world time; on clients the ability system moves their start into the client’s clock. The view model copies start and duration once; the effect bar asks Pulse::StatusHUD::GetRemaining with the world time when its timer fires (every Remaining Update Interval, only while a timed effect is shown). The text is FormatRemaining: “8 s”, “3 min”, “2 h”, rounded up.

The view model

UMVVMPulseStatusEffects is the list for own widgets (MVVM, or C++ and Blueprint):

  • With the Pulse Player View Model Resolver or BindToPlayer it follows the player’s pawn; SetSource shows any actor (an enemy, a party member).
  • Entries (field notify) is the sorted list; OnEntriesChanged fires after a change. GetRemaining(Entry) and GetRemainingFraction(Entry) give the time left now.
  • It listens to the ability system (effect added, removed, stack and time changes, inhibition) and builds the list again once per frame. Building is the pure function Pulse::StatusHUD::BuildEntries over FPulseStatusEffectInfo copies, so own rules can be tested without an ability system.
  • UIDataOverride replaces the UI data of the settings for this view model.

Attribute bars

A Pulse Attribute Bar shows Attribute over MaxAttribute of the player’s pawn through a Pulse Attribute view model (UMVVMPulseAttribute, see Attributes). Without a maximum only the number shows. With Hide Without Attribute (default) the bar hides while the pawn has no attribute set with the attribute, so a bar for an attribute of another system stays out of levels without it.

A local player shows, in this order, a bar with the same id replacing an earlier one:

  1. the Attribute Bars of the Status HUD settings,
  2. bars other modules registered: IPulseStatusHUD::Get().RegisterAttributeBar(Bar) (e.g. in StartupModule of a plugin with its own attribute set; UnregisterAttributeBar in ShutdownModule),
  3. bars added at runtime: UPulseStatusHUDSubsystem::AddAttributeBar / RemoveAttributeBar (Blueprint too).

The list is sorted by SortPriority (higher on top). The id is Id, or the name of the attribute.

// A plugin with hunger and thirst registers its bars for every player
FPulseAttributeBarInfo hunger;
hunger.Attribute = UMySurvivalSet::GetHungerAttribute();
hunger.MaxAttribute = UMySurvivalSet::GetMaxHungerAttribute();
hunger.DisplayName = LOCTEXT("Hunger", "Hunger");
hunger.FillColorRole = Pulse::UI::Tags::Color_Warning;
IPulseStatusHUD::Get().RegisterAttributeBar(hunger);

Own widgets and look

The default widgets build their layout in C++ and take their look from the UI theme: the icon frame uses the role Pulse.UI.Panel.Inset, texts Pulse.UI.Text.Number, .Small and .Caption, the bar Pulse.UI.ProgressBar.Default with the fill color of FillColorRole (default Pulse.UI.Color.Accent). A Blueprint child can bind its own parts:

Widget Bindable parts
Pulse Status Effect Bar EffectList (any panel), IconClass
Pulse Status Effect Icon KindBorder, Frame, IconImage, StackText, RemainingText
Pulse Attribute Bar IconImage, NameText, FillBar, ValueText
Pulse Attribute Bar List BarList (any panel), BarClass

Set the classes in the Status HUD settings, or place the widgets in your HUD layout (then the subsystem adds none). SetViewModel on the effect bar shows another view model, SetSource on an attribute bar another actor.

Settings

Setting Default Description
EffectUIData the example data Status Effect UI Data assets; only effects with an entry show
bAddEffectBarToHUD true Adds the effect bar to the HUD
EffectBarClass UPulseStatusEffectBar The effect bar
EffectBarAnchor, EffectBarOffset (0, 0), (32, 32) Corner and distance
RemainingUpdateInterval 0.25 s How often the remaining times update
AttributeBars none Attribute bars of every player
bAddAttributeBarsToHUD true Adds the list of attribute bars to the HUD
AttributeBarListClass, AttributeBarClass UPulseAttributeBarList, UPulseAttributeBarWidget List and bar
AttributeBarsAnchor, AttributeBarsOffset (0, 1), (32, 150) Corner and distance
AttributeBarWidth 220 Width of one bar

Example

Play the PulseCore example map (a listen server and a client work too), then as the player:

PulseCoreGrant
PulseStatusHUDApply Burning 45 2
PulseStatusHUDApply Poisoned 300 3
PulseStatusHUDApply Regeneration -1
PulseStatusHUDBar PulseStaminaAttributeSet.Stamina PulseStaminaAttributeSet.MaxStamina Stamina

The effect bar shows the three example effects of DA_PulseStatusHUD_ExampleEffects (/PulseCore/StatusHUD) with their stacks and times; Burning goes away after 45 seconds. The example tags (Pulse.StatusHUD.Example.*) never come from a game, so the example data in the settings does no harm; replace it with your own.

Cheats

Cheat Runs on What it does
PulseStatusHUDApply <tag> [seconds] [stacks] server Applies an example effect with the tag (short names below Pulse.StatusHUD.Example); 0 seconds = 10 s, negative = until cleared
PulseStatusHUDClear server Removes the example effects
PulseStatusHUDBar <Set.Attribute> [Set.MaxAttribute or none] [name] local Adds an attribute bar for this player
PulseStatusHUDBarRemove <id> local Removes a bar added at runtime
PulseStatusHUDInfo local Prints the shown effects with their time left and the attribute bars

Log category LogPulseStatusHUD; the status HUD subsystem is a snapshot provider (category StatusHUD). Specs: PulseStatusHUD (filter by UI entry, remaining time, stacks, sorting, attribute bars), without world or ability system.


PulseCore plugin documentation.

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