Better charge aimbot + make_unique

This commit is contained in:
LightCat 2018-10-11 19:08:40 +02:00
parent 82e8cd915a
commit af4a6613b0
3 changed files with 66 additions and 11 deletions

View File

@ -51,6 +51,66 @@ std::pair<CachedEntity *, Vector> FindBestEnt(bool teammate, bool Predict,
}
return { bestent, predicted };
}
static float slow_change_dist_y{};
static float slow_change_dist_p{};
void DoSlowAim(Vector &input_angle)
{
auto viewangles = current_user_cmd->viewangles;
// Yaw
if (viewangles.y != input_angle.y)
{
// Check if input angle and user angle are on opposing sides of yaw so
// we can correct for that
bool slow_opposing = false;
if ((input_angle.y < -90 && viewangles.y > 90) ||
(input_angle.y > 90 && viewangles.y < -90))
slow_opposing = true;
// Direction
bool slow_dir = false;
if (slow_opposing)
{
if (input_angle.y > 90 && viewangles.y < -90)
slow_dir = true;
}
else if (viewangles.y > input_angle.y)
slow_dir = true;
// Speed, check if opposing. We dont get a new distance due to the
// opposing sides making the distance spike, so just cheap out and reuse
// our last one.
if (!slow_opposing)
slow_change_dist_y =
std::abs(viewangles.y - input_angle.y) / 5;
// Move in the direction of the input angle
if (slow_dir)
input_angle.y = viewangles.y - slow_change_dist_y;
else
input_angle.y = viewangles.y + slow_change_dist_y;
}
// Pitch
if (viewangles.x != input_angle.x)
{
// Get speed
slow_change_dist_p =
std::abs(viewangles.x - input_angle.x) / 5;
// Move in the direction of the input angle
if (viewangles.x > input_angle.x)
input_angle.x = viewangles.x - slow_change_dist_p;
else
input_angle.x = viewangles.x + slow_change_dist_p;
}
// Clamp as we changed angles
fClampAngle(input_angle);
}
static HookedFunction
SandwichAim(HookedFunctions_types::HF_CreateMove, "SandwichAim", 1, []() {
if (!*enable)
@ -112,8 +172,7 @@ static HookedFunction
VectorAngles(tr, angles);
// Clamping is important
fClampAngle(angles);
DoSlowAim(angles);
current_user_cmd->viewangles = angles;
current_user_cmd->buttons |= IN_ATTACK2;
g_pLocalPlayer->bUseSilentAngles = true;
}
});
});

View File

@ -61,8 +61,8 @@ void RunEnginePrediction(IClientEntity *ent, CUserCmd *ucmd)
(FinishMoveFn)(*(unsigned *) (predictionVtable + 20));
// CMoveData *pMoveData = (CMoveData*)(sharedobj::client->lmap->l_addr +
// 0x1F69C0C); CMoveData movedata {};
char *object = new char[165];
CMoveData *pMoveData = (CMoveData *) object;
auto object = std::make_unique<char[]>(165);
CMoveData *pMoveData = (CMoveData *) object.get();
// Backup
float frameTime = g_GlobalVars->frametime;
@ -95,8 +95,6 @@ void RunEnginePrediction(IClientEntity *ent, CUserCmd *ucmd)
g_IGameMovement->FinishTrackPredictionErrors(
reinterpret_cast<CBasePlayer *>(ent));
delete[] object;
// Reset User CMD
NET_VAR(ent, 4188, CUserCmd *) = nullptr;

View File

@ -136,8 +136,8 @@ Vector EnginePrediction(CachedEntity *entity, float time)
// CMoveData *pMoveData = (CMoveData*)(sharedobj::client->lmap->l_addr +
// 0x1F69C0C); CMoveData movedata {};
char *object = new char[165];
CMoveData *pMoveData = (CMoveData *) object;
auto object = std::make_unique<char[]>(165);
CMoveData *pMoveData = (CMoveData *) object.get();
float frameTime = g_GlobalVars->frametime;
float curTime = g_GlobalVars->curtime;
@ -181,8 +181,6 @@ Vector EnginePrediction(CachedEntity *entity, float time)
g_IGameMovement->FinishTrackPredictionErrors(
reinterpret_cast<CBasePlayer *>(ent));
delete[] object;
NET_VAR(entity, 4188, CUserCmd *) = original_cmd;
g_GlobalVars->frametime = frameTime;