Исходник Chams weawe

Пользователь
Статус
Оффлайн
Регистрация
10 Ноя 2019
Сообщения
839
Реакции[?]
135
Поинты[?]
0
Типо да,тут вырезано пол кода и сделано немного проще для тех кто может не понимал хз.Типо те кто шарит и может это сделать сам не бейте)


Код:
void CChams::Draw(void* ecx, void* results, const DrawModelInfo_t& info,
    matrix* bone_to_world, float* flex_weights, float* flex_delayed_weights, const Vector& model_origin, int flags)
{
    static auto DrawModel = g_pStudioRenderHook->GetOriginal<fnDrawModel>(29);
    const auto ModelName = info.pStudioHdr->name;
    static IMaterial* Regular = interfaces.material_system->FindMaterial(hs::debugambientcube::s().c_str(), nullptr);
    static IMaterial* Flat = interfaces.material_system->FindMaterial(hs::debugdrawflat::s().c_str(), nullptr);
    static IMaterial* Glow = interfaces.material_system->FindMaterial(hs::glow_armsrace::s().c_str(), nullptr);
    
    
    
    //добавляете свой материал пример:  static IMaterial* materialGlass = interfaces.material_system->FindMaterial("models/inventory_items/cologne_prediction/cologne_prediction_glass", "Model textures");
    

    if (strstr(ModelName, "player/") != nullptr)
    {
        if (!info.pClientEntity)
            return DrawModel(ecx, results, info, bone_to_world, flex_weights, flex_delayed_weights, model_origin, flags);

        auto Entity = info.pClientEntity->GetIClientUnknown()->GetBaseEntity();

        if (!Entity)
            return DrawModel(ecx, results, info, bone_to_world, flex_weights, flex_delayed_weights, model_origin, flags);

        if (Entity && Entity->IsValid())
        {
            

            static IMaterial* OverridedMaterial = nullptr;
            static IMaterial* OverridedMaterialXqz = nullptr;

            static IMaterial* OverridedMaterialBck = nullptr;
            

            
            

            

            switch (vars.visuals.chamstype)
            {
            case 0: OverridedMaterial = Regular; break;
            case 1: OverridedMaterial = Flat; break;
            case 3: OverridedMaterial = materialGlass; break;
            
            }

            OverridedMaterial->SetMaterialVarFlag(MATERIAL_VAR_TRANSLUCENT, true);

            switch (vars.visuals.misc_chams[history].material)
            {
            case 0: OverridedMaterialBck = Regular; break;
            case 1: OverridedMaterialBck = Flat; break;
            case 2: OverridedMaterialBck = GlowFade; break;
            case 3: OverridedMaterialBck = materialGlass; break;
            
            }

            matrix pMat[128];
            if (vars.visuals.misc_chams[history].enable && GetBacktrackMaxtrix(Entity, pMat)) {
                

                OverridedMaterialBck->ColorModulate(
                    vars.visuals.misc_chams[history].clr[0],
                    vars.visuals.misc_chams[history].clr[1],
                    vars.visuals.misc_chams[history].clr[2]);
                OverridedMaterialBck->AlphaModulate(vars.visuals.misc_chams[history].clr[3]);
                OverridedMaterialBck->SetMaterialVarFlag(MATERIAL_VAR_IGNOREZ, true);
                bool bFound = false;
                IMaterialVar* pMatVar = OverridedMaterial->FindVar("$envmaptint", &bFound);
                if (bFound)
                    pMatVar->SetVecValue(vars.visuals.misc_chams[history].glow_clr[0],
                        vars.visuals.misc_chams[history].glow_clr[1], vars.visuals.misc_chams[history].glow_clr[2]);
                float backup_clr[3];
                interfaces.render_view->GetColorModulation(backup_clr);
                

                interfaces.models.model_render->ForcedMaterialOverride(OverridedMaterialBck);
                DrawModel(ecx, results, info, pMat, flex_weights, flex_delayed_weights, model_origin, flags);

                
            }




        

            if (vars.visuals.chamsxqz)
            {
                OverridedMaterial->ColorModulate(
                    vars.visuals.chamscolor_xqz[0] , vars.visuals.chamscolor_xqz[1] , vars.visuals.chamscolor_xqz[2] );
                OverridedMaterial->AlphaModulate(vars.visuals.chamscolor_xqz[3]) ;
                OverridedMaterial->SetMaterialVarFlag(MATERIAL_VAR_IGNOREZ, true);
                bool bFound = false;
                IMaterialVar* pMatVar = OverridedMaterial->FindVar("$envmaptint", &bFound);
                if (bFound)
                    pMatVar->SetVecValue(vars.visuals.chamscolor_xqz[0],
                        vars.visuals.chamscolor_xqz[1], vars.visuals.chamscolor_xqz[2]);
                
                float backup_clr[3];
                interfaces.render_view->GetColorModulation(backup_clr);
                
                interfaces.models.model_render->ForcedMaterialOverride(OverridedMaterial);
                DrawModel(ecx, results, info, bone_to_world, flex_weights, flex_delayed_weights, model_origin, flags);

                
            }

            if (vars.visuals.chams)
            {
                OverridedMaterial->ColorModulate(
                    vars.visuals.chamscolor[0], vars.visuals.chamscolor[1] , vars.visuals.chamscolor[2]  );
                OverridedMaterial->AlphaModulate(vars.visuals.chamscolor[3] );
                OverridedMaterial->SetMaterialVarFlag(MATERIAL_VAR_IGNOREZ, false);
                bool bFound = false;
                IMaterialVar* pMatVar = OverridedMaterial->FindVar("$envmaptint", &bFound);
                if (bFound)
                    pMatVar->SetVecValue(vars.visuals.chamscolor[0],
                        vars.visuals.chamscolor[1], vars.visuals.chamscolor[2]);
                float backup_clr[3];
                interfaces.render_view->GetColorModulation(backup_clr);
                
                interfaces.models.model_render->ForcedMaterialOverride(OverridedMaterial);
                DrawModel(ecx, results, info, bone_to_world, flex_weights, flex_delayed_weights, model_origin, flags);

                
            }
            else {
                interfaces.models.model_render->ForcedMaterialOverride(nullptr);
                DrawModel(ecx, results, info, bone_to_world, flex_weights, flex_delayed_weights, model_origin, flags);
            }
        }
        else if (Entity == csgo->local && csgo->local->isAlive())
        {

            static IMaterial* OverridedMaterialLocal = nullptr;
            
            if (interfaces.input->m_fCameraInThirdPerson) {

                switch (vars.visuals.localchamstype)
                {
                case 0: OverridedMaterialLocal = Regular; break;
                case 1: OverridedMaterialLocal = Flat; break;
                case 2: OverridedMaterialLocal = GlowFade; break;
                case 3: OverridedMaterialLocal = materialGlass; break;
            

                }

                

            
                
                if (vars.visuals.overlap_dsy) {
                    if (vars.visuals.localchams)
                    {
                        OverridedMaterialLocal->SetMaterialVarFlag(MATERIAL_VAR_TRANSLUCENT, true);

                        
                        OverridedMaterialLocal->ColorModulate(
                            vars.visuals.localchams_color[0], vars.visuals.localchams_color[1], vars.visuals.localchams_color[2]);
                        
                        float backup_clr[3];
                        interfaces.render_view->GetColorModulation(backup_clr);
                        bool bFound = false;
                        IMaterialVar* pMatVar = OverridedMaterialLocal->FindVar("$envmaptint", &bFound);
                        if (bFound)
                            pMatVar->SetVecValue(vars.visuals.local_chams.metallic_clr[0],
                                vars.visuals.local_chams.metallic_clr[1], vars.visuals.local_chams.metallic_clr[2]);

                        OverridedMaterialLocal->AlphaModulate(vars.visuals.localchams_color[3]);
                        OverridedMaterialLocal->SetMaterialVarFlag(MATERIAL_VAR_IGNOREZ, false);

                        interfaces.models.model_render->ForcedMaterialOverride(OverridedMaterialLocal);
                        DrawModel(ecx, results, info, bone_to_world, flex_weights, flex_delayed_weights, model_origin, flags);

                        
                    }
                    else {
                        interfaces.models.model_render->ForcedMaterialOverride(nullptr);
                        DrawModel(ecx, results, info, bone_to_world, flex_weights, flex_delayed_weights, model_origin, flags);
                    }
                }
                if (csgo->fakematrix != nullptr && !csgo->game_rules->IsFreezeTime())
                {
                    if (!vars.visuals.interpolated_dsy) {
                        for (auto& i : csgo->fakematrix)
                        {
                            i[0][3] += model_origin.x;
                            i[1][3] += model_origin.y;
                            i[2][3] += model_origin.z;
                        }
                    }

                    matrix mat1[128];
                    if (GetSmoothMatrix(csgo->local, mat1))
                    {
                        static IMaterial* OverridedMaterial = nullptr;
                        

                        

                        switch (vars.visuals.misc_chams[desync].material)
                        {
                        case 0: OverridedMaterial = Regular; break;
                        case 1: OverridedMaterial = Flat; break;
                        case 2: OverridedMaterial = GlowFade; break;
                        case 3: OverridedMaterial = materialGlass; break;
                        
                        }

                        

                        if (vars.visuals.misc_chams[desync].enable)
                        {
                            OverridedMaterial->ColorModulate(
                                vars.visuals.misc_chams[desync].clr[0],
                                vars.visuals.misc_chams[desync].clr[1], vars.visuals.misc_chams[desync].clr[2]);

                            OverridedMaterial->AlphaModulate(vars.visuals.misc_chams[desync].clr[3]);
                            OverridedMaterial->SetMaterialVarFlag(MATERIAL_VAR_IGNOREZ, false);
                            bool bFound = false;
                            IMaterialVar* pMatVar = OverridedMaterial->FindVar("$envmaptint", &bFound);
                            if (bFound)
                                pMatVar->SetVecValue(vars.visuals.misc_chams[desync].clr[0],
                                    
                                    vars.visuals.misc_chams[desync].clr[1], vars.visuals.misc_chams[desync].clr[2]);
                            

                            float backup_clr[3];
                            interfaces.render_view->GetColorModulation(backup_clr);
                            
                            interfaces.models.model_render->ForcedMaterialOverride(OverridedMaterial);
                            DrawModel(ecx, results, info, !vars.visuals.interpolated_dsy ? csgo->fakematrix : mat1, flex_weights, flex_delayed_weights, model_origin, flags);
                            interfaces.render_view->SetColorModulation(backup_clr);

                            
                        }
                    }

                    if (!vars.visuals.interpolated_dsy) {
                        for (auto& i : csgo->fakematrix)
                        {
                            i[0][3] -= model_origin.x;
                            i[1][3] -= model_origin.y;
                            i[2][3] -= model_origin.z;
                        }
                    }
                }
                if (!vars.visuals.overlap_dsy) {
                    if (vars.visuals.localchams)
                    {
                        OverridedMaterialLocal->SetMaterialVarFlag(MATERIAL_VAR_TRANSLUCENT, true);

                        
                        

                        OverridedMaterialLocal->AlphaModulate(vars.visuals.localchams_color[3]);
                        OverridedMaterialLocal->SetMaterialVarFlag(MATERIAL_VAR_IGNOREZ, false);

                        interfaces.models.model_render->ForcedMaterialOverride(OverridedMaterialLocal);
                        DrawModel(ecx, results, info, bone_to_world, flex_weights, flex_delayed_weights, model_origin, flags);

                        
                    }
                    else {
                        interfaces.models.model_render->ForcedMaterialOverride(nullptr);
                        DrawModel(ecx, results, info, bone_to_world, flex_weights, flex_delayed_weights, model_origin, flags);
                    }
                }
            }
        }
        else
            DrawModel(ecx, results, info, bone_to_world, flex_weights, flex_delayed_weights, model_origin, flags);
    }
    else if (strstr(ModelName, "arms") != nullptr)
    {
        if (csgo->local && csgo->local->isAlive() && !interfaces.input->m_fCameraInThirdPerson)
        {
            static IMaterial* OverridedMaterial = nullptr;
        

            

            switch (vars.visuals.misc_chams[arms].material)
            {
            case 0: OverridedMaterial = Regular; break;
            case 1: OverridedMaterial = Flat; break;
            case 2: OverridedMaterial = GlowFade; break;
            case 3: OverridedMaterial = materialGlass; break;
            
            }

            

            if (vars.visuals.misc_chams[arms].enable)
            {
                OverridedMaterial->ColorModulate(
                    vars.visuals.misc_chams[arms].clr[0],
                    vars.visuals.misc_chams[arms].clr[1],
                    vars.visuals.misc_chams[arms].clr[2]);
                OverridedMaterial->AlphaModulate(vars.visuals.misc_chams[arms].clr[3]);
                OverridedMaterial->SetMaterialVarFlag(MATERIAL_VAR_IGNOREZ, false);
                
                color_t col;
                bool bFound = false;
                IMaterialVar* pMatVar = OverridedMaterial->FindVar("$envmaptint", &bFound);
                if (bFound)
                    pMatVar->SetVecValue(vars.visuals.misc_chams[arms].clr[0],
                        vars.visuals.misc_chams[arms].clr[1], vars.visuals.misc_chams[arms].clr[2]);
                float backup_clr[3];
                interfaces.render_view->GetColorModulation(backup_clr);
                interfaces.models.model_render->ForcedMaterialOverride(OverridedMaterial);
                DrawModel(ecx, results, info, bone_to_world, flex_weights, flex_delayed_weights, model_origin, flags);

            

                
            }
            else
                DrawModel(ecx, results, info, bone_to_world, flex_weights, flex_delayed_weights, model_origin, flags);
        }
    }
    else if (strstr(ModelName, "v_") != nullptr)
    {
        if (csgo->local && csgo->local->isAlive() && !interfaces.input->m_fCameraInThirdPerson)
        {
            static IMaterial* OverridedMaterial = nullptr;
            

            

            switch (vars.visuals.misc_chams[weapon].material)
            {
            case 0: OverridedMaterial = Regular; break;
            case 1: OverridedMaterial = Flat; break;
            case 2: OverridedMaterial = GlowFade; break;
            case 3: OverridedMaterial = materialGlass; break;
            
            }

            

            if (vars.visuals.misc_chams[weapon].enable)
            {
                OverridedMaterial->ColorModulate(
                    vars.visuals.misc_chams[weapon].clr[0], vars.visuals.misc_chams[weapon].clr[1], vars.visuals.misc_chams[weapon].clr[2]);
                OverridedMaterial->AlphaModulate(vars.visuals.misc_chams[weapon].clr[3]);
                OverridedMaterial->SetMaterialVarFlag(MATERIAL_VAR_IGNOREZ, false);
                bool bFound = false;
                IMaterialVar* pMatVar = OverridedMaterial->FindVar("$envmaptint", &bFound);
                if (bFound)
                    pMatVar->SetVecValue(vars.visuals.misc_chams[weapon].clr[0],
                        vars.visuals.misc_chams[weapon].clr[1], vars.visuals.misc_chams[weapon].clr[2]);
                float backup_clr[3];
                interfaces.render_view->GetColorModulation(backup_clr);
                

                interfaces.models.model_render->ForcedMaterialOverride(OverridedMaterial);
                DrawModel(ecx, results, info, bone_to_world, flex_weights, flex_delayed_weights, model_origin, flags);

                
                interfaces.render_view->SetColorModulation(backup_clr);
            }
            else
                DrawModel(ecx, results, info, bone_to_world, flex_weights, flex_delayed_weights, model_origin, flags);
        }
    }
    else
        DrawModel(ecx, results, info, bone_to_world, flex_weights, flex_delayed_weights, model_origin, flags);
}
 
Сверху Снизу