From c4e18b4e500dc603fb7546b7bc9bc574fb09e0a8 Mon Sep 17 00:00:00 2001 From: navewindre Date: Thu, 30 Aug 2018 15:32:54 +0200 Subject: epic hitchance --- internal_rewrite/context.hpp | 2 ++ internal_rewrite/factory.hpp | 2 +- internal_rewrite/prediction.cpp | 19 +++++++++++++++++++ internal_rewrite/ragebot.cpp | 9 +++++---- internal_rewrite/util.cpp | 10 ++++------ 5 files changed, 31 insertions(+), 11 deletions(-) (limited to 'internal_rewrite') diff --git a/internal_rewrite/context.hpp b/internal_rewrite/context.hpp index c813aba..827a95a 100644 --- a/internal_rewrite/context.hpp +++ b/internal_rewrite/context.hpp @@ -55,6 +55,8 @@ public: bool m_drawing_postscreenspace{ }; bool m_has_incremented_shots{ }; bool m_drawing_screneend{ }; + float m_weapon_spread{ }; + float m_weapon_inaccuracy{ }; bool m_has_fired_this_frame{ }; diff --git a/internal_rewrite/factory.hpp b/internal_rewrite/factory.hpp index 9946f1b..50cbf60 100644 --- a/internal_rewrite/factory.hpp +++ b/internal_rewrite/factory.hpp @@ -10,7 +10,7 @@ //IFACE_DLLMAIN - interfaces are passed through dllmain and below code doesnt need to be ran #ifndef _DEBUG -#define IFACE_DLLMAIN +//#define IFACE_DLLMAIN #endif #ifdef IFACE_DLLMAIN diff --git a/internal_rewrite/prediction.cpp b/internal_rewrite/prediction.cpp index 1d643de..32a30ae 100644 --- a/internal_rewrite/prediction.cpp +++ b/internal_rewrite/prediction.cpp @@ -642,6 +642,13 @@ void c_prediction::run_command( user_cmd_t *ucmd ) { *reinterpret_cast< uint32_t * >( m_prediction_player ) = uint32_t( player ); // Copy user command to m_pCurrentCommand and m_pPlayerCommand. + int backup_buttons = ucmd->m_buttons; + float backup_forwardmove = ucmd->m_forwardmove; + float backup_sidemove = ucmd->m_sidemove; + + ucmd->m_forwardmove = ucmd->m_sidemove = 0.f; + ucmd->m_buttons &= ~( IN_BACK | IN_FORWARD | IN_MOVELEFT | IN_MOVERIGHT ); + *reinterpret_cast< uint32_t * >( uint32_t( player ) + 0x3314 ) = uint32_t( ucmd ); *reinterpret_cast< uint32_t * >( uint32_t( player ) + 0x326C ) = uint32_t( ucmd ); @@ -809,6 +816,18 @@ void c_prediction::run_command( user_cmd_t *ucmd ) { // IMLAZY: // I'd rather just restore this instead of fixing it everywhere in the cheat. player->m_vecVelocity( ) = m_velocity; + + ucmd->m_forwardmove = backup_forwardmove; + ucmd->m_sidemove = backup_sidemove; + + if( auto wep = g_ctx.m_local->get_weapon( ) ) { + wep->update_accuracy_penalty( ); + g_ctx.m_weapon_inaccuracy = wep->get_inaccuracy( ); + g_ctx.m_weapon_spread = wep->get_spread( ); + } + else { + g_ctx.m_weapon_inaccuracy = g_ctx.m_weapon_spread = 0.f; + } } void c_prediction::post_run_command( ) { diff --git a/internal_rewrite/ragebot.cpp b/internal_rewrite/ragebot.cpp index 7d0f3d3..a4ecc9a 100644 --- a/internal_rewrite/ragebot.cpp +++ b/internal_rewrite/ragebot.cpp @@ -831,10 +831,8 @@ namespace features if( g_settings.rage.compensate_spread ) { int seed = m_cmd->m_random_seed; - weapon->update_accuracy_penalty( ); - - float inaccuracy = weapon->get_inaccuracy( ); - float spread = weapon->get_spread( ); + float inaccuracy = g_ctx.m_weapon_inaccuracy; + float spread = g_ctx.m_weapon_spread; util::set_random_seed( ( seed & 0xff ) + 1 ); @@ -930,6 +928,9 @@ namespace features } } + if( g_settings.rage.active->m_auto_stop || g_settings.rage.compensate_spread ) + m_cmd->m_forwardmove = m_cmd->m_sidemove = 0.f; + m_cmd->m_buttons |= IN_ATTACK; m_cmd->m_buttons &= ~IN_USE; diff --git a/internal_rewrite/util.cpp b/internal_rewrite/util.cpp index 7e07d2f..ee815c5 100644 --- a/internal_rewrite/util.cpp +++ b/internal_rewrite/util.cpp @@ -184,8 +184,8 @@ vec3_t util::get_spread_dir( void *weapon, float inaccuracy, float spread, vec3_ } // Calculate spread. - const float rand_inacc = rand_a * wpn->get_inaccuracy( ); - const float rand_spread = rand_b * wpn->get_spread( ); + const float rand_inacc = rand_a * g_ctx.m_weapon_inaccuracy; + const float rand_spread = rand_b * g_ctx.m_weapon_spread; const float spread_x = data->m_inaccuracy [ 0 ] * rand_inacc + data->m_spread [ 0 ] * rand_spread; const float spread_y = data->m_inaccuracy [ 1 ] * rand_inacc + data->m_spread [ 1 ] * rand_spread; @@ -225,10 +225,8 @@ bool util::hitchance( int target, const vec3_t& angles, int percentage ) { float length = wpn_info->range; - wep->update_accuracy_penalty( ); - - float inaccuracy = wep->get_inaccuracy( ); - float spread = wep->get_spread( ); + float inaccuracy = g_ctx.m_weapon_inaccuracy; + float spread = g_ctx.m_weapon_spread; if( g_settings.rage.active->m_spread_limit( ) ) { bool crouched = g_ctx.m_local->m_vecViewOffset( ).z < 50.f; -- cgit v1.2.3