std::vector <scan_point> aim::get_points(adjust_data* record, int hitbox) { std::vector <scan_point> points; auto model = record->player->GetModel(); if (!model) return points; auto hdr = m_modelinfo()->GetStudioModel(model); if (!hdr) return points; auto set = hdr->pHitboxSet(record->player->m_nHitboxSet()); if (!set) return points; auto bbox = set->pHitbox(hitbox); if (!bbox) return points; auto center = (bbox->bbmin + bbox->bbmax) * 0.5f; auto POINT_SCALE = 0.0f; if (g_cfg.ragebot.weapon[globals.g.current_weapon].static_point_scale) { if (hitbox == HITBOX_HEAD) POINT_SCALE = g_cfg.ragebot.weapon[globals.g.current_weapon].head_scale; else POINT_SCALE = g_cfg.ragebot.weapon[globals.g.current_weapon].body_scale; } else { auto transformed_center = center; math::vector_transform(transformed_center, record->matrixes_data.main[bbox->bone], transformed_center); auto spread = globals.g.spread + globals.g.inaccuracy; auto distance = transformed_center.DistTo(globals.g.eye_pos); distance /= math::fast_sin(DEG2RAD(90.0f - RAD2DEG(spread))); spread = math::fast_sin(spread); auto radius = max(bbox->radius - distance * spread, 0.0f); POINT_SCALE = math::clamp(radius / bbox->radius, 0.0f, 1.0f); } if (bbox->radius <= 0.0f) { auto rotation_matrix = math::angle_matrix(bbox->rotation); matrix3x4_t matrix; math::concat_transforms(record->matrixes_data.main[bbox->bone], rotation_matrix, matrix); auto origin = matrix.GetOrigin(); if (hitbox == HITBOX_RIGHT_FOOT || hitbox == HITBOX_LEFT_FOOT) { auto side = (bbox->bbmin.z - center.z) * 0.875f; if (hitbox == HITBOX_LEFT_FOOT) side = -side; points.emplace_back(scan_point(Vector(center.x, center.y, center.z + side), hitbox, true)); auto min = (bbox->bbmin.x - center.x) * 0.875f; auto max = (bbox->bbmax.x - center.x) * 0.875f; points.emplace_back(scan_point(Vector(center.x + min, center.y, center.z), hitbox, false)); points.emplace_back(scan_point(Vector(center.x + max, center.y, center.z), hitbox, false)); } // rotate our bbox points by their correct angle and convert our points to world space. for (auto& p : points) { // VectorRotate. // rotate point by angle stored in matrix. p.point = { p.point.Dot(matrix[0]), p.point.Dot(matrix[1]), p.point.Dot(matrix[2]) }; // transform point to world space. p.point += origin; } } else { Vector min, max; math::vector_transform(bbox->bbmin, record->matrixes_data.main[bbox->bone], min); math::vector_transform(bbox->bbmax, record->matrixes_data.main[bbox->bone], max); Vector center = (bbox->bbmax + bbox->bbmin) * 0.5f; Vector centerTrans = center; math::vector_transform(centerTrans, record->matrixes_data.main[bbox->bone], centerTrans); points.emplace_back(scan_point(centerTrans, hitbox, true)); if (hitbox == HITBOX_RIGHT_CALF || hitbox == HITBOX_LEFT_THIGH || hitbox == HITBOX_LEFT_CALF || hitbox == HITBOX_RIGHT_THIGH) return points; Vector aeye = globals.g.eye_pos; auto delta = centerTrans - aeye; delta.Normalized(); auto max_min = max - min; max_min.Normalized(); auto cr = max_min.Cross(delta); QAngle d_angle; math::VectorAngles(delta, d_angle); bool vertical = hitbox == HITBOX_HEAD; Vector right, up; if (vertical) { QAngle cr_angle; math::VectorAngles(cr, cr_angle); cr_angle.ToVectors(&right, &up); cr_angle.roll = d_angle.pitch; Vector _up = up, _right = right, _cr = cr; cr = _right; right = _cr; } else { math::VectorVectors(delta, up, right); } RayTracer::Hitbox box(min, max, bbox->radius); RayTracer::Trace trace; if (hitbox == HITBOX_HEAD) { Vector middle = (right.Normalized() + up.Normalized()) * 0.5f; Vector middle2 = (right.Normalized() - up.Normalized()) * 0.5f; RayTracer::Ray ray = RayTracer::Ray(aeye, centerTrans + (middle * 1000.0f)); RayTracer::TraceFromCenter(ray, box, trace, RayTracer::Flags_RETURNEND); points.emplace_back(scan_point(trace.m_traceEnd, hitbox, false)); ray = RayTracer::Ray(aeye, centerTrans - (middle2 * 10000.0f)); RayTracer::TraceFromCenter(ray, box, trace, RayTracer::Flags_RETURNEND); points.emplace_back(scan_point(trace.m_traceEnd, hitbox, false)); ray = RayTracer::Ray(aeye, centerTrans + (up * 10000.0f)); RayTracer::TraceFromCenter(ray, box, trace, RayTracer::Flags_RETURNEND); points.emplace_back(scan_point(trace.m_traceEnd, hitbox, false)); ray = RayTracer::Ray(aeye, centerTrans - (up * 10000.0f)); RayTracer::TraceFromCenter(ray, box, trace, RayTracer::Flags_RETURNEND); points.emplace_back(scan_point(trace.m_traceEnd, hitbox, false)); } else { RayTracer::Ray ray = RayTracer::Ray(aeye, centerTrans - ((vertical ? cr : up) * 10000.0f)); RayTracer::TraceFromCenter(ray, box, trace, RayTracer::Flags_RETURNEND); points.emplace_back(scan_point(trace.m_traceEnd, hitbox, false)); ray = RayTracer::Ray(aeye, centerTrans + ((vertical ? up : up) * 10000.0f)); RayTracer::TraceFromCenter(ray, box, trace, RayTracer::Flags_RETURNEND); points.emplace_back(scan_point(trace.m_traceEnd, hitbox, false)); } for (size_t i = 1; i < points.size(); ++i) { auto delta_center = points[i].point - centerTrans; points[i].point = centerTrans + delta_center * POINT_SCALE; } } return points; }