* 방마저 속성추가
Attribute set 수정
ctrl + h => 한번에 수정
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_FireResistance, Category = "Resistance Attributes")
FGameplayAttributeData FireResistance;
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, FireResistance);
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_LightningResistance, Category = "Resistance Attributes")
FGameplayAttributeData LightningResistance;
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, LightningResistance);
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_ArcaneResistance, Category = "Resistance Attributes")
FGameplayAttributeData ArcaneResistance;
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, ArcaneResistance);
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_PhysicalResistance, Category = "Resistance Attributes")
FGameplayAttributeData PhysicalResistance;
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, PhysicalResistance);
콜백함수
UFUNCTION()
void OnRep_FireResistance(const FGameplayAttributeData& OldFireResistance) const;
UFUNCTION()
void OnRep_LightningResistance(const FGameplayAttributeData& OldLightningResistance) const;
UFUNCTION()
void OnRep_ArcaneResistance(const FGameplayAttributeData& OldArcaneResistance) const;
UFUNCTION()
void OnRep_PhysicalResistance(const FGameplayAttributeData& OldPhysicalResistance) const;
리플리케이션 콜백함수 정의 (속성이 변경되는 event 발생시 호출됨 && 속성변경 처리)
/**
* This is a helper macro that can be used in RepNotify functions to handle attributes that will be predictively modified by clients.
*
* void UMyHealthSet::OnRep_Health(const FGameplayAttributeData& OldValue)
* {
* GAMEPLAYATTRIBUTE_REPNOTIFY(UMyHealthSet, Health, OldValue);
* }
*/
void UAuraAttributeSet::OnRep_FireResistance(const FGameplayAttributeData& OldFireResistance) const
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAuraAttributeSet, ManaRegeneration, OldFireResistance);
}
void UAuraAttributeSet::OnRep_LightningResistance(const FGameplayAttributeData& OldLightningResistance) const
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAuraAttributeSet, ManaRegeneration, OldLightningResistance);
}
void UAuraAttributeSet::OnRep_ArcaneResistance(const FGameplayAttributeData& OldArcaneResistance) const
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAuraAttributeSet, ManaRegeneration, OldArcaneResistance);
}
void UAuraAttributeSet::OnRep_PhysicalResistance(const FGameplayAttributeData& OldPhysicalResistance) const
{
GAMEPLAYATTRIBUTE_REPNOTIFY(UAuraAttributeSet, ManaRegeneration, OldPhysicalResistance);
}
- 속성이 변경되는경우에만, 네트워크에 복제
/** Allows gamecode to specify RepNotify condition: REPNOTIFY_OnChanged (default) or REPNOTIFY_Always for when repnotify function is called */
// !네트워크에 복제할 속성들을 등록하는 함수! 등록안해주면 빌드에러
void UAuraAttributeSet::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
...
//방마저 속성
DOREPLIFETIME_CONDITION_NOTIFY(UAuraAttributeSet, FireResistance, COND_None, REPNOTIFY_Always);
DOREPLIFETIME_CONDITION_NOTIFY(UAuraAttributeSet, LightningResistance, COND_None, REPNOTIFY_Always);
DOREPLIFETIME_CONDITION_NOTIFY(UAuraAttributeSet, ArcaneResistance, COND_None, REPNOTIFY_Always);
DOREPLIFETIME_CONDITION_NOTIFY(UAuraAttributeSet, PhysicalResistance, COND_None, REPNOTIFY_Always);
}
* 태그 추가 && 맵에 추가
struct FAuraGameplayTags
{
public:
...
FGameplayTag Attributes_Resistance_Arcane;
FGameplayTag Attributes_Resistance_Fire;
FGameplayTag Attributes_Resistance_Lightning;
FGameplayTag Attributes_Resistance_Physical;
UAuraAttributeSet::UAuraAttributeSet()
{
...
/* 방마저 Attributes */
TagsToAttributes.Add(GameplayTags.Attributes_Resistance_Arcane, GetArcaneResistanceAttribute);
TagsToAttributes.Add(GameplayTags.Attributes_Resistance_Fire, GetFireResistanceAttribute);
TagsToAttributes.Add(GameplayTags.Attributes_Resistance_Lightning, GetLightningResistanceAttribute);
TagsToAttributes.Add(GameplayTags.Attributes_Resistance_Physical, GetArcaneResistanceAttribute);
}
* 요구사항 : 화염저항은 Resistance * 0.5 +3 으로 재정의
&& int
* 속성위젯에 속성추가
- Tags.cpp에서 태그추가를 빼먹었네요
/*
* 방마저 Attributes
*/
GameplayTags.Attributes_Resistance_Arcane = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("Attributes.Resistance.Arcane"),
FString("Arcane Resistance")
);
GameplayTags.Attributes_Resistance_Fire = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("Attributes.Resistance.Fire"),
FString("Fire Resistance")
);
GameplayTags.Attributes_Resistance_Lightning = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("Attributes.Resistance.Lightning"),
FString("Lightning Resistance")
);
GameplayTags.Attributes_Resistance_Physical = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("Attributes.Resistance.Physical"),
FString("Physical Resistance")
);
'UE5 > Advance Damage Techniques' 카테고리의 다른 글
[UE5] 멀티플레이 test // 서버 트러블슈팅 클라에서 데미지 표시안됨 해결, 각자 클라에서는 각자의 데미지만 표시 구현 (0) | 2024.08.22 |
---|---|
[UE5] 방마저에따른 데미지 감소 구현 (0) | 2024.08.22 |
[UE5] 데미지 유형들 추가, 확장성 refactor (0) | 2024.08.15 |
[UE5] 크리시 글자 애니메이션 구현, 메시지 구현, 인스턴싱 정책 (0) | 2024.08.14 |
[UE5] 크리티컬시, 노란글씨로 구현 (0) | 2024.08.14 |