Advertisement
fqrmix

esp.h

Jan 28th, 2017
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.56 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include "client-entity-list.h"
  4. #include "engine-client.h"
  5. #include "entity.h"
  6.  
  7. #include "render.h"
  8. class PanicKeys
  9. {
  10. public:
  11.  
  12.     bool VisualPanicKeyIsPressed;
  13.     bool InfoPanicKeyIsPressed;
  14.     bool BoxPanicKeyIsPressed;
  15.     bool DM_ESP_PanicKeyIsPressed;
  16.  
  17.     void IsPressed(int what, bool *to)
  18.     {
  19.         if (GetKeyState(what) == 1)
  20.             *to = TRUE;
  21.     }
  22. };
  23. class CESP
  24. {
  25. public:
  26.  
  27.     void Think( )
  28.     {
  29.         SetupConsole();
  30.  
  31.         CBaseEntity* Local = ( CBaseEntity* )ClientEntityList->GetClientEntity( EngineClient->GetLocalPlayer( ) );
  32.  
  33.         PlayerInfo_t Info;
  34.  
  35.         Matrix3x4_t Matrix = EngineClient->GetMatrix( );
  36.  
  37.         CVector Screen, Head;
  38.  
  39.         PanicKeys Panics;
  40.  
  41.         Panics.IsPressed(VK_F6, &Panics.VisualPanicKeyIsPressed);
  42.         Panics.IsPressed(VK_F7, &Panics.InfoPanicKeyIsPressed);
  43.         Panics.IsPressed(VK_F8, &Panics.BoxPanicKeyIsPressed);
  44.         Panics.IsPressed(VK_F9, &Panics.DM_ESP_PanicKeyIsPressed);
  45.  
  46.  
  47.         for ( int i = 0; i < 64; ++i )
  48.         {
  49.  
  50.             CBaseEntity* Entity = ( CBaseEntity* ) ClientEntityList->GetClientEntity( i );     
  51.  
  52.             if ( !Entity )
  53.                 continue;
  54.            
  55.             if ( Entity == Local )
  56.                 continue;
  57.  
  58.             if ( Entity->GetDormant( ) )
  59.                 continue;
  60.  
  61.  
  62.             if ( Entity->GetHealth( ) )
  63.             {
  64.            
  65.                 EngineClient->GetPlayerInfo( i, &Info );
  66.  
  67.                 if ( WorldToScreen( Entity->GetOrigin( ), Screen ) && WorldToScreen( ( Entity->GetEyePosition( ) + CVector( 0, 0, 8.f ) ), Head ) )
  68.                 {
  69.                     CColor Color( 255, 255, 255, 255 );
  70.  
  71.                     if ( Entity->GetTeam( ) != Local->GetTeam( ) )
  72.                         Color = CColor( 255, 0, 0, 255 );
  73.  
  74.                     else
  75.                         Color = CColor( 0, 255, 255, 255 );
  76.  
  77.                     std::cout << Info.Name;
  78.                     int Height = Screen.y - Head.y, Width = Height / 2.5;
  79.                     if (!(Panics.VisualPanicKeyIsPressed))
  80.                     {
  81.                         if (!(Panics.InfoPanicKeyIsPressed))
  82.                         {
  83.                             if (!(Panics.DM_ESP_PanicKeyIsPressed))
  84.                             {
  85.                                 if (Entity->GetTeam() != Local->GetTeam())
  86.                                 {
  87.                                     Render->DrawF(Screen.x, Screen.y + 2, Color, 5, 1, "- %s -", Info.Name);
  88.                                     Render->DrawF(Head.x, Head.y - 12, Color, 5, 1, "- %d -", Entity->GetHealth());
  89.                                 }
  90.                             }
  91.                             else
  92.                             {
  93.                                 Render->DrawF(Screen.x, Screen.y + 2, Color, 5, 1, "- %s -", Info.Name);
  94.                                 Render->DrawF(Head.x, Head.y - 12, Color, 5, 1, "- %d -", Entity->GetHealth());
  95.                             }
  96.                         }
  97.  
  98.                         if (!(Panics.BoxPanicKeyIsPressed))
  99.                         {
  100.                             if (!(Panics.DM_ESP_PanicKeyIsPressed))
  101.                             {
  102.                                 if (Entity->GetTeam() != Local->GetTeam())
  103.                                     Render->DrawInlineRect(Head.x - Width / 2, Head.y, Width, Height, Color);
  104.                             }
  105.                             else Render->DrawInlineRect(Head.x - Width / 2, Head.y, Width, Height, Color);
  106.                         }
  107.                     }
  108.                 }
  109.  
  110.  
  111.             }
  112.  
  113.  
  114.         }
  115.  
  116.     }
  117.  
  118.     __forceinline bool WorldToScreen( CVector In, CVector& Out )
  119.     {
  120.         Matrix3x4_t ViewMatrix = EngineClient->GetMatrix( );
  121.  
  122.         Out.x = ViewMatrix.Matrix[ 0 ] * In.x + ViewMatrix.Matrix[ 1 ] * In.y + ViewMatrix.Matrix[ 2 ] * In.z + ViewMatrix.Matrix[ 3 ];
  123.  
  124.         Out.y = ViewMatrix.Matrix[ 4 ] * In.x + ViewMatrix.Matrix[ 5 ] * In.y + ViewMatrix.Matrix[ 6 ] * In.z + ViewMatrix.Matrix[ 7 ];
  125.  
  126.         Out.z = ViewMatrix.Matrix[ 12 ] * In.x + ViewMatrix.Matrix[ 13 ] * In.y + ViewMatrix.Matrix[ 14 ] * In.z + ViewMatrix.Matrix[ 15 ];
  127.  
  128.         if ( Out.z < 0.01f )
  129.             return false;
  130.  
  131.         float Inverse = 1.f / Out.z;
  132.  
  133.         Out.x *= Inverse;
  134.         Out.y *= Inverse;
  135.  
  136.         int Width, Height;
  137.  
  138.         EngineClient->GetScreenSize( Width, Height );
  139.  
  140.         auto X = Width / 2;
  141.         auto Y = Height / 2;
  142.  
  143.         X += 0.5 * Out.x * Width + 0.5;
  144.         Y -= 0.5 * Out.y * Height + 0.5;
  145.  
  146.         Out.x = X;
  147.         Out.y = Y;
  148.  
  149.         return true;
  150.     }
  151.  
  152. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement