Untitled
unknown
plain_text
21 days ago
5.2 kB
2
Indexable
// CS2 Bone Data Extraction + Optimized ESP Drawing Code using Path Batching // Efficient internal DX11 overlay using Nuklear — reduced rendering overhead #include "nuklear.h" #include <windows.h> #include <stdio.h> #include <stdbool.h> struct Vector3 { float x, y, z; }; struct matrix3x4_t { float m[3][4]; }; Vector3 get_bone_position(uintptr_t entity_base, int bone_index) { uintptr_t bone_array_ptr = *(uintptr_t*)(entity_base + 0x1E0); // update offset as needed if (!bone_array_ptr) return { 0, 0, 0 }; matrix3x4_t bone = *(matrix3x4_t*)(bone_array_ptr + bone_index * sizeof(matrix3x4_t)); return { bone.m[0][3], bone.m[1][3], bone.m[2][3] }; } void get_player_bones(uintptr_t entity_base, Vector3 out_bones[32]) { for (int i = 0; i < 32; ++i) { out_bones[i] = get_bone_position(entity_base, i); } } extern bool WorldToScreen(const Vector3& world, struct nk_vec2& screen); static struct nk_font *custom_font = NULL; void setup_custom_font(struct nk_context* ctx) { struct nk_font_atlas *atlas; nk_d3d11_font_stash_begin(&atlas); custom_font = nk_font_atlas_add_from_file(atlas, "C:\\Windows\\Fonts\\arial.ttf", 14.0f, 0); nk_d3d11_font_stash_end(); if (custom_font) { nk_style_set_font(ctx, &custom_font->handle); } } void draw_player_esp(struct nk_context* ctx, const char* name, float distance, float health, float max_health, struct nk_vec2 head, struct nk_vec2 feet, struct nk_vec2 bone_screen[32], int bone_count, bool is_visible) { struct nk_command_buffer* canvas = nk_window_get_canvas(ctx); float height = feet.y - head.y; float width = height / 2.0f; float x = head.x - width / 2.0f; float y = head.y; struct nk_color color = is_visible ? nk_rgb(0, 255, 0) : nk_rgb(255, 0, 0); float thickness = 1.5f; float len = width * 0.25f; // ---- Corner Box batched ---- nk_path_begin(canvas, NK_STROKE_OPEN); nk_path_line_to(canvas, x, y); nk_path_line_to(canvas, x + len, y); nk_path_line_to(canvas, x, y); nk_path_line_to(canvas, x, y + len); nk_path_line_to(canvas, x + width, y); nk_path_line_to(canvas, x + width - len, y); nk_path_line_to(canvas, x + width, y); nk_path_line_to(canvas, x + width, y + len); nk_path_line_to(canvas, x, y + height); nk_path_line_to(canvas, x + len, y + height); nk_path_line_to(canvas, x, y + height); nk_path_line_to(canvas, x, y + height - len); nk_path_line_to(canvas, x + width, y + height); nk_path_line_to(canvas, x + width - len, y + height); nk_path_line_to(canvas, x + width, y + height); nk_path_line_to(canvas, x + width, y + height - len); nk_path_stroke(canvas, color, NK_STROKE_SOLID, thickness); // ---- Health Bar ---- float bar_width = 4.0f; float bar_x = x - 6.0f; float ratio = health / max_health; float filled = height * ratio; nk_fill_rect(canvas, nk_rect(bar_x, y, bar_width, height), 0, nk_rgb(50, 50, 50)); nk_fill_rect(canvas, nk_rect(bar_x, y + (height - filled), bar_width, filled), 0, nk_rgb(0, 255, 0)); char hp_text[16]; snprintf(hp_text, sizeof(hp_text), "%.1f", health); nk_draw_text(canvas, nk_rect(bar_x - 8, y + height + 2, 40, 16), hp_text, (int)strlen(hp_text), custom_font ? &custom_font->handle : ctx->style.font, nk_rgb(0,0,0), nk_rgb(255,255,255)); // ---- Head Cross ---- float cross_len = 5.0f; nk_path_begin(canvas, NK_STROKE_OPEN); nk_path_line_to(canvas, head.x - cross_len, head.y); nk_path_line_to(canvas, head.x + cross_len, head.y); nk_path_line_to(canvas, head.x, head.y - cross_len); nk_path_line_to(canvas, head.x, head.y + cross_len); nk_path_stroke(canvas, color, NK_STROKE_SOLID, 1.0f); // ---- Name + Distance ---- char label[64]; snprintf(label, sizeof(label), "%s [%.0f]", name, distance); nk_draw_text(canvas, nk_rect(x + width / 2 - 50, y - 16, 100, 16), label, (int)strlen(label), custom_font ? &custom_font->handle : ctx->style.font, nk_rgb(0,0,0), nk_rgb(255,255,255)); // ---- Skeleton batched ---- const int bone_pairs[][2] = { {6, 5}, {5, 4}, {4, 2}, {5,13}, {13,14}, {14,15}, {5,17}, {17,18}, {18,19}, {2,25}, {25,26}, {26,27}, {2,29}, {29,30}, {30,31} }; int num_pairs = sizeof(bone_pairs) / sizeof(bone_pairs[0]); nk_path_begin(canvas, NK_STROKE_OPEN); for (int i = 0; i < num_pairs; i++) { int a = bone_pairs[i][0]; int b = bone_pairs[i][1]; if (a < bone_count && b < bone_count) { nk_path_line_to(canvas, bone_screen[a].x, bone_screen[a].y); nk_path_line_to(canvas, bone_screen[b].x, bone_screen[b].y); } } nk_path_stroke(canvas, color, NK_STROKE_SOLID, 1.0f); } // Use WorldToScreen() to convert 3D bone positions to bone_screen[32] before calling draw_player_esp()
Editor is loading...
Leave a Comment