Jump to content

[CODE][HL2] Materials


Syran0

Recommended Posts

//check
bool we_are_ingame            = false;
bool is_the_world_edited    = false;

//storage
std::vector<IMaterial*> m_vec_hands; 
std::vector<IMaterial*> m_vec_Map_Textures; 
std::vector<IMaterial*> m_vec_Objects_Textures; 
std::vector<IMaterial*> m_vec_UseLess_Textures; 
std::vector<IMaterial*> m_vec_players_materials; 

//yep
void Add_To_List(char const* pMaterialName,const char*pTextureGroupName,IMaterial* pTemp )
{
    if ( plugin_game_interface::m_pEngine->IsInGame() )
    {
        we_are_ingame = true;            
    } 
    else
    {
        if ( we_are_ingame )
        {
            m_vec_Map_Textures.clear(); 
            m_vec_Objects_Textures.clear(); 
            m_vec_UseLess_Textures.clear(); 
            m_vec_players_materials.clear();
            m_vec_hands.clear();
            we_are_ingame = false; 
        }
        if(!strcmp(pTextureGroupName, "Lightmaps")||
            !strcmp(pTextureGroupName, "Particle textures")||
            !strcmp(pTextureGroupName, "Decal textures")||        
            !strcmp(pTextureGroupName, "CubeMap textures")||
            !strcmp(pTextureGroupName, "Dynamic Indices")||
            !strcmp(pTextureGroupName, "Dynamic Verts")||
            !strcmp(pTextureGroupName, "World Verts")||
            !strcmp(pTextureGroupName, "Lighting Verts"))
        {
            m_vec_UseLess_Textures.push_back( pTemp );
        }
        else if(!strcmp(pTextureGroupName, "World textures"))
        {
            m_vec_Map_Textures.push_back( pTemp );

            if (strstr(pMaterialName,"wood")||
                strstr(pMaterialName,"door")||
                strstr(pMaterialName,"gate")||
                strstr(pMaterialName,"box"))
            {
                m_vec_Objects_Textures.push_back( pTemp ); 
            }
        }
        else if (strstr(pMaterialName,"player" )||
            strstr(pMaterialName,"weapon" )||
            strstr(pMaterialName,"hostage" ) )
        {
            m_vec_players_materials.push_back( pTemp );
        }
        else if (strstr(pMaterialName,"hands"))
        {
            m_vec_hands.push_back( pTemp );
        }
        else
            return;
    }
}

void Ok_We_Make_The_List( void )
{
    //thx for this way :D
    int size    = plugin_game_interface::m_pMaterialSystem->GetNumMaterials();
    int list    = plugin_game_interface::m_pMaterialSystem->FirstMaterial();
    while ( ++list != size ) 
    {
        IMaterial* used_list = plugin_game_interface::m_pMaterialSystem->GetMaterial(list);
        Add_To_List(
            used_list->GetName(),
            used_list->GetTextureGroupName(),
            used_list);
    };
}

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//ok now edit the stuff
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
void reset_map_texture_to_default()
{
    if ( is_the_world_edited )
    {
        for (int i = 0; i < m_vec_Map_Textures.size(); i++)//set solid
        {
            m_vec_Map_Textures[i]->AlphaModulate( 1.0 ); 
            m_vec_Map_Textures[i]->SetMaterialVarFlag( MATERIAL_VAR_WIREFRAME,false );
        }
        for (int i = 0; i < m_vec_Objects_Textures.size(); i++)
        {    
            m_vec_Objects_Textures[i]->AlphaModulate( 1.0 );
        }
        is_the_world_edited = false;
    }
}

void make_the_map_transparent()
{
    if ( m_pCvars->whmode.GetBool() )
    {
        if ( m_pCvars->whmode.Getint() == 1 )
        {
            if ( is_the_world_edited )
            {
                reset_map_texture_to_default();
            }
            if ( !is_the_world_edited )
            {
                for (int i = 0; i < m_vec_Objects_Textures.size(); i++)
                {    
                    m_vec_Objects_Textures[i]->AlphaModulate( m_pCvars->wallhack.Getfloat() );
                }
                is_the_world_edited = true;
            }
        }
        if ( m_pCvars->whmode.Getint() == 2 )
        {
            if ( is_the_world_edited )
            {
                reset_map_texture_to_default();
            }
            if ( !is_the_world_edited )
            {
                for (int i = 0; i < m_vec_Map_Textures.size(); i++)
                    m_vec_Map_Textures[i]->AlphaModulate( m_pCvars->wallhack.Getfloat() ); 

                is_the_world_edited = true;
            }
        }
        if ( m_pCvars->whmode.Getint() == 3 )
        {  
            if ( is_the_world_edited )
            {
                reset_map_texture_to_default();
            }
            if ( !is_the_world_edited )
            {
                for (int i = 0; i < m_vec_Map_Textures.size(); i++)
                    m_vec_Map_Textures[i]->SetMaterialVarFlag( MATERIAL_VAR_WIREFRAME,true ); 

                is_the_world_edited = true;
            }
        }
    }     
        else
         reset_map_texture_to_default();
}

