-
Автор темы
- #1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Авто Алайн xoden'a
C++:
void Misc::autohug(UserCmd* cmd) noexcept
{
if (!config->misc.autohug)
return;
if (!localPlayer || !localPlayer->isAlive() || (localPlayer->flags() & 1))
return;
if (const auto mt = localPlayer->moveType(); mt == MoveType::LADDER || mt == MoveType::NOCLIP)
return;
Vector wishdir;
bool done = false;
if ((cmd->buttons & UserCmd::IN_FORWARD) && !(cmd->buttons & UserCmd::IN_BACK) && !(cmd->buttons & UserCmd::IN_MOVELEFT) && !(cmd->buttons & UserCmd::IN_MOVERIGHT)) {
wishdir = { std::cos(degreesToRadians(cmd->viewangles.y)) * 17.f, std::sin(degreesToRadians(cmd->viewangles.y)) * 17.f, 0.f };
done = true;
}
if ((cmd->buttons & UserCmd::IN_BACK) && !(cmd->buttons & UserCmd::IN_FORWARD) && !(cmd->buttons & UserCmd::IN_MOVELEFT) && !(cmd->buttons & UserCmd::IN_MOVERIGHT)) {
wishdir = { std::cos(degreesToRadians(cmd->viewangles.y + 180.f)) * 17.f, std::sin(degreesToRadians(cmd->viewangles.y + 180.f)) * 17.f, 0.f };
done = true;
}
if ((cmd->buttons & UserCmd::IN_MOVELEFT) && !(cmd->buttons & UserCmd::IN_BACK) && !(cmd->buttons & UserCmd::IN_FORWARD) && !(cmd->buttons & UserCmd::IN_MOVERIGHT)) {
wishdir = { std::cos(degreesToRadians(cmd->viewangles.y + 90.f)) * 17.f, std::sin(degreesToRadians(cmd->viewangles.y + 90.f)) * 17.f, 0.f };
done = true;
}
if ((cmd->buttons & UserCmd::IN_MOVERIGHT) && !(cmd->buttons & UserCmd::IN_BACK) && !(cmd->buttons & UserCmd::IN_MOVELEFT) && !(cmd->buttons & UserCmd::IN_FORWARD)) {
wishdir = { std::cos(degreesToRadians(cmd->viewangles.y - 90.f)) * 17.f, std::sin(degreesToRadians(cmd->viewangles.y - 90.f)) * 17.f, 0.f };
done = true;
}
if (!done)
return;
const auto startPos = localPlayer->getAbsOrigin();
const auto endPos = startPos + wishdir;
Trace trace;
interfaces->engineTrace->traceRay({ startPos, endPos }, MASK_PLAYERSOLID, localPlayer.get(), trace);
if ((trace.fraction < 1.f) && (trace.plane.normal.z == 0.f)) {
Vector Angles{ trace.plane.normal.x * -16.005f, trace.plane.normal.y * -16.005f, 0.f };
const auto endPos2 = startPos + Angles;
Trace trace2;
interfaces->engineTrace->traceRay({ startPos, endPos2 }, MASK_PLAYERSOLID, localPlayer.get(), trace2);
if (trace.plane != trace2.plane) {
Vector to_wall = Angles.toAngle();
float mVel = hypotf(localPlayer->velocity().x, localPlayer->velocity().y);
float ideal = radiansToDegrees(atanf(28.33f / mVel));
Vector dvelo = localPlayer->velocity();
dvelo.z = 0.f;
Vector velo_angle = dvelo.toAngle();
Vector delta = velo_angle - to_wall;
delta.normalize();
if (delta.y >= 0.f)
to_wall.y += ideal;
else
to_wall.y -= ideal;
float rotation = degreesToRadians(to_wall.y - cmd->viewangles.y);
float cos_rot = cos(rotation);
float sin_rot = sin(rotation);
float forwardmove = cos_rot * 450.f;
float sidemove = -sin_rot * 450.f;
cmd->forwardmove = forwardmove;
cmd->sidemove = sidemove;
}
}
}