2025-10-17 17:13:13 -04:00
// Copyright Echo Devgroup
# include "AbilitySystem/AuraProjectileSpell.h"
# include "AbilitySystemBlueprintLibrary.h"
# include "AbilitySystemComponent.h"
2025-10-18 11:28:42 -04:00
# include "AuraGameplayTags.h"
2025-10-17 17:13:13 -04:00
# include "Actor/AuraProjectile.h"
# include "Interact/CombatInterface.h"
void UAuraProjectileSpell : : ActivateAbility ( const FGameplayAbilitySpecHandle Handle ,
const FGameplayAbilityActorInfo * ActorInfo , const FGameplayAbilityActivationInfo ActivationInfo ,
const FGameplayEventData * TriggerEventData )
{
Super : : ActivateAbility ( Handle , ActorInfo , ActivationInfo , TriggerEventData ) ;
}
void UAuraProjectileSpell : : SpawnProjectile ( const FVector ProjectileTargetLocation )
{
const bool bIsServer = GetAvatarActorFromActorInfo ( ) - > HasAuthority ( ) ;
2025-10-17 17:54:45 -04:00
if ( ! bIsServer ) return ;
2025-10-17 17:13:13 -04:00
ICombatInterface * CombatInterface = Cast < ICombatInterface > ( GetAvatarActorFromActorInfo ( ) ) ;
if ( CombatInterface )
{
const FVector SocketLocation = CombatInterface - > GetCombatSocketLocation ( ) ;
FRotator Rotation = ( ProjectileTargetLocation - SocketLocation ) . Rotation ( ) ;
Rotation . Pitch = 0.0f ;
FTransform SpawnTransform ;
SpawnTransform . SetLocation ( SocketLocation ) ;
SpawnTransform . SetRotation ( Rotation . Quaternion ( ) ) ;
AAuraProjectile * Projectile = GetWorld ( ) - > SpawnActorDeferred < AAuraProjectile > (
ProjectileClass ,
SpawnTransform ,
GetOwningActorFromActorInfo ( ) ,
Cast < APawn > ( CurrentActorInfo - > AvatarActor ) , //Changed to allow GetInstigator() to work accurately in Projectile. Allowing ignoring the player character.
ESpawnActorCollisionHandlingMethod : : AlwaysSpawn ) ;
const UAbilitySystemComponent * SourceASC = UAbilitySystemBlueprintLibrary : : GetAbilitySystemComponent ( GetAvatarActorFromActorInfo ( ) ) ;
const FGameplayEffectSpecHandle SpecHandle = SourceASC - > MakeOutgoingSpec ( DamageEffectClass , GetAbilityLevel ( ) , SourceASC - > MakeEffectContext ( ) ) ;
2025-10-18 11:28:42 -04:00
const FAuraGameplayTags GameplayTags = FAuraGameplayTags : : Get ( ) ;
2025-11-02 06:40:35 -05:00
const float ScaledDamage = Damage . GetValueAtLevel ( GetAbilityLevel ( ) ) ;
//const float ScaledDamage = Damage.GetValueAtLevel(1);
UAbilitySystemBlueprintLibrary : : AssignTagSetByCallerMagnitude ( SpecHandle , GameplayTags . Damage , ScaledDamage ) ;
2025-10-18 11:28:42 -04:00
2025-10-17 17:13:13 -04:00
Projectile - > DamageEffectSpecHandle = SpecHandle ;
Projectile - > FinishSpawning ( SpawnTransform ) ;
}
}