SHARE
TWEET

Untitled

a guest Oct 22nd, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "c_resolver.h"
  2. #include "../utils/math.h"
  3. #include "c_aimhelper.h"
  4. #include "c_trace_system.h"
  5. #include "c_ragebot.h"
  6. #include "../sdk/c_debug_overlay.h"
  7. #include "../sdk/c_client_entity_list.h"
  8. #include <random>
  9. #include "c_esp.h"
  10.  
  11. static std::random_device rd;
  12. static std::mt19937 rng(rd());
  13.  
  14.  
  15.  
  16. void c_resolver::resolve(c_animation_system::animation* anim)
  17. {
  18.     auto is_moving = anim->player->get_velocity().length2d() > 0.1 && anim->player->is_on_ground();
  19.  
  20.     const auto info = animation_system->get_animation_info(anim->player);
  21.  
  22.     if (!info || !anim->has_anim_state)
  23.         return;
  24.  
  25.     const auto slow_walk = anim->anim_state.feet_yaw_rate >= 0.01f && anim->anim_state.feet_yaw_rate <= 0.8f;
  26.  
  27.     if (info->brute_state == resolver_start)
  28.         info->brute_yaw = std::uniform_int_distribution<int>(0, 1)(rng) ? -130.f : 130.f;
  29.     //info->brute_yaw = std::uniform_int_distribution<int>(0, 1)(rng) ? -130.f : 130.f; // original
  30.  
  31.     if (info->brute_moving_state == resolver_moving_start)
  32.         info->moving_brute_yaw = slow_walk ? std::uniform_int_distribution<int>(0, 1) (rng) ? -150.f : 150.f : 0.f;
  33.  
  34.     if (info->brute_moving_state == resolver_moving_start_inverse)
  35.         info->moving_brute_yaw = std::uniform_int_distribution<int>(0, 1)(rng) ? -167.f : 167.f;
  36.  
  37.  
  38.  
  39.  
  40.     if (is_moving)
  41.         anim->anim_state.goal_feet_yaw = math::normalize_yaw(anim->anim_state.goal_feet_yaw + info->moving_brute_yaw); // set to 0 at start :)
  42.     else
  43.         anim->anim_state.goal_feet_yaw = math::normalize_yaw(anim->anim_state.goal_feet_yaw + info->brute_yaw);
  44. }
  45.  
  46. void c_resolver::resolve_shot(resolver::shot& shot)
  47. {
  48.     if (!config.rage.enabled || shot.manual)
  49.         return;
  50.  
  51.     const auto player = reinterpret_cast<c_cs_player*>(client_entity_list()->get_client_entity(shot.record.index));
  52.  
  53.     if (player != shot.record.player)
  54.         return;
  55.  
  56.     const auto hdr = model_info_client()->get_studio_model(shot.record.player->get_model());
  57.  
  58.     if (!hdr)
  59.         return;
  60.  
  61.     const auto info = animation_system->get_animation_info(player);
  62.  
  63.     if (!info)
  64.         return;
  65.  
  66.     const auto angle = math::calc_angle(shot.start, shot.server_info.impacts.back());
  67.     c_vector3d forward;
  68.     math::angle_vectors(angle, forward);
  69.  
  70.     const auto end = shot.server_info.impacts.back() + forward * 2000.f;
  71.     const auto spread_miss = !c_aimhelper::can_hit_hitbox(shot.start, end, &shot.record, hdr, shot.hitbox);
  72.  
  73.     if (shot.server_info.damage > 0)
  74.     {
  75.         static const auto hit_msg = __("%d in %s to %s [index: %i] [history ticks: %i] | DidShot %s, UpPitch %s, Sideways %s.");
  76.         _rt(hit, hit_msg);
  77.         char msg[255];
  78.  
  79.         switch (shot.server_info.hitgroup)
  80.         {
  81.         case hitgroup_generic:
  82.             sprintf_s(msg, hit, shot.server_info.damage, _("generic"), player->get_info().name, shot.server_info.index, shot.tickcount, shot.shotting ? _("Yes") : _("No"), shot.uppitch ? _("Yes") : _("No"), shot.sideways ? _("Yes") : _("No"));
  83.             break;
  84.         case hitgroup_head:
  85.             sprintf_s(msg, hit, shot.server_info.damage, _("head"), player->get_info().name, shot.server_info.index, shot.tickcount, shot.shotting ? _("Yes") : _("No"), shot.uppitch ? _("Yes") : _("No"), shot.sideways ? _("Yes") : _("No"));
  86.             break;
  87.         case hitgroup_chest:
  88.             sprintf_s(msg, hit, shot.server_info.damage, _("chest"), player->get_info().name, shot.server_info.index, shot.tickcount, shot.shotting ? _("Yes") : _("No"), shot.uppitch ? _("Yes") : _("No"), shot.sideways ? _("Yes") : _("No"));
  89.             break;
  90.         case hitgroup_stomach:
  91.             sprintf_s(msg, hit, shot.server_info.damage, _("stomach"), player->get_info().name, shot.server_info.index, shot.tickcount, shot.shotting ? _("Yes") : _("No"), shot.uppitch ? _("Yes") : _("No"), shot.sideways ? _("Yes") : _("No"));
  92.             break;
  93.         case hitgroup_leftarm:
  94.             sprintf_s(msg, hit, shot.server_info.damage, _("left arm"), player->get_info().name, shot.server_info.index, shot.tickcount, shot.shotting ? _("Yes") : _("No"), shot.uppitch ? _("Yes") : _("No"), shot.sideways ? _("Yes") : _("No"));
  95.             break;
  96.         case hitgroup_rightarm:
  97.             sprintf_s(msg, hit, shot.server_info.damage, _("right arm"), player->get_info().name, shot.server_info.index, shot.tickcount, shot.shotting ? _("Yes") : _("No"), shot.uppitch ? _("Yes") : _("No"), shot.sideways ? _("Yes") : _("No"));
  98.             break;
  99.         case hitgroup_leftleg:
  100.             sprintf_s(msg, hit, shot.server_info.damage, _("left leg"), player->get_info().name, shot.server_info.index, shot.tickcount, shot.shotting ? _("Yes") : _("No"), shot.uppitch ? _("Yes") : _("No"), shot.sideways ? _("Yes") : _("No"));
  101.             break;
  102.         case hitgroup_rightleg:
  103.             sprintf_s(msg, hit, shot.server_info.damage, _("right leg"), player->get_info().name, shot.server_info.index, shot.tickcount, shot.shotting ? _("Yes") : _("No"), shot.uppitch ? _("Yes") : _("No"), shot.sideways ? _("Yes") : _("No"));
  104.             break;
  105.         case hitgroup_gear:
  106.             sprintf_s(msg, hit, shot.server_info.damage, _("gear"), player->get_info().name, shot.server_info.index, shot.tickcount, shot.shotting ? _("Yes") : _("No"), shot.uppitch ? _("Yes") : _("No"), shot.sideways ? _("Yes") : _("No"));
  107.             break;
  108.         }
  109.  
  110.         logging->info(msg);
  111.     }
  112.     else if (spread_miss)
  113.     {
  114.         char msg[255];
  115.         static const auto hit_msg = __("Missed shot due to spread (config issue). Shot %s, Up %s, Sidew %s.");
  116.         _rt(hit, hit_msg);
  117.         sprintf_s(msg, hit, shot.shotting ? _("Yes") : _("No"), shot.uppitch ? _("Yes") : _("No"), shot.sideways ? _("Yes") : _("No"));
  118.  
  119.         logging->info(msg);
  120.  
  121.         //c_esp::AddShot(player, 1);
  122.         ++info->missed_due_to_spread;
  123.     }
  124.     else
  125.     {
  126.         char msg[255];
  127.         static const auto hit_msg = __("Missed shot due to resolver. Target shot %s, Up %s, Sidew %s.");
  128.         _rt(hit, hit_msg);
  129.         sprintf_s(msg, hit, shot.shotting ? _("Yes") : _("No"), shot.uppitch ? _("Yes") : _("No"), shot.sideways ? _("Yes") : _("No"));
  130.  
  131.         logging->info(msg);
  132.  
  133.         //c_esp::AddShot(player, 1);
  134.         ++info->missed_due_to_resolver;
  135.     }
  136.  
  137.     if (!shot.record.player->is_alive() || !shot.record.has_anim_state || !shot.record.player->get_anim_state() || !info)
  138.         return;
  139.  
  140.     // note old brute_yaw.
  141.     const auto old_brute_yaw = info->brute_yaw;
  142.  
  143.     // check deviation from server.
  144.     auto backup = c_animation_system::animation(shot.record.player);
  145.     shot.record.apply(player);
  146.  
  147.     const auto trace = trace_system->wall_penetration(shot.start, end, &shot.record);
  148.  
  149.     auto does_match = (trace.has_value() && trace.value().hitgroup == shot.server_info.hitgroup) || (!trace.has_value() && spread_miss);
  150.  
  151.     auto is_moving = shot.record.player->get_velocity().length2d() > 0.1f && shot.record.player->is_on_ground();
  152.  
  153.     if (info->missed_due_to_resolver >= is_moving ? 5 : 4)
  154.         info->missed_due_to_resolver = 0;
  155.     if (!does_match) {
  156.         char tekt[123];
  157.         sprintf(tekt, _("does not match!!! %d"), time_to_ticks(global_vars_base->curtime));
  158.         logging->info(tekt);
  159.     }
  160.     float flRunningSpeed = player->get_velocity().length2d() / (260 * 0.520f);
  161.     float flYawModifier = (((player->get_anim_state()->on_ground * -0.3f) - 0.2f) * flRunningSpeed) + 1.0f;
  162.     if (player->get_anim_state()->duck_amount > 0.0f)
  163.     {
  164.         float flDuckingSpeed = std::clamp(flDuckingSpeed, 0.0f, 1.0f);
  165.         flYawModifier += (player->get_anim_state()->duck_amount * flDuckingSpeed) * (0.5f - flYawModifier);
  166.     }
  167.     float flMinBodyYaw = std::fabsf((float)(uintptr_t(player->get_anim_state()) + 0x330) * flYawModifier * flYawModifier);
  168.     float flMaxBodyYaw = std::fabsf((float)(uintptr_t(player->get_anim_state()) + 0x334) * flYawModifier * flYawModifier);
  169.     bool brute_once = false;
  170.     // start brute.
  171.     if (!does_match) // this is fucking shit raxer
  172.     {
  173.         brute_once = true;
  174.         if (is_moving)
  175.         {
  176.             switch (info->missed_due_to_resolver % 3)
  177.             {
  178.             case 0:
  179.                 info->moving_brute_yaw = player->get_eye_angles().y + flMinBodyYaw;
  180.                 break;
  181.             case 1:
  182.                 info->moving_brute_yaw = player->get_eye_angles().y + 180;
  183.                 break;
  184.             case 2:
  185.                 info->moving_brute_yaw = player->get_eye_angles().y + flMaxBodyYaw;
  186.                 break;
  187.             default:
  188.                 break;
  189.             }
  190.         }
  191.         else
  192.         {
  193.             switch (info->missed_due_to_resolver % 3)
  194.             {
  195.             case 0:
  196.                 info->moving_brute_yaw = player->get_eye_angles().y + flMinBodyYaw;
  197.                 break;
  198.             case 1:
  199.                 info->moving_brute_yaw = player->get_eye_angles().y + 180;
  200.                 break;
  201.             case 2:
  202.                 info->moving_brute_yaw = player->get_eye_angles().y + flMaxBodyYaw;
  203.                 break;
  204.             default:
  205.                 break;
  206.             }
  207.         }
  208.     }
  209.     if (!brute_once && !shot.server_info.damage > 0) {
  210.         char tekt[123];
  211.         sprintf(tekt, _("damage <= 0!!! %d"), time_to_ticks(global_vars_base->curtime));
  212.         logging->info(tekt);
  213.     }
  214.  
  215.     if (!brute_once && !shot.server_info.damage > 0)
  216.     {
  217.         if (is_moving)
  218.         {
  219.             switch (info->missed_due_to_resolver % 3)
  220.             {
  221.             case 0:
  222.                 info->moving_brute_yaw = player->get_eye_angles().y + flMinBodyYaw;
  223.                 break;
  224.             case 1:
  225.                 info->moving_brute_yaw = player->get_eye_angles().y + 180;
  226.                 break;
  227.             case 2:
  228.                 info->moving_brute_yaw = player->get_eye_angles().y + flMaxBodyYaw;
  229.                 break;
  230.             default:
  231.                 break;
  232.             }
  233.         }
  234.         else
  235.         {
  236.             switch (info->missed_due_to_resolver % 3)
  237.             {
  238.             case 0:
  239.                 info->moving_brute_yaw = player->get_eye_angles().y + flMinBodyYaw;
  240.                 break;
  241.             case 1:
  242.                 info->moving_brute_yaw = player->get_eye_angles().y + 180;
  243.                 break;
  244.             case 2:
  245.                 info->moving_brute_yaw = player->get_eye_angles().y + flMaxBodyYaw;
  246.                 break;
  247.             default:
  248.                 break;
  249.             }
  250.         }
  251.     }
  252.  
  253.     // apply changes.
  254.     if (!info->frames.empty())
  255.     {
  256.         c_animation_system::animation* previous = nullptr;
  257.  
  258.         // jump back to the beginning.
  259.         *player->get_anim_state() = info->frames.back().anim_state;
  260.  
  261.         for (auto it = info->frames.rbegin(); it != info->frames.rend(); ++it)
  262.         {
  263.             auto& frame = *it;
  264.  
  265.             const auto frame_player = reinterpret_cast<c_cs_player*>(client_entity_list()->get_client_entity(frame.index));
  266.  
  267.             if (frame_player == frame.player && frame.player == player)
  268.             {
  269.                 // re-run complete animation code and repredict all animations in between!
  270.                 frame.anim_state = *player->get_anim_state();
  271.                 frame.anim_state.goal_feet_yaw = is_moving ? info->moving_brute_yaw : info->brute_yaw; //added cuz we never use movingbruteyaw 24.july
  272.  
  273.                 frame.apply(player);
  274.  
  275.                 player->get_flags() = frame.flags;
  276.                 *player->get_animation_layers() = frame.layers;
  277.                 player->get_simtime() = frame.sim_time;
  278.  
  279.                 info->update_animations(&frame, previous);
  280.  
  281.                 frame.abs_ang.y = player->get_anim_state()->goal_feet_yaw;
  282.                 frame.flags = player->get_flags();
  283.  
  284.                 *player->get_animation_layers() = frame.layers;
  285.  
  286.                 frame.build_server_bones(player);
  287.  
  288.                 previous = &frame;
  289.             }
  290.         }
  291.     }
  292. }
  293.  
  294. void c_resolver::register_shot(resolver::shot&& s)
  295. {
  296.     shots.emplace_front(std::move(s));
  297. }
  298.  
  299. void c_resolver::on_player_hurt(c_game_event* event)
  300. {
  301.     const auto attacker = event->get_int(_("attacker"));
  302.     const auto attacker_index = engine_client()->get_player_for_user_id(attacker);
  303.  
  304.     if (attacker_index != engine_client()->get_local_player())
  305.         return;
  306.  
  307.     if (shots.empty())
  308.         return;
  309.  
  310.     resolver::shot* last_confirmed = nullptr;
  311.  
  312.     for (auto it = shots.rbegin(); it != shots.rend(); it = next(it))
  313.     {
  314.         if (it->confirmed && !it->skip)
  315.         {
  316.             last_confirmed = &*it;
  317.             break;
  318.         }
  319.     }
  320.  
  321.     if (!last_confirmed)
  322.         return;
  323.  
  324.     const auto userid = event->get_int(_("userid"));
  325.     const auto index = engine_client()->get_player_for_user_id(userid);
  326.  
  327.     if (index != last_confirmed->record.index)
  328.         return;
  329.  
  330.     last_confirmed->playerhurt = true;
  331.     last_confirmed->server_info.index = index;
  332.     last_confirmed->server_info.damage = event->get_int(_("dmg_health"));
  333.     last_confirmed->server_info.hitgroup = event->get_int(_("hitgroup"));
  334. }
  335.  
  336. void c_resolver::on_bullet_impact(c_game_event* event)
  337. {
  338.     const auto userid = event->get_int(_("userid"));
  339.     const auto index = engine_client()->get_player_for_user_id(userid);
  340.  
  341.     if (index != engine_client()->get_local_player())
  342.         return;
  343.  
  344.     if (shots.empty())
  345.         return;
  346.  
  347.     resolver::shot* last_confirmed = nullptr;
  348.  
  349.     for (auto it = shots.rbegin(); it != shots.rend(); it = next(it))
  350.     {
  351.         if (it->confirmed && !it->skip)
  352.         {
  353.             last_confirmed = &*it;
  354.             break;
  355.         }
  356.     }
  357.  
  358.     if (!last_confirmed)
  359.         return;
  360.  
  361.     last_confirmed->impacted = true;
  362.  
  363.     last_confirmed->server_info.impacts.emplace_back(event->get_float(_("x")),
  364.         event->get_float(_("y")),
  365.         event->get_float(_("z")));
  366. }
  367.  
  368. void c_resolver::on_weapon_fire(c_game_event* event)
  369. {
  370.     const auto userid = event->get_int(_("userid"));
  371.     const auto index = engine_client()->get_player_for_user_id(userid);
  372.  
  373.     if (index != engine_client()->get_local_player())
  374.         return;
  375.  
  376.     if (shots.empty())
  377.         return;
  378.  
  379.     resolver::shot* last_unconfirmed = nullptr;
  380.  
  381.     for (auto it = shots.rbegin(); it != shots.rend(); it = next(it))
  382.     {
  383.         if (!it->confirmed)
  384.         {
  385.             last_unconfirmed = &*it;
  386.             break;
  387.         }
  388.  
  389.         it->skip = true;
  390.     }
  391.  
  392.     if (!last_unconfirmed)
  393.         return;
  394.  
  395.     last_unconfirmed->confirmed = true;
  396. }
  397.  
  398. void c_resolver::on_render_start()
  399. {
  400.     if (shots.empty())return;
  401.     for (auto it = shots.begin(); it != shots.end();)
  402.     {
  403.         if (it->time + 1.f < global_vars_base->curtime)
  404.             it = shots.erase(it);
  405.         else
  406.             it = next(it);
  407.     }
  408.  
  409.     for (auto it = shots.begin(); it != shots.end();)
  410.     {
  411.         if (it->confirmed && it->impacted)
  412.         {
  413.             if (!it->delayed)it->delayed = true;
  414.             else {
  415.                 resolve_shot(*it);
  416.                 c_esp::draw_local_impact(it->start, it->server_info.impacts.back());
  417.                 it = shots.erase(it);
  418.             }
  419.         }
  420.         else
  421.             it = next(it);
  422.     }
  423. }
  424.  
  425.  
  426.  
  427. // beta
  428.  
  429. void c_resolver_beta::resolve(c_animation_system::animation* anim)
  430. {
  431.     auto is_moving = anim->player->get_velocity().length2d() > 0.1 && anim->player->is_on_ground();
  432.  
  433.     const auto info = animation_system->get_animation_info(anim->player);
  434.  
  435.     if (!info || !anim->has_anim_state)
  436.         return;
  437.  
  438.     const auto slow_walk = anim->anim_state.feet_yaw_rate >= 0.01f && anim->anim_state.feet_yaw_rate <= 0.8f;
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.     if (is_moving) {
  446.         auto ang = anim->player->get_abs_angles();
  447.         anim->player->set_abs_angles(c_qangle(ang.x, anim->lby, ang.z));
  448.         anim->anim_state.goal_feet_yaw = math::normalize_yaw(anim->anim_state.goal_feet_yaw + info->moving_brute_yaw); // set to 0 at start :)
  449.     }
  450.     else
  451.         anim->anim_state.goal_feet_yaw = math::normalize_yaw(anim->anim_state.goal_feet_yaw + info->brute_yaw);
  452. }
  453.  
  454. void c_resolver_beta::resolve_shot(resolver::shot& shot)
  455. {
  456.     if (!config.rage.enabled || shot.manual)
  457.         return;
  458.  
  459.     const auto player = reinterpret_cast<c_cs_player*>(client_entity_list()->get_client_entity(shot.record.index));
  460.  
  461.     if (player != shot.record.player)
  462.         return;
  463.  
  464.     const auto hdr = model_info_client()->get_studio_model(shot.record.player->get_model());
  465.  
  466.     if (!hdr)
  467.         return;
  468.  
  469.     const auto info = animation_system->get_animation_info(player);
  470.  
  471.     if (!info)
  472.         return;
  473.  
  474.     const auto angle = math::calc_angle(shot.start, shot.server_info.impacts.back());
  475.     c_vector3d forward;
  476.     math::angle_vectors(angle, forward);
  477.  
  478.     const auto end = shot.server_info.impacts.back() + forward * 2000.f;
  479.     const auto spread_miss = !c_aimhelper::can_hit_hitbox(shot.start, end, &shot.record, hdr, shot.hitbox);
  480.  
  481.     if (player->get_info().steam_id64 == 76561198203902260)
  482.         return;
  483.  
  484.     if (shot.server_info.damage > 0)
  485.     {
  486.         static const auto hit_msg = __("-%d in %s to %s [index: %i] [history ticks: %i]");
  487.         _rt(hit, hit_msg);
  488.         char msg[255];
  489.  
  490.         switch (shot.server_info.hitgroup)
  491.         {
  492.         case hitgroup_generic:
  493.             sprintf_s(msg, hit, shot.server_info.damage, _("generic"), player->get_info().name, shot.server_info.index, shot.tickcount);
  494.             break;
  495.         case hitgroup_head:
  496.             sprintf_s(msg, hit, shot.server_info.damage, _("head"), player->get_info().name, shot.server_info.index, shot.tickcount);
  497.             break;
  498.         case hitgroup_chest:
  499.             sprintf_s(msg, hit, shot.server_info.damage, _("chest"), player->get_info().name, shot.server_info.index, shot.tickcount);
  500.             break;
  501.         case hitgroup_stomach:
  502.             sprintf_s(msg, hit, shot.server_info.damage, _("stomach"), player->get_info().name, shot.server_info.index, shot.tickcount);
  503.             break;
  504.         case hitgroup_leftarm:
  505.             sprintf_s(msg, hit, shot.server_info.damage, _("left arm"), player->get_info().name, shot.server_info.index, shot.tickcount);
  506.             break;
  507.         case hitgroup_rightarm:
  508.             sprintf_s(msg, hit, shot.server_info.damage, _("right arm"), player->get_info().name, shot.server_info.index, shot.tickcount);
  509.             break;
  510.         case hitgroup_leftleg:
  511.             sprintf_s(msg, hit, shot.server_info.damage, _("left leg"), player->get_info().name, shot.server_info.index, shot.tickcount);
  512.             break;
  513.         case hitgroup_rightleg:
  514.             sprintf_s(msg, hit, shot.server_info.damage, _("right leg"), player->get_info().name, shot.server_info.index, shot.tickcount);
  515.             break;
  516.         case hitgroup_gear:
  517.             sprintf_s(msg, hit, shot.server_info.damage, _("gear"), player->get_info().name, shot.server_info.index, shot.tickcount);
  518.             break;
  519.         }
  520.  
  521.         logging->info(msg);
  522.     }
  523.     else if (spread_miss)
  524.     {
  525.  
  526.         logging->info(_("Missed shot due to spread (config issue)"));
  527.  
  528.         //c_esp::AddShot(player, 1);
  529.         ++info->missed_due_to_spread;
  530.     }
  531.     else
  532.     {
  533.         logging->info(_("Missed shot due to resolver"));
  534.  
  535.         //c_esp::AddShot(player, 1);
  536.         ++info->missed_due_to_resolver;
  537.     }
  538.  
  539.  
  540.  
  541.  
  542.     if (!shot.record.player->is_alive() || !shot.record.has_anim_state || !shot.record.player->get_anim_state() || !info)
  543.         return;
  544.  
  545.     // note old brute_yaw.
  546.     const auto old_brute_yaw = info->brute_yaw;
  547.  
  548.     // check deviation from server.
  549.     auto backup = c_animation_system::animation(shot.record.player);
  550.     shot.record.apply(player);
  551.  
  552.     const auto trace = trace_system->wall_penetration(shot.start, end, &shot.record);
  553.  
  554.     auto does_match = (trace.has_value() && trace.value().hitgroup == shot.server_info.hitgroup) || (!trace.has_value() && spread_miss);
  555.  
  556.     auto is_moving = shot.record.player->get_velocity().length2d() > 0.1f && shot.record.player->is_on_ground();
  557.  
  558.     if (info->missed_due_to_resolver >= is_moving ? 5 : 4)
  559.         info->missed_due_to_resolver = 0;
  560.  
  561.     // start brute.
  562.     if (!does_match) // this is fucking shit raxer
  563.     {
  564.         if (is_moving)
  565.         {
  566.             switch (info->brute_moving_state)
  567.             {
  568.             case resolver_moving_start:
  569.                 info->brute_moving_state = resolver_moving_start_inverse;
  570.                 break;
  571.             case resolver_moving_start_inverse:
  572.                 info->brute_moving_state = resolver_moving_inverse;
  573.                 info->moving_brute_yaw = -info->brute_yaw;
  574.                 break;
  575.             case resolver_moving_inverse:
  576.                 info->brute_moving_state = resolver_moving_no_desync;
  577.                 info->moving_brute_yaw = 0.f;
  578.                 break;
  579.             case resolver_moving_no_desync:
  580.                 info->brute_moving_state = resolver_moving_jitter;
  581.                 info->moving_brute_yaw = std::uniform_int_distribution<int>(0, 1)(rng) ? -120.f : 120.f;
  582.                 break;
  583.             default:
  584.             case resolver_moving_jitter:
  585.                 info->brute_moving_state = resolver_moving_start;
  586.                 info->moving_brute_yaw = -info->moving_brute_yaw;
  587.                 break;
  588.             }
  589.         }
  590.         else
  591.         {
  592.             switch (info->brute_state)
  593.             {
  594.             case resolver_start:
  595.                 info->brute_state = resolver_inverse;
  596.                 info->brute_yaw = -info->brute_yaw;
  597.                 break;
  598.             case resolver_inverse:
  599.                 info->brute_state = resolver_no_desync;
  600.                 info->brute_yaw = 0.f;
  601.                 break;
  602.             case resolver_no_desync:
  603.                 info->brute_state = resolver_jitter;
  604.                 info->brute_yaw = std::uniform_int_distribution<int>(0, 1)(rng) ? -120.f : 120.f;
  605.                 break;
  606.             default:
  607.             case resolver_jitter:
  608.                 info->brute_state = resolver_start;
  609.                 info->brute_yaw = -info->brute_yaw;
  610.                 break;
  611.             }
  612.         }
  613.     }
  614.  
  615.     if (!shot.server_info.damage > 0)
  616.     {
  617.         if (is_moving)
  618.         {
  619.             switch (info->missed_due_to_resolver)
  620.             {
  621.             case resolver_moving_start:
  622.                 info->moving_brute_yaw = std::uniform_int_distribution<int>(0, 1)(rng) ? -165.f : 165.f;
  623.                 break;
  624.             case resolver_moving_start_inverse:
  625.                 info->moving_brute_yaw = -info->brute_yaw;
  626.                 break;
  627.             case resolver_moving_inverse:
  628.                 info->moving_brute_yaw = 0.f;
  629.                 break;
  630.             case resolver_moving_no_desync:
  631.                 info->moving_brute_yaw = std::uniform_int_distribution<int>(0, 1)(rng) ? -120.f : 120.f;
  632.                 break;
  633.             default:
  634.             case resolver_moving_jitter:
  635.                 info->moving_brute_yaw = -info->moving_brute_yaw;
  636.                 break;
  637.             }
  638.         }
  639.         else
  640.         {
  641.             switch (info->missed_due_to_resolver)
  642.             {
  643.             case resolver_start:
  644.                 info->brute_yaw = -info->brute_yaw;
  645.                 break;
  646.             case resolver_inverse:
  647.                 info->brute_yaw = 0.f;
  648.                 break;
  649.             case resolver_no_desync:
  650.                 info->brute_yaw = std::uniform_int_distribution<int>(0, 1)(rng) ? -120.f : 120.f;
  651.                 break;
  652.             default:
  653.             case resolver_jitter:
  654.                 info->brute_yaw = -info->brute_yaw;
  655.                 break;
  656.             }
  657.         }
  658.     }
  659.  
  660.     // apply changes.
  661.     if (!info->frames.empty())
  662.     {
  663.         c_animation_system::animation* previous = nullptr;
  664.  
  665.         // jump back to the beginning.
  666.         *player->get_anim_state() = info->frames.back().anim_state;
  667.  
  668.         for (auto it = info->frames.rbegin(); it != info->frames.rend(); ++it)
  669.         {
  670.             auto& frame = *it;
  671.  
  672.             const auto frame_player = reinterpret_cast<c_cs_player*>(client_entity_list()->get_client_entity(frame.index));
  673.  
  674.             if (frame_player == frame.player && frame.player == player)
  675.             {
  676.                 // re-run complete animation code and repredict all animations in between!
  677.                 frame.anim_state = *player->get_anim_state();
  678.                 frame.anim_state.goal_feet_yaw = info->brute_yaw;
  679.  
  680.                 frame.apply(player);
  681.  
  682.                 player->get_flags() = frame.flags;
  683.                 *player->get_animation_layers() = frame.layers;
  684.                 player->get_simtime() = frame.sim_time;
  685.  
  686.                 info->update_animations(&frame, previous);
  687.  
  688.                 frame.abs_ang.y = player->get_anim_state()->goal_feet_yaw;
  689.                 frame.flags = player->get_flags();
  690.  
  691.                 *player->get_animation_layers() = frame.layers;
  692.  
  693.                 frame.build_server_bones(player);
  694.  
  695.                 previous = &frame;
  696.             }
  697.         }
  698.     }
  699. }
  700.  
  701. void c_resolver_beta::register_shot(resolver::shot&& s)
  702. {
  703.     shots.emplace_front(std::move(s));
  704. }
  705.  
  706. void c_resolver_beta::on_player_hurt(c_game_event* event)
  707. {
  708.     const auto attacker = event->get_int(_("attacker"));
  709.     const auto attacker_index = engine_client()->get_player_for_user_id(attacker);
  710.  
  711.     if (attacker_index != engine_client()->get_local_player())
  712.         return;
  713.  
  714.     if (shots.empty())
  715.         return;
  716.  
  717.     resolver::shot* last_confirmed = nullptr;
  718.  
  719.     for (auto it = shots.rbegin(); it != shots.rend(); it = next(it))
  720.     {
  721.         if (it->confirmed && !it->skip)
  722.         {
  723.             last_confirmed = &*it;
  724.             break;
  725.         }
  726.     }
  727.  
  728.     if (!last_confirmed)
  729.         return;
  730.  
  731.     const auto userid = event->get_int(_("userid"));
  732.     const auto index = engine_client()->get_player_for_user_id(userid);
  733.  
  734.     if (index != last_confirmed->record.index)
  735.         return;
  736.  
  737.     last_confirmed->server_info.index = index;
  738.     last_confirmed->server_info.damage = event->get_int(_("dmg_health"));
  739.     last_confirmed->server_info.hitgroup = event->get_int(_("hitgroup"));
  740. }
  741.  
  742. void c_resolver_beta::on_bullet_impact(c_game_event* event)
  743. {
  744.     const auto userid = event->get_int(_("userid"));
  745.     const auto index = engine_client()->get_player_for_user_id(userid);
  746.  
  747.     if (index != engine_client()->get_local_player())
  748.         return;
  749.  
  750.     if (shots.empty())
  751.         return;
  752.  
  753.     resolver::shot* last_confirmed = nullptr;
  754.  
  755.     for (auto it = shots.rbegin(); it != shots.rend(); it = next(it))
  756.     {
  757.         if (it->confirmed && !it->skip)
  758.         {
  759.             last_confirmed = &*it;
  760.             break;
  761.         }
  762.     }
  763.  
  764.     if (!last_confirmed)
  765.         return;
  766.  
  767.     last_confirmed->impacted = true;
  768.     last_confirmed->server_info.impacts.emplace_back(event->get_float(_("x")),
  769.         event->get_float(_("y")),
  770.         event->get_float(_("z")));
  771. }
  772.  
  773. void c_resolver_beta::on_weapon_fire(c_game_event* event)
  774. {
  775.     const auto userid = event->get_int(_("userid"));
  776.     const auto index = engine_client()->get_player_for_user_id(userid);
  777.  
  778.     if (index != engine_client()->get_local_player())
  779.         return;
  780.  
  781.     if (shots.empty())
  782.         return;
  783.  
  784.     resolver::shot* last_unconfirmed = nullptr;
  785.  
  786.     for (auto it = shots.rbegin(); it != shots.rend(); it = next(it))
  787.     {
  788.         if (!it->confirmed)
  789.         {
  790.             last_unconfirmed = &*it;
  791.             break;
  792.         }
  793.  
  794.         it->skip = true;
  795.     }
  796.  
  797.     if (!last_unconfirmed)
  798.         return;
  799.  
  800.     last_unconfirmed->confirmed = true;
  801. }
  802.  
  803. void c_resolver_beta::on_render_start()
  804. {
  805.     for (auto it = shots.begin(); it != shots.end();)
  806.     {
  807.         if (it->time + 1.f < global_vars_base->curtime)
  808.             it = shots.erase(it);
  809.         else
  810.             it = next(it);
  811.     }
  812.  
  813.     for (auto it = shots.begin(); it != shots.end();)
  814.     {
  815.         if (it->confirmed && it->impacted)
  816.         {
  817.             resolve_shot(*it);
  818.             c_esp::draw_local_impact(it->start, it->server_info.impacts.back());
  819.             it = shots.erase(it);
  820.         }
  821.         else
  822.             it = next(it);
  823.     }
  824. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top