Esempio n. 1
0
void UAreaOfEffect::Use()
{
	Super::Use();
	static FName NAME_TestMove = FName(TEXT("TestMove"));
	FCollisionQueryParams SphereParams(NAME_TestMove, false, GetOwner());
	FCollisionObjectQueryParams QueryParams = FCollisionObjectQueryParams(FCollisionObjectQueryParams::InitType::AllDynamicObjects);
	TArray<FOverlapResult> Overlaps;

	GetWorld()->OverlapMultiByObjectType(Overlaps, GetOwner()->GetActorLocation(), FQuat::Identity, QueryParams, FCollisionShape::MakeSphere(500.f), SphereParams);

	for (int32 i = 0; i < Overlaps.Num(); ++i)
	{
		//

		FOverlapResult const& Overlap = Overlaps[i];
		ABETCharacter* Mine = Cast<ABETCharacter>(Overlap.GetActor());

		//	AEffectOverTime* appliedDebuff;
		if (Mine != nullptr)
		{
			//appliedDebuff = debuff;
//			if (debuff){
			UsedFunction(Mine);
			//Mine->Destroy();
			//					appliedDebuff->SetActive();
//					appliedDebuff->AttachRootComponentToActor(Mine);		
//					DrawDebugSphere(GetWorld(), GetOwner()->GetActorLocation(), 24, 32, FColor(255, 0, 0), false, -1.f);
//			}
			//This is where you will attach an effect over time...			
		}
	}
	Overlaps.Empty();
	DeactivateAbility();
}
Esempio n. 2
0
TArray<AActor*> URPGEffectBase::SpreadEffect(URPGEffectBase* EffectIn, FVector FromLoc, float Radius, int32 MaxTargets)
{
	TArray<AActor*> ActorHits;
	if ((!GetWorld()))
		return ActorHits;

	TWeakObjectPtr<URPGEffectPeriodic> PeriodicEffect = Cast<URPGEffectPeriodic>(EffectIn);

	float TargetCounter = 0;
	//EffectSpec.SetEffect();

	FCollisionQueryParams SphereParams(this->GetFName(), false, CausedBy);
	//make sure we have world

	TArray<FOverlapResult> Overlaps;
	GetWorld()->OverlapMulti(Overlaps, FromLoc, FQuat::Identity, FCollisionShape::MakeSphere(Radius), SphereParams, FCollisionObjectQueryParams(FCollisionObjectQueryParams::InitType::AllDynamicObjects));


	for (FOverlapResult& overlap : Overlaps)
	{
		ActorHits.AddUnique(overlap.GetActor());
	}

	if (ActorHits.Num() > 0)
	{
		int32 TargetCounter = 0;
		if (MaxTargets > TargetCounter)
		{
			TargetCounter++;
			for (AActor* ActorHit : ActorHits)
			{
				URPGAttributeComponent* HitActorAttribute = ActorHit->FindComponentByClass<URPGAttributeComponent>();

				if (HitActorAttribute)
				{
					if (PeriodicEffect.IsValid())
					{
						PeriodicEffect->SetTarget(ActorHit);
						PeriodicEffect->PreInitialize();
						PeriodicEffect->Initialize();
						HitActorAttribute->ApplyPeriodicEffect(PeriodicEffect.Get());
						continue;
					}
					EffectIn->SetTarget(ActorHit);

					EffectIn->PreInitialize();
					EffectIn->Initialize();
				}
			}

		}
	}

	return ActorHits;
}