Osiris
Osiris copied to clipboard
[Suggestion] Knife-Bot or Zeus Bot
Source code:
ZeusBot: namespace zeusbot { float range = 150.f; c_base_combat_weapon* weapon = nullptr;
bool is_enabled(CUserCmd* cmd)
{
if (!interfaces::local_player || !interfaces::local_player->IsAlive() || cmd->buttons & IN_ATTACK)
return false;
if (globals::binds::zeus_bot == 0 || !input_system::is_key_down(globals::binds::zeus_bot))
return false;
weapon = interfaces::local_player->m_hActiveWeapon();
if (!weapon || weapon->m_iItemDefinitionIndex() != WEAPON_TASER || !weapon->CanFire())
return false;
return true;
}
void handle(CUserCmd* cmd)
{
if (!is_enabled(cmd))
return;
const auto weapon_data = weapon->get_weapon_data();
auto best_fov = -1.f;
auto best_time = 0.f;
Vector best_pos;
Ray_t ray;
QAngle angles;
CGameTrace tr;
c_base_player* player;
c_base_player* target = nullptr;
auto nci = interfaces::engine_client->GetNetChannelInfo();
if (!nci)
return;
static const auto sv_maxunlag = interfaces::cvar->find("sv_maxunlag");
const auto unlag = sv_maxunlag->GetFloat();
const auto interpolation_comp = utils::get_interpolation_compensation();
const auto network_delay = std::clamp(nci->GetLatency(FLOW_OUTGOING) + nci->GetLatency(FLOW_INCOMING) + interpolation_comp, 0.f, unlag);
const auto out_delay = std::clamp(nci->GetLatency(FLOW_OUTGOING) + interpolation_comp, 0.f, unlag);;
const auto correct_next_time = TICKS_TO_TIME(cmd->tick_count + 1) + network_delay;
CTraceFilterWorldAndPropsOnly filter;
const auto eye_pos = interfaces::local_player->GetEyePos();
for (const auto& tick : entities::m_items)
{
for (const auto& entity : tick.players)
{
if (entity.index == 0)
continue;
if (fabsf(out_delay - (correct_next_time - entity.m_flSimulationTime - interpolation_comp)) > 0.2f)
continue;
player = c_base_player::GetPlayerByIndex(entity.index);
if (!player || player == interfaces::local_player)
continue;
for (size_t h = 0; h < sizeof(entity.hitboxes); h++)
{
if (h == HITBOX_LEFT_FOOT || h == HITBOX_RIGHT_FOOT || h == HITBOX_RIGHT_HAND || h == HITBOX_LEFT_HAND)
continue;
const auto hitbox = entity.hitboxes[h][0];
if (!hitbox.IsValid())
continue;
const auto distance = eye_pos.DistTo(hitbox);
if (distance > weapon_data->flRange)
continue;
math::vector2angles(hitbox - eye_pos, angles);
angles.NormalizeClamp();
const auto fov = math::GetFovToPlayer(cmd->viewangles, angles);
if (fov > best_fov&& best_fov > 0.f)
continue;
//Damage* [RangeModifier ^ (Distance(u) / 500u)]
const auto damage = weapon_data->iDamage * pow(weapon_data->flRangeModifier, distance / 500);
if (damage < 100.f&& damage < player->m_iHealth())
continue;
ray.Init(eye_pos, hitbox);
interfaces::engine_trace->trace_ray(ray, MASK_SOLID, &filter, &tr);
if (eye_pos.DistTo(tr.endpos) != distance)
continue;
//console::print("zeus damage %.2f", damage);
target = player;
best_pos = hitbox;
best_fov = fov;
best_time = entity.m_flSimulationTime;
}
}
}
if (!target)
return;
math::vector2angles(best_pos - eye_pos, angles);
angles.NormalizeClamp();
if (!utils::hitchance(target, angles, 80.f))
return;
cmd->tick_count = TIME_TO_TICKS(best_time + interpolation_comp);
const auto old_angles = cmd->viewangles;
cmd->viewangles = angles;
interfaces::engine_client->SetViewAngles(angles);
math::correct_movement(cmd, old_angles);
if (!(cmd->buttons & IN_ATTACK))
cmd->buttons |= IN_ATTACK;
}
}
Knife: namespace knife_bot { const auto stab_dist = 32.f; const auto slash_dist = 48.f;
void handle(CUserCmd* cmd, bool& send_packet)
{
if (!interfaces::local_player || !interfaces::local_player->IsAlive() || !settings::misc::knife_bot)
return;
if (cmd->buttons & IN_ATTACK || cmd->buttons & IN_ATTACK2)
return;
auto weapon = interfaces::local_player->m_hActiveWeapon();
if (!weapon || !weapon->IsKnife())
return;
Ray_t ray;
QAngle angles;
CGameTrace tr;
static const auto sv_maxunlag = interfaces::cvar->find("sv_maxunlag");
auto nci = interfaces::engine_client->GetNetChannelInfo();
if (!nci)
return;
const auto unlag = sv_maxunlag->GetFloat();
const auto interpolation_comp = utils::get_interpolation_compensation();
const auto correct_curtime = std::clamp(nci->GetLatency(FLOW_OUTGOING) + nci->GetLatency(FLOW_INCOMING) + interpolation_comp, 0.f, unlag);
const auto eye_pos = interfaces::local_player->GetEyePos();
for (auto& tick : entities::m_items)
{
for (auto& player : tick.players)
{
if (player.index == 0)
continue;
const auto is_valid = fabsf(correct_curtime - (interfaces::global_vars->curtime - player.m_flSimulationTime)) <= 0.2f;
if (!is_valid)
continue;
auto entity = c_base_player::GetPlayerByIndex(player.index);
if (!entity || !entity->IsAlive() || entity == interfaces::local_player)
continue;
CTraceFilterSkipTwoEntities filter = CTraceFilterSkipTwoEntities(interfaces::local_player, entity);
for (size_t h = 0; h < sizeof(player.hitboxes); h++)
{
if (h == HITBOX_LEFT_FOOT || h == HITBOX_RIGHT_FOOT)
continue;
const auto hitbox = player.hitboxes[h][0];
if (!hitbox.IsValid())
continue;
const auto distance = eye_pos.DistTo(hitbox);
if (distance > slash_dist)
continue;
ray.Init(eye_pos, hitbox);
interfaces::engine_trace->trace_ray(ray, MASK_SHOT | CONTENTS_GRATE, &filter, &tr);
if (eye_pos.DistTo(tr.endpos) != distance)
continue;
math::vector2angles(hitbox - eye_pos, angles);
angles.NormalizeClamp();
const auto old_angles = cmd->viewangles;
cmd->buttons |= distance <= stab_dist ? IN_ATTACK2 : IN_ATTACK;
cmd->viewangles = angles;
cmd->tick_count = TIME_TO_TICKS(player.m_flSimulationTime + interpolation_comp);
math::correct_movement(cmd, old_angles);
send_packet = false;
return;
}
}
}
}
}
@danielkrupinski Have a look. Might be useful.
Have a look, i found something on the internet that's publicly available. smh Try doing it yourself, he'll most probably ignore you.
you should properly format it, instead of leaving some code behind in a different format