Исходник ThirdPerson TraceRay [Spoon Fed]

Пользователь
Статус
Оффлайн
Регистрация
3 Янв 2020
Сообщения
93
Реакции[?]
114
Поинты[?]
18K
Credits to the original poster xProgramer

complete spoon fed code with updated sigs etc

C++:
cs2 input sig "48 8B 0D ? ? ? ? 4C 8B C6 8B 10 E8"


override view hook sig "48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 41 56 41 57 48 83 EC ? 48 8B FA E8"


        sdk::QAngle get_view_angles()
        {
            using fnGetViewAngles = std::int64_t(__fastcall*)(ccsgo_input*, std::int32_t);
            static fnGetViewAngles oGetViewAngles = reinterpret_cast<fnGetViewAngles>(utils::find_pattern("client.dll", "4C 8B C1 85 D2 74 08 48 8D 05 ? ? ? ? C3"));


            return *reinterpret_cast<sdk::QAngle*>(oGetViewAngles(this, 0));
        }



    // Convert degrees to radians

    inline float XMConvertToRadians(float degrees) {
        return degrees * (XM_PI / 180.0f);  // Convert degrees to radians
    }


    __forceinline sdk::Vector calculate_camera_position(sdk::Vector anchorPos, float distance, sdk::QAngle viewAngles)
    {
        float yaw = XMConvertToRadians(viewAngles.y);
        float pitch = XMConvertToRadians(viewAngles.x);

        float x = anchorPos.x + distance * cosf(yaw) * cosf(pitch);
        float y = anchorPos.y + distance * sinf(yaw) * cosf(pitch);
        float z = anchorPos.z + distance * sinf(pitch);

        return sdk::Vector{ x, y, z };
    }


    bool GameTrace_t::DidHitWorld() const
    {
        C_BaseEntity* pWorldEntity = manager->resource_service->game_entity_system->get_entity_by_index(0);
        if (!pWorldEntity)
            return false;

        return reinterpret_cast<C_BaseEntity*>(m_pHitEntity) == pWorldEntity;
    }


static auto progress = 0.f;
        if (run_third_peron)
        {
            // Get and adjust camera view angles
            sdk::QAngle adjusted_view_angle = manager->input->get_view_angles();
            adjusted_view_angle.x = -adjusted_view_angle.x;

            // Bezier smoothing function for interpolation
            auto bezier_smooth = [](float t) { return t * t * (3.0f - 2.0f * t); };

            // Update the progress of interpolation
            constexpr float interpolation_speed = 6.0f;
            float target_distance = config.misc.thirdperson_dist.get();
            progress = clamp(progress + manager->global_vars->frame_time * interpolation_speed, target_distance, 1.f);

            // Calculate new camera position
            float interp_factor = config.misc.thirdperson_no_interp.get() ? 1.f : bezier_smooth(progress);
            view_setup->origin = math::calculate_camera_position(local_pawn->get_eye_pos(),
                -target_distance * interp_factor,
                adjusted_view_angle);

            sdk::Ray_t ray{};
            sdk::GameTrace_t trace{};
            sdk::TraceFilter_t filter{ 0x1C3003, local_pawn, NULL, 4 };

            if (manager->engine_trace->trace_shape(&ray, local_pawn->get_eye_pos(), view_setup->origin, &filter, &trace)) {
                if (trace.DidHitWorld()) {
                    view_setup->origin = trace.m_vecPosition;
                }
            }

            sdk::QAngle p = math::normalize_angles(CalcAngle(view_setup->origin, local_pawn->get_eye_pos()));
            view_setup->view = sdk::QAngle{ p.x, p.y , p.z };

        }
        else
        {
            progress = config.misc.thirdperson.get() ? 1.f : 0.f;
        }



    struct cview_setup
    {
        MEMORY_PAD(0x490);
        float flOrthoLeft; // 0x0494
        float flOrthoTop; // 0x0498
        float flOrthoRight; // 0x049C
        float flOrthoBottom; // 0x04A0
        MEMORY_PAD(0x38);
        float Fov; // 0x04D8
        float fov_viewmodel; // 0x04DC
        Vector origin; // 0x04E0
        MEMORY_PAD(0xC); // 0x04EC
        QAngle view; // 0x04F8
        MEMORY_PAD(0x14); // 0x0504
        float aspect_ratio; // 0x0518
        MEMORY_PAD(0x71);
        BYTE nSomeFlags;

    };
video showing it works
Пожалуйста, авторизуйтесь для просмотра ссылки.
 
Последнее редактирование:
Сверху Снизу