Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ESP.h"
- #include "..\..\Utils\GlobalVars.h"
- #include "..\Aimbot\Aimbot.h"
- #include "..\Aimbot\LagComp.h"
- #include "..\..\Utils\Utils.h"
- #include "..\..\SDK\IVEngineClient.h"
- #include "..\..\SDK\PlayerInfo.h"
- #include "..\..\SDK\ISurface.h"
- #include "..\..\SDK\Hitboxes.h"
- #include "..\..\Utils\Math.h"
- #include "..\..\Menu\Menu.h"
- #include "..\Misc\Misc.h"
- #include "..\..\Utils\Interfaces.h"
- #include <stdio.h>
- #include <ctype.h>
- #include <comdef.h>
- #include "../../SDK/vector2d.h"
- #include <windows.h>
- #include <iostream>
- #include <cstdint>
- #include <memory>
- #include <vector>
- #include <thread>
- #include <chrono>
- #include <array>
- #include <fstream>
- #include <istream>
- #include <unordered_map>
- #include <intrin.h>
- #define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
- float flPlayerAlpha[1024];
- std::string clean_item_name(std::string name) {
- std::string Name = name;
- auto weapon_start = Name.find("weapon");
- if (weapon_start != std::string::npos)
- Name.erase(Name.begin() + weapon_start, Name.begin() + weapon_start + 6);
- if (Name[0] == '_')
- Name.erase(Name.begin());
- if (Name[0] == 'c') //optional for dropped weapons - designer
- Name.erase(Name.begin());
- return Name;
- }
- bool WorldToScreen(const Vector& world, Vector& screen) {
- auto screen_transform = [&world, &screen]() -> bool {
- static auto &matrix = g_pEngine->WorldToScreenMatrix();
- screen.x = matrix[0][0] * world.x + matrix[0][1] * world.y + matrix[0][2] * world.z + matrix[0][3];
- screen.y = matrix[1][0] * world.x + matrix[1][1] * world.y + matrix[1][2] * world.z + matrix[1][3];
- screen.z = 0.0f;
- float w = matrix[3][0] * world.x + matrix[3][1] * world.y + matrix[3][2] * world.z + matrix[3][3];
- if (w < 0.001f) {
- screen.x *= 100000;
- screen.y *= 100000;
- return false;
- }
- screen.x /= w;
- screen.y /= w;
- return true;
- };
- if (screen_transform()) {
- int w, h;
- g_pEngine->GetScreenSize(w, h);
- screen.x = (w / 2.0f) + (screen.x * w) / 2.0f;
- screen.y = (h / 2.0f) - (screen.y * h) / 2.0f;
- return true;
- }
- return false;
- }
- float StoredCurtimePlayer[1024];
- #define MIN(a,b) ((a) < (b) ? (a) : (b))
- #include <minwindef.h>
- void c_visuals::BoxESP(C_BaseEntity* Entity) {
- Vector min, max;
- Entity->GetRenderBounds(min, max);
- Vector pos, pos3D, top, top3D;
- pos3D = Entity->GetAbsOrigin() - Vector(0, 0, 10);
- top3D = pos3D + Vector(0, 0, max.z + 11);
- Color ESP = Color(g_Menu.Config.BoxColor.red, g_Menu.Config.BoxColor.green, g_Menu.Config.BoxColor.blue, flPlayerAlpha[Entity->EntIndex()]);
- Color ESP2 = Color(0, 0, 0, flPlayerAlpha[Entity->EntIndex()]);
- if (WorldToScreen(pos3D, pos) && WorldToScreen(top3D, top))
- {
- int height = (pos.y - top.y);
- int y = top.y;
- int width = height / 2;
- int x = pos.x - ((width / 2) / 2);
- int x2 = pos.x - (width / 2);
- int h = height;
- int w = width / 2;
- int iw = w / 3.5;
- int ih = (h / 3.5) - 1;
- bool IsTeammate = Entity->GetTeam() == g::pLocalEntity->GetTeam();
- bool IsEnemy = Entity->GetTeam() != g::pLocalEntity->GetTeam();
- bool IsLocal = Entity == g::pLocalEntity;
- if (IsEnemy) {
- g_pSurface->OutlinedRect(x2, y, width, height, ESP);
- g_pSurface->OutlinedRect(x2 - 1, y - 1, width + 2, height + 2, ESP2);
- g_pSurface->OutlinedRect(x2 + 1, y + 1, width - 2, height - 2, ESP2);
- }
- }
- }
- void c_visuals::set_hitmarker_time(float time)
- {
- float flHurtTime = 0.f;
- flHurtTime = time;
- }
- void set_dormant_time(float time)
- {
- float dormanttime = 0.f;
- dormanttime = time;
- }
- void c_visuals::spec()
- {
- auto local_player = g_pEntityList->GetClientEntity(g_pEngine->GetLocalPlayer());
- if (!local_player)
- return;
- if (local_player->GetHealth() <= 0)
- return;
- static int lineSize = 4.25;
- static float alpha = 0;
- float step = 255.f / 0.3f *g_pGlobalVars->frametime;
- float flHurtTime = 0.f;
- if (g_pGlobalVars->realtime - flHurtTime < .3f)
- alpha = 255.f;
- else
- alpha -= step;
- if (alpha > 0)
- {
- int screenSizeX, screenCenterX;
- int screenSizeY, screenCenterY;
- g_pEngine->GetScreenSize(screenSizeX, screenSizeY);
- screenCenterX = screenSizeX / 2;
- screenCenterY = screenSizeY / 2;
- Color col = Color(240, 240, 240, alpha);
- g_pSurface->Line(screenCenterX - lineSize * 2, screenCenterY - lineSize * 2, screenCenterX - (lineSize), screenCenterY - (lineSize), col);
- g_pSurface->Line(screenCenterX - lineSize * 2, screenCenterY + lineSize * 2, screenCenterX - (lineSize), screenCenterY + (lineSize), col);
- g_pSurface->Line(screenCenterX + lineSize * 2, screenCenterY + lineSize * 2, screenCenterX + (lineSize), screenCenterY + (lineSize), col);
- g_pSurface->Line(screenCenterX + lineSize * 2, screenCenterY - lineSize * 2, screenCenterX + (lineSize), screenCenterY - (lineSize), col);
- }
- }
- void c_visuals::indicators2()
- {
- }
- void c_visuals::NameESP(C_BaseEntity* Entity) {
- Vector min, max;
- Entity->GetRenderBounds(min, max);
- Vector pos, pos3D, top, top3D;
- pos3D = Entity->GetAbsOrigin() - Vector(0, 0, 10);
- top3D = pos3D + Vector(0, 0, max.z + 11);
- PlayerInfo_s EntityInfo;
- g_pEngine->GetPlayerInfo(Entity->EntIndex(), &EntityInfo);
- Color ESP = Entity->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[Entity->EntIndex()]) : Color(g_Menu.Config.NameColor.red, g_Menu.Config.NameColor.green, g_Menu.Config.NameColor.blue, flPlayerAlpha[Entity->EntIndex()]);
- Color ESP2 = Entity->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[Entity->EntIndex()]) : Color(0, 0, 0, flPlayerAlpha[Entity->EntIndex()]);
- if (WorldToScreen(pos3D, pos) && WorldToScreen(top3D, top))
- {
- int height = (pos.y - top.y);
- int y = top.y;
- int width = height / 2;
- int x = pos.x - (width / 2);
- g_pSurface->DrawT(x + (width / 2), y - 14, ESP, g::EspTahoma, true, EntityInfo.szName);
- }
- }
- mstudiobbox_t* get_hitbox(C_BaseEntity* entity, int hitbox_index)
- {
- if (entity->IsDormant() || entity->GetHealth() <= 0)
- return NULL;
- const auto pModel = entity->GetModel();
- if (!pModel)
- return NULL;
- auto pStudioHdr = g_pModelInfo->GetStudiomodel(pModel);
- if (!pStudioHdr)
- return NULL;
- auto pSet = pStudioHdr->GetHitboxSet(0);
- if (!pSet)
- return NULL;
- if (hitbox_index >= pSet->numhitboxes || hitbox_index < 0)
- return NULL;
- return pSet->GetHitbox(hitbox_index);
- }
- Vector GetHitboxPosition(C_BaseEntity* entity, int hitbox_id)
- {
- auto hitbox = get_hitbox(entity, hitbox_id);
- if (!hitbox)
- return Vector(0, 0, 0);
- auto bone_matrix = entity->GetBoneMatrix(hitbox->bone);
- Vector bbmin, bbmax;
- g_Math.VectorTransform(hitbox->min, bone_matrix, bbmin);
- g_Math.VectorTransform(hitbox->max, bone_matrix, bbmax);
- return (bbmin + bbmax) * 0.5f;
- }
- void c_visuals::QuakeKillCounter()
- {
- if (!g_pEngine->IsInGame() || !g_pEngine->IsConnected()) return;
- int screen_sizex, screen_sizey, cW, cH;
- g_pEngine->GetScreenSize(screen_sizex, screen_sizey);
- cW = screen_sizex / 2;
- cH = screen_sizey / 2;
- float animationAlpha = 0.0;
- int alpha = 0;
- float animation_speed_value = 0.6;
- float step = 255 / 0.6 * g_pGlobalVars->frametime;
- if (g::killtime + 2 > g_pGlobalVars->realtime)
- {
- alpha = 255;
- }
- else
- alpha = alpha - step;
- float animate = g_pGlobalVars->curtime;
- float endTime = g::globalAlpha + 1.1f;
- float t = 1.0f - (endTime - g_pGlobalVars->curtime) / (endTime - g::globalAlpha);
- float animationStep = animation_speed_value * g_pGlobalVars->frametime;
- /*if (g::killtime + 0.1 > g_pGlobalVars->realtime)
- {
- animationAlpha -= 80;
- }
- else*/
- animationAlpha = animationAlpha - animationStep;
- int customY, customX;
- screen_sizey = (screen_sizey / 2) - (t * (20.0f));
- screen_sizex = (screen_sizex / 2) - (t * (20.0f));
- if (alpha > 0)
- {
- switch (g::kills)
- {
- case 1:
- g_pSurface->DrawT(screen_sizex, screen_sizey, Color(255, 0, 0, alpha), g::Indicators, true, "FIRST BLOOD");
- break;
- case 2:
- g_pSurface->DrawT(screen_sizex, screen_sizey, Color(0, 0, 255, alpha), g::Indicators, true, "DOUBLE KILL");
- break;
- case 3:
- g_pSurface->DrawT(screen_sizex, screen_sizey, Color(0, 255, 0, alpha), g::Indicators, true, "TRIPLE KILL");
- break;
- case 4:
- g_pSurface->DrawT(screen_sizex, screen_sizey, Color(155, 200, 0, alpha), g::Indicators, true, "MULTI KILL");
- break;
- case 5:
- g_pSurface->DrawT(screen_sizex, screen_sizey, Color(200, 0, 167, alpha), g::Indicators, true, "ULTRA KILL");
- break;
- case 6:
- g_pSurface->DrawT(screen_sizex, screen_sizey, Color(23, 34, 255, alpha), g::Indicators, true, "KILLING SPREE");
- break;
- default:
- g_pSurface->DrawT(screen_sizex, screen_sizey, Color(23, 34, 255, alpha), g::Indicators, true, "HUMILIATION");
- break;
- }
- }
- }
- bool IsOnScreen(Vector origin, Vector& screen)
- {
- if (!WorldToScreen(origin, screen)) return false;
- int iScreenWidth, iScreenHeight;
- g_pEngine->GetScreenSize(iScreenWidth, iScreenHeight);
- bool xOk = iScreenWidth > screen.x > 0, yOk = iScreenHeight > screen.y > 0;
- return xOk && yOk;
- }
- void TexturedPolygon(int n, std::vector<Vertex_t> vertice, Color color)
- {
- static int texture_id = g_pSurface->CreateNewTextureID(true); //
- static unsigned char buf[4] = { 255, 255, 255, 255 };
- g_pSurface->DrawSetTextureRGBA(texture_id, buf, 1, 1); //
- g_pSurface->DrawSetColor(color); //
- g_pSurface->DrawSetTexture(texture_id); //
- g_pSurface->DrawTexturedPolygon(n, vertice.data()); //
- }
- #include <map>
- bool DisplayAmmo[65];
- void c_visuals::WeaponESP(C_BaseEntity* Entity) {
- Vector min, max;
- Entity->GetRenderBounds(min, max);
- Vector pos, pos3D, top, top3D;
- pos3D = Entity->GetAbsOrigin() - Vector(0, 0, 10);
- top3D = pos3D + Vector(0, 0, max.z + 11);
- //spectators();
- auto Weapon = Entity->GetActiveWeapon();
- Color ESP = Entity->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[Entity->EntIndex()]) : Color(g_Menu.Config.WeaponColor.red, g_Menu.Config.WeaponColor.green, g_Menu.Config.WeaponColor.blue, flPlayerAlpha[Entity->EntIndex()]);
- Color ESP2 = Entity->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[Entity->EntIndex()]) : Color(0, 0, 0, flPlayerAlpha[Entity->EntIndex()]);
- if (WorldToScreen(pos3D, pos) && WorldToScreen(top3D, top))
- {
- int height = (pos.y - top.y);;
- int y = top.y;
- int width = height / 2;
- int x = pos.x - (width / 2);
- if (!Weapon)
- return;
- auto weapon_data = Weapon->GetCSWpnData();
- auto item_definition_index = Weapon->GetItemDefinitionIndex();
- if (!weapon_data)
- return;
- const auto xposition = x + (width / 2);
- const auto yposition = y + height + 1;
- bool IsTeammate = Entity->GetTeam() == g::pLocalEntity->GetTeam();
- bool IsEnemy = Entity->GetTeam() != g::pLocalEntity->GetTeam();
- bool IsLocal = Entity == g::pLocalEntity;
- int TypeOfEntity;
- if (IsLocal) {
- }
- else if (IsEnemy) {
- }
- else if (IsTeammate) {
- }
- auto add = g_Menu.Config.ammo && DisplayAmmo[Entity->EntIndex()] ? 5 : 0;
- auto DrawWeaponIcon = [Weapon, xposition, yposition, IsLocal, IsEnemy, IsTeammate, add, ESP]() -> bool
- {
- char icon_letter = '\0';
- if (IsEnemy && !g_Menu.Config.Weapon) {
- return false;
- }
- switch (reinterpret_cast<C_BaseCombatWeapon*>(Weapon)->GetItemDefinitionIndex())
- {
- case ItemDefinitionIndex::WEAPON_DEAGLE:
- icon_letter = 'A';
- break;
- case ItemDefinitionIndex::WEAPON_KNIFE:
- case ItemDefinitionIndex::WEAPON_KNIFE_T:
- icon_letter = '[';
- break;
- case ItemDefinitionIndex::WEAPON_AUG:
- icon_letter = 'U';
- break;
- case ItemDefinitionIndex::WEAPON_AWP:
- icon_letter = 'Z';
- break;
- case ItemDefinitionIndex::WEAPON_REVOLVER:
- icon_letter = 'J';
- break;
- case ItemDefinitionIndex::WEAPON_G3SG1:
- icon_letter = 'X';
- break;
- case ItemDefinitionIndex::WEAPON_MAC10:
- icon_letter = 'K';
- break;
- case ItemDefinitionIndex::WEAPON_P90:
- icon_letter = 'P';
- break;
- case ItemDefinitionIndex::WEAPON_SSG08:
- icon_letter = 'a';
- break;
- case ItemDefinitionIndex::WEAPON_SCAR20:
- icon_letter = 'Y';
- break;
- case ItemDefinitionIndex::WEAPON_UMP45:
- icon_letter = 'L';
- break;
- case ItemDefinitionIndex::WEAPON_ELITE:
- icon_letter = 'B';
- break;
- case ItemDefinitionIndex::WEAPON_FAMAS:
- icon_letter = 'R';
- break;
- case ItemDefinitionIndex::WEAPON_FIVESEVEN:
- icon_letter = 'C';
- break;
- case ItemDefinitionIndex::WEAPON_GALILAR:
- icon_letter = 'Q';
- break;
- case ItemDefinitionIndex::WEAPON_M4A1:
- icon_letter = 'S';
- break;
- case ItemDefinitionIndex::WEAPON_P250:
- icon_letter = 'F';
- break;
- case ItemDefinitionIndex::WEAPON_M249:
- icon_letter = 'g';
- break;
- case ItemDefinitionIndex::WEAPON_XM1014:
- icon_letter = 'b';
- break;
- case ItemDefinitionIndex::WEAPON_C4:
- icon_letter = 'o';
- break;
- case ItemDefinitionIndex::WEAPON_GLOCK:
- icon_letter = 'D';
- break;
- case ItemDefinitionIndex::WEAPON_HKP2000:
- icon_letter = 'G';
- case ItemDefinitionIndex::WEAPON_TASER:
- icon_letter = 'h';
- case ItemDefinitionIndex::WEAPON_AK47:
- icon_letter = 'W';
- break;
- default:
- return false;
- }
- char buffer[2] = { icon_letter, '\0' };
- auto weapon_data = Weapon->GetCSWpnData();
- g_pSurface->DrawT(xposition, yposition + 10 + add, ESP, g::WeaponIcons, true, buffer);
- std::string WeaponName = weapon_data->hud_name;
- WeaponName.erase(0, 13);
- std::transform(WeaponName.begin(), WeaponName.end(), WeaponName.begin(), ::toupper);
- g_pSurface->DrawT(xposition, yposition + add, ESP, g::EspTahoma, true, WeaponName.c_str());
- return true;
- };
- if (!DrawWeaponIcon())
- {
- std::string WeaponName = weapon_data->hud_name;
- WeaponName.erase(0, 13);
- std::transform(WeaponName.begin(), WeaponName.end(), WeaponName.begin(), ::toupper);
- g_pSurface->DrawT(xposition, yposition + add, ESP, g::EspTahoma, true, WeaponName.c_str());
- }
- }
- }
- void c_visuals::Ammo(C_BaseEntity* Entity) {
- Vector min, max;
- Entity->GetRenderBounds(min, max);
- Vector pos, pos3D, top, top3D;
- pos3D = Entity->GetAbsOrigin() - Vector(0, 0, 10);
- top3D = pos3D + Vector(0, 0, max.z + 11);
- //spectators();
- Color ESP = Entity->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[Entity->EntIndex()]) : Color(81, 140, 201, flPlayerAlpha[Entity->EntIndex()]);
- Color ESP2 = Entity->IsDormant() ? Color(0, 0, 0, flPlayerAlpha[Entity->EntIndex()]) : Color(0, 0, 0, flPlayerAlpha[Entity->EntIndex()]);
- auto Weapon = Entity->GetActiveWeapon();
- if (WorldToScreen(pos3D, pos) && WorldToScreen(top3D, top) && Weapon)
- {
- int height = (pos.y - top.y);;
- int y = top.y;
- int width2 = height / 2;
- int x = pos.x - (width2 / 2);
- float offset = (height / 4.f) + 5;
- UINT hp = height - (UINT)((height * 3) / 100);
- auto animLayer = Entity->GetAnimOverlay4(1);
- if (!animLayer)
- return;
- auto activity = Entity->GetSequenceActivity(animLayer->m_nSequence);
- if (!activity)
- return;
- int iClip = Weapon->GetAmmo();
- int iClipMax = Weapon->GetCSWpnData()->max_clip;
- if (!animLayer || !activity) {
- DisplayAmmo[Entity->EntIndex()] = false;
- return;
- }
- float box_w = (float)fabs(height / 2);
- float width;
- DisplayAmmo[Entity->EntIndex()] = iClip > 0 || (activity == 967 && animLayer->m_flWeight != 0.f);
- if (activity == 967 && animLayer->m_flWeight != 0.f)
- {
- float cycle = animLayer->m_flCycle;
- width = (((box_w * cycle) / 1.f));
- }
- else
- width = (((box_w * iClip) / iClipMax));
- if (!DisplayAmmo[Entity->EntIndex()])
- return;
- g_pSurface->FilledRect(x, y + height + 2, box_w, 4, ESP2);
- g_pSurface->FilledRect(x, y + height + 2, width, 4, Color(ESP));
- g_pSurface->OutlinedRect(x, y + height + 2, box_w, 4, ESP2);
- }
- }
- void c_visuals::HealthESP(C_BaseEntity* Entity) {
- Vector min, max;
- Entity->GetRenderBounds(min, max);
- Vector pos, pos3D, top, top3D;
- pos3D = Entity->GetAbsOrigin() - Vector(0, 0, 10);
- top3D = pos3D + Vector(0, 0, max.z + 11);
- Color ESP = Entity->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[Entity->EntIndex()]) : Color(0, 255, 0, flPlayerAlpha[Entity->EntIndex()]);
- Color ESP2 = Entity->IsDormant() ? Color(0, 0, 0, flPlayerAlpha[Entity->EntIndex()]) : Color(0, 0, 0, flPlayerAlpha[Entity->EntIndex()]);
- if (WorldToScreen(pos3D, pos) && WorldToScreen(top3D, top))
- {
- int height = (pos.y - top.y);
- int width = height / 2;
- int x = pos.x - (width / 2);
- int y = top.y;
- auto health = Entity->GetHealth();
- int Style = g_Menu.Config.Health;
- if (Style)/*Whats a switch statement?*/
- {
- int pixel_value = Entity->GetHealth() * height / 100;
- g_pSurface->FilledRect(x - 6, y - 1, 4, height + 2, ESP2);
- g_pSurface->FilledRect(x - 5, y + height - pixel_value, 2, pixel_value, ESP);
- g_pSurface->DrawT(x - 8, y + height - pixel_value, Color(255, 255, 255), g::EspTahoma, true, "%d", Entity->GetHealth());
- }
- }
- }
- inline void CrossProduct2(const Vector& a, const Vector& b, Vector& result)
- {
- CHECK_VALID(a);
- CHECK_VALID(b);
- Assert(&a != &result);
- Assert(&b != &result);
- result.x = a.y * b.z - a.z * b.y;
- result.y = a.z * b.x - a.x * b.z;
- result.z = a.x * b.y - a.y * b.x;
- }
- void CalcAngle2(Vector src, Vector dst, Vector& angles)
- {
- Vector delta = src - dst;
- double hyp = delta.Length2D(); //delta.Length
- angles.y = (atan(delta.y / delta.x) * 57.295779513082f);
- angles.x = (atan(delta.z / hyp) * 57.295779513082f);
- angles[2] = 0.00;
- if (delta.x >= 0.0)
- angles.y += 180.0f;
- }
- #include "../../SDK/vector2d.h"
- #include <windows.h>
- #include <iostream>
- #include <cstdint>
- #include <memory>
- #include <vector>
- #include <thread>
- #include <chrono>
- #include <array>
- #include <fstream>
- #include <istream>
- #include <unordered_map>
- #include <intrin.h>
- void rotate(std::array< vec2_t, 3 > & points, float rotation)
- {
- const auto points_center = (points.at(0) + points.at(1) + points.at(2)) / 3;
- for (auto& point : points) {
- point -= points_center;
- const auto temp_x = point.x;
- const auto temp_y = point.y;
- const auto theta = DEG2RAD(rotation);
- const auto c = cos(theta);
- const auto s = sin(theta);
- point.x = temp_x * c - temp_y * s;
- point.y = temp_x * s + temp_y * c;
- point += points_center;
- }
- }
- float meme = 0.f;
- int arrow_alpha[65];
- template <typename t> t clamp_value(t value, t min, t max) {
- if (value > max) {
- return max;
- }
- if (value < min) {
- return min;
- }
- return value;
- }
- void arrows(C_BaseEntity* player) {
- auto local = g::pLocalEntity;
- // another case of unnecessary float divison. gotta watch out for that guys! ~chance
- // const int fade = ( int )( ( ( 1 / 0.25f ) * interfaces::globals->frame_time ) * 255 );
- const int fade = (int)((4 * g_pGlobalVars->frametime) * 255);
- // if (!elements::get().vis_arrows)
- // return;
- if (!local)
- return;
- if (!local->IsAlive())
- return;
- if (!player)
- return;
- if (player->IsDormant())
- return;
- arrow_alpha[player->EntIndex()] = 255;
- Vector position;
- if (WorldToScreen(GetHitboxPosition(player, 2), position))
- return;
- Vector viewangles;
- int width, height;
- g_pEngine->GetViewAngles(viewangles);
- g_pEngine->GetScreenSize(width, height);
- // more float division, i'm just gonna stop putting comments next to it at this point xD. ~chance
- // const auto screen_center = vec2_t( width / 2.f, height / 2.f );
- const auto screen_center = vec2_t(width * .5f, height * .5f);
- const auto angle_yaw_rad = DEG2RAD(viewangles.y - g_Math.CalcAngle(local->GetEyePosition(), GetHitboxPosition(player, 2)).y - 90);
- int radius = 20;
- int size = 10;
- const auto new_point_x = screen_center.x + ((((width - (size * 3)) * .5f) * (radius / 100.0f)) * cos(angle_yaw_rad)) + (int)(6.0f * (((float)size - 4.f) / 16.0f));
- const auto new_point_y = screen_center.y + ((((height - (size * 3)) * .5f) * (radius / 100.0f)) * sin(angle_yaw_rad));
- Color ESP = player->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[player->EntIndex()]) : Color(g_Menu.Config.FovColor.red, g_Menu.Config.FovColor.green, g_Menu.Config.FovColor.blue, flPlayerAlpha[player->EntIndex()]);
- Color clr = ESP;
- std::array< vec2_t, 3 >points{ vec2_t(new_point_x - size, new_point_y - size),
- vec2_t(new_point_x + size, new_point_y),
- vec2_t(new_point_x - size, new_point_y + size) };
- rotate(points, viewangles.y - g_Math.CalcAngle(local->GetEyePosition(), GetHitboxPosition(player, 2)).y - 90);
- g_pSurface->draw_filled_triangle(points, clr);
- }
- #include "..\..\SDK\ICvar.h"
- enum cvar_flags {
- fcvar_none = 0,
- fcvar_unregistered = (1 << 0),
- fcvar_developmentonly = (1 << 1),
- fcvar_gamedll = (1 << 2),
- fcvar_clientdll = (1 << 3),
- fcvar_hidden = (1 << 4),
- fcvar_protected = (1 << 5),
- fcvar_sponly = (1 << 6),
- fcvar_archive = (1 << 7),
- fcvar_notify = (1 << 8),
- fcvar_userinfo = (1 << 9),
- fcvar_printableonly = (1 << 10),
- fcvar_unlogged = (1 << 11),
- fcvar_never_as_string = (1 << 12),
- fcvar_replicated = (1 << 13),
- fcvar_cheat = (1 << 14),
- fcvar_ss = (1 << 15),
- fcvar_demo = (1 << 16),
- fcvar_dontrecord = (1 << 17),
- fcvar_ss_added = (1 << 18),
- fcvar_release = (1 << 19),
- fcvar_reload_materials = (1 << 20),
- fcvar_reload_textures = (1 << 21),
- fcvar_not_connected = (1 << 22),
- fcvar_material_system_thread = (1 << 23),
- fcvar_archive_xbox = (1 << 24),
- fcvar_accessible_from_threads = (1 << 25),
- fcvar_server_can_execute = (1 << 28),
- fcvar_server_cannot_query = (1 << 29),
- fcvar_clientcmd_can_execute = (1 << 30),
- fcvar_meme_dll = (1 << 31),
- fcvar_material_thread_mask = (fcvar_reload_materials | fcvar_reload_textures | fcvar_material_system_thread)
- };
- void c_visuals::force_crosshair()
- {
- auto local_player = g::pLocalEntity;
- static ConVar* weapon_debug_spread_show = g_pCvar->FindVar("weapon_debug_spread_show");
- weapon_debug_spread_show->nFlags &= ~fcvar_cheat;
- if (local_player && local_player->GetHealth() > 0)
- {
- // weapon_debug_spread_show->SetValue(local_player->IsScoped() || !g_Menu.Config.force_crosshair ? 0 : 3);
- }
- }
- void c_visuals::flags(C_BaseEntity* player) {
- Vector min, max;
- player->GetRenderBounds(min, max);
- Vector pos, pos3D, top, top3D;
- pos3D = player->GetAbsOrigin() - Vector(0, 0, 10);
- top3D = pos3D + Vector(0, 0, max.z + 11);
- Color ESP = player->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[player->EntIndex()] / 2) : Color(255, 255, 255, flPlayerAlpha[player->EntIndex()] / 1.3);
- Color Money = player->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[player->EntIndex()] / 2) : Color(115, 180, 25, flPlayerAlpha[player->EntIndex()] / 1.3);
- Color Zoom = player->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[player->EntIndex()] / 2) : Color(53, 166, 208, flPlayerAlpha[player->EntIndex()] / 1.3);
- Color FakeDuck = player->IsDormant() ? Color(150, 150, 150, flPlayerAlpha[player->EntIndex()] / 2) : Color(255, 0, 0, flPlayerAlpha[player->EntIndex()] / 1.3);
- Color baim = player->IsDormant() ? Color(255, 0, 237, flPlayerAlpha[player->EntIndex()] / 2) : Color(255, 0, 0, flPlayerAlpha[player->EntIndex()] / 1.3);
- Color missed2 = player->IsDormant() ? Color(255, 0, 237, flPlayerAlpha[player->EntIndex()] / 2) : Color(255, 0, 0, flPlayerAlpha[player->EntIndex()] / 1.3);
- if (WorldToScreen(pos3D, pos) && WorldToScreen(top3D, top))
- {
- int height = (pos.y - top.y);
- int width = height / 2;
- int x = pos.x - (width / 2);
- int y = top.y;
- if (g_Menu.Config.YawPitch)
- {
- std::vector<std::pair<std::string, Color>> flags;
- flags.push_back(std::pair<std::string, Color>("HK", ESP));
- flags.push_back(std::pair<std::string, Color>(std::string("ZOOM"), Zoom));
- int pos = 0;
- for (auto text : flags) {
- g_pSurface->DrawT(x + width + 5, y + pos, text.second, g::EspTahoma, false, text.first.c_str());
- pos += 10;
- }
- }
- }
- }
- RECT GetViewport()
- {
- RECT Viewport = { 0, 0, 0, 0 };
- int w, h;
- g_pEngine->GetScreenSize(w, h);
- Viewport.right = w; Viewport.bottom = h;
- return Viewport;
- }
- void DrawWeapon(C_BaseEntity* player) {
- Vector min, max;
- player->GetRenderBounds(min, max);
- Vector pos, pos3D, top, top3D;
- pos3D = player->GetAbsOrigin() - Vector(0, 0, 10);
- top3D = pos3D + Vector(0, 0, max.z + 11);
- if (WorldToScreen(pos3D, pos) && WorldToScreen(top3D, top))
- {
- int height = (pos.y - top.y);
- int y = top.y;
- int width = height / 2;
- int x = pos.x - ((width / 2) / 2);
- int x2 = pos.x - (width / 2);
- int h = height;
- int w = width / 2;
- g_pSurface->OutlinedRect(x2, y, width, height, Color(255, 255, 255));
- g_pSurface->OutlinedRect(x2 - 1, y - 1, width + 2, height + 2, Color(0, 0, 0));
- g_pSurface->OutlinedRect(x2 + 1, y + 1, width - 2, height - 2, Color(0, 0, 0));
- }
- }
- void c_visuals::DrawPlayers() {
- force_crosshair();
- int spectator_count = 0;
- for (int Index = 1; Index < g_pGlobalVars->maxClients; Index++)
- {
- auto Entity = g_pEntityList->GetClientEntity(Index);
- auto LocalPlayer = g::pLocalEntity;
- if (!Entity || !LocalPlayer || !Entity->IsAlive())
- continue;
- ClientClass* cClass = (ClientClass*)Entity->GetClientClass();
- if (cClass->ClassID != (int)EClassIds::CBaseWeaponWorldModel && ((strstr(cClass->pNetworkName, "Weapon") || cClass->ClassID == (int)EClassIds::CDEagle || cClass->ClassID == (int)EClassIds::CAK47))) {
- DrawWeapon(Entity);
- }
- ConVar* mp_radar_showall = g_pCvar->FindVar("mp_radar_showall");
- *(int*)((DWORD)& mp_radar_showall->fnChangeCallback + 0xC) = 0; // ew
- mp_radar_showall->SetValue(1);
- if (g_Menu.Config.KillCounter)
- QuakeKillCounter();
- bool IsTeammate = Entity->GetTeam() == LocalPlayer->GetTeam();
- bool IsEnemy = Entity->GetTeam() != LocalPlayer->GetTeam();
- bool IsLocal = Entity == LocalPlayer;
- if (!Entity->IsDormant()) {
- StoredCurtimePlayer[Entity->EntIndex()] = g_pGlobalVars->curtime;
- }
- if (Entity->IsDormant() && flPlayerAlpha[Entity->EntIndex()] > 0 && g_pGlobalVars->curtime - StoredCurtimePlayer[Entity->EntIndex()] > 2)
- {
- flPlayerAlpha[Entity->EntIndex()] -= 5;
- }
- else if (flPlayerAlpha[Entity->EntIndex()] < 255 && !(Entity->IsDormant()))
- {
- flPlayerAlpha[Entity->EntIndex()] += 5;
- }
- //spectators();
- if (IsEnemy)
- {
- if (g_Menu.Config.Name) NameESP(Entity);
- if (g_Menu.Config.Box) BoxESP(Entity);
- if (g_Menu.Config.Weapon) WeaponESP(Entity);
- if (g_Menu.Config.ammo) Ammo(Entity);
- if (g_Menu.Config.Health) HealthESP(Entity);
- if (g_Menu.Config.FovEnable) arrows(Entity);
- flags(Entity);
- }
- }
- }
- template<class T>
- constexpr const T& clampv2(const T& v, const T& lo, const T& hi)
- {
- return clampv2(v, lo, hi, std::less<>());
- }
- template<class T, class Compare>
- constexpr const T& clampv2(const T& v, const T& lo, const T& hi, Compare comp)
- {
- return assert(!comp(hi, lo)),
- comp(v, lo) ? lo : comp(hi, v) ? hi : v;
- }
- void c_visuals::draw_scope() {
- if (!g_Menu.Config.NoScope)
- return;
- if (!g_pEngine->IsConnected() || !g_pEngine->IsInGame())
- return;
- auto local_player = g::pLocalEntity;
- if (!local_player)
- return;
- if (!local_player->IsAlive())
- return;
- int width_2, height_2;
- g_pEngine->GetScreenSize(width_2, height_2);
- if (local_player->IsScoped()) {
- auto weapon = local_player->GetActiveWeapon();
- if (!weapon)
- return;
- float spread = weapon->GetInaccuracy() * 100;
- int height = clampv2(spread, 1.f, 30.f);
- int alpha = 255 - (height * 4.2f);
- bool Dynamic = g_Menu.Config.NoScope;
- if (Dynamic) {
- g_pSurface->FilledRect(0, height_2 / 2 - (height / 2), width_2, height, Color(0, 0, 0, alpha));
- g_pSurface->FilledRect(width_2 / 2 - (height / 2), 0, height, height_2, Color(0, 0, 0, alpha));
- }
- else {
- g_pSurface->Line(0, height_2 / 2, width_2, height_2 / 2, Color(0, 0, 0, 255));
- g_pSurface->Line(width_2 / 2, 0, width_2 / 2, height_2, Color(0, 0, 0, 255));
- }
- }
- }
- int RadarX = 110;
- int RadarY = 110;
- int RadarSize = 100;
- void c_visuals::DrawRadarPoint(Vector vOriginX, Vector vOriginY, QAngle qAngle, C_BaseEntity* pBaseEntity, Color col)
- {
- auto pLocalEntity = g::pLocalEntity;
- if (pLocalEntity == NULL)
- return;
- float flDeltaX = vOriginX.x - vOriginY.x;
- float flDeltaY = vOriginX.y - vOriginY.y;
- float flAngle = qAngle.y;
- float flYaw = (flAngle) * (3.14159265358979323846 / 180.0);
- float flMainViewAngles_CosYaw = cos(flYaw);
- float flMainViewAngles_SinYaw = sin(flYaw);
- // rotate
- float x = flDeltaY * (-flMainViewAngles_CosYaw) + flDeltaX * flMainViewAngles_SinYaw;
- float y = flDeltaX * (-flMainViewAngles_CosYaw) - flDeltaY * flMainViewAngles_SinYaw;
- float flRange = 2000;
- if (fabs(x) > flRange || fabs(y) > flRange)
- {
- // clipping
- if (y > x)
- {
- if (y > -x)
- {
- x = flRange * x / y;
- y = flRange;
- }
- else
- {
- y = -flRange * y / x;
- x = -flRange;
- }
- }
- else
- {
- if (y > -x)
- {
- y = flRange * y / x;
- x = flRange;
- }
- else
- {
- x = -flRange * x / y;
- y = -flRange;
- }
- }
- }
- int iScreenX = RadarX + int(x / flRange * RadarSize);
- int iScreenY = RadarY + int(y / flRange * RadarSize);
- g_pSurface->FilledRect(iScreenX - 3, iScreenY - 3, 7, 7, Color(0, 0, 0, 255));
- g_pSurface->FilledRect(iScreenX - 2, iScreenY - 2, 5, 5, Color(255, 255, 255));
- }
- #define M_PI 3.14159265358979323846f
- Vector RotatePoint(Vector p, Vector c, float ang)
- {
- float angleInRadians = ang * (M_PI / 180.f);
- float cosTheta = cos(angleInRadians);
- float sinTheta = sin(angleInRadians);
- return Vector(
- (cosTheta * (p.x - c.x) -
- sinTheta * (p.y - c.y) + c.x),
- (sinTheta * (p.x - c.x) +
- cosTheta * (p.y - c.y) + c.y),
- 0);
- }
- void GradientV2(int x, int y, int w, int h, Color c1, Color c2)
- {
- g_pSurface->FilledRect(x, y, w, h, c1);
- BYTE first = c2.red;
- BYTE second = c2.green;
- BYTE third = c2.blue;
- for (int i = 0; i < h; i++)
- {
- float fi = i, fh = h;
- float a = fi / fh;
- DWORD ia = a * 255;
- g_pSurface->FilledRect(x, y + i, w, 1, Color(first, second, third, ia));
- }
- }
- //===================================================================================
- int RadarSizeFinal = 150;
- void GradientH2(int x, int y, int w, int h, Color c1, Color c2)
- {
- g_pSurface->FilledRect(x, y, w, h, c1);
- BYTE first = c2.red;
- BYTE second = c2.green;
- BYTE third = c2.blue;
- for (int i = 0; i < w; i++)
- {
- float fi = i, fw = w;
- float a = fi / fw;
- DWORD ia = a * 255;
- g_pSurface->FilledRect(x + i, y, 1, h, Color(first, second, third, ia));
- }
- }
- #include "../../Menu/Menu.h"
- static Vector TL(110, 110, 0);
- float CSGO_Armor(float flDamage, int ArmorValue)
- {
- float flArmorRatio = 0.5f;
- float flArmorBonus = 0.5f;
- if (ArmorValue > 0) {
- float flNew = flDamage * flArmorRatio;
- float flArmor = (flDamage - flNew) * flArmorBonus;
- if (flArmor > static_cast<float>(ArmorValue)) {
- flArmor = static_cast<float>(ArmorValue) * (1.f / flArmorBonus);
- flNew = flDamage - flArmor;
- }
- flDamage = flNew;
- }
- return flDamage;
- }
- static std::string damagestring;
- static bool lethal;
- static int bombR = 0, bombG = 0;
- static int lethaly;
- const wchar_t* to_wchar(const char* string) {
- va_list va_alist;
- char buf[1024];
- va_start(va_alist, string);
- _vsnprintf_s(buf, sizeof(buf), string, va_alist);
- va_end(va_alist);
- wchar_t wbuf[1024];
- MultiByteToWideChar(CP_UTF8, 0, buf, 256, wbuf, 256);
- return wbuf;
- }
- /*void c_visuals::SpecList() {
- if (!g_Menu.Config.visual_spectator_list)
- return;
- if (g_pEngine->IsConnected() || g_pEngine->IsInGame()) {
- int index = 0;
- int w, h;
- g_pEngine->GetScreenSize(w, h);
- g_pSurface->OutlinedRect(931 + g_Menu.Config.specx, 141 + g_Menu.Config.specy, 200, 100, Color(0, 0, 0, 155));
- g_pSurface->FilledRect(931, 141, 200, 100, Color(0, 0, 0, 65));
- g_pSurface->FilledRect(937, 147, 188, 88, Color(0, 0, 0, 100));
- g_pSurface->FilledRect(941, 172, 180, 57, Color(12, 12, 12, 255));
- g_pSurface->OutlinedRect(941, 172 + g_Menu.Config.specy, 180, 57, Color(43, 43, 43, 155));
- g_pSurface->FilledRect(941, 161, 180, 2, Color(g_Menu.Config.menu_color_r, g_Menu.Config.menu_color_g,
- g_Menu.Config.menu_color_b, 255));
- g_pSurface->FilledRect(941, 161, 180, 2, Color(g_Menu.Config.menu_color_r, g_Menu.Config.menu_color_g,
- g_Menu.Config.menu_color_b, 255));
- g_pSurface->DrawT(999, 148, Color(255, 255, 255, 255), g::SmallText, true, "Spectators");
- for (int i = 1; i < 65; i++) {
- auto p_local = g_pEntityList->GetClientEntity(g_pEngine->GetLocalPlayer()); // what's csgo::local_player???????
- auto p_entity = g_pEntityList->GetClientEntity(i);
- PlayerInfo_t e_info;
- if (p_entity && p_entity != p_local) {
- g_pEngine->GetPlayerInfo(i, &e_info);
- if (!p_entity->IsAlive() && p_entity->IsDormant()) {
- auto target = p_entity->observer_target();
- if (target) {
- auto p_target = g_pEntityList->GetClientEntityFromHandle(target);
- if (p_target == p_local) {
- int x, y;
- g_pEngine->GetScreenSize(x, y);
- g_pSurface->GetTextSize(g::SmallText, to_wchar(e_info.szName), x, y);
- std::string player_name = e_info.szName;
- PlayerInfo_t p_info;
- g_pEngine->GetPlayerInfo(i, &e_info);
- g_pSurface->DrawT(946 + g_Menu.Config.specx, 174 + g_Menu.Config.specy + (10 * index), Color(255, 255, 255, 255), g::SmallText, false, player_name.c_str());
- index++;
- }
- }
- }
- }
- }
- }
- }
- */
- /*void c_visuals::SpecList()
- {
- int specs = 0;
- int modes = 0;
- std::string spect = "";
- std::string mode = "";
- int screenx;
- int screeny;
- g_pEngine->GetScreenSize(screenx, screeny);
- int centerx = screenx / 2;
- int centery = screeny / 2;
- if (g_pEngine->IsInGame() && g_pEngine->IsConnected())
- {
- int localIndex = g_pEngine->GetLocalPlayer();
- if (g::pLocalEntity)
- {
- for (int i = 0; i < g_pEngine->GetMaxClients(); i++)
- {
- C_BaseEntity* pPlayerEntity = g_pEntityList->GetClientEntity(i);
- if (!pPlayerEntity)
- continue;
- if (pPlayerEntity->GetHealth() > 0)
- continue;
- auto target = pPlayerEntity->observer_target();
- auto p_target = g_pEntityList->GetClientEntityFromHandle(target);
- if (pPlayerEntity == g::pLocalEntity)
- continue;
- if (pPlayerEntity->IsDormant())
- continue;
- if (p_target != g::pLocalEntity)
- continue;
- PlayerInfo_t pInfo;
- g_pEngine->GetPlayerInfo(pPlayerEntity->EntIndex(), &pInfo);
- if (pInfo.ishltv)
- continue;
- spect += pInfo.szName;
- spect += "\n";
- specs++;
- g_pSurface->DrawT(centerx, centery, Color(255, 255, 255, 255), g::SmallText, true, spect.c_str());
- }
- }
- }
- }
- */
- auto spectator_count = 0;
- bool WorldToScreenAlpha(const Vector& origin, Vector2D& screen)
- {
- const auto screenTransform = [&origin, &screen]() -> bool
- {
- static std::uintptr_t pViewMatrix;
- if (!pViewMatrix)
- {
- pViewMatrix = static_cast<std::uintptr_t>(Utils::FindSignature("client_panorama.dll", "0F 10 05 ? ? ? ? 8D 85 ? ? ? ? B9"));
- pViewMatrix += 3;
- pViewMatrix = *reinterpret_cast<std::uintptr_t*>(pViewMatrix);
- pViewMatrix += 176;
- }
- const VMatrix& w2sMatrix = *reinterpret_cast<VMatrix*>(pViewMatrix);
- screen.x = w2sMatrix.m[0][0] * origin.x + w2sMatrix.m[0][1] * origin.y + w2sMatrix.m[0][2] * origin.z + w2sMatrix.m[0][3];
- screen.y = w2sMatrix.m[1][0] * origin.x + w2sMatrix.m[1][1] * origin.y + w2sMatrix.m[1][2] * origin.z + w2sMatrix.m[1][3];
- float w = w2sMatrix.m[3][0] * origin.x + w2sMatrix.m[3][1] * origin.y + w2sMatrix.m[3][2] * origin.z + w2sMatrix.m[3][3];
- if (w < 0.001f)
- {
- screen.x *= 100000;
- screen.y *= 100000;
- return true;
- }
- float invw = 1.f / w;
- screen.x *= invw;
- screen.y *= invw;
- return false;
- };
- if (!screenTransform())
- {
- int iScreenWidth, iScreenHeight;
- g_pEngine->GetScreenSize(iScreenWidth, iScreenHeight);
- screen.x = (iScreenWidth * 0.5f) + (screen.x * iScreenWidth) * 0.5f;
- screen.y = (iScreenHeight * 0.5f) - (screen.y * iScreenHeight) * 0.5f;
- return true;
- }
- return false;
- }
- struct
- {
- //int left, right, top, bottom;
- int x, y, w, h;
- } Box;
- bool boundingBox(C_BaseEntity* pEntity, Vector offset = Vector(0, 0, 0))
- {
- Vector min, max;
- pEntity->GetRenderBounds(min, max);
- Vector pos3D, top3D;
- Vector2D pos, top;
- pos3D = pEntity->GetAbsOrigin() - Vector(0, 0, 10);
- top3D = pos3D + Vector(0, 0, max.z + 15);
- if (WorldToScreenAlpha(pos3D, pos) && WorldToScreenAlpha(top3D, top))
- {
- int height = (pos.y - top.y);
- Box.h = height; //h
- int width = Box.h / 2;
- Box.w = width; //w
- Box.x = pos.x - width / 2; //x
- Box.y = top.y; //y
- return true;
- }
- return false;
- }
- enum FontRenderFlag_t
- {
- FONT_LEFT = 0,
- FONT_RIGHT = 1,
- FONT_CENTER = 2
- };
- void c_visuals::DrawString(unsigned long font, int x, int y, Color color, unsigned long alignment, const char* msg)
- {
- va_list va_alist;
- char buf[1024];
- va_start(va_alist, msg);
- _vsnprintf_s(buf, sizeof(buf), msg, va_alist);
- va_end(va_alist);
- wchar_t wbuf[1024];
- MultiByteToWideChar(CP_UTF8, 0, buf, 256, wbuf, 256);
- int r = 255, g = 255, b = 255, a = 255;
- // color.GetColor(r, g, b, a);
- int width, height;
- g_pSurface->GetTextSize(font, wbuf, width, height);
- if (alignment & FONT_RIGHT)
- x -= width;
- if (alignment & FONT_CENTER)
- x -= width / 2;
- g_pSurface->DrawSetTextFont(font);
- g_pSurface->DrawSetTextColor(r, g, b, a);
- g_pSurface->DrawSetTextPos(x, y - height / 2);
- g_pSurface->DrawPrintText(wbuf, wcslen(wbuf));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement