-
Notifications
You must be signed in to change notification settings - Fork 0
/
OverRideView.h
137 lines (104 loc) · 3.55 KB
/
OverRideView.h
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
#pragma once
#include "Hooks.h"
void Thirdperson()
{
if (!interfaces.engine->IsInGame() || !csgo->local)
return;
// static float cur_dist = vars.visuals.thirdperson_dist;
if (!g_Binds[bind_third_person].active)
{
enabledtp = false;
//cur_dist = vars.visuals.thirdperson_dist;
return;
}
if (csgo->local->isAlive() && enabledtp && csgo->client_state->iDeltaTick > 0)
{
if (!interfaces.input->m_fCameraInThirdPerson)
interfaces.input->m_fCameraInThirdPerson = true;
if (interfaces.input->m_fCameraInThirdPerson)
{
/*if (cur_dist > 0.f)
cur_dist -= 1.f * sin(animation_speed * 10.f);*/
auto distance = vars.visuals.thirdperson_dist /*- cur_dist*/;
Vector angles;
interfaces.engine->GetViewAngles(angles);
Vector inverse_angles;
interfaces.engine->GetViewAngles(inverse_angles);
inverse_angles.z = distance;
Vector forward, right, up;
Math::AngleVector4(inverse_angles, forward, right, up);
Ray_t ray;
CTraceFilterWorldAndPropsOnly filter;
trace_t trace;
auto eye_pos = csgo->fake_duck
? csgo->local->GetRenderOrigin() + interfaces.game_movement->GetPlayerViewOffset(false)
: csgo->local->GetRenderOrigin() + csgo->local->GetVecViewOffset();
auto offset = eye_pos + forward * -distance + right + up;
ray.Init(eye_pos, offset, Vector(-16.0f, -16.0f, -16.0f), Vector(16.0f, 16.0f, 16.0f));
interfaces.trace->TraceRay(ray, MASK_SHOT_HULL, &filter, &trace);
trace.fraction = clamp(trace.fraction, 0.f, 1.f);
angles.z = distance * trace.fraction;
interfaces.input->m_vecCameraOffset = angles;
}
/*else
cur_dist = vars.visuals.thirdperson_dist;*/
}
else {
//cur_dist = vars.visuals.thirdperson_dist;
interfaces.input->m_fCameraInThirdPerson = false;
interfaces.input->m_vecCameraOffset.z = 0.f;
}
static auto b_once = false;
if (csgo->local->isAlive())
{
b_once = false;
return;
}
if (b_once) {
csgo->local->SetObserverMode(5);
b_once = false;
}
if (csgo->local->GetObserverMode() == 4)
b_once = true;
}
void __stdcall Hooked_OverrideView(void* pSetup)
{
static auto OverRideView = g_pClientModeHook->GetOriginal< OverRideViewFn >(g_HookIndices[fnva1(hs::Hooked_OverrideView.s().c_str())]);
if (csgo->DoUnload)
return OverRideView(pSetup);
auto Setup = reinterpret_cast<CViewSetup*>(pSetup);
if (csgo->is_connected) {
float fov_addition = vars.misc.worldfov;
fov_addition = clamp(fov_addition, 0.f, 50.f);
if (csgo->is_local_alive) {
if (vars.visuals.remove & 1)
Setup->angles -= csgo->local->GetPunchAngle() * 0.9f + csgo->local->GetViewPunchAngle();
g_GrenadePrediction->View(Setup);
if (csgo->zoom_level > 0)
Setup->fov = (90.f + fov_addition - (50.f * (vars.misc.zoomfov / 100.f))) / csgo->zoom_level;
else
Setup->fov = (90.f + fov_addition);
}
else
Setup->fov = (90.f + fov_addition);
Thirdperson();
OverRideView(pSetup);
if (csgo->is_local_alive && csgo->fake_duck)
{
Setup->origin = csgo->local->GetRenderOrigin() + Vector(0.0f, 0.0f, interfaces.game_movement->GetPlayerViewOffset(false).z + 0.064f);
if (interfaces.input->m_fCameraInThirdPerson)
{
auto camera_angles = Vector(interfaces.input->m_vecCameraOffset.x, interfaces.input->m_vecCameraOffset.y, 0.0f); //-V807
auto camera_forward = Vector();
Math::AngleVectors(camera_angles, camera_forward);
Math::VectorMA(Setup->origin, -interfaces.input->m_vecCameraOffset.z, camera_forward, Setup->origin);
}
}
}
else
OverRideView(pSetup);
}
float __stdcall Hooked_ViewModel()
{
return vars.misc.viewmodelfov == 0 ? 68 : vars.misc.viewmodelfov;
}