-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCrosshair.cpp
37 lines (31 loc) · 1.35 KB
/
Crosshair.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
#include Crosshair.h
// Constants
const float RADIUS = 30.f;
const int X_CENTER = screen_size_x / 2;
const int Y_CENTER = screen_size_y / 2;
// Draws crosshair and penetration reticle
void DrawCrosshairAndPenetrationReticle() {
// Get local player
auto m_local = game::localdata.localplayer();
// Check if local player is alive and has a weapon
if (m_local && m_local->IsAlive()) {
auto m_weapon = m_local->GetWeapon();
if (m_weapon && !m_weapon->IsKnife()) {
// Draw spread crosshair
if (visualconfig.bSpreadCrosshair) {
// Calculate accuracy of the weapon
auto accuracy = m_weapon->GetCone() * 550.f;
// Draw filled circle with the calculated accuracy
draw.filled_circle(X_CENTER, Y_CENTER, RADIUS, accuracy, Color(27, 27, 27, 140));
}
// Draw penetration reticle
if (visualconfig.bPenetrationReticle) {
// Calculate damage and color based on whether the bullet can penetrate or not
float damage;
Color rect_color = trace_autowallable(damage) ? Color(130, 241, 13) : Color(255, 102, 102);
// Draw outlined rectangle with the calculated color
draw.outlined_rect(X_CENTER - 2, Y_CENTER - 2, 5, 5, rect_color);
}
}
}
}