무기를 획득하면 마우스 우클릭으로 스킬을 사용할 수 있는 기능을 추가
스킬 반경과 대미지 계산은 새로운 어트리뷰트 값을 사용 - SkillRange, SkillAttckRate
스킬은 광역스킬이며, 다수의 액터에게 피해를 전달하고 폭발 장식 이펙트를 발생시킴
스킬에는 에너지를 소비하며, 에너지가 모자라면 발동이 안됨 - SkillEnergy
스킬 시전 후 쿨다운이 발동되며, 쿨다운이 끝날 때까지 발동이 안됨
스킬이 주는 대미지는 공격자와의 거리에 따라 선형적으로 감소함
https://github.com/dnjfs/ArenaBattle_GAS/commit/619da934555f534e864bbc55a11b19272cb4de53
새로운 범위 공격 스킬 부여
무기를 장착하였을 때 스킬 GA 부여
우클릭 시 스킬 GA 발동
몽타주도 실행
애니메이션 노티파이 이벤트 설정
스킬 몽타주에 SkillHitCheck 태그 설정
기존 TA_Trace를 상속받아 여러 대상 반환 구현
공격 검사 GA에서 TA를 구분하여 실행하도록 TSubclassOf 추가
다수 NPC에 대미지 전달 및 장식 이펙트 부여
스킬 사용 시 TA에서 Actors를 세팅하여 전달
공격 검사 GA에서 GE 실행하는 방법은 동일 - ApplyGameplayEffectSpecToTarget() 함수의 인자로 TargetDataHandle 전달
피격 GC에서 Actors를 순회하여 이펙트 출력
신규 어트리뷰트의 추가 및 활용
캐릭터 스킬 AttributeSet 추가, PlayerState에도 포함
스킬데미지 GE에서 어트리뷰트 값을 가져오도록 설정 - Attribute Based 타입
스킬 비용, 쿨다운 처리
스킬 GA에 Cost, Cooldown 클래스에 GE 각자 설정
비용은 SkillEnergy를 감소
쿨다운은 SkillCooldown 태그 활성화 상태로 처리
최종 대미지의 수동 계산
GameplayEffectExecutionCalculation 상속받아 구현
스킬대미지 GE에서 "실행"의 계산 클래스로 적용
5.4 버전부턴 ActivateAbility() 함수 내에서 CommitAbility() 함수를 호출해줘야 비용과 쿨다운이 정상적으로 동작합니다.
ActivateAbility()는 어빌리티를 시도를 하는 함수고 CommitAbility()가 실제로 처리하는 함수입니다.
관련 내용이 GameplayEffectTypes 코드의 헤더와 cpp 파일에 작성되어 있습니다.5.4 버전 변경이 하나 더 추가되었습니다.
쿨다운 구현 시 GE에 "타깃 액터에 태그 부여"로 태그를 부여하면 GA에서 "활성화 차단 태그"에 해당 태그를 추가하지 않아도 자동으로 쿨다운 관리가 됩니다.
// GameplayEffectTypes.h
// ----------------------------------------------------------------------------------------------------------------
//
// The important functions:
//
// CanActivateAbility() - const function to see if ability is activatable. Callable by UI etc
//
// TryActivateAbility() - Attempts to activate the ability. Calls CanActivateAbility(). Input events can call this directly.
// - Also handles instancing-per-execution logic and replication/prediction calls.
//
// CallActivateAbility() - Protected, non virtual function. Does some boilerplate 'pre activate' stuff, then calls ActivateAbility()
//
// ActivateAbility() - What the abilities *does*. This is what child classes want to override.
//
// CommitAbility() - Commits reources/cooldowns etc. ActivateAbility() must call this!
//
// CancelAbility() - Interrupts the ability (from an outside source).
//
// EndAbility() - The ability has ended. This is intended to be called by the ability to end itself.
//
// ----------------------------------------------------------------------------------------------------------------
// GameplayEffectTypes.cpp
void UGameplayAbility::ActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, const FGameplayEventData* TriggerEventData)
{
...
else
{
// Native child classes should override ActivateAbility and call CommitAbility.
// CommitAbility is used to do one last check for spending resources.
// Previous versions of this function called CommitAbility but that prevents the callers
// from knowing the result. Your override should call it and check the result.
// Here is some starter code:
// if (!CommitAbility(Handle, ActorInfo, ActivationInfo))
// {
// constexpr bool bReplicateEndAbility = true;
// constexpr bool bWasCancelled = true;
// EndAbility(Handle, ActorInfo, ActivationInfo, bReplicateEndAbility, bWasCancelled);
// }
}
}