0% found this document useful (0 votes)
2 views2 pages

Message 3

The document contains a C++ function for an aimbot feature in a game, which identifies the closest enemy to the player and adjusts the camera's rotation to aim at that enemy. It checks various conditions such as the enemy's visibility and whether the player is allowed to shoot before executing the aim adjustment. The function utilizes game-specific methods to retrieve player and enemy positions, calculate distances, and determine the necessary rotation angles for aiming.

Uploaded by

Heartache
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Message 3

The document contains a C++ function for an aimbot feature in a game, which identifies the closest enemy to the player and adjusts the camera's rotation to aim at that enemy. It checks various conditions such as the enemy's visibility and whether the player is allowed to shoot before executing the aim adjustment. The function utilizes game-specific methods to retrieve player and enemy positions, calculate distances, and determine the necessary rotation angles for aiming.

Uploaded by

Heartache
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#pragma once

inline void AimbotStart(void* myplayer)


{
void* camera = GameFunctions::GetUnityCamera();
if (myplayer && playerList.size() > 0 && camera)
{
void* closestEnemy = nullptr;
float minDistance = 999999;

for (int i = 0; i < playerList.size(); i++)


{
void* enemy = playerList[i];
if (GameFunctions::isEnemyTo(myplayer, enemy) && !
GameFunctions::isDead(enemy))
{
void* myTransform = GameFunctions::GetTransform(myplayer);
void* enemyTransform = GameFunctions::GetTransform(enemy);

Vector3 myPos = GameFunctions::GetPosition(myTransform);


Vector3 enemyPos = GameFunctions::GetPosition(enemyTransform);
Quaternion myRotation = GameFunctions::get_rotation(myTransform);
Vector3 enemyScreenPos = GameFunctions::WorldToScreenPoint(camera,
enemyPos, Mono);
float distance = std::sqrt(pow(enemyPos.X - myPos.X, 2) +
pow(enemyPos.Y - myPos.Y, 2) + pow(enemyPos.Z - myPos.Z, 2));
static const Vector3 forwardDir(0.0f, 0.0f, 1.0f);
Vector3 playerForwardDirection = myRotation * forwardDir;
float screenX = (float)Variables::resolutionX -
((float)Variables::resolutionX - enemyScreenPos.X);
float screenY = ((float)Variables::resolutionY - enemyScreenPos.Y);
float screenDistance2Middle2 = sqrt(pow((screenX -
(Variables::resolutionX / 2)), 2) + pow((screenY - (Variables::resolutionY / 2)),
2));

if (Vector3::Dot(playerForwardDirection, enemyPos - myPos) > 0 &&


Vector3::Magnitude(enemyPos - myPos) < minDistance) // Check if enemy is in front
{
if (Variables::EnableCircleFov)
{
if (screenDistance2Middle2 <= Variables::CircleFov)
{
minDistance = Vector3::Magnitude(distance);
closestEnemy = enemy;
}
}
else
{
minDistance = Vector3::Magnitude(distance);
closestEnemy = enemy;
}
}
}
}

if (closestEnemy != nullptr)
{
void* myTransform =
GameFunctions::GetTransform(GameFunctions::get_playerTransform(myplayer));
void* closestEnemyTransform =
GameFunctions::GetTransform(closestEnemy);
Vector3 closestEnemyPos =
GameFunctions::GetPosition(closestEnemyTransform);
Vector3 enemyScreenPos = GameFunctions::WorldToScreenPoint(camera,
closestEnemyPos, Mono);
Vector3 myPos =
GameFunctions::GetPosition(GameFunctions::GetTransform(myplayer));
float distanceToClosestEnemy = Vector3::Magnitude(closestEnemyPos -
myPos);

if (enemyScreenPos.Z >= 1 && distanceToClosestEnemy < minDistance)


{
void *CurrentCamera = GameFunctions::GetCurrentCamera();
void* CurrentCamTransform =
GameFunctions::GetTransform(CurrentCamera);
auto camPosition =
GameFunctions::GetPosition(GameFunctions::GetTransform(CurrentCamTransform));
Vector3 targetEnemyVector =
GameFunctions::InverseTransformPoint(CurrentCamTransform, closestEnemyPos);
float deltaYaw = (std::atan2(targetEnemyVector.Z,
targetEnemyVector.X)) * 180 / M_PI;
float distanceVector = std::sqrt(targetEnemyVector.X *
targetEnemyVector.X + targetEnemyVector.Z * targetEnemyVector.Z);

float pitchOffset = 0.60;

float deltaPitch = (std::atan2(targetEnemyVector.Y + pitchOffset,


distanceVector)) * 180 / M_PI;
bool isVisible = !Variables::EnableAimVis ||
GameFunctions::LineOfSight(closestEnemyPos, camPosition);

if ((Variables::EnableShootcheck && GetAsyncKeyState(VK_LBUTTON) &


0x8000) || !Variables::EnableShootcheck)
{
if (isVisible)
{
if (Variables::aimbotMode ==
Variables::AimbotMode::LookAtInGame)
{
GameFunctions::Rotate(CurrentCamTransform, -
(deltaPitch), 0, 0);
GameFunctions::Rotate(myTransform, 0, -(deltaYaw - 90),
0);
}
}
}
}
}
}
}

You might also like