void UTankAimingComponent::Fire()
{
	UWorld* const World = GetWorld();

	if (!ensure(World)) { return; }
	if (!ensure(ProjectileBlueprint)) { return; }

	if (IsInitialised())
	{
		// Spawn Projectile into the world
		if (FiringState == EFiringState::Locked)
		{
			AProjectile* Projectile = World->SpawnActor<AProjectile>
			(
				ProjectileBlueprint,
				Barrel->GetSocketLocation(FName("Projectile")),
				Barrel->GetSocketRotation(FName("Projectile"))
			);

			if (Projectile)
			{
				Projectile->LaunchProjectile(LaunchSpeed);
				LastFireTime = FPlatformTime::Seconds();

				ReduceRounds();
			}
		}
	}
}
Beispiel #2
0
void ALauncherWeapon::Fire()
{

	Super::Fire();
	// try and fire a projectile
	if (GrenadeArchetype != NULL)
	{

		UWorld* const World = GetWorld();
		if (World && Mesh1P)
		{

			FActorSpawnParameters SpawnParams;
			SpawnParams.Owner = this;
			SpawnParams.Instigator = Instigator;
			// spawn the projectile at the muzzle
			//FVector loc = Mesh1P->GetSocketLocation(TEXT("MuzzleFlashSocket"));
			//FRotator rot = Mesh1P->GetSocketRotation(TEXT("MuzzleFlashSocket"));
		
		//	DrawDebugLine(GetWorld(),loc,loc+rot.Vector()*400,FColor::Red);

			AProjectile* theProjectile = World->SpawnActor<AProjectile>(GrenadeArchetype, Mesh1P->GetSocketLocation(TEXT("MuzzleFlashSocket")), Mesh1P->GetSocketRotation(TEXT("MuzzleFlashSocket")));
			//AProjectile* theProjectile = World->SpawnActor<AProjectile>(GrenadeArchetype,loc,rot );

			if (theProjectile)
			{
				// find launch direction
				theProjectile->InitVelocity(Mesh1P->GetSocketRotation(TEXT("MuzzleFlashSocket")).Vector());

			}
		}
	}
}
void FCommandTalentActive::Resolve()
{
	if (Talent->IsA<UTalentActiveProjectile>())
	{
		UTalentActiveProjectile* tp = Cast<UTalentActiveProjectile>(Talent);
		const FVector loca = Performer->GetPawn()->GetActorLocation();
		FActorSpawnParameters fuckyou;
		fuckyou.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
		AProjectile* projectile = Cast<AProjectile>(Performer->GetWorld()->SpawnActor(tp->Projectile, &loca, NULL, fuckyou));

		projectile->SetUser(Performer->GetDehrgadaTWUCharacter());
		projectile->SetTalent(Talent);
		if (Target && Talent->bCanTargetActor)
		{
			bool suc;
			ARollCalculatorCPP::Instance->RangedAttack(Target, Performer->GetDehrgadaTWUCharacter(), tp->Defense, tp->Range, tp->Falloff, suc);
			projectile->SetTarget(Target, (suc)?1:0);
		}
		else
		{
			projectile->SetTargetPoint(GetTargetLocation());
		}
	}
	else
	{
		if (Target && Talent->bCanTargetActor)
		{
			ATalentManagerCPP::Instance->Use_Target(Talent, Performer->GetDehrgadaTWUCharacter(), Target);
			//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Target!"));
		}
		else
		{
			ATalentManagerCPP::Instance->Use_Location(Talent, Performer->GetDehrgadaTWUCharacter(), GetTargetLocation());
			//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Location!"));
		}
	}

	Performer->GetDehrgadaTWUCharacter()->Stats->SpendVitals(Talent);
}
Beispiel #4
0
AActor* UWeaponComponent::SpawnProjectile(UClass* ProjectileClass, FVector RelativeSpawnLocation, AActor* LaunchingActor, UGameplaySystemComponent* GameplaySystem)
{
	FTransform SpawnTransform;
	{
		FRotator SpawnRotation = LaunchingActor->GetActorRotation();
		FVector SpawnLocation = LaunchingActor->GetActorLocation();
		SpawnLocation += SpawnRotation.RotateVector(RelativeSpawnLocation);
		SpawnTransform = FTransform(SpawnRotation, SpawnLocation);
	}

	FActorSpawnParameters SpawnParameters = FActorSpawnParameters();
	SpawnParameters.Owner = this->GetOwner();

	AActor* SpawnedActor = this->GetWorld()->SpawnActor(ProjectileClass, &SpawnTransform, SpawnParameters);
	AProjectile* Projectile = dynamic_cast<AProjectile*>(SpawnedActor);

	if (Projectile != nullptr)
	{
		Projectile->SetAttackPoints(GameplaySystem->GetInfightAttackPoints());
	}

	return SpawnedActor;
}
Beispiel #5
0
void ALauncherWeapon::Fire()
{
	Super::Fire();

	if (GrenadeArchetype)
	{
		UWorld* const World = GetWorld();
		if (World && Mesh1P && ThePlayer && ThePlayer->Controller)
		{
			// Get Camera Rotation
			FVector CamLoc;
			FRotator CamRot;
			ThePlayer->Controller->GetPlayerViewPoint(CamLoc, CamRot);

			// Calculate Origin and Direction of Fire
			const FVector StartTrace = GetFireSocketTransform().GetLocation();
			const FVector Direction = CamRot.Vector();

			// Set Spawn Paramets
			FActorSpawnParameters SpawnParams;
			SpawnParams.Owner = this;
			SpawnParams.Instigator = Instigator;


			// Spawn at Fire socket location
			AProjectile* TheProjectile = World->SpawnActor<AProjectile>(GrenadeArchetype, StartTrace, CamRot);

			// Set Projectile Velocity
			if (TheProjectile) 
			{
				
				TheProjectile->InitVelocity(Direction*ProjectileVelocity);
			}
				
		}
	}
}
Beispiel #6
0
bool AWeaponPowerUp::OnShoot_Implementation()
{
	// try and fire a projectile
	if(ProjectileClass != nullptr)
	{
		const FRotator SpawnRotation = GetPlayerCube()->GetActorRotation();
		// MuzzleOffset is in camera space, so transform it to world space before offsetting from the character location to find the final muzzle position
		const FVector OffsetVector(120.0f, 0.0f, 0.0f);
		const FVector SpawnLocation = GetPlayerCube()->GetActorLocation() + SpawnRotation.RotateVector(OffsetVector);

		UWorld* const World = GetWorld();
		if(World != nullptr)
		{
			// spawn the projectile at the muzzle
			AProjectile* projectile = World->SpawnActor<AProjectile>(ProjectileClass, SpawnLocation, SpawnRotation);

			projectile->SetInstigator(GetPlayerCube()->GetController());

			return true;
		}
	}

	return false;
}