forked from OneshotGH/supremacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.cpp
202 lines (154 loc) · 8.2 KB
/
hooks.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
200
201
202
#include "includes.h"
Hooks g_hooks{ };;
CustomEntityListener g_custom_entity_listener{ };;
void Pitch_proxy( CRecvProxyData *data, Address ptr, Address out ) {
// normalize this fucker.
math::NormalizeAngle( data->m_Value.m_Float );
// clamp to remove retardedness.
math::clamp( data->m_Value.m_Float, -90.f, 90.f );
// call original netvar proxy.
if ( g_hooks.m_Pitch_original )
g_hooks.m_Pitch_original( data, ptr, out );
}
void Body_proxy( CRecvProxyData *data, Address ptr, Address out ) {
Stack stack;
static Address RecvTable_Decode{ pattern::find( g_csgo.m_engine_dll, XOR( "EB 0D FF 77 10" ) ) };
// call from entity going into pvs.
if ( stack.next( ).next( ).ReturnAddress( ) != RecvTable_Decode ) {
// convert to player.
Player *player = ptr.as< Player * >( );
// store data about the update.
g_resolver.OnBodyUpdate( player, data->m_Value.m_Float );
}
// call original proxy.
if ( g_hooks.m_Body_original )
g_hooks.m_Body_original( data, ptr, out );
}
void AbsYaw_proxy( CRecvProxyData *data, Address ptr, Address out ) {
// convert to ragdoll.
//Ragdoll* ragdoll = ptr.as< Ragdoll* >( );
// get ragdoll owner.
//Player* player = ragdoll->GetPlayer( );
// get data for this player.
/*AimPlayer* aim = &g_aimbot.m_players[ player->index( ) - 1 ];
if( player && aim ) {
if( !aim->m_records.empty( ) ) {
LagRecord* match{ nullptr };
// iterate records.
for( const auto &it : aim->m_records ) {
// find record that matches with simulation time.
if( it->m_sim_time == player->m_flSimulationTime( ) ) {
match = it.get( );
break;
}
}
// we have a match.
// and it is standing
// TODO; add air?
if( match /*&& match->m_mode == Resolver::Modes::RESOLVE_STAND*/// ) {
/* RagdollRecord record;
record.m_record = match;
record.m_rotation = math::NormalizedAngle( data->m_Value.m_Float );
record.m_delta = math::NormalizedAngle( record.m_rotation - match->m_lbyt );
float death = math::NormalizedAngle( ragdoll->m_flDeathYaw( ) );
// store.
//aim->m_ragdoll.push_front( record );
//g_cl.print( tfm::format( XOR( "rot %f death %f delta %f\n" ), record.m_rotation, death, record.m_delta ).data( ) );
}
}*/
//}
// call original netvar proxy.
if ( g_hooks.m_AbsYaw_original )
g_hooks.m_AbsYaw_original( data, ptr, out );
}
void Force_proxy( CRecvProxyData *data, Address ptr, Address out ) {
// convert to ragdoll.
Ragdoll *ragdoll = ptr.as< Ragdoll * >( );
// get ragdoll owner.
Player *player = ragdoll->GetPlayer( );
// we only want this happening to noobs we kill.
if ( g_menu.main.misc.ragdoll_force.get( ) && g_cl.m_local && player && player->enemy( g_cl.m_local ) ) {
// get m_vecForce.
vec3_t vel = { data->m_Value.m_Vector[ 0 ], data->m_Value.m_Vector[ 1 ], data->m_Value.m_Vector[ 2 ] };
// give some speed to all directions.
vel *= 1000.f;
// boost z up a bit.
if ( vel.z <= 1.f )
vel.z = 2.f;
vel.z *= 2.f;
// don't want crazy values for this... probably unlikely though?
math::clamp( vel.x, std::numeric_limits< float >::lowest( ), std::numeric_limits< float >::max( ) );
math::clamp( vel.y, std::numeric_limits< float >::lowest( ), std::numeric_limits< float >::max( ) );
math::clamp( vel.z, std::numeric_limits< float >::lowest( ), std::numeric_limits< float >::max( ) );
// set new velocity.
data->m_Value.m_Vector[ 0 ] = vel.x;
data->m_Value.m_Vector[ 1 ] = vel.y;
data->m_Value.m_Vector[ 2 ] = vel.z;
}
if ( g_hooks.m_Force_original )
g_hooks.m_Force_original( data, ptr, out );
}
void Hooks::init( ) {
// hook wndproc.
m_old_wndproc = ( WNDPROC )g_winapi.SetWindowLongA( g_csgo.m_game->m_hWindow, GWL_WNDPROC, util::force_cast< LONG >( Hooks::WndProc ) );
// setup normal VMT hooks.
m_panel.init( g_csgo.m_panel );
m_panel.add( IPanel::PAINTTRAVERSE, util::force_cast( &Hooks::PaintTraverse ) );
m_client.init( g_csgo.m_client );
m_client.add( CHLClient::LEVELINITPREENTITY, util::force_cast( &Hooks::LevelInitPreEntity ) );
m_client.add( CHLClient::LEVELINITPOSTENTITY, util::force_cast( &Hooks::LevelInitPostEntity ) );
m_client.add( CHLClient::LEVELSHUTDOWN, util::force_cast( &Hooks::LevelShutdown ) );
//m_client.add( CHLClient::INKEYEVENT, util::force_cast( &Hooks::IN_KeyEvent ) );
m_client.add( CHLClient::FRAMESTAGENOTIFY, util::force_cast( &Hooks::FrameStageNotify ) );
m_engine.init( g_csgo.m_engine );
m_engine.add( IVEngineClient::ISCONNECTED, util::force_cast( &Hooks::IsConnected ) );
m_engine.add( IVEngineClient::ISHLTV, util::force_cast( &Hooks::IsHLTV ) );
m_engine_sound.init( g_csgo.m_sound );
m_engine_sound.add( IEngineSound::EMITSOUND, util::force_cast( &Hooks::EmitSound ) );
m_prediction.init( g_csgo.m_prediction );
m_prediction.add( CPrediction::INPREDICTION, util::force_cast( &Hooks::InPrediction ) );
m_prediction.add( CPrediction::RUNCOMMAND, util::force_cast( &Hooks::RunCommand ) );
m_client_mode.init( g_csgo.m_client_mode );
m_client_mode.add( IClientMode::SHOULDDRAWPARTICLES, util::force_cast( &Hooks::ShouldDrawParticles ) );
m_client_mode.add( IClientMode::SHOULDDRAWFOG, util::force_cast( &Hooks::ShouldDrawFog ) );
m_client_mode.add( IClientMode::OVERRIDEVIEW, util::force_cast( &Hooks::OverrideView ) );
m_client_mode.add( IClientMode::CREATEMOVE, util::force_cast( &Hooks::CreateMove ) );
m_client_mode.add( IClientMode::DOPOSTSPACESCREENEFFECTS, util::force_cast( &Hooks::DoPostScreenSpaceEffects ) );
m_surface.init( g_csgo.m_surface );
//m_surface.add( ISurface::GETSCREENSIZE, util::force_cast( &Hooks::GetScreenSize ) );
m_surface.add( ISurface::LOCKCURSOR, util::force_cast( &Hooks::LockCursor ) );
m_surface.add( ISurface::PLAYSOUND, util::force_cast( &Hooks::PlaySound ) );
m_surface.add( ISurface::ONSCREENSIZECHANGED, util::force_cast( &Hooks::OnScreenSizeChanged ) );
m_model_render.init( g_csgo.m_model_render );
m_model_render.add( IVModelRender::DRAWMODELEXECUTE, util::force_cast( &Hooks::DrawModelExecute ) );
m_render_view.init( g_csgo.m_render_view );
m_render_view.add( IVRenderView::SCENEEND, util::force_cast( &Hooks::SceneEnd ) );
m_shadow_mgr.init( g_csgo.m_shadow_mgr );
m_shadow_mgr.add( IClientShadowMgr::COMPUTESHADOWDEPTHTEXTURES, util::force_cast( &Hooks::ComputeShadowDepthTextures ) );
m_view_render.init( g_csgo.m_view_render );
m_view_render.add( CViewRender::ONRENDERSTART, util::force_cast( &Hooks::OnRenderStart ) );
m_view_render.add( CViewRender::RENDERVIEW, util::force_cast( &Hooks::RenderView ) );
m_view_render.add( CViewRender::RENDER2DEFFECTSPOSTHUD, util::force_cast( &Hooks::Render2DEffectsPostHUD ) );
m_view_render.add( CViewRender::RENDERSMOKEOVERLAY, util::force_cast( &Hooks::RenderSmokeOverlay ) );
m_match_framework.init( g_csgo.m_match_framework );
m_match_framework.add( CMatchFramework::GETMATCHSESSION, util::force_cast( &Hooks::GetMatchSession ) );
m_material_system.init( g_csgo.m_material_system );
m_material_system.add( IMaterialSystem::OVERRIDECONFIG, util::force_cast( &Hooks::OverrideConfig ) );
m_fire_bullets.init( g_csgo.TEFireBullets );
m_fire_bullets.add( 7, util::force_cast( &Hooks::PostDataUpdate ) );
m_client_state.init( g_csgo.m_hookable_cl );
m_client_state.add( CClientState::TEMPENTITIES, util::force_cast( &Hooks::TempEntities ) );
// register our custom entity listener.
// todo - dex; should we push our listeners first? should be fine like this.
g_custom_entity_listener.init( );
// cvar hooks.
m_debug_spread.init( g_csgo.net_showfragments );
m_debug_spread.add( ConVar::GETINT, util::force_cast( &Hooks::DebugSpreadGetInt ) );
m_net_show_fragments.init( g_csgo.net_showfragments );
m_net_show_fragments.add( ConVar::GETBOOL, util::force_cast( &Hooks::NetShowFragmentsGetBool ) );
// set netvar proxies.
g_netvars.SetProxy( HASH( "DT_CSPlayer" ), HASH( "m_angEyeAngles[0]" ), Pitch_proxy, m_Pitch_original );
g_netvars.SetProxy( HASH( "DT_CSPlayer" ), HASH( "m_flLowerBodyYawTarget" ), Body_proxy, m_Body_original );
g_netvars.SetProxy( HASH( "DT_CSRagdoll" ), HASH( "m_vecForce" ), Force_proxy, m_Force_original );
g_netvars.SetProxy( HASH( "DT_CSRagdoll" ), HASH( "m_flAbsYaw" ), AbsYaw_proxy, m_AbsYaw_original );
}