Advertisement
Guest User

[External Base] main.cpp

a guest
Jan 9th, 2013
900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.92 KB | None | 0 0
  1. #include <windows.h>
  2. #include <iostream>
  3.  
  4. #include "CProcess.h"
  5. #include "offsets.h"
  6. #include "Needed.h"
  7. #include "CMath.h"
  8.  
  9. using namespace std;
  10.  
  11. CProcess gProcess;
  12. CMath gMath;
  13.  
  14. bool doAim = true;
  15.  
  16. typedef struct C_LocalBasePlayer
  17. {
  18.     DWORD dw_BasePointer;
  19.     int iTeam;
  20.     int iCrosshairID;
  21.     int iFOV;
  22.     float vAngles[3];
  23.     float vPosition[3];
  24.     float vPunchAngles[3];
  25.     bool OnGround;
  26.  
  27.     void WipeStruct(void)
  28.     {
  29.         this->dw_BasePointer = 0x0;
  30.         this->iCrosshairID = 0;
  31.         this->iTeam = 0;
  32.         this->vPosition[0] = 0;
  33.         this->vPosition[1] = 0;
  34.         this->vPosition[2] = 0;
  35.         this->vAngles[0] = 0;
  36.         this->vAngles[1] = 0;
  37.         this->vAngles[2] = 0;
  38.         this->iFOV = 0;
  39.         this->vPunchAngles[0] = 0;
  40.         this->vPunchAngles[1] = 0;
  41.         this->vPunchAngles[2] = 0;
  42.     }
  43.  
  44.     void FillStruct(void)
  45.     {
  46.         this->WipeStruct();
  47.  
  48.         ReadProcessMemory(gProcess.hProcess, (PBYTE*)(gProcess.dwClient + c_dwLocalBaseEntity), &this->dw_BasePointer, sizeof(DWORD), 0); //LocalBaseEntity pointer
  49.         ReadProcessMemory(gProcess.hProcess, (PBYTE*)(gProcess.dwClient + 0x774354), &this->OnGround, sizeof(bool), 0); //1 if on ground / 0 if in air
  50.         ReadProcessMemory(gProcess.hProcess, (PVOID)(this->dw_BasePointer + 0xD7C + 0x6C), &this->vPunchAngles, 12, 0); //0xD7C - m_Local
  51.         ReadProcessMemory(gProcess.hProcess, (PBYTE*)(this->dw_BasePointer + c_dwBaseEntityTeam), &this->iTeam, sizeof(int), 0);
  52.         ReadProcessMemory(gProcess.hProcess, (PBYTE*)(this->dw_BasePointer + c_dwBaseEntityCrosshairID), &this->iCrosshairID, sizeof(int), 0);
  53.         ReadProcessMemory(gProcess.hProcess, (PVOID)(gProcess.dwEngine + c_dwLocalViewAngles), &this->vAngles, 12, 0);
  54.         ReadProcessMemory(gProcess.hProcess, (PVOID)(gProcess.dwEngine + c_dwLocalPosition), &this->vPosition, 12, 0);
  55.     }
  56.  
  57.     void cmd_Jump(void)
  58.     {
  59.         keybd_event(MapVirtualKey(VK_SPACE, 0), 0x39, KEYEVENTF_EXTENDEDKEY, 0);
  60.         Sleep(30);
  61.         keybd_event(MapVirtualKey(VK_SPACE, 0), 0x39, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
  62.     }
  63.  
  64.     //baseentity+0x1410 - flash alpha
  65.     void NoFlash(void)
  66.     {
  67.         WriteProcessMemory(gProcess.hProcess, (PBYTE*)(this->dw_BasePointer + 0x1410), &zero, 4, 0);
  68.     }
  69.  
  70.     //client+0x773D18 - r_drawparticles
  71.     void NoSmoke(void)
  72.     {
  73.         WriteProcessMemory(gProcess.hProcess, (PBYTE*)(gProcess.dwClient + 0x773D18), &zero, 4, 0);
  74.     }
  75.  
  76.     /*//engine+0x54EFC0 - mat_wireframe
  77.     void MatWireframe(void)
  78.     {
  79.         WriteProcessMemory(gProcess.hProcess, (PBYTE*)(gProcess.dwEngine + 0x54EFC0), &one, 4, 0);
  80.     }
  81.  
  82.     //client+0x741F20 - r_drawothermodels
  83.     void Wireframe(void)
  84.     {
  85.         WriteProcessMemory(gProcess.hProcess, (PBYTE*)(gProcess.dwClient + 0x741F20), &two, 4, 0);
  86.     }
  87.  
  88.     //engine+0x5A3B10 - sv_cheats
  89.     void Cheats(void)
  90.     {
  91.         WriteProcessMemory(gProcess.hProcess, (PBYTE*)(gProcess.dwClient + 0x741F20), &two, 4, 0);
  92.     }
  93.  
  94.     //engine+0x58D7E4 - sv_pure
  95.     void Pure(void)
  96.     {
  97.         WriteProcessMemory(gProcess.hProcess, (PBYTE*)(gProcess.dwEngine + 0x58D7E4), &zero, 4, 0);
  98.     }
  99.  
  100.     //engine+0x5A3D50 - sv_consistency
  101.     void Consistency(void)
  102.     {
  103.         WriteProcessMemory(gProcess.hProcess, (PBYTE*)(gProcess.dwEngine + 0x5A3D50), &zero, 4, 0);
  104.     }*/
  105.  
  106.     void cmd_Attack(void)
  107.     {
  108.         doAim = false;
  109.         mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
  110.         mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
  111.         Sleep(100);
  112.         doAim = true;
  113.     }
  114.  
  115.     void cmd_Attack2(void)
  116.     {
  117.         mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
  118.         mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
  119.     }
  120.  
  121.     void mp_playerid(void)
  122.     {
  123.         int i_True = 0;
  124.  
  125.         WriteProcessMemory(gProcess.hProcess, (PBYTE*)(gProcess.dwServer + 0x606BF0), &i_True, sizeof(int), 0);
  126.     }
  127.  
  128.     bool b_OnGround(void)
  129.     {
  130.         return (this->OnGround == 1);
  131.     }
  132.  
  133.     int b_PlayerInCrosshair(void)
  134.     {
  135.         return (this->iCrosshairID > 0 && this->iCrosshairID < 64);
  136.     }
  137. } LocalBasePlayer;
  138.  
  139.  
  140.  
  141. typedef struct C_BasePlayer
  142. {
  143. DWORD dw_BasePointer;
  144. DWORD dw_RadarBase;
  145. float vPosition[3];
  146. float vAngles[3];
  147. int iHealth;
  148. int iTeam;
  149. int iLifeState;
  150. float BonePosition[3];
  151. DWORD m_dwBoneMatrix;
  152. float vecBone[3];
  153.  
  154.     void WipeStruct(void)
  155.     {
  156.         this->dw_BasePointer = 0x0;
  157.         this->m_dwBoneMatrix = 0x0;
  158.         this->dw_RadarBase = 0x0;
  159.         this->iTeam = 0;
  160.         this->iHealth = 0;
  161.         this->vecBone[0] = 0;
  162.         this->vecBone[1] = 0;
  163.         this->vecBone[2] = 0;
  164.         this->vPosition[0] = 0;
  165.         this->vPosition[1] = 0;
  166.         this->vPosition[2] = 0;
  167.         this->iLifeState = 0;
  168.     }
  169.  
  170.     void FillStruct(int i_Player)
  171.     {
  172.         this->WipeStruct();
  173.         ReadProcessMemory(gProcess.hProcess, (PBYTE*)(gProcess.dwClient + c_dwBaseEntity + (i_Player * 0x10)), &this->dw_BasePointer, sizeof(DWORD), 0);
  174.         ReadProcessMemory(gProcess.hProcess, (PVOID)(this->dw_BasePointer + 0x538), &m_dwBoneMatrix, 4, NULL );    
  175.         //bones
  176.         ReadProcessMemory(gProcess.hProcess, ( PVOID )( m_dwBoneMatrix + (0x30 * (14)) + 0x0C ), &vecBone[0], 4, NULL );
  177.         ReadProcessMemory(gProcess.hProcess, ( PVOID )( m_dwBoneMatrix + (0x30 * (14)) + 0x1C ), &vecBone[1], 4, NULL );
  178.         ReadProcessMemory(gProcess.hProcess, ( PVOID )( m_dwBoneMatrix + (0x30 * (14)) + 0x2C ), &vecBone[2], 4, NULL );
  179.         //pos
  180.         ReadProcessMemory(gProcess.hProcess, (PVOID)(this->dw_BasePointer + 0x2FC), &this->vPosition, 12, 0);
  181.         //team & health
  182.         ReadProcessMemory(gProcess.hProcess, (PBYTE*)(this->dw_BasePointer + 0x98), &this->iTeam, sizeof(int), 0);
  183.         ReadProcessMemory(gProcess.hProcess, (PBYTE*)(this->dw_BasePointer + 0x90), &this->iHealth, sizeof(int), 0);
  184.         ReadProcessMemory(gProcess.hProcess, (PBYTE*)(this->dw_BasePointer + 0x8F), &this->iLifeState, sizeof(int), 0);
  185.     }
  186.  
  187.     bool b_isEnemy(LocalBasePlayer &LocalPlayer)
  188.     {
  189.         return (this->iTeam != LocalPlayer.iTeam);
  190.     }
  191. } BasePlayer[64];
  192.  
  193. LocalBasePlayer Local;
  194. BasePlayer Entity;
  195.  
  196. void DropTarget(void)
  197. {
  198.     fAimAngles[0] = 0;
  199.     fAimAngles[1] = 0;
  200.     fAimAngles[2] = 0;
  201.     fNearestTarget = 99999.9f;
  202.     iNearestTarget = -1;
  203. }
  204.  
  205. void Update(void)
  206. {
  207.     while(true)
  208.     {
  209.         gProcess.Initialize();
  210.         Local.mp_playerid();
  211.         Local.NoFlash();
  212.         Local.NoSmoke();
  213.         /*Local.Wireframe();
  214.         Local.Cheats();
  215.         Local.Pure();
  216.         Local.Consistency();*/
  217.         Sleep(5000);
  218.     }
  219. }
  220.  
  221. void Aim(void)
  222. {
  223.     while(true)
  224.     {
  225.         Sleep(1);
  226.         Local.FillStruct();
  227.         for(int i_Player = 0; i_Player < 64; i_Player++)
  228.         {
  229.             DropTarget();
  230.             Entity[i_Player].FillStruct(i_Player);
  231.             float fFov = gMath.GetFOV( Local.vAngles, Local.vPosition, Entity[i_Player].vecBone );
  232.             if ( ( fFov <= 50 ) && ( fFov < fNearestTarget ) && (Entity[i_Player].iHealth > 1) && Entity[i_Player].b_isEnemy(Local) )
  233.             {
  234.                 fNearestTarget = gMath.GetFOV( Local.vAngles, Local.vPosition, Entity[i_Player].vecBone );
  235.                 iNearestTarget = i_Player;
  236.             }
  237.             if ( iNearestTarget != -1)
  238.             {
  239.                 if(GetAsyncKeyState(1/*mouse1*/) && doAim)
  240.                 {
  241.                     gMath.CalcAngle(Local.vPosition, Entity[iNearestTarget].vecBone, fAimAngles);
  242.                     //leeb norecoil
  243.                     fAimAngles[0] -= Local.vPunchAngles[0] * 2.0f;
  244.                     fAimAngles[1] -= Local.vPunchAngles[1] * 2.0f;
  245.                     fAimAngles[2] -= Local.vPunchAngles[2] * 2.0f;
  246.  
  247.                     SetViewAngles( fAimAngles );
  248.                 }
  249.             }
  250.             DropTarget();
  251.         }
  252.     }
  253. }
  254.  
  255. void Trigger(void)
  256. {
  257.     while(true)
  258.     {
  259.         Sleep(1);
  260.         Entity[Local.iCrosshairID].FillStruct(Local.iCrosshairID);
  261.         if (GetAsyncKeyState(18/*ALT*/) && Local.b_PlayerInCrosshair() && Entity[Local.iCrosshairID].b_isEnemy(Local))
  262.         {
  263.             Local.cmd_Attack();
  264.         }
  265.         /*Knifebot
  266.  
  267.         if(Local.b_PlayerInCrosshair() && (gMath.GetDistance(Entity[Local.m_i_CrosshairID].v_Position, Local.v_Position )) <= 90)
  268.         {
  269.             Local.cmd_Attack2();
  270.         }
  271.         */
  272.     }
  273. }
  274.  
  275. void Bhop(void)
  276. {
  277.     while(true)
  278.     {
  279.         Sleep(1);
  280.         if(Local.b_OnGround() && GetAsyncKeyState(32))
  281.         {
  282.             Local.cmd_Jump();
  283.         }
  284.     }
  285. }
  286.  
  287. int main()
  288. {
  289.     gProcess.Initialize();
  290.  
  291.     Local.mp_playerid();
  292.     Local.NoFlash();
  293.     Local.NoSmoke();
  294.  
  295.     CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Update, 0, 0, 0);
  296.     CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Trigger, 0, 0, 0);
  297.     CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Bhop, 0, 0, 0);
  298.     CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Aim, 0, 0, 0);
  299.  
  300.     while (FindWindow(NULL, "Counter-Strike Source"))
  301.         Sleep(10);
  302. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement