summaryrefslogtreecommitdiff
path: root/internal_rewrite/extra.cpp
diff options
context:
space:
mode:
authorJustSomePwner <crotchyalt@gmail.com>2018-08-30 14:01:54 +0200
committerJustSomePwner <crotchyalt@gmail.com>2018-08-30 14:01:54 +0200
commit7ccb819f867493f8ec202ea3b39c94c198c64584 (patch)
tree94622e61af0ff359e3d6689cf274d74f60b2492a /internal_rewrite/extra.cpp
parent564d979b79e8a5aaa5014eba0ecd36c61575934f (diff)
first
Diffstat (limited to 'internal_rewrite/extra.cpp')
-rw-r--r--internal_rewrite/extra.cpp366
1 files changed, 366 insertions, 0 deletions
diff --git a/internal_rewrite/extra.cpp b/internal_rewrite/extra.cpp
new file mode 100644
index 0000000..58fa03a
--- /dev/null
+++ b/internal_rewrite/extra.cpp
@@ -0,0 +1,366 @@
+#include "base_cheat.hpp"
+#include "context.hpp"
+#include "input_system.hpp"
+#include "math.hpp"
+#include "hooks.hpp"
+#include "interface.hpp"
+#undef min
+
+
+namespace features
+{
+ void c_extra::rank_reveal( user_cmd_t* ucmd ) {
+ if( !( ucmd->m_buttons & IN_SCORE ) || !g_settings.misc.rank_reveal( ) ) return;
+
+ vec3_t a{ }; //stop this
+ static uintptr_t show_rank_addr = pattern::first_code_match( g_csgo.m_chl.dll( ), xors( "55 8B EC 8B 0D ? ? ? ? 68" ) );
+ //reinterpret_cast<bool( __cdecl* )( vec3_t* )>( show_rank_addr )( &a );
+
+ }
+
+ void c_extra::thirdperson( ) {
+ if( !g_ctx.m_local )
+ return;
+
+ static bool enabled = false;
+ static bool toggle = true;
+ static bool key_held = false;
+
+
+ if( g_input.is_key_pressed( ( VirtualKeys_t )g_settings.misc.thirdperson_key( ) ) ) {
+ if( !key_held ) {
+ toggle ^= 1;
+ }
+ key_held = true;
+ }
+ else {
+ key_held = false;
+ }
+
+ if( !g_settings.misc.thirdperson || !toggle ) {
+ if( enabled ) {
+ g_csgo.m_input( )->m_fCameraInThirdPerson = false;
+ enabled = false;
+ }
+
+ return;
+ }
+
+ vec3_t viewangles{ };
+ if( g_ctx.m_local->is_alive( ) ) {
+ g_csgo.m_engine( )->GetViewAngles( viewangles );
+ g_csgo.m_input( )->m_fCameraInThirdPerson = true;
+ g_csgo.m_input( )->m_vecCameraOffset = vec3_t( viewangles.x, viewangles.y, 150.0f );
+
+ constexpr float cam_hull_offset{ 16.f };
+
+ const vec3_t cam_hull_min( -cam_hull_offset, -cam_hull_offset, -cam_hull_offset );
+ const vec3_t cam_hull_max( cam_hull_offset, cam_hull_offset, cam_hull_offset );
+ vec3_t cam_forward, origin = g_ctx.m_local->get_eye_pos( );
+
+ cam_forward = math::angle_vectors( vec3_t( viewangles.x, viewangles.y, 0.f ) );
+
+ CTraceFilterWorldAndPropsOnly filter;
+ Ray_t ray;
+ CGameTrace tr;
+
+ ray.Init( origin, origin - ( cam_forward * 150.f ), cam_hull_min, cam_hull_max );
+
+ g_csgo.m_trace( )->TraceRay( ray, MASK_SOLID & ~CONTENTS_MONSTER, &filter, &tr );
+ g_csgo.m_input( )->m_vecCameraOffset.z = 150.f * tr.fraction;
+
+ enabled = true;
+ }
+ else if( g_csgo.m_entlist( )->GetClientEntityFromHandle< >( g_ctx.m_local->m_hObserverTarget( ) ) ) {
+ g_csgo.m_input( )->m_fCameraInThirdPerson = false;
+ g_ctx.m_local->m_iObserverMode( ) = 5;
+ }
+ }
+
+ void c_extra::update_netchannel( ) {
+ if( !g_csgo.m_engine( )->IsInGame( ) || !g_ctx.m_local ||
+ !g_ctx.m_local->is_valid( ) ) {
+ return;
+ }
+
+ switch( g_settings.misc.net_fakelag ) {
+ case 0:
+ g_settings.misc.net_fakeping_active = false;
+ break;
+ case 1:
+ g_settings.misc.net_fakeping_active = g_input.is_key_pressed( g_settings.misc.net_fakeping_key );
+ break;
+ case 2: {
+ static bool held = false;
+ bool pressed = g_input.is_key_pressed( g_settings.misc.net_fakeping_key );
+ if( pressed ) {
+ if( !held )
+ g_settings.misc.net_fakeping_active ^= 1;
+ held = true;
+ }
+ else held = false;
+ }
+ break;
+ case 3:
+ g_settings.misc.net_fakeping_active = true;
+ break;
+ default:
+ g_settings.misc.net_fakeping_active = false;
+ break;
+ }
+
+ auto clientstate = g_csgo.m_global_state->get_client_state( );
+ if( clientstate ) {
+ // TODO: Change this to the non-homosexual way of hooking CNetChan functions.
+ // Actually, I'm too lazy. You can do this if you want.
+ /*
+ auto *base_net_channel = *memory::find_signature< uint32_t ** >( g_cl.m_engine.dll( ), "C7 07 ? ? ? ? E8 ? ? ? ? 83 BF", 2 );
+
+ VirtualProtect( &base_net_channel [ 46 ], 4, PAGE_EXECUTE_READWRITE, &o_prot );
+ hooked::o_send_datagram = ( decltype( hooked::o_send_datagram ) ) base_net_channel [ 46 ];
+ base_net_channel [ 46 ] = uint32_t( hooked::send_datagram );
+ VirtualProtect( &base_net_channel [ 46 ], 4, o_prot, &o_prot );
+ */
+ auto netchannel = clientstate->m_netchannel;
+ if( netchannel ) {
+ auto old_netchannel = g_csgo.m_net_channel( );
+
+ if( old_netchannel != netchannel ||
+ ( old_netchannel &&
+ g_csgo.m_net_channel->get_function< void* >( 46 ) != &hooks::send_datagram ) ) {
+ g_csgo.m_net_channel( netchannel );
+ g_csgo.m_net_channel->hook( 46, &hooks::send_datagram );
+ }
+ }
+ }
+ }
+
+ void c_extra::add_latency( INetChannel* channel ) {
+ if ( g_ctx.m_local && g_ctx.m_local->is_valid( ) ) {
+ float latency = g_settings.misc.net_fakeping_amount( ) * 0.001f;
+
+ auto nci = g_csgo.m_engine( )->GetNetChannelInfo( );
+ if( g_settings.misc.net_fakeping_active ) {
+ // I doubt that the code below is actually necessary to accomplish fake latency.
+ // In fact, it might be the thing that is breaking it.
+
+ // float latency_floor = std::floorf( nci->GetLatency( 1 ) * 10.f ) * 0.1f;
+ // if( g_csgo.m_globals->m_frametime > TICK_INTERVAL( ) || latency_floor <= latency + g_csgo.m_globals->m_frametime * 2.f )
+
+ channel->m_nInSequenceNr += 2 * 64 - ( 63 * latency );
+ }
+ }
+ }
+
+ void c_extra::no_recoil( user_cmd_t* cmd ) {
+ if( !g_settings.misc.no_recoil( ) )
+ return;
+
+ if( g_ctx.m_local && g_ctx.m_local->is_alive( ) ) {
+ static auto weapon_recoil_scale = g_csgo.m_cvar( )->FindVar( xors( "weapon_recoil_scale" ) );
+ cmd->m_viewangles -= g_ctx.m_local->m_aimPunchAngle( true ) * weapon_recoil_scale->get_float( );
+ cmd->m_viewangles.y = std::remainderf( cmd->m_viewangles.y, 360.f );
+ }
+ }
+
+ void c_extra::rich_presence_flex( ) {
+ g_csgo.m_steam_friends( )->set_rich_presence( "game:mode", "competitive" );
+ g_csgo.m_steam_friends( )->set_rich_presence( "game:mapgroupname", "mg_active" );
+ g_csgo.m_steam_friends( )->set_rich_presence( "game:score", "moneybot.cc" );
+ }
+
+ void c_extra::remove_rich_presence_flex( ) {
+ g_csgo.m_steam_friends( )->clear_rich_presence( );
+ }
+
+ // I am so, so, so, so sorry.
+ void c_extra::money_talk( IGameEvent *evt ) {
+ static float last_time = 0.0f;
+
+ if ( !g_csgo.m_engine( )->IsConnected( ) || !g_csgo.m_engine( )->IsInGame( ) ) {
+ last_time = 0.0f;
+ }
+
+ if ( !g_settings.misc.money_talk( ) )
+ return;
+
+ if ( evt && !strcmp( evt->GetName( ), xors( "player_death" ) ) ) {
+ const int player = g_csgo.m_engine( )->GetPlayerForUserID( evt->GetInt( xors( "attacker" ) ) );
+
+ if ( player == g_csgo.m_engine( )->GetLocalPlayer( ) ) {
+ if ( last_time <= g_csgo.m_globals->m_curtime ) {
+ g_csgo.m_engine( )->ClientCmd( xors( "say god i wish i had moneybot" ) );
+
+ last_time = g_csgo.m_globals->m_curtime + 0.1f;
+ }
+ }
+ }
+ }
+
+ void c_extra::no_recoil( bool original ) {
+ static bool restore = false;
+ static vec3_t punch{ };
+ static vec3_t view_punch{ };
+
+ if( !g_settings.misc.no_recoil( ) || !g_ctx.m_local || !g_ctx.m_local->is_alive( ) )
+ return;
+
+ if( !original ) {
+ punch = g_ctx.m_local->m_aimPunchAngle( true );
+ view_punch = g_ctx.m_local->m_viewPunchAngle( );
+
+ g_ctx.m_local->m_aimPunchAngle( true ) = vec3_t( );
+ g_ctx.m_local->m_viewPunchAngle( ) = vec3_t( );
+
+ restore = true;
+ }
+
+ if( original && restore ) {
+ g_ctx.m_local->m_aimPunchAngle( true ) = punch;
+ g_ctx.m_local->m_viewPunchAngle( ) = view_punch;
+
+ restore = false;
+ }
+ }
+
+ void c_extra::auto_revolver( user_cmd_t* cmd ) {
+ if( !g_settings.misc.auto_revolver ) return;
+
+ auto weapon = g_ctx.m_local->get_weapon( );
+ if( !weapon ) return;
+
+ int def_index = weapon->m_iItemDefinitionIndex( );
+ if( def_index != WEAPON_R8REVOLVER ) return;
+
+ if( !g_ctx.m_local->can_attack( ) ) {
+ cmd->m_buttons |= IN_ATTACK;
+ }
+ else if( !g_cheat.m_lagmgr.get_sent( ) ) {
+ g_cheat.m_lagmgr.set_state( true );
+ }
+ }
+
+ void c_extra::no_flash( ) {
+ static bool once = false;
+ if( !g_ctx.m_local || !g_ctx.m_local->is_valid( ) ) {
+ return;
+ }
+
+ if( !g_settings.misc.no_flash ) {
+ if( once ) {
+ g_ctx.m_local->m_flMaxFlashAlpha( ) = 255.f;
+ }
+ return;
+ }
+
+ once = true;
+
+ if( g_ctx.m_local->m_flFlashDuration( ) )
+ g_ctx.m_local->m_flMaxFlashAlpha( ) = std::numeric_limits< float >::min( );
+ }
+
+ //this is not how it works
+ void c_extra::disable_post_processing( ) {
+ static auto var = g_csgo.m_cvar( )->FindVar( xors( "mat_postprocess_enable" ) );
+ var->m_flags |= 0;
+ var->set_value( !g_settings.misc.disable_post_process( ) );
+ }
+
+ void c_extra::float_ragdolls( ) {
+ static bool once = true;;
+ static auto var = g_csgo.m_cvar( )->FindVar( xors( "cl_ragdoll_gravity" ) );
+
+ if( !g_settings.visuals.floating_ragdolls ) {
+ if( !once ) {
+ var->set_value( 600 );
+ }
+ once = true;
+ return;
+ }
+
+ once = false;
+ var->m_flags |= 0;
+ var->set_value( -100 );
+ }
+
+ /*void c_extra::print_overwatch_info( ) {
+ for( int i{}; i < 65; ++i ) {
+ auto ent = g_csgo.m_entlist( )->GetClientEntity( i );
+ if( !ent->is_player( ) )
+ continue;
+
+ g_csgo.m_cvar( )->ConsolePrintf( "name: " );
+ g_csgo.m_cvar( )->ConsolePrintf( "userid: " );
+ g_csgo.m_cvar( )->ConsolePrintf( "steam3: " );
+ g_csgo.m_cvar( )->ConsolePrintf( "steam64: " );
+ g_csgo.m_cvar( )->ConsolePrintf( "steam community link: " );
+ g_csgo.m_cvar( )->ConsolePrintf( "rank: " );
+ g_csgo.m_cvar( )->ConsolePrintf( "wins: " );
+ }
+ }*/
+
+ void c_extra::no_smoke( ) {
+ static bool set = false;
+ static bool last_setting = g_settings.misc.no_smoke;
+ if( !g_ctx.m_local || !g_csgo.m_engine( )->IsInGame( ) ) {
+ last_setting = !g_settings.misc.no_smoke;
+ return;
+ }
+
+ if( g_settings.misc.no_smoke || last_setting != g_settings.misc.no_smoke ) {
+ if( g_ctx.m_local && g_csgo.m_engine( )->IsInGame( ) ) {
+ static auto v_smoke_smokegrenade = g_csgo.m_mat_system( )->FindMaterial( xors( "particle\\vistasmokev1\\vistasmokev1_smokegrenade" ) );
+ bool draw = g_settings.misc.no_smoke( );
+
+ if( v_smoke_smokegrenade )
+ v_smoke_smokegrenade->SetMaterialVarFlag( MATERIAL_VAR_NO_DRAW, draw );
+ }
+ }
+
+ last_setting = g_settings.misc.no_smoke;
+ }
+
+ void c_extra::server_information( ) {
+/* if( !g_settings.misc.server_information( ) )
+ return;
+
+ auto lobby = g_csgo.m_mm( )->GetMatchSession( );
+ if( !lobby )
+ return;
+
+ auto info = lobby->GetSessionSettings( );
+ if( !info )
+ return;
+
+ auto q = info->get_string( xors( "game/mmqueue" ), xors( "no queue!" ) );
+ if( !q || strcmp( q, xors( "reserved" ) ) )
+ return;
+
+ auto map = info->get_string( xors( "game/map" ), xors( "no map!" ) );
+ if( !map )
+ return;
+
+ auto location = info->get_string( xors( "game/loc" ), xors( "no location!" ) );
+
+ g_csgo.m_cvar( )->ConsoleColorPrintf( clr_t( 231, 105, 105 ), xors( "\n-----------------------\n" ) );
+ g_csgo.m_cvar( )->ConsoleColorPrintf( clr_t( 231, 105, 105 ), xors( "map: %s\n" ), map );
+ g_csgo.m_cvar( )->ConsoleColorPrintf( clr_t( 231, 105, 105 ), xors( "location: %s" ), location );
+ g_csgo.m_cvar( )->ConsoleColorPrintf( clr_t( 231, 105, 105 ), xors( "\n-----------------------\n" ) );
+ */
+ }
+
+ void c_extra::unlock_hidden_cvars( ) {
+ // Wouldn't this get you untrusted?
+ if ( g_settings.menu.anti_untrusted )
+ return;
+
+ auto it = g_csgo.m_cvar( )->FactoryInternalIterator( ); // genius code. list of cvars unlocked at https://github.com/saul/csgo-cvar-unhide/blob/master/cvarlist.md
+ for( it->SetFirst( ); it->IsValid( ); it->Next( ) ) {
+ auto cvar = ( cvar_t* )it->Get( );
+ if( cvar ) {
+ cvar->m_flags &= ~FCVAR_HIDDEN;
+ cvar->m_flags &= ~FCVAR_DEVELOPMENTONLY;
+ }
+ }
+ }
+} \ No newline at end of file