-
Автор темы
- #1
hello this is a blockbot for legendware (it's not very good), enjoy:
void misc::blockbot(CUserCmd* cmd)
{
if (!g_cfg.misc.blockbot_enabled || !key_binds::get().get_key_bind_state(24))
return;
float flBestDistance = 250.0f;
int iBestIndex = -1;
for (auto i = 1; i < m_globals()->m_maxclients; i++) {
auto entity = (player_t*)m_entitylist()->GetClientEntity(i);
if (!entity || entity->IsDormant() || !entity->is_alive() ||
entity == g_ctx.local())
continue;
float flDistance = g_ctx.local()->m_vecOrigin().DistTo(entity->m_vecOrigin());
if (flDistance < flBestDistance)
{
flBestDistance = flDistance;
iBestIndex = i;
}
}
auto entity = (player_t*)m_entitylist()->GetClientEntity(iBestIndex);
if (!entity)
return;
float flBestSpeed = g_cfg.misc.blockbot_type == 0 ? entity->m_vecVelocity().Length() : 450.0f;
Vector angLocal;
m_engine()->GetViewAngles(angLocal);
Vector vecForward = entity->m_vecOrigin() - g_ctx.local()->m_vecOrigin();
if (entity->hitbox_position(6).z < g_ctx.local()->m_vecOrigin().z && g_ctx.local()->m_vecOrigin().DistTo(entity->m_vecOrigin()) < 100.0f)
{
cmd->m_forwardmove = ((sin(DEG2RAD(angLocal.y)) * vecForward.y) + (cos(DEG2RAD(angLocal.y)) * vecForward.x)) * flBestSpeed;
cmd->m_sidemove = ((cos(DEG2RAD(angLocal.y)) * -vecForward.y) + (sin(DEG2RAD(angLocal.y)) * vecForward.x)) * flBestSpeed;
}
else
{
auto yaw_delta = (atan2(vecForward.y, vecForward.x) * 180.0f / M_PI) - angLocal.y;
if (yaw_delta > 180) { yaw_delta -= 360; }
else if (yaw_delta < -180) { yaw_delta += 360; }
if (yaw_delta > 0.25) { cmd->m_sidemove = -flBestSpeed; }
else if (yaw_delta < -0.25) { cmd->m_sidemove = flBestSpeed; }
}
}