From 716be28826ac61491944490373402c39123a1d75 Mon Sep 17 00:00:00 2001 From: navewindre Date: Mon, 3 Dec 2018 22:03:34 +0100 Subject: boris is cool --- cheat/internal_rewrite/c_base_player.cpp | 22 ++++--- cheat/internal_rewrite/context.cpp | 2 +- cheat/internal_rewrite/create_move.cpp | 5 ++ cheat/internal_rewrite/emit_sound.cpp | 7 +-- cheat/internal_rewrite/extra.cpp | 4 +- cheat/internal_rewrite/proxies.cpp | 2 +- cheat/internal_rewrite/ragebot.cpp | 7 --- cheat/internal_rewrite/ragebot_lagcomp.cpp | 24 ++++++-- cheat/internal_rewrite/ragebot_resolver.cpp | 71 +++++++++++++++------- .../update_clientside_animation.cpp | 14 ++++- cheat/internal_rewrite/visual_player.cpp | 24 +++++++- 11 files changed, 125 insertions(+), 57 deletions(-) diff --git a/cheat/internal_rewrite/c_base_player.cpp b/cheat/internal_rewrite/c_base_player.cpp index 11882ea..b24e7b5 100644 --- a/cheat/internal_rewrite/c_base_player.cpp +++ b/cheat/internal_rewrite/c_base_player.cpp @@ -612,7 +612,7 @@ void c_base_player::do_ent_interpolation( bool reset ) { set_abs_origin( vec_lerp ); invalidate_bone_cache( ); - ce( )->SetupBones( anim_data->m_bones, 128, BONE_USED_BY_ANYTHING, g_csgo.m_globals->m_curtime ); + ce( )->SetupBones( nullptr, -1, BONE_USED_BY_ANYTHING, g_csgo.m_globals->m_curtime ); this->m_iMostRecentModelBoneCounter( )++; *( byte* )( uintptr_t( this ) + 0x270 ) = backup; @@ -665,7 +665,7 @@ void c_base_player::calc_anim_velocity( bool reset ) { } //guess how many fucks i give, this works - accelspeed = std::min( accel * 10.f * TICK_INTERVAL( ) * std::max( speed, 250.f ), currentspeed ); + accelspeed = std::min( accel * 10.f * TICK_INTERVAL( ) * speed, currentspeed ); for( size_t i{ }; i < 3; ++i ) { velocity[ i ] += accelspeed * direction[ i ]; @@ -741,17 +741,21 @@ void c_base_player::calc_anim_velocity( bool reset ) { if( anim_vel.length2d( ) < 1.f ) anim_vel = vec3_t( ); - int ticks = TIME_TO_TICKS( delta * 0.5f ); - vec3_t est_tick_vel = math::lerp( last_velocity, velocity, .5f ); - for( int i{ }; i < ticks + 1; i++ ) { - if( est_tick_vel.length2d( ) < 5.f ) - break; + int ticks = TIME_TO_TICKS( delta ); + vec3_t est_tick_vel = last_velocity; + + for( int i{ }; i < ticks; i++ ) { + est_tick_vel = friction( est_tick_vel ); + + if( i <= ticks / 2 ) { + accelerate( anim_vel, wishdir, m_fFlags( ) & FL_DUCKING ? 83.3333333f : 250.f, sv_accelerate->get_float( ) ); + } est_tick_vel = friction( est_tick_vel ); } if( velocity.length2d( ) > last_velocity.length2d( ) ) - anim_vel = accelerate( anim_vel, wishdir, 250.f, sv_accelerate->get_float( ) ); + anim_vel = accelerate( anim_vel, wishdir, m_fFlags( ) & FL_DUCKING ? 83.3333333f : 250.f, sv_accelerate->get_float( ) ); //assume fakewalk if( anim_vel.length2d( ) >= sm_animdata[ idx ].m_anim_velocity.length2d( ) && est_tick_vel.length2d( ) < 5.f && delta > TICK_INTERVAL( ) ) @@ -926,7 +930,7 @@ void c_base_player::fix_animations( bool reset, bool resolver_change ) { TICK_INTERVAL( ) / ( m_flSimulationTime( ) - m_flOldSimulationTime( ) ) ); if( !reset ) { - m_AnimOverlay( ).GetElements( )[ 6 ].m_flCycle = prev_cycle + lerp_rate; + //m_AnimOverlay( ).GetElements( )[ 6 ].m_flCycle = prev_cycle + lerp_rate; } get_animdata( ).m_prev_flags = flags; diff --git a/cheat/internal_rewrite/context.cpp b/cheat/internal_rewrite/context.cpp index 26af64c..cf25cab 100644 --- a/cheat/internal_rewrite/context.cpp +++ b/cheat/internal_rewrite/context.cpp @@ -108,7 +108,7 @@ void c_context::on_cmove_end( user_cmd_t* cmd ) { last_shot = g_csgo.m_globals->m_curtime; else if( auto weapon = g_ctx.m_local->get_weapon( ) ) { float fire_rate = weapon->get_wpn_info( )->cycle_time; - float tolerance = util::get_total_latency( ) * 2.f + fire_rate + TICK_INTERVAL( ); + float tolerance = util::get_total_latency( ) + fire_rate + TICK_INTERVAL( ); if( std::abs( last_shot - g_csgo.m_globals->m_curtime ) > tolerance ) { reset_shot_queue( ); last_shot = g_csgo.m_globals->m_curtime; diff --git a/cheat/internal_rewrite/create_move.cpp b/cheat/internal_rewrite/create_move.cpp index a59930e..54c393e 100644 --- a/cheat/internal_rewrite/create_move.cpp +++ b/cheat/internal_rewrite/create_move.cpp @@ -109,8 +109,13 @@ bool __fastcall hooks::create_move( void* ecx_, void* edx_, float input_sample_f cl->m_netchannel->m_nChokedPackets = 0; + int in_seq = cl->m_netchannel->m_nInSequenceNr; + + g_cheat.m_extra.add_latency( cl->m_netchannel ); send_datagram_o( cl->m_netchannel, 0, 0 ); + cl->m_netchannel->m_nInSequenceNr = in_seq; + cl->m_netchannel->m_nOutSequenceNr--; cl->m_netchannel->m_nChokedPackets = choked; } diff --git a/cheat/internal_rewrite/emit_sound.cpp b/cheat/internal_rewrite/emit_sound.cpp index f27bb4c..e087302 100644 --- a/cheat/internal_rewrite/emit_sound.cpp +++ b/cheat/internal_rewrite/emit_sound.cpp @@ -17,12 +17,7 @@ void __fastcall hooks::emit_sound( void* ecx_, void* edx_, void* filter, int ent if( g_settings.misc.no_sound && strstr( sample, xors( "weapon" ) ) ) volume = 0.f; - - // todo: fix this not being drawn - // it's not drawn cause the option isn't in menu you dumbhead - if( g_settings.visuals.sound && ( strstr( sample, xors( "player/footsteps" ) ) || strstr( sample, xors( "player/land" ) ) ) && origin ) { - g_cheat.m_visuals.store_sound( ent, *origin ); - } + //a diff --git a/cheat/internal_rewrite/extra.cpp b/cheat/internal_rewrite/extra.cpp index 6882f21..e95a840 100644 --- a/cheat/internal_rewrite/extra.cpp +++ b/cheat/internal_rewrite/extra.cpp @@ -83,12 +83,14 @@ namespace features } void c_extra::add_latency( INetChannel* channel ) { + // todo @boris: + // replace this with sharklazer's method + if ( g_ctx.m_local && g_ctx.m_local->is_valid( ) ) { auto nci = g_csgo.m_engine( )->GetNetChannelInfo( ); float in_latency = nci->GetLatency( 0 ); - //arbitrary number much float latency = 0.15f - ( in_latency + g_csgo.m_globals->m_frametime ) - TICK_INTERVAL( ); if( g_settings.misc.net_fakelag && latency > 0.f ) { diff --git a/cheat/internal_rewrite/proxies.cpp b/cheat/internal_rewrite/proxies.cpp index 287970b..7819405 100644 --- a/cheat/internal_rewrite/proxies.cpp +++ b/cheat/internal_rewrite/proxies.cpp @@ -103,7 +103,7 @@ void __cdecl hooks::last_shot_proxy_fn( const CRecvProxyData* proxy_data_const, } void __cdecl hooks::simtime_proxy_fn( const CRecvProxyData* proxy_data_const, void* entity, void* output ) { - auto old_fn = simtime_proxy.get_old_function( ); + auto old_fn = simtime_proxy.get_old_function( );; 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 ) { diff --git a/cheat/internal_rewrite/ragebot.cpp b/cheat/internal_rewrite/ragebot.cpp index 4a85078..19034df 100644 --- a/cheat/internal_rewrite/ragebot.cpp +++ b/cheat/internal_rewrite/ragebot.cpp @@ -727,9 +727,6 @@ namespace features restore = true; tick_count = new_tickcount; } - else if( g_settings.misc.net_fakelag == 4 && can_hit_without_ping( it ) ) { - m_can_fakeping = false; - } } } else { @@ -741,10 +738,6 @@ namespace features restore = true; } else { - if( g_settings.misc.net_fakelag == 4 ) { - //if( can_hit_without_ping( it ) ) - // m_can_fakeping = false; - } lag_record_t* last_simtime_record = m_lagcomp->get_newest_valid_record( it ); if( last_simtime_record ) { diff --git a/cheat/internal_rewrite/ragebot_lagcomp.cpp b/cheat/internal_rewrite/ragebot_lagcomp.cpp index 5014143..ba1cc43 100644 --- a/cheat/internal_rewrite/ragebot_lagcomp.cpp +++ b/cheat/internal_rewrite/ragebot_lagcomp.cpp @@ -208,15 +208,22 @@ namespace features float delta = ent->m_flSimulationTime( ) - ent->m_flOldSimulationTime( ); new_record.m_globaltime = g_csgo.m_globals->m_curtime; - if( g_settings.legit.enabled( ) ) - new_record.m_globaltime -= TICK_INTERVAL( ); + new_record.m_globaltime -= util::get_lerptime( ); new_record.m_validtime = 0.f; - if( ent->ce( )->SetupBones( new_record.m_matrix, 128, BONE_USED_BY_ANYTHING, 0.f ) ) { - data.push_front( new_record ); + matrix3x4 matrix[ 128 ]; + ent->ce( )->SetupBones( matrix, 128, BONE_USED_BY_ANYTHING, 0.f ); + + for( size_t i{ }; i < 128; ++i ) { + vec3_t delta = math::get_matrix_position( matrix[ i ] ) - ent->m_vecOrigin( ); + math::set_matrix_position( delta + ent->m_vecOrigin( ), matrix[ i ] ); } + memcpy( new_record.m_matrix, matrix, sizeof( matrix ) ); + + data.push_front( new_record ); + last_simtime[ i ] = ent->m_flSimulationTime( ); } @@ -258,7 +265,7 @@ namespace features auto next_record = ( it + 1 ); if( std::abs( it->m_simtime - ent->m_flSimulationTime( ) ) > TIME_TO_TICKS( 16 ) ) - break; + continue; if( !it->m_validtime ) it->m_validtime = g_csgo.m_globals->m_curtime; @@ -275,9 +282,14 @@ namespace features float curtime = g_csgo.m_globals->m_curtime; float delta = ( curtime - it->m_validtime ) / lerptime; + delta = std::clamp( delta, 0.f, 1.f ); + + //EASE OUT BY NAVEWINDRE DO NOT STEAL + if( lerptime > 0.075f ) + delta = 1 + pow( delta - 1, 3 ); vec3_t next = ( it + 1 ) == data.rend( ) ? ent->m_vecOrigin( ) : ( it + 1 )->m_origin; - vec3_t lerp = math::lerp( it->m_origin, next, std::clamp( delta, 0.f, 1.f ) ); + vec3_t lerp = math::lerp( it->m_origin, next, delta ); matrix3x4 ret[ 128 ]; diff --git a/cheat/internal_rewrite/ragebot_resolver.cpp b/cheat/internal_rewrite/ragebot_resolver.cpp index 1b29305..a5a8d50 100644 --- a/cheat/internal_rewrite/ragebot_resolver.cpp +++ b/cheat/internal_rewrite/ragebot_resolver.cpp @@ -315,7 +315,22 @@ namespace features auto hdr = g_csgo.m_model_info( )->GetStudiomodel( model ); auto set = hdr->pHitboxSet( ent->m_nHitboxSet( ) ); - if( hitbox == HITBOX_HEAD ) { + auto do_rotate = [ ]( int box ) { + switch( box ) { + case HITBOX_HEAD: + case HITBOX_LEFT_FOOT: + case HITBOX_RIGHT_FOOT: + case HITBOX_LEFT_HAND: + case HITBOX_RIGHT_HAND: + case HITBOX_LEFT_CALF: + case HITBOX_RIGHT_CALF: + return true; + + default: return false; + } + }; + + if( do_rotate( hitbox ) ) { auto box = set->pHitbox( 0 ); if( box ) { auto dist = box->bbmin.dist_to( box->bbmax ); @@ -331,7 +346,7 @@ namespace features new_shot.m_hitbox.min = max; new_shot.m_hitbox.radius = radius; new_shot.m_missed = true; - new_shot.m_hitgroup = HITGROUP_HEAD; + new_shot.m_hitgroup = util::hitbox_to_hitgroup( hitbox ); g_ctx.m_last_shot++; g_ctx.m_last_shot %= 128; @@ -366,7 +381,9 @@ namespace features } else { matrix3x4 bone_matrix[ 128 ]; - if( model && hdr && set && ent->ce( )->SetupBones( bone_matrix, 128, 0x100, g_csgo.m_globals->m_curtime ) ) { + if( model && hdr && set ) { + memcpy( bone_matrix, ent->m_CachedBoneData( ).GetElements( ), sizeof( bone_matrix ) ); + auto box = set->pHitbox( hitbox ); if( !box ) return; @@ -375,32 +392,42 @@ namespace features vec3_t shot_pos = position; vec3_t rotated_center; - vec3_t offset = position - origin; - float radius = offset.length2d( ); - float cosine = offset.x / radius; + bool is_within = false; + for( float rotation = -180.f; rotation <= 180.f; rotation += 45.f ) { + float off = ( shot_pos - origin ).length2d( ); + float deg = ent->ce( )->GetRenderAngles( ).y; - float deg = RAD2DEG( acos( cosine ) ); - if( offset.y < 0 ) deg += 360.f; + float rot = std::remainderf( deg + rotation, 360.f ); + if( rot < 0.f ) + rot += 360.f; + rotated_center.x = origin.x + cos( DEG2RAD( rot ) ) * off; + rotated_center.y = origin.y + sin( DEG2RAD( rot ) ) * off; + rotated_center.z = position.z; - float rot = ( deg - 180.f ) * ( M_PI / 180.f ); - rotated_center.x = origin.x + cos( rot ) * radius; - rotated_center.y = origin.y + sin( rot ) * radius; - rotated_center.z = position.z; + vec3_t ang = math::vector_angles( g_ctx.m_local->get_eye_pos( ), + shot_pos ); - Ray_t ray; - CTraceFilterOneEntity filter; - CGameTrace tr_center; - CGameTrace tr_rot; + vec3_t dir = math::angle_vectors( ang ); + vec3_t trace_pos = g_ctx.m_local->get_eye_pos( ) + dir * 8192.f; - filter.ent = ent; + Ray_t ray; + CTraceFilterOneEntity filter; + CGameTrace tr_center; + CGameTrace tr_rot; - ray.Init( g_ctx.m_local->get_eye_pos( ), position ); - g_csgo.m_trace( )->TraceRay( ray, MASK_SHOT, &filter, &tr_center ); + filter.ent = ent; - ray.Init( g_ctx.m_local->get_eye_pos( ), rotated_center ); - g_csgo.m_trace( )->TraceRay( ray, MASK_SHOT, &filter, &tr_rot ); + ray.Init( g_ctx.m_local->get_eye_pos( ), position ); + g_csgo.m_trace( )->TraceRay( ray, MASK_ALL, &filter, &tr_center ); - bool is_within = tr_center.hitbox == tr_rot.hitbox; + ray.Init( g_ctx.m_local->get_eye_pos( ), trace_pos ); + g_csgo.m_trace( )->TraceRay( ray, MASK_ALL, &filter, &tr_rot ); + + is_within = ( tr_center.hitbox == tr_rot.hitbox ) && ( tr_rot.DidHit( ) ); + + if( !is_within ) + break; + } if( !is_within ) { auto dist = box->bbmin.dist_to( box->bbmax ); diff --git a/cheat/internal_rewrite/update_clientside_animation.cpp b/cheat/internal_rewrite/update_clientside_animation.cpp index 201d100..622fc46 100644 --- a/cheat/internal_rewrite/update_clientside_animation.cpp +++ b/cheat/internal_rewrite/update_clientside_animation.cpp @@ -39,8 +39,20 @@ void __fastcall hooks::update_clientside_animation( void* ecx_, void* edx_ ) { ent->get_animstate( )->m_bOnGround = false; ent->invalidate_bone_cache( ); - ent->ce( )->SetupBones( nullptr, 128, BONE_USED_BY_ANYTHING, 0.f ); + auto model = ent->ce( )->GetModel( ); + auto hdr = g_csgo.m_model_info( )->GetStudiomodel( model ); + auto set = hdr->pHitboxSet( ent->m_nHitboxSet( ) ); + + if( hdr && set ) { + for( size_t i{ }; i < hdr->numbones; i++ ) { + auto bone = hdr->GetBone( i ); + + bone->proctype &= ~5; + } + } + + ent->ce( )->SetupBones( nullptr, 128, BONE_USED_BY_ANYTHING, 0.f ); ent->get_animstate( )->m_bOnGround = backup; } diff --git a/cheat/internal_rewrite/visual_player.cpp b/cheat/internal_rewrite/visual_player.cpp index b685adc..cb99fb7 100644 --- a/cheat/internal_rewrite/visual_player.cpp +++ b/cheat/internal_rewrite/visual_player.cpp @@ -361,8 +361,20 @@ namespace features int idx = snd.sound_source; auto ent = g_csgo.m_entlist( )->GetClientEntity( idx ); - if( ent && ent->is_player( ) && ent->ce( )->IsDormant( ) ) - update_position( idx, snd.origin[ 0 ] ); + if( ent && ent->is_player( ) ) { + if( ent->ce( )->IsDormant( ) ) + update_position( idx, snd.origin[ 0 ] ); + else { + static float last_time[ 65 ]{ }; + + if( std::abs( g_csgo.m_globals->m_curtime - last_time[ idx ] ) > 1.f ) { + vec3_t pos = ent->m_vecOrigin( ); + pos.z += 10.f; + store_sound( idx, pos ); + last_time[ idx ] = g_csgo.m_globals->m_curtime; + } + } + } } } } @@ -544,7 +556,6 @@ namespace features float delta = ( ent->m_flSimulationTime( ) - update ) * 0.9f; if( delta >= 0.f && delta <= 1.f ) { - //don't allocate 20000000 bytes on the stack thx static vertex_t v[ 48 ]; @@ -572,6 +583,13 @@ namespace features g_renderer.draw_filled_circle( x_pos + radius / 2 + 2, y_pos + radius / 2 + 2, radius + 1, clr_t( 0, 0, 0, 170 * alpha ) ); g_renderer.draw_polygon( progress, v, g_settings.visuals.lby_bar_clr ); } + else { + draw_string( x_pos, y_pos, ALIGN_LEFT, false, + clr_t( 255, 255, 255, 255 * alpha ), + xors( "fake" ) ); + + right_pos += 9; + } } else { draw_string( x_pos, y_pos, ALIGN_LEFT, false, -- cgit v1.2.3