From 1778dd16217cabe8f29b5a938f12babd32659250 Mon Sep 17 00:00:00 2001 From: julianacat Date: Fri, 18 Aug 2017 16:16:22 -0500 Subject: [PATCH] Sightline Improvements --- src/colors.cpp | 23 ++++++++++++++++++ src/cvwrapper.cpp | 4 ++++ src/cvwrapper.h | 17 +++++++++++--- src/hacks/ESP.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 96 insertions(+), 8 deletions(-) diff --git a/src/colors.cpp b/src/colors.cpp index 89e93acc..69fa6d44 100644 --- a/src/colors.cpp +++ b/src/colors.cpp @@ -7,6 +7,14 @@ #include "common.h" +CatVar user_red_blue(CV_INT, "esp_color_red_blue", "0", "Red: Blue", "Blue color for red team", 255); +CatVar user_red_green(CV_INT, "esp_color_red_green", "0", "Red: Green", "Green color for red team", 255); +CatVar user_red_red(CV_INT, "esp_color_red_red", "0", "Red: Red", "Red color for red team", 255); + +CatVar user_blue_blue(CV_INT, "esp_color_blue_blue", "0", "Blue: Blue", "Blue color for blue team", 255); +CatVar user_blue_green(CV_INT, "esp_color_blue_green", "0", "Blue: Green", "Green color for blue team", 255); +CatVar user_blue_red(CV_INT, "esp_color_blue_red", "0", "Blue: Red", "Red color for blue team", 255); + rgba_t colors::EntityF(CachedEntity* ent) { rgba_t result, plclr; int skin; @@ -54,6 +62,21 @@ rgba_t colors::EntityF(CachedEntity* ent) { if (ent->m_Type == ENTITY_PLAYER || ent->m_Type == ENTITY_BUILDING) { if (ent->m_iTeam == TEAM_BLU) result = blu; else if (ent->m_iTeam == TEAM_RED) result = red; + // If user has custom color, check if we should change, and do so here + if (user_red_blue || user_red_green || user_red_red || user_blue_blue || user_blue_green || user_blue_red) { + switch(ent->m_iTeam) { + case TEAM_BLU: + if (user_blue_blue || user_blue_green || user_blue_red) { + result = FromRGBA8(user_blue_red, user_blue_green, user_blue_blue, 255); + } + break; + case TEAM_RED: + if (user_red_blue || user_red_green || user_red_red) { + result = FromRGBA8(user_red_red, user_red_green, user_red_blue, 255); + } + break; + } + } if (ent->m_Type == ENTITY_PLAYER) { if (IsPlayerInvulnerable(ent)) { if (ent->m_iTeam == TEAM_BLU) result = blu_u; diff --git a/src/cvwrapper.cpp b/src/cvwrapper.cpp index b70cd9f9..6f93ef66 100644 --- a/src/cvwrapper.cpp +++ b/src/cvwrapper.cpp @@ -170,12 +170,14 @@ void CatVar::Register() { registered = true; } +// TODO, reverse void CatVar::InstallChangeCallback(FnChangeCallback_t callback) { OnRegister([callback](CatVar* var) { var->convar_parent->InstallChangeCallback(callback); }); } +// Used during int to setup catvars void RegisterCatVars() { while (registrationArray().size()) { CatVar* var = registrationArray().back(); @@ -184,12 +186,14 @@ void RegisterCatVars() { } } +// Use when creating a CatEnum for use in a CatVar CatEnum::CatEnum(std::vector values, int min) : value_names(values) { min_value = min; max_value = min + int(values.size()) - 1; size = int(values.size()); } +// use to get a name from a CatEnum std::string CatEnum::Name(int value) { if (value >= min_value && value < max_value) { return value_names.at(unsigned(value) - unsigned(min_value)); diff --git a/src/cvwrapper.h b/src/cvwrapper.h index aa0602d3..de4ca1d6 100644 --- a/src/cvwrapper.h +++ b/src/cvwrapper.h @@ -19,6 +19,7 @@ class ConVar; #include #include "aftercheaders.h" +// Catvar types enum CatVar_t { CV_SWITCH, CV_INT, @@ -28,6 +29,8 @@ enum CatVar_t { CV_KEY }; +// TODO reverse +// Enum Something class CatEnum { public: CatEnum(std::vector values, int min = 0); @@ -39,6 +42,7 @@ public: int size; }; +// TODO reverse, no idea how catcommands are handled class CatCommand { public: CatCommand(std::string name, std::string help, FnCommandCallback_t callback); @@ -55,10 +59,10 @@ public: ConCommand* cmd { nullptr }; }; -void RegisterCatCommands(); + class CatVar { -public: +public: // TODo, unknown reverse CatVar(CatVar_t type, std::string name, std::string defaults, std::string desc_short, std::string desc_long = "no description"); CatVar(CatVar_t type, std::string name, std::string defaults, std::string desc_short, std::string desc_long, float max_val); CatVar(CatVar_t type, std::string name, std::string defaults, std::string desc_short, std::string desc_long, float min_val, float max_val); @@ -98,6 +102,7 @@ public: return current_base; } +// Storage for the catvar public: const CatVar_t type; const std::string name; @@ -122,10 +127,16 @@ public: static int last_id; }; +// TODO, find out what this formatting does "std::vector& ArrayName()?" + +// needed for registration std::vector& registrationArray(); std::vector& commandRegistrationArray(); - +// List to store catvars std::vector& CatVarList(); + +// Setup commands probs needed at int +void RegisterCatCommands(); void RegisterCatVars(); int GetRebasedCatVarCount(); diff --git a/src/hacks/ESP.cpp b/src/hacks/ESP.cpp index b0edb5f7..665a1cda 100644 --- a/src/hacks/ESP.cpp +++ b/src/hacks/ESP.cpp @@ -319,18 +319,68 @@ void _FASTCALL ProcessEntityPT(CachedEntity* ent) { float cy = cosf(DEG2RAD(eye_angles.y)); float sp = sinf(DEG2RAD(eye_angles.x)); // pitch float cp = cosf(DEG2RAD(eye_angles.x)); - Vector forward = Vector(cp * cy, cp * sy, -sp); + Vector forward_t = Vector(cp * cy, cp * sy, -sp); // We dont want the sightlines endpoint to go behind us because the world to screen check will fail, but keep it at most 4096 - forward = forward * min(ent->m_flDistance - 1, 4096) + eye_position; + Vector forward = forward_t * 4096.0F + eye_position; Ray_t ray; ray.Init(eye_position, forward); trace_t trace; g_ITrace->TraceRay(ray, MASK_SHOT_HULL, &trace::filter_no_player, &trace); + // Screen vectors Vector scn1, scn2; - if (draw::WorldToScreen(eye_position, scn1) && draw::WorldToScreen(trace.endpos, scn2)) { - drawgl::Line(scn1.x, scn1.y, scn2.x - scn1.x, scn2.y - scn1.y, fg); - } + + // Status vars + bool found_scn2 = true; + + // Get end point on screen + if (!draw::WorldToScreen(trace.endpos, scn2)) { + // Set status + found_scn2 = false; + // Get the end distance from the trace + float end_distance = trace.endpos.DistTo(eye_position); + + // Loop and look back untill we have a vector on screen + for (int i = 1; i > 30; i++) { + // Subtract 40 multiplyed by the tick from the end distance and use that as our length to check + Vector end_vector = forward_t * (end_distance - (40 * i)) + eye_position; + if (end_vector.DistTo(eye_position) < 40) break; + if (draw::WorldToScreen(end_vector, scn2)) { + found_scn2 = true; + break; + } + } + } + + if (found_scn2) { + // Set status + bool found_scn1 = true; + + // If we dont have a vector on screen, attempt to find one + if (!draw::WorldToScreen(eye_position, scn1)) { + // Set status + found_scn1 = false; + // Get the end distance from the trace + float start_distance = trace.endpos.DistTo(eye_position); + + // Loop and look back untill we have a vector on screen + for (int i = 1; i > 30; i++) { + // Multiply starting distance by 40, multiplyed by the loop tick + Vector start_vector = forward_t * (40 * i) + eye_position; + // We dont want it to go too far + if (start_vector.DistTo(trace.endpos) < 40) break; + // Check if we have a vector on screen, if we do then we set our status + if (draw::WorldToScreen(start_vector, scn1)) { + found_scn1 = true; + break; + } + } + } + // We have both vectors, draw + if (found_scn1) { + drawgl::Line(scn1.x, scn1.y, scn2.x - scn1.x, scn2.y - scn1.y, fg); + } + } } }