fixing things

This commit is contained in:
Nyx
2025-10-07 13:41:34 -06:00
parent d0105fde7d
commit 599cd852d0
10 changed files with 38 additions and 13 deletions

View File

@@ -66,3 +66,23 @@ void UHealthAttributeSet::PostGameplayEffectExecute(const FGameplayEffectModCall
}
}
void UHealthAttributeSet::PostAttributeChange(const FGameplayAttribute& Attribute, float OldValue, float NewValue)
{
Super::PostAttributeChange(Attribute, OldValue, NewValue);
if (Attribute == GetHealthAttribute())
{
const float ClampedHealth = FMath::Clamp(NewValue, 0.0f, GetMaxHealth());
if (ClampedHealth != NewValue)
{
SetHealth(ClampedHealth);
}
}
if (Attribute == GetMaxHealthAttribute())
{
const float ClampedMaxHealth = FMath::Max(1.0f, NewValue);
if (ClampedMaxHealth != NewValue)
{
SetMaxHealth(ClampedMaxHealth);
}
}
}

View File

@@ -13,7 +13,8 @@
/**
*
*/
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FAttributeChangedEvent, UAttributeSet*, AttributeSet, float, OldValue,
float, NewValue);
UCLASS()
class ELISTRIA_CALLING_API UHealthAttributeSet : public UElistriaAttributeSetBase
{
@@ -24,6 +25,10 @@ public:
virtual void PostGameplayEffectExecute(const FGameplayEffectModCallbackData& Data) override;
virtual void PostAttributeChange(const FGameplayAttribute& Attribute, float OldValue, float NewValue) override;
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
UPROPERTY(VisibleAnywhere,BlueprintReadOnly,ReplicatedUsing=OnRep_Health)

View File

@@ -13,6 +13,7 @@
/**
*
*/
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FAttributeChangedEvent, UAttributeSet*, AttributeSet, float, OldValue, float, NewValue);
UCLASS()
class ELISTRIA_CALLING_API ULevelAttributeSet : public UElistriaAttributeSetBase
{

View File

@@ -11,7 +11,7 @@
/**
*
*/
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FAttributeChangedEvent, UAttributeSet*, AttributeSet, float, OldValue, float, NewValue);
UCLASS()
class ELISTRIA_CALLING_API UStaminaAttributeSet : public UElistriaAttributeSetBase
{

View File

@@ -15,7 +15,6 @@
GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \
GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FAttributeChangedEvent, UAttributeSet*, AttributeSet, float, OldValue, float, NewValue);
UCLASS()
class ELISTRIA_CALLING_API UElistriaAttributeSetBase : public UAttributeSet
{