-
Notifications
You must be signed in to change notification settings - Fork 42
/
legit.cpp
199 lines (177 loc) · 6.09 KB
/
legit.cpp
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
#include "context.h"
#include "autowall.h"
#include "legit.h"
c_legit g_legit;
void c_legit::init_create_move( )
{
if ( !ctx.m_settings.legit_enabled || !ctx.m_local->weapon( ) )
return;
if ( ctx.m_settings.legit_trigger )
triggerbot( );
}
void c_legit::init_override_mouse_input( float* x, float* y )
{
aimbot( x, y );
if ( ctx.m_settings.legit_rcs && ctx.m_settings.legit_rcs_standalone )
{
static const auto weapon_recoil_scale = csgo.m_engine_cvars( )->FindVar( xors( "weapon_recoil_scale" ) );
vec3 aim_angles;
csgo.m_engine( )->GetViewAngles( aim_angles );
aim_angles.x -= ctx.m_local->punch( ).x * weapon_recoil_scale->get_float( ) * ( ctx.m_settings.legit_rcs_x / 100.0f );
aim_angles.y -= ctx.m_local->punch( ).y * weapon_recoil_scale->get_float( ) * ( ctx.m_settings.legit_rcs_y / 100.0f );
}
}
void c_legit::triggerbot( )
{
if ( ctx.m_settings.legit_trigger_key > KEYS_NONE && !g_input.is_key_pressed( ctx.m_settings.legit_trigger_key ) )
return;
if ( ctx.m_settings.legit_trigger_scope && ( ctx.m_local->weapon( )->type( ) == sniper && !ctx.m_local->in_scope( ) ) )
return;
// i'll implement this later
/*if ( ctx.m_settings.legit_trigger_delay > 0 )
{
const float delay = static_cast< float >( ctx.m_settings.legit_trigger_delay ) * 0.001f;
static float fire_time = csgo.m_globals( )->curtime + delay;
if ( csgo.m_globals( )->curtime >= fire_time )
{
// we've reached the user's desired delay, time to fire
ctx.m_cmd->m_buttons |= IN_ATTACK;
// reset our timer to the next
fire_time = csgo.m_globals( )->curtime + delay;
}
}*/
c_game_trace tr;
ray_t ray;
c_trace_filter filter( ctx.m_local );
const vec3 src = ctx.m_local->head_position( );
vec3 dst;
vec3 viewangles;
constexpr uint32_t mask = CONTENTS_SOLID | CONTENTS_GRATE | CONTENTS_HITBOX;
// ...
{
csgo.m_engine( )->GetViewAngles( viewangles );
math::angle_vectors( viewangles, &dst );
}
// setup our raytrace
ray.Init( src, ( dst * 8192.0f ) + src );
// send out a raytrace and clip player bounds
{
csgo.m_engine_trace( )->TraceRay( ray, mask, &filter, &tr );
g_auto_wall.clip_trace_to_players( src, dst, mask, &tr, ctx.m_local );
// handle smoke check
if ( ctx.m_settings.legit_trigger_smoke && m_aim_utils.trace_hit_smoke( src, dst ) )
return;
}
// check if we've hit an entity, and it's hit a desirable hitbox
if ( tr.m_ent && ( tr.m_hitgroup <= HITGROUP_LEFTLEG && tr.m_hitgroup > HITGROUP_GENERIC ) )
{
if ( ( tr.m_ent->team( ) == ctx.m_local->team( ) && !ctx.m_settings.legit_trigger_friendlies ) || tr.m_ent->immune( ) )
return;
ctx.m_cmd->m_buttons |= IN_ATTACK;
// autopistol
if ( ctx.m_local->weapon( )->type( ) == pistol && ctx.m_cmd->m_buttons & IN_ATTACK )
ctx.m_cmd->m_cmd_number % 2 == 1 ? ctx.m_cmd->m_buttons |= IN_ATTACK : ctx.m_cmd->m_buttons &= ~IN_ATTACK;
}
}
//bool c_legit::get_aim_pos( vec3& out, c_base_entity* player )
//{
// matrix3x4_t matrix[128];
//
// studiohdr_t* hdr;
// mstudiohitboxset_t* set;
// mstudiobbox_t* hitbox;
//
// vec3 min, max;
//
// const char* hitboxes[] = { xors("head"), xors("spine"), xors("pelvis"), };
//
// if ( !player || !g_boner.get_latest( player->index( ), matrix ) )
// return false;
//
// hdr = csgo.m_model_info( )->GetStudioModel( player->model( ) );
//
// if ( !hdr )
// return false;
//
// set = hdr->pHitboxSet( player->hitbox_set( ) );
//
// if ( !set )
// return false;
//
// for ( size_t i = 0; i < set->numhitboxes; i++ )
// {
// hitbox = set->pHitbox( i );
//
// if ( hitbox )
// {
// if ( strstr( hdr->GetBone( hitbox->m_Bone )->pszName( ), hitboxes[ctx.m_settings.rage_hitbox] ) )
// {
// hitbox->m_Mins = math::VectorRotate( hitbox->m_Mins, hitbox->m_Rotation );
// hitbox->m_Maxs = math::VectorRotate( hitbox->m_Maxs, hitbox->m_Rotation );
//
// math::VectorTransformASM( &hitbox->m_Mins[0], matrix[hitbox->m_Bone], &min[0] );
// math::VectorTransformASM( &hitbox->m_Maxs[0], matrix[hitbox->m_Bone], &max[0] );
//
// m_target_hitbox = i;
//
// out = ( min + max ) * 0.5f;
// //out.z += hitbox->m_Radius;
// return !out.is_zero( );
// }
// }
// }
//
// return false;
//}
void c_legit::aimbot( float* mouse_x, float* mouse_y )
{
//if ( !g_input.is_key_pressed( ctx.m_settings.legit_aim_key ) && ctx.m_settings.legit_aim_key > KEYS_NONE )
// return;
//
//c_base_entity* ent = m_aim_utils.get_aim_target( );
//
//if ( !ent || !ent->visible( ctx.m_local, ctx.m_local->head_position( ), ent->head_position( ) ) )
// return;
//
//vec3 hitbox_pos{ };
//if ( !g_aimbot.get_aim_pos( hitbox_pos, ent ) )
// return;
//
//static const auto weapon_recoil_scale = csgo.m_engine_cvars( )->FindVar( xors( "weapon_recoil_scale" ) );
//static const auto sensitivity = csgo.m_engine_cvars( )->FindVar( xors( "sensitivity" ) );
//
//float time_delta = m_aim_utils.get_time_delta( );
//const vec3 delta_angles = math::_vector_angles( ctx.m_local->head_position( ), hitbox_pos );
//const vec3 current_angles = csgo.m_engine( )->GetViewAngles( );
//vec3 delta = ( delta_angles - current_angles );
//const float distance = delta.length2d( );
//
//if ( ctx.m_settings.legit_rcs && !ctx.m_settings.legit_rcs_standalone )
//{
// // rcs strength %
// delta.x -= ctx.m_local->punch( ).x * weapon_recoil_scale->get_float( ) * ( ctx.m_settings.legit_rcs_x / 100.0f );
// delta.y -= ctx.m_local->punch( ).y * weapon_recoil_scale->get_float( ) * ( ctx.m_settings.legit_rcs_y / 100.0f );
//}
//
//if ( csgo.m_globals( )->curtime >= m_aim_utils.m_next_aim_time && distance > ( ctx.m_settings.legit_aim_threshold / 100.0f ) )
//{
// m_aim_utils.m_last_aim_time = csgo.m_globals( )->curtime;
//
// vec2 pixels = math::angles_to_pixels( delta );
//
// if ( ctx.m_settings.legit_smooth < 100 )
// pixels = ( pixels / sensitivity->get_float( ) ) * ( ctx.m_settings.legit_smooth / 100.0f );
//
// *mouse_x += pixels.x;
// *mouse_y += pixels.y;
//}
//
//// we're on the target(sorta)
//if ( distance < 1.0f )
//{
// //if ( ctx.m_settings.legit_auto_shoot )
//
// // if had ent and ent died
// //m_aim_utils.m_next_aim_time = csgo.m_globals( )->curtime + ( ctx.m_settings.legit_retarget_time / 100.0f );
//}
}