Структура
Создаём файл MainClass.h, подключаем его к проэкту
Код:
#include <Windows.h> #include <d3d9.h> #include <d3dx9.h> #pragma comment (lib, "d3dx9.lib") #pragma comment (lib, "d3d9.lib") class CPlayer; class CChara; class CRenderData; class CRenderContext; class CVisible; class CGameBase; class CBonesContext; class CBone; class CPlayer { public: BYTE IsLife; char Unk[79]; D3DXVECTOR2 Cross; D3DXVECTOR3 Pos; }; class CChara { public: BYTE Number; }; class CRenderData { public: CRenderContext* RenderData; }; class CRenderContext { public: char Unk[2000]; D3DXMATRIX ViewMatrix; D3DXMATRIX ProjectMatrix; D3DXMATRIX WorldMatrix; }; class CVisible { public: char Unk[0x628]; bool Visible; }; class CGameBase { public: char Unk[0x268]; CBonesContext* Bones; }; class CBonesContext { public: char Unk[0xB8]; CBone* BoneData; }; class CBone { public: D3DXMATRIX BoneMatrix; };
Тоже очень нужное
Теперь переходим в главный файл.
Код:
bool WorldToScreen(D3DXVECTOR3 inpos, D3DXVECTOR3 &outpos, LPDIRECT3DDEVICE9 pDevice) { DWORD dwRenderData = (DWORD)GetModuleHandleA("i3GfxDx.dll") + 0x18B0D4; CRenderData* RenderData = (CRenderData*)(dwRenderData); D3DXMATRIX identity; D3DXVECTOR3 vScreen; D3DVIEWPORT9 g_ViewPort; pDevice->GetViewport(&g_ViewPort); g_ViewPort.X = g_ViewPort.Y = 0; g_ViewPort.MinZ = 0; g_ViewPort.MaxZ = 1; D3DXVec3Project(&vScreen, &inpos, &g_ViewPort, &RenderData->RenderData->ProjectMatrix, &RenderData->RenderData->ViewMatrix, &RenderData->RenderData->WorldMatrix); if (vScren.z < 1.0f && vScren.x > 0.0f && vScren.y > 0.0f && vScren.x < g_ViewPort.Width && vScren.y < g_ViewPort.Height) { outpos.x = vScren.x; outpos.y = vScren.y; outpos.z = vScren.z; return true; } return false; } int GetCharaIndex( ) { DWORD dwGameContext = *(DWORD*)0x00AA39C8; CChara* User = (CChara*)(dwGameContext + 0x4E18); return User->Number; } bool GetUserLife( int Idx ) { DWORD dwGameContext = *(DWORD*)0x00AA39C8; CPlayer* User = (CPlayer*)((dwGameContext + 0x6120) + 0x11B4 * Idx); return User->IsLife; } D3DXVECTOR3 GetUserVector( int Idx ) { DWORD dwGameContext = *(DWORD*)0x00AA39C8; CPlayer* User = (CPlayer*)((dwGameContext + 0x6120) + 0x11B4 * Idx); return User->Pos; } bool GetVisible( int Idx ) { DWORD dwGameBase = *(DWORD*)0x00AA3994; if ( dwGameBase ) { CVisible* VisibleCheck = (CVisible*)( *(DWORD*)(dwGameBase + 0x68 + ( 0x4 * Idx ) ) ); return VisibleCheck->Visible; } return false; } bool GetUserBone( D3DXVECTOR3 &Out, int Idx, int BoneIdx ) { DWORD dwGameBase = *(DWORD*)0x00AA3994; if ( dwGameBase ) { CGameBase* GameBase = (CGameBase*)( *(DWORD*)(dwGameBase + 0x68 + ( 0x4 * Idx ) ) ); if ( GameBase && GameBase->Bones ) { Out.x = GameBase->Bones->BoneData[ BoneIdx ].BoneMatrix._41; Out.y = GameBase->Bones->BoneData[ BoneIdx ].BoneMatrix._42; Out.z = GameBase->Bones->BoneData[ BoneIdx ].BoneMatrix._43; return true; } } return false; } DWORD dwEnd = 0x0062FF0D; DWORD dwReturnEnd = dwEnd + 7; float fX = 10.0f, fY = 10.0f, fZ = 10.0f; DWORD dwTempEcx, dwTempEbx; bool EndEnable; _declspec( naked ) void End( ) { if ( EndEnable ) { _asm { mov [dwTempEcx], ecx; mov [dwTempEbx], ebx; mov ecx, [ebp+0x0C]; mov ebx, [fX]; mov [ecx], ebx; mov ebx, [fY]; mov [ecx+0x08], ebx; mov ebx, [fZ]; mov [ecx+0x08], ebx; mov ecx, [dwTempEcx]; mov ebx, [dwTempEbx]; } } _asm { mov eax, [ebp+0x08]; push eax; mov ecx, [ebp-0x1C]; jmp dwReturnEnd; } } float CalcDistance( D3DXVECTOR3 VecA, D3DXVECTOR3 VecB ) { return sqrt( ( ( VecA.x - VecB.x ) * ( VecA.x - VecB.x ) ) + ( ( VecA.y - VecB.y ) * ( VecA.y - VecB.y ) ) + ( ( VecA.z - VecB.z ) * ( VecA.z - VecB.z ) ) ); } int GetPriorityTarget( ) { int Result = -1; float fMaxDistance = 1000.0f; for ( int a = 0; a < 16; a++ ) { if ( !GetUserLife( a ) && GetCharaIndex( ) != a ) { D3DXVECTOR3 Head; if ( GetCharaIndex( ) %2 != a % 2 && GetUserBone( Head, a, 7 ) ) { if ( CalcDistance( GetUserVector( GetCharaIndex( ) ), GetUserVector( a ) ) < fMaxDistance ) { fMaxDistance = CalcDistance( GetUserVector( GetCharaIndex( ) ), GetUserVector( a ) ) < fMaxDistance; Result = a; } } } } return Result; }
Функция
В EndScene вставляем
Код:
int Priority = GetPriorityTarget( ); if ( название функции )//Тут мы рисуем кости { for ( int n = 0; n < 16; n++ ) { for ( int y = 0; y < 16; y++ ) { D3DXVECTOR3 OnScreen, OnWorld; if ( GetUserBone( OnWorld, n, y ) ) { if ( WorldToScreen( OnWorld, OnScreen, pDevice ) ) { DrawBox( (int)OnScreen.x-3, (int)OnScreen.y-3, 5, 5, цвет костей, pDevice ); } } } } } if(название функции)//Тут наводим на голову { if ( Priority != -1 ) { D3DXVECTOR3 OnScreen, OnWorld; if ( DxESP->GetUserBone( OnWorld, Priority, 7 ) ) { fX = OnWorld.x; fY = OnWorld.y; fZ = OnWorld.z; if ( DxESP->WorldToScreen( OnWorld, OnScreen, pDevice ) ) { DrawBox( OnScreen.x-3, OnScreen.y-3, 5, 5, GREEN, pDevice ); } } } } if(GetAsyncKeyState(VK_CONTROL))// При зажатии какой кнопки будет захват цели. {EndEnable = true;}else{EndEnable = false;} } DetourCreate((PBYTE)dwEnd, (PBYTE)End, 7);//AIM
Вот сообственно и всё.
З.Ы. Тут есть небольшие ошибки.