void make_the_map_fullbright()
{
    static bool fullbright = false;
    if ( m_pCvars->vis_fullbright.GetBool() )
    {
        if ( is_the_world_edited )
        {
            reset_map_texture_to_default();
        }
        if (!fullbright)
        {   
            for (int i = 0; i < m_vec_Map_Textures.size(); i++)
            {
                m_vec_Map_Textures[i]->SetMaterialVarFlag( MATERIAL_VAR_SELFILLUM,true );
            }
            fullbright = true; 
        }
    }
    else//set normal
    {
        if (fullbright)
        {  
            for (int i = 0; i < m_vec_Map_Textures.size(); i++)
            {
                m_vec_Map_Textures[i]->SetMaterialVarFlag( MATERIAL_VAR_SELFILLUM,false );
            }
            fullbright = false;
        }
    }
}

void make_player_and_weapon_xqz()
{
    static bool xqz = false;
    if( m_pCvars->vis_modelhack.GetBool() )//Aequitas
    {
        if (!xqz)
        {
            for( int i = 0; i < m_vec_players_materials.size(); i++ )
            {       
                m_vec_players_materials[i]->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, true ); 
                m_vec_players_materials[i]->SetMaterialVarFlag( MATERIAL_VAR_ZNEARER, true ); 
                m_vec_players_materials[i]->SetMaterialVarFlag( MATERIAL_VAR_FLAT, true );
            }
            xqz = true;
        }
    }
    else
    {   
        if (xqz)
        {  
            for( int i = 0; i < m_vec_players_materials.size(); i++ )
            {                     
                m_vec_players_materials[i]->SetMaterialVarFlag( MATERIAL_VAR_IGNOREZ, false ); 
                m_vec_players_materials[i]->SetMaterialVarFlag( MATERIAL_VAR_ZNEARER, false ); 
                m_vec_players_materials[i]->SetMaterialVarFlag( MATERIAL_VAR_FLAT, false );
            }
            xqz = false;
        }
    }
}

void make_player_and_weapon_wireframe()
{
    static bool wire = false;
    if( m_pCvars->vis_wireframe.GetBool() )//Aequitas 
    {
        if (!wire )
        {
            for( int i = 0; i < m_vec_players_materials.size(); i++ )
                m_vec_players_materials[i]->SetMaterialVarFlag( MATERIAL_VAR_WIREFRAME, true );
            wire = true;
        }
    }
    else                                                               
    {
        if (wire)
        {            
            for( int i = 0; i < m_vec_players_materials.size(); i++ )
                m_vec_players_materials[i]->SetMaterialVarFlag( MATERIAL_VAR_WIREFRAME, false );
            wire = false;
        }
    }
}

void make_player_and_weapon_invisible()
{
    static bool hidden = false;
    if( m_pCvars->vis_hide_model.GetBool() )//Aequitas 
    {
        if (!hidden )
        {
            for( int i = 0; i < m_vec_players_materials.size(); i++ )
                m_vec_players_materials[i]->SetMaterialVarFlag( MATERIAL_VAR_NO_DRAW, true );
            hidden = true;
        }
    }
    else                                                               
    {
        if (hidden)
        {            
            for( int i = 0; i < m_vec_players_materials.size(); i++ )
                m_vec_players_materials[i]->SetMaterialVarFlag( MATERIAL_VAR_NO_DRAW, false );
            hidden = false;
        }
    }
}

void make_your_hands_hidden()
{
    static bool no_hands = false;    
    if( m_pCvars->vis_hide_hands.GetBool() )//Aequitas 
    {
        if (!no_hands )
        {
            for( int i = 0; i < m_vec_hands.size(); i++ )
                m_vec_hands[i]->SetMaterialVarFlag( MATERIAL_VAR_NO_DRAW, true );
            no_hands = true;
        }
    }
    else                                                               
    {
        if (no_hands)
        {            
            for( int i = 0; i < m_vec_hands.size(); i++ )
                m_vec_hands[i]->SetMaterialVarFlag( MATERIAL_VAR_NO_DRAW, false );
            no_hands = false;
        }
    }
}

void remove_useless_texture()
{
    static bool removed = false;
    if ( m_pCvars->vis_fpsboost.GetBool() )
    {
        if (!removed)
        {   
            for (int i = 0; i < m_vec_UseLess_Textures.size(); i++)
            {
                m_vec_UseLess_Textures[i]->SetMaterialVarFlag( MATERIAL_VAR_NO_DRAW,true );
            }
            removed = true; 
        }
    }
    else//set normal
    {
        if (removed)
        {  
            for (int i = 0; i < m_vec_UseLess_Textures.size(); i++)
            {
                m_vec_UseLess_Textures[i]->SetMaterialVarFlag( MATERIAL_VAR_NO_DRAW,false );
            }
            removed = false;
        }
    }
}

void call_me_in_your_esp_or_somewhere_else()
{
    Ok_We_Make_The_List();
    //gogogo
    make_the_map_transparent();
    make_the_map_fullbright();
    make_player_and_weapon_xqz();
    make_player_and_weapon_wireframe();
    make_player_and_weapon_invisible();
    make_your_hands_hidden();
    remove_useless_texture();
}

 

i5zvxd.jpg

 

ka0s ; P47R!CK ; PizzaPan ; v3n0m4
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...