summaryrefslogtreecommitdiff
path: root/cheat/internal_rewrite/extra.cpp
blob: 66aba08a706a0da647adbffbe220155a041da54d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
#include "base_cheat.hpp"
#include "context.hpp"
#include "input_system.hpp"
#include "math.hpp"
#include "hooks.hpp"
#include "interface.hpp"
#include "detours.h"
#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( ) {
		// fuck u bithc
		auto *netchan = g_csgo.m_global_state->get_client_state( )->m_netchannel;

		if( netchan->m_nInSequenceNr != m_last_sequence ) {
			m_last_sequence = netchan->m_nInSequenceNr;

			// emplace new record
			netchan_record_t record{
				g_csgo.m_globals->m_curtime,
				netchan->m_nInReliableState,
				netchan->m_nInSequenceNr
			};
			m_net_records.emplace_back( record );
		}

		// here's the thing.
		// stl is autistic and it crashes.

		// clear outdated records
		for( size_t i{ }; i < m_net_records.size( ); ++i ) {
			const float delta = g_csgo.m_globals->m_curtime - m_net_records.at( i ).m_curtime;

			// 200ms is the max we can fake anyway..
			// hnn this might be why it's so fucked :/
			if( delta > 0.4f )
				m_net_records.erase( m_net_records.begin( ) + i  );
		}
	}

	void c_extra::add_latency( INetChannel* channel ) {
		if(!g_settings.misc.net_fakelag())
			return;

		auto nci = g_csgo.m_engine( )->GetNetChannelInfo( );
		float in_latency = nci->GetLatency( 0 );

		// amount of latency we want to achieve
		float latency = 0.15f - ( in_latency + g_csgo.m_globals->m_frametime ) - TICK_INTERVAL( );

		if( g_ctx.m_local && g_ctx.m_local->is_valid( ) ) {
			// god this is autistic
			for( auto& it : m_net_records ) {
				const float delta = g_csgo.m_globals->m_curtime - it.m_curtime;

				if( delta >= latency ) {
					// apply latency
					channel->m_nInReliableState = it.m_reliable;
					channel->m_nInSequenceNr = it.m_sequence;

					break;
				}
			}
		}
	}

	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 ) {
		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( ) ) {
				g_csgo.m_engine( )->ClientCmd( xors( "say god i wish i had moneybot" ) );
			}
		}
	}

	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;

		static float next_time = 0.f;

		auto time = g_ctx.pred_time( );
		auto primaryattack = weapon->m_flNextPrimaryAttack( );
		auto nextattack = g_ctx.m_local->m_flNextAttack( );
		
		if( primaryattack < time && nextattack < time ) {
			if( next_time >= time ) {
				g_ctx.m_revolver_shot = false;
				cmd->m_buttons |= IN_ATTACK;
			}
			else {
				next_time = time + 0.234375f;
				g_ctx.m_revolver_shot = true;
			}
		}
		else {
			g_ctx.m_revolver_shot = false;
			next_time = time + 0.234375f;
		}
	}

	void c_extra::no_flash( ) {
		static bool once = false;


		if( !g_ctx.run_frame( ) || !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;
			}
		}
	}
}