Beispiel #1
0
void AFournoidBullet::OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
	// Only add impulse and destroy projectile if we hit a physics
	if ( OtherActor && (OtherActor != this) )
	{
		// Check for Simulating Physics or there will be warning
		if ( OtherComp && OtherComp->IsSimulatingPhysics() )
		{
    		OtherComp->AddImpulseAtLocation(GetVelocity() * BulletImpulseStrength, GetActorLocation());
		}
		
		// Only cause damage when not hitting the instigator
		if ( Instigator && (OtherActor != Instigator) )
		{
			FPointDamageEvent PointDmg;
			PointDmg.DamageTypeClass = UDamageType::StaticClass();
			PointDmg.HitInfo = Hit;
			PointDmg.ShotDirection = FVector::ZeroVector;
			PointDmg.Damage = BulletDamage;
    		
    		OtherActor->TakeDamage(PointDmg.Damage, PointDmg, GetInstigatorController(), this);
    		if ( HitEmitter )
    		{
    			UE_LOG(Fournoid, Warning, TEXT("Spawning Emitter"));
				UGameplayStatics::SpawnEmitterAtLocation(this, HitEmitter, GetActorLocation());
    		}
		}
		
		
		
		Destroy();
	}
}
Beispiel #2
0
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;
}
Beispiel #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);
}
void ARPGProjectile::PostInitializeComponents()
{
	Super::PostInitializeComponents();
	
	//MovementComp->OnProjectileStop.AddDynamic(this, &ARPGProjectile::OnImpact);
	CollisionComp->MoveIgnoreActors.Add(Instigator);

	SetLifeSpan(10);
	MyController = Cast<ARPGPlayerController>(GetInstigatorController());
	
}
void AShooterProjectile::PostInitializeComponents()
{
	Super::PostInitializeComponents();
	MovementComp->OnProjectileStop.AddDynamic(this, &AShooterProjectile::OnImpact);
	CollisionComp->MoveIgnoreActors.Add(Instigator);

	AShooterWeapon_Projectile* OwnerWeapon = Cast<AShooterWeapon_Projectile>(GetOwner());
	if (OwnerWeapon)
	{
		OwnerWeapon->ApplyWeaponConfig(WeaponConfig);
	}

	SetLifeSpan( WeaponConfig.ProjectileLife );
	MyController = GetInstigatorController();
}
void AAzurukProjectile::PostInitializeComponents()
{
	Super::PostInitializeComponents();
	MovementComp->OnProjectileStop.AddDynamic(this, &AAzurukProjectile::OnImpact);
	CollisionComp->MoveIgnoreActors.Add(Instigator);

	AAzurukAbilityProjectile* OwnerAbility = Cast<AAzurukAbilityProjectile>(GetOwner());
	if (OwnerAbility)
	{
		OwnerAbility->ApplyAbilityConfig(AbilityConfig);
	}

	SetLifeSpan(AbilityConfig.ProjectileLife);
	MyController = GetInstigatorController();
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//Projectile Bounce Delegate
void ARPGProjectile::OnBounce(FHitResult const& HitResult)
{
	ARPGPlayerController* PC = Cast<ARPGPlayerController>(GetInstigatorController());
	if (PC) PC->ClientMessage("Bounce!!");
	
	//Get Hit Actor
	AActor* HitActor = HitResult.GetActor();
	if (!HitActor) return;
	
	//hit a pawn? Then do impact
	if (HitActor->IsA(APawn::StaticClass())) 
	{
		//do impact
		OnImpact(HitResult);
	}
}
void AAssaultWeapon::WeaponTrace()
{
    
    static FName WeaponFireTag = FName(TEXT("WeaponTrace"));
    static FName MuzzleSocket =	FName(TEXT("MuzzleFlashSocket"));
    
    //	Start	from	the	muzzle's	position
    
    FVector StartPos = WeaponMesh->GetSocketLocation(MuzzleSocket);
    
    //	Get	forward	vector	of	MyPawn
    FVector Forward =	MyPawn->GetActorForwardVector();
    
    //	Calculate	end	position
    FVector EndPos = StartPos + Forward * WeaponRange;
    
    //	Perform	trace	to	retrieve	hit	info
    FCollisionQueryParams TraceParams(WeaponFireTag, true, Instigator);
    TraceParams.bTraceAsyncScene = true;
    TraceParams.bReturnPhysicalMaterial = true;
    
    //	This	fires	the	ray	and checks	against	all	objects	w/	collision
    FHitResult Hit(ForceInit);
    GetWorld()->LineTraceSingleByObjectType(Hit, StartPos, EndPos, FCollisionObjectQueryParams::AllObjects,TraceParams);
    
    //	Did	this	hit	anything? If its a dwarf call their takedamage of assault weapon with the assault weapons "Damage" variable
    if (Hit.bBlockingHit)
    {
        UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), HitEffect, Hit.ImpactPoint, FRotator(0,0,0), true);
        Dwarf = Cast<ADwarfCharacter>(Hit.GetActor());
        if(Dwarf){
            Dwarf->TakeDamage(Damage,	FDamageEvent(),	GetInstigatorController(),	this);
        }
        
    }
}
Beispiel #9
0
void ANimModProjectile::PostInitializeComponents()
{
	Super::PostInitializeComponents();
	
	MovementComp->OnProjectileStop.AddDynamic(this, &ANimModProjectile::OnImpact);
	MovementComp->InitialSpeed = MaxSpeed;
	MovementComp->MaxSpeed = MaxSpeed;
	MovementComp->bShouldBounce = ShouldBounce;
	MovementComp->Velocity *= MaxSpeed;

	CollisionComp->MoveIgnoreActors.Add(Instigator);

	RadialForceComp->ForceStrength = RadialForce;
	RadialForceComp->ImpulseStrength = RadialForce;

	ANimModWeapon_Projectile* OwnerWeapon = Cast<ANimModWeapon_Projectile>(GetOwner());
	if (OwnerWeapon)
	{
		OwnerWeapon->ApplyWeaponConfig(WeaponConfig);
	}

	SetLifeSpan(WeaponConfig.ProjectileLife);
	MyController = GetInstigatorController();
}
void AShooterProjectile::OnProjectileStop(const FHitResult& HitResult)
{
	if (HasAuthority())
	{
		if (false == bExploded)
		{
			//!< レプリケートされてクライアントで SimulateExplode() がコールされる
			bExploded = true;

			//!< ダメージ
			const auto Location = HitResult.ImpactPoint + HitResult.ImpactNormal * 10.0f;
			const auto Damage = 100.0f;
			const auto Radius = 100.0f;
			UGameplayStatics::ApplyRadialDamage(this, Damage, Location, Radius, /*UShooterDamageType*/UDamageType::StaticClass(), TArray<AActor*>(), this, GetInstigatorController());

			if (nullptr != ProjectileMovementComp)
			{
				ProjectileMovementComp->StopMovementImmediately();
			}

			SetLifeSpan(2.0f);
		}
	}
}
Beispiel #11
0
void ABomb::Explode()
{
	SimulateExplosionFX();

	//We won't use any specific damage types in our case
	TSubclassOf<UDamageType> DmgType;
	//Do not ignore any actors
	TArray<AActor*> IgnoreActors;

	//This will eventually call the TakeDamage function that we have overriden in the Character class
	UGameplayStatics::ApplyRadialDamage(GetWorld(), ExplosionDamage, GetActorLocation(), ExplosionRadius, DmgType, IgnoreActors, this, GetInstigatorController());

	FTimerHandle TimerHandle;
	FTimerDelegate TimerDel;

	TimerDel.BindLambda([&]()
	{
		Destroy();
	});

	//Destroy the actor after 0.3 seconds. 
	GetWorld()->GetTimerManager().SetTimer(TimerHandle, TimerDel, 0.3f, false);
}