void AMech_RPGCharacter::FindSpawnpoint()
{
	float distanceTo = std::numeric_limits<float>::max();
	bool locationFound = false;

	APlayerSpawnpoint* spawn = nullptr;
	TArray<ASpawnpoint*>* spawnpoints = ASpawnpoint::GetSpawnpoints(APlayerSpawnpoint::StaticClass());

	if (spawnpoints != nullptr) {
		for (ASpawnpoint* spawnpoint : *spawnpoints) {
			if (spawnpoint != nullptr) {
				APlayerSpawnpoint* spawnFound = Cast<APlayerSpawnpoint>(spawnpoint);

				if (spawnFound != nullptr
					&& (spawn == nullptr || GetDistanceTo(spawnFound) < distanceTo)) {
					distanceTo = GetDistanceTo(spawnFound);
					spawn = spawnFound;
				}
			}
		}

		if (spawn != nullptr) {
			FNavLocation nav;

			while (!locationFound) {
				locationFound = GetWorld()->GetNavigationSystem()->GetRandomPointInNavigableRadius(spawn->GetActorLocation(), ASpawnpoint::defaultSpawnRadius, nav);
			}

			SetActorLocation(nav.Location);
			ASpawnpoint::AdjustCharacterLocationByCapsule(this);
		}
	}
}
void AExplosive::Explode()
{
	mTriggered = false; 


	mParticleSystem->ActivateSystem();
	mRadForce->FireImpulse();
	
	//UGameplayStatics::ApplyRadialDamage(GetWorld(), mExplosionDamage, GetActorLocation(), mExplosionRadius, UDamageType::StaticClass(), TArray<AActor*>(),NULL,NULL,true);
	//Use AACtor to dmg killzone
	for (TActorIterator<ACharacter> it(GetWorld()); it; ++it)
	{
		float Distance = GetDistanceTo(*it);

		if (Distance <= mExplosionRadius)
		{
			UGameplayStatics::ApplyDamage(*it, mExplosionDamage,
				GetInstigatorController(), this, UDamageType::StaticClass());
		}
	}

	
	UAISense_Hearing::ReportNoiseEvent(this, GetActorLocation(), 1, this, mExplosionSound);
	mExploded = true;
}
Exemple #3
0
void ABomb::ApplyExplosionDamage()
{
	for ( TActorIterator<ANetGameCPPCharacter> aItr(GetWorld()); aItr; ++aItr )
	{
		if ( GetDistanceTo(*aItr) <= ExplosionRadius)
			UGameplayStatics::ApplyDamage(*aItr, ExplosionDamage, GetInstigatorController(), this, UDamageType::StaticClass());
	}

	OnExplosion();
	SetLifeSpan(2.0f);
}
Exemple #4
0
double CLine::GetDistanceTo(const CLine& line) const
{
	if ((*this) * line)  // If two line cross, then return 0
		return 0;

	double d1=GetDistanceTo(line.m_pt1);
	double d2=GetDistanceTo(line.m_pt2);
	double d3=line.GetDistanceTo(m_pt1);
	double d4=line.GetDistanceTo(m_pt2);

	double dMin=d1;
	if (d2<dMin)
		dMin=d2;
	if (d3<dMin)
		dMin=d3;
	if (d4<dMin)
		dMin=d4;

	return dMin;
}
void APlayerCharacter::FadeToWhite()
{

	DistanceToX = GetDistanceTo(WhereBeAnna);
	if (DistanceToX > 50)
	{
		GetFirstPersonCameraComponent()->PostProcessSettings.ColorOffset.X = 20 / DistanceToX;
		GetFirstPersonCameraComponent()->PostProcessSettings.ColorOffset.Y = 20/ DistanceToX;
		GetFirstPersonCameraComponent()->PostProcessSettings.ColorOffset.Z = 20 / DistanceToX;
		GetFirstPersonCameraComponent()->PostProcessSettings.ColorContrast.X = 1 - 20 / DistanceToX;
		GetFirstPersonCameraComponent()->PostProcessSettings.ColorContrast.Y = 1 - 20 / DistanceToX;
		GetFirstPersonCameraComponent()->PostProcessSettings.ColorContrast.Z = 1 - 20 / DistanceToX;
	}
	else
	{
		ShowTime = false;
	}
}
Exemple #6
0
void AProjectile::Explode()
{
	BP_Explode();
	

	const FVector Loc = GetActorLocation();

	for (TActorIterator<AActor> aItr(GetWorld()); aItr; ++aItr)
	{
		const float distance = GetDistanceTo(*aItr);
		if (distance<AffectArea && aItr && aItr->GetRootComponent() && aItr->GetRootComponent()->Mobility == EComponentMobility::Movable)
		{
			FVector dir = aItr->GetActorLocation() - Loc;
			dir.Normalize();

			FRichCurve* RadialDamageCurveData = RadialDamageCurve.GetRichCurve();
			FRichCurve* RadialImpulseCurveData = RadialImpulseCurve.GetRichCurve();


			ABaseCharacter* theChar = Cast<ABaseCharacter>(*aItr);

			//If Player apply damage
			if (theChar && RadialDamageCurveData)
			{
				//printr("Apply Damage");
				UGameplayStatics::ApplyDamage(theChar, RadialDamageCurveData->Eval(distance), NULL, this, ExplosionDamageType);
			}
			
			if (RadialImpulseCurveData && aItr->GetRootComponent()->IsSimulatingPhysics() && Cast<UPrimitiveComponent>(aItr->GetRootComponent()))
			{
				Cast<UPrimitiveComponent>(aItr->GetRootComponent())->AddImpulse(dir*RadialImpulseCurveData->Eval(distance));
				
			}
		}

	}




	Destroy();
}
/*Unused for now*/
void AEnemy::UpdateCharacter()
{
	Super::UpdateCharacter();
	
	if (_receiverAttack)

		if (GetDistanceTo(_receiverAttack) < GetRangeAttack() && !IsAttacking() && !_receiverAttack->IsAttacked()) {
			auto timer = GetWorldTimerManager().GetTimerRate(_countdownTimerHandle);
			if (timer != GetFlipbook(Attack_Animation)->GetTotalDuration())
			{
				SetAttacking(true);
				GetCharacterMovement()->StopMovementImmediately();
				GetWorldTimerManager().SetTimer(_countdownTimerHandle, this, &AAzraelCharacter::Attacking, GetFlipbook(Attack_Animation)->GetTotalDuration()/2.0f, false);
			}
		}
		else {
			_receiverAttack->SetAttacked(false);
		}
		if (IsPawnJumping())
			GetCharacterMovement()->SetMovementMode(MOVE_Falling);
		else if (_isPatrolling && !_isImmobile) {
			GetCharacterMovement()->Velocity = FVector(GetPawnDirection()*-100.f, 0.f, 0.f);
		}
}
void ARoadFeverEnemy::Tick( float DeltaSeconds )
{
	DistanceVisual->SetText( FString::SanitizeFloat( GetDistanceTo( GetWorld()->GetFirstPlayerController()->GetPawn() ) ) );
}