Space Plunder
Loading...
Searching...
No Matches
UBTD_LowHealth Class Reference

#include <BTD_LowHealth.h>

Inheritance diagram for UBTD_LowHealth:

Public Member Functions

 UBTD_LowHealth ()
 

Protected Member Functions

virtual FString GetStaticDescription () const override
 
virtual bool CalculateRawConditionValue (UBehaviorTreeComponent &OwnerComp, uint8 *NodeMemory) const override
 

Protected Attributes

float LowHealthAmount = 20.0f
 
bool bUseHealthPercent = true
 
float LowHealthPercent = 20.0f
 

Constructor & Destructor Documentation

◆ UBTD_LowHealth()

UBTD_LowHealth::UBTD_LowHealth ( )
9{
10 NodeName = TEXT("Check Low Health");
11}

Member Function Documentation

◆ CalculateRawConditionValue()

bool UBTD_LowHealth::CalculateRawConditionValue ( UBehaviorTreeComponent & OwnerComp,
uint8 * NodeMemory ) const
overrideprotectedvirtual
37{
38 if(OwnerComp.GetAIOwner() == nullptr || OwnerComp.GetAIOwner()->GetPawn() == nullptr){return false;}
39 const ICharacterBaseInterface* BaseCharacter = Cast<ICharacterBaseInterface>(OwnerComp.GetAIOwner()->GetPawn());
40 if(BaseCharacter != nullptr)
41 {
42 float Health = 0.0f;
43 float MaxHealth = 0.0f;
44 const bool bSuccess = BaseCharacter->GetCharacterHealth(Health, MaxHealth);
45 if(bSuccess)
46 {
48 {
49 const float HealthPercent = (Health / MaxHealth) * 100.0f;
50 return HealthPercent < LowHealthPercent;
51 }
52 return Health < LowHealthAmount;
53 }
54 }
55 return false;
56}
Definition Health.Build.cs:6
Definition CustomCharacter.h:19
virtual bool GetCharacterHealth(float &Health, float &MaxHealth) const =0
bool bUseHealthPercent
Definition BTD_LowHealth.h:33
float LowHealthPercent
Definition BTD_LowHealth.h:35
float LowHealthAmount
Definition BTD_LowHealth.h:31

◆ GetStaticDescription()

FString UBTD_LowHealth::GetStaticDescription ( ) const
overrideprotectedvirtual
14{
15 FString Description;
16 Description += FString::Printf(TEXT("\nTrigger when Health is Below: "));
18 {
19 const FString Percent = "%";
20 Description += FString::Printf(TEXT("\n%2.f %s"), LowHealthPercent, *Percent);
21 }
22 else
23 {
24 Description += FString::Printf(TEXT("\n%2.f"), LowHealthAmount);
25 }
26 return Description;
27}

Member Data Documentation

◆ bUseHealthPercent

bool UBTD_LowHealth::bUseHealthPercent = true
protected

◆ LowHealthAmount

float UBTD_LowHealth::LowHealthAmount = 20.0f
protected

◆ LowHealthPercent

float UBTD_LowHealth::LowHealthPercent = 20.0f
protected

The documentation for this class was generated from the following files: