Начинающий
- Статус
- Оффлайн
- Регистрация
- 9 Сен 2021
- Сообщения
- 222
- Реакции
- 18
this is probably better has more sanity checksits already public but here
C++:float Resolver::AntiFreestand(Player* player, LagRecord* record, vec3_t start_, vec3_t end, bool include_base, float base_yaw, float delta) { AimPlayer* data = &g_aimbot.m_players[player->index() - 1]; // constants. constexpr float STEP{ 4.f }; constexpr float RANGE{ 32.f }; // construct vector of angles to test. std::vector< AdaptiveAngle > angles{ }; angles.emplace_back(base_yaw + delta); angles.emplace_back(base_yaw - delta); if (include_base) angles.emplace_back(base_yaw); // start the trace at the enemy shoot pos. vec3_t start = start_; // see if we got any valid result. // if this is false the path was not obstructed with anything. bool valid{ false }; // get the enemies shoot pos. vec3_t shoot_pos = end; // iterate vector of angles. for (auto it = angles.begin(); it != angles.end(); ++it) { // compute the 'rough' estimation of where our head will be. vec3_t end{ shoot_pos.x + std::cos(math::deg_to_rad(it->m_yaw)) * RANGE, shoot_pos.y + std::sin(math::deg_to_rad(it->m_yaw)) * RANGE, shoot_pos.z }; // draw a line for debugging purposes. //g_csgo.m_debug_overlay->AddLineOverlay( start, end, 255, 0, 0, true, 0.1f ); // compute the direction. vec3_t dir = end - start; float len = dir.normalize(); // should never happen. if (len <= 0.f) continue; // step thru the total distance, 4 units per step. for (float i{ 0.f }; i < len; i += STEP) { // get the current step position. vec3_t point = start + (dir * i); // get the contents at this point. int contents = g_csgo.m_engine_trace->GetPointContents(point, MASK_SHOT_HULL); // contains nothing that can stop a bullet. if (!(contents & MASK_SHOT_HULL)) continue; float mult = 1.f; // over 50% of the total length, prioritize this shit. if (i > (len * 0.5f)) mult = 1.25f; // over 90% of the total length, prioritize this shit. if (i > (len * 0.75f)) mult = 1.25f; // over 90% of the total length, prioritize this shit. if (i > (len * 0.9f)) mult = 2.f; // append 'penetrated distance'. it->m_dist += (STEP * mult); // mark that we found anything. valid = true; } } if (!valid) return base_yaw; // put the most distance at the front of the container. std::sort(angles.begin(), angles.end(), [](const AdaptiveAngle& a, const AdaptiveAngle& b) { return a.m_dist > b.m_dist; }); // the best angle should be at the front now. return angles.front().m_yaw; }