From 80d9845607058a85c5250aebca1280324b811285 Mon Sep 17 00:00:00 2001 From: navewindre Date: Wed, 5 Sep 2018 23:19:33 +0200 Subject: whole bunch of shit --- internal_rewrite/Valve/dt_common.h | 6 +- internal_rewrite/Valve/dt_recv.h | 6 +- internal_rewrite/c_base_player.cpp | 173 +++++++++++++---------- internal_rewrite/lag_mgr.cpp | 8 +- internal_rewrite/lag_mgr.hpp | 5 + internal_rewrite/proxies.cpp | 5 +- internal_rewrite/ragebot.cpp | 7 +- internal_rewrite/update_clientside_animation.cpp | 56 +++++--- internal_rewrite/util.cpp | 28 +++- internal_rewrite/util.hpp | 3 +- internal_rewrite/visual_local.cpp | 1 - 11 files changed, 185 insertions(+), 113 deletions(-) diff --git a/internal_rewrite/Valve/dt_common.h b/internal_rewrite/Valve/dt_common.h index 9555056..e936587 100644 --- a/internal_rewrite/Valve/dt_common.h +++ b/internal_rewrite/Valve/dt_common.h @@ -6,6 +6,8 @@ // //=============================================================================// +#pragma warning( push, 0 ) + #ifndef DATATABLE_COMMON_H #define DATATABLE_COMMON_H @@ -223,4 +225,6 @@ inline int NumBitsForCount( int nMaxElements ) } -#endif // DATATABLE_COMMON_H \ No newline at end of file +#endif // DATATABLE_COMMON_H + +#pragma warning( pop ) \ No newline at end of file diff --git a/internal_rewrite/Valve/dt_recv.h b/internal_rewrite/Valve/dt_recv.h index b47922c..6e73bdb 100644 --- a/internal_rewrite/Valve/dt_recv.h +++ b/internal_rewrite/Valve/dt_recv.h @@ -6,6 +6,8 @@ // //=============================================================================// +#pragma warning( push, 0 ) + #ifndef DATATABLE_RECV_H #define DATATABLE_RECV_H @@ -583,4 +585,6 @@ inline T GetMethod( const void* instance, size_t index ) return reinterpret_cast( GetVTable( instance )[ index ] ); } -#endif // DATATABLE_RECV_H \ No newline at end of file +#endif // DATATABLE_RECV_H + +#pragma warning( pop ) \ No newline at end of file diff --git a/internal_rewrite/c_base_player.cpp b/internal_rewrite/c_base_player.cpp index a96a4b4..0e03518 100644 --- a/internal_rewrite/c_base_player.cpp +++ b/internal_rewrite/c_base_player.cpp @@ -388,6 +388,9 @@ bool c_base_player::can_attack( bool ignore_rapid ) { auto weapon = get_weapon( ); if( !weapon ) return false; + if( weapon->is_sniper( ) && g_cheat.m_lagmgr.has_fired( ) ) + return false; + float time = g_ctx.pred_time( ); float next_attack = m_flNextAttack( ); @@ -649,36 +652,36 @@ void c_base_player::compute_move_cycle( bool reset, bool moving ) { void c_base_player::calc_anim_velocity( bool reset ) { int idx = ce( )->GetIndex( ); - auto accelerate = [ & ]( vec3_t velocity, vec3_t direction, float speed, float accel ) { - float addspeed, accelspeed, currentspeed; - - velocity.z = 0.f; - currentspeed = velocity.dot( direction ); - - addspeed = speed - currentspeed; - - if( addspeed <= 0.f ) { - return velocity; - } - - //guess how many fucks i give, this works - accelspeed = std::min( accel * 10.f * TICK_INTERVAL( ) * std::max( speed, 250.f ), currentspeed ); - - for( size_t i{ }; i < 3; ++i ) { - velocity[ i ] += accelspeed * direction[ i ]; - } - - return velocity; - }; - - auto friction = [ & ]( vec3_t velocity ) { - static auto sv_friction = g_csgo.m_cvar( )->FindVar( xors( "sv_friction" ) ); - static auto sv_stopspeed = g_csgo.m_cvar( )->FindVar( xors( "sv_stopspeed" ) ); - - float speed = velocity.length2d( ); - if( speed < 0.1f ) - return vec3_t{ }; - + auto accelerate = [ & ]( vec3_t velocity, vec3_t direction, float speed, float accel ) { + float addspeed, accelspeed, currentspeed; + + velocity.z = 0.f; + currentspeed = velocity.dot( direction ); + + addspeed = speed - currentspeed; + + if( addspeed <= 0.f ) { + return velocity; + } + + //guess how many fucks i give, this works + accelspeed = std::min( accel * 10.f * TICK_INTERVAL( ) * std::max( speed, 250.f ), currentspeed ); + + for( size_t i{ }; i < 3; ++i ) { + velocity[ i ] += accelspeed * direction[ i ]; + } + + return velocity; + }; + + auto friction = [ & ]( vec3_t velocity ) { + static auto sv_friction = g_csgo.m_cvar( )->FindVar( xors( "sv_friction" ) ); + static auto sv_stopspeed = g_csgo.m_cvar( )->FindVar( xors( "sv_stopspeed" ) ); + + float speed = velocity.length2d( ); + if( speed < 0.1f ) + return vec3_t{ }; + float friction = sv_friction->get_float( ); float control = ( speed < sv_stopspeed->get_float( ) ) ? sv_stopspeed->get_float( ) : speed; float drop = control * friction * TICK_INTERVAL( ); @@ -690,9 +693,9 @@ void c_base_player::calc_anim_velocity( bool reset ) { if( newspeed != speed ) { newspeed /= speed; velocity *= newspeed; - } - - return velocity; + } + + return velocity; }; if( reset ) { @@ -713,33 +716,46 @@ void c_base_player::calc_anim_velocity( bool reset ) { vec3_t origin_delta = origin - sm_animdata[ idx ].m_last_origin; vec3_t velocity = origin_delta / delta; - vec3_t last_velocity = sm_animdata[ idx ].m_last_velocity; - - vec3_t anim_vel; - - if( on_ground ) { - vec3_t ang = math::vector_angles( vec3_t( ), velocity ); - - float move_yaw = math::vector_angles( velocity ).y; - float move_delta = math::vector_angles( last_velocity ).y; - move_delta -= move_yaw; - move_delta = std::remainderf( move_delta, 360.f ); - - vec3_t move_dir = math::angle_vectors( vec3_t( 0.f, move_delta, 0.f ) ) * 450.f; - - vec3_t forward, right, up; - math::angle_vectors( ang, &forward, &right, &up ); - - vec3_t wishdir; - for( size_t i{ }; i < 2; ++i ) - wishdir[ i ] = forward[ i ] * move_dir.x + right[ i ] * move_dir.y; - - anim_vel = friction( last_velocity ); - if( anim_vel.length2d( ) < 15.f ) - anim_vel = vec3_t( ); - - if( anim_vel.length2d( ) >= 0.1f && velocity.length2d( ) > last_velocity.length2d( ) ) { - anim_vel = accelerate( anim_vel, wishdir, 250.f, sv_accelerate->get_float( ) ); + vec3_t last_velocity = sm_animdata[ idx ].m_last_velocity; + + vec3_t anim_vel; + + if( on_ground ) { + vec3_t ang = math::vector_angles( vec3_t( ), velocity ); + + float move_yaw = math::vector_angles( velocity ).y; + float move_delta = math::vector_angles( last_velocity ).y; + move_delta -= move_yaw; + move_delta = std::remainderf( move_delta, 360.f ); + + vec3_t move_dir = math::angle_vectors( vec3_t( 0.f, move_delta, 0.f ) ) * 450.f; + + vec3_t forward, right, up; + math::angle_vectors( ang, &forward, &right, &up ); + + vec3_t wishdir; + for( size_t i{ }; i < 2; ++i ) + wishdir[ i ] = forward[ i ] * move_dir.x + right[ i ] * move_dir.y; + + anim_vel = friction( last_velocity ); + if( anim_vel.length2d( ) < 1.f ) + anim_vel = vec3_t( ); + + int ticks = ( int )( 0.5f + TICK_INTERVAL( ) / delta ); + vec3_t est_tick_vel = math::lerp( last_velocity, velocity, .5f ); + for( int i{ }; i < ticks; i++ ) { + if( est_tick_vel.length2d( ) < 1.f ) + break; + + est_tick_vel = friction( est_tick_vel ); + } + + //assume fakewalk + if( est_tick_vel.length2d( ) < 5.f ) + anim_vel = vec3_t( ); + + else if( anim_vel.length2d( ) >= 0.1f && velocity.length2d( ) > last_velocity.length2d( ) ) { + anim_vel = accelerate( anim_vel, wishdir, 250.f, sv_accelerate->get_float( ) ); } } else { @@ -883,8 +899,9 @@ void c_base_player::fix_animations( bool reset, bool resolver_change ) { m_AnimOverlay( ).GetElements( )[ 6 ].m_flPlaybackRate, TICK_INTERVAL( ) / ( m_flSimulationTime( ) - m_flOldSimulationTime( ) ) ); - m_AnimOverlay( ).GetElements( )[ 6 ].m_flCycle = prev_cycle + lerp_rate; - + if( !reset ) { + m_AnimOverlay( ).GetElements( )[ 6 ].m_flCycle = prev_cycle + lerp_rate; + } get_animdata( ).m_prev_flags = flags; memcpy( @@ -1000,26 +1017,26 @@ void c_base_player::get_name_safe( char* buf ) { } } -void c_base_player::set_local_view_angles( vec3_t *angle ) { - using fn = void( __thiscall * )( void *, vec3_t * ); - util::get_vfunc< fn >( this, 363 )( this, angle ); -} - -bool c_base_player::run_physics_think( int unk01 ) { +void c_base_player::set_local_view_angles( vec3_t *angle ) { + using fn = void( __thiscall * )( void *, vec3_t * ); + util::get_vfunc< fn >( this, 363 )( this, angle ); +} + +bool c_base_player::run_physics_think( int unk01 ) { static auto impl = reinterpret_cast< bool( __thiscall * )( void *, int ) >( pattern::first_code_match( g_csgo.m_chl.dll( ), xors( "55 8B EC 83 EC 10 53 56 57 8B F9 8B 87 ? ? ? ? C1 E8 16" ) ) ); - return impl( this, unk01 ); -} - -void c_base_player::pre_think( ) { - using fn = void( __thiscall * )( void * ); - util::get_vfunc< fn >( this, 309 )( this ); -} - -void c_base_player::think( ) { - using fn = void( __thiscall * )( void * ); + return impl( this, unk01 ); +} + +void c_base_player::pre_think( ) { + using fn = void( __thiscall * )( void * ); + util::get_vfunc< fn >( this, 309 )( this ); +} + +void c_base_player::think( ) { + using fn = void( __thiscall * )( void * ); util::get_vfunc< fn >( this, 137 )( this ); } diff --git a/internal_rewrite/lag_mgr.cpp b/internal_rewrite/lag_mgr.cpp index 3aff26d..17dc194 100644 --- a/internal_rewrite/lag_mgr.cpp +++ b/internal_rewrite/lag_mgr.cpp @@ -35,7 +35,8 @@ namespace features vec3_t velocity_ang = math::vector_angles( vec3_t( ), g_ctx.m_local->m_vecVelocity( ) ); vec3_t velocity_dir = math::angle_vectors( velocity_ang ); - position += velocity_dir * 15.f; + //fuck getting pulled back on peek + position += velocity_dir * 20.f; float dmg = g_cheat.m_autowall.run( ent, g_ctx.m_local, position, false ); @@ -155,10 +156,15 @@ namespace features if( *m_sendpacket ) { ++m_sent_ticks; m_held_ticks = 0; + m_has_fired = false; } else { ++m_held_ticks; m_sent_ticks = 0; + + if( ( m_cmd->m_buttons & IN_ATTACK ) && g_ctx.m_local->can_attack( ) ) { + m_has_fired = true; + } } } } \ No newline at end of file diff --git a/internal_rewrite/lag_mgr.hpp b/internal_rewrite/lag_mgr.hpp index aa22c29..4f64c24 100644 --- a/internal_rewrite/lag_mgr.hpp +++ b/internal_rewrite/lag_mgr.hpp @@ -34,6 +34,10 @@ namespace features return m_held_ticks; } + bool has_fired( ) const { + return m_has_fired; + } + int get_sent( ) const { return m_sent_ticks; } @@ -56,5 +60,6 @@ namespace features int m_sent_ticks{ }; int m_held_ticks{ }; bool m_breaking_lc{ }; + bool m_has_fired{ }; }; } \ No newline at end of file diff --git a/internal_rewrite/proxies.cpp b/internal_rewrite/proxies.cpp index a42bf87..11a12e3 100644 --- a/internal_rewrite/proxies.cpp +++ b/internal_rewrite/proxies.cpp @@ -107,8 +107,11 @@ void __cdecl hooks::simtime_proxy_fn( const CRecvProxyData* proxy_data_const, vo auto ent = ( c_base_player* )( entity ); if( ent && ent->is_valid( ) && ent->has_valid_anim( ) && ( ent->m_iTeamNum( ) != g_ctx.m_local->m_iTeamNum( ) || g_settings.rage.friendlies( ) ) && ent != g_ctx.m_local ) { + //printf( "val: %f (%d)\n", proxy_data_const->m_pRecvProp ); + //printf( "prop name: %s\n", proxy_data_const->m_pRecvProp->GetName( ) ); + if( !proxy_data_const->m_Value.m_Int ) { - return; + //return; } } diff --git a/internal_rewrite/ragebot.cpp b/internal_rewrite/ragebot.cpp index 351e525..7f844b0 100644 --- a/internal_rewrite/ragebot.cpp +++ b/internal_rewrite/ragebot.cpp @@ -416,7 +416,7 @@ namespace features vec3_t vel = g_ctx.m_local->m_vecVelocity( ); float speed = vel.length2d( ); - if( speed < 1.f ) { + if( speed < 10.f ) { g_ctx.get_last_cmd( )->m_forwardmove = 0.f; g_ctx.get_last_cmd( )->m_sidemove = 0.f; return; @@ -788,7 +788,7 @@ namespace features quick_stop( m_cmd ); if( !util::hitchance( it, aim_angle, - g_settings.rage.active->m_hitchance ) ) { + g_settings.rage.active->m_hitchance, hitbox ) ) { if( g_settings.rage.active->m_auto_stop( ) == 1 ) quick_stop( m_cmd ); @@ -858,8 +858,7 @@ namespace features } if( g_settings.rage.silent == 2 ) { - g_cheat.m_lagmgr.set_state( weapon->m_iItemDefinitionIndex( ) == WEAPON_R8REVOLVER ); - m_send_next = weapon->m_iItemDefinitionIndex( ) != WEAPON_R8REVOLVER; + g_cheat.m_lagmgr.set_state( g_cheat.m_lagmgr.get_choked( ) && !g_settings.rage.fakelag.in_attack && !m_antiaim->is_fakewalking( ) ); } if( g_settings.rage.silent == 1 && !m_antiaim->is_fakewalking( ) ) { diff --git a/internal_rewrite/update_clientside_animation.cpp b/internal_rewrite/update_clientside_animation.cpp index 009250b..46f92fa 100644 --- a/internal_rewrite/update_clientside_animation.cpp +++ b/internal_rewrite/update_clientside_animation.cpp @@ -12,7 +12,7 @@ void __fastcall hooks::update_clientside_animation( void* ecx_, void* edx_ ) { static float last_choke; static float last_update; static float last_spawntime = 0.f; - + static float last_yaw; // Arbitrary number much. if( !g_settings.rage.anti_aim || !g_ctx.m_local->is_valid( ) || std::abs( last_update - g_csgo.m_globals->m_curtime ) > TICKS_TO_TIME( 20 ) || last_spawntime != ent->m_flSpawnTime( ) ) { @@ -59,11 +59,16 @@ void __fastcall hooks::update_clientside_animation( void* ecx_, void* edx_ ) { real_angle.x = pitch; } + last_yaw = ent->get_animstate( )->m_flGoalFeetYaw; + if( last_yaw < 0.f ) + last_yaw += 360.f; + g_csgo.m_prediction( )->SetViewAngles( real_angle ); ent->get_animstate( )->update( real_angle.y, real_angle.x ); old_func( ecx_, edx_ ); memcpy( &prev_anims, &ent->get_animdata( ), sizeof( prev_anims ) ); + prev_anims.m_last_simtime = last_yaw; ent->cache_anim_data( ); } @@ -73,19 +78,35 @@ void __fastcall hooks::update_clientside_animation( void* ecx_, void* edx_ ) { } ent->restore_anim_data( true ); - float yaw = ent->get_animstate( )->m_flGoalFeetYaw; + + float lerp = std::min( last_choke, TICK_INTERVAL( ) * 2.f ); + float update_delta = last_choke; + float update_lerp = std::clamp( update_delta - lerp, 0.f, 1.f ); + if( update_delta > 0.f ) + lerp = std::clamp( lerp, 0.f, update_delta ); + + float lerp_progress = ( last_update + lerp - g_csgo.m_globals->m_curtime ) / lerp; + + float lerp_yaw = 0.f; + if( !first_update && ( ent->get_animstate( )->m_velocity > 0.1f || std::abs( last_yaw - ent->get_animstate( )->m_flGoalFeetYaw ) < 35.f ) ) { + float yaw = ent->get_animstate( )->m_flGoalFeetYaw; + if( yaw < 0.f ) + yaw += 360.f; + + if( std::abs( yaw - last_yaw ) >= 180.f ) + lerp_yaw = yaw; + else { + float jmp_yaw = math::lerp( prev_anims.m_last_simtime, yaw, update_lerp / update_delta ); + lerp_yaw = math::lerp( yaw, jmp_yaw, std::clamp( lerp_progress, 0.f, 1.f ) ); + } + } + else { + lerp_yaw = ent->get_animstate( )->m_flGoalFeetYaw; + } //interpolate EVERYTHING if( !first_update && !( ent->get_animstate( )->m_bInHitGroundAnimation && ent->get_animstate( )->m_bOnGround ) ) { for( size_t i{ }; i < 18; ++i ) { - float lerp = std::min( last_choke, TICK_INTERVAL( ) * 2.f ); - float update_delta = last_choke; - float update_lerp = std::clamp( update_delta - lerp, 0.f, 1.f ); - if( update_delta > 0.f ) - lerp = std::clamp( lerp, 0.f, update_delta ); - - float lerp_progress = ( last_update + lerp - g_csgo.m_globals->m_curtime ) / lerp; - float old_param = prev_anims.m_poseparams.at( i ); float param = ent->get_animdata( ).m_poseparams.at( i ); @@ -101,28 +122,27 @@ void __fastcall hooks::update_clientside_animation( void* ecx_, void* edx_ ) { ent->m_flPoseParameter( )[ i ] = final_param; } - float lerp = std::min( last_choke, TICK_INTERVAL( ) * 2.f ); - float update_delta = last_choke; - float update_lerp = std::clamp( update_delta - lerp, 0.f, 1.f ); - if( update_delta > 0.f ) - lerp = std::clamp( lerp, 0.f, update_delta ); - for( size_t i{ }; i < 13; ++i ) { auto old_cycle = prev_anims.m_animlayers.at( i ).m_flCycle; auto cycle = ent->get_animdata( ).m_animlayers.at( i ).m_flCycle; - float lerp_progress = ( last_update + lerp - g_csgo.m_globals->m_curtime ) / lerp; + if( old_cycle > 0.9f && cycle < 0.1f ) { + cycle += 1.f; + } float jmp_cycle = math::lerp( old_cycle, cycle, update_lerp / update_delta ); float final_cycle = math::lerp( cycle, jmp_cycle, std::clamp( lerp_progress, 0.f, 1.f ) ); + if( final_cycle > 1.f ) + final_cycle -= 1.f; + ent->m_AnimOverlay( ).GetElements( )[ i ].m_flCycle = final_cycle; } } if( !first_update ) { //*( byte* )( uintptr_t( ent ) + 0x270 ) = 0; - ent->set_abs_angles( vec3_t( 0, yaw, 0 ) ); + ent->set_abs_angles( vec3_t( 0, lerp_yaw, 0 ) ); bool backup = ent->get_animstate( )->m_bOnGround; ent->get_animstate( )->m_bOnGround = false; diff --git a/internal_rewrite/util.cpp b/internal_rewrite/util.cpp index 9bc315f..a4df63d 100644 --- a/internal_rewrite/util.cpp +++ b/internal_rewrite/util.cpp @@ -210,7 +210,7 @@ bool __vectorcall util::intersects_hitbox( vec3_t eye_pos, vec3_t end_pos, vec3_ } // Note: abuse this as much as you can to achieve the full potential it offers. -bool util::hitchance( int target, const vec3_t& angles, int percentage ) { +bool util::hitchance( int target, const vec3_t& angles, int percentage, int hitbox ) { if( g_settings.rage.compensate_spread ) return true; @@ -276,16 +276,32 @@ bool util::hitchance( int target, const vec3_t& angles, int percentage ) { if( !hdr ) return false; matrix3x4 bone_matrix[ 128 ]; - if( !ent->ce()->SetupBones( bone_matrix, 128, 0x100, g_csgo.m_globals->m_curtime ) ) { - return false; - } + memcpy( bone_matrix, + ent->m_CachedBoneData( ).GetElements( ), + ent->m_CachedBoneData( ).GetSize( ) * sizeof( matrix3x4 ) ); auto set = hdr->pHitboxSet( ent->m_nHitboxSet( ) ); if( !set ) return false; - for( int hitbox{ }; hitbox < set->numhitboxes; ++hitbox ) { + if( hitbox == -1 ) { + for( int hitbox{ }; hitbox < set->numhitboxes; ++hitbox ) { + auto box = set->pHitbox( hitbox ); + if( !box ) continue; + + auto min = math::vector_transform( box->bbmin, bone_matrix[ box->bone ] ); + auto max = math::vector_transform( box->bbmax, bone_matrix[ box->bone ] ); + auto radius = box->m_flRadius; + + if( radius == -1.f ) { + radius = min.dist_to( max ); + } + + m_hitbox_data.push_back( hitbox_data_t( min, max, radius ) ); + } + } + else { auto box = set->pHitbox( hitbox ); - if( !box ) continue; + if( !box ) return false; auto min = math::vector_transform( box->bbmin, bone_matrix[ box->bone ] ); auto max = math::vector_transform( box->bbmax, bone_matrix[ box->bone ] ); diff --git a/internal_rewrite/util.hpp b/internal_rewrite/util.hpp index 34b5f93..ba7c779 100644 --- a/internal_rewrite/util.hpp +++ b/internal_rewrite/util.hpp @@ -96,8 +96,7 @@ extern void set_random_seed( int seed ); extern vec3_t get_spread_dir( void *weapon, float inaccuracy, float spread, vec3_t angles, int seed ); extern float get_random_float( float min, float max ); extern bool __vectorcall intersects_hitbox( vec3_t eye_pos, vec3_t end_pos, vec3_t min, vec3_t max, float radius ); -extern bool hitchance( int target, const vec3_t& angles, int percentage ); -extern bool hitchance( int target, const vec3_t& angle, int percentage, int hi ); +extern bool hitchance( int target, const vec3_t& angles, int percentage, int hitbox = -1 ); extern void calculate_spread_runtime( ); extern float get_total_latency( ); diff --git a/internal_rewrite/visual_local.cpp b/internal_rewrite/visual_local.cpp index 413a35f..c455326 100644 --- a/internal_rewrite/visual_local.cpp +++ b/internal_rewrite/visual_local.cpp @@ -525,7 +525,6 @@ namespace features float yaw_delta = sin( DEG2RAD( std::abs( ( ang - local_ang ).clamp( ).y ) ) ) * dist; float delta_sqr = ( yaw_delta * yaw_delta + pitch_delta * pitch_delta ); - if( delta_sqr > max_delta_sqr ) return; vec3_t vec = math::angle_vectors( ang ); -- cgit v1.2.3