S1L1R

Untitled

Aug 24th, 2020 (edited)
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 13.11 KB | None | 0 0
  1. #include "../../cheat.h"
  2. #include "../../framework/config.h"
  3.  
  4. bool c_coloredmodels::work(c_entity* ent, void* a, void* b, c_drawmodelstate c, c_modelrenderinfo d, c_matrix3x4* e) {
  5.     if (!csgo->local_player) return false;
  6.  
  7.     obj = a; arg_2 = b; state = c; render_info = d;
  8.     if (ent == csgo->local_player)
  9.         bones = e;
  10.     else
  11.         bones = csgo->e_render_bones;
  12.  
  13.     if (!glow_enemy)
  14.         glow_enemy = csgo->materialsystem->find_material(str("csgo_shaded_glow_walls"), str("Model textures"));
  15.     if (!glow_team)
  16.         glow_team = csgo->materialsystem->find_material(str("csgo_shaded_glow_walls"), str("Model textures"));
  17.     if (!glow_self)
  18.         glow_self = csgo->materialsystem->find_material(str("csgo_shaded_glow_normal"), str("Model textures"));
  19.  
  20.     if (type != config->i.vis_cm_type) {
  21.         type = config->i.vis_cm_type;
  22.  
  23.         if (type == 0) {
  24.             open = csgo->materialsystem->find_material(str("csgo_default_normal"), str("Model textures"));
  25.             cover = csgo->materialsystem->find_material(str("csgo_default_walls"), str("Model textures"));
  26.         }
  27.  
  28.         if (type == 1) {
  29.             open = csgo->materialsystem->find_material(str("csgo_flat_normal"), str("Model textures"));
  30.             cover = csgo->materialsystem->find_material(str("csgo_flat_walls"), str("Model textures"));
  31.         }
  32.  
  33.         if (type == 2) {
  34.             open = csgo->materialsystem->find_material(str("csgo_reflective_normal"), str("Model textures"));
  35.             cover = csgo->materialsystem->find_material(str("csgo_reflective_walls"), str("Model textures"));
  36.         }
  37.  
  38.         if (type == 3) {
  39.             open = csgo->materialsystem->find_material(str("csgo_celshaded_normal"), str("Model textures"));
  40.             cover = csgo->materialsystem->find_material(str("csgo_celshaded_walls"), str("Model textures"));
  41.         }
  42.     }
  43.  
  44.     if (backtrack_type != config->i.vis_cm_backtrack) {
  45.         backtrack_type = config->i.vis_cm_backtrack;
  46.  
  47.         if (backtrack_type == 0)
  48.             backtrack_cover = csgo->materialsystem->find_material(str("csgo_default_walls"), str("Model textures"));
  49.         if (backtrack_type == 1)
  50.             backtrack_cover = csgo->materialsystem->find_material(str("csgo_flat_walls"), str("Model textures"));
  51.         if (backtrack_type == 2)
  52.             backtrack_cover = csgo->materialsystem->find_material(str("csgo_reflective_walls"), str("Model textures"));
  53.         if (backtrack_type == 3)
  54.             backtrack_cover = csgo->materialsystem->find_material(str("csgo_celshaded_walls"), str("Model textures"));
  55.     }
  56.  
  57.     if (team_type != config->i.vis_cm_team_type) {
  58.         team_type = config->i.vis_cm_team_type;
  59.  
  60.         if (team_type == 0) {
  61.             team_open = csgo->materialsystem->find_material(str("csgo_default_normal"), str("Model textures"));
  62.             team_cover = csgo->materialsystem->find_material(str("csgo_default_walls"), str("Model textures"));
  63.         }
  64.  
  65.         if (team_type == 1) {
  66.             team_open = csgo->materialsystem->find_material(str("csgo_flat_normal"), str("Model textures"));
  67.             team_cover = csgo->materialsystem->find_material(str("csgo_flat_walls"), str("Model textures"));
  68.         }
  69.  
  70.         if (team_type == 2) {
  71.             team_open = csgo->materialsystem->find_material(str("csgo_reflective_normal"), str("Model textures"));
  72.             team_cover = csgo->materialsystem->find_material(str("csgo_reflective_walls"), str("Model textures"));
  73.         }
  74.  
  75.         if (team_type == 3) {
  76.             team_open = csgo->materialsystem->find_material(str("csgo_celshaded_normal"), str("Model textures"));
  77.             team_cover = csgo->materialsystem->find_material(str("csgo_celshaded_walls"), str("Model textures"));
  78.         }
  79.     }
  80.  
  81.     if (fake_type != config->i.vis_cm_fake_type) {
  82.         fake_type = config->i.vis_cm_fake_type;
  83.  
  84.         if (fake_type == 0)
  85.             fake_cover = csgo->materialsystem->find_material(str("csgo_default_walls"), str("Model textures"));
  86.         if (fake_type == 1)
  87.             fake_cover = csgo->materialsystem->find_material(str("csgo_flat_walls"), str("Model textures"));
  88.         if (fake_type == 2)
  89.             fake_cover = csgo->materialsystem->find_material(str("csgo_reflective_walls"), str("Model textures"));
  90.         if (fake_type == 3) {
  91.             fake_cover = csgo->materialsystem->find_material(str("models/inventory_items/dogtags/dogtags_outline"),
  92.                                                              str("Model textures"));
  93.             fake_cover->set_flag(MATERIAL_VAR_IGNOREZ, true);
  94.         }
  95.         if (fake_type == 4)
  96.             fake_cover = csgo->materialsystem->find_material(str("csgo_celshaded_walls"), str("Model textures"));
  97.  
  98.         if (fake_type == 5)
  99.             fake_cover = csgo->materialsystem->find_material(str("glowOverlay"), str("Model textures"));
  100.     }
  101.  
  102.     if (self_type != config->i.vis_cm_self_type) {
  103.         self_type = config->i.vis_cm_self_type;
  104.  
  105.         if (self_type == 0)
  106.             self_open = csgo->materialsystem->find_material(str("csgo_default_normal"), str("Model textures"));
  107.         if (self_type == 1)
  108.             self_open = csgo->materialsystem->find_material(str("csgo_flat_normal"), str("Model textures"));
  109.         if (self_type == 2)
  110.             self_open = csgo->materialsystem->find_material(str("csgo_reflective_normal"), str("Model textures"));
  111.         if (self_type == 3)
  112.             self_open = csgo->materialsystem->find_material(str("csgo_celshaded_normal"), str("Model textures"));
  113.         if (self_type == 4)
  114.             self_open = csgo->materialsystem->find_material(str("glowOverlay"), str("Model textures"));
  115.     }
  116.  
  117.     if (ent->is_player())
  118.         return process_player((c_player*)ent, e);
  119.  
  120.     return false;
  121. }
  122.  
  123. bool c_coloredmodels::process_player(c_player* p, c_matrix3x4* bone_out_world) {
  124.     auto changed = false;
  125.  
  126.     if (p->index() == csgo->local_player->index()) {
  127.         auto as = p->get_anim_state();
  128.         if (config->b.vis_cm_fake && as && !config->b.vis_cm_fake_overlayed && !(keymanager->check(config->i.aa_fakeduck, config->i.aa_fakeduck_style))) {
  129.             csgo->renderview->set_blend(!p->is_scoped() ? config->c.fake[3] : std::clamp(config->c.fake[3], 0.f, 0.5f));
  130.             csgo->renderview->set_color_modulation(config->c.fake);
  131.             if (fake_type == 5) {
  132.                 auto found1 = false;
  133.                 auto var1 = fake_cover->find_var(str("$envmaptint"), &found1);
  134.                 if (found1 && var1)
  135.                     var1->set_vec(config->c.fake, 3);
  136.             }
  137.  
  138.             c_matrix3x4 nb[128];
  139.             memcpy(nb, csgo->body_bones, sizeof(c_matrix3x4) * 128);
  140.  
  141.             if (config->b.vis_cm_nolagpos)
  142.                 utils->reposition_matrix(nb, csgo->sentpos, p->get_abs_origin());
  143.  
  144.             csgo->modelrender->forced_material_override(fake_cover);
  145.             oDrawModelExecute(obj, arg_2, state, render_info, nb);
  146.             csgo->modelrender->forced_material_override(0);
  147.         }
  148.  
  149.         if (config->b.vis_cm_self) {
  150.             csgo->renderview->set_blend(!p->is_scoped() ? config->c.self[3] : std::clamp(config->c.self[3], 0.f, 0.5f));
  151.             csgo->renderview->set_color_modulation(config->c.self);
  152.  
  153.             if (self_type == 4) {
  154.                 auto found1 = false;
  155.                 auto var1 = self_open->find_var(str("$envmaptint"), &found1);
  156.                 if (found1 && var1)
  157.                     var1->set_vec(config->c.self, 3);
  158.             }
  159.  
  160.             csgo->modelrender->forced_material_override(self_open);
  161.             oDrawModelExecute(obj, arg_2, state, render_info, bones);
  162.             csgo->modelrender->forced_material_override(0);
  163.  
  164.  
  165.             changed = true;
  166.         }
  167.  
  168.         if (config->i.vis_glow_self == 2 && !p->is_scoped()) {
  169.             if (!changed)
  170.                 oDrawModelExecute(obj, arg_2, state, render_info, bones);
  171.  
  172.             auto found = false;
  173.             auto var = glow_self->find_var(str("$envmaptint"), &found);
  174.             if (found && var)
  175.                var->set_vec(config->c.glow_self, 3);
  176.  
  177.             csgo->renderview->set_blend(config->c.glow_self[3]);
  178.             csgo->renderview->set_color_modulation(config->c.glow_self);
  179.  
  180.             csgo->modelrender->forced_material_override(glow_self);
  181.             oDrawModelExecute(obj, arg_2, state, render_info, bones);
  182.             csgo->modelrender->forced_material_override(0);
  183.  
  184.             changed = true;
  185.         }
  186.  
  187.         if (config->b.vis_cm_fake && as && config->b.vis_cm_fake_overlayed && !(keymanager->check(config->i.aa_fakeduck, config->i.aa_fakeduck_style))) {
  188.             csgo->renderview->set_blend(!p->is_scoped() ? config->c.fake[3] : std::clamp(config->c.fake[3], 0.f, 0.5f));
  189.             csgo->renderview->set_color_modulation(config->c.fake);
  190.             if (fake_type == 5) {
  191.                 auto found2 = false;
  192.                 auto var2 = fake_cover->find_var(str("$envmaptint"), &found2);
  193.                 if (found2 && var2)
  194.                     var2->set_vec(config->c.fake, 3);
  195.             }
  196.             c_matrix3x4 nb[128];
  197.             memcpy(nb, csgo->body_bones, sizeof(c_matrix3x4) * 128);
  198.  
  199.             if (config->b.vis_cm_nolagpos)
  200.                 utils->reposition_matrix(nb, csgo->sentpos, p->get_abs_origin());
  201.  
  202.             csgo->modelrender->forced_material_override(fake_cover);
  203.             oDrawModelExecute(obj, arg_2, state, render_info, nb);
  204.             csgo->modelrender->forced_material_override(0);
  205.         }
  206.  
  207.         csgo->renderview->set_blend(p->is_scoped() ? 0.5f : 1.f);
  208.         csgo->renderview->set_color_modulation(new float[3] {1, 1, 1});
  209.  
  210.         return changed;
  211.     }
  212.     else {
  213.         if (p->team() == csgo->local_player->team()) {         
  214.             if (config->b.vis_cm_team) {
  215.                 csgo->renderview->set_blend(csgo->goes_thru[p->index()] ? 0.25f : config->c.cm_team[3]);
  216.                 csgo->renderview->set_color_modulation(config->c.cm_team);
  217.  
  218.                 csgo->modelrender->forced_material_override(team_cover);
  219.                 oDrawModelExecute(obj, arg_2, state, render_info, bone_out_world);
  220.                 csgo->modelrender->forced_material_override(team_open);
  221.                 oDrawModelExecute(obj, arg_2, state, render_info, bone_out_world);
  222.                 csgo->modelrender->forced_material_override(0);
  223.  
  224.                 changed = true;
  225.             }
  226.  
  227.             if (config->i.vis_glow_team == 2) {
  228.                 if (!changed)
  229.                     oDrawModelExecute(obj, arg_2, state, render_info, bone_out_world);
  230.  
  231.                 auto found = false;
  232.                 auto var = glow_team->find_var(str("$envmaptint"), &found);
  233.                 if (found && var)
  234.                     var->set_vec(config->c.glow_team, 3);
  235.  
  236.                 csgo->renderview->set_blend(csgo->goes_thru[p->index()] ? 0.25f : config->c.glow_team[3]);
  237.                 csgo->renderview->set_color_modulation(config->c.glow_team);
  238.  
  239.                 csgo->modelrender->forced_material_override(glow_team);
  240.                 oDrawModelExecute(obj, arg_2, state, render_info, bone_out_world);
  241.                 csgo->modelrender->forced_material_override(0);
  242.  
  243.                 changed = true;
  244.             }
  245.  
  246.             return changed;
  247.         }
  248.         else {
  249.             auto v = features->lc->get(p);
  250.             if (config->b.vis_cm_backtrack && !v.empty()) {
  251.                 csgo->renderview->set_blend(config->c.cm_backtrack[3]);
  252.                 csgo->renderview->set_color_modulation(config->c.cm_backtrack);
  253.  
  254.                 csgo->modelrender->forced_material_override(backtrack_cover);
  255.                 oDrawModelExecute(obj, arg_2, state, render_info, v.front().bones);
  256.                 csgo->modelrender->forced_material_override(0);
  257.             }
  258.  
  259.             if (config->b.vis_cm_players_xqz) {
  260.                 csgo->renderview->set_blend(config->c.cm_players_xqz[3]);
  261.                 csgo->renderview->set_color_modulation(config->c.cm_players_xqz);
  262.  
  263.                 csgo->modelrender->forced_material_override(cover);
  264.                 oDrawModelExecute(obj, arg_2, state, render_info, bone_out_world);
  265.                 csgo->modelrender->forced_material_override(0);
  266.  
  267.                 changed = true;
  268.             }
  269.  
  270.             if (config->b.vis_cm_players) {
  271.                 csgo->renderview->set_blend(config->c.cm_players[3]);
  272.                 csgo->renderview->set_color_modulation(config->c.cm_players);
  273.  
  274.                 csgo->modelrender->forced_material_override(open);
  275.                 oDrawModelExecute(obj, arg_2, state, render_info, bone_out_world);
  276.                 csgo->modelrender->forced_material_override(0);
  277.  
  278.                 changed = true;
  279.             }
  280.  
  281.             if (config->i.vis_glow == 2) {
  282.                 if (!changed)
  283.                     oDrawModelExecute(obj, arg_2, state, render_info, bone_out_world);
  284.  
  285.                 auto found = false;
  286.                 auto var = glow_enemy->find_var(str("$envmaptint"), &found);
  287.                 if (found && var)
  288.                     var->set_vec(config->c.glow, 3);
  289.  
  290.                 csgo->renderview->set_blend(config->c.glow[3]);
  291.                 csgo->renderview->set_color_modulation(config->c.glow);
  292.  
  293.                 csgo->modelrender->forced_material_override(glow_enemy);
  294.                 oDrawModelExecute(obj, arg_2, state, render_info, bone_out_world);
  295.                 csgo->modelrender->forced_material_override(0);
  296.  
  297.                 changed = true;
  298.             }
  299.  
  300.             if (!changed) {
  301.                 csgo->renderview->set_blend(1.f);
  302.                 csgo->renderview->set_color_modulation(new float[3] { 1.f, 1.f, 1.f });
  303.  
  304.                 oDrawModelExecute(obj, arg_2, state, render_info, bone_out_world);
  305.             }
  306.  
  307.             return true;
  308.         }
  309.     }
  310. }
Add Comment
Please, Sign In to add comment