Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void c_ragebot::autostop(c_cs_player* local, c_user_cmd* cmd)
- {
- if (cmd->buttons & c_user_cmd::jump)
- return;
- static const auto nospread = cvar()->find_var(_("weapon_accuracy_nospread"));
- const auto weapon = reinterpret_cast<c_base_combat_weapon*>(
- client_entity_list()->get_client_entity_from_handle(local->get_current_weapon_handle()));
- if (nospread->get_int() || !local->is_on_ground() ||
- (weapon && weapon->get_item_definition() == weapon_taser) && local->is_on_ground())
- return;
- const auto wpn_info = weapon_system->get_weapon_data(weapon->get_item_definition());
- if (!wpn_info)
- return;
- auto& info = get_autostop_info();
- if (info.call_time == global_vars_base->curtime)
- {
- info.did_stop = true;
- return;
- }
- info.did_stop = false;
- info.call_time = global_vars_base->curtime;
- if (local->get_velocity().length2d() <= wpn_info->get_standing_accuracy(weapon))
- return;
- else
- {
- cmd->forwardmove = 0.f;
- cmd->sidemove = 0.f;
- prediction_system->repredict(local, cmd);
- if (config.rage.slow_walk && GetAsyncKeyState(config.rage.slow_walk))
- {
- info.did_stop = true;
- return;
- }
- if (local->get_velocity().length2d() <= wpn_info->get_standing_accuracy(weapon))
- return;
- }
- c_qangle dir;
- math::vector_angles(prediction_system->unpredicted_velocity, dir);
- const auto angles = engine_client()->get_view_angles();
- dir.y = angles.y - dir.y;
- c_vector3d move;
- math::angle_vectors(dir, move);
- if (prediction_system->unpredicted_velocity.length2d() > .1f)
- move *= -math::forward_bounds / std::max(std::abs(move.x), std::abs(move.y));
- cmd->forwardmove = move.x;
- cmd->sidemove = move.y;
- const auto backup = cmd->viewangles;
- cmd->viewangles = angles;
- prediction_system->repredict(local, cmd);
- cmd->viewangles = backup;
- if (local->get_velocity().length2d() > prediction_system->unpredicted_velocity.length2d())
- {
- cmd->forwardmove = 0.f;
- cmd->sidemove = 0.f;
- }
- prediction_system->repredict(local, cmd);
- }
Add Comment
Please, Sign In to add comment