Skip to content

Health Components

Overview

Health is driven by the Ability System (attributes for health, max health, resource, regen). UMIPBaseHealthComponent reads from the ASC and broadcasts change/death; UMIPPlayerHealthComponent adds auto regen (health and resource) and death/respawn delegates; UMIPMobHealthComponent handles mob death (EXP, loot, kill). UMIPPlayerHealthWidgetComponent is a widget component used for the player health nameplate.

Key traits:

  • Server-authoritative: Health values live in the attribute set; damage/healing via gameplay effects. Death and respawn flow are server-driven.
  • UMIPBaseHealthComponent – Pawn component; InitializeWithAbilitySystem(); health/max health/resource/regen getters and normalized; delegates for health changed, max health changed; HandleOutOfHealth for death handling.
  • UMIPPlayerHealthComponent – Timers for health and resource regen; death/respawn delegates.
  • UMIPMobHealthComponent – No auto-init in BeginPlay; mob calls InitializeWithAbilitySystem when ready; on death: EXP rewards, loot, kill.

All paths below are relative to Plugins/ModularInventoryPlus/Source/ModularInventoryPlus/.


Key Classes & Files

Class File
UMIPBaseHealthComponent Public/Health/MIPBaseHealthComponent.h
UMIPPlayerHealthComponent Public/Health/MIPPlayerHealthComponent.h
UMIPMobHealthComponent Public/Health/MIPMobHealthComponent.h
UMIPPlayerHealthWidgetComponent Public/Health/MIPPlayerHealthWidgetComponent.h

UMIPBaseHealthComponent

  • Base: UMIPBasePawnComponent.
  • Attachment: Pawn (player or mob).
  • Delegates: OnHealthChangedDelegate, OnMaxHealthChangedDelegate (FMIPHealth_AttributeChanged).
  • API: InitializeWithAbilitySystem() (virtual). Getters: GetHealth(), GetMaxHealth(), GetHealthNormalized(), IsHealthFull(), GetHealthRegen(); resource: GetResource(), GetMaxResource(), GetResourceNormalized(), IsResourceFull(), GetResourceRegen().
  • Override: OnPawnComponentReady_Implementation, OnUnregister; HandleOutOfHealth(EffectInstigator, EffectCauser, GameplayEffectSpec, InDamageDealt) (virtual) – subclasses implement death behavior. Uses UMIPAbilitySystemComponent and vital attribute set.

UMIPPlayerHealthComponent

  • Base: UMIPBaseHealthComponent.
  • Auto regen: RegeneratingHealthRate, RegeneratingResourceRate (EditDefaultsOnly); timers TryStartRegeneratingHealth/Resource, StopRegeneratingHealth/Resource, RegeneratingHealth/Resource().
  • Delegates: OnDeathStartedDelegate, OnRespawnedDelegate, OnDeathStateChangedDelegate(EMIPDeathState).
  • Flow: Death/respawn handled in base or overrides; regen starts/stops based on health/resource state.

UMIPMobHealthComponent

  • Base: UMIPBaseHealthComponent.
  • Attachment: Mob pawn (AMIPBaseMob). Initialization is not in BeginPlay; the mob spawner or mob actor calls InitializeWithAbilitySystem() when ready.
  • API: ResetMobHealthComponent() – called when mob spawns or aggro goes out of range.
  • Override: HandleOutOfHealth – calls GiveMobEXPRewardsAndKill(...) (EXP, ability EXP, loot from UMIPLootDefinitionAsset). Helpers: GetMobInfo(), GetOwnerMob(), GetLootDefinitionAsset().

UMIPPlayerHealthWidgetComponent

  • Base: UWidgetComponent (Engine).
  • Attachment: Created by UMIPAdvNameplateCreatorComponent for the health nameplate.
  • API: InitializePlayerHealthWidgetComponent(InOtherPlayerActor) – sets up widget to display the other actor's health (e.g. for party/nameplate).

Integration

  • UMIPAbilitySystemComponent / UMIPPlayerAbilitySystemComponent hold the attribute set; health component reads and listens to attribute changes.
  • Death/respawn is wired to game mode or respawn logic via the delegates.
  • Health nameplate is created by UMIPAdvNameplateCreatorComponent and uses UMIPPlayerHealthWidgetComponent; see Character.