5#include "CoreMinimal.h"
6#include "NiagaraComponent.h"
9#include "CharacterHealthComponent.generated.h"
19DECLARE_DYNAMIC_MULTICAST_DELEGATE_SevenParams(FOnDamageHit, AController*, InstigatedBy,
const float, TotalDamage,
const class UDamageType*, DamageType,
const FName&, HitBone,
const FVector&, HitLocation,
const bool, bKillingHit,
const bool, bInjuredPart);
20DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams(FOnHitReaction,
const float,
Damage,
const FVector&, HitLocation,
const FName&, BoneName,
const FVector&, ShotFromDirection,
const UDamageType*, DamageType);
22DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams(FOnHealthAndShieldChanged,
const float,
Health,
const float, MaxHealth,
const float, ShieldHealth,
const float, MaxShieldHealth,
const class UDamageType*, DamageType);
25UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent) )
31 UCharacterHealthComponent();
34 UPROPERTY(BlueprintAssignable, Category = "
Health")
35 FOnHealthAndShieldChanged OnHealthAndShieldChanged;
36 UPROPERTY(BlueprintAssignable, Category = "
Health")
37 FOnCharacterDeathEvent OnDeath;
38 UPROPERTY(BlueprintAssignable, Category = "
Health")
39 FOnInjuredBodyPart OnInjuredBodyPart;
40 UPROPERTY(BlueprintAssignable, Category = "
Health")
41 FOnShieldBreak OnShieldBreak;
42 UPROPERTY(BlueprintAssignable, Category = "
Health")
43 FOnNonLethalKnockOut OnNonLethalKnockOut;
44 UPROPERTY(BlueprintAssignable, Category = "
Health")
47 UPROPERTY(BlueprintAssignable, Category = "
Health")
48 FOnDamageHit OnDamageHit;
49 UPROPERTY(BlueprintAssignable, Category = "
Health")
50 FOnHitReaction OnHitReaction;
55 virtual
bool LoadComponentData(const FString& SlotName) override;
56 virtual
bool SaveComponentData(const FString& SlotName) override;
58 virtual
void SetupComponentWidgets() override;
59 virtual
void SetupComponent(USkeletalMeshComponent* SkeletalMesh, UAnimInstance* AnimationInstance, AController* Controller, AActor* HUDReference, const
bool bNPC, const
bool bDead) override;
62 UFUNCTION(BlueprintCallable, Category = "
Health")
63 FORCEINLINE
float GetHealth()
const {
return Health;}
64 UFUNCTION(BlueprintCallable, Category=
"Health")
65 FORCEINLINE
float GetMaxHealth()
const {
return MaxHealth;};
66 UFUNCTION(BlueprintPure, BlueprintCallable, Category =
"Health")
67 FORCEINLINE
float GetShieldHealth()
const {
return ShieldHealth;}
68 UFUNCTION(BlueprintPure, BlueprintCallable, Category =
"Health")
69 FORCEINLINE
float GetMaxShieldHealth()
const {
return MaxShieldHealth;}
70 UFUNCTION(BlueprintPure, BlueprintCallable, Category =
"Health")
71 FORCEINLINE TArray<
FBodyPart> GetBodyParts()
const {
return BodyParts;}
72 UFUNCTION(BlueprintPure, BlueprintCallable, Category =
"Health")
73 FORCEINLINE
bool GetIsKnockedOut()
const {
return bIsKnockedOut;}
75 UFUNCTION(BlueprintPure, BlueprintCallable, Category =
"Health")
76 TArray<
FBodyPart> GetInjuredBodyParts() const;
78 UFUNCTION(BlueprintCallable, Category = "
Health")
79 bool LimbDamage(const
float Damage, const FName& HitBone, const UDamageType* DamageType, const FVector& HitLocation);
81 UFUNCTION(BlueprintCallable, Category="
Health|KO")
86 UFUNCTION(BlueprintCallable)
87 void UpdateShieldAndHealth(const UDamageType* DamageType =
nullptr);
90 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Limbs", meta = (EditCondition = "!bALSSkeleton && !bUnrealSkeleton && !bUseCustomBones"))
92 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Limbs", meta = (EditCondition = "!bSyntySkeleton && !bUnrealSkeleton && !bUseCustomBones"))
94 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Limbs", meta = (EditCondition = "!bALSSkeleton && !bSyntySkeleton && !bUseCustomBones"))
96 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Limbs", meta = (EditCondition = "!bALSSkeleton && !bSyntySkeleton && !bUnrealSkeleton"))
98 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Limbs", meta = (EditCondition = "bUseCustomBones"))
99 TArray<FName> HeadBones;
100 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Limbs", meta = (EditCondition = "bUseCustomBones"))
101 TArray<FName> SpineBones;
102 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Limbs", meta = (EditCondition = "bUseCustomBones"))
103 TArray<FName> RightArmBones;
104 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Limbs", meta = (EditCondition = "bUseCustomBones"))
105 TArray<FName> LeftArmBones;
106 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Limbs", meta = (EditCondition = "bUseCustomBones"))
107 TArray<FName> RightLegBones;
108 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Limbs", meta = (EditCondition = "bUseCustomBones"))
109 TArray<FName> LeftLegBones;
110 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Limbs", meta = (EditCondition = "bUseCustomBones"))
111 TArray<FName> RightHandBones;
112 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Limbs", meta = (EditCondition = "bUseCustomBones"))
113 TArray<FName> LeftHandBones;
114 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Limbs")
115 float BodyPartMaxHealth = 50.0f;
116 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Limbs")
117 float BodyPartInjuredHealthLevel = 25.0f;
118 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|KO")
119 bool bCanBeKnockedOut = false;
121 UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite, Category = "
Health|Shield")
122 bool bHasShield = false;
124 virtual
void BeginPlay() override;
125 virtual
void ComponentSetupComplete() override;
128 virtual
void TakeDamage(AActor* DamagedActor,
float Damage, const UDamageType* DamageType, AController* InstigatedBy, AActor* DamageCauser);
130 virtual
void TakePointDamage(AActor* DamagedActor,
float Damage, class AController* InstigatedBy, FVector HitLocation, class UPrimitiveComponent* FHitComponent, FName BoneName, FVector ShotFromDirection, const class UDamageType* DamageType, AActor* DamageCauser);
132 virtual
void TakeRadialDamage(AActor* DamagedActor,
float Damage, const class UDamageType* DamageType, FVector Origin, const FHitResult& HitInfo, class AController* InstigatedBy, AActor* DamageCauser);
134 virtual
void Death(AActor* Causer, AController* DeathInstigator, const UDamageType* DamageType);
136 void OnDeathReplicated();
142 UFUNCTION(BlueprintCallable, Category="
Health|KO")
143 void KnockedOutSleep();
146 UFUNCTION(BlueprintCallable, Category="Heath|Effects")
147 void ImpactEffects(const
EBodyPartName BodyPartName, const FVector& HitLocation, const
bool bIsNonLethal = false, const FVector& ShotFromDirection = FVector::ZeroVector, const
float Damage = 10.0f);
148 UFUNCTION(NetMulticast, Unreliable, BlueprintCallable, Category="Heath|Effects")
149 void MulticastImpactEffects(const
EBodyPartName BodyPartName, const FVector& HitLocation, const
bool bIsNonLethal, const FVector& ShotFromDirection, const
float Damage);
151 UFUNCTION(BlueprintCallable, Category="Heath|Effects")
152 void BleedingEffects(const
EBodyPartName BodyPartName, const FVector& HitLocation);
153 UFUNCTION(NetMulticast, Unreliable, BlueprintCallable, Category="Heath|Effects")
154 void MulticastBleedingEffects(const
EBodyPartName BodyPartName, const FVector& HitLocation);
156 UPROPERTY(ReplicatedUsing=OnRep_Health)
158 UPROPERTY(ReplicatedUsing=OnRep_Health, EditAnywhere, BlueprintReadWrite, Category = "
Health|
General")
159 float MaxHealth = 100.0f;
165 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Shield")
166 const UDamageType* ShieldDamageType;
167 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Shield")
168 bool bShieldBroken = false;
169 UPROPERTY(ReplicatedUsing=OnRep_Shield, EditAnywhere, BlueprintReadWrite, Category = "
Health|Shield", meta = (EditCondition = "bHasShield"))
170 float MaxShieldHealth = 100.0f;
172 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Shield", meta = (EditCondition = "bHasShield"))
173 float ShieldTimeToRegen = 5.0f;
175 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Shield", meta = (EditCondition = "bHasShield"))
176 float AmountToRecharge = 0.1f;
178 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Traits")
179 float EnduranceMaxHealthMultiplier = 2.0f;
181 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "
Health|KO")
182 bool bIsKnockedOut = false;
183 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "
Health|KO")
184 float KnockOutHealth = 50.0f;
185 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "
Health|KO")
186 float KnockOutTimeToWakeUp = 0.0f;
187 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|KO")
188 float KnockOutTimeToWakeUpDefault = 20.0f;
189 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "
Health|KO")
190 float KnockOutMaxHealth = 50.0f;
192 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "
Health|
Damage Multiplier")
193 float HeadDamageMultiplier = 2.5f;
194 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "
Health|
Damage Multiplier")
195 float SpineDamageMultiplier = 1.5f;
196 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "
Health|
Damage Multiplier")
197 float ArmDamageMultiplier = 1.0f;
198 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "
Health|
Damage Multiplier")
199 float HandDamageMultiplier = 0.5f;
200 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "
Health|
Damage Multiplier")
201 float LegDamageMultiplier = 0.8f;
204 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Traits")
205 float IntelligenceMaxShieldMultiplierBase = 10.0f;
206 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Traits")
207 float EnduranceMaxKnockedOutHealthMultiplier = 5.0f;
208 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Traits")
209 float LuckMultiplier = 2.0f;
213 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="
Health|Effects")
214 class UNiagaraSystem* BloodImpact;
215 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="
Health|Effects")
216 class UNiagaraSystem* DamageShieldImpact;
217 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="
Health|Effects")
218 class UNiagaraSystem* DamageNonLethalImpact;
219 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="
Health|Effects")
220 class UNiagaraSystem* BleedingParticles;
221 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="
Health|Effects")
222 TArray<UNiagaraComponent* > BleedingSystems;
224 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Effects")
225 float BloodSpamWaitTime = 0.5f;
226 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Effects")
227 int32 BloodAmountMultiplier = 3;
228 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Effects")
229 int32 BloodAmountMin = 5;
230 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Effects")
231 int32 BloodAmountMax = 250;
233 UPROPERTY(ReplicatedUsing=OnDeathReplicated)
234 bool bDeathOnce = false;
236 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Debugging", meta=(EditCondition="bCheatsEnabled"))
237 bool bInfiniteHealth = false;
238 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Health|Debugging", meta=(EditCondition="bCheatsEnabled"))
239 bool bInfiniteShield = false;
243 UFUNCTION(BlueprintCallable, Category = "
Health")
244 void LoadHealthAndShieldFromSave(const
float LoadedHealth, const
float LoadedShield, const TArray<
FBodyPart>& LoadedBodyParts);
246 void InjuredBodyPart(const
EBodyPartName BodyPart, const FVector& HitLocation);
248 void SetupSyntySkeleton();
249 void SetupALSSkeleton();
250 void SetupCustomSkeleton();
253 virtual
void HealthDamage(const
float Damage);
254 void ShieldDamage(const
float Damage);
255 void NonLethalDamage(const
float Damage);
258 void ShieldBreak() const;
263 void UpdateHealthAndShieldHUDElement(const
float InHealth, const
float InMaxHealth, const
float InShieldHealth, const
float InMaxShieldHealth, const class UDamageType* InDamageType);
265 void UpdateHealthHUDElement(const
float InHealth, const
float InMaxHealth,const class UDamageType* InDamageType);
267 UPROPERTY(EditAnywhere, Category="HUD|
Health")
268 TSoftClassPtr<class UUserWidget> HealthHUDWidgetClass;
270 UPROPERTY(ReplicatedUsing=OnRep_Shield, meta = (EditCondition = "bHasShield"))
271 float ShieldHealth = 100.0f;
274 const UDamageType* LastDamageType;
275 void CheckShieldRegen();
276 void PreventBloodSpam();
277 bool bCanSpawnBlood = true;
278 bool bKillingHitOnce = true;
291 FTimerHandle ShieldTimerHandle;
292 FTimerHandle KnockOutTimerHandle;
293 FTimerHandle BloodPreventSpamTimerHandle;
EBodyPartName
Definition BaseData.h:133
EDeathType
Definition BaseData.h:53
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnShieldBreak)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_SevenParams(FOnDamageHit, AController *, InstigatedBy, const float, TotalDamage, const class UDamageType *, DamageType, const FName &, HitBone, const FVector &, HitLocation, const bool, bKillingHit, const bool, bInjuredPart)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnInjuredBodyPart, const EBodyPartName, InjuredBodyPart, const FVector &, HitLocation, const TArray< FBodyPart > &, AllBodyParts)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnNonLethalKnockOut, const class UDamageType *, DamageType, const float, WaitTime)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams(FOnHitReaction, const float, Damage, const FVector &, HitLocation, const FName &, BoneName, const FVector &, ShotFromDirection, const UDamageType *, DamageType)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnCharacterDeathEvent, AActor *, OwningActor, EDeathType, DeathType, AActor *, DeathCauser, AController *, DeathInstigator)
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
Definition Health.Build.cs:6
Definition HealthInterface.h:19
Represents a character component that can be added to an actor.
Definition HealthData.h:26