| 
									
										
										
										
											2023-07-23 14:36:44 +02:00
										 |  |  | #include <stdint.h>
 | 
					
						
							| 
									
										
										
										
											2023-07-22 16:23:15 +02:00
										 |  |  | #include "features.h"
 | 
					
						
							| 
									
										
										
										
											2023-07-22 16:05:47 +02:00
										 |  |  | #include "../include/globals.h"
 | 
					
						
							| 
									
										
										
										
											2025-04-04 16:51:40 -04:00
										 |  |  | #include "../include/settings.h"
 | 
					
						
							| 
									
										
										
										
											2023-07-22 16:15:57 +02:00
										 |  |  | #include "../include/util.h"
 | 
					
						
							| 
									
										
										
										
											2023-09-21 02:30:15 -04:00
										 |  |  | #include "../include/game_detection.h"
 | 
					
						
							| 
									
										
										
										
											2023-07-22 16:05:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-04 16:51:40 -04:00
										 |  |  | // ESP enums moved to settings.h as esp_mode_t
 | 
					
						
							| 
									
										
										
										
											2023-07-24 18:02:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-28 00:19:39 +02:00
										 |  |  | bool gl_draw3dbox(vec3_t o, int bh, int bw, int lw) { | 
					
						
							| 
									
										
										
										
											2023-07-23 14:36:44 +02:00
										 |  |  |     /*
 | 
					
						
							|  |  |  |      * Parameters: | 
					
						
							|  |  |  |      *   bw: 3d box width (game units) | 
					
						
							|  |  |  |      *   bh: 3d box height (game units) | 
					
						
							|  |  |  |      *   lw: Line width | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (vec_is_zero(o)) | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const rgb_t col = { 255, 255, 255 }; /* Color */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /*
 | 
					
						
							|  |  |  |      * (Origin would be in the middle of the cube) | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      *     1---2      y(+) | 
					
						
							|  |  |  |      *    /|  /|     / | 
					
						
							|  |  |  |      *   3---4 |    *--x(+) | 
					
						
							|  |  |  |      *   | 5-|-6    | | 
					
						
							|  |  |  |      *   |/ O|/     z(-) | 
					
						
							|  |  |  |      *   7---8 | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2023-07-28 21:56:35 +02:00
										 |  |  |     vec3_t p1 = vec3(o.x - bw / 2, o.y + bw / 2, o.z + bh / 2); | 
					
						
							|  |  |  |     vec3_t p2 = vec3(o.x + bw / 2, o.y + bw / 2, o.z + bh / 2); | 
					
						
							|  |  |  |     vec3_t p3 = vec3(o.x - bw / 2, o.y - bw / 2, o.z + bh / 2); | 
					
						
							|  |  |  |     vec3_t p4 = vec3(o.x + bw / 2, o.y - bw / 2, o.z + bh / 2); | 
					
						
							|  |  |  |     vec3_t p5 = vec3(o.x - bw / 2, o.y + bw / 2, o.z - bh / 2); | 
					
						
							|  |  |  |     vec3_t p6 = vec3(o.x + bw / 2, o.y + bw / 2, o.z - bh / 2); | 
					
						
							|  |  |  |     vec3_t p7 = vec3(o.x - bw / 2, o.y - bw / 2, o.z - bh / 2); | 
					
						
							|  |  |  |     vec3_t p8 = vec3(o.x + bw / 2, o.y - bw / 2, o.z - bh / 2); | 
					
						
							| 
									
										
										
										
											2023-07-23 14:36:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     vec2_t s1, s2, s3, s4, s5, s6, s7, s8; | 
					
						
							|  |  |  |     if (!world_to_screen(p1, s1) || !world_to_screen(p2, s2) || | 
					
						
							|  |  |  |         !world_to_screen(p3, s3) || !world_to_screen(p4, s4) || | 
					
						
							|  |  |  |         !world_to_screen(p5, s5) || !world_to_screen(p6, s6) || | 
					
						
							|  |  |  |         !world_to_screen(p7, s7) || !world_to_screen(p8, s8)) | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     gl_drawline_points(s1, s2, lw, col); | 
					
						
							|  |  |  |     gl_drawline_points(s1, s3, lw, col); | 
					
						
							|  |  |  |     gl_drawline_points(s1, s5, lw, col); | 
					
						
							|  |  |  |     gl_drawline_points(s2, s4, lw, col); | 
					
						
							|  |  |  |     gl_drawline_points(s2, s6, lw, col); | 
					
						
							|  |  |  |     gl_drawline_points(s3, s4, lw, col); | 
					
						
							|  |  |  |     gl_drawline_points(s3, s7, lw, col); | 
					
						
							|  |  |  |     gl_drawline_points(s4, s8, lw, col); | 
					
						
							|  |  |  |     gl_drawline_points(s5, s6, lw, col); | 
					
						
							|  |  |  |     gl_drawline_points(s5, s7, lw, col); | 
					
						
							|  |  |  |     gl_drawline_points(s6, s8, lw, col); | 
					
						
							|  |  |  |     gl_drawline_points(s7, s8, lw, col); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-28 00:19:39 +02:00
										 |  |  | static bool gl_draw2dbox(vec3_t o, int bh) { | 
					
						
							|  |  |  |     /* bh: 3d box height (game units) */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (vec_is_zero(o)) | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const rgb_t col     = { 255, 255, 255 }; /* Color */ | 
					
						
							|  |  |  |     const rgb_t out_col = { 0, 0, 0 };       /* Outline */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Get top and bottom of player from origin with box height */ | 
					
						
							| 
									
										
										
										
											2023-07-28 21:56:35 +02:00
										 |  |  |     const vec3_t bot = vec3(o.x, o.y, o.z - bh / 2); | 
					
						
							|  |  |  |     const vec3_t top = vec3(o.x, o.y, o.z + bh / 2); | 
					
						
							| 
									
										
										
										
											2023-07-28 00:19:39 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     vec2_t s_bot, s_top; | 
					
						
							|  |  |  |     if (!world_to_screen(bot, s_bot) || !world_to_screen(top, s_top)) | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const int h = s_bot[1] - s_top[1]; | 
					
						
							|  |  |  |     const int w = bh == 70 ? h * 0.40f : h * 0.75f; | 
					
						
							|  |  |  |     const int y = s_top[1]; | 
					
						
							|  |  |  |     const int x = s_top[0] - w / 2; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     gl_drawbox(x - 1, y - 1, w + 2, h + 2, out_col); /* Outer outline */ | 
					
						
							|  |  |  |     gl_drawbox(x + 1, y + 1, w - 2, h - 2, out_col); /* Inner outline */ | 
					
						
							|  |  |  |     gl_drawbox(x, y, w, h, col);                     /* Fill */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-22 16:05:47 +02:00
										 |  |  | void esp(void) { | 
					
						
							| 
									
										
										
										
											2025-04-04 16:51:40 -04:00
										 |  |  |     const int setting = g_settings.esp_mode; | 
					
						
							| 
									
										
										
										
											2023-07-24 18:02:05 +02:00
										 |  |  |     if (setting == ESP_OFF) | 
					
						
							| 
									
										
										
										
											2023-07-22 16:05:47 +02:00
										 |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (int i = 1; i <= i_engine->GetMaxClients(); i++) { | 
					
						
							| 
									
										
										
										
											2023-07-24 17:06:06 +02:00
										 |  |  |         cl_entity_t* ent = get_player(i); | 
					
						
							| 
									
										
										
										
											2023-07-22 16:05:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-24 17:06:06 +02:00
										 |  |  |         if (!valid_player(ent) || !is_alive(ent) || vec_is_zero(ent->origin)) | 
					
						
							| 
									
										
										
										
											2023-07-22 16:05:47 +02:00
										 |  |  |             continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-04 16:51:40 -04:00
										 |  |  |         if (is_friend(ent) && !g_settings.esp_friendly) | 
					
						
							| 
									
										
										
										
											2023-09-20 14:51:49 -04:00
										 |  |  |             continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-21 02:30:15 -04:00
										 |  |  |         int bh = 70; | 
					
						
							|  |  |  |         if (IsDayOfDefeat()) { | 
					
						
							|  |  |  |             bh = 76; | 
					
						
							|  |  |  |         } else if (ent->curstate.usehull == 1) { | 
					
						
							|  |  |  |             bh = 44; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-07-23 14:36:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-28 00:19:39 +02:00
										 |  |  |         if (setting & ESP_BOX && !gl_draw2dbox(ent->origin, bh)) | 
					
						
							| 
									
										
										
										
											2023-07-24 18:02:05 +02:00
										 |  |  |             continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (!(setting & ESP_NAME)) | 
					
						
							| 
									
										
										
										
											2023-07-23 14:36:44 +02:00
										 |  |  |             continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-21 02:30:15 -04:00
										 |  |  |         vec3_t name_pos = vec3(ent->origin.x, ent->origin.y, ent->origin.z + bh + 5); | 
					
						
							|  |  |  |         vec2_t s_name_pos; | 
					
						
							|  |  |  |         if (world_to_screen(name_pos, s_name_pos)) { | 
					
						
							|  |  |  |             engine_draw_text(s_name_pos[0] - 5, s_name_pos[1] - 2, get_name(ent->index), (rgb_t){ 255, 255, 255 }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-07-22 16:05:47 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } |