- // Credits Maikel233 You Have To Debug It To start
- // for maximum stealth, change the names below to something personal
- #define APPNAME L"maik"
- #define MUTEXNAME L"maik"
- // Includes
- #include <d3d9.h>
- #include <d3dx9.h>
- #include <dwmapi.h>
- #include <stdio.h>
- #include <math.h>
- //---------------------------------------------------------------------------
- // Import libraries to link with
- #pragma comment(lib, "d3d9.lib")
- #pragma comment(lib, "d3dx9.lib")
- #pragma comment(lib, "dwmapi.lib")
- #define CALIBRATING 0
- #define DEBUG_HQ 0
- #define MOTION 0
- // Global colors - change as you want to customize your version
- // format is 0xAARRGGBB: AA alpha (0=transparent, FF=opaque), RR red, GG green, BB blue
- #define ARGB_TRANS 0x00000000 // 100% alpha
- #define COLOR_FRIEND 0x800000FF // blue
- #define COLOR_ENEMY 0x80C00000 // dark red
- #define COLOR_ENEMY_COLDBLOODED 0x80FFBF00 // orange
- #define COLOR_DEAD 0x80444444 // dead body, the player is watching killcam
- #define COLOR_SENTRY 0x8000B050 // green
- #define COLOR_EXPLOSIVE 0x407F7F7F // yellow
- // colors for mini-map
- #define MAP_COLOR_FRIEND 0xFF4444FF
- #define MAP_COLOR_ENEMY 0XFFFF4444
- #define MAP_COLOR_ENEMY_COLDBLOODED 0XFFFFBF44
- #define MAP_COLOR_SENTRY 0xFF00B050 // green
- #define MAP_COLOR_EXPLOSIVE 0xFFFFFF00 // yellow
- // Game offsets - to be changed for new COD6 builds
- // these are for 1.0.184
- #define REFDEF 0x85F030
- #define ENTITY 0x8F7AF8
- #define CLIENTINFO 0x8EB2C8
- #define CG_T 0x7F49BC
- #define CGS_T 0x7F0CF8
- #define ISINGAME 0x7F48C8
- #define VIEWANGLEY 0xB35A40
- #define PLAYERMAX 18 // number of players to loop in
- #define ENTITIESMAX 2048 // total number of entities present
- #define M_PI 3.1415f
- // players poses
- #define FLAGS_CROUCHED 0x0004
- #define FLAGS_PRONE 0x0008
- #define FLAGS_FIRING 0x0200
- // Structs
- // originally in classes.h
- class Vector
- {
- public:
- Vector() { x = y = z = 0.0f; }
- Vector(float X, float Y, float Z) { x = X; y = Y; z = Z; }
- Vector(const Vector &v) { x = v.x; y = v.y; z = v.z; }
- float length() { return sqrt(x*x+y*y+z*z); }
- void substract(Vector sub) { x-=sub.x; y -= sub.y; z -= sub.z; }
- float dotproduct(Vector dot) { return (x*dot.x+y*dot.y+z*dot.z); }
- void normalize() { float l = 1/length(); x *= l; y *= l; z *= l; }
- float vectodegree(Vector to) { return ((180.0f/3.1415f)*(asinf(dotproduct(to)))); }
- Vector RotateX(Vector in, float angle) { float a,c,s; Vector out; a = (float) (angle * M_PI/180); c = (float) cos(a); s = (float) sin(a); out.x = in.x; out.y = c*in.y - s*in.z; out.z = s*in.y + c*in.z; return out; }
- Vector RotateY(Vector in, float angle) { float a,c,s; Vector out; a = (float) (angle * M_PI/180); c = (float) cos(a); s = (float) sin(a); out.x = c*in.x + s*in.z; out.y = in.y; out.z = -s*in.x + c*in.z; return out; }
- Vector RotateZ(Vector in, float angle) { float a,c,s; Vector out; a = (float) (angle * M_PI/180); c = (float) cos(a); s = (float) sin(a); out.x = c*in.x - s*in.y; out.y = s*in.x + c*in.y; out.z = in.z; return out; }
- void nullvec() { x = y = z = 0; }
- void operator = (const float *farray) { x = farray[0]; y = farray[1]; z = farray[2]; }
- void operator = (const float &val) { x = y = z = val; }
- float operator [] (unsigned int element) { switch(element) { case 1: return y; case 2: return z; default: return x; } }
- Vector operator + (const Vector& add) const { return Vector(x+add.x,y+add.y,z+add.z); }
- void operator += (const Vector& add) { x += add.x; y += add.y; z += add.z; }
- Vector operator - (const Vector& sub) const { return Vector(x-sub.x,y-sub.y,z-sub.z); }
- void operator -= (const Vector& sub) { x -= sub.x; y -= sub.y; z -= sub.z; }
- Vector operator * (const float mul) const { return Vector(x*mul,y*mul,z*mul); }
- void operator *= (const float mul) { x *= mul; y *= mul; z *= mul; }
- Vector operator / (const float mul) const { return Vector(x/mul,y/mul,z/mul); }
- void operator /= (const float mul) { x /= mul; y /= mul; z /= mul; }
- bool operator == (const Vector& eqal) { return ((x == eqal.x) && (y == eqal.y) && (z == eqal.z)); }
- bool operator != (const Vector& eqal) { return ((x != eqal.x) && (y != eqal.y) && (z != eqal.z)); }
- bool operator > (const Vector& eqal) { return ((x > eqal.x) && (y > eqal.y) && (z > eqal.z)); }
- bool operator < (const Vector& eqal) { return ((x < eqal.x) && (y < eqal.y) && (z < eqal.z)); }
- bool operator >= (const Vector& eqal) { return ((x >= eqal.x) && (y >= eqal.y) && (z >= eqal.z)); }
- bool operator <= (const Vector& eqal) { return ((x <= eqal.x) && (y <= eqal.y) && (z <= eqal.z)); }
- float x;
- float y;
- float z;
- };
- // from Big Dave
- class MW2_View_Y
- {
- public:
- Vector Recoil; // 0x0000
- char _p00[24]; // 0x000C
- Vector viewAngles; // 0x0024
- char _p01[16]; // 0x0030
- float AngleY; // 0x0040
- float AngleX; // 0x0044
- };
- class MW2_ClientInfo_T
- {
- public:
- char Unknown1[12];
- char name[16]; //0x000C
- __int32 team; //0x001C
- __int32 team2; //0x0020
- char unknown36[8]; //0x0024
- __int32 perk; //0x002C
- char unknown48[16]; //0x0030
- char BodyModel[64]; //0x0040
- char HeadModel[64]; //0x0080
- char WeaponModel[64]; //0x00C0
- char WeaponModel2[64]; //0x0100
- char WeaponExplosive[64]; //0x0140
- char unknown372[552]; //0x0180
- __int32 pose; //0x03A8
- char unknown936[96]; //0x03AC
- __int32 pose2; //0x040C
- char unknown1028[284]; //0x0410
- };
- class MW2_Entity_T
- {
- public:
- __int16 unknown0; //0x0000
- __int16 valid; //0x0002
- char unknown4[20]; //0x0003
- Vector pos; //0x0018
- char unknown36[72]; //0x0024
- __int32 pose; //0x006C
- char unknown109[12]; //0x0070
- float fPitch; //0x007C
- float fYaw; //0x0080
- float fRoll; //0x0084
- char unknown136[84]; //0x0088
- __int32 clientnum; //0x00DC
- __int32 typ; //0x00E0
- __int8 PlayerPose; //0x00E4
- __int8 Shooting; //0x00E5
- __int8 Zoomed; //0x00E6
- char unknown231[193]; //0x00E7
- __int16 WeaponNum; //0x01A8
- char unknown426[50]; //0x01AA
- __int32 alive; //0x01DC
- char unknown480[36]; //0x01E0
- };
- enum entity_type_t
- {
- ET_GENERAL = 0,
- ET_PLAYER = 1,
- ET_PLAYER_CORPSE = 2,
- ET_ITEM = 3,
- ET_EXPLOSIVE = 4,
- ET_INVISIBLE = 5,
- ET_SCRIPTMOVER = 6,
- ET_SOUND_BLEND = 7,
- ET_FX = 8,
- ET_LOOP_FX = 9,
- ET_PRIMARY_LIGHT = 10,
- ET_TURRET = 11,
- ET_HELICOPTER = 12,
- ET_PLANE = 13,
- ET_VEHICLE = 14,
- ET_VEHICLE_COLLMAP = 15,
- ET_VEHICLE_CORPSE = 16,
- ET_VEHICLE_SPAWNER = 17
- };
- class cPlayerInfo
- {
- public:
- COLORREF color;
- };
- // globals read from COD6
- int localclientnum, my_team;
- //int viewstatus;
- int kills;
- int deaths;
- int lastkills = 0;
- int lastdeaths = 0;
- int killcount;
- cPlayerInfo player[PLAYERMAX];
- DWORD IsInGame;
- MW2_ClientInfo_T mw2_clientinfo[PLAYERMAX];
- MW2_Entity_T mw2_entities[ENTITIESMAX]; // get a copy of entities
- MW2_View_Y mw2_view;
- long gTicks = 0;
- int mouse_move_x = 0;
- int mouse_move_y = 0;
- // Globals
- wchar_t status[512] = L"waiting"; //status message to display
- WCHAR *g_wcpAppName = APPNAME; // App name
- INT g_iWidth = 800; // initial width
- INT g_iHeight = 600; // initial height
- MARGINS g_mgDWMMargins = {-1, -1, -1, -1}; // margins for DWM
- IDirect3D9Ex *g_pD3D = NULL; // Direct3D object
- IDirect3DDevice9Ex *g_pD3DDevice = NULL; // Direct3D device
- ID3DXLine *line = NULL; // Direct3D line for player box
- ID3DXLine *back_line = NULL; // Direct3D line for black background behind status text
- ID3DXLine *radar_line = NULL; // Direct3D line for black background behind status text
- ID3DXFont *g_font = NULL; // Direct3D font for status display & player name
- ID3DXFont *g_killstreak_font = NULL; // Direct3D font for displaying current killstreak
- //ID3DXFont *g_kills_font = NULL; // Direct3D font for displaying current kills and deaths
- // from OSHeCoD6
- HANDLE mw2_process = NULL; // COD6 process
- DWORD mw2_pid = 0; // COD6 process PID
- HWND mw2_hwnd = NULL; // COD6 window
- int resolution[2]; // COD6 screen size
- int screencenter[2]; // COD6 screen center (local coordinates)
- int mouse_center[2]; // center for mouse movement
- int border_x, border_y; // COD6 border size
- bool init_ok = FALSE; // is everything initialised?
- //===========================================================================
- //---------------------------------------------------------------------------
- void MouseMove( float x, float y );
- int MinDist( float dists[] );
- bool FindAngle( Vector target, Vector player, float *ftraj_angle, float range );
- void DrawString(int x, int y, COLORREF color, bool center, char* text);
- void DrawBox(int x, int y, int w, int h, COLORREF color);
- bool WorldToScreen(const Vector &WorldLocation, float *fScreenX, float *fScreenY);
- void ReadGame();
- void Esp();
- void Radar();
- void CrossHair();
- void Render();
- void Bot();
- void KillCounter();
- void DisplayStatus();
- void Toggles();
- void draw4Outline(float x1, float y1, float x2, float y2,
- float x3, float y3, float x4, float y4, D3DCOLOR color);
- void fillRect(float x, float y, float w, float h, D3DCOLOR color);
- bool FindSlope(Vector *target, Vector *player, float vel, float *ftraj_slope);
- //---------------------------------------------------------------------------
- Vector mypos, viewangles;
- float fov[2];
- float grav = 322.f; // in 1/10th of feet/sē
- float tube_vel = 1550.f; // which is 155 ft/s, or 47m/s
- float knife_vel = 900.f; // which is 90 ft/s, or 27m/s
- // toggles for Fn keys
- #define FN_TOGGLES 12
- bool Fn[FN_TOGGLES] = { true, true, // F1 F2
- false, true, // F3 F4
- true, false, // F5 F6
- false, false, // F7 F8
- false, false, // F9 F10
- false, true }; // F11 F12
- wchar_t* Fn_label[FN_TOGGLES] = {
- L"radar", // F1
- L"box esp", // F2
- L"crosshair", // F3
- L"explosives", // F4
- L"aimbot", // F5
- L"tubebot", // F6
- L"knifebot", // F7
- L"autostab", // F8
- L"triggerbot", // F9
- L"", // F10
- L"", // F11
- L"status", // F12
- };
- // mini-map
- const float radar_size = 160.0f; // size of the radar in pixels
- const float radar_offset = 20.0f; // margin from top and right of the screen, in pixels
- // radar globals
- float rx, ry; // position x/y of mini-map
- float rh, rw; // size of mini-map
- //---------------------------------------------------------------------------
- // WindowProc()
- //
- // The main window message handler
- LRESULT WINAPI WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- switch(uMsg)
- {
- case WM_DESTROY:
- // Signal application to terminate
- PostQuitMessage(0);
- return 0;
- case WM_KEYDOWN:
- // If ESC has been pressed then signal window should close
- if (LOWORD(wParam) == VK_ESCAPE) SendMessage(hWnd, WM_CLOSE, NULL, NULL);
- break;
- case WM_ERASEBKGND:
- // We dont want to call render twice so just force Render() in WM_PAINT to be called
- SendMessage(hWnd, WM_PAINT, NULL, NULL);
- return TRUE;
- case WM_PAINT:
- // Force a render to keep the window updated
- //Render(); // not useful anymore
- return 0;
- }
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
- }
- //---------------------------------------------------------------------------
- // drawPlayer - draws a sort of 2pix circle
- VOID drawPlayer(float x, float y, D3DCOLOR color)
- {
- draw4Outline(x, y - 2,
- x + 2, y,
- x, y + 2,
- x - 2, y,
- color);
- }
- //---------------------------------------------------------------------------
- // D3DStartup()
- //
- // Initialise all Direct3D objects linked to the hWnd
- HRESULT D3DStartup(HWND hWnd)
- {
- BOOL bCompOk = FALSE; // Is composition enabled?
- D3DPRESENT_PARAMETERS pp; // Presentation prefs
- DWORD msqAAQuality = 0; // Non-maskable quality
- HRESULT hr;
- // Make sure that DWM composition is enabled
- DwmIsCompositionEnabled(&bCompOk);
- if(!bCompOk) return E_FAIL;
- // Create a Direct3D object
- hr = Direct3DCreate9Ex(D3D_SDK_VERSION, &g_pD3D);
- if (FAILED(hr)) {
- swprintf_s(status, L"Error Direct3DCreate9Ex:%u", hr);
- MessageBox(0,status,L"Error",MB_ICONERROR);
- return E_FAIL;
- }
- // Setup presentation parameters
- ZeroMemory(&pp, sizeof(pp));
- pp.Windowed = TRUE;
- pp.SwapEffect = D3DSWAPEFFECT_DISCARD; // Required for multi sampling
- pp.BackBufferFormat = D3DFMT_A8R8G8B8; // Back buffer format with alpha channel
- // Set highest quality non-maskable AA available or none if not
- if (SUCCEEDED(g_pD3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT,
- D3DDEVTYPE_HAL,
- D3DFMT_A8R8G8B8,
- TRUE,
- D3DMULTISAMPLE_NONMASKABLE,
- &msqAAQuality
- )))
- {
- // Set AA quality
- pp.MultiSampleType = D3DMULTISAMPLE_NONMASKABLE;
- pp.MultiSampleQuality = msqAAQuality - 1;
- }
- else
- {
- // No AA
- pp.MultiSampleType = D3DMULTISAMPLE_NONE;
- }
- // Create a Direct3D device object
- hr = g_pD3D->CreateDeviceEx(D3DADAPTER_DEFAULT,
- D3DDEVTYPE_HAL,
- hWnd,
- D3DCREATE_HARDWARE_VERTEXPROCESSING,
- &pp,
- NULL,
- &g_pD3DDevice
- );
- if (FAILED(hr)) {
- swprintf_s(status, L"Error CreateDeviceEx:%u", hr);
- MessageBox(0,status,L"Error",MB_ICONERROR);
- return E_FAIL;
- }
- hr=D3DXCreateFont(g_pD3DDevice, //D3D Device
- 14, //Font height
- 0, //Font width
- FW_NORMAL, //Font Weight
- 1, //MipLevels
- false, //Italic
- DEFAULT_CHARSET, //CharSet
- OUT_DEFAULT_PRECIS, //OutputPrecision
- DEFAULT_QUALITY, //Quality
- DEFAULT_PITCH|FF_DONTCARE, //PitchAndFamily
- L"Arial", //pFacename,
- &g_font); //ppFont
- hr=D3DXCreateFont(g_pD3DDevice, //D3D Device
- 120, //Font height
- 0, //Font width
- FW_BOLD, //Font Weight
- 2, //MipLevels
- false, //Italic
- DEFAULT_CHARSET, //CharSet
- OUT_DEFAULT_PRECIS, //OutputPrecision
- DEFAULT_QUALITY, //Quality
- DEFAULT_PITCH|FF_DONTCARE, //PitchAndFamily
- L"Arial", //pFacename,
- &g_killstreak_font); //ppFont
- //hr=D3DXCreateFont(g_pD3DDevice, //D3D Device
- // 36, //Font height
- // 0, //Font width
- // FW_BOLD, //Font Weight
- // 1, //MipLevels
- // false, //Italic
- // DEFAULT_CHARSET, //CharSet
- // OUT_DEFAULT_PRECIS, //OutputPrecision
- // DEFAULT_QUALITY, //Quality
- // DEFAULT_PITCH|FF_DONTCARE, //PitchAndFamily
- // L"Arial", //pFacename,
- // &g_kills_font); //ppFont
- // Line used for player box
- // Currently 3 pixels thick. Color is specified when drawing
- if (FAILED(D3DXCreateLine(g_pD3DDevice, &line))) return E_FAIL;
- line->SetWidth(3);
- line->SetPattern(0xffffffff);
- line->SetAntialias(FALSE);
- // Line used to draw a black background under the status text (upper left corner of window)
- // currently 20 pixels wide
- if (FAILED(D3DXCreateLine(g_pD3DDevice, &back_line))) return E_FAIL;
- back_line->SetWidth(20);
- back_line->SetPattern(0xffffffff);
- back_line->SetAntialias(FALSE);
- // Line used to draw the mini radar
- // currently 1 pixel wide
- if (FAILED(D3DXCreateLine(g_pD3DDevice, &radar_line))) return E_FAIL;
- radar_line->SetWidth(1.5f);
- radar_line->SetPattern(0xffffffff);
- radar_line->SetAntialias(FALSE);
- return S_OK;
- }
- //---------------------------------------------------------------------------
- // D3DShutdown()
- //
- // Release all created Direct3D objects
- VOID D3DShutdown(VOID)
- {
- if (line != NULL) line->Release();
- if (back_line != NULL) back_line->Release();
- if (radar_line != NULL) radar_line->Release();
- if (g_font != NULL) g_font->Release();
- if (g_killstreak_font != NULL) g_killstreak_font->Release();
- // if (g_kills_font != NULL) g_kills_font->Release();
- if (g_pD3DDevice != NULL) g_pD3DDevice->Release();
- if (g_pD3D != NULL) g_pD3D->Release();
- }
- //---------------------------------------------------------------------------
- // Render()
- //
- // Render the scene to the back buffer
- VOID Render(VOID)
- {
- gTicks++;
- // Sanity check
- if(g_pD3DDevice == NULL) return;
- // Clear the back buffer and z buffer to transparent
- g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, ARGB_TRANS, 1.0f, 0);
- // Render scene
- if (SUCCEEDED(g_pD3DDevice->BeginScene()))
- {
- if (init_ok) // if everything is correctly initialised
- {
- IsInGame = 0;
- ReadGame(); // read all structures in memory
- Toggles();
- Esp(); // draw game overlay
- Radar();
- CrossHair();
- Bot();
- KillCounter();
- DisplayStatus();
- }
- g_pD3DDevice->EndScene();
- }
- // Update display
- g_pD3DDevice->PresentEx(NULL, NULL, NULL, NULL, NULL);
- }
- //---------------------------------------------------------------------------
- // WinMain()
- //
- // Program entry point
- //---------------------------------------------------------------------------
- int wndpos[2] = {0, 0};
- INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, INT)
- {
- HWND hWnd = NULL;
- MSG uMsg;
- HRESULT hr;
- CreateMutex(0,false,MUTEXNAME );
- if(GetLastError())
- {
- MessageBox(0,L"External BoxESP is already running!",L"Error",MB_ICONERROR);
- return 0;
- }
- WNDCLASSEX wc = {sizeof(WNDCLASSEX), // cbSize
- NULL, // style
- WindowProc, // lpfnWndProc
- NULL, // cbClsExtra
- NULL, // cbWndExtra
- hInstance, // hInstance
- LoadIcon(NULL, IDI_APPLICATION), // hIcon
- LoadCursor(NULL, IDC_ARROW), // hCursor
- NULL, // hbrBackground
- NULL, // lpszMenuName
- g_wcpAppName, // lpszClassName
- LoadIcon(NULL, IDI_APPLICATION)};// hIconSm
- RegisterClassEx(&wc);
- hWnd = CreateWindowEx(WS_EX_TOPMOST | WS_EX_COMPOSITED | WS_EX_TRANSPARENT | WS_EX_LAYERED, // dwExStyle
- // WS_EX_COMPOSITED: for best performance in transparent mode
- // WS_EX_TOPMOST: always on top window
- // WS_EX_TRANSPARENT | WS_EX_LAYERED: click-through window
- g_wcpAppName, // lpClassName
- g_wcpAppName, // lpWindowName
- WS_POPUP, // dwStyle
- // dropped the WS_SIZEBOX, otherwise we have a "glow" background
- //WS_POPUP | WS_SIZEBOX, // dwStyle
- CW_USEDEFAULT, CW_USEDEFAULT, // x, y
- g_iWidth, g_iHeight, // nWidth, nHeight
- NULL, // hWndParent
- NULL, // hMenu
- hInstance, // hInstance
- NULL); // lpParam
- // Extend glass to cover whole window
- hr = DwmExtendFrameIntoClientArea(hWnd, &g_mgDWMMargins);
- /* if (FAILED(hr)) {
- swprintf_s(status, L"Error DwmExtendFrameIntoClientArea:%u", hr);
- MessageBox(0,status,L"Error",MB_ICONERROR);
- return E_FAIL;
- }*/
- // Initialise Direct3D
- if (SUCCEEDED(D3DStartup(hWnd)))
- {
- // Show the window
- ShowWindow(hWnd, SW_SHOWDEFAULT);
- UpdateWindow(hWnd);
- // Enter main loop
- while(TRUE)
- {
- // Check for a message
- if(PeekMessage(&uMsg, NULL, 0, 0, PM_REMOVE))
- {
- // Check if the message is WM_QUIT
- if(uMsg.message == WM_QUIT)
- {
- // Break out of main loop
- break;
- }
- // Pump the message
- TranslateMessage(&uMsg);
- DispatchMessage(&uMsg);
- }
- // Check if we need initialization
- if (mw2_hwnd == NULL) {
- mw2_hwnd = FindWindow(NULL,L"Modern Warfare 2");
- if (mw2_hwnd != NULL)
- swprintf_s(status, L"app foundn");
- }
- if ((mw2_hwnd != NULL) && (mw2_pid == 0)) {
- GetWindowThreadProcessId(mw2_hwnd,&mw2_pid);
- }
- if ((mw2_process == NULL) && (mw2_pid != 0)) {
- mw2_process = OpenProcess(PROCESS_VM_READ,false,mw2_pid);
- }
- if (mw2_process != NULL) {
- if ((!init_ok) || ((gTicks % 20) == 0)) {
- RECT client_rect;
- GetClientRect(mw2_hwnd, &client_rect);
- resolution[0] = client_rect.right;
- resolution[1] = client_rect.bottom;
- screencenter[0] = resolution[0]/2;
- screencenter[1] = resolution[1]/2;
- RECT bounding_rect;
- GetWindowRect(mw2_hwnd,&bounding_rect);
- mouse_center[0] = (bounding_rect.right - bounding_rect.left) / 2;
- mouse_center[1] = (bounding_rect.bottom - bounding_rect.top) / 2;
- border_x = ::GetSystemMetrics(SM_CXBORDER);
- border_y = ::GetSystemMetrics(SM_CYCAPTION);
- swprintf_s(status, L"Resolution: %ux%u, pos; %ix%ix%ix%i, border: %ix%i",resolution[0],resolution[1],
- bounding_rect.left,bounding_rect.top,bounding_rect.right,bounding_rect.bottom,
- border_x, border_y);
- if (init_ok) {
- if ((wndpos[0] != bounding_rect.left) || (wndpos[1] != bounding_rect.top)) {
- MoveWindow(hWnd, bounding_rect.left,bounding_rect.top, resolution[0],resolution[1],false);
- wndpos[0] = bounding_rect.left;
- wndpos[1] = bounding_rect.top;
- }
- } else {
- if ((bounding_rect.left == 0) && (bounding_rect.top == 0)) {
- // we force a 1 pixel move, otherwise the window is not resized (bug?)
- MoveWindow(hWnd, -1, -1, resolution[0],resolution[1],false);
- }
- MoveWindow(hWnd, bounding_rect.left,bounding_rect.top, resolution[0],resolution[1],false);
- wndpos[0] = bounding_rect.left;
- wndpos[1] = bounding_rect.top;
- // calc mini-map pos
- rx = resolution[0]/2 - radar_size/2;
- ry = radar_offset + border_y;
- rh = rw = radar_size;
- D3DShutdown(); // we resized then window so we need to recreate all D3D objects
- D3DStartup(hWnd);
- }
- init_ok = true; // off we go!
- }
- }
- Render();
- if ((init_ok) && ((gTicks % 10) == 0)) { // check only every 10 frames
- if (FindWindow(NULL,L"Modern Warfare 2") == NULL) {
- SendMessage(hWnd, WM_CLOSE, NULL, NULL); // quit if game is closed
- }
- }
- }
- }
- // Shutdown Direct3D
- D3DShutdown();
- // Exit application
- return 0;
- }
- //---------------------------------------------------------------------------
- void AngleVectors(const Vector &angles, Vector *forward, Vector *right, Vector *up)
- {
- float angle;
- static float sr, sp, sy, cr, cp, cy, cpi = (M_PI*2/360);
- angle = angles.y * cpi;
- sy = sin(angle);
- cy = cos(angle);
- angle = angles.x * cpi;
- sp = sin(angle);
- cp = cos(angle);
- angle = angles.z * cpi;
- sr = sin(angle);
- cr = cos(angle);
- if(forward)
- {
- forward->x = cp*cy;
- forward->y = cp*sy;
- forward->z = -sp;
- }
- if(right)
- {
- right->x = (-1*sr*sp*cy+-1*cr*-sy);
- right->y = (-1*sr*sp*sy+-1*cr*cy);
- right->z = -1*sr*cp;
- }
- if(up)
- {
- up->x = (cr*sp*cy+-sr*-sy);
- up->y = (cr*sp*sy+-sr*cy);
- up->z = cr*cp;
- }
- }
- //---------------------------------------------------------------------------
- bool WorldToScreen(const Vector &WorldLocation, float *fScreenX, float *fScreenY)
- {
- Vector vLocal, vTransForm, vForward, vRight, vUpward;
- AngleVectors(viewangles,&vForward,&vRight,&vUpward);
- vLocal = WorldLocation - mypos;
- vTransForm.x = vLocal.dotproduct(vRight);
- vTransForm.y = vLocal.dotproduct(vUpward);
- vTransForm.z = vLocal.dotproduct(vForward);
- if (vTransForm.z < 0.01)
- return false;
- *fScreenX = screencenter[0] + (screencenter[0]/vTransForm.z * (1/fov[0])) * vTransForm.x;
- *fScreenY = screencenter[1] - (screencenter[1]/vTransForm.z * (1/fov[1])) * vTransForm.y;
- return true;
- }
- //---------------------------------------------------------------------------
- void DrawBox(float x, float y, float w, float h, COLORREF color)
- {
- x += border_x;
- y += border_y;
- D3DXVECTOR2 points[5];
- points[0] = D3DXVECTOR2(x, y);
- points[1] = D3DXVECTOR2(x+w, y);
- points[2] = D3DXVECTOR2(x+w, y+h);
- points[3] = D3DXVECTOR2(x, y+h);
- points[4] = D3DXVECTOR2(x, y);
- line->Draw(points, 5, color);
- }//---------------------------------------------------------------------------
- void DrawClaymore(float x, float y)
- {
- x += border_x;
- y += border_y;
- fillRect(x-8, y, 16, 16, 0x3FFF6666);
- }
- //---------------------------------------------------------------------------
- void DrawString(float x, float y, COLORREF color, char* text, ID3DXFont *font)
- {
- RECT font_rect;
- // char* to LPCWSTR
- // http://www.codeguru.com/forum/showthread.php?t=231165
- int a = lstrlenA(text);
- BSTR unicodestr = SysAllocStringLen(NULL, a);
- ::MultiByteToWideChar(CP_ACP, 0, text, a, unicodestr, a);
- //... when done, free the BSTR
- SetRect(&font_rect, (int)x-150, (int)y-10, (int)x+150, (int)y+18);
- int font_height=font->DrawText(NULL, //pSprite
- unicodestr, //pString
- -1, //Count
- &font_rect, //pRect
- DT_CENTER | DT_NOCLIP | DT_SINGLELINE,//Format = centered, no clip and force single line
- color); //Color
- ::SysFreeString(unicodestr);
- }
- //---------------------------------------------------------------------------
- bool IsInSpace( float x, float y )
- {
- return ( ( x >= rx && y >= ry ) && ( x <= ( rx + rw ) && y <= ( ry + rh ) ) );
- }
- void CalcPoint( Vector vec, float *nx, float *ny, float flRange )
- {
- float fy = D3DXToRadian(viewangles.y); // y is YAW
- float fc = cos( fy );
- float fs = sin( fy );
- float dx = vec[ 0 ] - mypos[0];
- float dy = vec[ 1 ] - mypos[1];
- float px = dy * ( -fc ) + ( dx * fs );
- float py = dx * ( -fc ) - ( dy * fs );
- float irrx = ( rx + ( rw / 2 ) ) + int( px / flRange );
- float irry = ( ry + ( rh / 2 ) ) + int( py / flRange );
- // force on border of radar if off range
- if (irrx < rx) irrx = rx;
- if (irry < ry) irry = ry;
- if (irrx > rx + rw) irrx = rx + rw;
- if (irry > ry + rh) irry = ry + rh;
- *nx = irrx;
- *ny = irry;
- }
- //---------------------------------------------------------------------------
- void KillCounter()
- {
- char kill_str[128];
- if (!IsInGame) {
- lastdeaths = deaths;
- lastkills = kills;
- killcount = 0;
- return;
- }
- if (deaths != lastdeaths) {
- killcount = 0;
- lastdeaths = deaths;
- }
- if (kills != lastkills) {
- killcount = killcount + (kills - lastkills);
- lastkills = kills;
- }
- sprintf_s(kill_str, "%i", killcount);
- DrawString((float) (resolution[0]-100),70,0x5FFFFFFF,kill_str, g_killstreak_font);
- //sprintf_s(kill_str, "%i / %i", kills, deaths);
- //DrawString(resolution[0]-100,40,0x7F7FFF7F,kill_str, g_kills_font);
- }
- //---------------------------------------------------------------------------
- void ReadGame()
- {
- ReadProcessMemory(mw2_process,(PVOID)ISINGAME,&IsInGame,4,NULL);
- if (IsInGame)
- {
- ReadProcessMemory(mw2_process,(PVOID)(0x00A0178C),&kills,4,NULL);
- ReadProcessMemory(mw2_process,(PVOID)(0x01B2B920),&deaths,4,NULL);
- //ReadProcessMemory(mw2_process,(PVOID)(0x00868758),&viewstatus,4,NULL);
- ReadProcessMemory(mw2_process,(PVOID)(CG_T),&localclientnum,4,NULL);
- ReadProcessMemory(mw2_process,(PVOID)(REFDEF+0x10),&fov,8,NULL);
- //ReadProcessMemory(mw2_process,(PVOID)(REFDEF+0x18),&mypos,12,NULL);
- ReadProcessMemory(mw2_process,(PVOID)(REFDEF+0x9904),&mypos,12,NULL);
- //ReadProcessMemory(mw2_process,(PVOID)(REFDEF+0x3F90),&viewangles,12,NULL);
- ReadProcessMemory(mw2_process,(PVOID)(VIEWANGLEY-0x40),&mw2_view,sizeof(mw2_view), NULL);
- viewangles = mw2_view.viewAngles;
- ReadProcessMemory(mw2_process,(PVOID)ENTITY,mw2_entities,sizeof(mw2_entities),NULL);
- ReadProcessMemory(mw2_process,(PVOID)CLIENTINFO,mw2_clientinfo,sizeof(mw2_clientinfo),NULL);
- for(int i = 0; i < PLAYERMAX; i++)
- {
- if (localclientnum == mw2_entities[i].clientnum) {
- my_team = mw2_clientinfo[i].team;
- break;
- }
- }
- }
- }
- //---------------------------------------------------------------------------
- void Toggles()
- {
- static bool Fn_last_state[FN_TOGGLES];
- for (int i=0; i<FN_TOGGLES; i++) {
- bool key = (GetAsyncKeyState(VK_F1 + i) & 0x8000) != 0;
- if (key && !(Fn_last_state[i])) {
- Fn[i] = !(Fn[i]);
- }
- Fn_last_state[i] = key;
- }
- }
- //---------------------------------------------------------------------------
- void DisplayStatus()
- {
- wchar_t final_status[512]; //status message to display
- RECT font_rect;
- SetRect(&font_rect,5,5,795,15);
- // draw a black background behind text
- D3DXVECTOR2 back_points[2];
- back_points[0] = D3DXVECTOR2(0.0f, 10.0f);
- back_points[1] = D3DXVECTOR2(800.0f, 10.0f);
- back_line->Draw(back_points, 2, 0xFF000000);
- if (Fn[11]) { // F12 status
- for (int i=0; i<FN_TOGGLES; i++) {
- COLORREF color = Fn[i] ? 0xFFFFCC00 : 0xFF777777;
- font_rect.left = i*65 + 5;
- font_rect.right = i*65 + 70;
- swprintf_s(final_status, L"F%i %s", i+1, Fn_label[i]);
- int font_height=g_font->DrawText(NULL, //pSprite
- final_status, //pString
- -1, //Count
- &font_rect, //pRect
- DT_LEFT|DT_NOCLIP,//Format,
- color); //Color = white opaque
- }
- } else if (wcslen(status) > 0) {
- // draw status text if non-empty
- //swprintf_s(final_status, L"%s", status);
- swprintf_s(final_status, L"F12 %s, mouse_move=%ix%i, view=%.1f|%.1f|%.1f, pos=%.1f|%.1f|%.1f",
- status, mouse_move_x, mouse_move_y,
- viewangles.x, viewangles.y, viewangles.z,
- mypos.x, mypos.y, mypos.z);
- //swprintf_s(final_status, L"%s, mouve_move=%ix%i " , status, mouse_move_x, mouse_move_y,viewstatus,kills,deaths);
- // then draw text
- int font_height=g_font->DrawText(NULL, //pSprite
- final_status, //pString
- -1, //Count
- &font_rect, //pRect
- DT_LEFT|DT_NOCLIP,//Format,
- 0xFFFFFFFF); //Color = white opaque
- }
- }
- //---------------------------------------------------------------------------
- void CrossHair()
- {
- if (!IsInGame || !Fn[2]) // F3
- return;
- float x = screencenter[0] + border_x + 1.5f;
- float y = screencenter[1] + border_y + 2.5f;
- D3DXVECTOR2 points[2];
- points[0] = D3DXVECTOR2(x - 10, y);
- points[1] = D3DXVECTOR2(x + 10, y);
- radar_line->Draw(points, 2, 0xCCFF1111);
- points[0] = D3DXVECTOR2(x, y-10);
- points[1] = D3DXVECTOR2(x, y+10);
- radar_line->Draw(points, 2, 0xCCFF1111);
- }
- //---------------------------------------------------------------------------
- void Esp()
- {
- float drawx, drawy;
- bool enemy;
- float dist, ScreenX, ScreenY;
- if (!IsInGame)
- return;
- for(int i = 0; i < ENTITIESMAX; i++)
- {
- //if ((mw2_entities[i].typ != ET_PLAYER) && (mw2_entities[i].typ != ET_TURRET) && (mw2_entities[i].typ != ET_EXPLOSIVE))
- // continue;
- if ((i < PLAYERMAX) && (mw2_entities[i].typ == ET_PLAYER) && mw2_entities[i].valid && mw2_entities[i].alive && (localclientnum != mw2_entities[i].clientnum))
- {
- enemy = false;
- if (mw2_entities[i].alive & 0x0001)
- {
- if ( ((mw2_clientinfo[i].team == 1) || (mw2_clientinfo[i].team == 2)) && (mw2_clientinfo[i].team == my_team) ) // same team
- player[i].color = COLOR_FRIEND;
- else{
- enemy = true;
- if (mw2_clientinfo[i].perk & 0x8000000)
- player[i].color = COLOR_ENEMY_COLDBLOODED; // player has cold blood perk
- else
- player[i].color = COLOR_ENEMY;
- }
- } else
- player[i].color = COLOR_DEAD;
- dist = (mypos-mw2_entities[i].pos).length()/48;
- if (WorldToScreen(mw2_entities[i].pos, &ScreenX, &ScreenY))
- {
- // player[i].pos is at the players foot
- float headX, headY;
- Vector head = mw2_entities[i].pos;
- head.z += 60; // eyepos of standing player
- WorldToScreen(head, &headX, &headY); // so we project to the screen coordinates
- drawy = ScreenY - headY;
- if (drawy < 10) // minimal size of the box
- drawy = 10;
- if (mw2_entities[i].pose & FLAGS_CROUCHED)
- {
- drawy /= 1.5f;
- drawx = drawy / 1.5f; // w/h ratio
- }
- else if (mw2_entities[i].pose & FLAGS_PRONE)
- {
- drawy /= 3.f;
- drawx = drawy * 2.f; // w/h ratio
- }
- else
- drawx = drawy / 2.75f; // standing up
- if (Fn[1]) { // F2 box
- DrawBox(ScreenX-(drawx/2),ScreenY,drawx,-drawy,player[i].color);
- DrawString(ScreenX+1,ScreenY-drawy+1,0x7F000000,mw2_clientinfo[i].name, g_font);
- DrawString(ScreenX,ScreenY-drawy,0x7FFFFFFF,mw2_clientinfo[i].name, g_font);
- }
- if (Fn[8] && (GetAsyncKeyState(VK_RBUTTON) & 0x8000)) { // F9 triggerbot
- if(ScreenX < screencenter[0] + (drawx) && ScreenX > screencenter[0] - (drawx)){
- if(ScreenY < screencenter[1] + (drawy) && ScreenY > screencenter[1] - (drawy)){
- static long last_fire_tick = 0;
- if (gTicks - last_fire_tick > 5) {
- last_fire_tick = gTicks;
- keybd_event((BYTE)VkKeyScan('H'),0x9e,0 , 0);
- keybd_event((BYTE)VkKeyScan('H'),0x9e, KEYEVENTF_KEYUP,0);
- }
- }
- }
- }
- }
- if (enemy && (dist < 3) && Fn[7]) { // F8 autostab
- static long last_melee_tick;
- if (gTicks - last_melee_tick > 10) {
- last_melee_tick = gTicks;
- keybd_event(0x45, 0x12, NULL, NULL);
- keybd_event(0x45, 0x12, KEYEVENTF_KEYUP, NULL);
- }
- }
- } else if ((mw2_entities[i].typ == ET_TURRET) || (mw2_entities[i].typ == ET_EXPLOSIVE)) {
- if (mw2_entities[i].alive & 0x01) {
- COLORREF color = (mw2_entities[i].typ == ET_TURRET) ? COLOR_SENTRY : COLOR_EXPLOSIVE;
- if (WorldToScreen(mw2_entities[i].pos, &ScreenX, &ScreenY))
- {
- if (mw2_entities[i].typ == ET_TURRET)
- {
- float headX, headY;
- Vector head = mw2_entities[i].pos;
- head.z += 20;
- WorldToScreen(head, &headX, &headY);
- drawy = ScreenY - headY;
- if (drawy < 5) // minimal size of the box
- drawy = 5;
- drawx = drawy / 2.75f;
- DrawBox(ScreenX-(drawx/2),ScreenY,drawx,-drawy,color);
- } else {
- if (Fn[3]) { // F4 explo
- DrawClaymore(ScreenX, ScreenY);
- }
- }
- }
- }
- } else if (mw2_entities[i].typ == ET_SCRIPTMOVER) {
- // HQ?
- if (DEBUG_HQ) {
- if (WorldToScreen(mw2_entities[i].pos, &ScreenX, &ScreenY)) {
- char str[128];
- sprintf_s(str, "%i/%i/%i", i, mw2_entities[i].alive, mw2_entities[i].unknown0);
- DrawString(ScreenX,ScreenY,0x7FFFFFFF,str, g_font);
- }
- }
- }
- }
- }
- //---------------------------------------------------------------------------
- void Radar()
- {
- if (!IsInGame)
- return;
- if (Fn[0]) { // F1 radar
- // Draw mini-map frame
- fillRect(rx, ry, rw, rh, 0x44000000);
- draw4Outline(rx, ry,
- rx, ry + rh,
- rx + rw, ry + rh,
- rx + rw, ry,
- 0x800000FF);
- drawPlayer(rx + rw/2, ry + rh/2, 0xFF00FF00); // myself
- for(int i = 0; i < PLAYERMAX; i++)
- {
- if ((mw2_entities[i].typ == ET_PLAYER) && mw2_entities[i].valid && (mw2_entities[i].alive & 0x0001) && (localclientnum != mw2_entities[i].clientnum))
- {
- if ( ((mw2_clientinfo[i].team == 1) || (mw2_clientinfo[i].team == 2)) && (mw2_clientinfo[i].team == my_team) ) // same team
- player[i].color = MAP_COLOR_FRIEND;
- else{
- if (mw2_clientinfo[i].perk & 0x8000000)
- player[i].color = MAP_COLOR_ENEMY_COLDBLOODED; // player has cold blood perk
- else
- player[i].color = MAP_COLOR_ENEMY;
- }
- float cx = 0, cy = 0;
- CalcPoint( mw2_entities[i].pos, &cx, &cy, 50.f );
- drawPlayer(cx, cy, player[i].color);
- }
- }
- }
- if (CALIBRATING) // calibrating radar
- {
- Vector target(0,0,0);
- float cx = 0, cy = 0;
- CalcPoint( target, &cx, &cy, 50.f );
- drawPlayer(cx, cy, 0x7FFFFFFF);
- }
- }
- //===========================================================================
- int player_locked = -1; // >=0 if locked on a player, <0 otherwise
- long player_locked_ticks = 0; // gTicks time when we locked on player
- int last_aimed_player = -1;
- Vector last_aimed_vector = Vector(0,0,0);
- void Bot()
- {
- float screen_x, screen_y;
- float angle_dist = -1;
- float angle_x, angle_y;
- int aimed_player = -1;
- Vector aimed_vector = Vector(0,0,0);
- if (!IsInGame) {
- player_locked = -1;
- return;
- }
- // following is the keys used for different aimbots
- bool tube_key = Fn[5] && (GetAsyncKeyState(VK_HOME) & 0x8000);
- bool knife_key = Fn[6] && ((GetAsyncKeyState(0X47) & 0x8000) || (GetAsyncKeyState(VK_MBUTTON) & 0x8000)); // 'G' key or middle button
- bool aim_key = Fn[4] && ((GetAsyncKeyState(VK_RBUTTON) & 0x8000) || (GetAsyncKeyState(VK_END) & 0x8000));
- if ((player_locked >= 0) && !(mw2_entities[player_locked].alive & 0x01))
- player_locked = -1; // if player dead, cancel locked tracking
- if ((player_locked >= 0) && !tube_key && !knife_key && !aim_key)
- player_locked = -1; // tracking key released
- int start_index = 0, end_index = PLAYERMAX;
- if (player_locked >= 0) { // if locked, we iterate only on the locked player
- start_index = player_locked;
- end_index = start_index + 1;
- }
- for (int i=start_index; i<end_index; i++)
- {
- if ((mw2_entities[i].typ == ET_PLAYER) && mw2_entities[i].valid && (mw2_entities[i].alive & 0x0001) && (localclientnum != mw2_entities[i].clientnum))
- {
- Vector aim_target, foot;
- if ( ((mw2_clientinfo[i].team == 1) || (mw2_clientinfo[i].team == 2)) && (mw2_clientinfo[i].team == my_team) ) // same team
- continue; // same team
- foot = mw2_entities[i].pos;
- if (MOTION) {
- if (false) { // motion compensation?
- foot = foot + (foot - last_aimed_vector); // linear compensation, we are 1 frame ahead
- }
- }
- aim_target = foot;
- if (tube_key) {
- // no correction, aim is foot
- } else if (knife_key) {
- aim_target.z += 40; // middle of bodey
- } else { // standard aiming
- if (mw2_entities[i].pose & FLAGS_CROUCHED)
- aim_target.z += 38;
- else if (mw2_entities[i].pose & FLAGS_PRONE)
- aim_target.z += 10;
- else
- aim_target.z += 48; // eye is at 60, 48 is upper chest for easy kills
- // beware that 100% headshots will tweak your stats and
- // lead you to rooms full of cheaters
- }
- if (WorldToScreen(aim_target, &screen_x, &screen_y))
- {
- float cur_angle_dist = (screen_x-screencenter[0])*(screen_x-screencenter[0]) + (screen_y-screencenter[1])*(screen_y-screencenter[1]);
- // cur_angle_dist is the squared distance in pixels between the target and the center of screen
- if ((cur_angle_dist > 1) && (cur_angle_dist < 200*200)) {
- if ((angle_dist < 0) || (cur_angle_dist < angle_dist)) {
- // we sort out the closest to the center, independantly of the player distance
- angle_dist = cur_angle_dist;
- angle_x = screen_x - screencenter[0]; // required mouse movement for x
- angle_y = screen_y - screencenter[1]; // required mouse movement for y
- aimed_player = i;
- aimed_vector = foot;
- }
- }
- }
- }
- } // for
- if ((player_locked >= 0) && !tube_key && !knife_key && (aimed_player < 0))
- player_locked = -1; // if player locked is off range, and not tube/knife, we release lock
- if ((angle_dist > 0) && (player_locked < 0) && (tube_key || knife_key || aim_key)) { // just starting a player lock sequence
- player_locked = aimed_player; //lock on player
- player_locked_ticks = gTicks; // take the timestamp of the lock
- }
- if (angle_dist > 0) {
- //if ((player_locked < 0) && (angle_dist > 0)) {
- // draw white spot on the targeted player
- drawPlayer(screencenter[0] + border_x + angle_x, screencenter[1] + border_y + angle_y, 0x3FFFFFFF);
- }
- if (player_locked >= 0)
- { // now calculating aiming
- if (tube_key || knife_key) {
- float slope;
- float velocity = tube_vel;
- Vector aim = mw2_entities[player_locked].pos;
- if (knife_key) {
- velocity = knife_vel;
- aim.z += 40; // middle of body
- }
- if (FindSlope(&aim, &mypos, velocity, &slope)) {
- aim.z = mypos.z + slope*(aim - mypos).length();
- if (WorldToScreen(aim, &screen_x, &screen_y))
- {
- angle_x = screen_x - screencenter[0] - 1; // -1 to correct an apparent 1 pixel drift right
- angle_y = screen_y - screencenter[1];
- MouseMove((angle_x / 3), (angle_y / 3));
- }
- } else {
- player_locked = -1; // if not reachable, drop the lock
- }
- } else if (aim_key) {
- // aimbot is triggered through maintained right click or END key
- // aiming is accelerated in time to better target moving players, otherwise you're
- // always aiming behind the player
- // dividing by 7 gives a rather natural while quick aiming
- // see if we need to have quicker aim
- float aim_speed = 7;
- if (gTicks - player_locked_ticks > 15)
- aim_speed = 4; // more aggressive
- if (gTicks - player_locked_ticks > 30)
- aim_speed = 2; // really locked on player
- if (gTicks - player_locked_ticks > 40)
- aim_speed = 1;
- MouseMove((angle_x / aim_speed), (angle_y / aim_speed));
- } else {
- player_locked = -1;
- }
- }
- if (CALIBRATING) { // used for calibrating the grenade speed.
- Vector aim(0,0,0);
- if (WorldToScreen(aim, &screen_x, &screen_y))
- drawPlayer(border_x + screen_x, border_y + screen_y, 0xFFFF3333);
- if (knife_key)
- {
- float slope;
- if (FindSlope(&aim, &mypos, knife_vel, &slope)) {
- aim.z = mypos.z + slope*((aim - mypos).length());
- if (WorldToScreen(aim, &screen_x, &screen_y))
- {
- angle_x = screen_x - screencenter[0] -1;
- angle_y = screen_y - screencenter[1];
- MouseMove((angle_x / 5), (angle_y / 5));
- }
- }
- }
- }
- if (MOTION) {
- last_aimed_vector = aimed_vector;
- }
- }
- //===========================================================================
- void draw4Outline(float x1, float y1, float x2, float y2,
- float x3, float y3, float x4, float y4, D3DCOLOR color)
- {
- D3DXVECTOR2 points[5];
- points[0] = D3DXVECTOR2(x1, y1);
- points[1] = D3DXVECTOR2(x2, y2);
- points[2] = D3DXVECTOR2(x3, y3);
- points[3] = D3DXVECTOR2(x4, y4);
- points[4] = D3DXVECTOR2(x1, y1);
- radar_line->Draw(points, 5, color);
- }
- //===========================================================================
- void fillRect(float x, float y, float w, float h, D3DCOLOR color)
- {
- D3DRECT r = { (int)x, (int)y, (int)(x + w), (int)(y + h)};
- g_pD3DDevice->Clear(1, &r, D3DCLEAR_TARGET, color, 0.0f, 0);
- }
- //===========================================================================
- void MouseMove(float delta_x, float delta_y)
- {
- mouse_move_x = (int) delta_x;
- mouse_move_y = (int) delta_y;
- double fScreenWidth = ::GetSystemMetrics(SM_CXSCREEN)-1;
- double fScreenHeight = ::GetSystemMetrics(SM_CYSCREEN)-1;
- double dx = 65535.0f / fScreenWidth;
- double dy = 65535.0f / fScreenHeight;
- double fx = (wndpos[0] + mouse_center[0] + delta_x) * dx;
- double fy = (wndpos[1] + mouse_center[1] + delta_y) * dy;
- INPUT input;
- memset(&input, 0, sizeof(input));
- input.type = INPUT_MOUSE;
- input.mi.dwFlags = MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE;
- input.mi.dx = (long) fx;
- input.mi.dy = (long) fy;
- ::SendInput(1,&input,sizeof(input));
- }
- //===========================================================================
- bool FindSlope(Vector *target, Vector *player, float vel, float *ftraj_slope)
- {
- double sq_vel = vel*vel;
- double z = target->z - player->z;
- double range = (*target - *player).length();
- double discr = sq_vel*sq_vel - grav*grav*range*range - 2*grav*z*sq_vel;
- if( discr < 0 ) return false; // not reachable, maybe too far
- if (GetKeyState(VK_CAPITAL) & 0x0001) // CAPSLOCK
- *ftraj_slope = (float) ( (sq_vel + sqrt(discr))/(grav*range +.000001f) ); // indirect
- else
- *ftraj_slope = (float) ( (sq_vel - sqrt(discr))/(grav*range +.000001f) ); // direct
- return (*ftraj_slope < 10) && (*ftraj_slope > -10); // ~85 degrees up or down max
- }
MW2 HACK NOT PUBLIC
By: Maik Hack | Date: Sep 2 2010 17:21 | Format: None | Expires: never | Size: 43.1 KB | Hits: 1784
Latest pastes
2 days ago
3 days ago
3 days ago
4 days ago
5 days ago