From 20a1478bdc616f7175940d2f038f4d64e18a51b2 Mon Sep 17 00:00:00 2001 From: Cody Larkin Date: Sat, 29 Nov 2025 16:38:42 -0500 Subject: [PATCH] Added max health and current health to component take damage function created. need to decide how damage and health is managed --- .../PlayerCharacter/Components/DDIHealth.cpp | 10 +++-- .../PlayerCharacter/Components/DDIHealth.h | 41 ++++++++++++++++--- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/Source/OpenConflict/PlayerCharacter/Components/DDIHealth.cpp b/Source/OpenConflict/PlayerCharacter/Components/DDIHealth.cpp index e18c527..53fde41 100644 --- a/Source/OpenConflict/PlayerCharacter/Components/DDIHealth.cpp +++ b/Source/OpenConflict/PlayerCharacter/Components/DDIHealth.cpp @@ -9,11 +9,11 @@ UDDIHealth::UDDIHealth() // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features // off to improve performance if you don't need them. PrimaryComponentTick.bCanEverTick = true; - - // ... + MaxHealth = 100; + CurrentHealth = 100; + } - // Called when the game starts void UDDIHealth::BeginPlay() { @@ -32,3 +32,7 @@ void UDDIHealth::TickComponent(float DeltaTime, ELevelTick TickType, FActorCompo // ... } +// Called to cause damage +void UDDIHealth::TakeDamage(UDamageType* DamageType) +{ +} \ No newline at end of file diff --git a/Source/OpenConflict/PlayerCharacter/Components/DDIHealth.h b/Source/OpenConflict/PlayerCharacter/Components/DDIHealth.h index 17c1be2..eaa92ab 100644 --- a/Source/OpenConflict/PlayerCharacter/Components/DDIHealth.h +++ b/Source/OpenConflict/PlayerCharacter/Components/DDIHealth.h @@ -11,18 +11,49 @@ UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) class OPENCONFLICT_API UDDIHealth : public UActorComponent { GENERATED_BODY() +/*UPROPERTY and UFUNCTION declarations*/ +private: + /*Properties*/ -public: - // Sets default values for this component's properties - UDDIHealth(); + /*Functions*/ protected: + /*Properties*/ + UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Health") + float MaxHealth; //Stores the default max health of component + UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Health") + float CurrentHealth; //Stores the active health of component + + /*Functions*/ + UFUNCTION(BlueprintAuthorityOnly, BlueprintCallable, Category = "Health") + void TakeDamage(UDamageType* DamageType); + +public: + /*Properties*/ + + /*Functions*/ + + /*C++ only declarations*/ +private: + /*Properties*/ + + /*Functions*/ + +protected: + /*Properties*/ + + /*Functions*/ // Called when the game starts virtual void BeginPlay() override; -public: +public: + /*Properties*/ + + /*Functions*/ + // Sets default values for this component's properties + UDDIHealth(); + // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; - };