Advertisement
8dhsdu23dswW

dsfas23fdsaafaf

Jan 1st, 2020
3,914
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "Chams.h"
  2. #include "settings.h"
  3. #include "features/features.h"
  4. #include "hooks/hooks.h"
  5. #include "Backtrack_new.h"
  6. #include <fstream>
  7.  
  8. Chams::Chams() {
  9.     std::ofstream("csgo\\materials\\simple_regular.vmt") << R"#("VertexLitGeneric"
  10. {
  11.  "$basetexture" "vgui/white_additive"
  12.  "$ignorez"      "0"
  13.  "$envmap"       ""
  14.  "$nofog"        "1"
  15.  "$model"        "1"
  16.  "$nocull"       "0"
  17.  "$selfillum"    "1"
  18.  "$halflambert"  "1"
  19.  "$znearer"      "0"
  20.  "$flat"         "1"
  21. }
  22. )#";
  23.     std::ofstream("csgo\\materials\\simple_ignorez.vmt") << R"#("VertexLitGeneric"
  24. {
  25.  "$basetexture" "vgui/white_additive"
  26.  "$ignorez"      "1"
  27.  "$envmap"       ""
  28.  "$nofog"        "1"
  29.  "$model"        "1"
  30.  "$nocull"       "0"
  31.  "$selfillum"    "1"
  32.  "$halflambert"  "1"
  33.  "$znearer"      "0"
  34.  "$flat"         "1"
  35. }
  36. )#";
  37.     std::ofstream("csgo\\materials\\simple_flat.vmt") << R"#("UnlitGeneric"
  38. {
  39.  "$basetexture" "vgui/white_additive"
  40.  "$ignorez"      "0"
  41.  "$envmap"       ""
  42.  "$nofog"        "1"
  43.  "$model"        "1"
  44.  "$nocull"       "0"
  45.  "$selfillum"    "1"
  46.  "$halflambert"  "1"
  47.  "$znearer"      "0"
  48.  "$flat"         "1"
  49. }
  50. )#";
  51.     std::ofstream("csgo\\materials\\simple_flat_ignorez.vmt") << R"#("UnlitGeneric"
  52. {
  53.  "$basetexture" "vgui/white_additive"
  54.  "$ignorez"      "1"
  55.  "$envmap"       ""
  56.  "$nofog"        "1"
  57.  "$model"        "1"
  58.  "$nocull"       "0"
  59.  "$selfillum"    "1"
  60.  "$halflambert"  "1"
  61.  "$znearer"      "0"
  62.  "$flat"         "1"
  63. }
  64. )#";
  65.  
  66.     materialRegular = g::mat_system->FindMaterial("simple_regular", TEXTURE_GROUP_MODEL);
  67.     materialRegularIgnoreZ = g::mat_system->FindMaterial("simple_ignorez", TEXTURE_GROUP_MODEL);
  68.     materialFlatIgnoreZ = g::mat_system->FindMaterial("simple_flat_ignorez", TEXTURE_GROUP_MODEL);
  69.     materialFlat = g::mat_system->FindMaterial("simple_flat", TEXTURE_GROUP_MODEL);
  70. }
  71.  
  72. Chams::~Chams() {
  73.     std::remove("csgo\\materials\\simple_regular.vmt");
  74.     std::remove("csgo\\materials\\simple_ignorez.vmt");
  75.     std::remove("csgo\\materials\\simple_flat.vmt");
  76.     std::remove("csgo\\materials\\simple_flat_ignorez.vmt");
  77. }
  78.  
  79. void Chams::OnSceneEnd()
  80. {
  81.     IF (!g::engine_client->IsInGame() || !g::engine_client->IsConnected() || !g::local_player)
  82.         RETURN;
  83.  
  84.     ChamsModes LocalChamsMode = (ChamsModes)settings::chams::localmodenew;
  85.     ChamsModes TeamChamsMode = (ChamsModes)settings::chams::teammodenew;
  86.     ChamsModes EnemyChamsMode = (ChamsModes)settings::chams::enemymodenew;
  87.  
  88.     bool LocalChams = settings::chams::localnew;
  89.     bool TeamChams = settings::chams::teamnew;
  90.     bool EnemyChams = settings::chams::enemynew;
  91.  
  92.     Color LocalColor = settings::chams::LocalColor_vis;
  93.     Color TeamColor = settings::chams::TeamColor_vis;
  94.     Color EnemyColor = settings::chams::EnemyColor_vis;
  95.  
  96.     Color LocalColorXqz = settings::chams::LocalColor_XQZ;
  97.     Color TeamColorXqz = settings::chams::TeamColor_XQZ;
  98.     Color EnemyColorXqz = settings::chams::EnemyColor_XQZ;
  99.  
  100.     FOR (INT i = 1; i < g::engine_client->GetMaxClients(); i++)
  101.     {
  102.         auto entity = static_cast<c_base_player*>(g::entity_list->GetClientEntity(i));
  103.         IF (!entity || !entity->IsPlayer() || entity->IsDormant() || !entity->IsAlive())
  104.             CONTINUE;
  105.  
  106.         IF (utils::is_line_goes_through_smoke(interfaces::local_player->GetEyePos(), entity->get_hitbox_position(entity, HITBOX_HEAD))) //GetRenderOrigin()
  107.             CONTINUE;
  108.  
  109.         /*
  110.         IF (utilities::is_behind_smoke(local_player->get_eye_pos(), entity->get_hitbox_position(entity, hitbox_head)) && config_system.item.vis_chams_smoke_check)
  111.                     CONTINUE;
  112.         */
  113.  
  114.         bool IsLocal = entity == g::local_player;
  115.         bool IsTeam = !entity->IsEnemy();
  116.  
  117.         bool normal = false;
  118.         bool flat = false;
  119.         bool wireframe = false;
  120.         bool glass = false;
  121.         bool metallic = false;
  122.         bool xqz = false;
  123.         bool metallic_xqz = false;
  124.         bool flat_xqz = false;
  125.  
  126.         ChamsModes mode = IsLocal ? LocalChamsMode : (IsTeam ? TeamChamsMode : EnemyChamsMode);
  127.  
  128.         IF (IsLocal && !LocalChams)
  129.         {
  130.             CONTINUE;
  131.         }
  132.         IF ((IsTeam && !IsLocal) && !TeamChams)
  133.         {
  134.             CONTINUE;
  135.         }
  136.         IF (!IsTeam && !EnemyChams)
  137.         {
  138.             CONTINUE;
  139.         }
  140.  
  141.        
  142.          Color clr = IsLocal ? LocalColor : (IsTeam ? TeamColor : EnemyColor);
  143.          Color clr2 = IsLocal ? LocalColorXqz : (IsTeam ? TeamColorXqz : EnemyColorXqz);
  144.                
  145.        
  146.         switch (mode)
  147.         {
  148.         case ChamsModes::NORMAL:
  149.             normal = true;
  150.             break;
  151.         case ChamsModes::FLAT:
  152.             flat = true;
  153.             break;
  154.         case ChamsModes::WIREFRAME:
  155.             wireframe = true;
  156.             break;
  157.         case ChamsModes::GLASS:
  158.             glass = true;
  159.             break;
  160.         case ChamsModes::METALLIC:
  161.             metallic = true;
  162.             break;
  163.         case ChamsModes::XQZ:
  164.             xqz = true;
  165.             break;
  166.         case ChamsModes::METALLIC_XQZ:
  167.             metallic = true;
  168.             metallic_xqz = true;
  169.             break;
  170.         case ChamsModes::FLAT_XQZ:
  171.             flat = true;
  172.             flat_xqz = true;
  173.             break;
  174.         }
  175.  
  176.         MaterialManager::Get().OverrideMaterial(xqz || metallic_xqz || flat_xqz, flat, wireframe, glass, metallic);
  177.         g::render_view->SetColorModulation(clr.r() / 255.f, clr.g() / 255.f, clr.b() / 255.f);
  178.         entity->GetClientRenderable()->DrawModel(0x1, 255);
  179.         IF (xqz || metallic_xqz || flat_xqz)
  180.         {
  181.             MaterialManager::Get().OverrideMaterial(false, flat, wireframe, glass, metallic);
  182.             g::render_view->SetColorModulation(clr2.r() / 255.f, clr2.g() / 255.f, clr2.b() / 255.f);
  183.             entity->GetClientRenderable()->DrawModel(0x1, 255);
  184.         }
  185.         g::mdl_render->ForcedMaterialOverride(nullptr);
  186.     }
  187.  
  188.     g::mdl_render->ForcedMaterialOverride(nullptr);
  189. }
  190.  
  191. void Chams::OverrideMaterial(bool ignoreZ, bool flat, bool wireframe, bool glass, CONST Color& rgba) {
  192.     IMaterial* material = nullptr;
  193.  
  194.     IF (flat) {
  195.         IF (ignoreZ)
  196.             material = materialFlatIgnoreZ;
  197.         ELSE
  198.             material = materialFlat;
  199.     }
  200.     ELSE {
  201.         IF (ignoreZ)
  202.             material = materialRegularIgnoreZ;
  203.         ELSE
  204.             material = materialRegular;
  205.     }
  206.  
  207.  
  208.     IF (glass) {
  209.         material = materialFlat;
  210.         material->AlphaModulate(0.45f);
  211.     }
  212.     ELSE {
  213.         material->AlphaModulate(
  214.             rgba.a() / 255.0f);
  215.     }
  216.  
  217.     material->SetMaterialVarFlag(MATERIAL_VAR_WIREFRAME, wireframe);
  218.     material->ColorModulate(
  219.         rgba.r() / 255.0f,
  220.         rgba.g() / 255.0f,
  221.         rgba.b() / 255.0f);
  222.  
  223.     g::mdl_render->ForcedMaterialOverride(material);
  224. }
  225.  
  226. void Chams::OnDrawModelExecute(void* pResults, DrawModelInfo_t* pInfo, matrix3x4_t* pBoneToWorld,
  227.     FLOAT* flpFlexWeights, FLOAT* flpFlexDelayedWeights, Vector& vrModelOrigin, INT iFlags) {
  228.     static auto fnDME = hooks::mdlrender::hook.get_original<hooks::mdlrender::draw_model_execute::DrawModelExecute>(hooks::mdlrender::draw_model_execute::index);
  229.  
  230.     IF (!pInfo->m_pClientEntity || !g::local_player)
  231.         RETURN;
  232.  
  233.     CONST auto mdl = pInfo->m_pClientEntity->GetModel();
  234.  
  235.     FLOAT hue = 266.f; //276
  236.  
  237.     IF (settings::chams::bttype == 1 || settings::chams::bttype == 2 && strstr(mdl->szName, "models/player") != nullptr) {
  238.        
  239.         auto ent = (c_base_player*)(pInfo->m_pClientEntity->GetIClientUnknown()->GetBaseEntity());
  240.            
  241.         printf("W50IEJxdmpDYlFU=Z2FXVVpzT3JLYUdkdGVqcEpzbmtKV2NwZmFKYnNKQk1MQVZhSkpCblpwYnh2Wk5XR0ZhSm9mSkp5aHB5aW55Qll0UnQzNzg1NDYxNCA9IC0xNjYxOTc3NDk7ICAgIGludCBCcXZqQ2JRVGdhV1Vac09yS2FHZHRlanBKc25rSldjcGZhSmJzSkJNTEFWYUpKQm5acGJ4dlpOV0dG=YUpvZkpKeWhweWlueUJZdFJ0NDU0NTU4MDIgPSAtODY5MjQ5NTkzOyAgICBpbnQgQnF2akNiUVRnYVdVWnNPc==kthR2R0ZWpwSnNua0pXY3BmYUpic0pCTUxBVmFKSkJuWnBieHZaTldHRmFKb2ZKSnlo=cHlpbnlCWXRSdDgxMDc3MzY2ID0gLTcwOTgxNzYzNzsgICAg==aW50IEJxdmpDYlFU=Z2FXVVpzT3JLYUdkdGVqcEpzbmtKV2NwZ==mFKYnNKQk1=MQVZhSkpCblpwYnh2Wk5XR0ZhSm9mSkp5aHB5aW55Qll0UnQ2Mzc0Mzk2OCA9IC02ODM4OTgwNDY7ICAgIGludCBCcXZqQ2JRVGdhV1Vac09yS===2FHZHRlanBKc25rSldjcGZhSmJzSkJNTEFWYUpKQm5acGJ4dlpOV0dGYUpvZkpKeWhweWlueUJZdFJ");
  242.         printf("VDDcd8o7kxPwuGxkmo6BoXfTtgJlm5EgRsyzz7C2pw7M1FKrvY5AfXnh4oA8Ay1eQV11X3+D/N3wy4KC3wJC3ibM3PyCmDNwcEgiJLASRp7dEwi3viCKoiXvH5cuj67u2sG64yGxfBUrHONeqwDYpALNf86fDcq36r9scf58visR6TJS82ZpYYfrjmZEFP=rly2vEPxdJhHize");
  243.    
  244.         IF (ent && ent->IsPlayer() && ent->IsAlive()) {
  245.             CONST auto enemy = ent->m_iTeamNum() != g::local_player->m_iTeamNum();
  246.             IF (!enemy)
  247.                 RETURN;
  248.  
  249.             IF (settings::chams::bttype && g_Backtrack.data.count(ent->EntIndex()) > 0) {
  250.                 auto& data = g_Backtrack.data.AT(ent->EntIndex());
  251.                 IF (data.size() > 0) {
  252.                     IF (settings::chams::bttype == 2) {
  253.                         FOR (auto& record : data) {
  254.                             hue += 0.2f;
  255.                             IF (hue > 276.f)
  256.                                 hue = 266.f;
  257.                             OverrideMaterial(false, settings::chams::btflat, false, false, Color(settings::chams::btcolor));  //Color::FromHSB(hue, 1.0f, 1.0f)
  258.                             fnDME(g::g_studiorender, pResults, pInfo, record.boneMatrix, flpFlexWeights, flpFlexDelayedWeights, vrModelOrigin, iFlags);
  259.                         }
  260.                     }
  261.                     ELSE IF (settings::chams::bttype == 1) {
  262.                         auto& back = data.back();
  263.                         OverrideMaterial(false, settings::chams::btflat, false, false, Color(settings::chams::btcolor));
  264.                         fnDME(g::g_studiorender, pResults, pInfo, back.boneMatrix, flpFlexWeights, flpFlexDelayedWeights, vrModelOrigin, iFlags);
  265.                     }
  266.                 }
  267.             }
  268.         }
  269.     }
  270. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement