OldSchoolHack

Register / Login English

CrimeCraft ESP

icon Thread: CrimeCraft ESP

Join Date: Jan 2009

Posts: 2711

User-Rating:

17 positive
0 negative
Spoiler
CPP Code:
  1. struct Model_t
  2. {
  3. D3DXVECTOR3 Position2D;
  4. D3DXVECTOR3 Position3D;
  5. BOOL bVisible;
  6. FLOAT DepthDistance;
  7. };
  8.  
  9. std::vector<Model_t*>ModelList;
  10.  
  11. ULONG CurrentTexture[5];
  12.  
  13. FLOAT GetDistance(float Xx,float Yy,float xX,float yY)
  14. {
  15. return sqrt((yY-Yy)*(yY-Yy)+(xX-Xx)*(xX-Xx));
  16. }
  17.  
  18. VOID AddModel(IDirect3DDevice9* Device,UINT NumVertices)
  19. {
  20. D3DVIEWPORT9 Viewport;
  21. D3DXMATRIX ViewProjectionMatrix,LocalToWorld,WorldToLocal;
  22. IDirect3DVertexBuffer9 *pStreamData;
  23. IDirect3DIndexBuffer9 *pIndexData;
  24. Model_t* pModel = new Model_t;
  25. VOID* pIndex,*pData;
  26. UINT OffsetInBytes,Stride;
  27. Device->GetIndices(&pIndexData);
  28. Device->GetViewport(&Viewport);
  29. Device->GetVertexShaderConstantF(0,ViewProjectionMatrix,4);
  30. Device->GetVertexShaderConstantF(230,LocalToWorld,4);
  31. D3DXVECTOR3 VectorMiddle(0,0,0),ScreenMiddle(Viewport.Width/2,Viewport.Height/2,0);
  32. D3DXMatrixIdentity(&WorldToLocal);
  33. D3DXVec3Unproject(&VectorMiddle,&ScreenMiddle,&Viewport,&ViewProjectionMatrix,&LocalToWorld,&WorldToLocal);
  34.  
  35. if(pIndexData->Lock(0, 0, &pIndex, D3DLOCK_READONLY) == D3D_OK)
  36. {
  37. Device->GetStreamSource(0, &pStreamData, &OffsetInBytes, &Stride);
  38.  
  39. if(pStreamData->Lock(0, 0,&pData, D3DLOCK_READONLY) == D3D_OK)
  40. {
  41. D3DXVECTOR3 BoxMin,BoxMax;
  42. D3DXComputeBoundingBox((LPD3DXVECTOR3)pData,NumVertices,Stride,&BoxMin,&BoxMax);
  43. pModel->Position3D = BoxMin - ((BoxMin - BoxMax)/2);
  44. }
  45. }pIndexData->Unlock();pIndexData->Release();pStreamData->Unlock();pStreamData->Release();
  46.  
  47. D3DXVec3Project(&pModel->Position2D,&pModel->Position3D,&Viewport,&ViewProjectionMatrix,&LocalToWorld,&WorldToLocal);
  48.  
  49. pModel->DepthDistance = GetDistance(VectorMiddle.x,VectorMiddle.y,pModel->Position3D.x,pModel->Position3D.y);
  50.  
  51. if(pModel->Position2D.x > Viewport.Width || pModel->Position2D.x < 0 || pModel->Position2D.y > Viewport.Height || pModel->Position2D.y < 0 || (float)pModel->Position2D.z > 1.0f || (float)pModel->Position2D.z < 0.9f)
  52. {
  53. pModel->bVisible = D3DZB_FALSE;
  54. }else{
  55. pModel->bVisible = D3DZB_TRUE;
  56. }
  57. ModelList.push_back(pModel);
  58. }
  59.  
  60. VOID ProcessTargets(IDirect3DDevice9* Device)
  61. {
  62. if(ModelList.size() != NULL)
  63. {
  64. for(int i = 0; i < ModelList.size(); i++)
  65. {
  66. if(ModelList[i]->bVisible)
  67. {
  68. char bEspString[MAX_PATH];
  69. sprintf(bEspString,"-=|%.1f|=-",ModelList[i]->DepthDistance);
  70. iD3DFont.Draw((int)ModelList[i]->Position2D.x - (strlen(bEspString)/2*5),(int)ModelList[i]->Position2D.y,bEspString,D3DCOLOR_XRGB(50,100,255));
  71. }
  72. }
  73. ModelList.clear();
  74. }
  75. }
  76.  
  77. HRESULT (WINAPI* pEndScene)(LPDIRECT3DDEVICE9);
  78. HRESULT WINAPI myEndScene(LPDIRECT3DDEVICE9 pDevice)
  79. {
  80. if(ResourceLoaded==1)
  81. {
  82. ProcessTargets(pDevice);
  83. }
  84. return pEndScene(pDevice);
  85. }
  86.  
  87. HRESULT (WINAPI* pSetTexture)(LPDIRECT3DDEVICE9,DWORD,IDirect3DBaseTexture9*);
  88. HRESULT WINAPI mySetTexture(LPDIRECT3DDEVICE9 pDevice,DWORD Stage, IDirect3DBaseTexture9 *pTexture)
  89. {
  90. if(pTexture != NULL && pTexture->GetType() == D3DRTYPE_TEXTURE && pTexture != TextureBlue && pTexture != TextureRed)
  91. {
  92. ULONG* pTex = (ULONG*)pTexture;//modelrec...
  93. CurrentTexture[0] = pTex[8];
  94. CurrentTexture[1] = pTex[9];
  95. CurrentTexture[2] = pTex[35];
  96. }
  97. return pSetTexture(pDevice,Stage, pTexture);
  98. }
  99.  
  100. HRESULT (WINAPI* pDrawIndexedPrimitive)(LPDIRECT3DDEVICE9,D3DPRIMITIVETYPE,int,int,int,int,int);
  101. HRESULT WINAPI myDrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE pType,int BaseVertexIndex,int uiMinIndex,int NumVertices,int StartIndex,int PrimitiveCount)
  102. {
  103. if(myStride == 48)
  104. {
  105. if((CurrentTexture[0]==0x100 && CurrentTexture[1]==0x100 && CurrentTexture[2]==0x15570) || (CurrentTexture[0]==0x1 && CurrentTexture[1]==0x1 && CurrentTexture[2]==0x4))
  106. {
  107. if( NumVertices==784 || NumVertices==800 ||
  108. NumVertices==803 || NumVertices==806 ||
  109. NumVertices==801 || NumVertices==780 ||
  110. NumVertices==708 || NumVertices==750 ||
  111. NumVertices==737 || NumVertices==754 ||
  112. NumVertices==774 || NumVertices==786 ||
  113. NumVertices==783)
  114. {
  115. AddModel(pDevice,NumVertices);//just add heads, if you want another aimpoints get the right nums for them
  116. }
  117. DWORD dwOldZEnable;
  118. pDevice->SetTexture(1,TextureBlue);
  119. pDevice->GetRenderState(D3DRS_ZENABLE,&dwOldZEnable);
  120. pDevice->SetRenderState(D3DRS_ZENABLE,D3DZB_FALSE);
  121. pDrawIndexedPrimitive(pDevice,pType,BaseVertexIndex,uiMinIndex,NumVertices,StartIndex,PrimitiveCount);
  122. pDevice->SetRenderState(D3DRS_ZENABLE,dwOldZEnable);
  123. pDevice->SetTexture(1,TextureRed);
  124. }
  125. }
  126. return pDrawIndexedPrimitive(pDevice,pType,BaseVertexIndex,uiMinIndex,NumVertices,StartIndex,PrimitiveCount);
  127. }

da haste!

__________________

http://i.imgur.com/p86eYQU.gif