void ATankAIController::Tick(float DeltaSeconds)
{
	Super::Tick(DeltaSeconds);
	auto aiTank = GetPawn();
	auto playerTank = GetWorld()->GetFirstPlayerController()->GetPawn();
	if (ensure(playerTank)) {

		// TODO Move towards the player
		MoveToActor(playerTank, acceptanceRadius); // TODO check radius is in cm

		// Aim towards the player
		auto aimComponent = aiTank->FindComponentByClass<UTankAimingComponent>();
		aimComponent->AimAt(playerTank->GetActorLocation());
		

		//GetPawn().reloadTimeInSeconds = 10;
		// Fire if ready
		if (aimComponent->GetFiringState() == EFiringStatus::Ready) {
			aimComponent->Fire();
			//UE_LOG(LogTemp,Warning,TEXT("AI Tank Ready and Firing!"))
		}


		
	}

}
int KHero::LuaAimAt(Lua_State* L)
{
    BOOL bResult    = false;
    BOOL bRetCode   = false;
    int  nTopIndex  = 0;
    BOOL bAimAt     = false;
    int  nDirection = 0;
    KDoodad* pDoodad = NULL;

    nTopIndex = Lua_GetTopIndex(L);
    KGLOG_PROCESS_ERROR(nTopIndex == 2);
    
    bAimAt = (BOOL)Lua_ValueToNumber(L, 1);
    nDirection = (int)Lua_ValueToNumber(L, 2);

    pDoodad = GetHoldingDoodad();
    KGLOG_PROCESS_ERROR(pDoodad);

    bRetCode = AimAt(bAimAt, nDirection, pDoodad->m_dwID, true);
    KGLOG_PROCESS_ERROR(bRetCode);

    bResult = true;
Exit0:
    Lua_PushBoolean(L, bResult);
    return 1;
}
Beispiel #3
0
bool Aimbot::IsInFov( idVec3 v, float fov )
{
	idAngles ang = AimAt( v );
	if ( idMath::Cos( DEG2RAD( ang.yaw ) ) < idMath::Cos( DEG2RAD( fov / 2.0f ) ) )
		return false;
	if ( idMath::Cos( DEG2RAD( ang.pitch ) ) < idMath::Cos( DEG2RAD( fov / 2.0f ) ) )
		return false;
	return true;
}
void ATankPlayerController::AimTowardsCrosshair()
{
	if (!GetPawn()) { return; } // e.g. if not possessing
	auto AimingComponent = GetPawn()->FindComponentByClass<UTankAimingComponent>();
	if (!ensure(AimingComponent)) { return; }

	FVector HitLocation; // Out parameter
	bool IsLocationHit = GetSightRayHitLocation(HitLocation);
	if (GetSightRayHitLocation(HitLocation)) // Has "side-effect", is going to line trace
	{
		AimingComponent->AimAt(HitLocation);
	}
}
void ATankAIController::Tick(float DeltaSeconds)
{
	Super::Tick(DeltaSeconds);

	ATank* PlayerTank = Cast<ATank>(GetWorld()->GetFirstPlayerController()->GetPawn());
	auto ControlledTank = Cast<ATank>(GetPawn());

	if (PlayerTank)
	{
		ControlledTank->AimAt(PlayerTank->GetActorLocation());
	}

	ControlledTank->Fire();
}
Beispiel #6
0
idAngles Aimbot::Main( float fov, float ping, bool humanize, float smoothMultiplier, float smoothTransposition )
{
#define FRAME_TIME_SECONDS 0.008f
		Ping = ping;
	FOV = fov;
	_Muzzle = ImportExport::User->EyePosition() + ImportExport::User->ViewAngles().ToMat3()[0]*14.0f + EvaluatePath(idVec3(0,0,0), 
		ImportExport::User->Velocity(), FRAME_TIME_SECONDS);
	if ( ScanForTarget() )
	{
		idAngles angles = AimAt( TargetOrigin() );
		return humanize ? Humanize( smoothMultiplier, smoothTransposition, angles ) : angles;
	}
	return idAngles(0, 0, 0);
}
void ATankPlayerController::AimTowardsCrosshair()
{
	if (!GetPawn()) { return; }//e.g. if not possessing
	auto AimingComponent = GetPawn()->FindComponentByClass<UTankAimingComponent>();
	if (!ensure(AimingComponent)) { return; }

	FVector HitLocation;// Out parameter
	bool bGotHitLocation = GetSightRayHitLocation(HitLocation);

	if (bGotHitLocation)
	{
		AimingComponent->AimAt(HitLocation);
	}
}
void ATankPlayerController::AimTowardsCrosshair()
{
	if (!GetPawn()) { return; }

	auto AimingComponent = GetPawn()->FindComponentByClass<UTankAimingComponent>();
	if (!ensure(AimingComponent)) { return; }

	FVector HitLocation; // OUT parameter
	bool bGotHitLocation = GetSightRayHitLocation(HitLocation);
	if (bGotHitLocation)
	{
		// Tell controlled tank to aim at this point
		AimingComponent->AimAt(HitLocation);
	}
}
void ATankPlayerController::AimTowardsCrosshair() const
{
	// If we don't have a controlled tank, return.
	if (!GetPawn()) return;

	auto AimingComponent = GetPawn()->FindComponentByClass<UTankAimingComponent>();
	if (!ensure(AimingComponent)) { return; }

	FVector HitLocation; // OUT parameter
	bool bGotHitLocation = GetSightRayHitLocation(HitLocation);
	if(bGotHitLocation)
	{
		AimingComponent->AimAt(HitLocation);
	}
}
Beispiel #10
0
void ATankAIController::Tick(float deltaTime)
{
	Super::Tick(deltaTime);

	auto playerTank = GetWorld()->GetFirstPlayerController()->GetPawn();

	if (ensure(playerTank && GetPawn()))
	{
		MoveToActor(playerTank, acceptanceRadius);

		auto aimingComponent = GetPawn()->FindComponentByClass<UTankAimingComponent>();
		aimingComponent->AimAt(playerTank->GetActorLocation());

		if(aimingComponent->GetFiringStatus() == EFiringStatus::Locked)
			aimingComponent->Fire();
	}
}
// Called every frame
void ATankAIController::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	auto PlayerTank = Cast<ATank>(GetWorld()->GetFirstPlayerController()->GetPawn());
	auto ControlledTank = Cast<ATank>(GetPawn());

	if (PlayerTank)
	{
		// Move towards the player
		MoveToActor(PlayerTank, AcceptanceRadius); // TODO check radius is in cm

		// Aim towards the player
		ControlledTank->AimAt(PlayerTank->GetActorLocation());

		ControlledTank->Fire(); // TODO limit firing rate
	}
}
// Called every frame
void ATankAIController::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	auto PlayerTank = Cast<ATank>(GetWorld()->GetFirstPlayerController()->GetPawn());
	auto ControlledTank = Cast<ATank>(GetPawn());

	if (PlayerTank)
	{
		// TODO Move towards the player

		// Aim towars the player
		ControlledTank->AimAt(PlayerTank->GetActorLocation());

		// Fire if ready
		ControlledTank->Fire();  // TODO don't fire every frame
	}

}
void ATankAIController::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	auto PlayerTank = GetWorld()->GetFirstPlayerController()->GetPawn();
	auto AITank = GetPawn();

	if (!ensure(PlayerTank && AITank)) { return; }

	auto AIAimComp = AITank->FindComponentByClass<UTankAimingComponent>();
	// Move towards Actor
	MoveToActor(PlayerTank, AcceptanceRadius);
	// Aim towards the player
	AIAimComp->AimAt(PlayerTank->GetActorLocation());

	if (AIAimComp->GetFiringState() == EFiringState::Locked)
	{
		AIAimComp->Fire();
	}
}
void ATankAIController::Tick(float DeltaTime){
    
    Super::Tick(DeltaTime);
    
    auto PlayerTank = GetWorld()->GetFirstPlayerController()->GetPawn();
    
    auto ControlledTank = GetPawn();
    
    if(!ensure(PlayerTank && ControlledTank)){return ; }
        
        //move towards player
        MoveToActor(PlayerTank, AcceptanceRadius);
        //aim towards the player
    auto AimingComponent = ControlledTank->FindComponentByClass<UTankAimingComponent>();
        AimingComponent->AimAt(PlayerTank->GetActorLocation());
        //Fire if ready
    if(AimingComponent->GetFiringStatus() == EFiringStatus::Locked)
    {
    AimingComponent->Fire();
    }
}
void ATankAIController::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	auto PlayerTank = GetWorld()->GetFirstPlayerController()->GetPawn();
	auto ControlledTank =GetPawn();
	if (!ensure(PlayerTank && ControlledTank)) { return; }
	//Move Towards the player
	MoveToActor(PlayerTank, AcceptanceRadius);

	//aim towards the player
	auto AimingComponent = ControlledTank->FindComponentByClass<UTankAimingComponent>();
	AimingComponent->AimAt(PlayerTank->GetActorLocation());
		
	//if aiming or locked
	if (AimingComponent->GetFiringState() == EFiringState::Locked)
	{
		AimingComponent->Fire(); //TODO dont fire every frame , limit fire rate
	}
	
}